diff --git a/src/render/wiiu/SDL_rdraw_wiiu.c b/src/render/wiiu/SDL_rdraw_wiiu.c index 113c1fe4e..928153e92 100644 --- a/src/render/wiiu/SDL_rdraw_wiiu.c +++ b/src/render/wiiu/SDL_rdraw_wiiu.c @@ -127,9 +127,9 @@ int WIIU_SDL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, GX2SetPixelSampler(&tdata->sampler, 0); GX2RSetAttributeBuffer(a_position, 0, a_position->elemSize, 0); GX2RSetAttributeBuffer(a_texCoord, 1, a_texCoord->elemSize, 0); - GX2SetVertexUniformReg(wiiuTextureShader.vertexShader->uniformVars[0].offset, 4, (uint32_t *)data->u_viewSize); - GX2SetVertexUniformReg(wiiuTextureShader.vertexShader->uniformVars[1].offset, 4, (uint32_t *)tdata->u_texSize); - GX2SetPixelUniformReg(wiiuTextureShader.pixelShader->uniformVars[0].offset, 4, (uint32_t*)&u_mod); + GX2SetVertexUniformReg(wiiuTextureShader.vertexShader->uniformVars[0].offset, 4, (uint32_t *)&data->u_viewSize); + GX2SetVertexUniformReg(wiiuTextureShader.vertexShader->uniformVars[1].offset, 4, (uint32_t *)&tdata->u_texSize); + GX2SetPixelUniformReg(wiiuTextureShader.pixelShader->uniformVars[0].offset, 4, (uint32_t *)&u_mod); WIIU_SDL_SetGX2BlendMode(texture->blendMode); GX2DrawEx(GX2_PRIMITIVE_MODE_QUADS, 4, 0, 1); @@ -239,9 +239,9 @@ int WIIU_SDL_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture, GX2SetPixelSampler(&tdata->sampler, 0); GX2RSetAttributeBuffer(a_position, 0, a_position->elemSize, 0); GX2RSetAttributeBuffer(a_texCoord, 1, a_texCoord->elemSize, 0); - GX2SetVertexUniformReg(wiiuTextureShader.vertexShader->uniformVars[0].offset, 4, (uint32_t *)data->u_viewSize); - GX2SetVertexUniformReg(wiiuTextureShader.vertexShader->uniformVars[1].offset, 4, (uint32_t *)tdata->u_texSize); - GX2SetPixelUniformReg(wiiuTextureShader.pixelShader->uniformVars[0].offset, 4, (uint32_t*)&u_mod); + GX2SetVertexUniformReg(wiiuTextureShader.vertexShader->uniformVars[0].offset, 4, (uint32_t *)&data->u_viewSize); + GX2SetVertexUniformReg(wiiuTextureShader.vertexShader->uniformVars[1].offset, 4, (uint32_t *)&tdata->u_texSize); + GX2SetPixelUniformReg(wiiuTextureShader.pixelShader->uniformVars[0].offset, 4, (uint32_t *)&u_mod); WIIU_SDL_SetGX2BlendMode(texture->blendMode); GX2DrawEx(GX2_PRIMITIVE_MODE_QUADS, 4, 0, 1); @@ -286,8 +286,8 @@ int WIIU_SDL_RenderDrawPoints(SDL_Renderer * renderer, const SDL_FPoint * points GX2SetContextState(data->ctx); wiiuSetColorShader(); GX2RSetAttributeBuffer(a_position, 0, a_position->elemSize, 0); - GX2SetVertexUniformReg(wiiuColorShader.vertexShader->uniformVars[0].offset, 4, (uint32_t *)data->u_viewSize); - GX2SetPixelUniformReg(wiiuColorShader.pixelShader->uniformVars[0].offset, 4, (uint32_t*)&u_colour); + GX2SetVertexUniformReg(wiiuColorShader.vertexShader->uniformVars[0].offset, 4, (uint32_t *)&data->u_viewSize); + GX2SetPixelUniformReg(wiiuColorShader.pixelShader->uniformVars[0].offset, 4, (uint32_t *)&u_colour); WIIU_SDL_SetGX2BlendMode(renderer->blendMode); GX2DrawEx(GX2_PRIMITIVE_MODE_POINTS, count, 0, 1); @@ -333,8 +333,8 @@ int WIIU_SDL_RenderDrawLines(SDL_Renderer * renderer, const SDL_FPoint * points, GX2SetContextState(data->ctx); wiiuSetColorShader(); GX2RSetAttributeBuffer(a_position, 0, a_position->elemSize, 0); - GX2SetVertexUniformReg(wiiuColorShader.vertexShader->uniformVars[0].offset, 4, (uint32_t *)data->u_viewSize); - GX2SetPixelUniformReg(wiiuColorShader.pixelShader->uniformVars[0].offset, 4, (uint32_t*)&u_colour); + GX2SetVertexUniformReg(wiiuColorShader.vertexShader->uniformVars[0].offset, 4, (uint32_t *)&data->u_viewSize); + GX2SetPixelUniformReg(wiiuColorShader.pixelShader->uniformVars[0].offset, 4, (uint32_t *)&u_colour); WIIU_SDL_SetGX2BlendMode(renderer->blendMode); GX2DrawEx(GX2_PRIMITIVE_MODE_LINE_STRIP, count, 0, 1); @@ -394,8 +394,8 @@ int WIIU_SDL_RenderFillRects(SDL_Renderer * renderer, const SDL_FRect * rects, i GX2SetContextState(data->ctx); wiiuSetColorShader(); GX2RSetAttributeBuffer(a_position, 0, a_position->elemSize, 0); - GX2SetVertexUniformReg(wiiuColorShader.vertexShader->uniformVars[0].offset, 4, (uint32_t *)data->u_viewSize); - GX2SetPixelUniformReg(wiiuColorShader.pixelShader->uniformVars[0].offset, 4, (uint32_t*)&u_colour); + GX2SetVertexUniformReg(wiiuColorShader.vertexShader->uniformVars[0].offset, 4, (uint32_t *)&data->u_viewSize); + GX2SetPixelUniformReg(wiiuColorShader.pixelShader->uniformVars[0].offset, 4, (uint32_t *)&u_colour); WIIU_SDL_SetGX2BlendMode(renderer->blendMode); GX2DrawEx(GX2_PRIMITIVE_MODE_QUADS, 4 * count, 0, 1); diff --git a/src/render/wiiu/SDL_render_wiiu.c b/src/render/wiiu/SDL_render_wiiu.c index 20ca64072..d683786e2 100644 --- a/src/render/wiiu/SDL_render_wiiu.c +++ b/src/render/wiiu/SDL_render_wiiu.c @@ -144,8 +144,10 @@ int WIIU_SDL_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture) } // Update u_viewSize - data->u_viewSize[0] = target->surface.width; - data->u_viewSize[1] = target->surface.height; + data->u_viewSize = (WIIUVec4) { + .x = (float)target->surface.width, + .y = (float)target->surface.height, + }; // Update context state GX2SetContextState(data->ctx); diff --git a/src/render/wiiu/SDL_render_wiiu.h b/src/render/wiiu/SDL_render_wiiu.h index da7b28014..54e6da3e5 100644 --- a/src/render/wiiu/SDL_render_wiiu.h +++ b/src/render/wiiu/SDL_render_wiiu.h @@ -31,6 +31,24 @@ #include #include +typedef struct { + union { float x, r; }; + union { float y, g; }; +} WIIUVec2; + +typedef struct { + union { float x, r; }; + union { float y, g; }; + union { float z, b; }; +} WIIUVec3; + +typedef struct { + union { float x, r; }; + union { float y, g; }; + union { float z, b; }; + union { float w, a; }; +} WIIUVec4; + typedef struct { void *next; @@ -38,20 +56,18 @@ typedef struct } WIIU_RenderAllocData; //Driver internal data structures -typedef struct -{ +typedef struct { GX2ContextState *ctx; WIIU_RenderAllocData *listfree; - float u_viewSize[4]; + WIIUVec4 u_viewSize; SDL_Texture windowTex; } WIIU_RenderData; -typedef struct -{ +typedef struct { GX2Sampler sampler; GX2Texture texture; GX2ColorBuffer cbuf; - float u_texSize[4]; + WIIUVec4 u_texSize; } WIIU_TextureData; static inline GX2RBuffer* WIIU_AllocRenderData(WIIU_RenderData *r, GX2RBuffer buffer) { @@ -131,22 +147,6 @@ static inline Uint32 TextureNextPow2(Uint32 w) { return n; } -typedef struct { - union { float x, r; }; - union { float y, g; }; -} WIIUVec2; -typedef struct { - union { float x, r; }; - union { float y, g; }; - union { float z, b; }; -} WIIUVec3; -typedef struct { - union { float x, r; }; - union { float y, g; }; - union { float z, b; }; - union { float w, a; }; -} WIIUVec4; - typedef struct WIIUPixFmt { GX2SurfaceFormat fmt; uint32_t compMap; diff --git a/src/render/wiiu/SDL_rpresent_wiiu.c b/src/render/wiiu/SDL_rpresent_wiiu.c index 421abd30a..c04e4c3fa 100644 --- a/src/render/wiiu/SDL_rpresent_wiiu.c +++ b/src/render/wiiu/SDL_rpresent_wiiu.c @@ -17,14 +17,14 @@ #define SCREEN_WIDTH 1280 #define SCREEN_HEIGHT 720 -static const float u_viewSize[4] = {(float)SCREEN_WIDTH, (float)SCREEN_HEIGHT}; +static const WIIUVec4 u_viewSize = {.x = (float)SCREEN_WIDTH, .y = (float)SCREEN_HEIGHT}; static void render_scene(SDL_Renderer * renderer) { WIIU_RenderData *data = (WIIU_RenderData *) renderer->driverdata; WIIU_TextureData *tdata = (WIIU_TextureData *) data->windowTex.driverdata; - float tex_w = tdata->u_texSize[0]; - float tex_h = tdata->u_texSize[1]; + float tex_w = tdata->u_texSize.x; + float tex_h = tdata->u_texSize.y; int win_x, win_y, win_w, win_h; GX2RBuffer *a_position, *a_texCoord; WIIUVec2 *a_position_vals, *a_texCoord_vals; @@ -85,8 +85,8 @@ static void render_scene(SDL_Renderer * renderer) { WHBGfxClearColor(0.0f, 0.0f, 0.0f, 1.0f); wiiuSetTextureShader(); - GX2SetVertexUniformReg(wiiuTextureShader.vertexShader->uniformVars[0].offset, 4, (uint32_t *)u_viewSize); - GX2SetVertexUniformReg(wiiuTextureShader.vertexShader->uniformVars[1].offset, 4, (uint32_t *)tdata->u_texSize); + GX2SetVertexUniformReg(wiiuTextureShader.vertexShader->uniformVars[0].offset, 4, (uint32_t *)&u_viewSize); + GX2SetVertexUniformReg(wiiuTextureShader.vertexShader->uniformVars[1].offset, 4, (uint32_t *)&tdata->u_texSize); GX2SetPixelUniformReg(wiiuTextureShader.pixelShader->uniformVars[0].offset, 4, (uint32_t*)u_mod); GX2RSetAttributeBuffer(a_position, 0, a_position->elemSize, 0); diff --git a/src/render/wiiu/SDL_rtexture_wiiu.c b/src/render/wiiu/SDL_rtexture_wiiu.c index dc36ecc5c..9b0e2ba68 100644 --- a/src/render/wiiu/SDL_rtexture_wiiu.c +++ b/src/render/wiiu/SDL_rtexture_wiiu.c @@ -102,8 +102,10 @@ int WIIU_SDL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) return SDL_OutOfMemory(); } - tdata->u_texSize[0] = texture->w; - tdata->u_texSize[1] = texture->h; + tdata->u_texSize = (WIIUVec4) { + .x = texture->w, + .y = texture->h, + }; texture->driverdata = tdata;