OpenGL: It seems like there was a purpose with the separate glViewport() and glScissor() in PE_copy.clear after all. I'll disable the XFB supplement until it works with those functions to.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2320 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
John Peterson 2009-02-20 16:50:38 +00:00
parent af461eeb1e
commit f992dae50d
2 changed files with 36 additions and 18 deletions

View File

@ -372,7 +372,9 @@ void BPWritten(int addr, int changes, int newval)
case 0x67: case 0x67:
break; break;
// ===============================================================
// This case writes to bpmem.triggerEFBCopy and may apparently prompt us to update glScissor() // This case writes to bpmem.triggerEFBCopy and may apparently prompt us to update glScissor()
// ------------------------
case 0x52: case 0x52:
{ {
DVSTARTSUBPROFILE("LoadBPReg:swap"); DVSTARTSUBPROFILE("LoadBPReg:swap");
@ -401,17 +403,21 @@ void BPWritten(int addr, int changes, int newval)
UPE_Copy PE_copy; UPE_Copy PE_copy;
PE_copy.Hex = bpmem.triggerEFBCopy; PE_copy.Hex = bpmem.triggerEFBCopy;
// --------------------------------------------------------
// Check if we should copy the picture to XFB or not
// --------------------------
if (PE_copy.copy_to_xfb == 0) if (PE_copy.copy_to_xfb == 0)
{ {
// EFB to texture // EFB to texture
// for some reason it sets bpmem.zcontrol.pixel_format to PIXELFMT_Z24 every time a zbuffer format is given as a dest to GXSetTexCopyDst // for some reason it sets bpmem.zcontrol.pixel_format to PIXELFMT_Z24 every time a zbuffer format is given as a dest to GXSetTexCopyDst
if (g_Config.bEFBCopyDisable) if (g_Config.bEFBCopyDisable)
{ {
// We already have this in Render.cpp that we call when (PE_copy.clear) is true, why do we need this here to? /* We already have this in Render.cpp that we call when (PE_copy.clear) is true. But we need a separate one
//glViewport(rc.left,rc.bottom, rc.right,rc.top); here because UpdateViewport() is not run when this otion is set? */
//glScissor(rc.left,rc.bottom, rc.right,rc.top); glViewport(rc.left,rc.bottom, rc.right,rc.top);
glScissor(rc.left,rc.bottom, rc.right,rc.top);
// Logging // 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) else if (g_Config.bCopyEFBToRAM)
{ {
@ -451,24 +457,30 @@ void BPWritten(int addr, int changes, int newval)
g_VideoInitialize.pCopiedToXFB(); g_VideoInitialize.pCopiedToXFB();
} }
// clearing // --------------------------------------------------------
// Clearing
// --------------------------
if (PE_copy.clear) if (PE_copy.clear)
{ {
// clear color // Clear color
Renderer::SetRenderMode(Renderer::RM_Normal); Renderer::SetRenderMode(Renderer::RM_Normal);
// Clear Z-Buffer target
u32 nRestoreZBufferTarget = Renderer::GetZBufferTarget(); u32 nRestoreZBufferTarget = Renderer::GetZBufferTarget();
// Why do we have this here and in Render.cpp? // Why do we have this here and in Render.cpp?
//glViewport(0, 0, Renderer::GetTargetWidth(), Renderer::GetTargetHeight()); glViewport(0, 0, Renderer::GetTargetWidth(), Renderer::GetTargetHeight());
// Always set the scissor in case it was set by the game and has not been reset // Always set the scissor in case it was set by the game and has not been reset
// But we will do that at the end of this section, in SetScissorRect(), why would we do it twice in the same function? // But we will do that at the end of this section, in SetScissorRect(), why would we do it twice in the same function?
//glScissor(multirc.left, (Renderer::GetTargetHeight() - multirc.bottom), // Because this is needed by the intermediate functions diirectly below here, in glDrawBuffer()
// (multirc.right - multirc.left), (multirc.bottom - multirc.top)); // and so on.
glScissor(multirc.left, (Renderer::GetTargetHeight() - multirc.bottom),
(multirc.right - multirc.left), (multirc.bottom - multirc.top));
// Logging // Logging
// GLScissorX = multirc.left; GLScissorY = (Renderer::GetTargetHeight() - multirc.bottom); GLScissorX = multirc.left; GLScissorY = (Renderer::GetTargetHeight() - multirc.bottom);
// GLScissorW = (multirc.right - multirc.left); GLScissorH = (multirc.bottom - multirc.top); GLScissorW = (multirc.right - multirc.left); GLScissorH = (multirc.bottom - multirc.top);
//Console::Print("%i %i %i %i\n", GLScissorX, GLScissorY, GLScissorW, GLScissorH);
VertexShaderManager::SetViewportChanged(); VertexShaderManager::SetViewportChanged();
@ -510,16 +522,20 @@ void BPWritten(int addr, int changes, int newval)
GL_REPORT_ERRORD(); GL_REPORT_ERRORD();
} }
if (nRestoreZBufferTarget) { if (nRestoreZBufferTarget)
{
// restore target // restore target
GLenum s_drawbuffers[2] = {GL_COLOR_ATTACHMENT0_EXT, GL_COLOR_ATTACHMENT1_EXT}; GLenum s_drawbuffers[2] = {GL_COLOR_ATTACHMENT0_EXT, GL_COLOR_ATTACHMENT1_EXT};
glDrawBuffers(2, s_drawbuffers); glDrawBuffers(2, s_drawbuffers);
} }
Renderer::SetScissorRect(); // reset the scissor rect Renderer::SetScissorRect(); // reset the scissor rectangle
} }
// ------------------------------
} }
break; break;
// ==================================
case 0x65: //GXLoadTlut case 0x65: //GXLoadTlut
{ {

View File

@ -699,7 +699,8 @@ bool Renderer::SetScissorRect()
// XFB supplement, fix the black borders problem // XFB supplement, fix the black borders problem
// ------------------ // ------------------
// See comment in UpdateViewport() about why I don't the XFB supplement to these options // See comment in UpdateViewport() about why I don't the XFB supplement to these options
if(g_Config.bStretchToFit && !g_Config.bUseXFB) //if(g_Config.bStretchToFit && !g_Config.bUseXFB)
if(false)
{ {
int WidthDifference = 640 - (int)(rc_right - rc_left); int WidthDifference = 640 - (int)(rc_right - rc_left);
int HeightDifference = 480 - (int)(rc_bottom - rc_top); int HeightDifference = 480 - (int)(rc_bottom - rc_top);
@ -1206,7 +1207,7 @@ void UpdateViewport()
int scissorYOff = bpmem.scissorOffset.y * 2 - 342; int scissorYOff = bpmem.scissorOffset.y * 2 - 342;
// Used in the XFB supplement and the keep aspect ratio function // Used in the XFB supplement and the keep aspect ratio function
int XOffset, YOffset; int XOffset = 0, YOffset = 0;
// ------------------------------------- // -------------------------------------
@ -1218,7 +1219,8 @@ void UpdateViewport()
/* I'm limiting it to the stretch to fit option because I don't know how the other mode works. The reason /* I'm limiting it to the stretch to fit option because I don't know how the other mode works. The reason
I don't allow this option together with UseXFB is that they are supplements and the XFB function I don't allow this option together with UseXFB is that they are supplements and the XFB function
should be able to produce the same result */ should be able to produce the same result */
if(g_Config.bStretchToFit && !g_Config.bUseXFB) //if(g_Config.bStretchToFit && !g_Config.bUseXFB)
if(false)
{ {
XOffset = (640 - GLScissorW); XOffset = (640 - GLScissorW);
YOffset = (480 - GLScissorH); YOffset = (480 - GLScissorH);
@ -1343,7 +1345,7 @@ void UpdateViewport()
GetWindowRect(Child, &RcChild); GetWindowRect(Child, &RcChild);
Console::ClearScreen(); //Console::ClearScreen();
Console::Print("----------------------------------------------------------------\n"); Console::Print("----------------------------------------------------------------\n");
Console::Print("Top window: X:%03i Y:%03i Width:%03i Height:%03i\n", RcTop.left, RcTop.top, RcTop.right - RcTop.left, RcTop.bottom - RcTop.top); Console::Print("Top window: X:%03i Y:%03i Width:%03i Height:%03i\n", RcTop.left, RcTop.top, RcTop.right - RcTop.left, RcTop.bottom - RcTop.top);
Console::Print("Parent window: X:%03i Y:%03i Width:%03i Height:%03i\n", RcParent.left, RcParent.top, RcParent.right - RcParent.left, RcParent.bottom - RcParent.top); Console::Print("Parent window: X:%03i Y:%03i Width:%03i Height:%03i\n", RcParent.left, RcParent.top, RcParent.right - RcParent.left, RcParent.bottom - RcParent.top);