]> Chaos Git - corbenik/ctrulib.git/commitdiff
Fix GPU example
authorfincs <fincs.alt1@gmail.com>
Sun, 1 Mar 2015 23:54:29 +0000 (00:54 +0100)
committerfincs <fincs.alt1@gmail.com>
Sun, 1 Mar 2015 23:54:29 +0000 (00:54 +0100)
examples/gpu/data/test.vsh
examples/gpu/source/main.c

index 37293aecc2c629e8c71af1bf96b7bd887f4fc66b..a1426411705250ad499601babc7250291725dd5b 100644 (file)
@@ -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
index 9f561891167d52155eb9e2dfb5ad4b89538f3898..411d7aaeef41e86068508140ff97cf2d2fd09c0c 100644 (file)
@@ -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);