From 386a700673fdab59f208b50e0c6c4536f8a175d4 Mon Sep 17 00:00:00 2001 From: fincs Date: Mon, 2 Mar 2015 00:54:29 +0100 Subject: [PATCH] Fix GPU example --- examples/gpu/data/test.vsh | 10 +++++----- examples/gpu/source/main.c | 25 +++++++++++++++---------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/examples/gpu/data/test.vsh b/examples/gpu/data/test.vsh index 37293ae..a142641 100644 --- a/examples/gpu/data/test.vsh +++ b/examples/gpu/data/test.vsh @@ -2,11 +2,11 @@ .const c20, 1.0, 0.0, 0.5, 1.0 ; setup outmap - .out o0, result.position, 0x0 - .out o1, result.color, 0x0 - .out o2, result.texcoord0, 0x0 - .out o3, result.texcoord1, 0x0 - .out o4, result.texcoord2, 0x0 + .out o0, result.position, 0xF + .out o1, result.color, 0xF + .out o2, result.texcoord0, 0x3 + .out o3, result.texcoord1, 0x3 + .out o4, result.texcoord2, 0x3 ; setup uniform map (not required) .uniform c0, c3, projection diff --git a/examples/gpu/source/main.c b/examples/gpu/source/main.c index 9f56189..411d7aa 100644 --- a/examples/gpu/source/main.c +++ b/examples/gpu/source/main.c @@ -137,8 +137,8 @@ void renderFrame() GPU_SetBlendingColor(0,0,0,0); GPU_SetDepthTestAndWriteMask(true, GPU_GREATER, GPU_WRITE_ALL); - GPUCMD_AddSingleParam(0x00010062, 0); - GPUCMD_AddSingleParam(0x000F0118, 0); + GPUCMD_AddMaskedWrite(GPUREG_0062, 0x1, 0); + GPUCMD_AddWrite(GPUREG_0118, 0); GPU_SetAlphaBlending(GPU_BLEND_ADD, GPU_BLEND_ADD, GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA); GPU_SetAlphaTest(false, GPU_ALWAYS, 0x00); @@ -196,14 +196,6 @@ int main(int argc, char** argv) //let GFX know we're ok with doing stereoscopic 3D rendering gfxSet3D(true); - //load our vertex shader binary - dvlb=DVLB_ParseFile((u32*)test_vsh_shbin, test_vsh_shbin_size); - shaderProgramInit(&shader); - shaderProgramSetVsh(&shader, &dvlb->DVLE[0]); - - //initialize GS - gsInit(&shader); - //allocate our GPU command buffers //they *have* to be on the linear heap u32 gpuCmdSize=0x40000; @@ -213,6 +205,19 @@ int main(int argc, char** argv) //actually reset the GPU GPU_Reset(NULL, gpuCmd, gpuCmdSize); + //load our vertex shader binary + dvlb=DVLB_ParseFile((u32*)test_vsh_shbin, test_vsh_shbin_size); + shaderProgramInit(&shader); + shaderProgramSetVsh(&shader, &dvlb->DVLE[0]); + + //initialize GS + gsInit(&shader); + + // Flush the command buffer so that the shader upload gets executed + GPUCMD_Finalize(); + GPUCMD_FlushAndRun(NULL); + gspWaitForP3D(); + //create texture texData=(u32*)linearMemAlign(texture_bin_size, 0x80); //textures need to be 0x80-byte aligned memcpy(texData, texture_bin, texture_bin_size);