Add complete shader sources
This commit is contained in:
parent
f2ffab48e1
commit
a112001886
6 changed files with 109 additions and 0 deletions
8
src/Backends/WiiU/shader sources/fragmentshader.frag
Normal file
8
src/Backends/WiiU/shader sources/fragmentshader.frag
Normal file
|
@ -0,0 +1,8 @@
|
|||
#version 150 core
|
||||
layout(location = 0) uniform sampler2D tex;
|
||||
in vec2 texture_coordinates;
|
||||
out vec4 fragment;
|
||||
void main()
|
||||
{
|
||||
fragment = texture(tex, texture_coordinates);
|
||||
}
|
18
src/Backends/WiiU/shader sources/fragmentshader.psh
Normal file
18
src/Backends/WiiU/shader sources/fragmentshader.psh
Normal file
|
@ -0,0 +1,18 @@
|
|||
; $MODE = "UniformRegister"
|
||||
; $SAMPLER_VARS[0].name= "tex"
|
||||
; $SAMPLER_VARS[0].type= "sampler2D"
|
||||
; $SAMPLER_VARS[0].location = 0
|
||||
; $NUM_SPI_PS_INPUT_CNTL = 1
|
||||
; $SPI_PS_INPUT_CNTL[0].semantic = 0
|
||||
; $SPI_PS_INPUT_CNTL[0].default_val = 1
|
||||
; $UNIFORM_VARS[0].name = "texture_coordinates"
|
||||
; $UNIFORM_VARS[0].type = "vec2"
|
||||
; $UNIFORM_VARS[0].count = 1
|
||||
; $UNIFORM_VARS[0].offset = 0
|
||||
; $UNIFORM_VARS[0].block = -1
|
||||
|
||||
00 TEX: ADDR(32) CNT(1) VALID_PIX
|
||||
0 SAMPLE R0, R0.xy0x, t0, s0
|
||||
01 EXP_DONE: PIX0, R0
|
||||
END_OF_PROGRAM
|
||||
|
9
src/Backends/WiiU/shader sources/vertexshader.vert
Normal file
9
src/Backends/WiiU/shader sources/vertexshader.vert
Normal file
|
@ -0,0 +1,9 @@
|
|||
#version 150 core
|
||||
layout(location = 0) in vec4 input_vertex_coordinates;
|
||||
layout(location = 1) in vec2 input_texture_coordinates;
|
||||
out vec2 texture_coordinates;
|
||||
void main()
|
||||
{
|
||||
gl_Position = input_vertex_coordinates;
|
||||
texture_coordinates = input_texture_coordinates;
|
||||
}
|
27
src/Backends/WiiU/shader sources/vertexshader.vsh
Normal file
27
src/Backends/WiiU/shader sources/vertexshader.vsh
Normal file
|
@ -0,0 +1,27 @@
|
|||
; $MODE = "UniformRegister"
|
||||
; $ATTRIB_VARS[0].name = "input_texture_coordinates"
|
||||
; $ATTRIB_VARS[0].type = "vec2"
|
||||
; $ATTRIB_VARS[0].location = 1
|
||||
; $ATTRIB_VARS[1].name = "input_vertex_coordinates"
|
||||
; $ATTRIB_VARS[1].type = "vec2"
|
||||
; $ATTRIB_VARS[1].location = 0
|
||||
; $NUM_SPI_VS_OUT_ID = 1
|
||||
; $SPI_VS_OUT_ID[0].SEMANTIC_0 = 0
|
||||
|
||||
00 CALL_FS NO_BARRIER
|
||||
01 ALU: ADDR(32) CNT(2)
|
||||
0 x: MOV R1.x, R1.x
|
||||
y: MOV R1.y, R1.y
|
||||
02 EXP_DONE: POS0, R2
|
||||
03 EXP_DONE: PARAM0, R1.xyzz NO_BARRIER
|
||||
04 ALU: ADDR(34) CNT(1)
|
||||
1 x: NOP ____
|
||||
05 NOP NO_BARRIER
|
||||
END_OF_PROGRAM
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
47
src/Backends/WiiU/shader sources/wtf is this.txt
Normal file
47
src/Backends/WiiU/shader sources/wtf is this.txt
Normal file
|
@ -0,0 +1,47 @@
|
|||
I'mma give it to you straight: compiling shaders for the Wii U is an absolute
|
||||
nightmare.
|
||||
|
||||
You see, there are three major steps:
|
||||
* Compile the GLSL to assembly
|
||||
* Fill in a header by-hand
|
||||
* Assemble the assembly + header
|
||||
|
||||
To compile, you need AMD's 'GPU ShaderAnalyzer', which is Windows-only:
|
||||
https://gpuopen.com/archive/gpu-shaderanalyzer/
|
||||
|
||||
You then need to compile for the RV730.
|
||||
|
||||
After that, you need to fill-in a header. The only way I was able to figure out
|
||||
what little I did was by finding examples on the internet:
|
||||
https://github.com/snickerbockers/gx2gl/tree/master/src/shaders
|
||||
https://github.com/yawut/SDL/tree/wiiu-2.0.9/src/video/wiiu/shaders
|
||||
https://github.com/devkitPro/wut/tree/master/samples/cmake/content
|
||||
|
||||
Even now, I don't have a complete idea of exactly what everything means.
|
||||
|
||||
Anyway, once you have *that* out of the way, you still need to assemble your
|
||||
shaders. For that, you'll need `latte-assembler` - a tool that comes with the
|
||||
Decaf emulator.
|
||||
|
||||
For me, I needed to clone the entire source tree (and its dependencies) in order
|
||||
to build the tool successfully, which is a royal pain in the ass.
|
||||
|
||||
For compilation, I used MSYS2+MinGW-w64. There were a couple of compilation
|
||||
errors I had to address, but nothing too hard to solve.
|
||||
|
||||
Eventually you'll have the assembler built. With it, you can link your `.psh`
|
||||
and `.vsh` files into the final `.gsh` blob.
|
||||
|
||||
Oh, right. I should warn you - the devs changed latte-assembler's syntax at some
|
||||
point, so all the example `.psh`/`.vsh` files I could fine online were
|
||||
incompatible. That sucked. The main change was that stuff like 'float2' and
|
||||
'float4' were changed to 'vec2' and 'vec4'. Just keep that in mind, and you
|
||||
should be okay.
|
||||
|
||||
Also, latte-assembler's 'assemble' command was originally named 'compile', and
|
||||
the other 'compile' option didn't exist. Keep that in mind if you ever find any
|
||||
documentation on how to use the tool.
|
||||
|
||||
latte-assembler does have an option to convert straight from GLSL to `.gsh`, but
|
||||
this feature is woefully incomplete (it doesn't support `sampler2D`), and not
|
||||
worth using.
|
Loading…
Add table
Reference in a new issue