mirror of https://github.com/PCSX2/pcsx2.git
gsdx ogl:
* retry compilation when driver failed to compile with a static 'index' constraint. Replace previous AMD hack. * clean context default attribute value zzogl 4: clean context default attribute value too. zzogl 3: backport texture size fix git-svn-id: http://pcsx2.googlecode.com/svn/trunk@5442 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
a9020c6065
commit
c4af005f0b
|
@ -39,8 +39,6 @@ GSDeviceOGL::GSDeviceOGL()
|
|||
, m_pipeline(0)
|
||||
, m_fbo(0)
|
||||
, m_fbo_read(0)
|
||||
, m_AMD_gpu(false)
|
||||
, m_enable_shader_AMD_hack(false)
|
||||
, m_vb_sr(NULL)
|
||||
, m_srv_changed(false)
|
||||
, m_ss_changed(false)
|
||||
|
@ -172,9 +170,8 @@ bool GSDeviceOGL::Create(GSWnd* wnd)
|
|||
s = glGetString(GL_VERSION);
|
||||
if (s == NULL) return false;
|
||||
fprintf(stderr, "Supported Opengl version: %s on GPU: %s. Vendor: %s\n", s, glGetString(GL_RENDERER), glGetString(GL_VENDOR));
|
||||
if ( strcmp((const char*)glGetString(GL_VENDOR), "ATI Technologies Inc.") == 0 ) {
|
||||
m_AMD_gpu = true;
|
||||
}
|
||||
// Could be useful to detect the GPU vendor:
|
||||
// if ( strcmp((const char*)glGetString(GL_VENDOR), "ATI Technologies Inc.") == 0 )
|
||||
|
||||
GLuint dot = 0;
|
||||
while (s[dot] != '\0' && s[dot] != '.') dot++;
|
||||
|
@ -204,7 +201,7 @@ bool GSDeviceOGL::Create(GSWnd* wnd)
|
|||
}
|
||||
|
||||
// FIXME disable it when code is ready
|
||||
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
|
||||
// glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
|
||||
|
||||
m_window = wnd;
|
||||
|
||||
|
@ -385,9 +382,6 @@ bool GSDeviceOGL::Create(GSWnd* wnd)
|
|||
// ****************************************************************
|
||||
// HW renderer shader
|
||||
// ****************************************************************
|
||||
if (m_AMD_gpu) {
|
||||
m_enable_shader_AMD_hack = true; // ....
|
||||
}
|
||||
CreateTextureFX();
|
||||
|
||||
// ****************************************************************
|
||||
|
@ -1266,7 +1260,7 @@ GLuint GSDeviceOGL::glCreateShaderProgramv_AMD_BUG_WORKAROUND(GLenum type, GLs
|
|||
if (compiled) {
|
||||
glAttachShader(program, shader);
|
||||
// HACK TO SET CORRECTLY THE INDEX
|
||||
if (type == GL_FRAGMENT_SHADER && m_enable_shader_AMD_hack) {
|
||||
if (type == GL_FRAGMENT_SHADER) {
|
||||
glBindFragDataLocationIndexed(program, 0, 0, "SV_Target0");
|
||||
glBindFragDataLocationIndexed(program, 0, 1, "SV_Target1");
|
||||
}
|
||||
|
@ -1355,23 +1349,18 @@ void GSDeviceOGL::CompileShaderFromSource(const std::string& glsl_file, const st
|
|||
header.copy(header_str, header.size(), 0);
|
||||
header_str[header.size()] = '\0';
|
||||
|
||||
// ... See below to test that index is correctly set by driver
|
||||
if (m_AMD_gpu)
|
||||
*program = glCreateShaderProgramv_AMD_BUG_WORKAROUND(type, 2, sources_array);
|
||||
else
|
||||
*program = glCreateShaderProgramv(type, 2, sources_array);
|
||||
*program = glCreateShaderProgramv(type, 2, sources_array);
|
||||
|
||||
// DEBUG AMD failure...
|
||||
// GLint index = -1;
|
||||
|
||||
// index = glGetFragDataIndex(*program, "SV_Target0");
|
||||
// fprintf(stderr, "Frag0 index %d\n", index);
|
||||
// assert(index == 0);
|
||||
|
||||
// index = glGetFragDataIndex(*program, "SV_Target1");
|
||||
// fprintf(stderr, "Frag1 index %d\n", index);
|
||||
// assert(index == 1);
|
||||
// END DEBUG AMD
|
||||
// Check the correctness of the driver
|
||||
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(header_str);
|
||||
|
|
|
@ -485,9 +485,6 @@ class GSDeviceOGL : public GSDevice
|
|||
GSVertexBufferStateOGL* m_vb; // vb_state for HW renderer
|
||||
GSVertexBufferStateOGL* m_vb_sr; // vb_state for StretchRect
|
||||
|
||||
bool m_enable_shader_AMD_hack;
|
||||
bool m_AMD_gpu;
|
||||
|
||||
struct {
|
||||
GLuint ps[2]; // program object
|
||||
GSUniformBufferOGL* cb; // uniform buffer object
|
||||
|
|
|
@ -236,9 +236,9 @@ bool GSWnd::CreateContext(int major, int minor)
|
|||
// Get visual information
|
||||
static int attrListDbl[] =
|
||||
{
|
||||
// GLX_X_RENDERABLE: If True is specified, then only frame buffer configurations that have associated X
|
||||
// visuals (and can be used to render to Windows and/or GLX pixmaps) will be considered. The default value is GLX_DONT_CARE.
|
||||
GLX_X_RENDERABLE , True,
|
||||
GLX_DRAWABLE_TYPE , GLX_WINDOW_BIT,
|
||||
GLX_RENDER_TYPE , GLX_RGBA_BIT,
|
||||
GLX_RED_SIZE , 8,
|
||||
GLX_GREEN_SIZE , 8,
|
||||
GLX_BLUE_SIZE , 8,
|
||||
|
|
|
@ -244,9 +244,10 @@ inline void CreateOtherCheck()
|
|||
GLint Max_Texture_Size_2d = 0;
|
||||
|
||||
glGetIntegerv(GL_MAX_RECTANGLE_TEXTURE_SIZE_NV, &Max_Texture_Size_NV);
|
||||
|
||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &Max_Texture_Size_2d);
|
||||
|
||||
g_MaxTexHeight = min(Max_Texture_Size_2d, Max_Texture_Size_NV);
|
||||
|
||||
ZZLog::Error_Log("Maximum texture size is %d for Tex_2d and %d for Tex_NV.", Max_Texture_Size_2d, Max_Texture_Size_NV);
|
||||
|
||||
if (Max_Texture_Size_NV < 1024)
|
||||
|
@ -494,8 +495,10 @@ bool ZZCreate(int _width, int _height)
|
|||
|
||||
CreateOtherCheck();
|
||||
|
||||
// Incorrect must check rectangle texture too. Now done directly on CreateOtherCheck()
|
||||
//
|
||||
// check the max texture width and height
|
||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &g_MaxTexWidth);
|
||||
///glGetIntegerv(GL_MAX_TEXTURE_SIZE, &g_MaxTexWidth);
|
||||
// Limit the texture size supported to 8192. We do not need bigger texture.
|
||||
// Besides the following assertion is false when texture are too big.
|
||||
// ZZoglFlush.cpp:2349: assert(fblockstride >= 1.0f)
|
||||
|
|
|
@ -210,9 +210,9 @@ bool GLWindow::CreateContextGL(int major, int minor)
|
|||
// Get visual information
|
||||
int attrListDbl[] =
|
||||
{
|
||||
// GLX_X_RENDERABLE: If True is specified, then only frame buffer configurations that have associated X
|
||||
// visuals (and can be used to render to Windows and/or GLX pixmaps) will be considered. The default value is GLX_DONT_CARE.
|
||||
GLX_X_RENDERABLE , True,
|
||||
GLX_DRAWABLE_TYPE , GLX_WINDOW_BIT,
|
||||
GLX_RENDER_TYPE , GLX_RGBA_BIT,
|
||||
GLX_RED_SIZE , 8,
|
||||
GLX_GREEN_SIZE , 8,
|
||||
GLX_BLUE_SIZE , 8,
|
||||
|
@ -268,7 +268,7 @@ bool GLWindow::CreateContextGL(int major, int minor)
|
|||
GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB,
|
||||
//GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB | GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB,
|
||||
// FIXME : Request a debug context to ease opengl development
|
||||
#if defined(ZEROGS_DEVBUILD) || defined(_DEBUG)
|
||||
#if (defined(ZEROGS_DEVBUILD) || defined(_DEBUG)) && defined(OGL4_LOG)
|
||||
GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB,
|
||||
#endif
|
||||
None
|
||||
|
@ -282,7 +282,10 @@ bool GLWindow::CreateContextGL(int major, int minor)
|
|||
|
||||
XSync( NativeDisplay, false);
|
||||
|
||||
glXMakeCurrent(NativeDisplay, NativeWindow, glxContext);
|
||||
if (!glXMakeCurrent(NativeDisplay, NativeWindow, glxContext)) {
|
||||
ZZLog::Error_Log("GLX: failed to attach the opengl context");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue