GL: Delete "exact-2x" feature. The way it's currently implemented it requires us to allocate double-sized buffers, which really hurt some GFX cards. So, it's gone for now but may return later in some form.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4201 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
hrydgard 2009-09-04 17:29:16 +00:00
parent 8d4ecacb4b
commit 0d1662e020
8 changed files with 116 additions and 86 deletions

View File

@ -325,6 +325,86 @@ void Renderer::SetColorMask()
D3D::SetRenderState(D3DRS_COLORWRITEENABLE, write); D3D::SetRenderState(D3DRS_COLORWRITEENABLE, write);
} }
u32 Renderer::AccessEFB(EFBAccessType type, int x, int y)
{
// Get the rectangular target region covered by the EFB pixel.
EFBRectangle efbPixelRc;
efbPixelRc.left = x;
efbPixelRc.top = y;
efbPixelRc.right = x + 1;
efbPixelRc.bottom = y + 1;
TargetRectangle targetPixelRc = Renderer::ConvertEFBRectangle(efbPixelRc);
// TODO (FIX) : currently, AA path is broken/offset and doesn't return the correct pixel
switch (type)
{
case PEEK_Z:
{
// if (s_MSAASamples > 1)
{
// Resolve our rectangle.
// g_framebufferManager.GetEFBDepthTexture(efbPixelRc);
// glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, g_framebufferManager.GetResolvedFramebuffer());
}
// Sample from the center of the target region.
int srcX = (targetPixelRc.left + targetPixelRc.right) / 2;
int srcY = (targetPixelRc.top + targetPixelRc.bottom) / 2;
u32 z = 0;
// glReadPixels(srcX, srcY, 1, 1, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, &z);
// Scale the 32-bit value returned by glReadPixels to a 24-bit
// value (GC uses a 24-bit Z-buffer).
// TODO: in RE0 this value is often off by one, which causes lighting to disappear
return z >> 8;
}
case POKE_Z:
// TODO: Implement
break;
case PEEK_COLOR: // GXPeekARGB
{
// Although it may sound strange, this really is A8R8G8B8 and not RGBA or 24-bit...
// Tested in Killer 7, the first 8bits represent the alpha value which is used to
// determine if we're aiming at an enemy (0x80 / 0x88) or not (0x70)
// Wind Waker is also using it for the pictograph to determine the color of each pixel
// if (s_MSAASamples > 1)
{
// Resolve our rectangle.
// g_framebufferManager.GetEFBColorTexture(efbPixelRc);
// glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, g_framebufferManager.GetResolvedFramebuffer());
}
// Sample from the center of the target region.
int srcX = (targetPixelRc.left + targetPixelRc.right) / 2;
int srcY = (targetPixelRc.top + targetPixelRc.bottom) / 2;
// Read back pixel in BGRA format, then byteswap to get GameCube's ARGB Format.
u32 color = 0;
// glReadPixels(srcX, srcY, 1, 1, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, &color);
return color;
}
case POKE_COLOR:
// TODO: Implement. One way is to draw a tiny pixel-sized rectangle at
// the exact location. Note: EFB pokes are susceptible to Z-buffering
// and perhaps blending.
//WARN_LOG(VIDEOINTERFACE, "This is probably some kind of software rendering");
break;
}
return 0;
}
// mtx.m[0][3] = pMatrix[1]; // -0.5f/m_targetWidth; <-- fix d3d pixel center? // mtx.m[0][3] = pMatrix[1]; // -0.5f/m_targetWidth; <-- fix d3d pixel center?
// mtx.m[1][3] = pMatrix[3]; // +0.5f/m_targetHeight; <-- fix d3d pixel center? // mtx.m[1][3] = pMatrix[3]; // +0.5f/m_targetHeight; <-- fix d3d pixel center?

View File

@ -20,6 +20,7 @@
#include <d3dx9.h> #include <d3dx9.h>
#include "Common.h" #include "Common.h"
#include "Atomic.h"
#include "Thread.h" #include "Thread.h"
#include "LogManager.h" #include "LogManager.h"
@ -59,10 +60,9 @@ SVideoInitialize g_VideoInitialize;
PLUGIN_GLOBALS* globals = NULL; PLUGIN_GLOBALS* globals = NULL;
int initCount = 0; int initCount = 0;
static volatile u32 s_AccessEFBResult = 0, s_EFBx, s_EFBy; static u32 s_efbAccessRequested = FALSE;
static volatile EFBAccessType s_AccessEFBType; static volatile EFBAccessType s_AccessEFBType;
static Common::Event s_AccessEFBDone;
static Common::CriticalSection s_criticalEFB;
bool HandleDisplayList(u32 address, u32 size) bool HandleDisplayList(u32 address, u32 size)
{ {
@ -413,65 +413,40 @@ void Video_Screenshot(const char *_szFilename)
} }
} }
static struct
{
EFBAccessType type;
u32 x;
u32 y;
} s_accessEFBArgs;
static u32 s_AccessEFBResult = 0;
void VideoFifo_CheckEFBAccess() void VideoFifo_CheckEFBAccess()
{ {
s_criticalEFB.Enter(); if (Common::AtomicLoadAcquire(s_efbAccessRequested))
s_AccessEFBResult = 0;
/*
switch (s_AccessEFBType)
{ {
case PEEK_Z: s_AccessEFBResult = Renderer::AccessEFB(s_accessEFBArgs.type, s_accessEFBArgs.x, s_accessEFBArgs.y);
break;
case POKE_Z: Common::AtomicStoreRelease(s_efbAccessRequested, FALSE);
break;
case PEEK_COLOR:
break;
case POKE_COLOR:
break;
default:
break;
} }
*/
if (g_VideoInitialize.bUseDualCore)
s_AccessEFBDone.Set();
s_criticalEFB.Leave();
} }
u32 Video_AccessEFB(EFBAccessType type, u32 x, u32 y) u32 Video_AccessEFB(EFBAccessType type, u32 x, u32 y)
{ {
u32 result; s_accessEFBArgs.type = type;
s_accessEFBArgs.x = x;
s_accessEFBArgs.y = y;
s_criticalEFB.Enter(); Common::AtomicStoreRelease(s_efbAccessRequested, TRUE);
s_AccessEFBType = type;
s_EFBx = x;
s_EFBy = y;
if (g_VideoInitialize.bUseDualCore) if (g_VideoInitialize.bUseDualCore)
s_AccessEFBDone.Init(); {
while (Common::AtomicLoadAcquire(s_efbAccessRequested))
s_criticalEFB.Leave(); Common::YieldCPU();
}
if (g_VideoInitialize.bUseDualCore)
s_AccessEFBDone.Wait();
else else
VideoFifo_CheckEFBAccess(); VideoFifo_CheckEFBAccess();
s_criticalEFB.Enter(); return s_AccessEFBResult;
if (g_VideoInitialize.bUseDualCore)
s_AccessEFBDone.Shutdown();
result = s_AccessEFBResult;
s_criticalEFB.Leave();
return result;
} }

View File

@ -43,7 +43,6 @@ void Config::Load()
iniFile.Get("Hardware", "VSync", &bVSync, 0); // Hardware iniFile.Get("Hardware", "VSync", &bVSync, 0); // Hardware
iniFile.Get("Hardware", "RenderToMainframe", &renderToMainframe, false); iniFile.Get("Hardware", "RenderToMainframe", &renderToMainframe, false);
iniFile.Get("Settings", "StretchToFit", &bNativeResolution, true); iniFile.Get("Settings", "StretchToFit", &bNativeResolution, true);
iniFile.Get("Settings", "2xResolution", &b2xResolution, false);
iniFile.Get("Settings", "wideScreenHack", &bWidescreenHack, false); iniFile.Get("Settings", "wideScreenHack", &bWidescreenHack, false);
iniFile.Get("Settings", "KeepAR_4_3", &bKeepAR43, false); iniFile.Get("Settings", "KeepAR_4_3", &bKeepAR43, false);
iniFile.Get("Settings", "KeepAR_16_9", &bKeepAR169, false); iniFile.Get("Settings", "KeepAR_16_9", &bKeepAR169, false);
@ -137,7 +136,6 @@ void Config::Save()
iniFile.Set("Hardware", "VSync", bVSync); iniFile.Set("Hardware", "VSync", bVSync);
iniFile.Set("Hardware", "RenderToMainframe", renderToMainframe); iniFile.Set("Hardware", "RenderToMainframe", renderToMainframe);
iniFile.Set("Settings", "StretchToFit", bNativeResolution); iniFile.Set("Settings", "StretchToFit", bNativeResolution);
iniFile.Set("Settings", "2xResolution", b2xResolution);
iniFile.Set("Settings", "KeepAR_4_3", bKeepAR43); iniFile.Set("Settings", "KeepAR_4_3", bKeepAR43);
iniFile.Set("Settings", "KeepAR_16_9", bKeepAR169); iniFile.Set("Settings", "KeepAR_16_9", bKeepAR169);
iniFile.Set("Settings", "Crop", bCrop); iniFile.Set("Settings", "Crop", bCrop);

View File

@ -59,7 +59,7 @@ struct Config
char iFSResolution[16]; char iFSResolution[16];
char iInternalRes[16]; char iInternalRes[16];
bool bNativeResolution, b2xResolution; // Should possibly be augmented with 2x, 4x native. bool bNativeResolution; // Should possibly be augmented with 2x, 4x native.
bool bWidescreenHack; bool bWidescreenHack;
bool bKeepAR43, bKeepAR169, bCrop; // Aspect ratio controls. bool bKeepAR43, bKeepAR169, bCrop; // Aspect ratio controls.
bool bUseXFB; bool bUseXFB;

View File

@ -45,7 +45,6 @@ BEGIN_EVENT_TABLE(GFXConfigDialogOGL,wxDialog)
EVT_CHOICE(ID_MAXANISOTROPY, GFXConfigDialogOGL::GeneralSettingsChanged) EVT_CHOICE(ID_MAXANISOTROPY, GFXConfigDialogOGL::GeneralSettingsChanged)
EVT_CHOICE(ID_MSAAMODECB, GFXConfigDialogOGL::GeneralSettingsChanged) EVT_CHOICE(ID_MSAAMODECB, GFXConfigDialogOGL::GeneralSettingsChanged)
EVT_CHECKBOX(ID_NATIVERESOLUTION, GFXConfigDialogOGL::GeneralSettingsChanged) EVT_CHECKBOX(ID_NATIVERESOLUTION, GFXConfigDialogOGL::GeneralSettingsChanged)
EVT_CHECKBOX(ID_2X_RESOLUTION, GFXConfigDialogOGL::GeneralSettingsChanged)
EVT_CHECKBOX(ID_WIDESCREEN_HACK, GFXConfigDialogOGL::GeneralSettingsChanged) EVT_CHECKBOX(ID_WIDESCREEN_HACK, GFXConfigDialogOGL::GeneralSettingsChanged)
EVT_CHECKBOX(ID_USEXFB, GFXConfigDialogOGL::GeneralSettingsChanged) EVT_CHECKBOX(ID_USEXFB, GFXConfigDialogOGL::GeneralSettingsChanged)
EVT_CHECKBOX(ID_FORCEFILTERING, GFXConfigDialogOGL::GeneralSettingsChanged) EVT_CHECKBOX(ID_FORCEFILTERING, GFXConfigDialogOGL::GeneralSettingsChanged)
@ -179,7 +178,6 @@ void GFXConfigDialogOGL::CreateGUIControls()
m_RenderToMainWindow = new wxCheckBox(m_PageGeneral, ID_RENDERTOMAINWINDOW, wxT("Render to main window"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); m_RenderToMainWindow = new wxCheckBox(m_PageGeneral, ID_RENDERTOMAINWINDOW, wxT("Render to main window"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_RenderToMainWindow->SetValue(g_Config.renderToMainframe); m_RenderToMainWindow->SetValue(g_Config.renderToMainframe);
m_NativeResolution = new wxCheckBox(m_PageGeneral, ID_NATIVERESOLUTION, wxT("Native"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); m_NativeResolution = new wxCheckBox(m_PageGeneral, ID_NATIVERESOLUTION, wxT("Native"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_2xResolution = new wxCheckBox(m_PageGeneral, ID_2X_RESOLUTION, wxT("2x"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_WidescreenHack = new wxCheckBox(m_PageGeneral, ID_WIDESCREEN_HACK, wxT("Wide Screen Hack"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); m_WidescreenHack = new wxCheckBox(m_PageGeneral, ID_WIDESCREEN_HACK, wxT("Wide Screen Hack"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
wxStaticText *IRText = new wxStaticText(m_PageGeneral, ID_IRTEXT, wxT("Internal resolution Settings:"), wxDefaultPosition, wxDefaultSize, 0); wxStaticText *IRText = new wxStaticText(m_PageGeneral, ID_IRTEXT, wxT("Internal resolution Settings:"), wxDefaultPosition, wxDefaultSize, 0);
wxStaticText *RText = new wxStaticText(m_PageGeneral, ID_RTEXT, wxT("Resolution Settings:"), wxDefaultPosition, wxDefaultSize, 0); wxStaticText *RText = new wxStaticText(m_PageGeneral, ID_RTEXT, wxT("Resolution Settings:"), wxDefaultPosition, wxDefaultSize, 0);
@ -203,7 +201,6 @@ void GFXConfigDialogOGL::CreateGUIControls()
// Default values // Default values
m_NativeResolution->SetValue(g_Config.bNativeResolution); m_NativeResolution->SetValue(g_Config.bNativeResolution);
m_2xResolution->SetValue(g_Config.b2xResolution);
m_WidescreenHack->SetValue(g_Config.bWidescreenHack); m_WidescreenHack->SetValue(g_Config.bWidescreenHack);
m_KeepAR43->SetValue(g_Config.bKeepAR43); m_KeepAR43->SetValue(g_Config.bKeepAR43);
m_KeepAR169->SetValue(g_Config.bKeepAR169); m_KeepAR169->SetValue(g_Config.bKeepAR169);
@ -251,8 +248,6 @@ void GFXConfigDialogOGL::CreateGUIControls()
wxT("\nmay result in a blurrier image, but it may also give a higher") wxT("\nmay result in a blurrier image, but it may also give a higher")
wxT("\nFPS if you have a slow graphics card.") wxT("\nFPS if you have a slow graphics card.")
wxT("\n\nApplies instanty during gameplay: <Yes>")); wxT("\n\nApplies instanty during gameplay: <Yes>"));
m_2xResolution->SetToolTip(wxT(
"Applies instanty during gameplay: <Yes>"));
m_WidescreenHack->SetToolTip(wxT( m_WidescreenHack->SetToolTip(wxT(
"Applies instanty during gameplay: <Yes>")); "Applies instanty during gameplay: <Yes>"));
m_Crop->SetToolTip( m_Crop->SetToolTip(
@ -318,7 +313,6 @@ void GFXConfigDialogOGL::CreateGUIControls()
sBasic->Add(IRText, wxGBPosition(0, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL | wxALL, 5); sBasic->Add(IRText, wxGBPosition(0, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL | wxALL, 5);
sBasic->Add(m_NativeResolution, wxGBPosition(0, 1), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL | wxALL, 5); sBasic->Add(m_NativeResolution, wxGBPosition(0, 1), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL | wxALL, 5);
sBasic->Add(m_2xResolution, wxGBPosition(0, 2), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL | wxALL, 5);
sBasic->Add(RText, wxGBPosition(1, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL | wxALL, 5); sBasic->Add(RText, wxGBPosition(1, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL | wxALL, 5);
sBasic->Add(WMText, wxGBPosition(1, 1), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL | wxALL, 5); sBasic->Add(WMText, wxGBPosition(1, 1), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL | wxALL, 5);
@ -582,13 +576,6 @@ void GFXConfigDialogOGL::GeneralSettingsChanged(wxCommandEvent& event)
break; break;
case ID_NATIVERESOLUTION: case ID_NATIVERESOLUTION:
g_Config.bNativeResolution = m_NativeResolution->IsChecked(); g_Config.bNativeResolution = m_NativeResolution->IsChecked();
// Don't allow 1x and 2x at the same time
if (g_Config.bNativeResolution) { g_Config.b2xResolution = false; m_2xResolution->SetValue(false); }
break;
case ID_2X_RESOLUTION:
g_Config.b2xResolution = m_2xResolution->IsChecked();
// Don't allow 1x and 2x at the same time
if (g_Config.b2xResolution) { g_Config.bNativeResolution = false; m_NativeResolution->SetValue(false); }
break; break;
case ID_WIDESCREEN_HACK: case ID_WIDESCREEN_HACK:
g_Config.bWidescreenHack = m_WidescreenHack->IsChecked(); g_Config.bWidescreenHack = m_WidescreenHack->IsChecked();
@ -771,13 +758,12 @@ void GFXConfigDialogOGL::UpdateGUI()
if (g_Config.renderToMainframe) m_Fullscreen->SetValue(false); if (g_Config.renderToMainframe) m_Fullscreen->SetValue(false);
// Disable the internal resolution option if it's set to native // Disable the internal resolution option if it's set to native
m_WindowResolutionCB->Enable(!(g_Config.bNativeResolution || g_Config.b2xResolution)); m_WindowResolutionCB->Enable(!(g_Config.bNativeResolution));
m_WindowFSResolutionCB->Enable(!(g_Config.bNativeResolution || g_Config.b2xResolution)); m_WindowFSResolutionCB->Enable(!(g_Config.bNativeResolution));
//Disable the Copy to options when EFBCopy is disabled //Disable the Copy to options when EFBCopy is disabled
m_Radio_CopyEFBToRAM->Enable(!(g_Config.bEFBCopyDisable)); m_Radio_CopyEFBToRAM->Enable(!(g_Config.bEFBCopyDisable));
m_Radio_CopyEFBToGL->Enable(!(g_Config.bEFBCopyDisable)); m_Radio_CopyEFBToGL->Enable(!(g_Config.bEFBCopyDisable));
} }

View File

@ -92,7 +92,7 @@ class GFXConfigDialogOGL : public wxDialog
wxCheckBox *m_Fullscreen; wxCheckBox *m_Fullscreen;
wxCheckBox *m_VSync; wxCheckBox *m_VSync;
wxCheckBox *m_RenderToMainWindow; wxCheckBox *m_RenderToMainWindow;
wxCheckBox *m_NativeResolution, *m_2xResolution; wxCheckBox *m_NativeResolution;
wxCheckBox *m_WidescreenHack; wxCheckBox *m_WidescreenHack;
wxCheckBox *m_ForceFiltering; wxCheckBox *m_ForceFiltering;
wxCheckBox *m_KeepAR43, *m_KeepAR169, *m_Crop; wxCheckBox *m_KeepAR43, *m_KeepAR169, *m_Crop;
@ -150,7 +150,7 @@ class GFXConfigDialogOGL : public wxDialog
ID_FULLSCREEN, ID_FULLSCREEN,
ID_VSYNC, ID_VSYNC,
ID_RENDERTOMAINWINDOW, ID_RENDERTOMAINWINDOW,
ID_NATIVERESOLUTION, ID_2X_RESOLUTION, ID_NATIVERESOLUTION,
ID_WIDESCREEN_HACK, ID_WIDESCREEN_HACK,
ID_KEEPAR_4_3, ID_KEEPAR_16_9, ID_CROP, ID_KEEPAR_4_3, ID_KEEPAR_16_9, ID_CROP,
ID_USEXFB, ID_USEXFB,

View File

@ -98,12 +98,7 @@ void OSDMenu(WPARAM wParam)
case '3': case '3':
OSDChoice = 1; OSDChoice = 1;
// Toggle native resolution // Toggle native resolution
if (!(g_Config.bNativeResolution || g_Config.b2xResolution)) g_Config.bNativeResolution = !g_Config.bNativeResolution;
g_Config.bNativeResolution = true;
else if (g_Config.bNativeResolution)
{ g_Config.bNativeResolution = false; g_Config.b2xResolution = true; }
else
g_Config.b2xResolution = false;
break; break;
case '4': case '4':
OSDChoice = 2; OSDChoice = 2;

View File

@ -290,8 +290,8 @@ bool Renderer::Init()
if (g_Config.bNativeResolution) if (g_Config.bNativeResolution)
{ {
s_targetwidth = g_Config.b2xResolution ? EFB_WIDTH * 2 : EFB_WIDTH; s_targetwidth = EFB_WIDTH;
s_targetheight = g_Config.b2xResolution ? EFB_HEIGHT * 2 : EFB_HEIGHT; s_targetheight = EFB_HEIGHT;
} }
else else
{ {
@ -299,11 +299,9 @@ bool Renderer::Init()
// The EFB is larger than 640x480 - in fact, it's 640x528, give or take a couple of lines. // The EFB is larger than 640x480 - in fact, it's 640x528, give or take a couple of lines.
// So the below is wrong. // So the below is wrong.
// This should really be grabbed from config rather than from OpenGL. // This should really be grabbed from config rather than from OpenGL.
// JP: Set these to the biggest of the 2x mode and the custom resolution so that the framebuffer
// does not get to be too small
int W = (int)OpenGL_GetBackbufferWidth(), H = (int)OpenGL_GetBackbufferHeight(); int W = (int)OpenGL_GetBackbufferWidth(), H = (int)OpenGL_GetBackbufferHeight();
s_targetwidth = (1280 >= W) ? 1280 : W; s_targetwidth = (W < 640) ? 640 : W;
s_targetheight = (960 >= H) ? 960 : H; s_targetheight = (H < 480) ? 480 : H;
// Compensate height of render target for scaling, so that we get something close to the correct number of // Compensate height of render target for scaling, so that we get something close to the correct number of
// vertical pixels. // vertical pixels.
@ -1233,10 +1231,8 @@ void Renderer::DrawDebugText()
sscanf(g_Config.iInternalRes, "%dx%d", &W, &H); sscanf(g_Config.iInternalRes, "%dx%d", &W, &H);
std::string OSDM1 = std::string OSDM1 =
g_Config.bNativeResolution || g_Config.b2xResolution ? g_Config.bNativeResolution ?
(g_Config.bNativeResolution ?
StringFromFormat("%i x %i (native)", OSDInternalW, OSDInternalH) StringFromFormat("%i x %i (native)", OSDInternalW, OSDInternalH)
: StringFromFormat("%i x %i (2x)", OSDInternalW, OSDInternalH))
: StringFromFormat("%i x %i (custom)", W, H); : StringFromFormat("%i x %i (custom)", W, H);
std::string OSDM21 = std::string OSDM21 =
!(g_Config.bKeepAR43 || g_Config.bKeepAR169) ? "-": (g_Config.bKeepAR43 ? "4:3" : "16:9"); !(g_Config.bKeepAR43 || g_Config.bKeepAR169) ? "-": (g_Config.bKeepAR43 ? "4:3" : "16:9");