Some cleanup in OGL plugin and VideoCommon

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2329 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
omegadox 2009-02-21 02:42:35 +00:00
parent e6ca85c059
commit 228652b070
9 changed files with 91 additions and 125 deletions

View File

@ -29,6 +29,7 @@
#define BPMEM_ZMODE 0x40 #define BPMEM_ZMODE 0x40
#define BPMEM_BLENDMODE 0x41 #define BPMEM_BLENDMODE 0x41
#define BPMEM_CONSTANTALPHA 0x42 #define BPMEM_CONSTANTALPHA 0x42
#define BPMEM_SETDRAWDONE 0x45
#define BPMEM_ALPHACOMPARE 0xF3 #define BPMEM_ALPHACOMPARE 0xF3
#define BPMEM_LINEPTWIDTH 0x22 #define BPMEM_LINEPTWIDTH 0x22
#define BPMEM_TEXINVALIDATE 0x66 #define BPMEM_TEXINVALIDATE 0x66

View File

@ -945,7 +945,7 @@ static bool WriteAlphaTest(char *&p)
static void WriteFog(char *&p) static void WriteFog(char *&p)
{ {
bool enabled = bpmem.fog.c_proj_fsel.fsel; bool enabled = bpmem.fog.c_proj_fsel.fsel == 0 ? false : true;
if (enabled) { if (enabled) {
if (bpmem.fog.c_proj_fsel.proj == 0) { if (bpmem.fog.c_proj_fsel.proj == 0) {

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="Windows-1252"?> <?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject <VisualStudioProject
ProjectType="Visual C++" ProjectType="Visual C++"
Version="9,00" Version="9.00"
Name="Plugin_VideoOGL" Name="Plugin_VideoOGL"
ProjectGUID="{CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160}" ProjectGUID="{CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160}"
RootNamespace="Plugin_VideoOGL" RootNamespace="Plugin_VideoOGL"
@ -185,6 +185,7 @@
SuppressStartupBanner="true" SuppressStartupBanner="true"
DebugInformationFormat="3" DebugInformationFormat="3"
CompileAs="0" CompileAs="0"
DisableSpecificWarnings="4390;"
ForcedIncludeFiles="stdafx.h" ForcedIncludeFiles="stdafx.h"
/> />
<Tool <Tool

View File

@ -279,7 +279,6 @@ void BPWritten(int addr, int changes, int newval)
break; break;
case BPMEM_TEXINVALIDATE: case BPMEM_TEXINVALIDATE:
//TexCache_Invalidate();
break; break;
case BPMEM_SCISSOROFFSET: case BPMEM_SCISSOROFFSET:
@ -343,7 +342,8 @@ void BPWritten(int addr, int changes, int newval)
PixelShaderManager::SetTevKSelChanged(addr-0xf6); PixelShaderManager::SetTevKSelChanged(addr-0xf6);
} }
break; break;
case 0x45: //GXSetDrawDone
case BPMEM_SETDRAWDONE:
VertexManager::Flush(); VertexManager::Flush();
switch (newval & 0xFF) switch (newval & 0xFF)
{ {
@ -358,18 +358,17 @@ void BPWritten(int addr, int changes, int newval)
} }
break; break;
case BPMEM_PE_TOKEN_ID: // 0x47 case BPMEM_PE_TOKEN_ID:
g_VideoInitialize.pSetPEToken(static_cast<u16>(newval & 0xFFFF), FALSE); g_VideoInitialize.pSetPEToken(static_cast<u16>(newval & 0xFFFF), FALSE);
DebugLog("SetPEToken 0x%04x", (newval & 0xFFFF)); DebugLog("SetPEToken 0x%04x", (newval & 0xFFFF));
break; break;
case BPMEM_PE_TOKEN_INT_ID: // 0x48 case BPMEM_PE_TOKEN_INT_ID:
g_VideoInitialize.pSetPEToken(static_cast<u16>(newval & 0xFFFF), TRUE); g_VideoInitialize.pSetPEToken(static_cast<u16>(newval & 0xFFFF), TRUE);
DebugLog("SetPEToken + INT 0x%04x", (newval & 0xFFFF)); DebugLog("SetPEToken + INT 0x%04x", (newval & 0xFFFF));
break; break;
// Set gp metric? case 0x67: // Set gp metric?
case 0x67:
break; break;
// =============================================================== // ===============================================================
@ -547,15 +546,18 @@ void BPWritten(int addr, int changes, int newval)
u32 tlutXferCount = (newval & 0x1FFC00) >> 5; u32 tlutXferCount = (newval & 0x1FFC00) >> 5;
u8 *ptr = 0; u8 *ptr = 0;
// TODO - figure out a cleaner way. // TODO - figure out a cleaner way.
if (g_VideoInitialize.bWii) if (g_VideoInitialize.bWii)
ptr = g_VideoInitialize.pGetMemoryPointer(bpmem.tlutXferSrc << 5); ptr = g_VideoInitialize.pGetMemoryPointer(bpmem.tlutXferSrc << 5);
else else
ptr = g_VideoInitialize.pGetMemoryPointer((bpmem.tlutXferSrc & 0xFFFFF) << 5); ptr = g_VideoInitialize.pGetMemoryPointer((bpmem.tlutXferSrc & 0xFFFFF) << 5);
if (ptr) if (ptr)
memcpy_gc(texMem + tlutTMemAddr, ptr, tlutXferCount); memcpy_gc(texMem + tlutTMemAddr, ptr, tlutXferCount);
else else
PanicAlert("Invalid palette pointer %08x %08x %08x", bpmem.tlutXferSrc, bpmem.tlutXferSrc << 5, (bpmem.tlutXferSrc & 0xFFFFF)<< 5); PanicAlert("Invalid palette pointer %08x %08x %08x", bpmem.tlutXferSrc, bpmem.tlutXferSrc << 5, (bpmem.tlutXferSrc & 0xFFFFF)<< 5);
// TODO(ector) : kill all textures that use this palette // TODO(ector) : kill all textures that use this palette
// Not sure if it's a good idea, though. For now, we hash texture palettes // Not sure if it's a good idea, though. For now, we hash texture palettes
} }

View File

@ -52,10 +52,6 @@
#include "OS/Win32.h" #include "OS/Win32.h"
#endif #endif
#if defined(HAVE_WX) && HAVE_WX
#include "Debugger/Debugger.h" // for the CDebugger class
#endif
#ifdef _WIN32 #ifdef _WIN32
#include "Win32Window.h" // warning: crapcode #include "Win32Window.h" // warning: crapcode
#else #else
@ -73,10 +69,6 @@ CGcontext g_cgcontext;
CGprofile g_cgvProf; CGprofile g_cgvProf;
CGprofile g_cgfProf; CGprofile g_cgfProf;
#if defined(HAVE_WX) && HAVE_WX
extern CDebugger* m_frame; // the debugging class
#endif
static RasterFont* s_pfont = NULL; static RasterFont* s_pfont = NULL;
static std::list<MESSAGE> s_listMsgs; static std::list<MESSAGE> s_listMsgs;
@ -101,7 +93,6 @@ bool g_bBlendSeparate = false;
int frameCount; int frameCount;
void HandleCgError(CGcontext ctx, CGerror err, void *appdata); void HandleCgError(CGcontext ctx, CGerror err, void *appdata);
/////////////////////////////
static const GLenum glSrcFactors[8] = static const GLenum glSrcFactors[8] =
{ {
@ -125,8 +116,10 @@ static u32 s_blendMode;
bool Renderer::Init() bool Renderer::Init()
{ {
bool bSuccess = true; bool bSuccess = true;
int numvertexattribs = 0;
GLenum err = GL_NO_ERROR; GLenum err = GL_NO_ERROR;
g_cgcontext = cgCreateContext(); g_cgcontext = cgCreateContext();
cgGetError(); cgGetError();
cgSetErrorHandler(HandleCgError, NULL); cgSetErrorHandler(HandleCgError, NULL);
@ -135,37 +128,37 @@ bool Renderer::Init()
if (ptoken == NULL) return false; if (ptoken == NULL) return false;
INFO_LOG("Supported OpenGL Extensions:\n"); INFO_LOG("Supported OpenGL Extensions:\n");
INFO_LOG(ptoken); // write to the log file INFO_LOG(ptoken); // write to the log file
INFO_LOG("\n"); INFO_LOG("\n");
if (strstr(ptoken, "GL_EXT_blend_func_separate") != NULL && strstr(ptoken, "GL_EXT_blend_equation_separate") != NULL) if (GLEW_EXT_blend_func_separate && GLEW_EXT_blend_equation_separate)
g_bBlendSeparate = true; g_bBlendSeparate = true;
if (strstr(ptoken, "ATI_draw_buffers") != NULL && strstr(ptoken, "ARB_draw_buffers") == NULL)
//Checks if it ONLY has the ATI_draw_buffers extension, some have both //Checks if it ONLY has the ATI_draw_buffers extension, some have both
if (GLEW_ATI_draw_buffers && !GLEW_ARB_draw_buffers)
s_bATIDrawBuffers = true; s_bATIDrawBuffers = true;
s_bFullscreen = g_Config.bFullscreen; s_bFullscreen = g_Config.bFullscreen;
if (glewInit() != GLEW_OK) { if (glewInit() != GLEW_OK) {
ERROR_LOG("glewInit() failed!\n"); ERROR_LOG("glewInit() failed!\nDoes your video card support OpenGL 2.x?");
return false; return false;
} }
if (!GLEW_EXT_framebuffer_object) { if (!GLEW_EXT_framebuffer_object) {
ERROR_LOG("*********\nGPU: ERROR: Need GL_EXT_framebufer_object for multiple render targets\nGPU: *********\n"); ERROR_LOG("*********\nGPU: ERROR: Need GL_EXT_framebufer_object for multiple render targets\nGPU: *********\nDoes your video card support OpenGL 2.x?");
bSuccess = false; bSuccess = false;
} }
if (!GLEW_EXT_secondary_color) { if (!GLEW_EXT_secondary_color) {
ERROR_LOG("*********\nGPU: OGL ERROR: Need GL_EXT_secondary_color\nGPU: *********\n"); ERROR_LOG("*********\nGPU: OGL ERROR: Need GL_EXT_secondary_color\nGPU: *********\nDoes your video card support OpenGL 2.x?");
bSuccess = false; bSuccess = false;
} }
int numvertexattribs=0;
glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, (GLint *)&numvertexattribs); glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, (GLint *)&numvertexattribs);
if (numvertexattribs < 11) { if (numvertexattribs < 11) {
ERROR_LOG("*********\nGPU: OGL ERROR: Number of attributes %d not enough\nGPU: *********\n", numvertexattribs); ERROR_LOG("*********\nGPU: OGL ERROR: Number of attributes %d not enough\nGPU: *********\nDoes your video card support OpenGL 2.x?", numvertexattribs);
bSuccess = false; bSuccess = false;
} }
@ -176,7 +169,7 @@ bool Renderer::Init()
if (WGLEW_EXT_swap_control) if (WGLEW_EXT_swap_control)
wglSwapIntervalEXT(0); wglSwapIntervalEXT(0);
else else
ERROR_LOG("no support for SwapInterval (framerate clamped to monitor refresh rate)\n"); ERROR_LOG("no support for SwapInterval (framerate clamped to monitor refresh rate)\nDoes your video card support OpenGL 2.x?");
#elif defined(HAVE_X11) && HAVE_X11 #elif defined(HAVE_X11) && HAVE_X11
if (glXSwapIntervalSGI) if (glXSwapIntervalSGI)
glXSwapIntervalSGI(0); glXSwapIntervalSGI(0);
@ -203,7 +196,7 @@ bool Renderer::Init()
glGenFramebuffersEXT(1, (GLuint *)&s_uFramebuffer); glGenFramebuffersEXT(1, (GLuint *)&s_uFramebuffer);
if (s_uFramebuffer == 0) { if (s_uFramebuffer == 0) {
ERROR_LOG("failed to create the renderbuffer\n"); ERROR_LOG("failed to create the renderbuffer\nDoes your video card support OpenGL 2.x?");
} }
_assert_(glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) == GL_FRAMEBUFFER_COMPLETE_EXT); _assert_(glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) == GL_FRAMEBUFFER_COMPLETE_EXT);
@ -217,8 +210,9 @@ bool Renderer::Init()
// Create the framebuffer target // Create the framebuffer target
glGenTextures(1, (GLuint *)&s_RenderTarget); glGenTextures(1, (GLuint *)&s_RenderTarget);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, s_RenderTarget); glBindTexture(GL_TEXTURE_RECTANGLE_ARB, s_RenderTarget);
// Setup the texture params
// initialize to default // initialize to default
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, 4, nBackbufferWidth, nBackbufferHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, 4, nBackbufferWidth, nBackbufferHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
@ -235,7 +229,9 @@ bool Renderer::Init()
int nMaxMRT = 0; int nMaxMRT = 0;
glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, (GLint *)&nMaxMRT); glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, (GLint *)&nMaxMRT);
if (nMaxMRT > 1) {
if (nMaxMRT > 1)
{
// create zbuffer target // create zbuffer target
glGenTextures(1, (GLuint *)&s_ZBufferTarget); glGenTextures(1, (GLuint *)&s_ZBufferTarget);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, s_ZBufferTarget); glBindTexture(GL_TEXTURE_RECTANGLE_ARB, s_ZBufferTarget);
@ -257,10 +253,13 @@ bool Renderer::Init()
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, s_DepthTarget); glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, s_DepthTarget);
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH24_STENCIL8_EXT, nBackbufferWidth, nBackbufferHeight); glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH24_STENCIL8_EXT, nBackbufferWidth, nBackbufferHeight);
if (glGetError() != GL_NO_ERROR) { if (glGetError() != GL_NO_ERROR)
{
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, nBackbufferWidth, nBackbufferHeight); glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, nBackbufferWidth, nBackbufferHeight);
s_bHaveStencilBuffer = false; s_bHaveStencilBuffer = false;
} else { }
else
{
s_bHaveStencilBuffer = true; s_bHaveStencilBuffer = true;
} }
@ -284,10 +283,10 @@ bool Renderer::Init()
} }
} }
if (s_ZBufferTarget == 0) { if (s_ZBufferTarget == 0)
ERROR_LOG("disabling ztarget mrt feature (max mrt=%d)\n", nMaxMRT); ERROR_LOG("disabling ztarget mrt feature (max mrt=%d)\n", nMaxMRT);
}
// Why is this left here?
//glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, s_DepthTarget); //glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, s_DepthTarget);
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT); glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
@ -304,6 +303,7 @@ bool Renderer::Init()
ERROR_LOG("arbvp1 not supported\n"); ERROR_LOG("arbvp1 not supported\n");
return false; return false;
} }
if (cgGLIsProfileSupported(CG_PROFILE_ARBFP1) != CG_TRUE) { if (cgGLIsProfileSupported(CG_PROFILE_ARBFP1) != CG_TRUE) {
ERROR_LOG("arbfp1 not supported\n"); ERROR_LOG("arbfp1 not supported\n");
return false; return false;
@ -323,9 +323,8 @@ bool Renderer::Init()
DEBUG_LOG("max program env parameters: vert=%d, frag=%d\n", nenvvertparams, nenvfragparams); DEBUG_LOG("max program env parameters: vert=%d, frag=%d\n", nenvvertparams, nenvfragparams);
DEBUG_LOG("max program address register parameters: vert=%d, frag=%d\n", naddrregisters[0], naddrregisters[1]); DEBUG_LOG("max program address register parameters: vert=%d, frag=%d\n", naddrregisters[0], naddrregisters[1]);
if (nenvvertparams < 238) { if (nenvvertparams < 238)
ERROR_LOG("not enough vertex shader environment constants!!\n"); ERROR_LOG("not enough vertex shader environment constants!!\n");
}
#ifndef _DEBUG #ifndef _DEBUG
cgGLSetDebugMode(GL_FALSE); cgGLSetDebugMode(GL_FALSE);
@ -374,7 +373,7 @@ bool Renderer::InitializeGL()
glStencilFunc(GL_ALWAYS, 0, 0); glStencilFunc(GL_ALWAYS, 0, 0);
glBlendFunc(GL_ONE, GL_ONE); glBlendFunc(GL_ONE, GL_ONE);
glViewport(0, 0, GetTargetWidth(), GetTargetHeight()); // Reset The Current Viewport glViewport(0, 0, GetTargetWidth(), GetTargetHeight()); // Reset The Current Viewport
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glLoadIdentity(); glLoadIdentity();
@ -388,7 +387,7 @@ bool Renderer::InitializeGL()
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
glDepthFunc(GL_LEQUAL); glDepthFunc(GL_LEQUAL);
glPixelStorei(GL_UNPACK_ALIGNMENT, 4); // 4-byte pixel alignment glPixelStorei(GL_UNPACK_ALIGNMENT, 4); // 4-byte pixel alignment
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // perspective correct interpolation of colors and tex coords glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // perspective correct interpolation of colors and tex coords
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
@ -470,47 +469,6 @@ void Renderer::RenderText(const char* pstr, int left, int top, u32 color)
s_pfont->printMultilineText(pstr, left * 2.0f / (float)nBackbufferWidth - 1, 1 - top * 2.0f / (float)nBackbufferHeight,0,nBackbufferWidth,nBackbufferHeight); s_pfont->printMultilineText(pstr, left * 2.0f / (float)nBackbufferWidth - 1, 1 - top * 2.0f / (float)nBackbufferHeight,0,nBackbufferWidth,nBackbufferHeight);
} }
void Renderer::ReinitView(int nNewWidth, int nNewHeight)
{
int oldscreen = s_bFullscreen;
OpenGL_Shutdown();
int oldwidth = (int)OpenGL_GetWidth(),
oldheight = (int)OpenGL_GetHeight();
if (!OpenGL_Create(g_VideoInitialize, nNewWidth, nNewHeight)) {//nNewWidth&~7, nNewHeight&~7)) {
ERROR_LOG("Failed to recreate, reverting to old settings\n");
if (!OpenGL_Create(g_VideoInitialize, oldwidth, oldheight)) {
g_VideoInitialize.pSysMessage("Failed to revert, exiting...\n");
// TODO - don't takedown the entire emu
exit(0);
}
}
OpenGL_MakeCurrent();
if (oldscreen && !g_Config.bFullscreen) { // if transitioning from full screen
#ifdef _WIN32
//RECT rc;
//rc.left = 0; rc.top = 0;
//rc.right = nNewWidth; rc.bottom = nNewHeight;
//AdjustWindowRect(&rc, EmuWindow::g_winstyle, FALSE);
//RECT rcdesktop;
//GetWindowRect(GetDesktopWindow(), &rcdesktop);
//SetWindowLong(EmuWindow::GetWnd(), GWL_STYLE, EmuWindow::g_winstyle);
//SetWindowPos(EmuWindow:GetWnd(), HWND_TOP, ((rcdesktop.right-rcdesktop.left)-(rc.right-rc.left))/2,
// ((rcdesktop.bottom-rcdesktop.top)-(rc.bottom-rc.top))/2,
// rc.right-rc.left, rc.bottom-rc.top, SWP_SHOWWINDOW);
//UpdateWindow(EmuWindow::GetWnd());
#else // linux
#endif
}
OpenGL_SetSize(nNewWidth > 16 ? nNewWidth : 16,
nNewHeight > 16 ? nNewHeight : 16);
}
////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////
// Return the rendering window width and height // Return the rendering window width and height
// ------------------------ // ------------------------
@ -670,19 +628,19 @@ bool Renderer::SetScissorRect()
int yoff = bpmem.scissorOffset.y * 2 - 342; int yoff = bpmem.scissorOffset.y * 2 - 342;
float MValueX = OpenGL_GetXmax(); float MValueX = OpenGL_GetXmax();
float MValueY = OpenGL_GetYmax(); float MValueY = OpenGL_GetYmax();
float rc_left = bpmem.scissorTL.x - xoff - 342; // left = 0 float rc_left = (float)bpmem.scissorTL.x - xoff - 342; // left = 0
rc_left *= MValueX; rc_left *= MValueX;
if (rc_left < 0) rc_left = 0; if (rc_left < 0) rc_left = 0;
float rc_top = bpmem.scissorTL.y - yoff - 342; // right = 0 float rc_top = (float)bpmem.scissorTL.y - yoff - 342; // right = 0
rc_top *= MValueY; rc_top *= MValueY;
if (rc_top < 0) rc_top = 0; if (rc_top < 0) rc_top = 0;
float rc_right = bpmem.scissorBR.x - xoff - 341; // right = 640 float rc_right = (float)bpmem.scissorBR.x - xoff - 341; // right = 640
rc_right *= MValueX; rc_right *= MValueX;
if (rc_right > 640 * MValueX) rc_right = 640 * MValueX; if (rc_right > 640 * MValueX) rc_right = 640 * MValueX;
float rc_bottom = bpmem.scissorBR.y - yoff - 341; // bottom = 480 float rc_bottom = (float)bpmem.scissorBR.y - yoff - 341; // bottom = 480
rc_bottom *= MValueY; rc_bottom *= MValueY;
if (rc_bottom > 480 * MValueY) rc_bottom = 480 * MValueY; if (rc_bottom > 480 * MValueY) rc_bottom = 480 * MValueY;
@ -887,6 +845,7 @@ void Renderer::Swap(const TRectangle& rc)
Renderer::SetRenderMode(Renderer::RM_Normal); Renderer::SetRenderMode(Renderer::RM_Normal);
#if 0 #if 0
// Blit the FBO to do Anti-Aliasing
// Not working? // Not working?
glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, s_uFramebuffer); glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, s_uFramebuffer);
glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0); glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0);
@ -904,9 +863,11 @@ void Renderer::Swap(const TRectangle& rc)
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, s_RenderTarget); glBindTexture(GL_TEXTURE_RECTANGLE_ARB, s_RenderTarget);
TextureMngr::EnableTexRECT(0); TextureMngr::EnableTexRECT(0);
// disable all other stages
// disable all other stages
for (int i = 1; i < 8; ++i) for (int i = 1; i < 8; ++i)
TextureMngr::DisableStage(i); TextureMngr::DisableStage(i);
GL_REPORT_ERRORD(); GL_REPORT_ERRORD();
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
@ -917,6 +878,7 @@ void Renderer::Swap(const TRectangle& rc)
glTexCoord2f((float)GetTargetWidth(), 0); glVertex2f(1,-1); glTexCoord2f((float)GetTargetWidth(), 0); glVertex2f(1,-1);
glEnd(); glEnd();
// Wireframe
if (g_Config.bWireFrame) if (g_Config.bWireFrame)
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
@ -955,7 +917,7 @@ void Renderer::SwapBuffers()
if (g_Config.bShowFPS) if (g_Config.bShowFPS)
{ {
p+=sprintf(p, "%d\n", s_fps); p+=sprintf(p, "FPS: %d\n", s_fps);
} }
if (g_Config.bOverlayStats) { if (g_Config.bOverlayStats) {
@ -988,6 +950,7 @@ void Renderer::SwapBuffers()
VertexLoaderManager::AppendListToString(&text1); VertexLoaderManager::AppendListToString(&text1);
p+=sprintf(p,"%s",text1.c_str()); p+=sprintf(p,"%s",text1.c_str());
} }
if (g_Config.bOverlayBlendStats) if (g_Config.bOverlayBlendStats)
{ {
p+=sprintf(p,"LogicOp Mode: %i\n", stats.logicOpMode); p+=sprintf(p,"LogicOp Mode: %i\n", stats.logicOpMode);
@ -1000,6 +963,7 @@ void Renderer::SwapBuffers()
p+=sprintf(p,"Dst Alpha: %08x\n", stats.dstAlpha); p+=sprintf(p,"Dst Alpha: %08x\n", stats.dstAlpha);
} }
if (g_Config.bOverlayProjStats) if (g_Config.bOverlayProjStats)
{ {
p+=sprintf(p,"Projection #: X for Raw 6=0 (X for Raw 6!=0)\n\n"); p+=sprintf(p,"Projection #: X for Raw 6=0 (X for Raw 6!=0)\n\n");
@ -1053,6 +1017,7 @@ void Renderer::SwapBuffers()
TextureMngr::Cleanup(); TextureMngr::Cleanup();
frameCount++; frameCount++;
// New frame // New frame
stats.ResetFrame(); stats.ResetFrame();
@ -1118,6 +1083,7 @@ void HandleGLError()
if (!error) if (!error)
return; return;
// What is this for?
// int w, h; // int w, h;
// GLint fmt; // GLint fmt;
// glGetRenderbufferParameterivEXT(GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_INTERNAL_FORMAT_EXT, &fmt); // glGetRenderbufferParameterivEXT(GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_INTERNAL_FORMAT_EXT, &fmt);
@ -1256,13 +1222,13 @@ void UpdateViewport()
wAdj = Ratio; wAdj = Ratio;
hAdj = 1; hAdj = 1;
GLWidth = ceil(FloatGLWidth / wAdj); GLWidth = (int)ceil(FloatGLWidth / wAdj);
GLHeight = ceil(FloatGLHeight / hAdj); GLHeight = (int)ceil(FloatGLHeight / hAdj);
actualWid = ceil((float)WinW / Ratio); actualWid = (int)ceil((float)WinW / Ratio);
// The picture compared to the screen // The picture compared to the screen
actualRatiow = (float)actualWid / (float)GLWidth; actualRatiow = (float)actualWid / (float)GLWidth;
overfl = (WinW - actualWid) / actualRatiow; overfl = (int)ceil((WinW - actualWid) / actualRatiow);
XOffset = XOffset + overfl / 2; XOffset = XOffset + overfl / 2;
} }
// The window is to high, we have to limit the height // The window is to high, we have to limit the height
@ -1274,13 +1240,13 @@ void UpdateViewport()
wAdj = 1; wAdj = 1;
hAdj = Ratio; hAdj = Ratio;
GLWidth = ceil(FloatGLWidth / wAdj); GLWidth = (int)ceil(FloatGLWidth / wAdj);
GLHeight = ceil(FloatGLHeight / hAdj); GLHeight = (int)ceil(FloatGLHeight / hAdj);
actualHei = ceil((float)WinH / Ratio); actualHei = (int)ceil((float)WinH / Ratio);
// The picture compared to the screen // The picture compared to the screen
actualRatioh = (float)actualHei / (float)GLHeight; actualRatioh = (float)actualHei / (float)GLHeight;
overfl = (WinH - actualHei) / actualRatioh; overfl = (int)ceil((WinH - actualHei) / actualRatioh);
YOffset = YOffset + overfl / 2; YOffset = YOffset + overfl / 2;
} }
} }
@ -1288,8 +1254,8 @@ void UpdateViewport()
else else
{ {
// Round up to the nearest integer // Round up to the nearest integer
GLWidth = ceil(FloatGLWidth); GLWidth = (int)ceil(FloatGLWidth);
GLHeight = ceil(FloatGLHeight); GLHeight = (int)ceil(FloatGLHeight);
} }
// ------------------------------------- // -------------------------------------
@ -1310,10 +1276,10 @@ void UpdateViewport()
float MValueX = OpenGL_GetXmax(); float MValueX = OpenGL_GetXmax();
float MValueY = OpenGL_GetYmax(); float MValueY = OpenGL_GetYmax();
GLx = (int)(xfregs.rawViewport[3] - xfregs.rawViewport[0] - 342 - scissorXOff) * MValueX; GLx = (int)ceil((xfregs.rawViewport[3] - xfregs.rawViewport[0] - 342 - scissorXOff) * MValueX);
GLy = Renderer::GetTargetHeight() - ((int)(xfregs.rawViewport[4] - xfregs.rawViewport[1] - 342 - scissorYOff)) * MValueY; GLy = (int)ceil(Renderer::GetTargetHeight() - ((int)(xfregs.rawViewport[4] - xfregs.rawViewport[1] - 342 - scissorYOff)) * MValueY);
GLWidth = abs((int)(2 * xfregs.rawViewport[0])) * MValueX; GLWidth = (int)ceil(abs((int)(2 * xfregs.rawViewport[0])) * MValueX);
GLHeight = abs((int)(2 * xfregs.rawViewport[1])) * MValueY; GLHeight = (int)ceil(abs((int)(2 * xfregs.rawViewport[1])) * MValueY);
} }
// ------------------------------------- // -------------------------------------

View File

@ -100,8 +100,6 @@ public:
static void ProcessMessages(); // draw the current messages on the screen static void ProcessMessages(); // draw the current messages on the screen
static void RenderText(const char* pstr, int left, int top, u32 color); static void RenderText(const char* pstr, int left, int top, u32 color);
static void ReinitView(int nNewWidth, int nNewHeight);
static int GetTargetWidth(); static int GetTargetWidth();
static int GetTargetHeight(); static int GetTargetHeight();
static void SetCgErrorOutput(bool bOutput); static void SetCgErrorOutput(bool bOutput);

View File

@ -99,12 +99,12 @@ void TextureMngr::TCacheEntry::SetTextureParameters(TexMode0 &newmode)
(newmode.mag_filter || g_Config.bForceFiltering) ? GL_LINEAR : GL_NEAREST); (newmode.mag_filter || g_Config.bForceFiltering) ? GL_LINEAR : GL_NEAREST);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER,
(g_Config.bForceFiltering || newmode.min_filter >= 4) ? GL_LINEAR : GL_NEAREST); (g_Config.bForceFiltering || newmode.min_filter >= 4) ? GL_LINEAR : GL_NEAREST);
if (newmode.wrap_s == 2 || newmode.wrap_t == 2) {
if (newmode.wrap_s == 2 || newmode.wrap_t == 2)
DEBUG_LOG("cannot support mirrorred repeat mode\n"); DEBUG_LOG("cannot support mirrorred repeat mode\n");
}
if (newmode.wrap_s == 1 || newmode.wrap_t == 1) { if (newmode.wrap_s == 1 || newmode.wrap_t == 1)
DEBUG_LOG("cannot support repeat mode\n"); DEBUG_LOG("cannot support repeat mode\n");
}
} }
else { else {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
@ -133,6 +133,7 @@ void TextureMngr::TCacheEntry::Destroy()
{ {
if (!texture) if (!texture)
return; return;
glDeleteTextures(1, &texture); glDeleteTextures(1, &texture);
if (!isRenderTarget) { if (!isRenderTarget) {
if (!g_Config.bSafeTextureCache) { if (!g_Config.bSafeTextureCache) {
@ -319,9 +320,11 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
entry.hashoffset = 0; entry.hashoffset = 0;
//entry.paletteHash = hashseed; //entry.paletteHash = hashseed;
entry.oldpixel = ((u32 *)ptr)[entry.hashoffset]; entry.oldpixel = ((u32 *)ptr)[entry.hashoffset];
if (g_Config.bSafeTextureCache) {
if (g_Config.bSafeTextureCache)
entry.hash = hash_value; entry.hash = hash_value;
} else { else
{
entry.hash = (u32)(((double)rand() / RAND_MAX) * 0xFFFFFFFF); entry.hash = (u32)(((double)rand() / RAND_MAX) * 0xFFFFFFFF);
((u32 *)ptr)[entry.hashoffset] = entry.hash; ((u32 *)ptr)[entry.hashoffset] = entry.hash;
} }
@ -370,7 +373,9 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
gl_type = GL_UNSIGNED_SHORT_5_6_5; gl_type = GL_UNSIGNED_SHORT_5_6_5;
break; break;
} }
if (!entry.isNonPow2 && ((tm0.min_filter & 3) == 1 || (tm0.min_filter & 3) == 2)) {
if (!entry.isNonPow2 && ((tm0.min_filter & 3) == 1 || (tm0.min_filter & 3) == 2))
{
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE); glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
glTexImage2D(GL_TEXTURE_2D, 0, gl_iformat, width, height, 0, gl_format, gl_type, temp); glTexImage2D(GL_TEXTURE_2D, 0, gl_iformat, width, height, 0, gl_format, gl_type, temp);
@ -389,7 +394,8 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
entry.fmt = format; entry.fmt = format;
entry.SetTextureParameters(tm0); entry.SetTextureParameters(tm0);
if (g_Config.bDumpTextures) { // dump texture to file if (g_Config.bDumpTextures) // dump texture to file
{
static int counter = 0; static int counter = 0;
char szTemp[MAX_PATH]; char szTemp[MAX_PATH];
sprintf(szTemp, "%s/txt_%04i_%i.tga", g_Config.texDumpPath, counter++, format); sprintf(szTemp, "%s/txt_%04i_%i.tga", g_Config.texDumpPath, counter++, format);
@ -479,7 +485,8 @@ void TextureMngr::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, bool
} }
} }
if (!bIsInit || !entry.isRenderTarget) { if (!bIsInit || !entry.isRenderTarget)
{
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

View File

@ -66,9 +66,11 @@ void LoadXFReg(u32 transferSize, u32 baseAddress, u32 *pData)
break; break;
case 0x1006: //SetGPMetric case 0x1006: //SetGPMetric
break; break;
case 0x1008: //__GXXfVtxSpecs, wrote 0004 case 0x1008: //__GXXfVtxSpecs, wrote 0004
xfregs.hostinfo = *(INVTXSPEC*)&data; xfregs.hostinfo = *(INVTXSPEC*)&data;
break; break;
case 0x1009: //GXSetNumChans (no) case 0x1009: //GXSetNumChans (no)
if ((u32)xfregs.nNumChans != (data&3)) { if ((u32)xfregs.nNumChans != (data&3)) {
VertexManager::Flush(); VertexManager::Flush();
@ -226,9 +228,9 @@ void LoadIndexedXF(u32 val, int array)
//load stuff from array to address in xf mem //load stuff from array to address in xf mem
VertexManager::Flush(); VertexManager::Flush();
VertexShaderManager::InvalidateXFRange(address, address+size); VertexShaderManager::InvalidateXFRange(address, address + size);
//PRIM_LOG("xfmem iwrite: 0x%x-0x%x\n", address, address+size); //PRIM_LOG("xfmem iwrite: 0x%x-0x%x\n", address, address + size);
for (int i = 0; i < size; i++) for (int i = 0; i < size; i++)
xfmem[address + i] = Memory_Read_U32(arraybases[array] + arraystrides[array]*index + i*4); xfmem[address + i] = Memory_Read_U32(arraybases[array] + arraystrides[array] * index + i * 4);
} }

View File

@ -28,7 +28,6 @@
#if defined(HAVE_WX) && HAVE_WX #if defined(HAVE_WX) && HAVE_WX
#include "GUI/ConfigDlg.h" #include "GUI/ConfigDlg.h"
#include "Debugger/Debugger.h" // for the CDebugger class
#endif #endif
#include "Config.h" #include "Config.h"
@ -75,19 +74,9 @@ int GLScissorX, GLScissorY, GLScissorW, GLScissorH;
Update: This crash seems to be gone for now. */ Update: This crash seems to be gone for now. */
#if defined(HAVE_WX) && HAVE_WX #if defined(HAVE_WX) && HAVE_WX
CDebugger* m_frame;
void DllDebugger(HWND _hParent, bool Show) void DllDebugger(HWND _hParent, bool Show)
{ {
if(!m_frame && Show) // TODO: Debugger needs recoding, right now its useless
{
m_frame = new CDebugger(NULL);
m_frame->Show();
}
else if (m_frame && !Show)
{
if(m_frame->Close())
m_frame = NULL;
}
} }
void DoDllDebugger(){} void DoDllDebugger(){}