GSdx: only enable AMD hack for AMD GPU. Remove the older geometry shader hack fixed since 6 monthes

ZZogl: support xdg for the replayer


git-svn-id: http://pcsx2.googlecode.com/svn/trunk@5441 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
gregory.hainaut 2012-10-28 10:14:42 +00:00
parent 059346b5f2
commit a9020c6065
6 changed files with 57 additions and 38 deletions

View File

@ -20,8 +20,6 @@ set(CommonFlags
-std=c++0x
-fno-strict-aliasing
#-DOGL_DEBUG # FIXME remove me when code is ready
# Unload of Geometry shader was fixed in Cat 12.3 (ie OpenGL version string: 4.2.11554)
#-DAMD_DRIVER_WORKAROUND
)
set(OptimizationFlags

View File

@ -39,6 +39,7 @@ 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)
@ -148,8 +149,10 @@ bool GSDeviceOGL::Create(GSWnd* wnd)
{
if (m_window == NULL) {
// FIXME......
// GLEW's problem is that it calls glGetString(GL_EXTENSIONS) which causes GL_INVALID_ENUM on GL 3.2 forward compatible context as soon as glewInit() is called. It also doesn't fetch the function pointers. The solution is for GLEW to use glGetStringi instead.
// The current version of GLEW is 1.7.0 but they still haven't corrected it. The only fix is to use glewExperimental for now :
// GLEW's problem is that it calls glGetString(GL_EXTENSIONS) which causes GL_INVALID_ENUM
// on GL 3.2 forward compatible context as soon as glewInit() is called. It also doesn't fetch
// the function pointers. The solution is for GLEW to use glGetStringi instead.
// The current version of GLEW is 1.9.0 but they still haven't corrected it. The only fix is to use glewExperimental for now :
//NOTE: I'm not sure experimental work on 1.6 ...
glewExperimental=true;
const int glew_ok = glewInit();
@ -168,7 +171,10 @@ bool GSDeviceOGL::Create(GSWnd* wnd)
const GLubyte* s;
s = glGetString(GL_VERSION);
if (s == NULL) return false;
fprintf(stderr, "Supported Opengl version: %s\n", s);
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;
}
GLuint dot = 0;
while (s[dot] != '\0' && s[dot] != '.') dot++;
@ -379,7 +385,9 @@ bool GSDeviceOGL::Create(GSWnd* wnd)
// ****************************************************************
// HW renderer shader
// ****************************************************************
m_enable_shader_AMD_hack = true; // ....
if (m_AMD_gpu) {
m_enable_shader_AMD_hack = true; // ....
}
CreateTextureFX();
// ****************************************************************
@ -779,11 +787,8 @@ void GSDeviceOGL::CopyRect(GSTexture* st, GSTexture* dt, const GSVector4i& r)
return;
}
// GL_NV_copy_image seem like the good extension but not supported on AMD...
// Maybe opengl 4.3 !
// FIXME: the extension was integrated in opengl 4.3 (now we need driver that support OGL4.3)
// FIXME check those function work as expected
// FIXME: it is an NVIDIA extension. Hopefully lastest AMD driver support it too.
// An EXT extensions might be release later.
// void CopyImageSubDataNV(
// uint srcName, enum srcTarget, int srcLevel, int srcX, int srcY, int srcZ,
// uint dstName, enum dstTarget, int dstLevel, int dstX, int dstY, int dstZ,
@ -880,11 +885,7 @@ void GSDeviceOGL::StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt,
// gs
// ************************************
#ifdef AMD_DRIVER_WORKAROUND
GSSetShader(m_convert.gs);
#else
GSSetShader(0);
#endif
// ************************************
// ps
@ -992,12 +993,7 @@ void GSDeviceOGL::SetupDATE(GSTexture* rt, GSTexture* ds, const GSVertexPT1* ver
// gs
#ifdef AMD_DRIVER_WORKAROUND
GSSetShader(m_convert.gs);
#else
GSSetShader(0);
#endif
// ps
@ -1360,8 +1356,10 @@ void GSDeviceOGL::CompileShaderFromSource(const std::string& glsl_file, const st
header_str[header.size()] = '\0';
// ... See below to test that index is correctly set by driver
//*program = glCreateShaderProgramv(type, 2, sources_array);
*program = glCreateShaderProgramv_AMD_BUG_WORKAROUND(type, 2, sources_array);
if (m_AMD_gpu)
*program = glCreateShaderProgramv_AMD_BUG_WORKAROUND(type, 2, sources_array);
else
*program = glCreateShaderProgramv(type, 2, sources_array);
// DEBUG AMD failure...
// GLint index = -1;

View File

@ -486,6 +486,7 @@ class GSDeviceOGL : public GSDevice
GSVertexBufferStateOGL* m_vb_sr; // vb_state for StretchRect
bool m_enable_shader_AMD_hack;
bool m_AMD_gpu;
struct {
GLuint ps[2]; // program object

View File

@ -107,11 +107,7 @@ void GSDeviceOGL::SetupGS(GSSelector sel)
// Static
// *************************************************************
GLuint gs = 0;
#ifdef AMD_DRIVER_WORKAROUND
if (true)
#else
if(sel.prim > 0 && (sel.iip == 0 || sel.prim == 3))
#endif
{
auto i = m_gs.find(sel);

View File

@ -121,7 +121,7 @@ bool GLWindow::ReleaseContext()
if (glxContext)
{
if (!glXMakeCurrent(NativeDisplay, None, NULL)) {
ZZLog::Error_Log("Could not release drawing context.");
ZZLog::Error_Log("GLX: Could not release drawing context.");
status = false;
}
@ -197,8 +197,8 @@ void GLWindow::PrintProtocolVersion()
ZZLog::Error_Log("glX-Version %d.%d with Indirect Rendering !!! It will be slow", glxMajorVersion, glxMinorVersion);
#endif
#ifdef EGL_API
ZZLog::Error_Log("Egl: %s : %s", eglQueryString(eglDisplay, EGL_VENDOR) , eglQueryString(eglDisplay, EGL_VERSION) );
ZZLog::Error_Log("Egl: extensions supported: %s", eglQueryString(eglDisplay, EGL_EXTENSIONS));
ZZLog::Error_Log("EGL: %s : %s", eglQueryString(eglDisplay, EGL_VENDOR) , eglQueryString(eglDisplay, EGL_VERSION) );
ZZLog::Error_Log("EGL: extensions supported: %s", eglQueryString(eglDisplay, EGL_EXTENSIONS));
#endif
}
@ -251,7 +251,10 @@ bool GLWindow::CreateContextGL(int major, int minor)
PFNGLXCHOOSEFBCONFIGPROC glXChooseFBConfig = (PFNGLXCHOOSEFBCONFIGPROC)GetProcAddress("glXChooseFBConfig");
int fbcount = 0;
GLXFBConfig *fbc = glXChooseFBConfig(NativeDisplay, DefaultScreen(NativeDisplay), attrListDbl, &fbcount);
if (!fbc || fbcount < 1) return false;
if (!fbc || fbcount < 1) {
ZZLog::Error_Log("GLX: failed to find a framebuffer");
return false;
}
PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC)GetProcAddress("glXCreateContextAttribsARB");
if (!glXCreateContextAttribsARB) return false;
@ -272,7 +275,10 @@ bool GLWindow::CreateContextGL(int major, int minor)
};
glxContext = glXCreateContextAttribsARB(NativeDisplay, fbc[0], 0, true, context_attribs);
if (!glxContext) return false;
if (!glxContext) {
ZZLog::Error_Log("GLX: failed to create an opengl context");
return false;
}
XSync( NativeDisplay, false);
@ -335,21 +341,21 @@ bool GLWindow::CreateContextGL(int major, int minor)
if ( !eglChooseConfig(eglDisplay, attrList, &eglConfig, 1, &numConfigs) )
{
ZZLog::Error_Log("Failed to get a frame buffer config!");
ZZLog::Error_Log("EGL: Failed to get a frame buffer config!");
return EGL_FALSE;
}
eglSurface = eglCreateWindowSurface(eglDisplay, eglConfig, NativeWindow, NULL);
if ( eglSurface == EGL_NO_SURFACE )
{
ZZLog::Error_Log("Failed to get a window surface");
ZZLog::Error_Log("EGL: Failed to get a window surface");
return EGL_FALSE;
}
eglContext = eglCreateContext(eglDisplay, eglConfig, EGL_NO_CONTEXT, contextAttribs );
if ( eglContext == EGL_NO_CONTEXT )
{
ZZLog::Error_Log("Failed to create the context");
ZZLog::Error_Log("EGL: Failed to create the context");
ZZLog::Error_Log("EGL STATUS: %x", eglGetError());
return EGL_FALSE;
}
@ -438,7 +444,7 @@ void GLWindow::InitVsync(bool extension)
swapinterval(0);
vsync_supported = true;
} else {
ZZLog::Error_Log("No support for SwapInterval (framerate clamped to monitor refresh rate),");
ZZLog::Error_Log("GLX: No support for SwapInterval (framerate clamped to monitor refresh rate),");
}
}

View File

@ -35,10 +35,30 @@ void help()
int main ( int argc, char *argv[] )
{
if ( argc < 2 ) help();
GSsetLogDir("/tmp");
if ( argc == 3) {
GSsetSettingsDir(argv[1]);
GSReplay(argv[2]);
} else if ( argc == 2) {
#ifdef XDG_STD
std::string home("HOME");
char * val = getenv( home.c_str() );
if (val == NULL) {
fprintf(stderr, "Failed to get the home dir\n");
help();
}
std::string ini_dir(val);
ini_dir += "/.config/pcsx2/inis";
GSsetSettingsDir(ini_dir.c_str());
GSReplay(argv[1]);
#else
fprintf(stderr, "default ini dir only supported on XDG\n");
help();
#endif
} else
help();
GSsetSettingsDir(argv[1]);
GSsetLogDir("/tmp");
GSReplay(argv[2]);
}