Shader compilation error message modified to contain some helpful information for noobs (includes a reference to the full bad shader dump).

Removed the "Hide Shader Errors" option; hide shader errors if panic handlers are disabled now.
Removed superfluous error messages about shader compilations; display only one error message instead.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7688 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
NeoBrainX 2011-07-29 22:18:11 +00:00
parent 81807e3f2c
commit 0655ee571d
10 changed files with 94 additions and 104 deletions

View File

@ -557,7 +557,6 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con
{ {
wxGridSizer* const szr_misc = new wxGridSizer(2, 5, 5); wxGridSizer* const szr_misc = new wxGridSizer(2, 5, 5);
szr_misc->Add(CreateCheckBox(page_advanced, _("Hide Shader Errors"), wxGetTranslation(shader_errors_desc), vconfig.bShowShaderErrors, true));
szr_misc->Add(CreateCheckBox(page_advanced, _("Show Input Display"), wxGetTranslation(show_input_display_desc), vconfig.bShowInputDisplay)); szr_misc->Add(CreateCheckBox(page_advanced, _("Show Input Display"), wxGetTranslation(show_input_display_desc), vconfig.bShowInputDisplay));
szr_misc->Add(CreateCheckBox(page_advanced, _("Crop"), wxGetTranslation(crop_desc), vconfig.bCrop)); szr_misc->Add(CreateCheckBox(page_advanced, _("Crop"), wxGetTranslation(crop_desc), vconfig.bCrop));
szr_misc->Add(CreateCheckBox(page_advanced, _("Enable Hotkeys"), wxGetTranslation(hotkeys_desc), vconfig.bOSDHotKey)); szr_misc->Add(CreateCheckBox(page_advanced, _("Enable Hotkeys"), wxGetTranslation(hotkeys_desc), vconfig.bOSDHotKey));

View File

@ -81,7 +81,6 @@ void VideoConfig::Load(const char *ini_file)
iniFile.Get("Settings", "EnablePixelLighting", &bEnablePixelLighting, 0); iniFile.Get("Settings", "EnablePixelLighting", &bEnablePixelLighting, 0);
iniFile.Get("Settings", "EnablePerPixelDepth", &bEnablePerPixelDepth, 0); iniFile.Get("Settings", "EnablePerPixelDepth", &bEnablePerPixelDepth, 0);
iniFile.Get("Settings", "ShowShaderErrors", &bShowShaderErrors, 1);
iniFile.Get("Settings", "MSAA", &iMultisampleMode, 0); iniFile.Get("Settings", "MSAA", &iMultisampleMode, 0);
iniFile.Get("Settings", "EFBScale", &iEFBScale, 2); // native iniFile.Get("Settings", "EFBScale", &iEFBScale, 2); // native
@ -219,7 +218,6 @@ void VideoConfig::Save(const char *ini_file)
iniFile.Set("Settings", "ShowEFBCopyRegions", bShowEFBCopyRegions); iniFile.Set("Settings", "ShowEFBCopyRegions", bShowEFBCopyRegions);
iniFile.Set("Settings", "ShowShaderErrors", bShowShaderErrors);
iniFile.Set("Settings", "MSAA", iMultisampleMode); iniFile.Set("Settings", "MSAA", iMultisampleMode);
iniFile.Set("Settings", "EFBScale", iEFBScale); iniFile.Set("Settings", "EFBScale", iEFBScale);
iniFile.Set("Settings", "TexFmtOverlayEnable", bTexFmtOverlayEnable); iniFile.Set("Settings", "TexFmtOverlayEnable", bTexFmtOverlayEnable);

View File

@ -143,7 +143,6 @@ struct VideoConfig
//currently unused: //currently unused:
int iCompileDLsLevel; int iCompileDLsLevel;
bool bShowShaderErrors;
// D3D only config, mostly to be merged into the above // D3D only config, mostly to be merged into the above
int iAdapter; int iAdapter;

View File

@ -34,10 +34,8 @@ ID3D11VertexShader* CreateVertexShaderFromByteCode(const void* bytecode, unsigne
ID3D11VertexShader* v_shader; ID3D11VertexShader* v_shader;
HRESULT hr = D3D::device->CreateVertexShader(bytecode, len, NULL, &v_shader); HRESULT hr = D3D::device->CreateVertexShader(bytecode, len, NULL, &v_shader);
if (FAILED(hr)) if (FAILED(hr))
{ return NULL;
PanicAlert("CreateVertexShaderFromByteCode failed from %p (size %d) at %s %d\n", bytecode, len, __FILE__, __LINE__);
v_shader = NULL;
}
return v_shader; return v_shader;
} }
@ -63,15 +61,17 @@ bool CompileVertexShader(const char* code, unsigned int len, D3DBlob** blob)
if (FAILED(hr)) if (FAILED(hr))
{ {
if (g_ActiveConfig.bShowShaderErrors) static int num_failures = 0;
{ char szTemp[MAX_PATH];
std::string msg = (char*)errorBuffer->GetBufferPointer(); sprintf(szTemp, "%sbad_vs_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), num_failures++);
msg += "\n\n"; std::ofstream file(szTemp);
msg += D3D::VertexShaderVersionString(); file << code;
msg += "\n\n"; file.close();
msg += code;
MessageBoxA(0, msg.c_str(), "Error compiling vertex shader", MB_ICONERROR); PanicAlert("Failed to compile vertex shader!\nThis usually happens when trying to use Dolphin with an outdated GPU or integrated GPU like the Intel GMA series.\n\nIf you're sure this is Dolphin's error anyway, post the contents of %s along with this error message at the forums.\n\nDebug info (%s):\n%s",
} szTemp,
D3D::VertexShaderVersionString(),
(char*)errorBuffer->GetBufferPointer());
*blob = NULL; *blob = NULL;
errorBuffer->Release(); errorBuffer->Release();
@ -90,10 +90,8 @@ ID3D11GeometryShader* CreateGeometryShaderFromByteCode(const void* bytecode, uns
ID3D11GeometryShader* g_shader; ID3D11GeometryShader* g_shader;
HRESULT hr = D3D::device->CreateGeometryShader(bytecode, len, NULL, &g_shader); HRESULT hr = D3D::device->CreateGeometryShader(bytecode, len, NULL, &g_shader);
if (FAILED(hr)) if (FAILED(hr))
{ return NULL;
PanicAlert("CreateGeometryShaderFromByteCode failed from %p (size %d) at %s %d\n", bytecode, len, __FILE__, __LINE__);
g_shader = NULL;
}
return g_shader; return g_shader;
} }
@ -120,15 +118,17 @@ bool CompileGeometryShader(const char* code, unsigned int len, D3DBlob** blob,
if (FAILED(hr)) if (FAILED(hr))
{ {
if (g_ActiveConfig.bShowShaderErrors) static int num_failures = 0;
{ char szTemp[MAX_PATH];
std::string msg = (char*)errorBuffer->GetBufferPointer(); sprintf(szTemp, "%sbad_gs_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), num_failures++);
msg += "\n\n"; std::ofstream file(szTemp);
msg += D3D::GeometryShaderVersionString(); file << code;
msg += "\n\n"; file.close();
msg += code;
MessageBoxA(0, msg.c_str(), "Error compiling geometry shader", MB_ICONERROR); PanicAlert("Failed to compile geometry shader!\nThis usually happens when trying to use Dolphin with an outdated GPU or integrated GPU like the Intel GMA series.\n\nIf you're sure this is Dolphin's error anyway, post the contents of %s along with this error message at the forums.\n\nDebug info (%s):\n%s",
} szTemp,
D3D::GeometryShaderVersionString(),
(char*)errorBuffer->GetBufferPointer());
*blob = NULL; *blob = NULL;
errorBuffer->Release(); errorBuffer->Release();
@ -177,15 +177,17 @@ bool CompilePixelShader(const char* code, unsigned int len, D3DBlob** blob,
if (FAILED(hr)) if (FAILED(hr))
{ {
if (g_ActiveConfig.bShowShaderErrors) static int num_failures = 0;
{ char szTemp[MAX_PATH];
std::string msg = (char*)errorBuffer->GetBufferPointer(); sprintf(szTemp, "%sbad_ps_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), num_failures++);
msg += "\n\n"; std::ofstream file(szTemp);
msg += D3D::PixelShaderVersionString(); file << code;
msg += "\n\n"; file.close();
msg += code;
MessageBoxA(0, msg.c_str(), "Error compiling pixel shader", MB_ICONERROR); PanicAlert("Failed to compile pixel shader!\nThis usually happens when trying to use Dolphin with an outdated GPU or integrated GPU like the Intel GMA series.\n\nIf you're sure this is Dolphin's error anyway, post the contents of %s along with this error message at the forums.\n\nDebug info (%s):\n%s",
} szTemp,
D3D::PixelShaderVersionString(),
(char*)errorBuffer->GetBufferPointer());
*blob = NULL; *blob = NULL;
errorBuffer->Release(); errorBuffer->Release();
@ -209,7 +211,6 @@ ID3D11VertexShader* CompileAndCreateVertexShader(const char* code,
blob->Release(); blob->Release();
return v_shader; return v_shader;
} }
PanicAlert("Failed to compile and create vertex shader from %p (size %d) at %s %d\n", code, len, __FILE__, __LINE__);
return NULL; return NULL;
} }
@ -223,7 +224,6 @@ ID3D11GeometryShader* CompileAndCreateGeometryShader(const char* code,
blob->Release(); blob->Release();
return g_shader; return g_shader;
} }
PanicAlert("Failed to compile and create geometry shader from %p (size %d) at %s %d\n", code, len, __FILE__, __LINE__);
return NULL; return NULL;
} }
@ -238,7 +238,6 @@ ID3D11PixelShader* CompileAndCreatePixelShader(const char* code,
blob->Release(); blob->Release();
return p_shader; return p_shader;
} }
PanicAlert("Failed to compile and create pixel shader, %s %d\n", __FILE__, __LINE__);
return NULL; return NULL;
} }

View File

@ -33,10 +33,8 @@ LPDIRECT3DVERTEXSHADER9 CreateVertexShaderFromByteCode(const u8 *bytecode, int l
LPDIRECT3DVERTEXSHADER9 v_shader; LPDIRECT3DVERTEXSHADER9 v_shader;
HRESULT hr = D3D::dev->CreateVertexShader((DWORD *)bytecode, &v_shader); HRESULT hr = D3D::dev->CreateVertexShader((DWORD *)bytecode, &v_shader);
if (FAILED(hr)) if (FAILED(hr))
{ return NULL;
PanicAlert("CreateVertexShaderFromByteCode failed from %p (size %d) at %s %d\n", bytecode, len, __FILE__, __LINE__);
v_shader = NULL;
}
return v_shader; return v_shader;
} }
@ -49,17 +47,22 @@ bool CompileVertexShader(const char *code, int len, u8 **bytecode, int *bytecode
0, &shaderBuffer, &errorBuffer, 0); 0, &shaderBuffer, &errorBuffer, 0);
if (FAILED(hr)) if (FAILED(hr))
{ {
//compilation error static int num_failures = 0;
if (g_ActiveConfig.bShowShaderErrors) { char szTemp[MAX_PATH];
std::string hello = (char*)errorBuffer->GetBufferPointer(); sprintf(szTemp, "%sbad_vs_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), num_failures++);
hello += "\n\n"; std::ofstream file(szTemp);
hello += code; file << code;
MessageBoxA(0, hello.c_str(), "Error compiling vertex shader", MB_ICONERROR); file.close();
}
*bytecode = 0; PanicAlert("Failed to compile vertex shader!\nThis usually happens when trying to use Dolphin with an outdated GPU or integrated GPU like the Intel GMA series.\n\nIf you're sure this is Dolphin's error anyway, post the contents of %s along with this error message at the forums.\n\nDebug info (%s):\n%s",
szTemp,
D3D::VertexShaderVersionString(),
(char*)errorBuffer->GetBufferPointer());
*bytecode = NULL;
*bytecodelen = 0; *bytecodelen = 0;
} }
else if (SUCCEEDED(hr)) else
{ {
*bytecodelen = shaderBuffer->GetBufferSize(); *bytecodelen = shaderBuffer->GetBufferSize();
*bytecode = new u8[*bytecodelen]; *bytecode = new u8[*bytecodelen];
@ -80,10 +83,8 @@ LPDIRECT3DPIXELSHADER9 CreatePixelShaderFromByteCode(const u8 *bytecode, int len
LPDIRECT3DPIXELSHADER9 p_shader; LPDIRECT3DPIXELSHADER9 p_shader;
HRESULT hr = D3D::dev->CreatePixelShader((DWORD *)bytecode, &p_shader); HRESULT hr = D3D::dev->CreatePixelShader((DWORD *)bytecode, &p_shader);
if (FAILED(hr)) if (FAILED(hr))
{ return NULL;
PanicAlert("CreatePixelShaderFromByteCode failed at %s %d\n", __FILE__, __LINE__);
p_shader = NULL;
}
return p_shader; return p_shader;
} }
@ -101,16 +102,22 @@ bool CompilePixelShader(const char *code, int len, u8 **bytecode, int *bytecodel
if (FAILED(hr)) if (FAILED(hr))
{ {
if (g_ActiveConfig.bShowShaderErrors) { static int num_failures = 0;
std::string hello = (char*)errorBuffer->GetBufferPointer(); char szTemp[MAX_PATH];
hello += "\n\n"; sprintf(szTemp, "%sbad_ps_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), num_failures++);
hello += code; std::ofstream file(szTemp);
MessageBoxA(0, hello.c_str(), "Error compiling pixel shader", MB_ICONERROR); file << code;
} file.close();
*bytecode = 0;
PanicAlert("Failed to compile pixel shader!\nThis usually happens when trying to use Dolphin with an outdated GPU or integrated GPU like the Intel GMA series.\n\nIf you're sure this is Dolphin's error anyway, post the contents of %s along with this error message at the forums.\n\nDebug info (%s):\n%s",
szTemp,
D3D::PixelShaderVersionString(),
(char*)errorBuffer->GetBufferPointer());
*bytecode = NULL;
*bytecodelen = 0; *bytecodelen = 0;
} }
else if (SUCCEEDED(hr)) else
{ {
*bytecodelen = shaderBuffer->GetBufferSize(); *bytecodelen = shaderBuffer->GetBufferSize();
*bytecode = new u8[*bytecodelen]; *bytecode = new u8[*bytecodelen];
@ -135,7 +142,6 @@ LPDIRECT3DVERTEXSHADER9 CompileAndCreateVertexShader(const char *code, int len)
delete [] bytecode; delete [] bytecode;
return v_shader; return v_shader;
} }
PanicAlert("Failed to compile and create vertex shader from %p (size %d) at %s %d\n", code, len, __FILE__, __LINE__);
return NULL; return NULL;
} }
@ -149,7 +155,6 @@ LPDIRECT3DPIXELSHADER9 CompileAndCreatePixelShader(const char* code, unsigned in
delete [] bytecode; delete [] bytecode;
return p_shader; return p_shader;
} }
PanicAlert("Failed to compile and create pixel shader, %s %d\n", __FILE__, __LINE__);
return NULL; return NULL;
} }

View File

@ -375,14 +375,6 @@ bool PixelShaderCache::SetShader(DSTALPHA_MODE dstAlphaMode, u32 components)
u8 *bytecode = 0; u8 *bytecode = 0;
int bytecodelen = 0; int bytecodelen = 0;
if (!D3D::CompilePixelShader(code, (int)strlen(code), &bytecode, &bytecodelen)) { if (!D3D::CompilePixelShader(code, (int)strlen(code), &bytecode, &bytecodelen)) {
if (g_ActiveConfig.bShowShaderErrors)
{
PanicAlert("Failed to compile Pixel Shader:\n\n%s", code);
static int counter = 0;
char szTemp[MAX_PATH];
sprintf(szTemp, "%sBADps_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), counter++);
SaveData(szTemp, code);
}
GFX_DEBUGGER_PAUSE_AT(NEXT_ERROR, true); GFX_DEBUGGER_PAUSE_AT(NEXT_ERROR, true);
return false; return false;
} }

View File

@ -209,10 +209,6 @@ bool VertexShaderCache::SetShader(u32 components)
int bytecodelen; int bytecodelen;
if (!D3D::CompileVertexShader(code, (int)strlen(code), &bytecode, &bytecodelen)) if (!D3D::CompileVertexShader(code, (int)strlen(code), &bytecode, &bytecodelen))
{ {
if (g_ActiveConfig.bShowShaderErrors)
{
PanicAlert("Failed to compile Vertex Shader:\n\n%s", code);
}
GFX_DEBUGGER_PAUSE_AT(NEXT_ERROR, true); GFX_DEBUGGER_PAUSE_AT(NEXT_ERROR, true);
return false; return false;
} }

View File

@ -223,13 +223,7 @@ FRAGMENTSHADER* PixelShaderCache::SetShader(DSTALPHA_MODE dstAlphaMode, u32 comp
} }
#endif #endif
// printf("Compiling pixel shader. size = %i\n", strlen(code));
if (!code || !CompilePixelShader(newentry.shader, code)) { if (!code || !CompilePixelShader(newentry.shader, code)) {
ERROR_LOG(VIDEO, "failed to create pixel shader");
static int counter = 0;
char szTemp[MAX_PATH];
sprintf(szTemp, "%sBADps_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), counter++);
SaveData(szTemp, code);
GFX_DEBUGGER_PAUSE_AT(NEXT_ERROR, true); GFX_DEBUGGER_PAUSE_AT(NEXT_ERROR, true);
return NULL; return NULL;
} }
@ -258,13 +252,19 @@ bool PixelShaderCache::CompilePixelShader(FRAGMENTSHADER& ps, const char* pstrpr
if (!cgIsProgram(tempprog)) if (!cgIsProgram(tempprog))
{ {
cgDestroyProgram(tempprog); cgDestroyProgram(tempprog);
if (g_ActiveConfig.bShowShaderErrors)
{ static int num_failures = 0;
std::string message = cgGetLastListing(g_cgcontext); char szTemp[MAX_PATH];
message += "\n\n"; sprintf(szTemp, "%sbad_ps_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), num_failures++);
message += pstrprogram; std::ofstream file(szTemp);
CriticalAlertT("Failed to compile ps %s", message.c_str()); file << pstrprogram;
} file.close();
PanicAlert("Failed to compile pixel shader!\nThis usually happens when trying to use Dolphin with an outdated GPU or integrated GPU like the Intel GMA series.\n\nIf you're sure this is Dolphin's error anyway, post the contents of %s along with this error message at the forums.\n\nDebug info (%d):\n%s",
szTemp,
g_cgfProf,
cgGetLastListing(g_cgcontext));
return false; return false;
} }

View File

@ -38,7 +38,6 @@ namespace OGL
{ {
VertexShaderCache::VSCache VertexShaderCache::vshaders; VertexShaderCache::VSCache VertexShaderCache::vshaders;
bool VertexShaderCache::s_displayCompileAlert;
GLuint VertexShaderCache::CurrentShader; GLuint VertexShaderCache::CurrentShader;
bool VertexShaderCache::ShaderEnabled; bool VertexShaderCache::ShaderEnabled;
@ -53,8 +52,6 @@ void VertexShaderCache::Init()
CurrentShader = 0; CurrentShader = 0;
memset(&last_vertex_shader_uid, 0xFF, sizeof(last_vertex_shader_uid)); memset(&last_vertex_shader_uid, 0xFF, sizeof(last_vertex_shader_uid));
s_displayCompileAlert = true;
glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB, (GLint *)&s_nMaxVertexInstructions); glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB, (GLint *)&s_nMaxVertexInstructions);
if (strstr((const char*)glGetString(GL_VENDOR), "Humper") != NULL) s_nMaxVertexInstructions = 4096; if (strstr((const char*)glGetString(GL_VENDOR), "Humper") != NULL) s_nMaxVertexInstructions = 4096;
#if CG_VERSION_NUM == 2100 #if CG_VERSION_NUM == 2100
@ -114,7 +111,6 @@ VERTEXSHADER* VertexShaderCache::SetShader(u32 components)
#endif #endif
if (!code || !VertexShaderCache::CompileVertexShader(entry.shader, code)) { if (!code || !VertexShaderCache::CompileVertexShader(entry.shader, code)) {
ERROR_LOG(VIDEO, "failed to create vertex shader");
GFX_DEBUGGER_PAUSE_AT(NEXT_ERROR, true); GFX_DEBUGGER_PAUSE_AT(NEXT_ERROR, true);
return NULL; return NULL;
} }
@ -140,10 +136,18 @@ bool VertexShaderCache::CompileVertexShader(VERTEXSHADER& vs, const char* pstrpr
const char *opts[] = {"-profileopts", stropt, "-O2", "-q", NULL}; const char *opts[] = {"-profileopts", stropt, "-O2", "-q", NULL};
CGprogram tempprog = cgCreateProgram(g_cgcontext, CG_SOURCE, pstrprogram, g_cgvProf, "main", opts); CGprogram tempprog = cgCreateProgram(g_cgcontext, CG_SOURCE, pstrprogram, g_cgvProf, "main", opts);
if (!cgIsProgram(tempprog)) { if (!cgIsProgram(tempprog)) {
if (s_displayCompileAlert) { static int num_failures = 0;
PanicAlert("Failed to create vertex shader"); char szTemp[MAX_PATH];
s_displayCompileAlert = false; sprintf(szTemp, "%sbad_vs_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), num_failures++);
} std::ofstream file(szTemp);
file << pstrprogram;
file.close();
PanicAlert("Failed to compile vertex shader!\nThis usually happens when trying to use Dolphin with an outdated GPU or integrated GPU like the Intel GMA series.\n\nIf you're sure this is Dolphin's error anyway, post the contents of %s along with this error message at the forums.\n\nDebug info (%d):\n%s",
szTemp,
g_cgfProf,
cgGetLastListing(g_cgcontext));
cgDestroyProgram(tempprog); cgDestroyProgram(tempprog);
ERROR_LOG(VIDEO, "Failed to load vs %s:", cgGetLastListing(g_cgcontext)); ERROR_LOG(VIDEO, "Failed to load vs %s:", cgGetLastListing(g_cgcontext));
ERROR_LOG(VIDEO, "%s", pstrprogram); ERROR_LOG(VIDEO, "%s", pstrprogram);

View File

@ -55,8 +55,6 @@ class VertexShaderCache
static VSCache vshaders; static VSCache vshaders;
static bool s_displayCompileAlert;
static GLuint CurrentShader; static GLuint CurrentShader;
static bool ShaderEnabled; static bool ShaderEnabled;