diff --git a/cmake/SelectPcsx2Plugins.cmake b/cmake/SelectPcsx2Plugins.cmake index b4cf72779e..b5e35e0f36 100644 --- a/cmake/SelectPcsx2Plugins.cmake +++ b/cmake/SelectPcsx2Plugins.cmake @@ -121,13 +121,13 @@ endif(GTK2_FOUND) # -X11 # -PCSX2 SDL #--------------------------------------- -if(OPENGL_FOUND AND X11_FOUND AND projectSDL) +if(OPENGL_FOUND AND X11_FOUND) set(GSdx TRUE) -else(OPENGL_FOUND AND X11_FOUND AND projectSDL) +else(OPENGL_FOUND AND X11_FOUND) set(GSdx FALSE) message(STATUS "Skip build of GSdx: miss some dependencies") message(STATUS "${msg_dep_gsdx}") -endif(OPENGL_FOUND AND X11_FOUND AND projectSDL) +endif(OPENGL_FOUND AND X11_FOUND) #--------------------------------------- #--------------------------------------- diff --git a/plugins/GSdx/CMakeLists.txt b/plugins/GSdx/CMakeLists.txt index b9690455c0..53bb692fa0 100644 --- a/plugins/GSdx/CMakeLists.txt +++ b/plugins/GSdx/CMakeLists.txt @@ -18,7 +18,7 @@ set(CommonFlags -Wunused-variable -std=c++0x -fno-strict-aliasing - -DOGL_DEBUG + -DOGL_DEBUG # FIXME remove me when code is ready -DAMD_DRIVER_WORKAROUND ) @@ -27,21 +27,22 @@ set(OptimizationFlags -DNDEBUG ) +if(projectSDL) + add_definitions(-DENABLE_SDL_DEV) +endif(projectSDL) + # Debug - Build if(CMAKE_BUILD_TYPE STREQUAL Debug) - # add defines add_definitions(${CommonFlags} -DOGL_DEBUG -g -Wall) endif(CMAKE_BUILD_TYPE STREQUAL Debug) # Devel - Build if(CMAKE_BUILD_TYPE STREQUAL Devel) - # add defines add_definitions(${CommonFlags} ${OptimizationFlags} -g -W) endif(CMAKE_BUILD_TYPE STREQUAL Devel) # Release - Build if(CMAKE_BUILD_TYPE STREQUAL Release) - # add defines add_definitions(${CommonFlags} ${OptimizationFlags} -W) endif(CMAKE_BUILD_TYPE STREQUAL Release) @@ -188,8 +189,9 @@ add_library(${Output} SHARED # link target with X11 target_link_libraries(${Output} ${X11_LIBRARIES}) -# link target with SDL -target_link_libraries(${Output} ${SDL_LIBRARY}) +if(projectSDL) + target_link_libraries(${Output} ${SDL_LIBRARY}) +endif(projectSDL) # link target with glew target_link_libraries(${Output} ${GLEW_LIBRARY}) diff --git a/plugins/GSdx/GPU.cpp b/plugins/GSdx/GPU.cpp index c2764016eb..4df60190c9 100644 --- a/plugins/GSdx/GPU.cpp +++ b/plugins/GSdx/GPU.cpp @@ -118,7 +118,9 @@ EXPORT_C_(int32) GPUopen(void* hWnd) case 0: s_gpu = new GPURendererSW(new GSDevice9(), threads); break; case 1: s_gpu = new GPURendererSW(new GSDevice11(), threads); break; #endif + #ifdef ENABLE_SDL_DEV case 2: s_gpu = new GPURendererSW(new GSDeviceSDL(), threads); break; + #endif case 3: s_gpu = new GPURendererSW(new GSDeviceNull(), threads); break; //case 4: s_gpu = new GPURendererNull(new GSDeviceNull()); break; } diff --git a/plugins/GSdx/GS.cpp b/plugins/GSdx/GS.cpp index a052142637..c0baf6196c 100644 --- a/plugins/GSdx/GS.cpp +++ b/plugins/GSdx/GS.cpp @@ -136,6 +136,7 @@ EXPORT_C_(int) GSinit() #endif +#ifdef ENABLE_SDL_DEV if(!SDL_WasInit(SDL_INIT_VIDEO)) { if(SDL_Init(SDL_INIT_VIDEO) < 0) @@ -143,6 +144,7 @@ EXPORT_C_(int) GSinit() return -1; } } +#endif return 0; } @@ -155,7 +157,9 @@ EXPORT_C GSshutdown() s_renderer = -1; +#ifdef ENABLE_SDL_DEV SDL_Quit(); +#endif #ifdef _WINDOWS @@ -216,7 +220,11 @@ static int _GSopen(void** dsp, char* title, int renderer, int threads = -1) case 0: dev = new GSDevice9(); break; case 1: dev = new GSDevice11(); break; #endif + #ifdef ENABLE_SDL_DEV case 2: dev = new GSDeviceSDL(); break; + #else + case 2: dev = NULL; break; + #endif case 3: dev = new GSDeviceNull(); break; case 4: dev = new GSDeviceOGL(); break; } @@ -287,7 +295,7 @@ static int _GSopen(void** dsp, char* title, int renderer, int threads = -1) { s_gs->SetMultithreaded(true); -#ifdef __LINUX__ +#ifdef _LINUX // Get the Xwindow from dsp. if( !s_gs->m_wnd.Attach((void*)((uint32*)(dsp)+1), false) ) return -1; @@ -325,7 +333,8 @@ EXPORT_C_(int) GSopen2(void** dsp, uint32 flags) int retval = _GSopen(dsp, NULL, renderer); - s_gs->SetAspectRatio(0); // PCSX2 manages the aspect ratios + if (s_gs != NULL) + s_gs->SetAspectRatio(0); // PCSX2 manages the aspect ratios return retval; } diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index cf53ec34b6..57aa9b8966 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -56,9 +56,10 @@ #define SHADER_DEBUG //#define DUMP_START (70) //#define DUMP_LENGTH (130) -//#define DUMP_ONLY_FRAME (112) +//#define PRINT_FRAME_NUMBER +//#define ONLY_LINES -// It seems dual blending does not work (at least on AMD) +// It seems dual blending does not work on AMD !!! //#define DISABLE_DUAL_BLEND #ifdef DUMP_START @@ -337,6 +338,10 @@ bool GSDeviceOGL::Create(GSWnd* wnd) // FIXME enable it when multisample code will be here // DX: rd.MultisampleEnable = true; glDisable(GL_MULTISAMPLE); +#ifdef ONLY_LINES + glLineWidth(5.0); + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); +#endif // Hum I don't know for those options but let's hope there are not activated #if 0 rd.FrontCounterClockwise = false; @@ -513,6 +518,9 @@ void GSDeviceOGL::Flip() // FIXME: disable it when code is working CheckDebugLog(); m_wnd->Flip(); +#ifdef PRINT_FRAME_NUMBER + fprintf(stderr, "Draw %d (Frame %d)\n", g_draw_count, g_frame_count); +#endif #ifdef DUMP_START g_frame_count++; #endif @@ -522,14 +530,8 @@ void GSDeviceOGL::DrawPrimitive() { #ifdef DUMP_START bool dump_me = false; - if ( (g_draw_count > DUMP_START && g_draw_count < (DUMP_START+DUMP_LENGTH)) ) + if ( (g_frame_count > DUMP_START && g_frame_count < (DUMP_START+DUMP_LENGTH)) ) dump_me = true; -#ifdef DUMP_ONLY_FRAME - if (DUMP_ONLY_FRAME != 0 && DUMP_ONLY_FRAME == g_frame_count) - dump_me = true; - else if (DUMP_ONLY_FRAME != 0) - dump_me = false; -#endif #endif // DUMP INPUT diff --git a/plugins/GSdx/GSDeviceOGL.h b/plugins/GSdx/GSDeviceOGL.h index 653218b98c..2e727d3922 100644 --- a/plugins/GSdx/GSDeviceOGL.h +++ b/plugins/GSdx/GSDeviceOGL.h @@ -408,7 +408,7 @@ public: topo = "triangle"; break; case GL_TRIANGLE_STRIP: - element = m_count - 3; + element = m_count - 2; topo = "triangle strip"; break; } diff --git a/plugins/GSdx/GSDeviceSDL.cpp b/plugins/GSdx/GSDeviceSDL.cpp index be0a15ecdf..1fccc4b386 100644 --- a/plugins/GSdx/GSDeviceSDL.cpp +++ b/plugins/GSdx/GSDeviceSDL.cpp @@ -22,6 +22,7 @@ #include "stdafx.h" #include "GSDeviceSDL.h" +#ifdef ENABLE_SDL_DEV GSDeviceSDL::GSDeviceSDL() : m_free_window(false) , m_window(NULL) @@ -230,3 +231,4 @@ void GSDeviceSDL::Flip() { SDL_RenderPresent(m_renderer); } +#endif diff --git a/plugins/GSdx/GSDeviceSDL.h b/plugins/GSdx/GSDeviceSDL.h index 324d41c2c8..6a61ce30f2 100644 --- a/plugins/GSdx/GSDeviceSDL.h +++ b/plugins/GSdx/GSDeviceSDL.h @@ -21,6 +21,8 @@ #pragma once +#ifdef ENABLE_SDL_DEV + #include "GSDeviceSW.h" #include "../../3rdparty/SDL-1.3.0-5387/include/SDL.h" @@ -52,4 +54,5 @@ public: bool Reset(int w, int h); void Present(GSTexture* st, GSTexture* dt, const GSVector4& dr, int shader = 0); void Flip(); -}; \ No newline at end of file +}; +#endif diff --git a/plugins/GSdx/GSWnd.cpp b/plugins/GSdx/GSWnd.cpp index a977aba0f2..d3ec81e6f1 100644 --- a/plugins/GSdx/GSWnd.cpp +++ b/plugins/GSdx/GSWnd.cpp @@ -318,11 +318,13 @@ GSWnd::GSWnd() GSWnd::~GSWnd() { +#ifdef ENABLE_SDL_DEV if(m_window != NULL && m_managed) { SDL_DestroyWindow(m_window); m_window = NULL; } +#endif if (m_XDisplay) { XCloseDisplay(m_XDisplay); m_XDisplay = NULL; @@ -402,11 +404,13 @@ void GSWnd::Detach() // Actually the destructor is not called when there is only a GSclose/GSshutdown // The window still need to be closed if (m_renderer == 2) { +#ifdef ENABLE_SDL_DEV if(m_window != NULL && m_managed) { SDL_DestroyWindow(m_window); m_window = NULL; } +#endif } else { glXMakeCurrent(m_XDisplay, None, NULL); if (m_context) glXDestroyContext(m_XDisplay, m_context); @@ -419,6 +423,7 @@ void GSWnd::Detach() bool GSWnd::Create(const string& title, int w, int h) { +#ifdef ENABLE_SDL_DEV if(m_window != NULL) return false; if(w <= 0 || h <= 0) { @@ -456,10 +461,14 @@ bool GSWnd::Create(const string& title, int w, int h) m_Xwindow = wminfo.info.x11.window; return (m_window != NULL); +#else + return false; +#endif } Display* GSWnd::GetDisplay() { +#ifdef ENABLE_SDL_DEV SDL_SysWMinfo wminfo; memset(&wminfo, 0, sizeof(wminfo)); @@ -470,6 +479,9 @@ Display* GSWnd::GetDisplay() SDL_GetWindowWMInfo(m_window, &wminfo); return wminfo.subsystem == SDL_SYSWM_X11 ? wminfo.info.x11.display : NULL; +#else + return NULL; +#endif } GSVector4i GSWnd::GetClientRect() @@ -490,8 +502,10 @@ GSVector4i GSWnd::GetClientRect() // In real world...: if (!m_XDisplay) m_XDisplay = XOpenDisplay(NULL); XGetGeometry(m_XDisplay, m_Xwindow, &winDummy, &xDummy, &yDummy, &w, &h, &borderDummy, &depthDummy); +#ifdef ENABLE_SDL_DEV if (m_renderer == 2) SDL_SetWindowSize(m_window, w, h); +#endif return GSVector4i(0, 0, (int)w, (int)h); } @@ -501,6 +515,7 @@ GSVector4i GSWnd::GetClientRect() bool GSWnd::SetWindowText(const char* title) { +#if ENABLE_SDL_DEV if (!m_managed) return true; // Do not find anyway to check the current fullscreen status @@ -519,16 +534,19 @@ bool GSWnd::SetWindowText(const char* title) SDL_SetWindowTitle(m_window, title); } +#endif return true; } void GSWnd::Flip() { if (m_renderer == 2) { +#ifdef ENABLE_SDL_DEV #if SDL_VERSION_ATLEAST(1,3,0) SDL_GL_SwapWindow(m_window); #else SDL_GL_SwapBuffers(); +#endif #endif } else { glXSwapBuffers(m_XDisplay, m_Xwindow); @@ -538,7 +556,9 @@ void GSWnd::Flip() void GSWnd::Show() { if (m_renderer == 2) { +#ifdef ENABLE_SDL_DEV SDL_ShowWindow(m_window); +#endif } else { XMapRaised(m_XDisplay, m_Xwindow); XFlush(m_XDisplay); @@ -548,7 +568,9 @@ void GSWnd::Show() void GSWnd::Hide() { if (m_renderer == 2) { +#ifdef ENABLE_SDL_DEV SDL_HideWindow(m_window); +#endif } else { XUnmapWindow(m_XDisplay, m_Xwindow); XFlush(m_XDisplay); diff --git a/plugins/GSdx/GSWnd.h b/plugins/GSdx/GSWnd.h index 44fcc844db..6e85a3aef5 100644 --- a/plugins/GSdx/GSWnd.h +++ b/plugins/GSdx/GSWnd.h @@ -88,12 +88,18 @@ public: }; */ #include +#ifdef ENABLE_SDL_DEV #include "../../3rdparty/SDL-1.3.0-5387/include/SDL.h" #include "../../3rdparty/SDL-1.3.0-5387/include/SDL_syswm.h" +#endif class GSWnd { +#ifdef ENABLE_SDL_DEV SDL_Window* m_window; +#else + void* m_window; +#endif Window m_Xwindow; Display* m_XDisplay; bool m_managed; @@ -113,7 +119,9 @@ public: void* GetHandle() {return (void*)m_Xwindow;} GSVector4i GetClientRect(); bool SetWindowText(const char* title); +#ifdef ENABLE_SDL_DEV void SetWindow(SDL_Window* current_window) { if (current_window) m_window = current_window; } +#endif void Show(); void Hide();