int main(void) { SVGA3DUtil_InitFullscreen(CID, 800, 600); SVGA3DText_Init(); vertexSid = SVGA3DUtil_DefineStaticBuffer(vertexData, sizeof vertexData); indexSid = SVGA3DUtil_DefineStaticBuffer(indexData, sizeof indexData); SVGA3D_DefineShader(CID, MY_VSHADER_ID, SVGA3D_SHADERTYPE_VS, g_vs20_MyVertexShader, sizeof g_vs20_MyVertexShader); SVGA3D_DefineShader(CID, MY_PSHADER_ID, SVGA3D_SHADERTYPE_PS, g_ps20_MyPixelShader, sizeof g_ps20_MyPixelShader); Matrix_Perspective(perspectiveMat, 45.0f, gSVGA.width / (float)gSVGA.height, 10.0f, 100.0f); while (1) { if (SVGA3DUtil_UpdateFPSCounter(&gFPS)) { Console_Clear(); Console_Format("Half-precision floating point test.\n" "You should see four identical cubes.\n" "\n" "Top row: Fixed function, Bottom row: Shaders.\n" "Left column: 32-bit float, Right column: 16-bit float.\n" "\n%s", gFPS.text); SVGA3DText_Update(); VMBackdoor_VGAScreenshot(); } SVGA3DUtil_ClearFullscreen(CID, SVGA3D_CLEAR_COLOR | SVGA3D_CLEAR_DEPTH, 0x113366, 1.0f, 0); renderCube(-2, 2, FALSE, FALSE); /* Top-left */ renderCube(2, 2, FALSE, TRUE); /* Top-right */ renderCube(-2, -2, TRUE, FALSE); /* Bottom-left */ renderCube(2, -2, TRUE, TRUE); /* Bottom-right */ SVGA3DText_Draw(); SVGA3DUtil_PresentFullscreen(); } return 0; }
static enum pipe_error compile_vs( struct svga_context *svga, struct svga_vertex_shader *vs, const struct svga_vs_compile_key *key, struct svga_shader_result **out_result ) { struct svga_shader_result *result; enum pipe_error ret = PIPE_ERROR; result = svga_translate_vertex_program( vs, key ); if (result == NULL) { ret = PIPE_ERROR_OUT_OF_MEMORY; goto fail; } result->id = util_bitmask_add(svga->vs_bm); if(result->id == UTIL_BITMASK_INVALID_INDEX) { ret = PIPE_ERROR_OUT_OF_MEMORY; goto fail; } ret = SVGA3D_DefineShader(svga->swc, result->id, SVGA3D_SHADERTYPE_VS, result->tokens, result->nr_tokens * sizeof result->tokens[0]); if (ret) goto fail; *out_result = result; result->next = vs->base.results; vs->base.results = result; return PIPE_OK; fail: if (result) { if (result->id != UTIL_BITMASK_INVALID_INDEX) util_bitmask_clear( svga->vs_bm, result->id ); svga_destroy_shader_result( result ); } return ret; }