Take care of some compiler warnings from unused variables, and a little code cleanup.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6081 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Glenn Rice
2010-08-10 01:08:22 +00:00
parent 55d7f93e0c
commit a1daa636c2
4 changed files with 286 additions and 217 deletions

View File

@ -437,11 +437,11 @@ void CCodeWindow::CreateMenu(const SCoreStartupParameter& _LocalCoreStartupParam
interpreter->Check(_LocalCoreStartupParameter.iCPUCore == 0);
pCoreMenu->AppendSeparator();
jitblocklinking = pCoreMenu->Append(IDM_JITBLOCKLINKING, _T("&JIT Block Linking off"),
pCoreMenu->Append(IDM_JITBLOCKLINKING, _T("&JIT Block Linking off"),
_T("Provide safer execution by not linking the JIT blocks."),
wxITEM_CHECK);
jitnoblockcache = pCoreMenu->Append(IDM_JITNOBLOCKCACHE, _T("&Disable JIT Cache"),
pCoreMenu->Append(IDM_JITNOBLOCKCACHE, _T("&Disable JIT Cache"),
_T("Avoid any involuntary JIT cache clearing, this may prevent Zelda TP from crashing.")
_T(" [This option must be selected before a game is started.]"),
wxITEM_CHECK);
@ -452,28 +452,28 @@ void CCodeWindow::CreateMenu(const SCoreStartupParameter& _LocalCoreStartupParam
pCoreMenu->Append(IDM_SEARCHINSTRUCTION, _T("&Search for an op"));
pCoreMenu->AppendSeparator();
jitoff = pCoreMenu->Append(IDM_JITOFF, _T("&JIT off (JIT core)"),
pCoreMenu->Append(IDM_JITOFF, _T("&JIT off (JIT core)"),
_T("Turn off all JIT functions, but still use the JIT core from Jit.cpp"),
wxITEM_CHECK);
jitlsoff = pCoreMenu->Append(IDM_JITLSOFF, _T("&JIT LoadStore off"),
pCoreMenu->Append(IDM_JITLSOFF, _T("&JIT LoadStore off"),
wxEmptyString, wxITEM_CHECK);
jitlslbzxoff = pCoreMenu->Append(IDM_JITLSLBZXOFF, _T(" &JIT LoadStore lbzx off"),
pCoreMenu->Append(IDM_JITLSLBZXOFF, _T(" &JIT LoadStore lbzx off"),
wxEmptyString, wxITEM_CHECK);
jitlslxzoff = pCoreMenu->Append(IDM_JITLSLXZOFF, _T(" &JIT LoadStore lXz off"),
pCoreMenu->Append(IDM_JITLSLXZOFF, _T(" &JIT LoadStore lXz off"),
wxEmptyString, wxITEM_CHECK);
jitlslwzoff = pCoreMenu->Append(IDM_JITLSLWZOFF, _T(" &JIT LoadStore lwz off"),
pCoreMenu->Append(IDM_JITLSLWZOFF, _T(" &JIT LoadStore lwz off"),
wxEmptyString, wxITEM_CHECK);
jitlspoff = pCoreMenu->Append(IDM_JITLSFOFF, _T("&JIT LoadStore Floating off"),
pCoreMenu->Append(IDM_JITLSFOFF, _T("&JIT LoadStore Floating off"),
wxEmptyString, wxITEM_CHECK);
jitlsfoff = pCoreMenu->Append(IDM_JITLSPOFF, _T("&JIT LoadStore Paired off"),
pCoreMenu->Append(IDM_JITLSPOFF, _T("&JIT LoadStore Paired off"),
wxEmptyString, wxITEM_CHECK);
jitfpoff = pCoreMenu->Append(IDM_JITFPOFF, _T("&JIT FloatingPoint off"),
pCoreMenu->Append(IDM_JITFPOFF, _T("&JIT FloatingPoint off"),
wxEmptyString, wxITEM_CHECK);
jitioff = pCoreMenu->Append(IDM_JITIOFF, _T("&JIT Integer off"),
pCoreMenu->Append(IDM_JITIOFF, _T("&JIT Integer off"),
wxEmptyString, wxITEM_CHECK);
jitpoff = pCoreMenu->Append(IDM_JITPOFF, _T("&JIT Paired off"),
pCoreMenu->Append(IDM_JITPOFF, _T("&JIT Paired off"),
wxEmptyString, wxITEM_CHECK);
jitsroff = pCoreMenu->Append(IDM_JITSROFF, _T("&JIT SystemRegisters off"),
pCoreMenu->Append(IDM_JITSROFF, _T("&JIT SystemRegisters off"),
wxEmptyString, wxITEM_CHECK);
pMenuBar->Append(pCoreMenu, _T("&JIT"));
@ -482,9 +482,9 @@ void CCodeWindow::CreateMenu(const SCoreStartupParameter& _LocalCoreStartupParam
// Debug Menu
wxMenu* pDebugMenu = new wxMenu;
wxMenuItem* stepinto = pDebugMenu->Append(IDM_STEP, _T("Step &Into\tF11"));
wxMenuItem* stepover = pDebugMenu->Append(IDM_STEPOVER, _T("Step &Over\tF10"));
wxMenuItem* togglebreakpoint = pDebugMenu->Append(IDM_TOGGLE_BREAKPOINT, _T("Toggle &Breakpoint\tF9"));
pDebugMenu->Append(IDM_STEP, _T("Step &Into\tF11"));
pDebugMenu->Append(IDM_STEPOVER, _T("Step &Over\tF10"));
pDebugMenu->Append(IDM_TOGGLE_BREAKPOINT, _T("Toggle &Breakpoint\tF9"));
pMenuBar->Append(pDebugMenu, _T("&Debug"));

View File

@ -143,15 +143,6 @@ class CCodeWindow
void InitBitmaps();
void CreateGUIControls(const SCoreStartupParameter& _LocalCoreStartupParameter);
wxMenuItem* jitblocklinking, *jitnoblockcache, *jitoff;
wxMenuItem* jitlsoff, *jitlslxzoff, *jitlslwzoff, *jitlslbzxoff;
wxMenuItem* jitlspoff;
wxMenuItem* jitlsfoff;
wxMenuItem* jitfpoff;
wxMenuItem* jitioff;
wxMenuItem* jitpoff;
wxMenuItem* jitsroff;
CCodeView* codeview;
wxListBox* callstack;
wxListBox* symbols;

View File

@ -76,8 +76,6 @@ BOOL APIENTRY DllMain(HINSTANCE hinstDLL, // DLL module handle
}
extern bool gShowDebugger;
int OSDChoice = 0 , OSDTime = 0, OSDInternalW = 0, OSDInternalH = 0;
// ---------------------------------------------------------------------
// OSD Menu

View File

@ -15,7 +15,6 @@
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "Globals.h"
#include "Thread.h"
#include "Atomic.h"
@ -119,16 +118,15 @@ static unsigned int s_XFB_height;
static float xScale;
static float yScale;
static int EFBxScale;
static int EFByScale;
static float EFBxScale;
static float EFByScale;
static bool s_skipSwap = false;
#ifndef _WIN32
int OSDChoice = 0 , OSDTime = 0, OSDInternalW = 0, OSDInternalH = 0;
#endif
namespace {
namespace
{
#if defined(HAVE_WX) && HAVE_WX
// Screenshot thread struct
@ -198,7 +196,8 @@ void SetDefaultRectTexParams()
// Set some standard texture filter modes.
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
if (GL_REPORT_ERROR() != GL_NO_ERROR) {
if (GL_REPORT_ERROR() != GL_NO_ERROR)
{
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP);
GL_REPORT_ERRORD();
@ -212,10 +211,9 @@ void HandleCgError(CGcontext ctx, CGerror err, void* appdata)
{
DEBUG_LOG(VIDEO, "Cg error: %s", cgGetErrorString(err));
const char* listing = cgGetLastListing(g_cgcontext);
if (listing != NULL) {
if (listing != NULL)
DEBUG_LOG(VIDEO, " last listing: %s", listing);
}
}
#endif
} // namespace
@ -224,7 +222,6 @@ void VideoConfig::UpdateProjectionHack()
::UpdateProjectionHack(g_Config.iPhackvalue);
}
// Init functions
bool Renderer::Init()
{
@ -240,10 +237,14 @@ bool Renderer::Init()
case MULTISAMPLE_2X: s_MSAASamples = 2; break;
case MULTISAMPLE_4X: s_MSAASamples = 4; break;
case MULTISAMPLE_8X: s_MSAASamples = 8; break;
case MULTISAMPLE_CSAA_8X: s_MSAASamples = 4; s_MSAACoverageSamples = 8; break;
case MULTISAMPLE_CSAA_8XQ: s_MSAASamples = 8; s_MSAACoverageSamples = 8; break;
case MULTISAMPLE_CSAA_16X: s_MSAASamples = 4; s_MSAACoverageSamples = 16; break;
case MULTISAMPLE_CSAA_16XQ: s_MSAASamples = 8; s_MSAACoverageSamples = 16; break;
case MULTISAMPLE_CSAA_8X:
s_MSAASamples = 4; s_MSAACoverageSamples = 8; break;
case MULTISAMPLE_CSAA_8XQ:
s_MSAASamples = 8; s_MSAACoverageSamples = 8; break;
case MULTISAMPLE_CSAA_16X:
s_MSAASamples = 4; s_MSAACoverageSamples = 16; break;
case MULTISAMPLE_CSAA_16XQ:
s_MSAASamples = 8; s_MSAACoverageSamples = 16; break;
default:
s_MSAASamples = 1;
}
@ -260,8 +261,7 @@ bool Renderer::Init()
{
PanicAlert("Your OpenGL Driver seems to be not working.\n"
"Please make sure your drivers are up-to-date and\n"
"that your video hardware is OpenGL 2.x compatible "
);
"that your video hardware is OpenGL 2.x compatible.");
return false;
}
@ -269,35 +269,48 @@ bool Renderer::Init()
INFO_LOG(VIDEO, ptoken); // write to the log file
INFO_LOG(VIDEO, "");
OSD::AddMessage(StringFromFormat("Video Info: %s, %s, %s", (const char*)glGetString(GL_VENDOR),
(const char*)glGetString(GL_RENDERER),
(const char*)glGetString(GL_VERSION)).c_str(), 5000);
OSD::AddMessage(StringFromFormat("Video Info: %s, %s, %s",
glGetString(GL_VENDOR),
glGetString(GL_RENDERER),
glGetString(GL_VERSION)).c_str(), 5000);
glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &numvertexattribs);
if (numvertexattribs < 11) {
ERROR_LOG(VIDEO, "*********\nGPU: OGL ERROR: Number of attributes %d not enough\nGPU: *********Does your video card support OpenGL 2.x?", numvertexattribs);
if (numvertexattribs < 11)
{
ERROR_LOG(VIDEO, "GPU: OGL ERROR: Number of attributes %d not enough.\n"
"GPU: Does your video card support OpenGL 2.x?",
numvertexattribs);
bSuccess = false;
}
// Init extension support.
if (glewInit() != GLEW_OK) {
if (glewInit() != GLEW_OK)
{
ERROR_LOG(VIDEO, "glewInit() failed! Does your video card support OpenGL 2.x?");
return false;
}
if (!GLEW_EXT_framebuffer_object) {
ERROR_LOG(VIDEO, "*********\nGPU: ERROR: Need GL_EXT_framebufer_object for multiple render targets\nGPU: *********Does your video card support OpenGL 2.x?");
if (!GLEW_EXT_framebuffer_object)
{
ERROR_LOG(VIDEO, "GPU: ERROR: Need GL_EXT_framebufer_object for multiple render targets.\n"
"GPU: Does your video card support OpenGL 2.x?");
bSuccess = false;
}
if (!GLEW_EXT_secondary_color) {
ERROR_LOG(VIDEO, "*********\nGPU: OGL ERROR: Need GL_EXT_secondary_color\nGPU: *********Does your video card support OpenGL 2.x?");
if (!GLEW_EXT_secondary_color)
{
ERROR_LOG(VIDEO, "GPU: OGL ERROR: Need GL_EXT_secondary_color.\n"
"GPU: Does your video card support OpenGL 2.x?");
bSuccess = false;
}
s_bHaveFramebufferBlit = strstr(ptoken, "GL_EXT_framebuffer_blit") != NULL;
if (!s_bHaveFramebufferBlit)
{
// MSAA ain't gonna work. turn it off if enabled.
s_MSAASamples = 1;
}
s_bHaveCoverageMSAA = strstr(ptoken, "GL_NV_framebuffer_multisample_coverage") != NULL;
if (!s_bHaveCoverageMSAA)
{
@ -314,20 +327,20 @@ bool Renderer::Init()
if (WGLEW_EXT_swap_control)
wglSwapIntervalEXT(g_ActiveConfig.bVSync ? 1 : 0);
else
ERROR_LOG(VIDEO, "no support for SwapInterval (framerate clamped to monitor refresh rate)Does your video card support OpenGL 2.x?");
ERROR_LOG(VIDEO, "No support for SwapInterval (framerate clamped to monitor refresh rate).");
#elif defined(HAVE_X11) && HAVE_X11
if (glXSwapIntervalSGI)
glXSwapIntervalSGI(g_ActiveConfig.bVSync ? 1 : 0);
else
ERROR_LOG(VIDEO, "no support for SwapInterval (framerate clamped to monitor refresh rate)");
ERROR_LOG(VIDEO, "No support for SwapInterval (framerate clamped to monitor refresh rate).");
#endif
// check the max texture width and height
GLint max_texture_size;
glGetIntegerv(GL_MAX_TEXTURE_SIZE, (GLint *)&max_texture_size);
if (max_texture_size < 1024) {
ERROR_LOG(VIDEO, "GL_MAX_TEXTURE_SIZE too small at %i - must be at least 1024", max_texture_size);
}
if (max_texture_size < 1024)
ERROR_LOG(VIDEO, "GL_MAX_TEXTURE_SIZE too small at %i - must be at least 1024.",
max_texture_size);
if (GL_REPORT_ERROR() != GL_NO_ERROR)
bSuccess = false;
@ -335,9 +348,8 @@ bool Renderer::Init()
if (glDrawBuffers == NULL && !GLEW_ARB_draw_buffers)
glDrawBuffers = glDrawBuffersARB;
if (!GLEW_ARB_texture_non_power_of_two) {
if (!GLEW_ARB_texture_non_power_of_two)
WARN_LOG(VIDEO, "ARB_texture_non_power_of_two not supported.");
}
// Decide frambuffer size
int W = (int)OpenGL_GetBackbufferWidth(), H = (int)OpenGL_GetBackbufferHeight();
@ -365,7 +377,6 @@ bool Renderer::Init()
}
}
EFBxScale = ceilf(xScale);
EFByScale = ceilf(yScale);
@ -376,14 +387,16 @@ bool Renderer::Init()
m_CustomWidth = W;
m_CustomHeight = H;
// Because of the fixed framebuffer size we need to disable the resolution options while running
// Because of the fixed framebuffer size we need to disable the resolution
// options while running
g_Config.bRunning = true;
if (GL_REPORT_ERROR() != GL_NO_ERROR)
bSuccess = false;
// Initialize the FramebufferManager
g_framebufferManager.Init(m_FrameBufferWidth, m_FrameBufferHeight, s_MSAASamples, s_MSAACoverageSamples);
g_framebufferManager.Init(m_FrameBufferWidth, m_FrameBufferHeight,
s_MSAASamples, s_MSAACoverageSamples);
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
@ -394,12 +407,14 @@ bool Renderer::Init()
#if defined HAVE_CG && HAVE_CG
// load the effect, find the best profiles (if any)
if (cgGLIsProfileSupported(CG_PROFILE_ARBVP1) != CG_TRUE) {
if (cgGLIsProfileSupported(CG_PROFILE_ARBVP1) != CG_TRUE)
{
ERROR_LOG(VIDEO, "arbvp1 not supported");
return false;
}
if (cgGLIsProfileSupported(CG_PROFILE_ARBFP1) != CG_TRUE) {
if (cgGLIsProfileSupported(CG_PROFILE_ARBFP1) != CG_TRUE)
{
ERROR_LOG(VIDEO, "arbfp1 not supported");
return false;
}
@ -412,23 +427,30 @@ bool Renderer::Init()
// which is correct in OpenGL but Cg fails to handle it properly. As a result
// -1 is used by Cg resulting (signedness incorrect) and compilation fails.
if (strstr((const char*)glGetString(GL_VENDOR), "ATI") == NULL)
#endif
{
cgGLSetOptimalOptions(g_cgvProf);
cgGLSetOptimalOptions(g_cgfProf);
}
#else
cgGLSetOptimalOptions(g_cgvProf);
cgGLSetOptimalOptions(g_cgfProf);
#endif
#endif // HAVE_CG
int nenvvertparams, nenvfragparams, naddrregisters[2];
glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB, (GLint *)&nenvvertparams);
glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB, (GLint *)&nenvfragparams);
glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB, (GLint *)&naddrregisters[0]);
glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB, (GLint *)&naddrregisters[1]);
DEBUG_LOG(VIDEO, "Max program env parameters: vert=%d, frag=%d", nenvvertparams, nenvfragparams);
DEBUG_LOG(VIDEO, "Max program address register parameters: vert=%d, frag=%d", naddrregisters[0], naddrregisters[1]);
glGetProgramivARB(GL_VERTEX_PROGRAM_ARB,
GL_MAX_PROGRAM_ENV_PARAMETERS_ARB,
(GLint *)&nenvvertparams);
glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB,
GL_MAX_PROGRAM_ENV_PARAMETERS_ARB,
(GLint *)&nenvfragparams);
glGetProgramivARB(GL_VERTEX_PROGRAM_ARB,
GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB,
(GLint *)&naddrregisters[0]);
glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB,
GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB,
(GLint *)&naddrregisters[1]);
DEBUG_LOG(VIDEO, "Max program env parameters: vert=%d, frag=%d",
nenvvertparams, nenvfragparams);
DEBUG_LOG(VIDEO, "Max program address register parameters: vert=%d, frag=%d",
naddrregisters[0], naddrregisters[1]);
if (nenvvertparams < 238)
ERROR_LOG(VIDEO, "Not enough vertex shader environment constants!!");
@ -490,7 +512,8 @@ void Renderer::Shutdown(void)
s_pfont = 0;
#if defined HAVE_CG && HAVE_CG
if (g_cgcontext) {
if (g_cgcontext)
{
cgDestroyContext(g_cgcontext);
g_cgcontext = 0;
}
@ -504,13 +527,11 @@ void Renderer::Shutdown(void)
g_framebufferManager.Shutdown();
#ifdef _WIN32
if(s_bAVIDumping) {
if(s_bAVIDumping)
AVIDump::Stop();
}
#else
if(f_pFrameDump != NULL) {
if(f_pFrameDump != NULL)
fclose(f_pFrameDump);
}
#endif
}
@ -522,6 +543,7 @@ bool Renderer::Allow2x()
else
return false;
}
bool Renderer::AllowCustom()
{
if (GetCustomWidth() <= GetFrameBufferWidth() && GetCustomHeight() <= GetFrameBufferHeight())
@ -535,28 +557,34 @@ int Renderer::GetFrameBufferWidth()
{
return m_FrameBufferWidth;
}
int Renderer::GetFrameBufferHeight()
{
return m_FrameBufferHeight;
}
// Return the custom resolution
int Renderer::GetCustomWidth()
{
return m_CustomWidth;
}
int Renderer::GetCustomHeight()
{
return m_CustomHeight;
}
// Return the rendering target width and height
int Renderer::GetTargetWidth()
{
return m_FrameBufferWidth;
}
int Renderer::GetTargetHeight()
{
return m_FrameBufferHeight;
}
float Renderer::GetTargetScaleX()
{
return EFBxScale;
@ -567,9 +595,15 @@ float Renderer::GetTargetScaleY()
return EFByScale;
}
float Renderer::GetXFBScaleX()
{
return xScale;
}
float Renderer::GetXFBScaleX() { return xScale; }
float Renderer::GetXFBScaleY() { return yScale; }
float Renderer::GetXFBScaleY()
{
return yScale;
}
TargetRectangle Renderer::ConvertEFBRectangle(const EFBRectangle& rc)
{
@ -628,9 +662,10 @@ void Renderer::SetBlendMode(bool forceUpdate)
u32 newval = bpmem.blendmode.subtract << 2;
if (bpmem.blendmode.subtract) {
if (bpmem.blendmode.subtract)
newval |= 0x0049; // enable blending src 1 dst 1
} else if (bpmem.blendmode.blendenable) {
else if (bpmem.blendmode.blendenable)
{
newval |= 1; // enable blending
newval |= bpmem.blendmode.srcfactor << 3;
newval |= bpmem.blendmode.dstfactor << 6;
@ -638,20 +673,17 @@ void Renderer::SetBlendMode(bool forceUpdate)
u32 changes = forceUpdate ? 0xFFFFFFFF : newval ^ s_blendMode;
if (changes & 1) {
if (changes & 1)
// blend enable change
(newval & 1) ? glEnable(GL_BLEND) : glDisable(GL_BLEND);
}
if (changes & 4) {
if (changes & 4)
// subtract enable change
glBlendEquation(newval & 4 ? GL_FUNC_REVERSE_SUBTRACT : GL_FUNC_ADD);
}
if (changes & 0x1F8) {
if (changes & 0x1F8)
// blend RGB change
glBlendFunc(glSrcFactors[(newval >> 3) & 7], glDestFactors[(newval >> 6) & 7]);
}
s_blendMode = newval;
}
@ -763,7 +795,6 @@ bool Renderer::SetScissorRect()
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
if (rc_bottom > EFB_HEIGHT) rc_bottom = EFB_HEIGHT;
@ -780,7 +811,6 @@ bool Renderer::SetScissorRect()
rc_top = temp;
}
// Check that the coordinates are good
if (rc_right != rc_left && rc_bottom != rc_top)
{
@ -804,18 +834,16 @@ bool Renderer::SetScissorRect()
return false;
}
void Renderer::ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaEnable, bool zEnable, u32 color, u32 z)
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);
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
VertexShaderManager::SetViewportChanged();
GLbitfield bits = 0;
@ -839,6 +867,7 @@ void Renderer::ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaE
glClear(bits);
SetScissorRect();
}
static bool XFBWrited = false;
void Renderer::RenderToXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRectangle& sourceRc)
{
@ -851,9 +880,7 @@ void Renderer::RenderToXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRect
// XXX: Without the VI, how would we know what kind of field this is? So
// just use progressive.
if (g_ActiveConfig.bUseXFB)
{
g_framebufferManager.CopyToXFB(xfbAddr, fbWidth, fbHeight, sourceRc);
}
else
{
Renderer::Swap(xfbAddr, FIELD_PROGRESSIVE, fbWidth, fbHeight,sourceRc);
@ -902,7 +929,6 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
// Copy the framebuffer to screen.
// Texture map s_xfbTexture onto the main buffer
glActiveTexture(GL_TEXTURE0);
glEnable(GL_TEXTURE_RECTANGLE_ARB);
@ -980,25 +1006,44 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
// Texture map xfbSource->texture onto the main buffer
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, xfbSource->texture);
// We must call ApplyShader here even if no post proc is selected - it takes
// care of disabling it in that case. It returns false in case of no post processing.
// We must call ApplyShader here even if no post proc is selected.
// It takes care of disabling it in that case. It returns false in
// case of no post processing.
if (applyShader)
{
glBegin(GL_QUADS);
glTexCoord2f(sourceRc.left, sourceRc.bottom); glMultiTexCoord2fARB(GL_TEXTURE1, 0, 0); glVertex2f(drawRc.left, drawRc.bottom);
glTexCoord2f(sourceRc.left, sourceRc.top); glMultiTexCoord2fARB(GL_TEXTURE1, 0, 1); glVertex2f(drawRc.left, drawRc.top);
glTexCoord2f(sourceRc.right, sourceRc.top); glMultiTexCoord2fARB(GL_TEXTURE1, 1, 1); glVertex2f(drawRc.right, drawRc.top);
glTexCoord2f(sourceRc.right, sourceRc.bottom); glMultiTexCoord2fARB(GL_TEXTURE1, 1, 0); glVertex2f(drawRc.right, drawRc.bottom);
glTexCoord2f(sourceRc.left, sourceRc.bottom);
glMultiTexCoord2fARB(GL_TEXTURE1, 0, 0);
glVertex2f(drawRc.left, drawRc.bottom);
glTexCoord2f(sourceRc.left, sourceRc.top);
glMultiTexCoord2fARB(GL_TEXTURE1, 0, 1);
glVertex2f(drawRc.left, drawRc.top);
glTexCoord2f(sourceRc.right, sourceRc.top);
glMultiTexCoord2fARB(GL_TEXTURE1, 1, 1);
glVertex2f(drawRc.right, drawRc.top);
glTexCoord2f(sourceRc.right, sourceRc.bottom);
glMultiTexCoord2fARB(GL_TEXTURE1, 1, 0);
glVertex2f(drawRc.right, drawRc.bottom);
glEnd();
PixelShaderCache::DisableShader();
}
else
{
glBegin(GL_QUADS);
glTexCoord2f(sourceRc.left, sourceRc.bottom); glVertex2f(drawRc.left, drawRc.bottom);
glTexCoord2f(sourceRc.left, sourceRc.top); glVertex2f(drawRc.left, drawRc.top);
glTexCoord2f(sourceRc.right, sourceRc.top); glVertex2f(drawRc.right, drawRc.top);
glTexCoord2f(sourceRc.right, sourceRc.bottom); glVertex2f(drawRc.right, drawRc.bottom);
glTexCoord2f(sourceRc.left, sourceRc.bottom);
glVertex2f(drawRc.left, drawRc.bottom);
glTexCoord2f(sourceRc.left, sourceRc.top);
glVertex2f(drawRc.left, drawRc.top);
glTexCoord2f(sourceRc.right, sourceRc.top);
glVertex2f(drawRc.right, drawRc.top);
glTexCoord2f(sourceRc.right, sourceRc.bottom);
glVertex2f(drawRc.right, drawRc.bottom);
glEnd();
}
@ -1015,24 +1060,41 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
if (applyShader)
{
glBegin(GL_QUADS);
glTexCoord2f(targetRc.left, targetRc.bottom); glMultiTexCoord2fARB(GL_TEXTURE1, 0, 0); glVertex2f(-1, -1);
glTexCoord2f(targetRc.left, targetRc.top); glMultiTexCoord2fARB(GL_TEXTURE1, 0, 1); glVertex2f(-1, 1);
glTexCoord2f(targetRc.right, targetRc.top); glMultiTexCoord2fARB(GL_TEXTURE1, 1, 1); glVertex2f( 1, 1);
glTexCoord2f(targetRc.right, targetRc.bottom); glMultiTexCoord2fARB(GL_TEXTURE1, 1, 0); glVertex2f( 1, -1);
glTexCoord2f(targetRc.left, targetRc.bottom);
glMultiTexCoord2fARB(GL_TEXTURE1, 0, 0);
glVertex2f(-1, -1);
glTexCoord2f(targetRc.left, targetRc.top);
glMultiTexCoord2fARB(GL_TEXTURE1, 0, 1);
glVertex2f(-1, 1);
glTexCoord2f(targetRc.right, targetRc.top);
glMultiTexCoord2fARB(GL_TEXTURE1, 1, 1);
glVertex2f( 1, 1);
glTexCoord2f(targetRc.right, targetRc.bottom);
glMultiTexCoord2fARB(GL_TEXTURE1, 1, 0);
glVertex2f( 1, -1);
glEnd();
PixelShaderCache::DisableShader();
}
else
{
glBegin(GL_QUADS);
glTexCoord2f(targetRc.left, targetRc.bottom); glVertex2f(-1, -1);
glTexCoord2f(targetRc.left, targetRc.top); glVertex2f(-1, 1);
glTexCoord2f(targetRc.right, targetRc.top); glVertex2f( 1, 1);
glTexCoord2f(targetRc.right, targetRc.bottom); glVertex2f( 1, -1);
glTexCoord2f(targetRc.left, targetRc.bottom);
glVertex2f(-1, -1);
glTexCoord2f(targetRc.left, targetRc.top);
glVertex2f(-1, 1);
glTexCoord2f(targetRc.right, targetRc.top);
glVertex2f( 1, 1);
glTexCoord2f(targetRc.right, targetRc.bottom);
glVertex2f( 1, -1);
glEnd();
}
}
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0);
TextureMngr::DisableStage(0);
@ -1073,7 +1135,8 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
else
{
OSD::AddMessage(StringFromFormat(
"Dumping Frames to \"%sframedump0.avi\" (%dx%d RGB24)", File::GetUserPath(D_DUMPFRAMES_IDX), w, h).c_str(), 2000);
"Dumping Frames to \"%sframedump0.avi\" (%dx%d RGB24)",
File::GetUserPath(D_DUMPFRAMES_IDX), w, h).c_str(), 2000);
}
}
if (s_bAVIDumping)
@ -1082,9 +1145,8 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
s_bLastFrameDumped = true;
}
else
{
NOTICE_LOG(VIDEO, "Error reading framebuffer");
}
free(data);
s_criticalScreenshot.Leave();
}
@ -1099,7 +1161,8 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
s_bLastFrameDumped = false;
}
#else
if (g_ActiveConfig.bDumpFrames) {
if (g_ActiveConfig.bDumpFrames)
{
s_criticalScreenshot.Enter();
char movie_file_name[255];
int w = back_rc.GetWidth();
@ -1107,33 +1170,40 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
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);
if (GL_REPORT_ERROR() == GL_NO_ERROR) {
if (!s_bLastFrameDumped) {
if (GL_REPORT_ERROR() == GL_NO_ERROR)
{
if (!s_bLastFrameDumped)
{
sprintf(movie_file_name, "%sframedump.raw", File::GetUserPath(D_DUMPFRAMES_IDX));
f_pFrameDump = fopen(movie_file_name, "wb");
if (f_pFrameDump == NULL) {
PanicAlert("Error opening framedump.raw for writing.");
} else {
if (f_pFrameDump == NULL)
OSD::AddMessage("Error opening framedump.raw for writing.", 2000);
else
{
char msg [255];
sprintf(msg, "Dumping Frames to \"%s\" (%dx%d RGB24)", movie_file_name, w, h);
OSD::AddMessage(msg, 2000);
}
}
if (f_pFrameDump != NULL) {
if (f_pFrameDump != NULL)
{
FlipImageData(data, w, h);
fwrite(data, w * 3, h, f_pFrameDump);
fflush(f_pFrameDump);
}
s_bLastFrameDumped = true;
}
free(data);
s_criticalScreenshot.Leave();
} else {
if (s_bLastFrameDumped && f_pFrameDump != NULL) {
}
else
{
if (s_bLastFrameDumped && f_pFrameDump != NULL)
{
fclose(f_pFrameDump);
f_pFrameDump = NULL;
}
s_bLastFrameDumped = false;
}
#endif
@ -1160,7 +1230,6 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
m_CustomHeight = H;
}
if( xfbchanged || WindowResized)
{
TargetRectangle dst_rect;
@ -1183,19 +1252,20 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
}
}
EFBxScale = ceilf(xScale);
EFByScale = ceilf(yScale);
int m_newFrameBufferWidth = EFB_WIDTH * EFBxScale;
int m_newFrameBufferHeight = EFB_HEIGHT * EFByScale;
if(m_newFrameBufferWidth != m_FrameBufferWidth || m_newFrameBufferHeight != m_FrameBufferHeight )
if(m_newFrameBufferWidth != m_FrameBufferWidth ||
m_newFrameBufferHeight != m_FrameBufferHeight )
{
m_FrameBufferWidth = m_newFrameBufferWidth;
m_FrameBufferHeight = m_newFrameBufferHeight;
g_framebufferManager.Shutdown();
g_framebufferManager.Init(m_FrameBufferWidth, m_FrameBufferHeight, s_MSAASamples, s_MSAACoverageSamples);
g_framebufferManager.Init(m_FrameBufferWidth, m_FrameBufferHeight,
s_MSAASamples, s_MSAACoverageSamples);
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
}
@ -1228,18 +1298,22 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
if (blend_enabled)
glEnable(GL_BLEND);
GL_REPORT_ERRORD();
#if defined(DVPROFILE)
if (g_bWriteProfile) {
if (g_bWriteProfile)
{
//g_bWriteProfile = 0;
static int framenum = 0;
const int UPDATE_FRAMES = 8;
if (++framenum >= UPDATE_FRAMES) {
if (++framenum >= UPDATE_FRAMES)
{
DVProfWrite("prof.txt", UPDATE_FRAMES);
DVProfClear();
framenum = 0;
}
}
#endif
// Copy the rendered frame to the real window
OpenGL_SwapBuffers();
@ -1277,10 +1351,10 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
// For testing zbuffer targets.
// Renderer::SetZBufferRender();
// SaveTexture("tex.tga", GL_TEXTURE_RECTANGLE_ARB, s_FakeZTarget, GetTargetWidth(), GetTargetHeight());
// SaveTexture("tex.tga", GL_TEXTURE_RECTANGLE_ARB, s_FakeZTarget,
// GetTargetWidth(), GetTargetHeight());
g_VideoInitialize.pCopiedToXFB(XFBWrited || g_ActiveConfig.bUseRealXFB);
XFBWrited = false;
}
// Create On-Screen-Messages
@ -1308,7 +1382,8 @@ void Renderer::DrawDebugText()
glBegin(GL_LINES);
// Draw EFB copy regions rectangles
for (std::vector<EFBRectangle>::const_iterator it = stats.efb_regions.begin(); it != stats.efb_regions.end(); ++it)
for (std::vector<EFBRectangle>::const_iterator it = stats.efb_regions.begin();
it != stats.efb_regions.end(); ++it)
{
GLfloat halfWidth = EFB_WIDTH / 2.0f;
GLfloat halfHeight = EFB_HEIGHT / 2.0f;
@ -1342,14 +1417,10 @@ void Renderer::DrawDebugText()
}
if (g_ActiveConfig.bOverlayStats)
{
p = Statistics::ToString(p);
}
if (g_ActiveConfig.bOverlayProjStats)
{
p = Statistics::ToStringProj(p);
}
// Render a shadow, and then the text.
if (p != debugtext_buffer)
@ -1407,11 +1478,16 @@ void Renderer::DrawDebugText()
{ T1 += "\n\n"; T2 += "\n\n"; }
// The rows
T0.push_back(StringFromFormat("3: Internal Resolution: %s\n", OSDM1.c_str()));
T0.push_back(StringFromFormat("4: Aspect Ratio: %s%s\n", OSDM21.c_str(), OSDM22.c_str()));
T0.push_back(StringFromFormat("5: Copy EFB: %s\n", OSDM3.c_str()));
T0.push_back(StringFromFormat("6: Fog: %s\n", g_ActiveConfig.bDisableFog ? "Disabled" : "Enabled"));
T0.push_back(StringFromFormat("7: Material Lighting: %s\n", g_ActiveConfig.bDisableLighting ? "Disabled" : "Enabled"));
T0.push_back(StringFromFormat("3: Internal Resolution: %s\n",
OSDM1.c_str()));
T0.push_back(StringFromFormat("4: Aspect Ratio: %s%s\n",
OSDM21.c_str(), OSDM22.c_str()));
T0.push_back(StringFromFormat("5: Copy EFB: %s\n",
OSDM3.c_str()));
T0.push_back(StringFromFormat("6: Fog: %s\n",
g_ActiveConfig.bDisableFog ? "Disabled" : "Enabled"));
T0.push_back(StringFromFormat("7: Material Lighting: %s\n",
g_ActiveConfig.bDisableLighting ? "Disabled" : "Enabled"));
// The latest changed setting in yellow
T1 += (OSDChoice == -1) ? T0.at(0) : "\n";
@ -1435,6 +1511,7 @@ void Renderer::DrawDebugText()
}
}
}
void Renderer::RenderText(const char* pstr, int left, int top, u32 color)
{
int nBackbufferWidth = (int)OpenGL_GetBackbufferWidth();
@ -1492,11 +1569,13 @@ THREAD_RETURN TakeScreenshot(void *pArgs)
// Save the screenshot and finally kill the wxImage object
// This is really expensive when saving to PNG, but not at all when using BMP
threadStruct->img->SaveFile(wxString::FromAscii(threadStruct->filename.c_str()), wxBITMAP_TYPE_PNG);
threadStruct->img->SaveFile(wxString::FromAscii(threadStruct->filename.c_str()),
wxBITMAP_TYPE_PNG);
threadStruct->img->Destroy();
// Show success messages
OSD::AddMessage(StringFromFormat("Saved %i x %i %s", (int)FloatW, (int)FloatH, threadStruct->filename.c_str()).c_str(), 2000);
OSD::AddMessage(StringFromFormat("Saved %i x %i %s", (int)FloatW, (int)FloatH,
threadStruct->filename.c_str()).c_str(), 2000);
delete threadStruct;
return 0;
@ -1567,9 +1646,6 @@ bool Renderer::SaveRenderTarget(const char *filename, TargetRectangle back_rc)
return result;
}
// Called from VertexShaderManager
void UpdateViewport()
{
@ -1580,14 +1656,17 @@ void UpdateViewport()
// [3] = xorig + width/2 + 342
// [4] = yorig + height/2 + 342
// [5] = 16777215 * farz
int scissorXOff = bpmem.scissorOffset.x * 2; // 342
int scissorYOff = bpmem.scissorOffset.y * 2; // 342
float scissorXOff = float(bpmem.scissorOffset.x) * 2.0f; // 342
float scissorYOff = float(bpmem.scissorOffset.y) * 2.0f; // 342
// Stretch picture with increased internal resolution
int GLx = (int)ceil((xfregs.rawViewport[3] - xfregs.rawViewport[0] - scissorXOff) * EFBxScale);
int GLy = (int)ceil((float)((int)(EFB_HEIGHT - xfregs.rawViewport[4] + xfregs.rawViewport[1] + scissorYOff)) * EFByScale);
int GLWidth = (int)ceil((float)(2 * xfregs.rawViewport[0]) * EFBxScale);
int GLHeight = (int)ceil((float)(-2 * xfregs.rawViewport[1]) * EFByScale);
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);
double GLNear = (xfregs.rawViewport[5] - xfregs.rawViewport[2]) / 16777216.0f;
double GLFar = xfregs.rawViewport[5] / 16777216.0f;
if(GLWidth < 0)
@ -1652,12 +1731,13 @@ void Renderer::SetDitherMode()
glDisable(GL_DITHER);
}
void Renderer::SetLineWidth()
{
float fratio = xfregs.rawViewport[0] != 0 ? ((float)Renderer::GetTargetWidth() / EFB_WIDTH) : 1.0f;
float fratio = xfregs.rawViewport[0] != 0 ?
((float)Renderer::GetTargetWidth() / EFB_WIDTH) : 1.0f;
if (bpmem.lineptwidth.linesize > 0)
glLineWidth((float)bpmem.lineptwidth.linesize * fratio / 6.0f); // scale by ratio of widths
// scale by ratio of widths
glLineWidth((float)bpmem.lineptwidth.linesize * fratio / 6.0f);
if (bpmem.lineptwidth.pointsize > 0)
glPointSize((float)bpmem.lineptwidth.pointsize * fratio / 6.0f);
}