shithub: cstory

Download patch

ref: e40de4992f89d4301e6d12851f109b0162f38e1b
parent: 24d8f318e573bbddc8f057f5686bcfb175204a05
author: Clownacy <Clownacy@users.noreply.github.com>
date: Mon Apr 20 10:54:31 EDT 2020

Wii U cleanup

--- a/src/Backends/WiiU/Window-Software-Polygon.cpp
+++ b/src/Backends/WiiU/Window-Software-Polygon.cpp
@@ -112,6 +112,12 @@
 			                                                                   GX2R_RESOURCE_USAGE_CPU_WRITE | GX2R_RESOURCE_USAGE_CPU_READ |
 			                                                                   GX2R_RESOURCE_USAGE_GPU_WRITE | GX2R_RESOURCE_USAGE_GPU_READ)))
 			{
+				// Do some binding
+				GX2SetPixelSampler(&sampler, shader_group.pixelShader->samplerVars[0].location);
+				GX2SetPixelTexture(&screen_texture, shader_group.pixelShader->samplerVars[0].location);
+				GX2RSetAttributeBuffer(&vertex_position_buffer, 0, vertex_position_buffer.elemSize, 0);
+				GX2RSetAttributeBuffer(&texture_coordinate_buffer, 1, texture_coordinate_buffer.elemSize, 0);
+
 				return true;
 			}
 
@@ -119,6 +125,8 @@
 			GX2RDestroyBufferEx(&vertex_position_buffer, (GX2RResourceFlags)0);
 		}
 
+		WHBGfxFreeShaderGroup(&shader_group);
+
 		WHBGfxShutdown();
 
 		free(fake_framebuffer);
@@ -134,6 +142,8 @@
 	GX2RDestroyBufferEx(&texture_coordinate_buffer, (GX2RResourceFlags)0);
 	GX2RDestroyBufferEx(&vertex_position_buffer, (GX2RResourceFlags)0);
 
+	WHBGfxFreeShaderGroup(&shader_group);
+
 	WHBGfxShutdown();
 
 	free(fake_framebuffer);
@@ -172,13 +182,9 @@
 	// Draw to the TV
 	WHBGfxBeginRenderTV();
 	WHBGfxClearColor(0.0f, 0.0f, 0.0f, 1.0f);
-	GX2SetPixelTexture(&screen_texture, shader_group.pixelShader->samplerVars[0].location);
-	GX2SetPixelSampler(&sampler, shader_group.pixelShader->samplerVars[0].location);
 	GX2SetFetchShader(&shader_group.fetchShader);
 	GX2SetVertexShader(shader_group.vertexShader);
 	GX2SetPixelShader(shader_group.pixelShader);
-	GX2RSetAttributeBuffer(&vertex_position_buffer, 0, vertex_position_buffer.elemSize, 0);
-	GX2RSetAttributeBuffer(&texture_coordinate_buffer, 1, texture_coordinate_buffer.elemSize, 0);
 	GX2DrawEx(GX2_PRIMITIVE_MODE_QUADS, 4, 0, 1);
 	WHBGfxFinishRenderTV();
 
@@ -185,13 +191,9 @@
 	// Draw to the gamepad
 	WHBGfxBeginRenderDRC();
 	WHBGfxClearColor(0.0f, 0.0f, 0.0f, 1.0f);
-	GX2SetPixelTexture(&screen_texture, shader_group.pixelShader->samplerVars[0].location);
-	GX2SetPixelSampler(&sampler, shader_group.pixelShader->samplerVars[0].location);
 	GX2SetFetchShader(&shader_group.fetchShader);
 	GX2SetVertexShader(shader_group.vertexShader);
 	GX2SetPixelShader(shader_group.pixelShader);
-	GX2RSetAttributeBuffer(&vertex_position_buffer, 0, vertex_position_buffer.elemSize, 0);
-	GX2RSetAttributeBuffer(&texture_coordinate_buffer, 1, texture_coordinate_buffer.elemSize, 0);
 	GX2DrawEx(GX2_PRIMITIVE_MODE_QUADS, 4, 0, 1);
 	WHBGfxFinishRenderDRC();