summaryrefslogtreecommitdiff
path: root/Source/Plugins
diff options
context:
space:
mode:
authorNeoBrainX <NeoBrainX@googlemail.com>2011-07-29 22:18:11 +0000
committerNeoBrainX <NeoBrainX@googlemail.com>2011-07-29 22:18:11 +0000
commit0655ee571d49493a2018ea819ebbb6eb9208fefd (patch)
treea0bcd5490a3f7c5e8120a8bb17fb72aa45d95484 /Source/Plugins
parent81807e3f2cac43ad89b69fa1f77fcb3c85c0da53 (diff)
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
Diffstat (limited to 'Source/Plugins')
-rw-r--r--Source/Plugins/Plugin_VideoDX11/Src/D3DShader.cpp75
-rw-r--r--Source/Plugins/Plugin_VideoDX9/Src/D3DShader.cpp59
-rw-r--r--Source/Plugins/Plugin_VideoDX9/Src/PixelShaderCache.cpp8
-rw-r--r--Source/Plugins/Plugin_VideoDX9/Src/VertexShaderCache.cpp4
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp26
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/VertexShaderCache.cpp20
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/VertexShaderCache.h2
7 files changed, 94 insertions, 100 deletions
diff --git a/Source/Plugins/Plugin_VideoDX11/Src/D3DShader.cpp b/Source/Plugins/Plugin_VideoDX11/Src/D3DShader.cpp
index 8e02a6db59..41e5423990 100644
--- a/Source/Plugins/Plugin_VideoDX11/Src/D3DShader.cpp
+++ b/Source/Plugins/Plugin_VideoDX11/Src/D3DShader.cpp
@@ -34,10 +34,8 @@ ID3D11VertexShader* CreateVertexShaderFromByteCode(const void* bytecode, unsigne
ID3D11VertexShader* v_shader;
HRESULT hr = D3D::device->CreateVertexShader(bytecode, len, NULL, &v_shader);
if (FAILED(hr))
- {
- PanicAlert("CreateVertexShaderFromByteCode failed from %p (size %d) at %s %d\n", bytecode, len, __FILE__, __LINE__);
- v_shader = NULL;
- }
+ return NULL;
+
return v_shader;
}
@@ -63,15 +61,17 @@ bool CompileVertexShader(const char* code, unsigned int len, D3DBlob** blob)
if (FAILED(hr))
{
- if (g_ActiveConfig.bShowShaderErrors)
- {
- std::string msg = (char*)errorBuffer->GetBufferPointer();
- msg += "\n\n";
- msg += D3D::VertexShaderVersionString();
- msg += "\n\n";
- msg += code;
- MessageBoxA(0, msg.c_str(), "Error compiling vertex shader", MB_ICONERROR);
- }
+ static int num_failures = 0;
+ char szTemp[MAX_PATH];
+ sprintf(szTemp, "%sbad_vs_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), num_failures++);
+ std::ofstream file(szTemp);
+ file << code;
+ 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 (%s):\n%s",
+ szTemp,
+ D3D::VertexShaderVersionString(),
+ (char*)errorBuffer->GetBufferPointer());
*blob = NULL;
errorBuffer->Release();
@@ -90,10 +90,8 @@ ID3D11GeometryShader* CreateGeometryShaderFromByteCode(const void* bytecode, uns
ID3D11GeometryShader* g_shader;
HRESULT hr = D3D::device->CreateGeometryShader(bytecode, len, NULL, &g_shader);
if (FAILED(hr))
- {
- PanicAlert("CreateGeometryShaderFromByteCode failed from %p (size %d) at %s %d\n", bytecode, len, __FILE__, __LINE__);
- g_shader = NULL;
- }
+ return NULL;
+
return g_shader;
}
@@ -120,15 +118,17 @@ bool CompileGeometryShader(const char* code, unsigned int len, D3DBlob** blob,
if (FAILED(hr))
{
- if (g_ActiveConfig.bShowShaderErrors)
- {
- std::string msg = (char*)errorBuffer->GetBufferPointer();
- msg += "\n\n";
- msg += D3D::GeometryShaderVersionString();
- msg += "\n\n";
- msg += code;
- MessageBoxA(0, msg.c_str(), "Error compiling geometry shader", MB_ICONERROR);
- }
+ static int num_failures = 0;
+ char szTemp[MAX_PATH];
+ sprintf(szTemp, "%sbad_gs_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), num_failures++);
+ std::ofstream file(szTemp);
+ file << code;
+ file.close();
+
+ 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;
errorBuffer->Release();
@@ -177,15 +177,17 @@ bool CompilePixelShader(const char* code, unsigned int len, D3DBlob** blob,
if (FAILED(hr))
{
- if (g_ActiveConfig.bShowShaderErrors)
- {
- std::string msg = (char*)errorBuffer->GetBufferPointer();
- msg += "\n\n";
- msg += D3D::PixelShaderVersionString();
- msg += "\n\n";
- msg += code;
- MessageBoxA(0, msg.c_str(), "Error compiling pixel shader", MB_ICONERROR);
- }
+ static int num_failures = 0;
+ char szTemp[MAX_PATH];
+ sprintf(szTemp, "%sbad_ps_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), num_failures++);
+ std::ofstream file(szTemp);
+ file << code;
+ 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 (%s):\n%s",
+ szTemp,
+ D3D::PixelShaderVersionString(),
+ (char*)errorBuffer->GetBufferPointer());
*blob = NULL;
errorBuffer->Release();
@@ -209,7 +211,6 @@ ID3D11VertexShader* CompileAndCreateVertexShader(const char* code,
blob->Release();
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;
}
@@ -223,7 +224,6 @@ ID3D11GeometryShader* CompileAndCreateGeometryShader(const char* code,
blob->Release();
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;
}
@@ -238,7 +238,6 @@ ID3D11PixelShader* CompileAndCreatePixelShader(const char* code,
blob->Release();
return p_shader;
}
- PanicAlert("Failed to compile and create pixel shader, %s %d\n", __FILE__, __LINE__);
return NULL;
}
diff --git a/Source/Plugins/Plugin_VideoDX9/Src/D3DShader.cpp b/Source/Plugins/Plugin_VideoDX9/Src/D3DShader.cpp
index b2bb44a920..9c17c3df8c 100644
--- a/Source/Plugins/Plugin_VideoDX9/Src/D3DShader.cpp
+++ b/Source/Plugins/Plugin_VideoDX9/Src/D3DShader.cpp
@@ -33,10 +33,8 @@ LPDIRECT3DVERTEXSHADER9 CreateVertexShaderFromByteCode(const u8 *bytecode, int l
LPDIRECT3DVERTEXSHADER9 v_shader;
HRESULT hr = D3D::dev->CreateVertexShader((DWORD *)bytecode, &v_shader);
if (FAILED(hr))
- {
- PanicAlert("CreateVertexShaderFromByteCode failed from %p (size %d) at %s %d\n", bytecode, len, __FILE__, __LINE__);
- v_shader = NULL;
- }
+ return NULL;
+
return v_shader;
}
@@ -49,17 +47,22 @@ bool CompileVertexShader(const char *code, int len, u8 **bytecode, int *bytecode
0, &shaderBuffer, &errorBuffer, 0);
if (FAILED(hr))
{
- //compilation error
- if (g_ActiveConfig.bShowShaderErrors) {
- std::string hello = (char*)errorBuffer->GetBufferPointer();
- hello += "\n\n";
- hello += code;
- MessageBoxA(0, hello.c_str(), "Error compiling vertex shader", MB_ICONERROR);
- }
- *bytecode = 0;
+ static int num_failures = 0;
+ char szTemp[MAX_PATH];
+ sprintf(szTemp, "%sbad_vs_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), num_failures++);
+ std::ofstream file(szTemp);
+ file << code;
+ 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 (%s):\n%s",
+ szTemp,
+ D3D::VertexShaderVersionString(),
+ (char*)errorBuffer->GetBufferPointer());
+
+ *bytecode = NULL;
*bytecodelen = 0;
}
- else if (SUCCEEDED(hr))
+ else
{
*bytecodelen = shaderBuffer->GetBufferSize();
*bytecode = new u8[*bytecodelen];
@@ -80,10 +83,8 @@ LPDIRECT3DPIXELSHADER9 CreatePixelShaderFromByteCode(const u8 *bytecode, int len
LPDIRECT3DPIXELSHADER9 p_shader;
HRESULT hr = D3D::dev->CreatePixelShader((DWORD *)bytecode, &p_shader);
if (FAILED(hr))
- {
- PanicAlert("CreatePixelShaderFromByteCode failed at %s %d\n", __FILE__, __LINE__);
- p_shader = NULL;
- }
+ return NULL;
+
return p_shader;
}
@@ -101,16 +102,22 @@ bool CompilePixelShader(const char *code, int len, u8 **bytecode, int *bytecodel
if (FAILED(hr))
{
- if (g_ActiveConfig.bShowShaderErrors) {
- std::string hello = (char*)errorBuffer->GetBufferPointer();
- hello += "\n\n";
- hello += code;
- MessageBoxA(0, hello.c_str(), "Error compiling pixel shader", MB_ICONERROR);
- }
- *bytecode = 0;
+ static int num_failures = 0;
+ char szTemp[MAX_PATH];
+ sprintf(szTemp, "%sbad_ps_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), num_failures++);
+ std::ofstream file(szTemp);
+ file << code;
+ 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 (%s):\n%s",
+ szTemp,
+ D3D::PixelShaderVersionString(),
+ (char*)errorBuffer->GetBufferPointer());
+
+ *bytecode = NULL;
*bytecodelen = 0;
}
- else if (SUCCEEDED(hr))
+ else
{
*bytecodelen = shaderBuffer->GetBufferSize();
*bytecode = new u8[*bytecodelen];
@@ -135,7 +142,6 @@ LPDIRECT3DVERTEXSHADER9 CompileAndCreateVertexShader(const char *code, int len)
delete [] bytecode;
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;
}
@@ -149,7 +155,6 @@ LPDIRECT3DPIXELSHADER9 CompileAndCreatePixelShader(const char* code, unsigned in
delete [] bytecode;
return p_shader;
}
- PanicAlert("Failed to compile and create pixel shader, %s %d\n", __FILE__, __LINE__);
return NULL;
}
diff --git a/Source/Plugins/Plugin_VideoDX9/Src/PixelShaderCache.cpp b/Source/Plugins/Plugin_VideoDX9/Src/PixelShaderCache.cpp
index c168ffc69b..f76837837d 100644
--- a/Source/Plugins/Plugin_VideoDX9/Src/PixelShaderCache.cpp
+++ b/Source/Plugins/Plugin_VideoDX9/Src/PixelShaderCache.cpp
@@ -375,14 +375,6 @@ bool PixelShaderCache::SetShader(DSTALPHA_MODE dstAlphaMode, u32 components)
u8 *bytecode = 0;
int bytecodelen = 0;
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);
return false;
}
diff --git a/Source/Plugins/Plugin_VideoDX9/Src/VertexShaderCache.cpp b/Source/Plugins/Plugin_VideoDX9/Src/VertexShaderCache.cpp
index e5c889b54b..5fc2b6dee2 100644
--- a/Source/Plugins/Plugin_VideoDX9/Src/VertexShaderCache.cpp
+++ b/Source/Plugins/Plugin_VideoDX9/Src/VertexShaderCache.cpp
@@ -209,10 +209,6 @@ bool VertexShaderCache::SetShader(u32 components)
int 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);
return false;
}
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp b/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp
index abde68f1db..bee12e0186 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp
+++ b/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp
@@ -223,13 +223,7 @@ FRAGMENTSHADER* PixelShaderCache::SetShader(DSTALPHA_MODE dstAlphaMode, u32 comp
}
#endif
- // printf("Compiling pixel shader. size = %i\n", strlen(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);
return NULL;
}
@@ -258,13 +252,19 @@ bool PixelShaderCache::CompilePixelShader(FRAGMENTSHADER& ps, const char* pstrpr
if (!cgIsProgram(tempprog))
{
cgDestroyProgram(tempprog);
- if (g_ActiveConfig.bShowShaderErrors)
- {
- std::string message = cgGetLastListing(g_cgcontext);
- message += "\n\n";
- message += pstrprogram;
- CriticalAlertT("Failed to compile ps %s", message.c_str());
- }
+
+ static int num_failures = 0;
+ char szTemp[MAX_PATH];
+ sprintf(szTemp, "%sbad_ps_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), num_failures++);
+ std::ofstream file(szTemp);
+ 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;
}
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderCache.cpp b/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderCache.cpp
index 68e430be50..96f2d5a2ae 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderCache.cpp
+++ b/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderCache.cpp
@@ -38,7 +38,6 @@ namespace OGL
{
VertexShaderCache::VSCache VertexShaderCache::vshaders;
-bool VertexShaderCache::s_displayCompileAlert;
GLuint VertexShaderCache::CurrentShader;
bool VertexShaderCache::ShaderEnabled;
@@ -53,8 +52,6 @@ void VertexShaderCache::Init()
CurrentShader = 0;
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);
if (strstr((const char*)glGetString(GL_VENDOR), "Humper") != NULL) s_nMaxVertexInstructions = 4096;
#if CG_VERSION_NUM == 2100
@@ -114,7 +111,6 @@ VERTEXSHADER* VertexShaderCache::SetShader(u32 components)
#endif
if (!code || !VertexShaderCache::CompileVertexShader(entry.shader, code)) {
- ERROR_LOG(VIDEO, "failed to create vertex shader");
GFX_DEBUGGER_PAUSE_AT(NEXT_ERROR, true);
return NULL;
}
@@ -140,10 +136,18 @@ bool VertexShaderCache::CompileVertexShader(VERTEXSHADER& vs, const char* pstrpr
const char *opts[] = {"-profileopts", stropt, "-O2", "-q", NULL};
CGprogram tempprog = cgCreateProgram(g_cgcontext, CG_SOURCE, pstrprogram, g_cgvProf, "main", opts);
if (!cgIsProgram(tempprog)) {
- if (s_displayCompileAlert) {
- PanicAlert("Failed to create vertex shader");
- s_displayCompileAlert = false;
- }
+ static int num_failures = 0;
+ char szTemp[MAX_PATH];
+ 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);
ERROR_LOG(VIDEO, "Failed to load vs %s:", cgGetLastListing(g_cgcontext));
ERROR_LOG(VIDEO, "%s", pstrprogram);
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderCache.h b/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderCache.h
index 9ada76fd3b..e311fde77b 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderCache.h
+++ b/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderCache.h
@@ -55,8 +55,6 @@ class VertexShaderCache
static VSCache vshaders;
- static bool s_displayCompileAlert;
-
static GLuint CurrentShader;
static bool ShaderEnabled;