Update GPU example (untested)
This commit is contained in:
parent
b175fdbca5
commit
9abad5bbaf
@ -32,15 +32,16 @@ void initBufferMatrixList()
|
|||||||
bufferMatrixListLength=0;
|
bufferMatrixListLength=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gsInit(DVLB_s* shader)
|
void gsInit(shaderProgram_s* shader)
|
||||||
{
|
{
|
||||||
gsInitMatrixStack();
|
gsInitMatrixStack();
|
||||||
initBufferMatrixList();
|
initBufferMatrixList();
|
||||||
svcCreateMutex(&linearAllocMutex, false);
|
svcCreateMutex(&linearAllocMutex, false);
|
||||||
if(shader)
|
if(shader)
|
||||||
{
|
{
|
||||||
gsMatrixStackRegisters[0]=SHDR_GetUniformRegister(shader, "projection", 0);
|
gsMatrixStackRegisters[0]=shaderInstanceGetUniformLocation(shader->vertexShader, "projection");
|
||||||
gsMatrixStackRegisters[1]=SHDR_GetUniformRegister(shader, "modelview", 0);
|
gsMatrixStackRegisters[1]=shaderInstanceGetUniformLocation(shader->vertexShader, "modelview");
|
||||||
|
shaderProgramUse(shader);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,7 +236,7 @@ static void gsSetUniformMatrix(u32 startreg, float* m)
|
|||||||
param[0xe]=m[13];
|
param[0xe]=m[13];
|
||||||
param[0xf]=m[12];
|
param[0xf]=m[12];
|
||||||
|
|
||||||
GPU_SetUniform(startreg, (u32*)param, 4);
|
GPU_SetFloatUniform(GPU_VERTEX_SHADER, startreg, (u32*)param, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int gsUpdateTransformation()
|
static int gsUpdateTransformation()
|
||||||
|
@ -24,7 +24,7 @@ typedef struct
|
|||||||
}gsVbo_s;
|
}gsVbo_s;
|
||||||
|
|
||||||
|
|
||||||
void gsInit(DVLB_s* shader);
|
void gsInit(shaderProgram_s* shader);
|
||||||
void gsExit(void);
|
void gsExit(void);
|
||||||
|
|
||||||
void gsStartFrame(void);
|
void gsStartFrame(void);
|
||||||
|
@ -25,7 +25,8 @@
|
|||||||
#define RGBA8(r,g,b,a) ((((r)&0xFF)<<24) | (((g)&0xFF)<<16) | (((b)&0xFF)<<8) | (((a)&0xFF)<<0))
|
#define RGBA8(r,g,b,a) ((((r)&0xFF)<<24) | (((g)&0xFF)<<16) | (((b)&0xFF)<<8) | (((a)&0xFF)<<0))
|
||||||
|
|
||||||
//shader structure
|
//shader structure
|
||||||
DVLB_s* shader;
|
DVLB_s* dvlb;
|
||||||
|
shaderProgram_s shader;
|
||||||
//texture data pointer
|
//texture data pointer
|
||||||
u32* texData;
|
u32* texData;
|
||||||
//vbo structure
|
//vbo structure
|
||||||
@ -139,9 +140,6 @@ void renderFrame()
|
|||||||
GPUCMD_AddSingleParam(0x00010062, 0);
|
GPUCMD_AddSingleParam(0x00010062, 0);
|
||||||
GPUCMD_AddSingleParam(0x000F0118, 0);
|
GPUCMD_AddSingleParam(0x000F0118, 0);
|
||||||
|
|
||||||
//setup shader
|
|
||||||
SHDR_UseProgram(shader, 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_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);
|
GPU_SetAlphaTest(false, GPU_ALWAYS, 0x00);
|
||||||
|
|
||||||
@ -168,8 +166,8 @@ void renderFrame()
|
|||||||
|
|
||||||
//setup lighting (this is specific to our shader)
|
//setup lighting (this is specific to our shader)
|
||||||
vect3Df_s lightDir=vnormf(vect3Df(cos(lightAngle), -1.0f, sin(lightAngle)));
|
vect3Df_s lightDir=vnormf(vect3Df(cos(lightAngle), -1.0f, sin(lightAngle)));
|
||||||
GPU_SetUniform(SHDR_GetUniformRegister(shader, "lightDirection", 0), (u32*)(float[]){0.0f, -lightDir.z, -lightDir.y, -lightDir.x}, 1);
|
GPU_SetFloatUniform(GPU_VERTEX_SHADER, shaderInstanceGetUniformLocation(shader.vertexShader, "lightDirection"), (u32*)(float[]){0.0f, -lightDir.z, -lightDir.y, -lightDir.x}, 1);
|
||||||
GPU_SetUniform(SHDR_GetUniformRegister(shader, "lightAmbient", 0), (u32*)(float[]){0.7f, 0.4f, 0.4f, 0.4f}, 1);
|
GPU_SetFloatUniform(GPU_VERTEX_SHADER, shaderInstanceGetUniformLocation(shader.vertexShader, "lightAmbient"), (u32*)(float[]){0.7f, 0.4f, 0.4f, 0.4f}, 1);
|
||||||
|
|
||||||
//initialize projection matrix to standard perspective stuff
|
//initialize projection matrix to standard perspective stuff
|
||||||
gsMatrixMode(GS_PROJECTION);
|
gsMatrixMode(GS_PROJECTION);
|
||||||
@ -199,10 +197,12 @@ int main(int argc, char** argv)
|
|||||||
gfxSet3D(true);
|
gfxSet3D(true);
|
||||||
|
|
||||||
//load our vertex shader binary
|
//load our vertex shader binary
|
||||||
shader=SHDR_ParseSHBIN((u32*)test_vsh_shbin, test_vsh_shbin_size);
|
dvlb=DVLB_ParseFile((u32*)test_vsh_shbin, test_vsh_shbin_size);
|
||||||
|
shaderProgramInit(&shader);
|
||||||
|
shaderProgramSetVsh(&shader, &dvlb->DVLE[0]);
|
||||||
|
|
||||||
//initialize GS
|
//initialize GS
|
||||||
gsInit(shader);
|
gsInit(&shader);
|
||||||
|
|
||||||
//allocate our GPU command buffers
|
//allocate our GPU command buffers
|
||||||
//they *have* to be on the linear heap
|
//they *have* to be on the linear heap
|
||||||
@ -318,6 +318,8 @@ int main(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
gsExit();
|
gsExit();
|
||||||
|
shaderProgramFree(&shader);
|
||||||
|
DVLB_Free(dvlb);
|
||||||
gfxExit();
|
gfxExit();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user