mirror of https://github.com/PCSX2/pcsx2.git
gsdx:
* add exception in GSWndEGL and GSWndOGL * Try to use EGL when GLX failed => you don't need any flags for the opensource driver ;) cmake: don't install anymore the glsl shader git-svn-id: http://pcsx2.googlecode.com/svn/trunk@5671 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
9b037a3813
commit
09571dac0b
|
@ -44,11 +44,6 @@ if(XDG_STD)
|
|||
add_definitions(-DXDG_STD)
|
||||
endif(XDG_STD)
|
||||
|
||||
# Select the EGL API
|
||||
if(EGL_API)
|
||||
add_definitions(-DEGL_API)
|
||||
endif()
|
||||
|
||||
set(GSdxSources
|
||||
GLLoader.cpp
|
||||
GPU.cpp
|
||||
|
@ -200,16 +195,8 @@ endif(NOT USER_CMAKE_LD_FLAGS STREQUAL "")
|
|||
|
||||
if(PACKAGE_MODE)
|
||||
install(TARGETS ${Output} DESTINATION ${PLUGIN_DIR})
|
||||
|
||||
foreach(glsl IN ITEMS convert.glsl interlace.glsl merge.glsl tfx.glsl shadeboost.glsl fxaa.fx)
|
||||
install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/${glsl} DESTINATION ${GLSL_SHADER_DIR})
|
||||
endforeach()
|
||||
else(PACKAGE_MODE)
|
||||
install(TARGETS ${Output} DESTINATION ${CMAKE_SOURCE_DIR}/bin/plugins)
|
||||
|
||||
foreach(glsl IN ITEMS convert.glsl interlace.glsl merge.glsl tfx.glsl shadeboost.glsl fxaa.fx)
|
||||
install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/${glsl} DESTINATION ${CMAKE_SOURCE_DIR}/bin/plugins)
|
||||
endforeach()
|
||||
endif(PACKAGE_MODE)
|
||||
|
||||
################################### Replay Loader
|
||||
|
|
|
@ -200,6 +200,7 @@ static int _GSopen(void** dsp, char* title, int renderer, int threads = -1)
|
|||
threads = theApp.GetConfig("extrathreads", 0);
|
||||
}
|
||||
|
||||
GSWnd* wnd[2];
|
||||
try
|
||||
{
|
||||
if(s_renderer != renderer)
|
||||
|
@ -286,11 +287,8 @@ static int _GSopen(void** dsp, char* title, int renderer, int threads = -1)
|
|||
else
|
||||
s_gs->m_wnd = new GSWndDX();
|
||||
#else
|
||||
#ifdef EGL_API
|
||||
s_gs->m_wnd = new GSWndEGL();
|
||||
#else
|
||||
s_gs->m_wnd = new GSWndOGL();
|
||||
#endif
|
||||
wnd[0] = new GSWndOGL();
|
||||
wnd[1] = new GSWndEGL();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -317,12 +315,39 @@ static int _GSopen(void** dsp, char* title, int renderer, int threads = -1)
|
|||
int w = theApp.GetConfig("ModeWidth", 0);
|
||||
int h = theApp.GetConfig("ModeHeight", 0);
|
||||
|
||||
#ifdef _LINUX
|
||||
for(uint32 i = 0; i < 2; i++) {
|
||||
try
|
||||
{
|
||||
if (wnd[i] == NULL) continue;
|
||||
|
||||
wnd[i]->Create(title, w, h);
|
||||
s_gs->m_wnd = wnd[i];
|
||||
|
||||
if (i == 0) delete wnd[1];
|
||||
|
||||
break;
|
||||
}
|
||||
catch (GSDXRecoverableError)
|
||||
{
|
||||
delete wnd[i];
|
||||
}
|
||||
}
|
||||
if (s_gs->m_wnd == NULL)
|
||||
{
|
||||
GSclose();
|
||||
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
#ifdef _WINDOWS
|
||||
if(!s_gs->CreateWnd(title, w, h))
|
||||
{
|
||||
GSclose();
|
||||
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
s_gs->m_wnd->Show();
|
||||
|
||||
|
@ -333,10 +358,30 @@ static int _GSopen(void** dsp, char* title, int renderer, int threads = -1)
|
|||
s_gs->SetMultithreaded(true);
|
||||
|
||||
#ifdef _LINUX
|
||||
// Get the Xwindow from dsp.
|
||||
if( !s_gs->m_wnd->Attach((void*)((uint32*)(dsp)+1), false) )
|
||||
for(uint32 i = 0; i < 2; i++) {
|
||||
try
|
||||
{
|
||||
if (wnd[i] == NULL) continue;
|
||||
|
||||
wnd[i]->Attach((void*)((uint32*)(dsp)+1), false);
|
||||
s_gs->m_wnd = wnd[i];
|
||||
|
||||
if (i == 0) delete wnd[1];
|
||||
|
||||
break;
|
||||
}
|
||||
catch (GSDXRecoverableError)
|
||||
{
|
||||
wnd[i]->Detach();
|
||||
delete wnd[i];
|
||||
}
|
||||
}
|
||||
if (s_gs->m_wnd == NULL)
|
||||
{
|
||||
return -1;
|
||||
#else
|
||||
}
|
||||
#endif
|
||||
#ifdef _WINDOWS
|
||||
s_gs->m_wnd->Attach(*dsp, false);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ GSWndEGL::GSWndEGL()
|
|||
{
|
||||
}
|
||||
|
||||
bool GSWndEGL::CreateContext(int major, int minor)
|
||||
void GSWndEGL::CreateContext(int major, int minor)
|
||||
{
|
||||
EGLConfig eglConfig;
|
||||
EGLint numConfigs;
|
||||
|
@ -60,14 +60,14 @@ bool GSWndEGL::CreateContext(int major, int minor)
|
|||
if ( !eglChooseConfig(m_eglDisplay, attrList, &eglConfig, 1, &numConfigs) )
|
||||
{
|
||||
fprintf(stderr,"EGL: Failed to get a frame buffer config!\n");
|
||||
return EGL_FALSE;
|
||||
throw GSDXRecoverableError();
|
||||
}
|
||||
|
||||
m_eglSurface = eglCreateWindowSurface(m_eglDisplay, eglConfig, m_NativeWindow, NULL);
|
||||
if ( m_eglSurface == EGL_NO_SURFACE )
|
||||
{
|
||||
fprintf(stderr,"EGL: Failed to get a window surface\n");
|
||||
return EGL_FALSE;
|
||||
throw GSDXRecoverableError();
|
||||
}
|
||||
|
||||
m_eglContext = eglCreateContext(m_eglDisplay, eglConfig, EGL_NO_CONTEXT, contextAttribs );
|
||||
|
@ -75,15 +75,13 @@ bool GSWndEGL::CreateContext(int major, int minor)
|
|||
{
|
||||
fprintf(stderr,"EGL: Failed to create the context\n");
|
||||
fprintf(stderr,"EGL STATUS: %x\n", eglGetError());
|
||||
return EGL_FALSE;
|
||||
throw GSDXRecoverableError();
|
||||
}
|
||||
|
||||
if ( !eglMakeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext) )
|
||||
{
|
||||
return EGL_FALSE;
|
||||
throw GSDXRecoverableError();
|
||||
}
|
||||
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
||||
void GSWndEGL::AttachContext()
|
||||
|
@ -120,10 +118,9 @@ bool GSWndEGL::Attach(void* handle, bool managed)
|
|||
m_managed = managed;
|
||||
|
||||
m_NativeDisplay = XOpenDisplay(NULL);
|
||||
if (!OpenEGLDisplay()) return false;
|
||||
OpenEGLDisplay();
|
||||
|
||||
// Note: 4.2 crash on latest nvidia drivers!
|
||||
if (!CreateContext(3, 3)) return false;
|
||||
CreateContext(3, 3);
|
||||
|
||||
AttachContext();
|
||||
|
||||
|
@ -149,7 +146,8 @@ void GSWndEGL::Detach()
|
|||
|
||||
bool GSWndEGL::Create(const string& title, int w, int h)
|
||||
{
|
||||
if(m_NativeWindow) return false;
|
||||
if(m_NativeWindow)
|
||||
throw GSDXRecoverableError();
|
||||
|
||||
if(w <= 0 || h <= 0) {
|
||||
w = theApp.GetConfig("ModeWidth", 640);
|
||||
|
@ -160,21 +158,21 @@ bool GSWndEGL::Create(const string& title, int w, int h)
|
|||
|
||||
// note this part must be only executed when replaying .gs debug file
|
||||
m_NativeDisplay = XOpenDisplay(NULL);
|
||||
if (!OpenEGLDisplay()) return false;
|
||||
OpenEGLDisplay();
|
||||
|
||||
m_NativeWindow = XCreateSimpleWindow(m_NativeDisplay, DefaultRootWindow(m_NativeDisplay), 0, 0, w, h, 0, 0, 0);
|
||||
|
||||
XMapWindow (m_NativeDisplay, m_NativeWindow);
|
||||
|
||||
if (!CreateContext(3, 3)) return false;
|
||||
CreateContext(3, 3);
|
||||
|
||||
AttachContext();
|
||||
|
||||
CheckContext();
|
||||
|
||||
PopulateGlFunction();
|
||||
if (m_NativeWindow != 0)
|
||||
throw GSDXRecoverableError();
|
||||
|
||||
return (m_NativeWindow != 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
void* GSWndEGL::GetProcAddress(const char* name)
|
||||
|
@ -182,6 +180,7 @@ void* GSWndEGL::GetProcAddress(const char* name)
|
|||
void* ptr = (void*)eglGetProcAddress(name);
|
||||
if (ptr == NULL) {
|
||||
fprintf(stderr, "Failed to find %s\n", name);
|
||||
throw GSDXRecoverableError();
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
|
@ -265,15 +264,15 @@ void GSWndEGL::CloseEGLDisplay()
|
|||
eglTerminate(m_eglDisplay);
|
||||
}
|
||||
|
||||
EGLBoolean GSWndEGL::OpenEGLDisplay()
|
||||
void GSWndEGL::OpenEGLDisplay()
|
||||
{
|
||||
// Create an EGL display from the native display
|
||||
m_eglDisplay = eglGetDisplay((EGLNativeDisplayType)m_NativeDisplay);
|
||||
if ( m_eglDisplay == EGL_NO_DISPLAY ) return EGL_FALSE;
|
||||
if ( m_eglDisplay == EGL_NO_DISPLAY )
|
||||
throw GSDXRecoverableError();
|
||||
|
||||
if ( !eglInitialize(m_eglDisplay, NULL, NULL) ) return EGL_FALSE;
|
||||
|
||||
return EGL_TRUE;
|
||||
if ( !eglInitialize(m_eglDisplay, NULL, NULL) )
|
||||
throw GSDXRecoverableError();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -54,10 +54,10 @@ class GSWndEGL : public GSWndGL
|
|||
EGLSurface m_eglSurface;
|
||||
EGLContext m_eglContext;
|
||||
|
||||
bool CreateContext(int major, int minor);
|
||||
void CreateContext(int major, int minor);
|
||||
void CheckContext();
|
||||
|
||||
EGLBoolean OpenEGLDisplay();
|
||||
void OpenEGLDisplay();
|
||||
void CloseEGLDisplay();
|
||||
|
||||
public:
|
||||
|
|
|
@ -35,12 +35,12 @@ static int ctxErrorHandler(Display *dpy, XErrorEvent *ev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
bool GSWndOGL::CreateContext(int major, int minor)
|
||||
void GSWndOGL::CreateContext(int major, int minor)
|
||||
{
|
||||
if ( !m_NativeDisplay || !m_NativeWindow )
|
||||
{
|
||||
fprintf( stderr, "Wrong X11 display/window\n" );
|
||||
exit(1);
|
||||
throw GSDXRecoverableError();
|
||||
}
|
||||
|
||||
// Get visual information
|
||||
|
@ -60,10 +60,14 @@ bool GSWndOGL::CreateContext(int major, int minor)
|
|||
PFNGLXCHOOSEFBCONFIGPROC glX_ChooseFBConfig = (PFNGLXCHOOSEFBCONFIGPROC) glXGetProcAddress((GLubyte *) "glXChooseFBConfig");
|
||||
int fbcount = 0;
|
||||
GLXFBConfig *fbc = glX_ChooseFBConfig(m_NativeDisplay, DefaultScreen(m_NativeDisplay), attrListDbl, &fbcount);
|
||||
if (!fbc || fbcount < 1) return false;
|
||||
if (!fbc || fbcount < 1) {
|
||||
throw GSDXRecoverableError();
|
||||
}
|
||||
|
||||
PFNGLXCREATECONTEXTATTRIBSARBPROC glX_CreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC)glXGetProcAddress((const GLubyte*) "glXCreateContextAttribsARB");
|
||||
if (!glX_CreateContextAttribsARB) return false;
|
||||
if (!glX_CreateContextAttribsARB) {
|
||||
throw GSDXRecoverableError();
|
||||
}
|
||||
|
||||
// Install a dummy handler to handle gracefully (aka not segfault) the support of GL version
|
||||
int (*oldHandler)(Display*, XErrorEvent*) = XSetErrorHandler(&ctxErrorHandler);
|
||||
|
@ -92,10 +96,8 @@ bool GSWndOGL::CreateContext(int major, int minor)
|
|||
|
||||
if (!m_context || ctxError) {
|
||||
fprintf(stderr, "Failed to create the opengl context. Check your drivers support openGL %d.%d. Hint: opensource drivers don't\n", major, minor );
|
||||
return false;
|
||||
throw GSDXRecoverableError();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void GSWndOGL::AttachContext()
|
||||
|
@ -122,8 +124,10 @@ void GSWndOGL::CheckContext()
|
|||
glXQueryVersion(m_NativeDisplay, &glxMajorVersion, &glxMinorVersion);
|
||||
if (glXIsDirect(m_NativeDisplay, m_context))
|
||||
fprintf(stderr, "glX-Version %d.%d with Direct Rendering\n", glxMajorVersion, glxMinorVersion);
|
||||
else
|
||||
else {
|
||||
fprintf(stderr, "glX-Version %d.%d with Indirect Rendering !!! It won't support properly opengl\n", glxMajorVersion, glxMinorVersion);
|
||||
throw GSDXRecoverableError();
|
||||
}
|
||||
}
|
||||
|
||||
bool GSWndOGL::Attach(void* handle, bool managed)
|
||||
|
@ -133,12 +137,7 @@ bool GSWndOGL::Attach(void* handle, bool managed)
|
|||
|
||||
m_NativeDisplay = XOpenDisplay(NULL);
|
||||
|
||||
// Note: 4.2 crash on latest nvidia drivers!
|
||||
#ifdef OGL_FREE_DRIVER
|
||||
if (!CreateContext(3, 0)) return false;
|
||||
#else
|
||||
if (!CreateContext(3, 3)) return false;
|
||||
#endif
|
||||
CreateContext(3, 3);
|
||||
|
||||
AttachContext();
|
||||
|
||||
|
@ -167,7 +166,8 @@ void GSWndOGL::Detach()
|
|||
|
||||
bool GSWndOGL::Create(const string& title, int w, int h)
|
||||
{
|
||||
if(m_NativeWindow) return false;
|
||||
if(m_NativeWindow)
|
||||
throw GSDXRecoverableError();
|
||||
|
||||
if(w <= 0 || h <= 0) {
|
||||
w = theApp.GetConfig("ModeWidth", 640);
|
||||
|
@ -180,11 +180,9 @@ bool GSWndOGL::Create(const string& title, int w, int h)
|
|||
m_NativeDisplay = XOpenDisplay(NULL);
|
||||
|
||||
m_NativeWindow = XCreateSimpleWindow(m_NativeDisplay, DefaultRootWindow(m_NativeDisplay), 0, 0, w, h, 0, 0, 0);
|
||||
|
||||
XMapWindow (m_NativeDisplay, m_NativeWindow);
|
||||
|
||||
|
||||
if (!CreateContext(3, 3)) return false;
|
||||
CreateContext(3, 3);
|
||||
|
||||
AttachContext();
|
||||
|
||||
|
@ -192,7 +190,10 @@ bool GSWndOGL::Create(const string& title, int w, int h)
|
|||
|
||||
PopulateGlFunction();
|
||||
|
||||
return (m_NativeWindow != 0);
|
||||
if (m_NativeWindow != 0)
|
||||
throw GSDXRecoverableError();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void* GSWndOGL::GetProcAddress(const char* name)
|
||||
|
@ -200,6 +201,7 @@ void* GSWndOGL::GetProcAddress(const char* name)
|
|||
void* ptr = (void*)glXGetProcAddress((const GLubyte*)name);
|
||||
if (ptr == NULL) {
|
||||
fprintf(stderr, "Failed to find %s\n", name);
|
||||
throw GSDXRecoverableError();
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ class GSWndOGL : public GSWndGL
|
|||
|
||||
PFNGLXSWAPINTERVALMESAPROC m_swapinterval;
|
||||
|
||||
bool CreateContext(int major, int minor);
|
||||
void CreateContext(int major, int minor);
|
||||
void CheckContext();
|
||||
|
||||
public:
|
||||
|
|
|
@ -40,6 +40,3 @@
|
|||
#ifdef _DEBUG
|
||||
#define ENABLE_OGL_DEBUG // Create a debug context and check opengl command status. Allow also to dump various textures/states.
|
||||
#endif
|
||||
|
||||
// Allow to create only a 3.0 context for opensource driver
|
||||
//#define OGL_FREE_DRIVER
|
||||
|
|
Loading…
Reference in New Issue