OGL plugin: +Autoscale option (attempts to remove borders, even without XFB). Lots of cleanup, especially around aspect ratio and similar stuff. MP2 scanner still broken, wonder when that happened?

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2470 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
hrydgard
2009-02-28 16:33:59 +00:00
parent 11fd8062ad
commit 6dc4194767
22 changed files with 460 additions and 729 deletions
+6
View File
@@ -118,4 +118,10 @@ namespace
#define GC_ALIGNED64_DECL(x) __attribute((aligned(64))) x
#endif // WIN32
// A macro to disallow the copy constructor and operator= functions
// This should be used in the private: declarations for a class
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
TypeName(const TypeName&); \
void operator=(const TypeName&)
#endif // COMMON_H
@@ -89,9 +89,6 @@ struct PortableVertexDeclaration
// all the data loading code must always be made compatible.
class NativeVertexFormat
{
protected:
NativeVertexFormat() {}
public:
virtual ~NativeVertexFormat() {}
@@ -103,6 +100,13 @@ public:
// TODO: move these in under private:
u32 m_components; // VB_HAS_X. Bitmask telling what vertex components are present.
protected:
// Let subclasses construct.
NativeVertexFormat() {}
private:
DISALLOW_COPY_AND_ASSIGN(NativeVertexFormat);
};
#endif // _NATIVEVERTEXFORMAT_H
@@ -23,6 +23,8 @@
#include <string>
#include "Common.h"
#include "CPMemory.h"
#include "DataReader.h"
#include "NativeVertexFormat.h"
@@ -103,6 +105,8 @@ private:
void WriteGetVariable(int bits, Gen::OpArg dest, void *address);
void WriteSetVariable(int bits, void *address, Gen::OpArg dest);
DISALLOW_COPY_AND_ASSIGN(VertexLoader);
};
#endif
@@ -37,7 +37,6 @@
#include "XFB.h"
#include "main.h"
// ---------------------------------------------------------------------------------------
// State translation lookup tables
// -------------
@@ -383,8 +382,8 @@ void BPWritten(int addr, int changes, int newval)
(int)((bpmem.copyTexSrcXY.x + bpmem.copyTexSrcWH.x + 1)),
(int)((bpmem.copyTexSrcXY.y + bpmem.copyTexSrcWH.y + 1))
};
float MValueX = OpenGL_GetXmax();
float MValueY = OpenGL_GetYmax();
float MValueX = Renderer::GetTargetScaleX();
float MValueY = Renderer::GetTargetScaleY();
// Need another rc here to get it to scale.
// Here the bottom right is the out of the rectangle.
TRectangle multirc = {
@@ -407,9 +406,9 @@ void BPWritten(int addr, int changes, int newval)
if (g_Config.bEFBCopyDisable)
{
/* We already have this in Render.cpp that we call when (PE_copy.clear) is true. But we need a separate one
here because UpdateViewport() is not run when this otion is set? */
glViewport(rc.left,rc.bottom, rc.right,rc.top);
glScissor(rc.left,rc.bottom, rc.right,rc.top);
here because UpdateViewport() is not run when this option is set? */
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;
@@ -560,7 +559,7 @@ void BPWritten(int addr, int changes, int newval)
break;
default:
switch(addr & 0xFC) //texture sampler filter
switch (addr & 0xFC) //texture sampler filter
{
case 0x28: // tevorder 0-3
case 0x2C: // tevorder 4-7
@@ -571,7 +570,6 @@ void BPWritten(int addr, int changes, int newval)
PixelShaderManager::SetTevOrderChanged(addr - 0x28);
}
break;
case 0x80: // TEX MODE 0
case 0xA0:
if (changes)
+7 -11
View File
@@ -40,17 +40,15 @@ void Config::Load()
iniFile.Get("Hardware", "FullscreenRes", &temp, "640x480");
strncpy(iFSResolution, temp.c_str(), 16);
iniFile.Get("Settings", "Backend", &temp, "");
strncpy(iBackend, temp.c_str(), 16);
iniFile.Get("Hardware", "Fullscreen", &bFullscreen, 0); // Hardware
iniFile.Get("Hardware", "RenderToMainframe", &renderToMainframe, false);
iniFile.Get("Settings", "StretchToFit", &bStretchToFit, true);
iniFile.Get("Settings", "StretchToFit", &bNativeResolution, true);
iniFile.Get("Settings", "KeepAR_4_3", &bKeepAR43, false);
iniFile.Get("Settings", "KeepAR_16_9", &bKeepAR169, false);
iniFile.Get("Settings", "Crop", &bCrop, false);
iniFile.Get("Settings", "HideCursor", &bHideCursor, false);
iniFile.Get("Settings", "UseXFB", &bUseXFB, 0);
iniFile.Get("Settings", "AutoScale", &bAutoScale, true);
iniFile.Get("Settings", "SafeTextureCache", &bSafeTextureCache, false); // Settings
iniFile.Get("Settings", "ShowFPS", &bShowFPS, false); // Settings
@@ -69,12 +67,11 @@ void Config::Load()
strcpy(texDumpPath, s.c_str());
else {
strncpy(texDumpPath, s.c_str(), sizeof(texDumpPath)-1);
texDumpPath[sizeof(texDumpPath)-1] = 0;
texDumpPath[sizeof(texDumpPath) - 1] = 0;
}
iniFile.Get("Settings", "TexFmtOverlayEnable", &bTexFmtOverlayEnable, 0);
iniFile.Get("Settings", "TexFmtOverlayCenter", &bTexFmtOverlayCenter, 0);
iniFile.Get("Settings", "UseXFB", &bUseXFB, 0);
iniFile.Get("Settings", "WireFrame", &bWireFrame, 0);
iniFile.Get("Settings", "DisableLighting", &bDisableLighting, 0);
iniFile.Get("Settings", "DisableTexturing", &bDisableTexturing, 0);
@@ -97,13 +94,13 @@ void Config::Save()
iniFile.Set("Hardware", "FullscreenRes", iFSResolution);
iniFile.Set("Hardware", "Fullscreen", bFullscreen);
iniFile.Set("Hardware", "RenderToMainframe", renderToMainframe);
iniFile.Set("Settings", "StretchToFit", bStretchToFit);
iniFile.Set("Settings", "StretchToFit", bNativeResolution);
iniFile.Set("Settings", "KeepAR_4_3", bKeepAR43);
iniFile.Set("Settings", "KeepAR_16_9", bKeepAR169);
iniFile.Set("Settings", "Crop", bCrop);
iniFile.Set("Settings", "HideCursor", bHideCursor);
iniFile.Set("Settings", "Backend", iBackend);
iniFile.Set("Settings", "UseXFB", bUseXFB);
iniFile.Set("Settings", "AutoScale", bAutoScale);
iniFile.Set("Settings", "SafeTextureCache", bSafeTextureCache);
iniFile.Set("Settings", "ShowFPS", bShowFPS);
@@ -117,7 +114,6 @@ void Config::Save()
iniFile.Set("Settings", "TexDumpPath", texDumpPath);
iniFile.Set("Settings", "TexFmtOverlayEnable", bTexFmtOverlayEnable);
iniFile.Set("Settings", "TexFmtOverlayCenter", bTexFmtOverlayCenter);
iniFile.Set("Settings", "UseXFB", bUseXFB);
iniFile.Set("Settings", "Wireframe", bWireFrame);
iniFile.Set("Settings", "DisableLighting", bDisableLighting);
iniFile.Set("Settings", "DisableTexturing", bDisableTexturing);
+17 -11
View File
@@ -18,6 +18,8 @@
#ifndef _CONFIG_H
#define _CONFIG_H
#include "Common.h"
// Log in two categories, and save three other options in the same byte
#define CONF_LOG 1
#define CONF_PRIMLOG 2
@@ -25,6 +27,7 @@
#define CONF_SAVETARGETS 8
#define CONF_SAVESHADERS 16
// NEVER inherit from this class.
struct Config
{
Config();
@@ -33,17 +36,17 @@ struct Config
// General
bool bFullscreen;
bool renderToMainframe;
char iFSResolution[16];
char iWindowedRes[16];
char iBackend[16];
// stretch to fit should be split into two options, I think - one for low resolution backbuffer,
// one for ignore aspect ratio. I guess KeepAR sort of does that. Anyway, these should be rethought.
bool bStretchToFit;
bool bKeepAR43, bKeepAR169, bCrop;
bool bHideCursor;
bool bSafeTextureCache;
bool renderToMainframe;
// Resolution control
char iFSResolution[16];
char iWindowedRes[16];
bool bNativeResolution; // Should possibly be augmented with 2x, 4x native.
bool bKeepAR43, bKeepAR169, bCrop; // Aspect ratio controls.
bool bUseXFB;
bool bAutoScale; // Removes annoying borders without using XFB. Doesn't always work perfectly.
// Enhancements
int iMultisampleMode;
@@ -59,7 +62,6 @@ struct Config
bool bTexFmtOverlayCenter;
// Render
bool bUseXFB;
bool bWireFrame;
bool bDisableLighting;
bool bDisableTexturing;
@@ -74,6 +76,7 @@ struct Config
bool bProjectionHax1;
bool bProjectionHax2;
bool bCopyEFBToRAM;
bool bSafeTextureCache;
int iLog; // CONF_ bits
int iSaveTargetId;
@@ -81,6 +84,9 @@ struct Config
//currently unused:
int iCompileDLsLevel;
bool bShowShaderErrors;
private:
DISALLOW_COPY_AND_ASSIGN(Config);
};
extern Config g_Config;
+37 -114
View File
@@ -37,18 +37,17 @@ struct RECT
// Handles OpenGL and the window
// externals
int nBackbufferWidth, nBackbufferHeight; // screen width
int nXoff, nYoff; // screen offset
float MValueX, MValueY;
// Window dimensions.
static int s_backbuffer_width;
static int s_backbuffer_height;
#ifndef _WIN32
GLWindow GLWin;
#endif
#if defined(_WIN32)
static HDC hDC = NULL; // Private GDI Device Context
static HGLRC hRC = NULL; // Permanent Rendering Context
static HDC hDC = NULL; // Private GDI Device Context
static HGLRC hRC = NULL; // Permanent Rendering Context
extern HINSTANCE g_hInstance;
#endif
@@ -67,36 +66,14 @@ void OpenGL_SwapBuffers()
#endif
}
float OpenGL_GetXmax() {
return MValueX;
u32 OpenGL_GetBackbufferWidth() {
return s_backbuffer_width;
}
float OpenGL_GetYmax() {
return MValueY;
u32 OpenGL_GetBackbufferHeight() {
return s_backbuffer_height;
}
int OpenGL_GetXoff() {
return nXoff;
}
int OpenGL_GetYoff() {
return nYoff;
}
u32 OpenGL_GetWidth() {
return nBackbufferWidth;
}
u32 OpenGL_GetHeight() {
return nBackbufferHeight;
}
void OpenGL_SetSize(u32 width, u32 height) {
nBackbufferWidth = width;
nBackbufferHeight = height;
}
void OpenGL_SetWindowText(const char *text)
{
#if USE_SDL
@@ -123,7 +100,7 @@ void OpenGL_SetWindowText(const char *text)
unsigned int Callback_PeekMessages()
{
#ifdef _WIN32
//TODO: peekmessage
// TODO: peekmessage
MSG msg;
while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
{
@@ -137,6 +114,7 @@ unsigned int Callback_PeekMessages()
return FALSE;
#endif
}
// Show the current FPS
void UpdateFPSDisplay(const char *text)
{
@@ -187,40 +165,17 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight
#endif
// ----------------------------
// ---------------------------------------------------------------------------------------
// Control window size and picture scaling
// ------------------
// nBackbufferWidth and nBackbufferHeight = Screen resolution from ini, or 640x480
// See OpenGL_Update() for documentation of the other variables
// ------------------
nBackbufferWidth = _twidth;
nBackbufferHeight = _theight;
float FactorW = 640.0f / (float)nBackbufferWidth;
float FactorH = 480.0f / (float)nBackbufferHeight;
float Max = (FactorW < FactorH) ? FactorH : FactorW;
if (g_Config.bStretchToFit)
{
MValueX = 1.0f / FactorW;
MValueY = 1.0f / FactorH;
nXoff = 0;
nYoff = 0;
}
else
{
MValueX = 1.0f / Max;
MValueY = 1.0f / Max;
nXoff = (int)((nBackbufferWidth - (640 * MValueX)) / 2);
nYoff = (int)((nBackbufferHeight - (480 * MValueY)) / 2);
}
s_backbuffer_width = _twidth;
s_backbuffer_height = _theight;
g_VideoInitialize.pPeekMessages = &Callback_PeekMessages;
g_VideoInitialize.pUpdateFPSDisplay = &UpdateFPSDisplay;
//char buff[100];
//sprintf(buff, "%i %i %d %d %d", nBackbufferWidth, nBackbufferHeight, Max, MValueX, MValueY);
//sprintf(buff, "%i %i %d %d %d", s_backbuffer_width, s_backbuffer_height, Max, MValueX, MValueY);
//MessageBox(0, buff, "", 0);
#if USE_SDL
@@ -234,8 +189,8 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight
//setup ogl to use double buffering
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
#elif defined(HAVE_COCOA) && HAVE_COCOA
GLWin.width = nBackbufferWidth;
GLWin.height = nBackbufferHeight;
GLWin.width = s_backbuffer_width;
GLWin.height = s_backbuffer_height;
GLWin.cocoaWin = cocoaGLCreateWindow(GLWin.width, GLWin.height);
GLWin.cocoaCtx = cocoaGLInit(g_Config.iMultisampleMode);
#elif defined(USE_WX) && USE_WX
@@ -290,14 +245,14 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight
GetWindowRect(GetDesktopWindow(), &rcdesktop);
if (g_Config.bFullscreen) {
//nBackbufferWidth = rcdesktop.right - rcdesktop.left;
//nBackbufferHeight = rcdesktop.bottom - rcdesktop.top;
//s_backbuffer_width = rcdesktop.right - rcdesktop.left;
//s_backbuffer_height = rcdesktop.bottom - rcdesktop.top;
DEVMODE dmScreenSettings;
memset(&dmScreenSettings,0,sizeof(dmScreenSettings));
dmScreenSettings.dmSize=sizeof(dmScreenSettings);
dmScreenSettings.dmPelsWidth = nBackbufferWidth;
dmScreenSettings.dmPelsHeight = nBackbufferHeight;
dmScreenSettings.dmPelsWidth = s_backbuffer_width;
dmScreenSettings.dmPelsHeight = s_backbuffer_height;
dmScreenSettings.dmBitsPerPel = 32;
dmScreenSettings.dmFields = DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT;
@@ -329,7 +284,7 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight
RECT rc;
rc.left = 0; rc.top = 0;
rc.right = nBackbufferWidth; rc.bottom = nBackbufferHeight;
rc.right = s_backbuffer_width; rc.bottom = s_backbuffer_height;
AdjustWindowRectEx(&rc, dwStyle, FALSE, dwExStyle);
int X = (rcdesktop.right-rcdesktop.left)/2 - (rc.right-rc.left)/2;
int Y = (rcdesktop.bottom-rcdesktop.top)/2 - (rc.bottom-rc.top)/2;
@@ -540,8 +495,8 @@ bool OpenGL_MakeCurrent()
| ( g_Config.bFullscreen ? SDL_FULLSCREEN : 0);
// Set vide mode.
// TODO: Can we use this field or is a separate field needed?
int _twidth = nBackbufferWidth;
int _theight = nBackbufferHeight;
int _twidth = s_backbuffer_width;
int _theight = s_backbuffer_height;
SDL_Surface *screen = SDL_SetVideoMode(_twidth, _theight, 0, videoFlags);
if (!screen) {
//TODO : Display an error message
@@ -587,37 +542,36 @@ void OpenGL_Update()
{
#if USE_SDL
SDL_Surface *surface = SDL_GetVideoSurface();
RECT rcWindow;
if (!surface) return;
nBackbufferWidth = surface->w;
nBackbufferHeight = surface->h;
RECT rcWindow = {0};
if (!surface)
return;
s_backbuffer_width = surface->w;
s_backbuffer_height = surface->h;
rcWindow.right = surface->w;
rcWindow.bottom = surface->h;
#elif defined(HAVE_COCOA) && HAVE_COCOA
RECT rcWindow;
RECT rcWindow = {0};
rcWindow.right = GLWin.width;
rcWindow.bottom = GLWin.height;
#elif defined(USE_WX) && USE_WX
RECT rcWindow;
RECT rcWindow = {0};
rcWindow.right = GLWin.width;
rcWindow.bottom = GLWin.height;
// TODO fill in
#elif defined(_WIN32)
RECT rcWindow;
// If we are not rendering to a child window
if (!EmuWindow::GetParentWnd())
{
// return if we don't stretch the picture
if (!g_Config.bStretchToFit) return;
GetWindowRect(EmuWindow::GetWnd(), &rcWindow);
rcWindow.top += 25;
// We are not rendering to a child window - use client size.
GetClientRect(EmuWindow::GetWnd(), &rcWindow);
}
else
{
// We are rendering to a child window - use parent size.
GetWindowRect(EmuWindow::GetParentWnd(), &rcWindow);
}
@@ -633,8 +587,8 @@ void OpenGL_Update()
if (EmuWindow::GetParentWnd() != 0)
::MoveWindow(EmuWindow::GetWnd(), 0, 0, width, height, FALSE);
nBackbufferWidth = width;
nBackbufferHeight = height;
s_backbuffer_width = width;
s_backbuffer_height = height;
#elif defined(HAVE_X11) && HAVE_X11
// We just check all of our events here
@@ -684,8 +638,8 @@ void OpenGL_Update()
unsigned int borderDummy;
XGetGeometry(GLWin.dpy, GLWin.win, &winDummy, &GLWin.x, &GLWin.y,
&GLWin.width, &GLWin.height, &borderDummy, &GLWin.depth);
nBackbufferWidth = GLWin.width;
nBackbufferHeight = GLWin.height;
s_backbuffer_width = GLWin.width;
s_backbuffer_height = GLWin.height;
rcWindow.left = 0;
rcWindow.top = 0;
rcWindow.right = GLWin.width;
@@ -705,37 +659,6 @@ void OpenGL_Update()
}
return;
#endif
// ---------------------------------------------------------------------------------------
// Get the new window width and height
/* ------------------
nBackbufferWidth and nBackbufferHeight: Now the actual rendering window size
Max: The highest of w and h
nXoff and nYoff: Controls the picture's position inside the rendering window
MValueX and MValueY: Used for the picture resolution-change rescaling
// ------------------
MValueX and MValueY: Used for the picture resolution-change rescaling. It will be used in
TextureMngr and VertexShaderManager: Rescale textures on resolution changes
BPStructs.cpp: Control glScissor()
// ------------------ */
float FactorW = 640.0f / (float)nBackbufferWidth;
float FactorH = 480.0f / (float)nBackbufferHeight;
float Max = (FactorW < FactorH) ? FactorH : FactorW;
if (g_Config.bStretchToFit)
{
MValueX = 1;
MValueY = 1;
nXoff = 0;
nYoff = 0;
}
else
{
MValueX = 1.0f / Max;
MValueY = 1.0f / Max;
nXoff = (int)((nBackbufferWidth - (640 * MValueX)) / 2);
nYoff = (int)((nBackbufferHeight - (480 * MValueY)) / 2);
}
}
+2 -10
View File
@@ -119,16 +119,8 @@ extern GLWindow GLWin;
#endif
float OpenGL_GetXmax();
float OpenGL_GetYmax();
int OpenGL_GetXoff();
int OpenGL_GetYoff();
u32 OpenGL_GetWidth();
u32 OpenGL_GetHeight();
void OpenGL_SetSize(u32 width, u32 height);
// yeah yeah, these should be hidden
//extern int nBackbufferWidth, nBackbufferHeight;
//extern int nXoff, nYoff;
u32 OpenGL_GetBackbufferWidth();
u32 OpenGL_GetBackbufferHeight();
bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _width, int _height);
bool OpenGL_MakeCurrent();
@@ -30,11 +30,12 @@ BEGIN_EVENT_TABLE(ConfigDialog,wxDialog)
EVT_CHECKBOX(ID_RENDERTOMAINWINDOW, ConfigDialog::GeneralSettingsChanged)
EVT_COMBOBOX(ID_FULLSCREENCB, ConfigDialog::GeneralSettingsChanged)
EVT_COMBOBOX(ID_WINDOWRESOLUTIONCB, ConfigDialog::GeneralSettingsChanged)
EVT_COMBOBOX(ID_RENDERBACKEND, ConfigDialog::GeneralSettingsChanged)
EVT_COMBOBOX(ID_ALIASMODECB, ConfigDialog::GeneralSettingsChanged)
EVT_CHOICE(ID_MAXANISOTROPY, ConfigDialog::GeneralSettingsChanged)
EVT_CHECKBOX(ID_FORCEFILTERING, ConfigDialog::GeneralSettingsChanged)
EVT_CHECKBOX(ID_STRETCHTOFIT, ConfigDialog::GeneralSettingsChanged)
EVT_CHECKBOX(ID_NATIVERESOLUTION, ConfigDialog::GeneralSettingsChanged)
EVT_CHECKBOX(ID_USEXFB, ConfigDialog::GeneralSettingsChanged)
EVT_CHECKBOX(ID_AUTOSCALE, ConfigDialog::GeneralSettingsChanged)
EVT_CHECKBOX(ID_KEEPAR_4_3, ConfigDialog::GeneralSettingsChanged)
EVT_CHECKBOX(ID_KEEPAR_16_9, ConfigDialog::GeneralSettingsChanged)
EVT_CHECKBOX(ID_CROP, ConfigDialog::GeneralSettingsChanged)
@@ -49,7 +50,6 @@ BEGIN_EVENT_TABLE(ConfigDialog,wxDialog)
EVT_CHECKBOX(ID_SHADERERRORS, ConfigDialog::AdvancedSettingsChanged)
EVT_CHECKBOX(ID_TEXFMTOVERLAY, ConfigDialog::AdvancedSettingsChanged)
EVT_CHECKBOX(ID_TEXFMTCENTER, ConfigDialog::AdvancedSettingsChanged)
EVT_CHECKBOX(ID_USEXFB, ConfigDialog::AdvancedSettingsChanged)
EVT_CHECKBOX(ID_DUMPTEXTURES, ConfigDialog::AdvancedSettingsChanged)
EVT_CHECKBOX(ID_DISABLELIGHTING, ConfigDialog::AdvancedSettingsChanged)
EVT_CHECKBOX(ID_DISABLETEXTURING, ConfigDialog::AdvancedSettingsChanged)
@@ -120,11 +120,6 @@ void ConfigDialog::AddWindowReso(char *reso)
arrayStringFor_WindowResolutionCB.Add(wxString::FromAscii(reso));
}
void ConfigDialog::AddRenderBackend(const char *backend)
{
m_RenderBackend->Append(wxString::FromAscii(backend));
}
void ConfigDialog::AddAAMode(int mode)
{
wxString tmp;
@@ -168,16 +163,21 @@ void ConfigDialog::CreateGUIControls()
m_Fullscreen->SetValue(g_Config.bFullscreen);
m_RenderToMainWindow = new wxCheckBox(m_PageGeneral, ID_RENDERTOMAINWINDOW, wxT("Render to main window"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_RenderToMainWindow->SetValue(g_Config.renderToMainframe);
m_StretchToFit = new wxCheckBox(m_PageGeneral, ID_STRETCHTOFIT, wxT("Stretch to fit"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_NativeResolution = new wxCheckBox(m_PageGeneral, ID_NATIVERESOLUTION, wxT("Native resolution"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
// Aspect ratio / positioning controls
m_KeepAR43 = new wxCheckBox(m_PageGeneral, ID_KEEPAR_4_3, wxT("Keep 4:3 aspect ratio"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_KeepAR169 = new wxCheckBox(m_PageGeneral, ID_KEEPAR_16_9, wxT("Keep 16:9 aspect ratio"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_Crop = new wxCheckBox(m_PageGeneral, ID_CROP, wxT("Crop"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_UseXFB = new wxCheckBox(m_PageGeneral, ID_USEXFB, 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);
// Default values
m_StretchToFit->SetValue(g_Config.bStretchToFit);
m_NativeResolution->SetValue(g_Config.bNativeResolution);
m_KeepAR43->SetValue(g_Config.bKeepAR43);
m_KeepAR169->SetValue(g_Config.bKeepAR169);
m_Crop->SetValue(g_Config.bCrop);
m_UseXFB->SetValue(g_Config.bUseXFB);
m_AutoScale->SetValue(g_Config.bAutoScale);
#ifndef _WIN32
m_HideCursor = new wxCheckBox(m_PageGeneral, ID_HIDECURSOR, wxT("Hide mouse cursor"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
@@ -192,17 +192,13 @@ void ConfigDialog::CreateGUIControls()
m_WindowResolutionCB = new wxComboBox(m_PageGeneral, ID_WINDOWRESOLUTIONCB, arrayStringFor_WindowResolutionCB[0], wxDefaultPosition, wxDefaultSize, arrayStringFor_WindowResolutionCB, wxCB_READONLY, wxDefaultValidator);
m_WindowResolutionCB->SetValue(wxString::FromAscii(g_Config.iWindowedRes));
wxStaticText *BEText = new wxStaticText(m_PageGeneral, ID_BETEXT, wxT("Rendering backend:"), wxDefaultPosition, wxDefaultSize, 0);
m_RenderBackend = new wxComboBox(m_PageGeneral, ID_RENDERBACKEND, wxEmptyString, wxDefaultPosition, wxDefaultSize, arrayStringFor_RenderBackend, 0, wxDefaultValidator);
m_RenderBackend->SetValue(wxString::FromAscii(g_Config.iBackend));
// Tool tips
m_Fullscreen->SetToolTip(wxT(
"This option use a separate rendering window and can only be used when"
" 'Render to main window' is unchecked. The only way to exit this mode\n"
" is with Alt + F4 (that also close Dolphin)."
));
m_StretchToFit->SetToolTip(wxT(
m_NativeResolution->SetToolTip(wxT(
"This will use the game's native resolution and stretch it to fill the"
"\nwindow instead of changing the internal display resolution. It"
"\nmay result in a slightly blurrier image, but it may also give a higher"
@@ -242,12 +238,15 @@ void ConfigDialog::CreateGUIControls()
sBasic = new wxGridBagSizer(0, 0);
sBasic->Add(m_Fullscreen, wxGBPosition(0, 0), wxGBSpan(1, 3), wxALL, 5);
sBasic->Add(m_RenderToMainWindow, wxGBPosition(1, 0), wxGBSpan(1, 3), wxALL, 5);
sBasic->Add(m_StretchToFit, wxGBPosition(2, 0), wxGBSpan(1, 3), wxALL, 5);
sBasic->Add(m_KeepAR43, wxGBPosition(3, 0), wxGBSpan(1, 1), wxALL, 5);
sBasic->Add(m_KeepAR169, wxGBPosition(3, 1), wxGBSpan(1, 1), wxALL, 5);
sBasic->Add(m_Crop, wxGBPosition(3, 2), wxGBSpan(1, 1), wxALL, 5);
sBasic->Add(m_AutoScale, wxGBPosition(2, 0), wxGBSpan(1, 3), wxALL, 5);
sBasic->Add(m_NativeResolution, wxGBPosition(3, 0), wxGBSpan(1, 3), wxALL, 5);
sBasic->Add(m_UseXFB, wxGBPosition(4, 0), wxGBSpan(1, 3), wxALL, 5);
sBasic->Add(m_KeepAR43, wxGBPosition(5, 0), wxGBSpan(1, 1), wxALL, 5);
sBasic->Add(m_KeepAR169, wxGBPosition(5, 1), wxGBSpan(1, 1), wxALL, 5);
sBasic->Add(m_Crop, wxGBPosition(5, 2), wxGBSpan(1, 1), wxALL, 5);
// Because of the ifdef here we need this variable for the row number
int Row = 4;
int Row = 6;
#ifndef _WIN32
sBasic->Add(m_HideCursor, wxGBPosition(Row++, 0), wxGBSpan(1, 3), wxALL, 5);
#endif
@@ -255,8 +254,6 @@ void ConfigDialog::CreateGUIControls()
sBasic->Add(m_FullscreenCB, wxGBPosition(Row++, 1), wxGBSpan(1, 1), wxALL, 5);
sBasic->Add(WMText, wxGBPosition(Row, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL | wxALL, 5);
sBasic->Add(m_WindowResolutionCB, wxGBPosition(Row++, 1), wxGBSpan(1, 1), wxALL, 5);
sBasic->Add(BEText, wxGBPosition(Row, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL | wxALL, 5);
sBasic->Add(m_RenderBackend, wxGBPosition(Row++, 1), wxGBSpan(1, 1), wxALL, 5);
sbBasic->Add(sBasic);
sGeneral->Add(sbBasic, 0, wxEXPAND|wxALL, 5);
@@ -293,8 +290,6 @@ void ConfigDialog::CreateGUIControls()
// Render
sbRendering = new wxStaticBoxSizer(wxVERTICAL, m_PageAdvanced, wxT("Rendering"));
m_UseXFB = new wxCheckBox(m_PageAdvanced, ID_USEXFB, wxT("Use External Framebuffer (XFB)"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_UseXFB->SetValue(g_Config.bUseXFB);
m_Wireframe = new wxCheckBox(m_PageAdvanced, ID_WIREFRAME, wxT("Enable Wireframe"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_Wireframe->SetValue(g_Config.bWireFrame);
m_Wireframe->Enable(true);
@@ -378,10 +373,9 @@ void ConfigDialog::CreateGUIControls()
wxBoxSizer *sRenderBoxRow1 = new wxBoxSizer(wxHORIZONTAL);
sRendering = new wxGridBagSizer(0, 0);
sRendering->Add(m_UseXFB, wxGBPosition(0, 0), wxGBSpan(1, 1), wxALL, 5);
sRendering->Add(m_Wireframe, wxGBPosition(1, 0), wxGBSpan(1, 1), wxALL, 5);
sRendering->Add(m_DisableLighting, wxGBPosition(2, 0), wxGBSpan(1, 1), wxALL, 5);
sRendering->Add(m_DisableTexturing, wxGBPosition(3, 0), wxGBSpan(1, 1), wxALL, 5);
sRendering->Add(m_Wireframe, wxGBPosition(0, 0), wxGBSpan(1, 1), wxALL, 5);
sRendering->Add(m_DisableLighting, wxGBPosition(1, 0), wxGBSpan(1, 1), wxALL, 5);
sRendering->Add(m_DisableTexturing, wxGBPosition(2, 0), wxGBSpan(1, 1), wxALL, 5);
sRenderBoxRow1->Add(sRendering, 0, wxALL|wxEXPAND, 5);
wxStaticBoxSizer *sSBox = new wxStaticBoxSizer(m_StaticBox_EFB, wxVERTICAL);
wxBoxSizer *sStrip1 = new wxBoxSizer(wxHORIZONTAL);
@@ -431,8 +425,15 @@ void ConfigDialog::GeneralSettingsChanged(wxCommandEvent& event)
case ID_RENDERTOMAINWINDOW:
g_Config.renderToMainframe = m_RenderToMainWindow->IsChecked();
break;
case ID_STRETCHTOFIT:
g_Config.bStretchToFit = m_StretchToFit->IsChecked();
case ID_NATIVERESOLUTION:
g_Config.bNativeResolution = m_NativeResolution->IsChecked();
break;
case ID_USEXFB:
g_Config.bUseXFB = m_UseXFB->IsChecked();
break;
case ID_AUTOSCALE:
g_Config.bAutoScale = m_AutoScale->IsChecked();
break;
case ID_KEEPAR_4_3:
g_Config.bKeepAR43 = m_KeepAR43->IsChecked();
@@ -447,10 +448,11 @@ void ConfigDialog::GeneralSettingsChanged(wxCommandEvent& event)
case ID_CROP:
g_Config.bCrop = m_Crop->IsChecked();
break;
#ifndef _WIN32
case ID_HIDECURSOR:
g_Config.bHideCursor = m_HideCursor->IsChecked();
break;
case ID_HIDECURSOR:
g_Config.bHideCursor = m_HideCursor->IsChecked();
break;
#endif
case ID_FULLSCREENCB:
strcpy(g_Config.iFSResolution, m_FullscreenCB->GetValue().mb_str() );
@@ -458,9 +460,6 @@ void ConfigDialog::GeneralSettingsChanged(wxCommandEvent& event)
case ID_WINDOWRESOLUTIONCB:
strcpy(g_Config.iWindowedRes, m_WindowResolutionCB->GetValue().mb_str() );
break;
case ID_RENDERBACKEND:
strcpy(g_Config.iBackend, m_RenderBackend->GetValue().mb_str());
break;
case ID_FORCEFILTERING:
g_Config.bForceFiltering = m_ForceFiltering->IsChecked();
break;
@@ -498,9 +497,6 @@ void ConfigDialog::AdvancedSettingsChanged(wxCommandEvent& event)
g_Config.bTexFmtOverlayCenter = m_TexFmtCenter->IsChecked();
TextureMngr::Invalidate(false);
break;
case ID_USEXFB:
g_Config.bUseXFB = m_UseXFB->IsChecked();
break;
case ID_WIREFRAME:
g_Config.bWireFrame = m_Wireframe->IsChecked();
break;
@@ -532,12 +528,14 @@ void ConfigDialog::AdvancedSettingsChanged(wxCommandEvent& event)
case ID_SAFETEXTURECACHE:
g_Config.bSafeTextureCache = m_SafeTextureCache->IsChecked();
break;
// Extented frame buffer
// External frame buffer
case ID_RADIO_COPYEFBTORAM:
TextureMngr::ClearRenderTargets();
g_Config.bCopyEFBToRAM = true;
break;
case ID_RADIO_COPYEFBTOGL:
TextureMngr::ClearRenderTargets();
g_Config.bCopyEFBToRAM = false;
break;
case ID_BLENDSTATS:
@@ -563,11 +561,14 @@ void ConfigDialog::TexturePathChange(wxFileDirPickerEvent& event)
void ConfigDialog::UpdateGUI()
{
// This option is only compatible with the Strech To Fit option
m_KeepAR43->Enable(g_Config.bStretchToFit);
m_KeepAR169->Enable(g_Config.bStretchToFit);
// This is only used together with the aspect ratio options
m_Crop->Enable(g_Config.bStretchToFit && (g_Config.bKeepAR43 || g_Config.bKeepAR169));
m_Crop->Enable(g_Config.bKeepAR43 || g_Config.bKeepAR169);
if (g_Config.bUseXFB) {
// XFB looks much better if the copy comes from native resolution.
g_Config.bNativeResolution = true;
m_NativeResolution->SetValue(true);
}
m_AutoScale->Enable(!g_Config.bUseXFB);
// These options are for the separate rendering window
m_Fullscreen->Enable(!g_Config.renderToMainframe);
@@ -45,7 +45,6 @@ class ConfigDialog : public wxDialog
void AddFSReso(char *reso);
void AddWindowReso(char *reso);
void AddRenderBackend(const char *backend);
void AddAAMode(int mode);
void CreateGUIControls();
@@ -77,16 +76,16 @@ class ConfigDialog : public wxDialog
wxPanel *m_PageAdvanced;
wxCheckBox *m_Fullscreen;
wxCheckBox *m_RenderToMainWindow;
wxCheckBox *m_StretchToFit;
wxCheckBox *m_NativeResolution;
wxCheckBox *m_KeepAR43, *m_KeepAR169, *m_Crop;
wxCheckBox *m_UseXFB;
wxCheckBox *m_AutoScale;
#ifndef _WIN32
wxCheckBox *m_HideCursor;
#endif
wxComboBox *m_FullscreenCB;
wxArrayString arrayStringFor_WindowResolutionCB;
wxComboBox *m_WindowResolutionCB;
wxArrayString arrayStringFor_RenderBackend;
wxComboBox *m_RenderBackend;
wxCheckBox *m_ForceFiltering; // advanced
wxChoice *m_MaxAnisotropyCB;
@@ -99,7 +98,6 @@ class ConfigDialog : public wxDialog
wxCheckBox *m_ProjStats;
wxCheckBox *m_TexFmtOverlay;
wxCheckBox *m_TexFmtCenter;
wxCheckBox *m_UseXFB;
wxCheckBox *m_Wireframe;
wxCheckBox *m_DisableLighting;
wxCheckBox *m_DisableTexturing;
@@ -128,15 +126,16 @@ class ConfigDialog : public wxDialog
ID_FULLSCREEN,
ID_RENDERTOMAINWINDOW,
ID_STRETCHTOFIT,
ID_NATIVERESOLUTION,
ID_KEEPAR_4_3, ID_KEEPAR_16_9, ID_CROP,
ID_USEXFB,
ID_AUTOSCALE,
ID_HIDECURSOR,
ID_FSTEXT,
ID_FULLSCREENCB,
ID_WMTEXT,
ID_WINDOWRESOLUTIONCB,
ID_BETEXT,
ID_RENDERBACKEND,
ID_FORCEFILTERING,
ID_MAXANISOTROPY,
@@ -151,7 +150,6 @@ class ConfigDialog : public wxDialog
ID_TEXFMTOVERLAY,
ID_TEXFMTCENTER,
ID_USEXFB,
ID_WIREFRAME,
ID_DISABLELIGHTING,
ID_DISABLETEXTURING,
@@ -152,7 +152,7 @@ FRAGMENTSHADER* PixelShaderCache::GetShader()
return pShaderLast;
}
void PixelShaderCache::Cleanup()
void PixelShaderCache::ProgressiveCleanup()
{
PSCache::iterator iter = pshaders.begin();
while (iter != pshaders.end()) {
@@ -168,14 +168,14 @@ void PixelShaderCache::Cleanup()
else
iter++;
}
SETSTAT(stats.numPixelShadersAlive,(int)pshaders.size());
SETSTAT(stats.numPixelShadersAlive, (int)pshaders.size());
}
bool PixelShaderCache::CompilePixelShader(FRAGMENTSHADER& ps, const char* pstrprogram)
{
char stropt[64];
char stropt[128];
sprintf(stropt, "MaxLocalParams=32,NumInstructionSlots=%d", s_nMaxPixelInstructions);
const char* opts[] = {"-profileopts", stropt, "-O2", "-q", NULL};
const char *opts[] = {"-profileopts", stropt, "-O2", "-q", NULL};
CGprogram tempprog = cgCreateProgram(g_cgcontext, CG_SOURCE, pstrprogram, g_cgfProf, "main", opts);
if (!cgIsProgram(tempprog) || cgGetError() != CG_NO_ERROR) {
ERROR_LOG(VIDEO, "Failed to create ps %s:\n", cgGetLastListing(g_cgcontext));
@@ -183,18 +183,20 @@ bool PixelShaderCache::CompilePixelShader(FRAGMENTSHADER& ps, const char* pstrpr
return false;
}
// This looks evil - we modify the program through the const char * we got from cgGetProgramString!
// It SHOULD not have any nasty side effects though - but you never know...
char *pcompiledprog = (char*)cgGetProgramString(tempprog, CG_COMPILED_PROGRAM);
char *plocal = strstr(pcompiledprog, "program.local");
while (plocal != NULL) {
const char* penv = " program.env";
const char *penv = " program.env";
memcpy(plocal, penv, 13);
plocal = strstr(plocal+13, "program.local");
}
if (Renderer::IsUsingATIDrawBuffers()) {
// sometimes compilation can use ARB_draw_buffers, which would fail for ATI cards
// replace the three characters ARB with ATI. TODO - check whether this is fixed in modern ATI drivers.
char* poptions = strstr(pcompiledprog, "ARB_draw_buffers");
// Sometimes compilation can use ARB_draw_buffers, which would fail for ATI cards.
// Replace the three characters ARB with ATI. TODO - check whether this is fixed in modern ATI drivers.
char *poptions = strstr(pcompiledprog, "ARB_draw_buffers");
if (poptions != NULL) {
poptions[0] = 'A';
poptions[1] = 'T';
@@ -202,9 +204,9 @@ bool PixelShaderCache::CompilePixelShader(FRAGMENTSHADER& ps, const char* pstrpr
}
}
glGenProgramsARB( 1, &ps.glprogid );
glBindProgramARB( GL_FRAGMENT_PROGRAM_ARB, ps.glprogid );
glProgramStringARB( GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, (GLsizei)strlen(pcompiledprog), pcompiledprog);
glGenProgramsARB(1, &ps.glprogid);
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, ps.glprogid);
glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, (GLsizei)strlen(pcompiledprog), pcompiledprog);
GLenum err = GL_NO_ERROR;
GL_REPORT_ERROR();
@@ -214,7 +216,6 @@ bool PixelShaderCache::CompilePixelShader(FRAGMENTSHADER& ps, const char* pstrpr
}
cgDestroyProgram(tempprog);
// printf("Compiled pixel shader %i\n", ps.glprogid);
#if defined(_DEBUG) || defined(DEBUGFAST)
ps.strprog = pstrprogram;
@@ -53,7 +53,7 @@ class PixelShaderCache
public:
static void Init();
static void Cleanup();
static void ProgressiveCleanup();
static void Shutdown();
static FRAGMENTSHADER* GetShader();
File diff suppressed because it is too large Load Diff
+8 -1
View File
@@ -116,6 +116,10 @@ public:
static int GetTargetWidth();
static int GetTargetHeight();
// Multiply any 0-640 / 0-480 coordinates by these when rendering.
static float GetTargetScaleX();
static float GetTargetScaleY();
static void SetFramebuffer(GLuint fb);
static void SetZBufferRender(); // sets rendering of the zbuffer using MRTs
static void SetRenderTarget(GLuint targ); // if targ is 0, sets to original render target
@@ -126,11 +130,14 @@ public:
// Random utilities
static void RenderText(const char* pstr, int left, int top, u32 color);
static void DrawDebugText();
static void SetScreenshot(const char *filename);
static bool SaveRenderTarget(const char *filename);
static bool SaveRenderTarget(const char *filename, int w, int h);
// Finish up the current frame, print some stats
static void Swap(const TRectangle& rc);
};
void ComputeBackbufferRectangle(TRectangle *rc);
#endif
@@ -177,7 +177,7 @@ void EncodeToRam(GLuint srcTexture, const TRectangle& sourceRc,
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, srcTexture);
if(linearFilter)
if (linearFilter)
{
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
@@ -198,6 +198,7 @@ void EncodeToRam(GLuint srcTexture, const TRectangle& sourceRc,
glEnable(GL_FRAGMENT_PROGRAM_ARB);
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, shader.glprogid);
// Draw...
glBegin(GL_QUADS);
glTexCoord2f((float)sourceRc.left, (float)sourceRc.top); glVertex2f(-1,-1);
glTexCoord2f((float)sourceRc.left, (float)sourceRc.bottom); glVertex2f(-1,1);
@@ -206,6 +207,7 @@ void EncodeToRam(GLuint srcTexture, const TRectangle& sourceRc,
glEnd();
GL_REPORT_ERRORD();
// .. and then readback the results.
// TODO: make this less slow.
glReadPixels(0, 0, (GLsizei)dstWidth, (GLsizei)dstHeight, GL_BGRA, GL_UNSIGNED_BYTE, destAddr);
GL_REPORT_ERRORD();
@@ -245,7 +247,7 @@ void EncodeToRam(u32 address, bool bFromZBuffer, bool bIsIntensityFmt, u32 copyf
u8* ptr = Memory_GetPtr(address);
u32 target = bFromZBuffer?Renderer::GetZBufferTarget():Renderer::GetRenderTarget();
u32 target = bFromZBuffer ? Renderer::GetZBufferTarget() : Renderer::GetRenderTarget();
s32 width = source.right - source.left;
s32 height = source.bottom - source.top;
@@ -660,12 +660,12 @@ void TextureMngr::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, bool
GL_REPORT_ERRORD();
glBegin(GL_QUADS);
float MValueX = OpenGL_GetXmax();
float MValueY = OpenGL_GetYmax();
glTexCoord2f((float)source->left * MValueX, Renderer::GetTargetHeight()-(float)source->bottom * MValueY); glVertex2f(-1,1);
glTexCoord2f((float)source->left * MValueX, Renderer::GetTargetHeight()-(float)source->top * MValueY); glVertex2f(-1,-1);
glTexCoord2f((float)source->right * MValueX, Renderer::GetTargetHeight()-(float)source->top * MValueY); glVertex2f(1,-1);
glTexCoord2f((float)source->right * MValueX, Renderer::GetTargetHeight()-(float)source->bottom * MValueY); glVertex2f(1,1);
float MValueX = Renderer::GetTargetScaleX();
float MValueY = Renderer::GetTargetScaleY();
glTexCoord2f((float)source->left * MValueX, Renderer::GetTargetHeight()-(float)source->bottom * MValueY); glVertex2f(-1, 1);
glTexCoord2f((float)source->left * MValueX, Renderer::GetTargetHeight()-(float)source->top * MValueY); glVertex2f(-1, -1);
glTexCoord2f((float)source->right * MValueX, Renderer::GetTargetHeight()-(float)source->top * MValueY); glVertex2f( 1, -1);
glTexCoord2f((float)source->right * MValueX, Renderer::GetTargetHeight()-(float)source->bottom * MValueY); glVertex2f( 1, 1);
glEnd();
GL_REPORT_ERRORD();
@@ -299,7 +299,7 @@ void Flush()
if (g_Config.iLog & CONF_SAVETARGETS) {
char str[128];
sprintf(str, "%sframes/targ%.3d.tga", FULL_DUMP_DIR, g_Config.iSaveTargetId);
Renderer::SaveRenderTarget(str);
Renderer::SaveRenderTarget(str, Renderer::GetTargetWidth(), Renderer::GetTargetHeight());
}
#endif
g_Config.iSaveTargetId++;
@@ -109,7 +109,7 @@ VERTEXSHADER* VertexShaderCache::GetShader(u32 components)
return pShaderLast;
}
void VertexShaderCache::Cleanup()
void VertexShaderCache::ProgressiveCleanup()
{
VSCache::iterator iter = vshaders.begin();
while (iter != vshaders.end()) {
@@ -142,18 +142,15 @@ bool VertexShaderCache::CompileVertexShader(VERTEXSHADER& vs, const char* pstrpr
return false;
}
//ERROR_LOG(VIDEO, pstrprogram);
//ERROR_LOG(VIDEO, "id: %d\n", g_Config.iSaveTargetId);
char* pcompiledprog = (char*)cgGetProgramString(tempprog, CG_COMPILED_PROGRAM);
char* plocal = strstr(pcompiledprog, "program.local");
// This looks evil - we modify the program through the const char * we got from cgGetProgramString!
// It SHOULD not have any nasty side effects though - but you never know...
char *pcompiledprog = (char*)cgGetProgramString(tempprog, CG_COMPILED_PROGRAM);
char *plocal = strstr(pcompiledprog, "program.local");
while (plocal != NULL) {
const char* penv = " program.env";
memcpy(plocal, penv, 13);
plocal = strstr(plocal+13, "program.local");
plocal = strstr(plocal + 13, "program.local");
}
glGenProgramsARB(1, &vs.glprogid);
glBindProgramARB(GL_VERTEX_PROGRAM_ARB, vs.glprogid);
glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, (GLsizei)strlen(pcompiledprog), pcompiledprog);
@@ -166,7 +163,6 @@ bool VertexShaderCache::CompileVertexShader(VERTEXSHADER& vs, const char* pstrpr
}
cgDestroyProgram(tempprog);
// printf("Compiled vertex shader %i\n", vs.glprogid);
#if defined(_DEBUG) || defined(DEBUGFAST)
vs.strprog = pstrprogram;
@@ -51,7 +51,7 @@ class VertexShaderCache
public:
static void Init();
static void Cleanup();
static void ProgressiveCleanup();
static void Shutdown();
static VERTEXSHADER* GetShader(u32 components);
+8 -8
View File
@@ -59,7 +59,6 @@ static struct
void XFB_SetUpdateArgs(u8* _pXFB, u32 _dwWidth, u32 _dwHeight, s32 _dwYOffset);
void XFB_Init()
{
glGenTextures(1, &xfb_decoded_texture);
@@ -81,23 +80,22 @@ int XFB_isInit()
void XFB_Write(u8 *xfb_in_ram, const TRectangle& sourceRc, u32 dstWd, u32 dstHt)
{
u32 nBackbufferHeight = OpenGL_GetHeight();
TRectangle renderSrcRc;
renderSrcRc.left = sourceRc.left;
renderSrcRc.right = sourceRc.right;
renderSrcRc.top = nBackbufferHeight - sourceRc.top;
renderSrcRc.bottom = nBackbufferHeight - sourceRc.bottom;
// OpenGL upside down as usual...
renderSrcRc.top = Renderer::GetTargetHeight() - sourceRc.top;
renderSrcRc.bottom = Renderer::GetTargetHeight() - sourceRc.bottom;
TextureConverter::EncodeToRamYUYV(Renderer::GetRenderTarget(), renderSrcRc, xfb_in_ram, dstWd, dstHt);
}
// Draw the XFB straight to the OpenGL backbuffer.
void XFB_Draw(u8 *xfb_in_ram, u32 width, u32 height, s32 yOffset)
{
TextureConverter::DecodeToTexture(xfb_in_ram, width, height, xfb_decoded_texture);
OpenGL_Update(); // just updates the render window position and the backbuffer size
Renderer::ResetGLState();
TextureMngr::EnableTexRECT(0);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); // switch to the backbuffer
@@ -105,8 +103,10 @@ void XFB_Draw(u8 *xfb_in_ram, u32 width, u32 height, s32 yOffset)
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, xfb_decoded_texture);
glViewport(OpenGL_GetXoff(), OpenGL_GetYoff(),
(int)OpenGL_GetWidth(), (int)OpenGL_GetHeight());
TRectangle back_rc;
ComputeBackbufferRectangle(&back_rc);
glViewport(back_rc.left, back_rc.top, back_rc.right - back_rc.left, back_rc.bottom - back_rc.top);
GL_REPORT_ERRORD();
float w = (float)width;

Some files were not shown because too many files have changed in this diff Show More