diff --git a/misc/wiiu/assembler.sh b/misc/wiiu/assembler.sh index abf20d5b9..47f2aae1a 100755 --- a/misc/wiiu/assembler.sh +++ b/misc/wiiu/assembler.sh @@ -6,10 +6,12 @@ assemble() $ASSEMBLER assemble $1 --vsh $2 --psh $3 } -assemble coloured_none.gsh vs_coloured.vsh ps_coloured_none.psh +assemble coloured_none.gsh vs_coloured.vsh ps_coloured_none.psh -assemble textured_none.gsh vs_textured.vsh ps_textured_none.psh -assemble textured_lin.gsh vs_textured.vsh ps_textured_lin.psh -assemble textured_exp.gsh vs_textured.vsh ps_textured_exp.psh +assemble textured_none.gsh vs_textured.vsh ps_textured_none.psh +assemble textured_lin.gsh vs_textured.vsh ps_textured_lin.psh +assemble textured_exp.gsh vs_textured.vsh ps_textured_exp.psh -assemble textured_ofst.gsh vs_textured_offset.vsh ps_textured_none.psh +assemble offset_none.gsh vs_offset.vsh ps_textured_none.psh +assemble offset_lin.gsh vs_offset.vsh ps_textured_lin.psh +assemble offset_exp.gsh vs_offset.vsh ps_textured_exp.psh diff --git a/misc/wiiu/offset_exp.gsh b/misc/wiiu/offset_exp.gsh new file mode 100644 index 000000000..49b5ab4fb Binary files /dev/null and b/misc/wiiu/offset_exp.gsh differ diff --git a/misc/wiiu/offset_lin.gsh b/misc/wiiu/offset_lin.gsh new file mode 100644 index 000000000..200a460fb Binary files /dev/null and b/misc/wiiu/offset_lin.gsh differ diff --git a/misc/wiiu/textured_ofst.gsh b/misc/wiiu/offset_none.gsh similarity index 100% rename from misc/wiiu/textured_ofst.gsh rename to misc/wiiu/offset_none.gsh diff --git a/misc/wiiu/vs_textured_offset.glsl b/misc/wiiu/vs_offset.glsl similarity index 100% rename from misc/wiiu/vs_textured_offset.glsl rename to misc/wiiu/vs_offset.glsl diff --git a/misc/wiiu/vs_textured_offset.vsh b/misc/wiiu/vs_offset.vsh similarity index 100% rename from misc/wiiu/vs_textured_offset.vsh rename to misc/wiiu/vs_offset.vsh diff --git a/src/Graphics_WiiU.c b/src/Graphics_WiiU.c index b8daad6c6..f9cc8b350 100644 --- a/src/Graphics_WiiU.c +++ b/src/Graphics_WiiU.c @@ -73,7 +73,9 @@ extern const uint8_t coloured_none_gsh[]; extern const uint8_t textured_none_gsh[]; extern const uint8_t textured_lin_gsh[]; extern const uint8_t textured_exp_gsh[]; -extern const uint8_t textured_ofst_gsh[]; +extern const uint8_t offset_none_gsh[]; +extern const uint8_t offset_lin_gsh[]; +extern const uint8_t offset_exp_gsh[]; #define VS_UNI_OFFSET_MVP 0 #define VS_UNI_COUNT_MVP 16 @@ -85,8 +87,17 @@ extern const uint8_t textured_ofst_gsh[]; #define PS_UNI_OFFSET_FOG 4 #define PS_UNI_COUNT_FOG 4 -static GX2VertexShader *texture_VS, *colour_VS, *offset_VS; -static GX2PixelShader *texture_PS[3], *colour_PS[3]; +struct ShaderProgram { + GX2VertexShader* vs; + GX2PixelShader* ps; +}; + +static struct ShaderProgram colour_PG, texture_PG[3], offset_PG[3]; + +static void LoadProgram(struct ShaderProgram* prog, const cc_uint8* gsh) { + prog->vs = WHBGfxLoadGFDVertexShader(0, gsh); + prog->ps = WHBGfxLoadGFDPixelShader(0, gsh); +} static GX2Sampler sampler; static GfxResourceID white_square; @@ -98,40 +109,39 @@ static void InitGfx(void) { CompileFetchShaders(); GX2InitSampler(&sampler, GX2_TEX_CLAMP_MODE_WRAP, GX2_TEX_XY_FILTER_MODE_POINT); - colour_VS = WHBGfxLoadGFDVertexShader(0, coloured_none_gsh); - colour_PS[0] = WHBGfxLoadGFDPixelShader(0, coloured_none_gsh); + LoadProgram(&colour_PG, coloured_none_gsh); - texture_VS = WHBGfxLoadGFDVertexShader(0, textured_none_gsh); + LoadProgram(&texture_PG[0], textured_none_gsh); + LoadProgram(&texture_PG[1], textured_lin_gsh); + LoadProgram(&texture_PG[2], textured_exp_gsh); - offset_VS = WHBGfxLoadGFDVertexShader(0, textured_ofst_gsh); - - texture_PS[0] = WHBGfxLoadGFDPixelShader(0, textured_none_gsh); - texture_PS[1] = WHBGfxLoadGFDPixelShader(0, textured_lin_gsh); - texture_PS[2] = WHBGfxLoadGFDPixelShader(0, textured_exp_gsh); + LoadProgram(&offset_PG[0], offset_none_gsh); + LoadProgram(&offset_PG[1], offset_lin_gsh); + LoadProgram(&offset_PG[2], offset_exp_gsh); } static struct Vec4 texOffset; static void UpdateVS(void) { if (gfx_format != VERTEX_FORMAT_TEXTURED) { - cur_VS = colour_VS; + cur_VS = colour_PG.vs; } else if (texOffset.x || texOffset.y) { - cur_VS = offset_VS; + cur_VS = offset_PG[0].vs; } else { - cur_VS = texture_VS; + cur_VS = texture_PG[0].vs; } GX2SetVertexShader(cur_VS); } static void UpdatePS(void) { if (gfx_format != VERTEX_FORMAT_TEXTURED) { - cur_PS = colour_PS[0]; + cur_PS = colour_PG.ps; /*} else if (gfx_fogEnabled && fog_func == FOG_EXP) { cur_PS = texture_PS[2]; } else if (gfx_fogEnabled && fog_func == FOG_LINEAR) { cur_PS = texture_PS[1]; */} else { - cur_PS = texture_PS[0]; + cur_PS = texture_PG[0].ps; } GX2SetPixelShader(cur_PS); } @@ -223,7 +233,7 @@ void Gfx_BindTexture(GfxResourceID texId) { } static void BindPendingTexture(void) { - if (!pendingTex || cur_VS == colour_VS) return; + if (!pendingTex || cur_VS == colour_PG.vs) return; GX2SetPixelTexture(pendingTex, cur_PS->samplerVars[0].location); GX2SetPixelSampler(&sampler, cur_PS->samplerVars[0].location);