gsdx-ogl:

* add some define to enable/disable SDL so we could build gsdx without SDL
* debug: dump data based on frame count rather from draw count


git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@5044 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
gregory.hainaut 2012-01-04 23:19:17 +00:00
parent 4c5d1e11a8
commit 0e80e0adca
10 changed files with 72 additions and 22 deletions

View File

@ -121,13 +121,13 @@ endif(GTK2_FOUND)
# -X11 # -X11
# -PCSX2 SDL # -PCSX2 SDL
#--------------------------------------- #---------------------------------------
if(OPENGL_FOUND AND X11_FOUND AND projectSDL) if(OPENGL_FOUND AND X11_FOUND)
set(GSdx TRUE) set(GSdx TRUE)
else(OPENGL_FOUND AND X11_FOUND AND projectSDL) else(OPENGL_FOUND AND X11_FOUND)
set(GSdx FALSE) set(GSdx FALSE)
message(STATUS "Skip build of GSdx: miss some dependencies") message(STATUS "Skip build of GSdx: miss some dependencies")
message(STATUS "${msg_dep_gsdx}") message(STATUS "${msg_dep_gsdx}")
endif(OPENGL_FOUND AND X11_FOUND AND projectSDL) endif(OPENGL_FOUND AND X11_FOUND)
#--------------------------------------- #---------------------------------------
#--------------------------------------- #---------------------------------------

View File

@ -18,7 +18,7 @@ set(CommonFlags
-Wunused-variable -Wunused-variable
-std=c++0x -std=c++0x
-fno-strict-aliasing -fno-strict-aliasing
-DOGL_DEBUG -DOGL_DEBUG # FIXME remove me when code is ready
-DAMD_DRIVER_WORKAROUND -DAMD_DRIVER_WORKAROUND
) )
@ -27,21 +27,22 @@ set(OptimizationFlags
-DNDEBUG -DNDEBUG
) )
if(projectSDL)
add_definitions(-DENABLE_SDL_DEV)
endif(projectSDL)
# Debug - Build # Debug - Build
if(CMAKE_BUILD_TYPE STREQUAL Debug) if(CMAKE_BUILD_TYPE STREQUAL Debug)
# add defines
add_definitions(${CommonFlags} -DOGL_DEBUG -g -Wall) add_definitions(${CommonFlags} -DOGL_DEBUG -g -Wall)
endif(CMAKE_BUILD_TYPE STREQUAL Debug) endif(CMAKE_BUILD_TYPE STREQUAL Debug)
# Devel - Build # Devel - Build
if(CMAKE_BUILD_TYPE STREQUAL Devel) if(CMAKE_BUILD_TYPE STREQUAL Devel)
# add defines
add_definitions(${CommonFlags} ${OptimizationFlags} -g -W) add_definitions(${CommonFlags} ${OptimizationFlags} -g -W)
endif(CMAKE_BUILD_TYPE STREQUAL Devel) endif(CMAKE_BUILD_TYPE STREQUAL Devel)
# Release - Build # Release - Build
if(CMAKE_BUILD_TYPE STREQUAL Release) if(CMAKE_BUILD_TYPE STREQUAL Release)
# add defines
add_definitions(${CommonFlags} ${OptimizationFlags} -W) add_definitions(${CommonFlags} ${OptimizationFlags} -W)
endif(CMAKE_BUILD_TYPE STREQUAL Release) endif(CMAKE_BUILD_TYPE STREQUAL Release)
@ -188,8 +189,9 @@ add_library(${Output} SHARED
# link target with X11 # link target with X11
target_link_libraries(${Output} ${X11_LIBRARIES}) target_link_libraries(${Output} ${X11_LIBRARIES})
# link target with SDL if(projectSDL)
target_link_libraries(${Output} ${SDL_LIBRARY}) target_link_libraries(${Output} ${SDL_LIBRARY})
endif(projectSDL)
# link target with glew # link target with glew
target_link_libraries(${Output} ${GLEW_LIBRARY}) target_link_libraries(${Output} ${GLEW_LIBRARY})

View File

@ -118,7 +118,9 @@ EXPORT_C_(int32) GPUopen(void* hWnd)
case 0: s_gpu = new GPURendererSW(new GSDevice9(), threads); break; case 0: s_gpu = new GPURendererSW(new GSDevice9(), threads); break;
case 1: s_gpu = new GPURendererSW(new GSDevice11(), threads); break; case 1: s_gpu = new GPURendererSW(new GSDevice11(), threads); break;
#endif #endif
#ifdef ENABLE_SDL_DEV
case 2: s_gpu = new GPURendererSW(new GSDeviceSDL(), threads); break; case 2: s_gpu = new GPURendererSW(new GSDeviceSDL(), threads); break;
#endif
case 3: s_gpu = new GPURendererSW(new GSDeviceNull(), threads); break; case 3: s_gpu = new GPURendererSW(new GSDeviceNull(), threads); break;
//case 4: s_gpu = new GPURendererNull(new GSDeviceNull()); break; //case 4: s_gpu = new GPURendererNull(new GSDeviceNull()); break;
} }

View File

@ -136,6 +136,7 @@ EXPORT_C_(int) GSinit()
#endif #endif
#ifdef ENABLE_SDL_DEV
if(!SDL_WasInit(SDL_INIT_VIDEO)) if(!SDL_WasInit(SDL_INIT_VIDEO))
{ {
if(SDL_Init(SDL_INIT_VIDEO) < 0) if(SDL_Init(SDL_INIT_VIDEO) < 0)
@ -143,6 +144,7 @@ EXPORT_C_(int) GSinit()
return -1; return -1;
} }
} }
#endif
return 0; return 0;
} }
@ -155,7 +157,9 @@ EXPORT_C GSshutdown()
s_renderer = -1; s_renderer = -1;
#ifdef ENABLE_SDL_DEV
SDL_Quit(); SDL_Quit();
#endif
#ifdef _WINDOWS #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 0: dev = new GSDevice9(); break;
case 1: dev = new GSDevice11(); break; case 1: dev = new GSDevice11(); break;
#endif #endif
#ifdef ENABLE_SDL_DEV
case 2: dev = new GSDeviceSDL(); break; case 2: dev = new GSDeviceSDL(); break;
#else
case 2: dev = NULL; break;
#endif
case 3: dev = new GSDeviceNull(); break; case 3: dev = new GSDeviceNull(); break;
case 4: dev = new GSDeviceOGL(); 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); s_gs->SetMultithreaded(true);
#ifdef __LINUX__ #ifdef _LINUX
// Get the Xwindow from dsp. // Get the Xwindow from dsp.
if( !s_gs->m_wnd.Attach((void*)((uint32*)(dsp)+1), false) ) if( !s_gs->m_wnd.Attach((void*)((uint32*)(dsp)+1), false) )
return -1; return -1;
@ -325,7 +333,8 @@ EXPORT_C_(int) GSopen2(void** dsp, uint32 flags)
int retval = _GSopen(dsp, NULL, renderer); 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; return retval;
} }

View File

@ -56,9 +56,10 @@
#define SHADER_DEBUG #define SHADER_DEBUG
//#define DUMP_START (70) //#define DUMP_START (70)
//#define DUMP_LENGTH (130) //#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 //#define DISABLE_DUAL_BLEND
#ifdef DUMP_START #ifdef DUMP_START
@ -337,6 +338,10 @@ bool GSDeviceOGL::Create(GSWnd* wnd)
// FIXME enable it when multisample code will be here // FIXME enable it when multisample code will be here
// DX: rd.MultisampleEnable = true; // DX: rd.MultisampleEnable = true;
glDisable(GL_MULTISAMPLE); 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 // Hum I don't know for those options but let's hope there are not activated
#if 0 #if 0
rd.FrontCounterClockwise = false; rd.FrontCounterClockwise = false;
@ -513,6 +518,9 @@ void GSDeviceOGL::Flip()
// FIXME: disable it when code is working // FIXME: disable it when code is working
CheckDebugLog(); CheckDebugLog();
m_wnd->Flip(); m_wnd->Flip();
#ifdef PRINT_FRAME_NUMBER
fprintf(stderr, "Draw %d (Frame %d)\n", g_draw_count, g_frame_count);
#endif
#ifdef DUMP_START #ifdef DUMP_START
g_frame_count++; g_frame_count++;
#endif #endif
@ -522,14 +530,8 @@ void GSDeviceOGL::DrawPrimitive()
{ {
#ifdef DUMP_START #ifdef DUMP_START
bool dump_me = false; 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; 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 #endif
// DUMP INPUT // DUMP INPUT

View File

@ -408,7 +408,7 @@ public:
topo = "triangle"; topo = "triangle";
break; break;
case GL_TRIANGLE_STRIP: case GL_TRIANGLE_STRIP:
element = m_count - 3; element = m_count - 2;
topo = "triangle strip"; topo = "triangle strip";
break; break;
} }

View File

@ -22,6 +22,7 @@
#include "stdafx.h" #include "stdafx.h"
#include "GSDeviceSDL.h" #include "GSDeviceSDL.h"
#ifdef ENABLE_SDL_DEV
GSDeviceSDL::GSDeviceSDL() GSDeviceSDL::GSDeviceSDL()
: m_free_window(false) : m_free_window(false)
, m_window(NULL) , m_window(NULL)
@ -230,3 +231,4 @@ void GSDeviceSDL::Flip()
{ {
SDL_RenderPresent(m_renderer); SDL_RenderPresent(m_renderer);
} }
#endif

View File

@ -21,6 +21,8 @@
#pragma once #pragma once
#ifdef ENABLE_SDL_DEV
#include "GSDeviceSW.h" #include "GSDeviceSW.h"
#include "../../3rdparty/SDL-1.3.0-5387/include/SDL.h" #include "../../3rdparty/SDL-1.3.0-5387/include/SDL.h"
@ -53,3 +55,4 @@ public:
void Present(GSTexture* st, GSTexture* dt, const GSVector4& dr, int shader = 0); void Present(GSTexture* st, GSTexture* dt, const GSVector4& dr, int shader = 0);
void Flip(); void Flip();
}; };
#endif

View File

@ -318,11 +318,13 @@ GSWnd::GSWnd()
GSWnd::~GSWnd() GSWnd::~GSWnd()
{ {
#ifdef ENABLE_SDL_DEV
if(m_window != NULL && m_managed) if(m_window != NULL && m_managed)
{ {
SDL_DestroyWindow(m_window); SDL_DestroyWindow(m_window);
m_window = NULL; m_window = NULL;
} }
#endif
if (m_XDisplay) { if (m_XDisplay) {
XCloseDisplay(m_XDisplay); XCloseDisplay(m_XDisplay);
m_XDisplay = NULL; m_XDisplay = NULL;
@ -402,11 +404,13 @@ void GSWnd::Detach()
// Actually the destructor is not called when there is only a GSclose/GSshutdown // Actually the destructor is not called when there is only a GSclose/GSshutdown
// The window still need to be closed // The window still need to be closed
if (m_renderer == 2) { if (m_renderer == 2) {
#ifdef ENABLE_SDL_DEV
if(m_window != NULL && m_managed) if(m_window != NULL && m_managed)
{ {
SDL_DestroyWindow(m_window); SDL_DestroyWindow(m_window);
m_window = NULL; m_window = NULL;
} }
#endif
} else { } else {
glXMakeCurrent(m_XDisplay, None, NULL); glXMakeCurrent(m_XDisplay, None, NULL);
if (m_context) glXDestroyContext(m_XDisplay, m_context); 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) bool GSWnd::Create(const string& title, int w, int h)
{ {
#ifdef ENABLE_SDL_DEV
if(m_window != NULL) return false; if(m_window != NULL) return false;
if(w <= 0 || h <= 0) { 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; m_Xwindow = wminfo.info.x11.window;
return (m_window != NULL); return (m_window != NULL);
#else
return false;
#endif
} }
Display* GSWnd::GetDisplay() Display* GSWnd::GetDisplay()
{ {
#ifdef ENABLE_SDL_DEV
SDL_SysWMinfo wminfo; SDL_SysWMinfo wminfo;
memset(&wminfo, 0, sizeof(wminfo)); memset(&wminfo, 0, sizeof(wminfo));
@ -470,6 +479,9 @@ Display* GSWnd::GetDisplay()
SDL_GetWindowWMInfo(m_window, &wminfo); SDL_GetWindowWMInfo(m_window, &wminfo);
return wminfo.subsystem == SDL_SYSWM_X11 ? wminfo.info.x11.display : NULL; return wminfo.subsystem == SDL_SYSWM_X11 ? wminfo.info.x11.display : NULL;
#else
return NULL;
#endif
} }
GSVector4i GSWnd::GetClientRect() GSVector4i GSWnd::GetClientRect()
@ -490,8 +502,10 @@ GSVector4i GSWnd::GetClientRect()
// In real world...: // In real world...:
if (!m_XDisplay) m_XDisplay = XOpenDisplay(NULL); if (!m_XDisplay) m_XDisplay = XOpenDisplay(NULL);
XGetGeometry(m_XDisplay, m_Xwindow, &winDummy, &xDummy, &yDummy, &w, &h, &borderDummy, &depthDummy); XGetGeometry(m_XDisplay, m_Xwindow, &winDummy, &xDummy, &yDummy, &w, &h, &borderDummy, &depthDummy);
#ifdef ENABLE_SDL_DEV
if (m_renderer == 2) if (m_renderer == 2)
SDL_SetWindowSize(m_window, w, h); SDL_SetWindowSize(m_window, w, h);
#endif
return GSVector4i(0, 0, (int)w, (int)h); return GSVector4i(0, 0, (int)w, (int)h);
} }
@ -501,6 +515,7 @@ GSVector4i GSWnd::GetClientRect()
bool GSWnd::SetWindowText(const char* title) bool GSWnd::SetWindowText(const char* title)
{ {
#if ENABLE_SDL_DEV
if (!m_managed) return true; if (!m_managed) return true;
// Do not find anyway to check the current fullscreen status // 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); SDL_SetWindowTitle(m_window, title);
} }
#endif
return true; return true;
} }
void GSWnd::Flip() void GSWnd::Flip()
{ {
if (m_renderer == 2) { if (m_renderer == 2) {
#ifdef ENABLE_SDL_DEV
#if SDL_VERSION_ATLEAST(1,3,0) #if SDL_VERSION_ATLEAST(1,3,0)
SDL_GL_SwapWindow(m_window); SDL_GL_SwapWindow(m_window);
#else #else
SDL_GL_SwapBuffers(); SDL_GL_SwapBuffers();
#endif
#endif #endif
} else { } else {
glXSwapBuffers(m_XDisplay, m_Xwindow); glXSwapBuffers(m_XDisplay, m_Xwindow);
@ -538,7 +556,9 @@ void GSWnd::Flip()
void GSWnd::Show() void GSWnd::Show()
{ {
if (m_renderer == 2) { if (m_renderer == 2) {
#ifdef ENABLE_SDL_DEV
SDL_ShowWindow(m_window); SDL_ShowWindow(m_window);
#endif
} else { } else {
XMapRaised(m_XDisplay, m_Xwindow); XMapRaised(m_XDisplay, m_Xwindow);
XFlush(m_XDisplay); XFlush(m_XDisplay);
@ -548,7 +568,9 @@ void GSWnd::Show()
void GSWnd::Hide() void GSWnd::Hide()
{ {
if (m_renderer == 2) { if (m_renderer == 2) {
#ifdef ENABLE_SDL_DEV
SDL_HideWindow(m_window); SDL_HideWindow(m_window);
#endif
} else { } else {
XUnmapWindow(m_XDisplay, m_Xwindow); XUnmapWindow(m_XDisplay, m_Xwindow);
XFlush(m_XDisplay); XFlush(m_XDisplay);

View File

@ -88,12 +88,18 @@ public:
}; };
*/ */
#include <X11/Xlib.h> #include <X11/Xlib.h>
#ifdef ENABLE_SDL_DEV
#include "../../3rdparty/SDL-1.3.0-5387/include/SDL.h" #include "../../3rdparty/SDL-1.3.0-5387/include/SDL.h"
#include "../../3rdparty/SDL-1.3.0-5387/include/SDL_syswm.h" #include "../../3rdparty/SDL-1.3.0-5387/include/SDL_syswm.h"
#endif
class GSWnd class GSWnd
{ {
#ifdef ENABLE_SDL_DEV
SDL_Window* m_window; SDL_Window* m_window;
#else
void* m_window;
#endif
Window m_Xwindow; Window m_Xwindow;
Display* m_XDisplay; Display* m_XDisplay;
bool m_managed; bool m_managed;
@ -113,7 +119,9 @@ public:
void* GetHandle() {return (void*)m_Xwindow;} void* GetHandle() {return (void*)m_Xwindow;}
GSVector4i GetClientRect(); GSVector4i GetClientRect();
bool SetWindowText(const char* title); bool SetWindowText(const char* title);
#ifdef ENABLE_SDL_DEV
void SetWindow(SDL_Window* current_window) { if (current_window) m_window = current_window; } void SetWindow(SDL_Window* current_window) { if (current_window) m_window = current_window; }
#endif
void Show(); void Show();
void Hide(); void Hide();