Hello,
I've been kicking around this project in my head since around the time of release of Ninjhax 1. This is more or less a pre-release and very much a WIP. Selena is a shader compiler that aims to translate GLSL-esque code into shader assembly. Currently, it can generate very rudimentary code for Nihstro, however, the main goal is to link against the project as a library and produce a shader binary directly that can be immediately fed into ctrulib, your preferred OpenGL implementation, or other graphics libraries.
It doesn't yet perform type checking, error handling, swizzling or any other fancy features. They're important and are on my todo list.
Pre-builts will not be provided until the project is much more matured.
Building:
This will produce an offline compiler to be used within a toolchain and a run-time library to optionally link against.
Usage:
Options:
Inline assembly:
Source: https://github.com/machinamentum/Selena
Examples: https://github.com/machinamentum/selena-examples
I've been kicking around this project in my head since around the time of release of Ninjhax 1. This is more or less a pre-release and very much a WIP. Selena is a shader compiler that aims to translate GLSL-esque code into shader assembly. Currently, it can generate very rudimentary code for Nihstro, however, the main goal is to link against the project as a library and produce a shader binary directly that can be immediately fed into ctrulib, your preferred OpenGL implementation, or other graphics libraries.
It doesn't yet perform type checking, error handling, swizzling or any other fancy features. They're important and are on my todo list.
Pre-builts will not be provided until the project is much more matured.
Building:
Code:
git clone https://github.com/machinamentum/Selena.git
cd Selena
mkdir build
cd build
cmake ..
make
make install
Usage:
Code:
selenacc my_GLSL_shader.vsh -o my_shader.shbin
Options:
Code:
-o <output> | Select output file
-h,--help | Show this help message
--verbose | Print parse and syntax tree structures
-S | Output nihstro assembler
Inline assembly:
The compiler supports robust inline assembly. Syntax:
Example:
rsq is the reciprocal square root instruction. @0 is a special directive to the compiler that gets the first temporary register that is unused. @1, @2, @3, @<number> references the list of variables following the command string in sequential order, beginning with 1, and retrieves the register or alias assigned to that variable.
Code:
asm("<opcode> <dst>, <src1>[,<src2>,<src3>]", <variable list>)
Code:
asm("rsq @0, @1", Value);
Examples: https://github.com/machinamentum/selena-examples
Last edited by machinamentum,