From 4e2099a2e47f5916f59eba0a264812d16c0cba4e Mon Sep 17 00:00:00 2001 From: James Benton Date: Thu, 31 May 2018 10:10:10 +0100 Subject: [PATCH] whb: Add missing GX2Invalidate call. GX2RUnlockBuffer is supposed to be calling invalidate for us.... but it does not seem to work and we require an explicit invalidate instead?!?! --- libraries/libgfd/src/gfd.c | 1 + libraries/libwhb/src/gfx_shader.c | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/libraries/libgfd/src/gfd.c b/libraries/libgfd/src/gfd.c index a934f83..df192e9 100644 --- a/libraries/libgfd/src/gfd.c +++ b/libraries/libgfd/src/gfd.c @@ -799,6 +799,7 @@ GFDGetGX2RTexture(GX2Texture *texture, GX2RCreateSurface(&texture->surface, GX2R_RESOURCE_BIND_TEXTURE + | GX2R_RESOURCE_USAGE_CPU_READ | GX2R_RESOURCE_USAGE_CPU_WRITE | GX2R_RESOURCE_USAGE_GPU_READ); diff --git a/libraries/libwhb/src/gfx_shader.c b/libraries/libwhb/src/gfx_shader.c index eb57f7d..a3bfe18 100644 --- a/libraries/libwhb/src/gfx_shader.c +++ b/libraries/libwhb/src/gfx_shader.c @@ -42,7 +42,10 @@ WHBGfxLoadGFDPixelShader(uint32_t index, goto error; } - shader->gx2rBuffer.flags = GX2R_RESOURCE_BIND_SHADER_PROGRAM | GX2R_RESOURCE_USAGE_CPU_WRITE | GX2R_RESOURCE_USAGE_GPU_READ; + shader->gx2rBuffer.flags = GX2R_RESOURCE_BIND_SHADER_PROGRAM | + GX2R_RESOURCE_USAGE_CPU_READ | + GX2R_RESOURCE_USAGE_CPU_WRITE | + GX2R_RESOURCE_USAGE_GPU_READ; shader->gx2rBuffer.elemSize = programSize; shader->gx2rBuffer.elemCount = 1; shader->gx2rBuffer.buffer = NULL; @@ -64,6 +67,10 @@ WHBGfxLoadGFDPixelShader(uint32_t index, } GX2RUnlockBufferEx(&shader->gx2rBuffer, 0); + + // For some reason we still need to manually invalidate the buffers, + // even though GX2RUnlockBuffer SHOULD be doing that for us + GX2Invalidate(GX2_INVALIDATE_MODE_CPU_SHADER, shader->program, shader->size); return shader; error: @@ -122,7 +129,10 @@ WHBGfxLoadGFDVertexShader(uint32_t index, goto error; } - shader->gx2rBuffer.flags = GX2R_RESOURCE_BIND_SHADER_PROGRAM | GX2R_RESOURCE_USAGE_CPU_WRITE | GX2R_RESOURCE_USAGE_GPU_READ; + shader->gx2rBuffer.flags = GX2R_RESOURCE_BIND_SHADER_PROGRAM | + GX2R_RESOURCE_USAGE_CPU_READ | + GX2R_RESOURCE_USAGE_CPU_WRITE | + GX2R_RESOURCE_USAGE_GPU_READ; shader->gx2rBuffer.elemSize = programSize; shader->gx2rBuffer.elemCount = 1; shader->gx2rBuffer.buffer = NULL; @@ -144,6 +154,10 @@ WHBGfxLoadGFDVertexShader(uint32_t index, } GX2RUnlockBufferEx(&shader->gx2rBuffer, 0); + + // For some reason we still need to manually invalidate the buffers, + // even though GX2RUnlockBuffer SHOULD be doing that for us + GX2Invalidate(GX2_INVALIDATE_MODE_CPU_SHADER, shader->program, shader->size); return shader; error: