From 6cc3e4ba14e7028c9f9dd0edc94d90d3164c0dfb Mon Sep 17 00:00:00 2001 From: "j4ck.fr0st" Date: Sat, 3 Jul 2010 19:10:23 +0000 Subject: [PATCH] Add the patch from Dragonlord for broken Cg 2.1 on Linux with ATI cards (Fixes Issue 2508). Shouldn't affect anything else than Linux, please test it there. Update Issue 2508 This should take care about the black screen. Please open a new issue for other problems that may arise. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5830 8ced0084-cf51-0410-be5f-012b33b47a6e --- .../Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp | 10 ++++++++-- Source/Plugins/Plugin_VideoOGL/Src/Render.cpp | 12 ++++++++++++ .../Plugin_VideoOGL/Src/VertexShaderCache.cpp | 8 +++++++- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp b/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp index 29c4f75e3f..99a35b4bfd 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp @@ -93,10 +93,16 @@ void PixelShaderCache::Init() lastPSconstants[i/4][i%4] = -100000000.0f; memset(&last_pixel_shader_uid, 0xFF, sizeof(last_pixel_shader_uid)); - s_displayCompileAlert = true; + s_displayCompileAlert = true; glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB, (GLint *)&s_nMaxPixelInstructions); - +#ifdef __linux__ + if (strstr((const char*)glGetString(GL_VENDOR), "ATI") != NULL) + { + s_nMaxPixelInstructions = 4096; + } +#endif + int maxinst, maxattribs; glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB, (GLint *)&maxinst); glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB, (GLint *)&maxattribs); diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp index 0962004496..df38ddb3d7 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp @@ -403,8 +403,20 @@ bool Renderer::Init() g_cgvProf = cgGLGetLatestProfile(CG_GL_VERTEX); g_cgfProf = cgGLGetLatestProfile(CG_GL_FRAGMENT); +#ifdef __linux__ + // A bug was introduced in Cg2.1's handling of very large profile option values + // so this will not work on ATI. ATI returns MAXINT = 2147483647 (0x7fffffff) + // which is correct in OpenGL but Cg fails to handle it properly. As a result + // -1 is used by Cg resulting (signedness incorrect) and compilation fails. + if (strstr((const char*)glGetString(GL_VENDOR), "ATI") == NULL) + { + cgGLSetOptimalOptions(g_cgvProf); + cgGLSetOptimalOptions(g_cgfProf); + } +#else cgGLSetOptimalOptions(g_cgvProf); cgGLSetOptimalOptions(g_cgfProf); +#endif INFO_LOG(VIDEO, "Max buffer sizes: %d %d", cgGetProgramBufferMaxSize(g_cgvProf), cgGetProgramBufferMaxSize(g_cgfProf)); int nenvvertparams, nenvfragparams, naddrregisters[2]; diff --git a/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderCache.cpp b/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderCache.cpp index 87752e5f80..ed8ffbdcdf 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderCache.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderCache.cpp @@ -111,7 +111,13 @@ void VertexShaderCache::Init() 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); +#ifdef __linux__ + if (strstr((const char*)glGetString(GL_VENDOR), "ATI") != NULL) + { + s_nMaxVertexInstructions = 4096; + } +#endif } void VertexShaderCache::Shutdown()