Coder Social home page Coder Social logo

exzap / cafeglsl Goto Github PK

View Code? Open in Web Editor NEW

This project forked from notaz/mesa

19.0 3.0 3.0 543.23 MB

Wii U GLSL compiler based on Mesa

Shell 0.18% C++ 18.97% Python 2.32% C 75.52% Emacs Lisp 0.01% Objective-C 0.01% Lua 0.03% Assembly 1.36% Rust 0.38% PowerShell 0.03% XSLT 0.01% Makefile 0.02% CMake 0.01% LLVM 0.04% GLSL 0.11% Yacc 0.31% Lex 0.07% Meson 0.65% Jinja 0.01%

cafeglsl's Introduction

CafeGLSL - Shader Compiler for Wii U

This project is an experimental runtime GLSL shader compiler library for the Wii U. It's implemented as a fork of Mesa. The compiler is currently designed for runtime use, meaning you invoke it from your application to compile shaders on the fly. It's not designed to be used as a standalone tool, but support for this may be added in the future.

Why make this? By default, Wii U offers no way to compile shaders dynamically during runtime, yet many games, render API translation layers and other dependencies rely on this. This project is intended to fill this void.

⚠️ Warning

This library is still in its experimental stage. While it lacks some features and likely contains bugs, it's released early in the hopes that the community can already start benefiting.

Current Limitations:

  • Supports only separable shaders. All binding locations for textures, in/out varyings and uniform buffers need to be explicit
  • No support for geometry/compute/tesselation shaders
  • No uniform register support, all uniforms are read via buffers. Uniforms declared outside of blocks will be mapped to a virtual block bound to buffer 15.

Shaders may still compile even if you break these rules, but they will likely not function as you expect.

Usage

To use the shader compiler:

  1. Copy cafecompiler/CafeGLSLCompiler.h into your project's source directory and include it.
  2. Install glslcompiler.rpl
    • For Aroma: Copy glslcompiler.rpl to sd:/wiiu/libs/glslcompiler.rpl
    • For Cemu: Find the Cemu data folder, on Windows this is where Cemu.exe is. Create a folder called cafeLibs and copy glslcompiler.rpl into it.
    • For Decaf: Copy glslcompiler.rpl into the code folder of the title. But note that the shaders currently cause Decaf to assert.

Currently, the shader compiler is only available as a Wii U dynamic library (.rpl)

Example:

To initialize the compiler:

GLSL_Init();

To compile shaders:

WHBGfxShaderGroup* GLSL_CompileShader(const char* vsSrc, const char* psSrc) 
{
    char infoLog[1024];
    GX2VertexShader* vs = GLSL_CompileVertexShader(vsSrc, infoLog, sizeof(infoLog), GLSL_COMPILER_FLAG_NONE);
    if(!vs) {
        OSReport("Failed to compile vertex shader. Infolog: %s\n", infoLog);
        return NULL;
    }
    GX2PixelShader* ps = GLSL_CompilePixelShader(psSrc, infoLog, sizeof(infoLog), GLSL_COMPILER_FLAG_NONE);
    if(!ps) {
        OSReport("Failed to compile pixel shader. Infolog: %s\n", infoLog);
        return NULL;
    }
    WHBGfxShaderGroup* shaderGroup = (WHBGfxShaderGroup*)malloc(sizeof(WHBGfxShaderGroup));
    memset(shaderGroup, 0, sizeof(*shaderGroup));
    shaderGroup->vertexShader = vs;
    shaderGroup->pixelShader = ps;
    return shaderGroup;
}

How to compile

Note: If you just want to use the shader compiler in your project, you can grab a precompiled binary from the releases page.

Setup a Linux or WSL environment in the usual way for Wii U homebrew development. Then additionally you need:

  1. Meson - Mesa uses the Meson build system. You can get it from your system package manager.
  2. For Meson and Mesa you need these additional system packages (the names may differ on non-Debian based distros):
    • python3, python3-setuptools, python3-mako, bison, flex
  3. Additional dependencies from devkitPro pacman:
    • dkp-meson-scripts
    • dkp-toolchain-vars
  4. ⚠️ Requires WUT with the changes from PR 325. As of writing this, the PR has not yet been merged.

Compile for Wii U using:

./cafecompiler/compile_for_cafe.sh

Troublshooting and contributing

If you have any problems using this, please open a github issue. I'll try to help as much as I can.
I would also appreciate any help with this project and PRs are very welcome!

📜 License

For original Mesa code see https://docs.mesa3d.org/license.html
Any additions by this fork are licensed under MIT.

cafeglsl's People

Contributors

1ace avatar airlied avatar anholt avatar bbrezillon avatar bnieuwenhuizen avatar brianpaul avatar curro avatar cwabbott0 avatar evelikov avatar freedreno-zz avatar gfxstrand avatar hakzsam avatar ianromanick avatar imirkin avatar itoral avatar jrfonseca avatar kaydenl avatar krh avatar kusma avatar llandwerlin-intel avatar marekolsak avatar mattst88 avatar nhaehnle avatar olvaffe avatar pendingchaos avatar tarceri avatar versalinyaa avatar vinsonlee avatar wallbraker avatar zmike avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.