mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 14:49:42 -06:00
Added EFB Scale option to the OpenGL plug-in.
Renamed EFB Scale to Internal Resolution. Removed Auto Scale option (it is now always on). Added on-the-fly changing of the Internal Resolution in the OpenGL and Direct3D9 plug-ins. Further consolidated the code in the video plug-ins. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6240 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -197,7 +197,7 @@ GLuint FramebufferManager::GetEFBColorTexture(const EFBRectangle& sourceRc) cons
|
||||
// Transfer the EFB to a resolved texture. EXT_framebuffer_blit is
|
||||
// required.
|
||||
|
||||
TargetRectangle targetRc = ConvertEFBRectangle(sourceRc);
|
||||
TargetRectangle targetRc = Renderer::ConvertEFBRectangle(sourceRc);
|
||||
targetRc.ClampLL(0, 0, m_targetWidth, m_targetHeight);
|
||||
|
||||
// Resolve.
|
||||
@ -227,7 +227,7 @@ GLuint FramebufferManager::GetEFBDepthTexture(const EFBRectangle& sourceRc) cons
|
||||
// Transfer the EFB to a resolved texture. EXT_framebuffer_blit is
|
||||
// required.
|
||||
|
||||
TargetRectangle targetRc = ConvertEFBRectangle(sourceRc);
|
||||
TargetRectangle targetRc = Renderer::ConvertEFBRectangle(sourceRc);
|
||||
targetRc.ClampLL(0, 0, m_targetWidth, m_targetHeight);
|
||||
|
||||
// Resolve.
|
||||
@ -262,18 +262,6 @@ const XFBSource** FramebufferManager::GetXFBSource(u32 xfbAddr, u32 fbWidth, u32
|
||||
return getVirtualXFBSource(xfbAddr, fbWidth, fbHeight, xfbCount);
|
||||
}
|
||||
|
||||
TargetRectangle FramebufferManager::ConvertEFBRectangle(const EFBRectangle& rc) const
|
||||
{
|
||||
TargetRectangle result;
|
||||
float XScale = Renderer::GetTargetScaleX();
|
||||
float YScale = Renderer::GetTargetScaleY();
|
||||
result.left = rc.left * XScale;
|
||||
result.top = ((EFB_HEIGHT - rc.top) * YScale);
|
||||
result.right = rc.right * XScale ;
|
||||
result.bottom = ((EFB_HEIGHT - rc.bottom) * YScale);
|
||||
return result;
|
||||
}
|
||||
|
||||
FramebufferManager::VirtualXFBListType::iterator FramebufferManager::findVirtualXFB(u32 xfbAddr, u32 width, u32 height)
|
||||
{
|
||||
u32 srcLower = xfbAddr;
|
||||
@ -373,7 +361,7 @@ void FramebufferManager::copyToVirtualXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight
|
||||
|
||||
it->xfbSource.texWidth = Renderer::GetTargetWidth();
|
||||
it->xfbSource.texHeight = Renderer::GetTargetHeight();
|
||||
it->xfbSource.sourceRc = ConvertEFBRectangle(sourceRc);
|
||||
it->xfbSource.sourceRc = Renderer::ConvertEFBRectangle(sourceRc);
|
||||
|
||||
xfbTexture = it->xfbSource.texture;
|
||||
|
||||
@ -417,7 +405,7 @@ void FramebufferManager::copyToVirtualXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight
|
||||
newVirt.xfbSource.texture = xfbTexture;
|
||||
newVirt.xfbSource.texWidth = m_targetWidth;
|
||||
newVirt.xfbSource.texHeight = m_targetHeight;
|
||||
newVirt.xfbSource.sourceRc = ConvertEFBRectangle(sourceRc);
|
||||
newVirt.xfbSource.sourceRc = Renderer::ConvertEFBRectangle(sourceRc);
|
||||
|
||||
// Add the new Virtual XFB to the list
|
||||
|
||||
|
@ -106,8 +106,6 @@ public:
|
||||
// Resolved framebuffer is only used in MSAA mode.
|
||||
GLuint GetResolvedFramebuffer() const { return m_resolvedFramebuffer; }
|
||||
|
||||
TargetRectangle ConvertEFBRectangle(const EFBRectangle& rc) const;
|
||||
|
||||
void SetFramebuffer(GLuint fb);
|
||||
|
||||
// If in MSAA mode, this will perform a resolve of the specified rectangle, and return the resolve target as a texture ID.
|
||||
|
@ -164,16 +164,8 @@ THREAD_RETURN XEventThread(void *pArg)
|
||||
case XK_3:
|
||||
OSDChoice = 1;
|
||||
// Toggle native resolution
|
||||
if (!(g_Config.bNativeResolution || g_Config.b2xResolution))
|
||||
g_Config.bNativeResolution = true;
|
||||
else if (g_Config.bNativeResolution && Renderer::AllowCustom())
|
||||
{
|
||||
g_Config.bNativeResolution = false;
|
||||
if (Renderer::Allow2x())
|
||||
g_Config.b2xResolution = true;
|
||||
}
|
||||
else if (Renderer::AllowCustom())
|
||||
g_Config.b2xResolution = false;
|
||||
g_Config.iEFBScale = g_Config.iEFBScale + 1;
|
||||
if (g_Config.iEFBScale > 4) g_Config.iEFBScale = 0;
|
||||
break;
|
||||
case XK_4:
|
||||
OSDChoice = 2;
|
||||
|
@ -39,14 +39,12 @@ BEGIN_EVENT_TABLE(GFXConfigDialogOGL,wxDialog)
|
||||
EVT_CHECKBOX(ID_VSYNC, GFXConfigDialogOGL::GeneralSettingsChanged)
|
||||
EVT_CHOICE(ID_MAXANISOTROPY, GFXConfigDialogOGL::GeneralSettingsChanged)
|
||||
EVT_CHOICE(ID_MSAAMODECB, GFXConfigDialogOGL::GeneralSettingsChanged)
|
||||
EVT_CHECKBOX(ID_NATIVERESOLUTION, GFXConfigDialogOGL::GeneralSettingsChanged)
|
||||
EVT_CHECKBOX(ID_2X_RESOLUTION, GFXConfigDialogOGL::GeneralSettingsChanged)
|
||||
EVT_CHOICE(ID_EFBSCALEMODE, GFXConfigDialogOGL::GeneralSettingsChanged)
|
||||
EVT_CHECKBOX(ID_USEXFB, GFXConfigDialogOGL::GeneralSettingsChanged)
|
||||
EVT_CHECKBOX(ID_USEREALXFB, GFXConfigDialogOGL::GeneralSettingsChanged)
|
||||
EVT_CHECKBOX(ID_FORCEFILTERING, GFXConfigDialogOGL::GeneralSettingsChanged)
|
||||
EVT_CHECKBOX(ID_USENATIVEMIPS, GFXConfigDialogOGL::GeneralSettingsChanged)
|
||||
EVT_CHECKBOX(ID_EFBSCALEDCOPY, GFXConfigDialogOGL::GeneralSettingsChanged)
|
||||
EVT_CHECKBOX(ID_AUTOSCALE, GFXConfigDialogOGL::GeneralSettingsChanged)
|
||||
EVT_CHECKBOX(ID_WIDESCREENHACK, GFXConfigDialogOGL::GeneralSettingsChanged)
|
||||
EVT_CHOICE(ID_ASPECT, GFXConfigDialogOGL::GeneralSettingsChanged)
|
||||
EVT_CHECKBOX(ID_CROP, GFXConfigDialogOGL::GeneralSettingsChanged)
|
||||
@ -154,6 +152,13 @@ void GFXConfigDialogOGL::LoadShaders()
|
||||
|
||||
void GFXConfigDialogOGL::InitializeGUILists()
|
||||
{
|
||||
// EFB Scale
|
||||
arrayStringFor_EFBScale.Add(wxT("Auto (fractional)"));
|
||||
arrayStringFor_EFBScale.Add(wxT("Auto (integral)"));
|
||||
arrayStringFor_EFBScale.Add(wxT("Native"));
|
||||
arrayStringFor_EFBScale.Add(wxT("2x"));
|
||||
arrayStringFor_EFBScale.Add(wxT("3x"));
|
||||
|
||||
// Keep Aspect Ratio
|
||||
arrayStringFor_AspectRatio.Add(wxT("Auto Aspect (recommended)"));
|
||||
arrayStringFor_AspectRatio.Add(wxT("Force 16:9 Widescreen"));
|
||||
@ -191,8 +196,7 @@ void GFXConfigDialogOGL::InitializeGUILists()
|
||||
void GFXConfigDialogOGL::InitializeGUIValues()
|
||||
{
|
||||
// General Display Settings
|
||||
m_NativeResolution->SetValue(g_Config.bNativeResolution);
|
||||
m_2xResolution->SetValue(g_Config.b2xResolution);
|
||||
m_EFBScaleMode->SetSelection(g_Config.iEFBScale);
|
||||
|
||||
m_KeepAR->SetSelection(g_Config.iAspectRatio);
|
||||
m_Crop->SetValue(g_Config.bCrop);
|
||||
@ -202,7 +206,6 @@ void GFXConfigDialogOGL::InitializeGUIValues()
|
||||
m_VSync->SetValue(g_Config.bVSync);
|
||||
m_UseXFB->SetValue(g_Config.bUseXFB);
|
||||
m_UseRealXFB->SetValue(g_Config.bUseRealXFB);
|
||||
m_AutoScale->SetValue(g_Config.bAutoScale);
|
||||
m_WidescreenHack->SetValue(g_Config.bWidescreenHack);
|
||||
m_UseNativeMips->SetValue(g_Config.bUseNativeMips);
|
||||
m_EFBScaledCopy->SetValue(g_Config.bCopyEFBScaled);
|
||||
@ -260,14 +263,12 @@ void GFXConfigDialogOGL::InitializeGUIValues()
|
||||
void GFXConfigDialogOGL::InitializeGUITooltips()
|
||||
{
|
||||
// Tool tips
|
||||
m_NativeResolution->SetToolTip(
|
||||
wxT("This will use the game's native resolution and stretch it to fill the")
|
||||
wxT("\nwindow instead of changing the internal display resolution. It")
|
||||
m_EFBScaleMode->SetToolTip(
|
||||
wxT("This will change the game's native resolution and stretch it to fill the")
|
||||
wxT("\nwindow instead of changing the display resolution. It")
|
||||
wxT("\nmay result in a blurrier image, but it may also give a higher")
|
||||
wxT("\nFPS if you have a slow graphics card.")
|
||||
wxT("\n\nApplies instanty during gameplay: <Yes>"));
|
||||
m_2xResolution->SetToolTip(wxT(
|
||||
"Applies instanty during gameplay: <Yes, if allowed>"));
|
||||
wxT("\n\nApplies instantly during gameplay: <Yes>"));
|
||||
m_KeepAR->SetToolTip(
|
||||
wxT("This sets the aspect ratio of the image.")
|
||||
wxT("\nThe Widescreen hack may cause graphical issues in some games !")
|
||||
@ -358,9 +359,8 @@ void GFXConfigDialogOGL::CreateGUIControls()
|
||||
|
||||
// General Display Settings
|
||||
sbBasic = new wxStaticBoxSizer(wxVERTICAL, m_PageGeneral, wxT("Basic Display Settings"));
|
||||
wxStaticText *IRText = new wxStaticText(m_PageGeneral, wxID_ANY, wxT("Resolution:"), wxDefaultPosition, wxDefaultSize, 0);
|
||||
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);
|
||||
wxStaticText *IRText = new wxStaticText(m_PageGeneral, wxID_ANY, wxT("Internal Resolution:"), wxDefaultPosition, wxDefaultSize, 0);
|
||||
m_EFBScaleMode = new wxChoice(m_PageGeneral, ID_EFBSCALEMODE, wxDefaultPosition, wxDefaultSize, arrayStringFor_EFBScale);
|
||||
// Aspect ratio / positioning controls
|
||||
wxStaticText *KeepARText = new wxStaticText(m_PageGeneral, wxID_ANY, wxT("Keep aspect ratio:"), wxDefaultPosition, wxDefaultSize, 0);
|
||||
m_KeepAR = new wxChoice(m_PageGeneral, ID_ASPECT, wxDefaultPosition, wxDefaultSize, arrayStringFor_AspectRatio);
|
||||
@ -375,7 +375,6 @@ void GFXConfigDialogOGL::CreateGUIControls()
|
||||
m_VSync = new wxCheckBox(m_PageGeneral, ID_VSYNC, wxT("VSync (req. restart)"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
|
||||
m_UseXFB = new wxCheckBox(m_PageGeneral, ID_USEXFB, wxT("Use XFB"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
|
||||
m_UseRealXFB = new wxCheckBox(m_PageGeneral, ID_USEREALXFB, wxT("Use Real XFB"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
|
||||
m_AutoScale = new wxCheckBox(m_PageGeneral, ID_AUTOSCALE, wxT("Auto scale (try to remove borders)"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
|
||||
m_WidescreenHack = new wxCheckBox(m_PageGeneral, ID_WIDESCREENHACK, wxT("Wide screen hack"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
|
||||
m_UseNativeMips = new wxCheckBox(m_PageGeneral, ID_USENATIVEMIPS, wxT("Use Native Mips"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
|
||||
m_EFBScaledCopy = new wxCheckBox(m_PageGeneral, ID_EFBSCALEDCOPY, wxT("EFB Scaled Copy"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
|
||||
@ -397,8 +396,7 @@ void GFXConfigDialogOGL::CreateGUIControls()
|
||||
sBasic = new wxGridBagSizer(0, 0);
|
||||
|
||||
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_2xResolution, wxGBPosition(0, 2), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL | wxALL, 5);
|
||||
sBasic->Add(m_EFBScaleMode, wxGBPosition(0, 1), wxGBSpan(1, 1), wxALL, 5);
|
||||
|
||||
sBasic->Add(KeepARText, wxGBPosition(1, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL | wxALL, 5);
|
||||
sBasic->Add(m_KeepAR, wxGBPosition(1, 1), wxGBSpan(1, 1), wxALL, 5);
|
||||
@ -413,7 +411,6 @@ void GFXConfigDialogOGL::CreateGUIControls()
|
||||
sBasicAdvanced->Add(m_VSync, wxGBPosition(1, 0), wxGBSpan(1, 2), wxALL, 5);
|
||||
sBasicAdvanced->Add(m_UseXFB, wxGBPosition(2, 0), wxGBSpan(1, 2), wxALL, 5);
|
||||
sBasicAdvanced->Add(m_UseRealXFB, wxGBPosition(3, 0), wxGBSpan(1, 2), wxALL, 5);
|
||||
sBasicAdvanced->Add(m_AutoScale, wxGBPosition(4, 0), wxGBSpan(1, 2), wxALL, 5);
|
||||
sBasicAdvanced->Add(m_WidescreenHack, wxGBPosition(5, 0), wxGBSpan(1, 2), wxALL, 5);
|
||||
sBasicAdvanced->Add(m_UseNativeMips, wxGBPosition(6, 0), wxGBSpan(1, 2), wxALL, 5);
|
||||
sBasicAdvanced->Add(m_EFBScaledCopy, wxGBPosition(7, 0), wxGBSpan(1, 2), wxALL, 5);
|
||||
@ -589,15 +586,9 @@ void GFXConfigDialogOGL::GeneralSettingsChanged(wxCommandEvent& event)
|
||||
{
|
||||
switch (event.GetId())
|
||||
{
|
||||
case ID_NATIVERESOLUTION:
|
||||
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); }
|
||||
case ID_EFBSCALEMODE:
|
||||
g_Config.iEFBScale = m_EFBScaleMode->GetSelection();
|
||||
|
||||
break;
|
||||
case ID_VSYNC:
|
||||
g_Config.bVSync = m_VSync->IsChecked();
|
||||
@ -614,9 +605,6 @@ void GFXConfigDialogOGL::GeneralSettingsChanged(wxCommandEvent& event)
|
||||
case ID_EFBSCALEDCOPY:
|
||||
g_Config.bCopyEFBScaled = m_EFBScaledCopy->IsChecked();
|
||||
break;
|
||||
case ID_AUTOSCALE:
|
||||
g_Config.bAutoScale = m_AutoScale->IsChecked();
|
||||
break;
|
||||
case ID_ASPECT:
|
||||
g_Config.iAspectRatio = m_KeepAR->GetSelection();
|
||||
break;
|
||||
@ -775,20 +763,14 @@ void GFXConfigDialogOGL::UpdateGUI()
|
||||
m_UseXFB->SetValue(true);
|
||||
|
||||
// XFB looks much better if the copy comes from native resolution.
|
||||
g_Config.bNativeResolution = true;
|
||||
m_NativeResolution->SetValue(true);
|
||||
//also disable 2x, since it might leave both checked.
|
||||
g_Config.b2xResolution = false;
|
||||
m_2xResolution->SetValue(false);
|
||||
g_Config.iEFBScale = 2;
|
||||
m_EFBScaleMode->SetSelection(g_Config.iEFBScale);
|
||||
}
|
||||
m_AutoScale->Enable(!g_Config.bUseRealXFB);
|
||||
m_UseXFB->Enable(!g_Config.bUseRealXFB);
|
||||
|
||||
// Resolution settings
|
||||
//disable native/2x choice when real xfb is on. native simply looks best, as ector noted above.
|
||||
//besides, it would look odd if one disabled native, and it came back on again.
|
||||
m_NativeResolution->Enable(!g_Config.bUseRealXFB);
|
||||
m_2xResolution->Enable(!g_Config.bUseRealXFB && (!g_Config.bRunning || Renderer::Allow2x()));
|
||||
m_EFBScaleMode->Enable(!g_Config.bUseRealXFB);
|
||||
|
||||
|
||||
// Disable the Copy to options when EFBCopy is disabled
|
||||
m_Radio_CopyEFBToRAM->Enable(!(g_Config.bEFBCopyDisable));
|
||||
|
@ -90,7 +90,7 @@ class GFXConfigDialogOGL : public wxDialog
|
||||
wxPanel *m_PageGeneral;
|
||||
wxPanel *m_PageAdvanced;
|
||||
wxCheckBox *m_VSync;
|
||||
wxCheckBox *m_NativeResolution, *m_2xResolution;
|
||||
wxChoice *m_EFBScaleMode;
|
||||
wxCheckBox *m_WidescreenHack;
|
||||
wxCheckBox *m_ForceFiltering;
|
||||
wxCheckBox *m_Crop;
|
||||
@ -98,7 +98,6 @@ class GFXConfigDialogOGL : public wxDialog
|
||||
wxCheckBox *m_UseNativeMips;
|
||||
wxCheckBox *m_EFBScaledCopy;
|
||||
wxCheckBox *m_UseRealXFB;
|
||||
wxCheckBox *m_AutoScale;
|
||||
wxChoice *m_MaxAnisotropyCB;
|
||||
wxChoice *m_MSAAModeCB, *m_PhackvalueCB, *m_PostShaderCB, *m_KeepAR;
|
||||
|
||||
@ -136,6 +135,7 @@ class GFXConfigDialogOGL : public wxDialog
|
||||
wxCheckBox *m_ScreenSize;
|
||||
|
||||
wxArrayString arrayStringFor_FullscreenCB;
|
||||
wxArrayString arrayStringFor_EFBScale;
|
||||
wxArrayString arrayStringFor_AspectRatio;
|
||||
wxArrayString arrayStringFor_MaxAnisotropyCB;
|
||||
wxArrayString arrayStringFor_MSAAModeCB;
|
||||
@ -149,14 +149,13 @@ class GFXConfigDialogOGL : public wxDialog
|
||||
ID_PAGEADVANCED,
|
||||
|
||||
ID_VSYNC,
|
||||
ID_NATIVERESOLUTION, ID_2X_RESOLUTION,
|
||||
ID_EFBSCALEMODE,
|
||||
ID_ASPECT,
|
||||
ID_CROP,
|
||||
ID_USEREALXFB,
|
||||
ID_USEXFB,
|
||||
ID_USENATIVEMIPS,
|
||||
ID_EFBSCALEDCOPY,
|
||||
ID_AUTOSCALE,
|
||||
ID_WIDESCREENHACK,
|
||||
|
||||
ID_FORCEFILTERING,
|
||||
|
@ -123,7 +123,7 @@ void GLVertexFormat::Initialize(const PortableVertexDeclaration &_vtx_decl)
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
if (_vtx_decl.color_offset[i] != -1)
|
||||
{
|
||||
|
@ -89,12 +89,8 @@ void OSDMenu(WPARAM wParam)
|
||||
case '3':
|
||||
OSDChoice = 1;
|
||||
// Toggle native resolution
|
||||
if (!(g_Config.bNativeResolution || g_Config.b2xResolution))
|
||||
g_Config.bNativeResolution = true;
|
||||
else if (g_Config.bNativeResolution && Renderer::AllowCustom())
|
||||
{ g_Config.bNativeResolution = false; if (Renderer::Allow2x()) {g_Config.b2xResolution = true;} }
|
||||
else if (Renderer::AllowCustom())
|
||||
g_Config.b2xResolution = false;
|
||||
g_Config.iEFBScale = g_Config.iEFBScale + 1;
|
||||
if (g_Config.iEFBScale > 4) g_Config.iEFBScale = 0;
|
||||
break;
|
||||
case '4':
|
||||
OSDChoice = 2;
|
||||
|
@ -35,7 +35,7 @@
|
||||
static int s_nMaxPixelInstructions;
|
||||
static GLuint s_ColorMatrixProgram = 0;
|
||||
static GLuint s_DepthMatrixProgram = 0;
|
||||
PixelShaderCache::PSCache PixelShaderCache::pshaders;
|
||||
PixelShaderCache::PSCache PixelShaderCache::PixelShaders;
|
||||
PIXELSHADERUID PixelShaderCache::s_curuid;
|
||||
bool PixelShaderCache::s_displayCompileAlert;
|
||||
GLuint PixelShaderCache::CurrentShader;
|
||||
@ -177,27 +177,30 @@ void PixelShaderCache::Shutdown()
|
||||
s_ColorMatrixProgram = 0;
|
||||
glDeleteProgramsARB(1, &s_DepthMatrixProgram);
|
||||
s_DepthMatrixProgram = 0;
|
||||
PSCache::iterator iter = pshaders.begin();
|
||||
for (; iter != pshaders.end(); iter++)
|
||||
PSCache::iterator iter = PixelShaders.begin();
|
||||
for (; iter != PixelShaders.end(); iter++)
|
||||
iter->second.Destroy();
|
||||
pshaders.clear();
|
||||
PixelShaders.clear();
|
||||
}
|
||||
|
||||
FRAGMENTSHADER* PixelShaderCache::SetShader(bool dstAlphaEnable,u32 components)
|
||||
FRAGMENTSHADER* PixelShaderCache::SetShader(bool dstAlpha,u32 components)
|
||||
{
|
||||
DVSTARTPROFILE();
|
||||
PIXELSHADERUID uid;
|
||||
GetPixelShaderId(&uid, dstAlphaEnable ? 1 : 0);
|
||||
if (uid == last_pixel_shader_uid && pshaders[uid].frameCount == frameCount)
|
||||
GetPixelShaderId(&uid, dstAlpha ? 1 : 0);
|
||||
|
||||
// Check if the shader is already set
|
||||
if (uid == last_pixel_shader_uid && PixelShaders[uid].frameCount == frameCount)
|
||||
{
|
||||
return pShaderLast;
|
||||
}
|
||||
|
||||
memcpy(&last_pixel_shader_uid, &uid, sizeof(PIXELSHADERUID));
|
||||
|
||||
PSCache::iterator iter = pshaders.find(uid);
|
||||
PSCache::iterator iter = PixelShaders.find(uid);
|
||||
|
||||
if (iter != pshaders.end()) {
|
||||
if (iter != PixelShaders.end())
|
||||
{
|
||||
iter->second.frameCount = frameCount;
|
||||
PSCacheEntry &entry = iter->second;
|
||||
if (&entry.shader != pShaderLast)
|
||||
@ -209,10 +212,10 @@ FRAGMENTSHADER* PixelShaderCache::SetShader(bool dstAlphaEnable,u32 components)
|
||||
}
|
||||
|
||||
//Make an entry in the table
|
||||
PSCacheEntry& newentry = pshaders[uid];
|
||||
PSCacheEntry& newentry = PixelShaders[uid];
|
||||
newentry.frameCount = frameCount;
|
||||
pShaderLast = &newentry.shader;
|
||||
const char *code = GeneratePixelShaderCode(dstAlphaEnable,API_OPENGL,components);
|
||||
const char *code = GeneratePixelShaderCode(dstAlpha,API_OPENGL,components);
|
||||
|
||||
#if defined(_DEBUG) || defined(DEBUGFAST)
|
||||
if (g_ActiveConfig.iLog & CONF_SAVESHADERS && code) {
|
||||
@ -235,7 +238,7 @@ FRAGMENTSHADER* PixelShaderCache::SetShader(bool dstAlphaEnable,u32 components)
|
||||
}
|
||||
|
||||
INCSTAT(stats.numPixelShadersCreated);
|
||||
SETSTAT(stats.numPixelShadersAlive, pshaders.size());
|
||||
SETSTAT(stats.numPixelShadersAlive, PixelShaders.size());
|
||||
return pShaderLast;
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ class PixelShaderCache
|
||||
|
||||
typedef std::map<PIXELSHADERUID, PSCacheEntry> PSCache;
|
||||
|
||||
static PSCache pshaders;
|
||||
static PSCache PixelShaders;
|
||||
|
||||
static PIXELSHADERUID s_curuid; // the current pixel shader uid (progressively changed as memory is written)
|
||||
|
||||
|
@ -94,6 +94,7 @@ static int s_MSAACoverageSamples = 0;
|
||||
bool s_bHaveFramebufferBlit = false; // export to FramebufferManager.cpp
|
||||
static bool s_bHaveCoverageMSAA = false;
|
||||
static u32 s_blendMode;
|
||||
static u32 s_LastEFBScale;
|
||||
|
||||
static volatile bool s_bScreenshot = false;
|
||||
#if defined(HAVE_WX) && HAVE_WX
|
||||
@ -105,6 +106,9 @@ static std::string s_sScreenshotName;
|
||||
int frameCount;
|
||||
|
||||
// The custom resolution
|
||||
static int s_Fulltarget_width;
|
||||
static int s_Fulltarget_height;
|
||||
|
||||
// TODO: Add functionality to reinit all the render targets when the window is resized.
|
||||
static int s_backbuffer_width;
|
||||
static int s_backbuffer_height;
|
||||
@ -348,29 +352,40 @@ bool Renderer::Init()
|
||||
TargetRectangle dst_rect;
|
||||
ComputeDrawRectangle(s_backbuffer_width, s_backbuffer_height, false, &dst_rect);
|
||||
|
||||
xScale = 1.0f;
|
||||
yScale = 1.0f;
|
||||
|
||||
if(!g_ActiveConfig.bNativeResolution)
|
||||
if(g_ActiveConfig.bUseRealXFB)
|
||||
{
|
||||
if (g_ActiveConfig.b2xResolution)
|
||||
{
|
||||
xScale = 2.0f;
|
||||
yScale = 2.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
xScale = (float)(dst_rect.right - dst_rect.left) / (float)s_XFB_width;
|
||||
yScale = (float)(dst_rect.bottom - dst_rect.top) / (float)s_XFB_height;
|
||||
}
|
||||
xScale = 1.0f;
|
||||
yScale = 1.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
xScale = (float)(dst_rect.right - dst_rect.left) / (float)s_XFB_width;
|
||||
yScale = (float)(dst_rect.bottom - dst_rect.top) / (float)s_XFB_height;
|
||||
}
|
||||
|
||||
EFBxScale = ceilf(xScale);
|
||||
EFByScale = ceilf(yScale);
|
||||
s_LastEFBScale = g_ActiveConfig.iEFBScale;
|
||||
switch(s_LastEFBScale)
|
||||
{
|
||||
case 0:
|
||||
EFBxScale = xScale;
|
||||
EFByScale = yScale;
|
||||
break;
|
||||
case 1:
|
||||
EFBxScale = ceilf(xScale);
|
||||
EFByScale = ceilf(yScale);
|
||||
break;
|
||||
default:
|
||||
EFBxScale = g_ActiveConfig.iEFBScale - 1;
|
||||
EFByScale = EFBxScale;
|
||||
break;
|
||||
};
|
||||
|
||||
s_target_width = EFB_WIDTH * EFBxScale;
|
||||
s_target_height = EFB_HEIGHT * EFByScale;
|
||||
|
||||
s_Fulltarget_width = s_target_width;
|
||||
s_Fulltarget_height = s_target_height;
|
||||
|
||||
// Because of the fixed framebuffer size we need to disable the resolution
|
||||
// options while running
|
||||
g_Config.bRunning = true;
|
||||
@ -488,7 +503,7 @@ bool Renderer::Init()
|
||||
return GL_REPORT_ERROR() == GL_NO_ERROR && bSuccess;
|
||||
}
|
||||
|
||||
void Renderer::Shutdown(void)
|
||||
void Renderer::Shutdown()
|
||||
{
|
||||
g_Config.bRunning = false;
|
||||
UpdateActiveConfig();
|
||||
@ -530,15 +545,14 @@ int Renderer::GetTargetHeight()
|
||||
return s_target_height;
|
||||
}
|
||||
|
||||
// Return the custom resolution
|
||||
int Renderer::GetCustomWidth()
|
||||
int Renderer::GetFullTargetWidth()
|
||||
{
|
||||
return s_backbuffer_width;
|
||||
return s_Fulltarget_width;
|
||||
}
|
||||
|
||||
int Renderer::GetCustomHeight()
|
||||
int Renderer::GetFullTargetHeight()
|
||||
{
|
||||
return s_backbuffer_height;
|
||||
return s_Fulltarget_height;
|
||||
}
|
||||
|
||||
float Renderer::GetTargetScaleX()
|
||||
@ -561,17 +575,6 @@ float Renderer::GetXFBScaleY()
|
||||
return yScale;
|
||||
}
|
||||
|
||||
// Return the framebuffer size
|
||||
int Renderer::GetFrameBufferWidth()
|
||||
{
|
||||
return s_target_width;
|
||||
}
|
||||
|
||||
int Renderer::GetFrameBufferHeight()
|
||||
{
|
||||
return s_target_height;
|
||||
}
|
||||
|
||||
// Create On-Screen-Messages
|
||||
void Renderer::DrawDebugText()
|
||||
{
|
||||
@ -657,16 +660,26 @@ void Renderer::DrawDebugText()
|
||||
std::string T1 = "", T2 = "";
|
||||
std::vector<std::string> T0;
|
||||
|
||||
int W, H;
|
||||
W = OpenGL_GetBackbufferWidth();
|
||||
H = OpenGL_GetBackbufferHeight();
|
||||
std::string OSDM1;
|
||||
switch(g_ActiveConfig.iEFBScale)
|
||||
{
|
||||
case 0:
|
||||
OSDM1 = "Auto (fractional)";
|
||||
break;
|
||||
case 1:
|
||||
OSDM1 = "Auto (integral)";
|
||||
break;
|
||||
case 2:
|
||||
OSDM1 = "Native";
|
||||
break;
|
||||
case 3:
|
||||
OSDM1 = "2x";
|
||||
break;
|
||||
case 4:
|
||||
OSDM1 = "3x";
|
||||
break;
|
||||
}
|
||||
|
||||
std::string OSDM1 =
|
||||
g_ActiveConfig.bNativeResolution || g_ActiveConfig.b2xResolution ?
|
||||
(g_ActiveConfig.bNativeResolution ?
|
||||
StringFromFormat("%i x %i (native)", OSDInternalW, OSDInternalH)
|
||||
: StringFromFormat("%i x %i (2x)", OSDInternalW, OSDInternalH))
|
||||
: StringFromFormat("%i x %i (custom)", W, H);
|
||||
std::string OSDM21;
|
||||
switch(g_ActiveConfig.iAspectRatio)
|
||||
{
|
||||
@ -740,7 +753,14 @@ void Renderer::RenderText(const char *text, int left, int top, u32 color)
|
||||
|
||||
TargetRectangle Renderer::ConvertEFBRectangle(const EFBRectangle& rc)
|
||||
{
|
||||
return g_framebufferManager.ConvertEFBRectangle(rc);
|
||||
TargetRectangle result;
|
||||
int Xstride = (s_Fulltarget_width - s_target_width) / 2;
|
||||
int Ystride = (s_Fulltarget_height - s_target_height) / 2;
|
||||
result.left = (int)(rc.left * EFBxScale) + Xstride;
|
||||
result.top = (int)((EFB_HEIGHT - rc.top) * EFByScale) + Ystride;
|
||||
result.right = (int)(rc.right * EFBxScale) - (Xstride * 2);
|
||||
result.bottom = (int)((EFB_HEIGHT - rc.bottom) * EFByScale) - (Ystride * 2);
|
||||
return result;
|
||||
}
|
||||
|
||||
void Renderer::RenderToXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRectangle& sourceRc)
|
||||
@ -778,39 +798,51 @@ bool Renderer::SetScissorRect()
|
||||
{
|
||||
int xoff = bpmem.scissorOffset.x * 2 - 342;
|
||||
int yoff = bpmem.scissorOffset.y * 2 - 342;
|
||||
|
||||
float rc_left = (float)bpmem.scissorTL.x - xoff - 342; // left = 0
|
||||
if (rc_left < 0) rc_left = 0;
|
||||
|
||||
float rc_top = (float)bpmem.scissorTL.y - yoff - 342; // right = 0
|
||||
if (rc_top < 0) rc_top = 0;
|
||||
|
||||
float rc_right = (float)bpmem.scissorBR.x - xoff - 341; // right = 640
|
||||
if (rc_right > EFB_WIDTH) rc_right = EFB_WIDTH;
|
||||
|
||||
float rc_bottom = (float)bpmem.scissorBR.y - yoff - 341; // bottom = 480
|
||||
|
||||
// TODO: Sanity checks require further testing
|
||||
if (rc_left < 0) rc_left = 0;
|
||||
//if (rc_right < 0) rc_right = 0;
|
||||
//if (rc_left > EFB_WIDTH) rc_left = EFB_WIDTH;
|
||||
if (rc_right > EFB_WIDTH) rc_right = EFB_WIDTH;
|
||||
if (rc_top < 0) rc_top = 0;
|
||||
//if (rc_bottom < 0) rc_bottom = 0;
|
||||
//if (rc_top > EFB_HEIGHT) rc_top = EFB_HEIGHT;
|
||||
if (rc_bottom > EFB_HEIGHT) rc_bottom = EFB_HEIGHT;
|
||||
|
||||
if(rc_left > rc_right)
|
||||
if (rc_left > rc_right)
|
||||
{
|
||||
int temp = rc_right;
|
||||
rc_right = rc_left;
|
||||
rc_left = temp;
|
||||
}
|
||||
if(rc_top > rc_bottom)
|
||||
if (rc_top > rc_bottom)
|
||||
{
|
||||
int temp = rc_bottom;
|
||||
rc_bottom = rc_top;
|
||||
rc_top = temp;
|
||||
}
|
||||
|
||||
int Xstride = (s_Fulltarget_width - s_target_width) / 2;
|
||||
int Ystride = (s_Fulltarget_height - s_target_height) / 2;
|
||||
|
||||
rc_left = (int)(rc_left * EFBxScale);// + Xstride;
|
||||
rc_top = (int)((rc_bottom - rc_top) * EFByScale);// + Ystride;
|
||||
rc_right = (int)((rc_right - rc_left) * EFBxScale);
|
||||
rc_bottom = (int)((EFB_HEIGHT - rc_bottom) * EFByScale); // -Ystride?
|
||||
|
||||
// Check that the coordinates are good
|
||||
if (rc_right != rc_left && rc_bottom != rc_top)
|
||||
{
|
||||
glScissor(
|
||||
(int)(rc_left * EFBxScale), // x = 0 for example
|
||||
(int)((EFB_HEIGHT - rc_bottom) * EFByScale), // y = 0 for example
|
||||
(int)((rc_right - rc_left)* EFBxScale), // width = 640 for example
|
||||
(int)((rc_bottom - rc_top) * EFByScale) // height = 480 for example
|
||||
(int)(rc_left), // x = 0 for example
|
||||
(int)(rc_bottom), // y = 0 for example
|
||||
(int)(rc_right), // width = 640 for example
|
||||
(int)(rc_top) // height = 480 for example
|
||||
);
|
||||
return true;
|
||||
}
|
||||
@ -835,7 +867,7 @@ void Renderer::SetColorMask()
|
||||
|
||||
u32 Renderer::AccessEFB(EFBAccessType type, int x, int y)
|
||||
{
|
||||
if(!g_ActiveConfig.bEFBAccessEnable)
|
||||
if (!g_ActiveConfig.bEFBAccessEnable)
|
||||
return 0;
|
||||
|
||||
// Get the rectangular target region covered by the EFB pixel
|
||||
@ -845,7 +877,7 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y)
|
||||
efbPixelRc.right = x + 1;
|
||||
efbPixelRc.bottom = y + 1;
|
||||
|
||||
TargetRectangle targetPixelRc = Renderer::ConvertEFBRectangle(efbPixelRc);
|
||||
TargetRectangle targetPixelRc = ConvertEFBRectangle(efbPixelRc);
|
||||
|
||||
// TODO (FIX) : currently, AA path is broken/offset and doesn't return the correct pixel
|
||||
switch (type)
|
||||
@ -929,42 +961,44 @@ void UpdateViewport()
|
||||
// [3] = xorig + width/2 + 342
|
||||
// [4] = yorig + height/2 + 342
|
||||
// [5] = 16777215 * farz
|
||||
float scissorXOff = float(bpmem.scissorOffset.x) * 2.0f; // 342
|
||||
float scissorYOff = float(bpmem.scissorOffset.y) * 2.0f; // 342
|
||||
|
||||
int scissorXOff = bpmem.scissorOffset.x * 2;
|
||||
int scissorYOff = bpmem.scissorOffset.y * 2;
|
||||
|
||||
int Xstride = (s_Fulltarget_width - s_target_width) / 2;
|
||||
int Ystride = (s_Fulltarget_height - s_target_height) / 2;
|
||||
|
||||
// Stretch picture with increased internal resolution
|
||||
int GLx = (int)ceil((xfregs.rawViewport[3] - xfregs.rawViewport[0] - scissorXOff) *
|
||||
EFBxScale);
|
||||
int GLy = (int)ceil(
|
||||
(float(EFB_HEIGHT) - xfregs.rawViewport[4] + xfregs.rawViewport[1] + scissorYOff) *
|
||||
EFByScale);
|
||||
int GLWidth = (int)ceil(2.0f * xfregs.rawViewport[0] * EFBxScale);
|
||||
int GLHeight = (int)ceil(-2.0f * xfregs.rawViewport[1] * EFByScale);
|
||||
int X = (int)ceil((xfregs.rawViewport[3] - xfregs.rawViewport[0] - float(scissorXOff)) * EFBxScale);
|
||||
int Y = (int)ceil((float(EFB_HEIGHT) - xfregs.rawViewport[4] + xfregs.rawViewport[1] + float(scissorYOff)) * EFByScale);
|
||||
int Width = (int)ceil(2.0f * xfregs.rawViewport[0] * EFBxScale);
|
||||
int Height = (int)ceil(-2.0f * xfregs.rawViewport[1] * EFByScale);
|
||||
double GLNear = (xfregs.rawViewport[5] - xfregs.rawViewport[2]) / 16777216.0f;
|
||||
double GLFar = xfregs.rawViewport[5] / 16777216.0f;
|
||||
if(GLWidth < 0)
|
||||
if (Width < 0)
|
||||
{
|
||||
GLx += GLWidth;
|
||||
GLWidth*=-1;
|
||||
X += Width;
|
||||
Width*=-1;
|
||||
}
|
||||
if(GLHeight < 0)
|
||||
if (Height < 0)
|
||||
{
|
||||
GLy += GLHeight;
|
||||
GLHeight *= -1;
|
||||
Y += Height;
|
||||
Height *= -1;
|
||||
}
|
||||
// Update the view port
|
||||
glViewport(GLx, GLy, GLWidth, GLHeight);
|
||||
glViewport(X, Y, Width, Height);
|
||||
glDepthRange(GLNear, GLFar);
|
||||
}
|
||||
|
||||
void Renderer::ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaEnable, bool zEnable, u32 color, u32 z)
|
||||
{
|
||||
// Update the view port for clearing the picture
|
||||
TargetRectangle targetRc = Renderer::ConvertEFBRectangle(rc);
|
||||
TargetRectangle targetRc = ConvertEFBRectangle(rc);
|
||||
glViewport(targetRc.left, targetRc.bottom, targetRc.GetWidth(), targetRc.GetHeight());
|
||||
glScissor(targetRc.left, targetRc.bottom, targetRc.GetWidth(), targetRc.GetHeight());
|
||||
|
||||
|
||||
// Always set the scissor in case it was set by the game and has not been reset
|
||||
glScissor(targetRc.left, targetRc.bottom, targetRc.GetWidth(), targetRc.GetHeight());
|
||||
|
||||
VertexShaderManager::SetViewportChanged();
|
||||
|
||||
@ -1048,10 +1082,9 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
||||
}
|
||||
|
||||
DVSTARTPROFILE();
|
||||
|
||||
ResetAPIState();
|
||||
TargetRectangle back_rc;
|
||||
ComputeDrawRectangle(s_backbuffer_width, s_backbuffer_height, true, &back_rc);
|
||||
TargetRectangle dst_rect;
|
||||
ComputeDrawRectangle(s_backbuffer_width, s_backbuffer_height, true, &dst_rect);
|
||||
|
||||
// Make sure that the wireframe setting doesn't screw up the screen copy.
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
@ -1063,7 +1096,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
||||
TextureCache::DisableStage(i);
|
||||
|
||||
// Update GLViewPort
|
||||
glViewport(back_rc.left, back_rc.bottom, back_rc.GetWidth(), back_rc.GetHeight());
|
||||
glViewport(dst_rect.left, dst_rect.bottom, dst_rect.GetWidth(), dst_rect.GetHeight());
|
||||
|
||||
GL_REPORT_ERRORD();
|
||||
|
||||
@ -1094,21 +1127,11 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
||||
|
||||
TargetRectangle sourceRc;
|
||||
|
||||
if (g_ActiveConfig.bAutoScale || g_ActiveConfig.bUseXFB)
|
||||
{
|
||||
sourceRc = xfbSource->sourceRc;
|
||||
}
|
||||
else
|
||||
{
|
||||
sourceRc.left = 0;
|
||||
sourceRc.top = xfbSource->texHeight;
|
||||
sourceRc.right = xfbSource->texWidth;
|
||||
sourceRc.bottom = 0;
|
||||
}
|
||||
sourceRc = xfbSource->sourceRc;
|
||||
|
||||
MathUtil::Rectangle<float> drawRc;
|
||||
|
||||
if (g_ActiveConfig.bUseXFB && !g_ActiveConfig.bUseRealXFB)
|
||||
if (!g_ActiveConfig.bUseRealXFB)
|
||||
{
|
||||
// use virtual xfb with offset
|
||||
int xfbHeight = xfbSource->srcHeight;
|
||||
@ -1120,17 +1143,14 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
||||
drawRc.left = -(xfbWidth / (float)fbWidth);
|
||||
drawRc.right = (xfbWidth / (float)fbWidth);
|
||||
|
||||
if (!g_ActiveConfig.bAutoScale)
|
||||
{
|
||||
// scale draw area for a 1 to 1 pixel mapping with the draw target
|
||||
float vScale = (float)fbHeight / (float)back_rc.GetHeight();
|
||||
float hScale = (float)fbWidth / (float)back_rc.GetWidth();
|
||||
|
||||
drawRc.top *= vScale;
|
||||
drawRc.bottom *= vScale;
|
||||
drawRc.left *= hScale;
|
||||
drawRc.right *= hScale;
|
||||
}
|
||||
// The following code disables auto stretch. Kept for reference.
|
||||
// scale draw area for a 1 to 1 pixel mapping with the draw target
|
||||
//float vScale = (float)fbHeight / (float)dst_rect.GetHeight();
|
||||
//float hScale = (float)fbWidth / (float)dst_rect.GetWidth();
|
||||
//drawRc.top *= vScale;
|
||||
//drawRc.bottom *= vScale;
|
||||
//drawRc.left *= hScale;
|
||||
//drawRc.right *= hScale;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1192,7 +1212,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
||||
}
|
||||
else
|
||||
{
|
||||
TargetRectangle targetRc = Renderer::ConvertEFBRectangle(rc);
|
||||
TargetRectangle targetRc = ConvertEFBRectangle(rc);
|
||||
GLuint read_texture = g_framebufferManager.ResolveAndGetRenderTarget(rc);
|
||||
// Render to the real buffer now.
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); // switch to the window backbuffer
|
||||
@ -1234,12 +1254,11 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
||||
glVertex2f( 1, -1);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0);
|
||||
TextureCache::DisableStage(0);
|
||||
if(g_ActiveConfig.bAnaglyphStereo)
|
||||
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
|
||||
// Wireframe
|
||||
if (g_ActiveConfig.bWireFrame)
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||
@ -1249,7 +1268,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
||||
{
|
||||
s_criticalScreenshot.Enter();
|
||||
// Save screenshot
|
||||
SaveRenderTarget(s_sScreenshotName.c_str(), back_rc);
|
||||
SaveRenderTarget(s_sScreenshotName.c_str(), dst_rect);
|
||||
// Reset settings
|
||||
s_sScreenshotName = "";
|
||||
s_bScreenshot = false;
|
||||
@ -1261,11 +1280,11 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
||||
if (g_ActiveConfig.bDumpFrames)
|
||||
{
|
||||
s_criticalScreenshot.Enter();
|
||||
int w = back_rc.GetWidth();
|
||||
int h = back_rc.GetHeight();
|
||||
int w = dst_rect.GetWidth();
|
||||
int h = dst_rect.GetHeight();
|
||||
u8 *data = (u8 *) malloc(3 * w * h);
|
||||
glPixelStorei(GL_PACK_ALIGNMENT, 1);
|
||||
glReadPixels(back_rc.left, back_rc.bottom, w, h, GL_BGR, GL_UNSIGNED_BYTE, data);
|
||||
glReadPixels(dst_rect.left, dst_rect.bottom, w, h, GL_BGR, GL_UNSIGNED_BYTE, data);
|
||||
if (GL_REPORT_ERROR() == GL_NO_ERROR && w > 0 && h > 0)
|
||||
{
|
||||
if (!s_bLastFrameDumped)
|
||||
@ -1306,11 +1325,11 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
||||
{
|
||||
s_criticalScreenshot.Enter();
|
||||
char movie_file_name[255];
|
||||
int w = back_rc.GetWidth();
|
||||
int h = back_rc.GetHeight();
|
||||
int w = dst_rect.GetWidth();
|
||||
int h = dst_rect.GetHeight();
|
||||
u8 *data = (u8 *) malloc(3 * w * h);
|
||||
glPixelStorei(GL_PACK_ALIGNMENT, 1);
|
||||
glReadPixels(back_rc.left, back_rc.bottom, w, h, GL_BGR, GL_UNSIGNED_BYTE, data);
|
||||
glReadPixels(dst_rect.left, dst_rect.bottom, w, h, GL_BGR, GL_UNSIGNED_BYTE, data);
|
||||
if (GL_REPORT_ERROR() == GL_NO_ERROR)
|
||||
{
|
||||
if (!s_bLastFrameDumped)
|
||||
@ -1348,6 +1367,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
||||
s_bLastFrameDumped = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Finish up the current frame, print some stats
|
||||
OpenGL_Update(); // just updates the render window position and the backbuffer size
|
||||
bool xfbchanged = false;
|
||||
@ -1364,38 +1384,47 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
||||
}
|
||||
|
||||
bool WindowResized = false;
|
||||
int W = (int)OpenGL_GetBackbufferWidth(), H = (int)OpenGL_GetBackbufferHeight();
|
||||
if (W != s_backbuffer_width || H != s_backbuffer_height)
|
||||
int W = (int)OpenGL_GetBackbufferWidth();
|
||||
int H = (int)OpenGL_GetBackbufferHeight();
|
||||
if (W != s_backbuffer_width || H != s_backbuffer_height || s_LastEFBScale != g_ActiveConfig.iEFBScale)
|
||||
{
|
||||
WindowResized = true;
|
||||
s_backbuffer_width = W;
|
||||
s_backbuffer_height = H;
|
||||
s_LastEFBScale = g_ActiveConfig.iEFBScale;
|
||||
}
|
||||
|
||||
if( xfbchanged || WindowResized)
|
||||
if (xfbchanged || WindowResized)
|
||||
{
|
||||
TargetRectangle dst_rect;
|
||||
ComputeDrawRectangle(s_backbuffer_width, s_backbuffer_height, false, &dst_rect);
|
||||
|
||||
xScale = 1.0f;
|
||||
yScale = 1.0f;
|
||||
|
||||
if(!g_ActiveConfig.bNativeResolution)
|
||||
if(g_ActiveConfig.bUseRealXFB)
|
||||
{
|
||||
if (g_ActiveConfig.b2xResolution)
|
||||
{
|
||||
xScale = 2.0f;
|
||||
yScale = 2.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
xScale = (float)(dst_rect.right - dst_rect.left) / (float)s_XFB_width;
|
||||
yScale = (float)(dst_rect.bottom - dst_rect.top) / (float)s_XFB_height;
|
||||
}
|
||||
xScale = 1.0f;
|
||||
yScale = 1.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
xScale = (float)(dst_rect.right - dst_rect.left) / (float)s_XFB_width;
|
||||
yScale = (float)(dst_rect.bottom - dst_rect.top) / (float)s_XFB_height;
|
||||
}
|
||||
|
||||
EFBxScale = ceilf(xScale);
|
||||
EFByScale = ceilf(yScale);
|
||||
switch(s_LastEFBScale)
|
||||
{
|
||||
case 0:
|
||||
EFBxScale = xScale;
|
||||
EFByScale = yScale;
|
||||
break;
|
||||
case 1:
|
||||
EFBxScale = ceilf(xScale);
|
||||
EFByScale = ceilf(yScale);
|
||||
break;
|
||||
default:
|
||||
EFBxScale = g_ActiveConfig.iEFBScale - 1;
|
||||
EFByScale = EFBxScale;
|
||||
break;
|
||||
};
|
||||
|
||||
int m_newFrameBufferWidth = EFB_WIDTH * EFBxScale;
|
||||
int m_newFrameBufferHeight = EFB_HEIGHT * EFByScale;
|
||||
@ -1405,6 +1434,9 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
||||
s_target_width = m_newFrameBufferWidth;
|
||||
s_target_height = m_newFrameBufferHeight;
|
||||
|
||||
s_Fulltarget_width = s_target_width;
|
||||
s_Fulltarget_height = s_target_height;
|
||||
|
||||
g_framebufferManager.Shutdown();
|
||||
g_framebufferManager.Init(s_target_width, s_target_height,
|
||||
s_MSAASamples, s_MSAACoverageSamples);
|
||||
@ -1617,23 +1649,6 @@ void Renderer::SetScreenshot(const char *filename)
|
||||
s_criticalScreenshot.Leave();
|
||||
}
|
||||
|
||||
// For the OSD menu's live resolution change
|
||||
bool Renderer::Allow2x()
|
||||
{
|
||||
if (GetFrameBufferWidth() >= 1280 && GetFrameBufferHeight() >= 960)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Renderer::AllowCustom()
|
||||
{
|
||||
if (GetCustomWidth() <= GetFrameBufferWidth() && GetCustomHeight() <= GetFrameBufferHeight())
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
void Renderer::FlipImageData(u8 *data, int w, int h)
|
||||
{
|
||||
// Flip image upside down. Damn OpenGL.
|
||||
|
@ -500,7 +500,7 @@ TextureCache::TCacheEntry* TextureCache::Load(int texstage, u32 address, int wid
|
||||
}
|
||||
else
|
||||
{
|
||||
if(skip_texture_create)
|
||||
if (skip_texture_create)
|
||||
{
|
||||
glCompressedTexSubImage2D(target, 0,0,0,width, height,
|
||||
GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,expandedWidth*expandedHeight/2, temp);
|
||||
|
@ -309,7 +309,7 @@ void EncodeToRam(u32 address, bool bFromZBuffer, bool bIsIntensityFmt, u32 copyf
|
||||
Renderer::ResetAPIState();
|
||||
EncodeToRamUsingShader(texconv_shader, source_texture, scaledSource, dest_ptr, expandedWidth / samples, expandedHeight, readStride, true, bScaleByHalf > 0);
|
||||
g_framebufferManager.SetFramebuffer(0);
|
||||
VertexShaderManager::SetViewportChanged();
|
||||
VertexShaderManager::SetViewportChanged();
|
||||
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0);
|
||||
TextureCache::DisableStage(0);
|
||||
Renderer::RestoreAPIState();
|
||||
@ -371,10 +371,9 @@ u64 EncodeToRamFromTexture(u32 address,GLuint source_texture,float MValueX,float
|
||||
cacheBytes = 64;
|
||||
|
||||
int readStride = (expandedWidth * cacheBytes) / TexDecoder_GetBlockWidthInTexels(format);
|
||||
|
||||
EncodeToRamUsingShader(texconv_shader, source_texture, scaledSource, dest_ptr, expandedWidth / samples, expandedHeight, readStride, true, bScaleByHalf > 0 && !bFromZBuffer);
|
||||
TextureCache::MakeRangeDynamic(address,size_in_bytes);
|
||||
return GetHash64(dest_ptr,size_in_bytes,g_ActiveConfig.iSafeTextureCache_ColorSamples);
|
||||
return GetHash64(dest_ptr,size_in_bytes,g_ActiveConfig.iSafeTextureCache_ColorSamples);
|
||||
}
|
||||
|
||||
void EncodeToRamYUYV(GLuint srcTexture, const TargetRectangle& sourceRc, u8* destAddr, int dstWidth, int dstHeight)
|
||||
@ -400,10 +399,10 @@ void DecodeToTexture(u32 xfbAddr, int srcWidth, int srcHeight, GLuint destTextur
|
||||
return;
|
||||
}
|
||||
|
||||
Renderer::ResetAPIState();
|
||||
|
||||
int srcFmtWidth = srcWidth / 2;
|
||||
|
||||
Renderer::ResetAPIState(); // reset any game specific settings
|
||||
|
||||
// swich to texture converter frame buffer
|
||||
// attach destTexture as color destination
|
||||
g_framebufferManager.SetFramebuffer(s_texConvFrameBuffer);
|
||||
|
@ -86,7 +86,7 @@ bool Init()
|
||||
g_nativeVertexFmt = NULL;
|
||||
Flushed=false;
|
||||
GL_REPORT_ERRORD();
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -181,17 +181,17 @@ void AddVertices(int primitive, int numVertices)
|
||||
|
||||
inline void Draw()
|
||||
{
|
||||
if(IndexGenerator::GetNumTriangles() > 0)
|
||||
if (IndexGenerator::GetNumTriangles() > 0)
|
||||
{
|
||||
glDrawElements(GL_TRIANGLES, IndexGenerator::GetTriangleindexLen(), GL_UNSIGNED_SHORT, TIBuffer);
|
||||
INCSTAT(stats.thisFrame.numIndexedDrawCalls);
|
||||
}
|
||||
if(IndexGenerator::GetNumLines() > 0)
|
||||
if (IndexGenerator::GetNumLines() > 0)
|
||||
{
|
||||
glDrawElements(GL_LINES, IndexGenerator::GetLineindexLen(), GL_UNSIGNED_SHORT, LIBuffer);
|
||||
INCSTAT(stats.thisFrame.numIndexedDrawCalls);
|
||||
}
|
||||
if(IndexGenerator::GetNumPoints() > 0)
|
||||
if (IndexGenerator::GetNumPoints() > 0)
|
||||
{
|
||||
glDrawElements(GL_POINTS, IndexGenerator::GetPointindexLen(), GL_UNSIGNED_SHORT, PIBuffer);
|
||||
INCSTAT(stats.thisFrame.numIndexedDrawCalls);
|
||||
@ -288,26 +288,23 @@ void Flush()
|
||||
}
|
||||
}
|
||||
|
||||
FRAGMENTSHADER* ps = PixelShaderCache::SetShader(false,g_nativeVertexFmt->m_components);
|
||||
VERTEXSHADER* vs = VertexShaderCache::SetShader(g_nativeVertexFmt->m_components);
|
||||
|
||||
// set global constants
|
||||
VertexShaderManager::SetConstants();
|
||||
PixelShaderManager::SetConstants();
|
||||
|
||||
// finally bind
|
||||
|
||||
if (vs) VertexShaderCache::SetCurrentShader(vs->glprogid);
|
||||
FRAGMENTSHADER* ps = PixelShaderCache::SetShader(false,g_nativeVertexFmt->m_components);
|
||||
VERTEXSHADER* vs = VertexShaderCache::SetShader(g_nativeVertexFmt->m_components);
|
||||
if (ps) PixelShaderCache::SetCurrentShader(ps->glprogid); // Lego Star Wars crashes here.
|
||||
if (vs) VertexShaderCache::SetCurrentShader(vs->glprogid);
|
||||
|
||||
Draw();
|
||||
|
||||
|
||||
// run through vertex groups again to set alpha
|
||||
if (!g_ActiveConfig.bDstAlphaPass && bpmem.dstalpha.enable && bpmem.blendmode.alphaupdate)
|
||||
if (bpmem.dstalpha.enable && bpmem.blendmode.alphaupdate)
|
||||
{
|
||||
ps = PixelShaderCache::SetShader(true,g_nativeVertexFmt->m_components);
|
||||
|
||||
if (ps)PixelShaderCache::SetCurrentShader(ps->glprogid);
|
||||
if (ps) PixelShaderCache::SetCurrentShader(ps->glprogid);
|
||||
|
||||
// only update alpha
|
||||
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE);
|
||||
@ -353,6 +350,5 @@ void Flush()
|
||||
g_Config.iSaveTargetId++;
|
||||
|
||||
GL_REPORT_ERRORD();
|
||||
|
||||
}
|
||||
} // namespace
|
||||
|
@ -50,9 +50,9 @@ Make AA apply instantly during gameplay if possible
|
||||
*/
|
||||
|
||||
#include "Globals.h"
|
||||
#include "LogManager.h"
|
||||
#include "Thread.h"
|
||||
#include "Atomic.h"
|
||||
#include "Thread.h"
|
||||
#include "LogManager.h"
|
||||
|
||||
#include <cstdarg>
|
||||
|
||||
@ -124,7 +124,15 @@ bool IsD3D()
|
||||
return false;
|
||||
}
|
||||
|
||||
void GetDllInfo (PLUGIN_INFO* _PluginInfo)
|
||||
// This is used for the functions right below here which use wxwidgets
|
||||
#if defined(HAVE_WX) && HAVE_WX
|
||||
#ifdef _WIN32
|
||||
WXDLLIMPEXP_BASE void wxSetInstance(HINSTANCE hInst);
|
||||
extern HINSTANCE g_hInstance;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
void GetDllInfo(PLUGIN_INFO* _PluginInfo)
|
||||
{
|
||||
_PluginInfo->Version = 0x0100;
|
||||
_PluginInfo->Type = PLUGIN_TYPE_VIDEO;
|
||||
@ -143,14 +151,6 @@ void SetDllGlobals(PLUGIN_GLOBALS* _pPluginGlobals)
|
||||
LogManager::SetInstance((LogManager*)globals->logManager);
|
||||
}
|
||||
|
||||
// This is used for the functions right below here which use wxwidgets
|
||||
#if defined(HAVE_WX) && HAVE_WX
|
||||
#ifdef _WIN32
|
||||
WXDLLIMPEXP_BASE void wxSetInstance(HINSTANCE hInst);
|
||||
extern HINSTANCE g_hInstance;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
void *DllDebugger(void *_hParent, bool Show)
|
||||
{
|
||||
#if defined(HAVE_WX) && HAVE_WX
|
||||
@ -205,6 +205,68 @@ void Initialize(void *init)
|
||||
s_PluginInitialized = true;
|
||||
}
|
||||
|
||||
// This is called after Initialize() from the Core
|
||||
// Run from the graphics thread
|
||||
void Video_Prepare()
|
||||
{
|
||||
OpenGL_MakeCurrent();
|
||||
|
||||
s_efbAccessRequested = FALSE;
|
||||
s_FifoShuttingDown = FALSE;
|
||||
s_swapRequested = FALSE;
|
||||
|
||||
// internal interfaces
|
||||
Renderer::Init();
|
||||
TextureCache::Init();
|
||||
VertexManager::Init();
|
||||
BPInit();
|
||||
Fifo_Init();
|
||||
VertexLoaderManager::Init();
|
||||
OpcodeDecoder_Init();
|
||||
VertexShaderCache::Init();
|
||||
VertexShaderManager::Init();
|
||||
PixelShaderCache::Init();
|
||||
PixelShaderManager::Init();
|
||||
CommandProcessor::Init();
|
||||
PixelEngine::Init();
|
||||
PostProcessing::Init();
|
||||
TextureConverter::Init();
|
||||
DLCache::Init();
|
||||
|
||||
// Notify the core that the video plugin is ready
|
||||
g_VideoInitialize.pCoreMessage(WM_USER_CREATE);
|
||||
|
||||
s_PluginInitialized = true;
|
||||
INFO_LOG(VIDEO, "Video plugin initialized.");
|
||||
}
|
||||
|
||||
void Shutdown()
|
||||
{
|
||||
s_PluginInitialized = false;
|
||||
|
||||
s_efbAccessRequested = FALSE;
|
||||
s_FifoShuttingDown = FALSE;
|
||||
s_swapRequested = FALSE;
|
||||
|
||||
// VideoCommon
|
||||
DLCache::Shutdown();
|
||||
Fifo_Shutdown();
|
||||
PostProcessing::Shutdown();
|
||||
CommandProcessor::Shutdown();
|
||||
PixelShaderManager::Shutdown();
|
||||
VertexShaderManager::Shutdown();
|
||||
OpcodeDecoder_Shutdown();
|
||||
VertexLoaderManager::Shutdown();
|
||||
PixelShaderCache::Shutdown();
|
||||
TextureConverter::Shutdown();
|
||||
VertexShaderCache::Shutdown();
|
||||
VertexManager::Shutdown();
|
||||
TextureCache::Shutdown();
|
||||
Renderer::Shutdown();
|
||||
OpenGL_Shutdown();
|
||||
EmuWindow::Close();
|
||||
}
|
||||
|
||||
static volatile struct
|
||||
{
|
||||
unsigned char **ptr;
|
||||
@ -260,73 +322,6 @@ void EmuStateChange(PLUGIN_EMUSTATE newState)
|
||||
Fifo_RunLoop((newState == PLUGIN_EMUSTATE_PLAY) ? true : false);
|
||||
}
|
||||
|
||||
// This is called after Initialize() from the Core
|
||||
// Run from the graphics thread
|
||||
void Video_Prepare(void)
|
||||
{
|
||||
OpenGL_MakeCurrent();
|
||||
if (!Renderer::Init()) {
|
||||
g_VideoInitialize.pLog("Renderer::Create failed\n", TRUE);
|
||||
PanicAlert("Can't create opengl renderer. You might be missing some required opengl extensions, check the logs for more info");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
s_efbAccessRequested = FALSE;
|
||||
s_FifoShuttingDown = FALSE;
|
||||
s_swapRequested = FALSE;
|
||||
|
||||
CommandProcessor::Init();
|
||||
PixelEngine::Init();
|
||||
|
||||
TextureCache::Init();
|
||||
|
||||
BPInit();
|
||||
VertexManager::Init();
|
||||
Fifo_Init(); // must be done before OpcodeDecoder_Init()
|
||||
OpcodeDecoder_Init();
|
||||
VertexShaderCache::Init();
|
||||
VertexShaderManager::Init();
|
||||
PixelShaderCache::Init();
|
||||
PixelShaderManager::Init();
|
||||
PostProcessing::Init();
|
||||
GL_REPORT_ERRORD();
|
||||
VertexLoaderManager::Init();
|
||||
TextureConverter::Init();
|
||||
DLCache::Init();
|
||||
|
||||
// Notify the core that the video plugin is ready
|
||||
g_VideoInitialize.pCoreMessage(WM_USER_CREATE);
|
||||
|
||||
s_PluginInitialized = true;
|
||||
INFO_LOG(VIDEO, "Video plugin initialized.");
|
||||
}
|
||||
|
||||
void Shutdown()
|
||||
{
|
||||
s_PluginInitialized = false;
|
||||
|
||||
s_efbAccessRequested = FALSE;
|
||||
s_FifoShuttingDown = FALSE;
|
||||
s_swapRequested = FALSE;
|
||||
DLCache::Shutdown();
|
||||
Fifo_Shutdown();
|
||||
PostProcessing::Shutdown();
|
||||
|
||||
// The following calls are NOT Thread Safe
|
||||
// And need to be called from the video thread
|
||||
TextureConverter::Shutdown();
|
||||
VertexLoaderManager::Shutdown();
|
||||
VertexShaderCache::Shutdown();
|
||||
VertexShaderManager::Shutdown();
|
||||
PixelShaderManager::Shutdown();
|
||||
PixelShaderCache::Shutdown();
|
||||
VertexManager::Shutdown();
|
||||
TextureCache::Shutdown();
|
||||
OpcodeDecoder_Shutdown();
|
||||
Renderer::Shutdown();
|
||||
OpenGL_Shutdown();
|
||||
}
|
||||
|
||||
// Enter and exit the video loop
|
||||
void Video_EnterLoop()
|
||||
{
|
||||
|
Reference in New Issue
Block a user