gsdx ogl: AMD fix some bugs in their driver ! (catalyst 13.4 branch). Let's remove some buggy workaround now.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@5627 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
gregory.hainaut 2013-05-08 15:51:42 +00:00
parent c51f8cae54
commit 320d3a572e
4 changed files with 1 additions and 56 deletions

View File

@ -1262,40 +1262,6 @@ void GSDeviceOGL::OMSetRenderTargets(GSTexture* rt, GSTexture* ds, const GSVecto
} }
} }
// AMD drivers fail to support correctly the setting of index in fragment shader (layout statement in glsl)...
// So instead to use directly glCreateShaderProgramv, you need to emulate the function and manually set
// the index in the fragment shader.
GLuint GSDeviceOGL::glCreateShaderProgramv_AMD_BUG_WORKAROUND(GLenum type, GLsizei count, const char ** strings)
{
const GLuint shader = glCreateShader(type);
if (shader) {
glShaderSource(shader, count, strings, NULL);
glCompileShader(shader);
const GLuint program = glCreateProgram();
if (program) {
GLint compiled = GL_FALSE;
glGetShaderiv(shader, GL_COMPILE_STATUS, &compiled);
glProgramParameteri(program, GL_PROGRAM_SEPARABLE, GL_TRUE);
if (compiled) {
glAttachShader(program, shader);
// HACK TO SET CORRECTLY THE INDEX
if (type == GL_FRAGMENT_SHADER) {
glBindFragDataLocationIndexed(program, 0, 0, "SV_Target0");
glBindFragDataLocationIndexed(program, 0, 1, "SV_Target1");
}
// END OF HACK
glLinkProgram(program);
glDetachShader(program, shader);
}
/* append-shader-info-log-to-program-info-log */
}
glDeleteShader(shader);
return program;
} else {
return 0;
}
}
void GSDeviceOGL::CompileShaderFromSource(const std::string& glsl_file, const std::string& entry, GLenum type, GLuint* program, const std::string& macro_sel) void GSDeviceOGL::CompileShaderFromSource(const std::string& glsl_file, const std::string& entry, GLenum type, GLuint* program, const std::string& macro_sel)
{ {
// ***************************************************** // *****************************************************
@ -1381,20 +1347,6 @@ void GSDeviceOGL::CompileShaderFromSource(const std::string& glsl_file, const st
*program = glCreateShaderProgramv(type, 2, sources_array); *program = glCreateShaderProgramv(type, 2, sources_array);
#endif #endif
// Check the correctness of the (AMD) driver
// Note: glGetFragDataLocation crash too!!! Catalyst 12.10 (and later) => HD 5XXX,6XXX !!!
if (theApp.GetConfig("renderer", 0) == 12) {
GLint slot = glGetFragDataLocation(*program, "SV_Target1");
if (slot == 0) { // <=> SV_Target1 used same slot as SV_Target0
GLint index = glGetFragDataIndex(*program, "SV_Target1");
if (index != 1) {
fprintf(stderr, "Driver bug: failed to set the index, program will be recompiled\n");
glDeleteProgram(*program);
*program = glCreateShaderProgramv_AMD_BUG_WORKAROUND(type, 2, sources_array);
}
}
}
free(source_str); free(source_str);
free(header_str); free(header_str);
free(sources_array); free(sources_array);

View File

@ -656,6 +656,4 @@ class GSDeviceOGL : public GSDevice
void SetupGS(GSSelector sel); void SetupGS(GSSelector sel);
void SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSelector ssel); void SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSelector ssel);
void SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 afix); void SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 afix);
GLuint glCreateShaderProgramv_AMD_BUG_WORKAROUND(GLenum type, GLsizei count, const char ** strings);
}; };

View File

@ -19,8 +19,6 @@
* *
*/ */
#pragma once
#include <limits.h> #include <limits.h>
#include "GSTextureOGL.h" #include "GSTextureOGL.h"
static int g_state_texture_unit = -1; static int g_state_texture_unit = -1;

View File

@ -153,10 +153,7 @@ out gl_PerVertex {
float gl_ClipDistance[]; float gl_ClipDistance[];
}; };
// FIXME layout(location = 0) in vertex GSin[];
// AMD Driver bug again !!!!
//layout(location = 0) in vertex GSin[];
in vertex GSin[];
layout(location = 0) out vertex GSout; layout(location = 0) out vertex GSout;