psyjoe's patch to shader compilation. ector/some "shader person" check this please :) looks reasonable to me though.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4267 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
e76d2a1a4c
commit
a08c801256
|
@ -627,15 +627,15 @@ void WriteZ24Encoder(char* p)
|
|||
WRITE(p, " if(cl > 0.5f) {\n");
|
||||
// upper 16
|
||||
WRITE(p, " ocol0.b = frac(depth0 * 256.0f);\n");
|
||||
WRITE(p, " ocol0.g = depth0\n");
|
||||
WRITE(p, " ocol0.g = depth0;\n");
|
||||
WRITE(p, " ocol0.r = frac(depth1 * 256.0f);\n");
|
||||
WRITE(p, " ocol0.a = depth1\n");
|
||||
WRITE(p, " ocol0.a = depth1;\n");
|
||||
WRITE(p, " } else {\n");
|
||||
// lower 8
|
||||
WRITE(p, " ocol0.b = 1.0f;\n");
|
||||
WRITE(p, " ocol0.g = frac(depth0 * 65536.0f)\n");
|
||||
WRITE(p, " ocol0.r = 1.0f);\n");
|
||||
WRITE(p, " ocol0.a = frac(depth0 * 65536.0f)\n");
|
||||
WRITE(p, " ocol0.g = frac(depth0 * 65536.0f);\n");
|
||||
WRITE(p, " ocol0.r = 1.0f;\n");
|
||||
WRITE(p, " ocol0.a = frac(depth0 * 65536.0f);\n");
|
||||
WRITE(p, " }\n"
|
||||
"}\n");
|
||||
}
|
||||
|
|
|
@ -251,13 +251,22 @@ bool PixelShaderCache::CompilePixelShader(FRAGMENTSHADER& ps, const char* pstrpr
|
|||
sprintf(stropt, "MaxLocalParams=32,NumInstructionSlots=%d", s_nMaxPixelInstructions);
|
||||
const char *opts[] = {"-profileopts", stropt, "-O2", "-q", NULL};
|
||||
CGprogram tempprog = cgCreateProgram(g_cgcontext, CG_SOURCE, pstrprogram, g_cgfProf, "main", opts);
|
||||
if (!cgIsProgram(tempprog) || cgGetError() != CG_NO_ERROR) {
|
||||
|
||||
// handle errors
|
||||
if (!cgIsProgram(tempprog)) {
|
||||
cgDestroyProgram(tempprog);
|
||||
ERROR_LOG(VIDEO, "Failed to compile ps %s:", cgGetLastListing(g_cgcontext));
|
||||
ERROR_LOG(VIDEO, pstrprogram);
|
||||
return false;
|
||||
}
|
||||
|
||||
// handle warnings
|
||||
if(cgGetError() != CG_NO_ERROR)
|
||||
{
|
||||
WARN_LOG(VIDEO, "Warnings on compile ps %s:", cgGetLastListing(g_cgcontext));
|
||||
WARN_LOG(VIDEO, pstrprogram);
|
||||
}
|
||||
|
||||
// This looks evil - we modify the program through the const char * we got from cgGetProgramString!
|
||||
// It SHOULD not have any nasty side effects though - but you never know...
|
||||
char *pcompiledprog = (char*)cgGetProgramString(tempprog, CG_COMPILED_PROGRAM);
|
||||
|
|
|
@ -196,7 +196,7 @@ bool VertexShaderCache::CompileVertexShader(VERTEXSHADER& vs, const char* pstrpr
|
|||
sprintf(stropt, "MaxLocalParams=256,MaxInstructions=%d", s_nMaxVertexInstructions);
|
||||
const char *opts[] = {"-profileopts", stropt, "-O2", "-q", NULL};
|
||||
CGprogram tempprog = cgCreateProgram(g_cgcontext, CG_SOURCE, pstrprogram, g_cgvProf, "main", opts);
|
||||
if (!cgIsProgram(tempprog) || cgGetError() != CG_NO_ERROR) {
|
||||
if (!cgIsProgram(tempprog)) {
|
||||
if (s_displayCompileAlert) {
|
||||
PanicAlert("Failed to create vertex shader");
|
||||
s_displayCompileAlert = false;
|
||||
|
@ -207,6 +207,12 @@ bool VertexShaderCache::CompileVertexShader(VERTEXSHADER& vs, const char* pstrpr
|
|||
return false;
|
||||
}
|
||||
|
||||
if(cgGetError() != CG_NO_ERROR)
|
||||
{
|
||||
WARN_LOG(VIDEO, "Failed to load vs %s:", cgGetLastListing(g_cgcontext));
|
||||
WARN_LOG(VIDEO, pstrprogram);
|
||||
}
|
||||
|
||||
// This looks evil - we modify the program through the const char * we got from cgGetProgramString!
|
||||
// It SHOULD not have any nasty side effects though - but you never know...
|
||||
char *pcompiledprog = (char*)cgGetProgramString(tempprog, CG_COMPILED_PROGRAM);
|
||||
|
|
Loading…
Reference in New Issue