More cleanup in gl plugin

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2337 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
hrydgard 2009-02-21 13:11:49 +00:00
parent b211200460
commit 3331a024c0
4 changed files with 80 additions and 95 deletions

View File

@ -64,16 +64,11 @@ void BPInit()
At the end of every: OpcodeDecoding.cpp ExecuteDisplayList > Decode() > LoadBPReg
TODO:
Turn into function table. The (future) DL jit can then call the functions directly,
getting rid of dynamic dispatch.
getting rid of dynamic dispatch. Unfortunately, few games use DLs properly - most\
just stuff geometry in them and don't put state changes there.
// ------------------ */
void BPWritten(int addr, int changes, int newval)
{
//static int count = 0;
//ERROR_LOG("(%d) %x: %x\n", count++, addr, newval);
//Console::Print("BPWritten: 0x%02x %i %i %i\n", addr, changes, newval, (int)bpmem.copyTexSrcWH.y);
//if(addr == 0x49) PanicAlert("0x49");
switch (addr)
{
case BPMEM_GENMODE:
@ -173,8 +168,8 @@ void BPWritten(int addr, int changes, int newval)
glPointSize((float)bpmem.lineptwidth.pointsize * fratio / 6.0f);
break;
}
case 0x43:
case 0x43: // ????
if (changes) {
VertexManager::Flush();
((u32*)&bpmem)[addr] = newval;
@ -368,13 +363,13 @@ void BPWritten(int addr, int changes, int newval)
DebugLog("SetPEToken + INT 0x%04x", (newval & 0xFFFF));
break;
case 0x67: // Set gp metric?
case BPMEM_SETGPMETRIC: // Set gp metric?
break;
// ===============================================================
// This case writes to bpmem.triggerEFBCopy and may apparently prompt us to update glScissor()
// ------------------------
case 0x52:
case BPMEM_TRIGGER_EFB_COPY:
{
DVSTARTSUBPROFILE("LoadBPReg:swap");
VertexManager::Flush();
@ -416,7 +411,10 @@ void BPWritten(int addr, int changes, int newval)
glViewport(rc.left,rc.bottom, rc.right,rc.top);
glScissor(rc.left,rc.bottom, rc.right,rc.top);
// Logging
GLScissorX = rc.left; GLScissorY = rc.bottom; GLScissorW = rc.right; GLScissorH = rc.top;
GLScissorX = rc.left;
GLScissorY = rc.bottom;
GLScissorW = rc.right;
GLScissorH = rc.top;
}
else if (g_Config.bCopyEFBToRAM)
{
@ -451,7 +449,7 @@ void BPWritten(int addr, int changes, int newval)
}
else
{
Renderer::Swap(multirc);
Renderer::Swap();
}
g_VideoInitialize.pCopiedToXFB();
}
@ -535,8 +533,7 @@ void BPWritten(int addr, int changes, int newval)
break;
// ==================================
case 0x65: //GXLoadTlut
case BPMEM_LOADTLUT:
{
DVSTARTSUBPROFILE("LoadBPReg:GXLoadTlut");
VertexManager::Flush();
@ -563,7 +560,6 @@ void BPWritten(int addr, int changes, int newval)
}
break;
default:
switch(addr & 0xFC) //texture sampler filter
{

View File

@ -804,3 +804,65 @@ void OpenGL_Shutdown()
#endif
#endif
}
void HandleGLError()
{
const GLubyte* pstr = glGetString(GL_PROGRAM_ERROR_STRING_ARB);
if (pstr != NULL && pstr[0] != 0)
{
GLint loc = 0;
glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &loc);
ERROR_LOG("program error at %d: ", loc);
ERROR_LOG((char*)pstr);
ERROR_LOG("\n");
}
// check the error status of this framebuffer */
GLenum error = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
// if error != GL_FRAMEBUFFER_COMPLETE_EXT, there's an error of some sort
if (!error)
return;
switch(error)
{
case GL_FRAMEBUFFER_COMPLETE_EXT:
break;
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT:
ERROR_LOG("Error! missing a required image/buffer attachment!\n");
break;
case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT:
ERROR_LOG("Error! has no images/buffers attached!\n");
break;
// case GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT:
// ERROR_LOG("Error! has an image/buffer attached in multiple locations!\n");
// break;
case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT:
ERROR_LOG("Error! has mismatched image/buffer dimensions!\n");
break;
case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT:
ERROR_LOG("Error! colorbuffer attachments have different types!\n");
break;
case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT:
ERROR_LOG("Error! trying to draw to non-attached color buffer!\n");
break;
case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT:
ERROR_LOG("Error! trying to read from a non-attached color buffer!\n");
break;
case GL_FRAMEBUFFER_UNSUPPORTED_EXT:
ERROR_LOG("Error! format is not supported by current graphics card/driver!\n");
break;
default:
ERROR_LOG("*UNKNOWN ERROR* reported from glCheckFramebufferStatusEXT()!\n");
break;
}
}
void HandleCgError(CGcontext ctx, CGerror err, void* appdata)
{
ERROR_LOG("Cg error: %s\n", cgGetErrorString(err));
const char* listing = cgGetLastListing(g_cgcontext);
if (listing != NULL) {
ERROR_LOG(" last listing: %s\n", listing);
}
}

View File

@ -65,7 +65,6 @@ CGprofile g_cgfProf;
RasterFont* s_pfont = NULL;
static bool s_bFullscreen = false;
static bool s_bOutputCgErrors = true;
static int nZBufferRender = 0; // if > 0, then use zbuffer render, and count down.
@ -776,7 +775,7 @@ Renderer::RenderMode Renderer::GetRenderMode()
return s_RenderMode;
}
void Renderer::Swap(const TRectangle& rc)
void Renderer::Swap()
{
OpenGL_Update(); // just updates the render window position and the backbuffer size
@ -1011,76 +1010,6 @@ bool Renderer::SaveRenderTarget(const char* filename, int jpeg)
return SaveTGA(filename, nBackbufferWidth, nBackbufferHeight, &data[0]);
}
void Renderer::SetCgErrorOutput(bool bOutput)
{
s_bOutputCgErrors = bOutput;
}
void HandleGLError()
{
const GLubyte* pstr = glGetString(GL_PROGRAM_ERROR_STRING_ARB);
if (pstr != NULL && pstr[0] != 0)
{
GLint loc = 0;
glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &loc);
ERROR_LOG("program error at %d: ", loc);
ERROR_LOG((char*)pstr);
ERROR_LOG("\n");
}
// check the error status of this framebuffer */
GLenum error = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
// if error != GL_FRAMEBUFFER_COMPLETE_EXT, there's an error of some sort
if (!error)
return;
switch(error)
{
case GL_FRAMEBUFFER_COMPLETE_EXT:
break;
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT:
ERROR_LOG("Error! missing a required image/buffer attachment!\n");
break;
case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT:
ERROR_LOG("Error! has no images/buffers attached!\n");
break;
// case GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT:
// ERROR_LOG("Error! has an image/buffer attached in multiple locations!\n");
// break;
case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT:
ERROR_LOG("Error! has mismatched image/buffer dimensions!\n");
break;
case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT:
ERROR_LOG("Error! colorbuffer attachments have different types!\n");
break;
case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT:
ERROR_LOG("Error! trying to draw to non-attached color buffer!\n");
break;
case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT:
ERROR_LOG("Error! trying to read from a non-attached color buffer!\n");
break;
case GL_FRAMEBUFFER_UNSUPPORTED_EXT:
ERROR_LOG("Error! format is not supported by current graphics card/driver!\n");
break;
default:
ERROR_LOG("*UNKNOWN ERROR* reported from glCheckFramebufferStatusEXT()!\n");
break;
}
}
void HandleCgError(CGcontext ctx, CGerror err, void* appdata)
{
if (s_bOutputCgErrors)
{
ERROR_LOG("Cg error: %s\n", cgGetErrorString(err));
const char* listing = cgGetLastListing(g_cgcontext);
if (listing != NULL) {
ERROR_LOG(" last listing: %s\n", listing);
}
}
}
//////////////////////////////////////////////////////////////////////////////////////
// Called from VertexShaderManager
// ----------------------

View File

@ -96,11 +96,12 @@ public:
// initialize opengl standard values (like viewport)
static bool InitializeGL();
static void SetCgErrorOutput(bool bOutput);
static void ResetGLState();
static void RestoreGLState();
static bool IsUsingATIDrawBuffers();
static void SwapBuffers();
static bool IsUsingATIDrawBuffers();
static bool HaveStencilBuffer();
static void SetColorMask();
@ -127,10 +128,7 @@ public:
static bool SaveRenderTarget(const char* filename, int jpeg);
// Finish up the current frame, print some stats
static void Swap(const TRectangle& rc);
static void SwapBuffers();
static void Swap();
};
#endif