Clean up OpenGL plugin error handling macros. No longer bother with enabling TEXTURE_2D and TEXTURE_RECTANGLE_ARB - they don't apply when using shaders. Change a PanicAlert when looking for valid plugins into a LOG_WARN.
Let me know if this breaks anything - it shouldn't. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2726 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
4dc6dd7db7
commit
e62b7f35ce
|
@ -254,11 +254,11 @@ CPluginInfo::CPluginInfo(const char *_rFilename)
|
||||||
m_Valid = true;
|
m_Valid = true;
|
||||||
else
|
else
|
||||||
PanicAlert("Could not get info about plugin %s", _rFilename);
|
PanicAlert("Could not get info about plugin %s", _rFilename);
|
||||||
|
|
||||||
// We are now done with this plugin and will call FreeLibrary()
|
// We are now done with this plugin and will call FreeLibrary()
|
||||||
delete plugin;
|
delete plugin;
|
||||||
} else
|
} else {
|
||||||
PanicAlert("PluginInfo: %s is not valid", _rFilename);
|
WARN_LOG(CONSOLE, "PluginInfo: %s is not a valid Dolphin plugin. Ignoring.", _rFilename);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
///////////////////////////////////////////
|
///////////////////////////////////////////
|
||||||
|
|
||||||
|
|
|
@ -93,28 +93,6 @@ void OpenGL_SetWindowText(const char *text)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OpenGL_CheckFBOStatus()
|
|
||||||
{
|
|
||||||
unsigned int fbo_status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
|
|
||||||
if (fbo_status != GL_FRAMEBUFFER_COMPLETE_EXT)
|
|
||||||
{
|
|
||||||
std::string error = "error creating fbo, framebufferstatus is not complete:\n";
|
|
||||||
switch (fbo_status)
|
|
||||||
{
|
|
||||||
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT: error += "INCOMPLETE_ATTACHMENT_EXT"; break;
|
|
||||||
case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT: error += "INCOMPLETE_MISSING_ATTACHMENT_EXT"; break;
|
|
||||||
case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT: error += "INCOMPLETE_DIMENSIONS_EXT"; break;
|
|
||||||
case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT: error += "INCOMPLETE_FORMATS_EXT"; break;
|
|
||||||
case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT: error += "INCOMPLETE_DRAW_BUFFER_EXT"; break;
|
|
||||||
case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT: error += "INCOMPLETE_READ_BUFFER_EXT"; break;
|
|
||||||
case GL_FRAMEBUFFER_UNSUPPORTED_EXT: error += "UNSUPPORTED_EXT"; break;
|
|
||||||
}
|
|
||||||
PanicAlert(error.c_str());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// =======================================================================================
|
// =======================================================================================
|
||||||
// Draw messages on top of the screen
|
// Draw messages on top of the screen
|
||||||
// ------------------
|
// ------------------
|
||||||
|
@ -336,22 +314,22 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!(hDC=GetDC(EmuWindow::GetWnd()))) {
|
if (!(hDC=GetDC(EmuWindow::GetWnd()))) {
|
||||||
PanicAlert("(1) Can't Create A GL Device Context.");
|
PanicAlert("(1) Can't create an OpenGL Device context. Fail.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(PixelFormat = ChoosePixelFormat(hDC,&pfd))) {
|
if (!(PixelFormat = ChoosePixelFormat(hDC,&pfd))) {
|
||||||
PanicAlert("(2) Can't Find A Suitable PixelFormat.");
|
PanicAlert("(2) Can't find a suitable PixelFormat.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!SetPixelFormat(hDC, PixelFormat, &pfd)) {
|
if (!SetPixelFormat(hDC, PixelFormat, &pfd)) {
|
||||||
PanicAlert("(3) Can't Set The PixelFormat.");
|
PanicAlert("(3) Can't set the PixelFormat.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(hRC = wglCreateContext(hDC))) {
|
if (!(hRC = wglCreateContext(hDC))) {
|
||||||
PanicAlert("(4) Can't Create A GL Rendering Context.");
|
PanicAlert("(4) Can't create an OpenGL rendering context.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// --------------------------------------
|
// --------------------------------------
|
||||||
|
@ -384,6 +362,7 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight
|
||||||
g_VideoInitialize.pWindowHandle = (HWND)GLWin.dpy;
|
g_VideoInitialize.pWindowHandle = (HWND)GLWin.dpy;
|
||||||
GLWin.screen = DefaultScreen(GLWin.dpy);
|
GLWin.screen = DefaultScreen(GLWin.dpy);
|
||||||
|
|
||||||
|
// Fullscreen option.
|
||||||
GLWin.fs = g_Config.bFullscreen; //Set to setting in Options
|
GLWin.fs = g_Config.bFullscreen; //Set to setting in Options
|
||||||
|
|
||||||
/* get an appropriate visual */
|
/* get an appropriate visual */
|
||||||
|
@ -400,16 +379,15 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight
|
||||||
|
|
||||||
glXQueryVersion(GLWin.dpy, &glxMajorVersion, &glxMinorVersion);
|
glXQueryVersion(GLWin.dpy, &glxMajorVersion, &glxMinorVersion);
|
||||||
NOTICE_LOG(VIDEO, "glX-Version %d.%d", glxMajorVersion, glxMinorVersion);
|
NOTICE_LOG(VIDEO, "glX-Version %d.%d", glxMajorVersion, glxMinorVersion);
|
||||||
/* create a GLX context */
|
// Create a GLX context.
|
||||||
GLWin.ctx = glXCreateContext(GLWin.dpy, vi, 0, GL_TRUE);
|
GLWin.ctx = glXCreateContext(GLWin.dpy, vi, 0, GL_TRUE);
|
||||||
if(!GLWin.ctx)
|
if(!GLWin.ctx)
|
||||||
{
|
{
|
||||||
PanicAlert("Couldn't Create GLX context.Quit");
|
PanicAlert("Couldn't Create GLX context.Quit");
|
||||||
exit(0); // TODO: Don't bring down entire Emu
|
exit(0); // TODO: Don't bring down entire Emu
|
||||||
}
|
}
|
||||||
/* create a color map */
|
// Create a color map.
|
||||||
cmap = XCreateColormap(GLWin.dpy, RootWindow(GLWin.dpy, vi->screen),
|
cmap = XCreateColormap(GLWin.dpy, RootWindow(GLWin.dpy, vi->screen), vi->visual, AllocNone);
|
||||||
vi->visual, AllocNone);
|
|
||||||
GLWin.attr.colormap = cmap;
|
GLWin.attr.colormap = cmap;
|
||||||
GLWin.attr.border_pixel = 0;
|
GLWin.attr.border_pixel = 0;
|
||||||
XkbSetDetectableAutoRepeat(GLWin.dpy, True, NULL);
|
XkbSetDetectableAutoRepeat(GLWin.dpy, True, NULL);
|
||||||
|
@ -721,6 +699,19 @@ void OpenGL_Shutdown()
|
||||||
hDC = NULL; // Set DC To NULL
|
hDC = NULL; // Set DC To NULL
|
||||||
}
|
}
|
||||||
#elif defined(HAVE_X11) && HAVE_X11
|
#elif defined(HAVE_X11) && HAVE_X11
|
||||||
|
<<<<<<< .mine
|
||||||
|
if (GLWin.ctx)
|
||||||
|
{
|
||||||
|
if (!glXMakeCurrent(GLWin.dpy, None, NULL))
|
||||||
|
{
|
||||||
|
ERROR_LOG(VIDEO, "Could not release drawing context.\n");
|
||||||
|
}
|
||||||
|
XUnmapWindow(GLWin.dpy, GLWin.win);
|
||||||
|
glXDestroyContext(GLWin.dpy, GLWin.ctx);
|
||||||
|
XCloseDisplay(GLWin.dpy);
|
||||||
|
GLWin.ctx = NULL;
|
||||||
|
}
|
||||||
|
=======
|
||||||
if (GLWin.ctx)
|
if (GLWin.ctx)
|
||||||
{
|
{
|
||||||
if (!glXMakeCurrent(GLWin.dpy, None, NULL))
|
if (!glXMakeCurrent(GLWin.dpy, None, NULL))
|
||||||
|
@ -732,6 +723,7 @@ void OpenGL_Shutdown()
|
||||||
XCloseDisplay(GLWin.dpy);
|
XCloseDisplay(GLWin.dpy);
|
||||||
GLWin.ctx = NULL;
|
GLWin.ctx = NULL;
|
||||||
}
|
}
|
||||||
|
>>>>>>> .r2724
|
||||||
#if defined(HAVE_XXF86VM) && HAVE_XXF86VM
|
#if defined(HAVE_XXF86VM) && HAVE_XXF86VM
|
||||||
/* switch back to original desktop resolution if we were in fs */
|
/* switch back to original desktop resolution if we were in fs */
|
||||||
if (GLWin.dpy != NULL) {
|
if (GLWin.dpy != NULL) {
|
||||||
|
@ -744,7 +736,17 @@ void OpenGL_Shutdown()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandleGLError()
|
GLuint OpenGL_ReportGLError(const char *function, const char *file, int line)
|
||||||
|
{
|
||||||
|
GLint err = glGetError();
|
||||||
|
if (err != GL_NO_ERROR)
|
||||||
|
{
|
||||||
|
ERROR_LOG(VIDEO, "%s:%d: (%s) OpenGL error 0x%x - %s\n", file, line, function, err, gluErrorString(err));
|
||||||
|
}
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
void OpenGL_ReportARBProgramError()
|
||||||
{
|
{
|
||||||
const GLubyte* pstr = glGetString(GL_PROGRAM_ERROR_STRING_ARB);
|
const GLubyte* pstr = glGetString(GL_PROGRAM_ERROR_STRING_ARB);
|
||||||
if (pstr != NULL && pstr[0] != 0)
|
if (pstr != NULL && pstr[0] != 0)
|
||||||
|
@ -755,46 +757,28 @@ void HandleGLError()
|
||||||
ERROR_LOG(VIDEO, (char*)pstr);
|
ERROR_LOG(VIDEO, (char*)pstr);
|
||||||
ERROR_LOG(VIDEO, "");
|
ERROR_LOG(VIDEO, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
// check the error status of this framebuffer */
|
|
||||||
GLenum error = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
|
|
||||||
|
|
||||||
// if error != GL_FRAMEBUFFER_COMPLETE_EXT, there's an error of some sort
|
|
||||||
if (!error)
|
|
||||||
return;
|
|
||||||
|
|
||||||
switch(error)
|
|
||||||
{
|
|
||||||
case GL_FRAMEBUFFER_COMPLETE_EXT:
|
|
||||||
break;
|
|
||||||
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT:
|
|
||||||
ERROR_LOG(VIDEO, "Error! missing a required image/buffer attachment!");
|
|
||||||
break;
|
|
||||||
case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT:
|
|
||||||
ERROR_LOG(VIDEO, "Error! has no images/buffers attached!");
|
|
||||||
break;
|
|
||||||
// case GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT:
|
|
||||||
// ERROR_LOG(VIDEO, "Error! has an image/buffer attached in multiple locations!");
|
|
||||||
// break;
|
|
||||||
case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT:
|
|
||||||
ERROR_LOG(VIDEO, "Error! has mismatched image/buffer dimensions!");
|
|
||||||
break;
|
|
||||||
case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT:
|
|
||||||
ERROR_LOG(VIDEO, "Error! colorbuffer attachments have different types!");
|
|
||||||
break;
|
|
||||||
case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT:
|
|
||||||
ERROR_LOG(VIDEO, "Error! trying to draw to non-attached color buffer!");
|
|
||||||
break;
|
|
||||||
case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT:
|
|
||||||
ERROR_LOG(VIDEO, "Error! trying to read from a non-attached color buffer!");
|
|
||||||
break;
|
|
||||||
case GL_FRAMEBUFFER_UNSUPPORTED_EXT:
|
|
||||||
ERROR_LOG(VIDEO, "Error! format is not supported by current graphics card/driver!");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
ERROR_LOG(VIDEO, "*UNKNOWN ERROR* reported from glCheckFramebufferStatusEXT()!");
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool OpenGL_ReportFBOError(const char *function, const char *file, int line)
|
||||||
|
{
|
||||||
|
unsigned int fbo_status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
|
||||||
|
if (fbo_status != GL_FRAMEBUFFER_COMPLETE_EXT)
|
||||||
|
{
|
||||||
|
const char *error = "-";
|
||||||
|
switch (fbo_status)
|
||||||
|
{
|
||||||
|
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT: error = "INCOMPLETE_ATTACHMENT_EXT"; break;
|
||||||
|
case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT: error = "INCOMPLETE_MISSING_ATTACHMENT_EXT"; break;
|
||||||
|
case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT: error = "INCOMPLETE_DIMENSIONS_EXT"; break;
|
||||||
|
case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT: error = "INCOMPLETE_FORMATS_EXT"; break;
|
||||||
|
case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT: error = "INCOMPLETE_DRAW_BUFFER_EXT"; break;
|
||||||
|
case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT: error = "INCOMPLETE_READ_BUFFER_EXT"; break;
|
||||||
|
case GL_FRAMEBUFFER_UNSUPPORTED_EXT: error = "UNSUPPORTED_EXT"; break;
|
||||||
|
}
|
||||||
|
ERROR_LOG(VIDEO, "%s:%d: (%s) OpenGL FBO error - %s\n", file, line, function, error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandleCgError(CGcontext ctx, CGerror err, void* appdata)
|
void HandleCgError(CGcontext ctx, CGerror err, void* appdata)
|
||||||
|
|
|
@ -67,15 +67,6 @@
|
||||||
#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1
|
#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define GL_REPORT_ERROR() { err = glGetError(); if( err != GL_NO_ERROR ) { ERROR_LOG(VIDEO, "%s:%d: gl error 0x%x", __FILE__, (int)__LINE__, err); HandleGLError(); } }
|
|
||||||
|
|
||||||
#if defined(_DEBUG) || defined(DEBUGFAST)
|
|
||||||
#define GL_REPORT_ERRORD() { GLenum err = glGetError(); if( err != GL_NO_ERROR ) { ERROR_LOG(VIDEO, "%s:%d: gl error 0x%x", __FILE__, (int)__LINE__, err); HandleGLError(); } }
|
|
||||||
#else
|
|
||||||
#define GL_REPORT_ERRORD()
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
#if defined(HAVE_X11) && HAVE_X11
|
#if defined(HAVE_X11) && HAVE_X11
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
|
@ -119,6 +110,8 @@ extern GLWindow GLWin;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Public OpenGL util
|
||||||
|
|
||||||
// Initialization / upkeep
|
// Initialization / upkeep
|
||||||
bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _width, int _height);
|
bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _width, int _height);
|
||||||
void OpenGL_Shutdown();
|
void OpenGL_Shutdown();
|
||||||
|
@ -127,12 +120,33 @@ bool OpenGL_MakeCurrent();
|
||||||
void OpenGL_SwapBuffers();
|
void OpenGL_SwapBuffers();
|
||||||
|
|
||||||
// Get status
|
// Get status
|
||||||
bool OpenGL_CheckFBOStatus();
|
|
||||||
u32 OpenGL_GetBackbufferWidth();
|
u32 OpenGL_GetBackbufferWidth();
|
||||||
u32 OpenGL_GetBackbufferHeight();
|
u32 OpenGL_GetBackbufferHeight();
|
||||||
|
|
||||||
// Set things
|
// Set things
|
||||||
void OpenGL_SetWindowText(const char *text);
|
void OpenGL_SetWindowText(const char *text);
|
||||||
|
|
||||||
|
// Error reporting - use the convenient macros.
|
||||||
|
void OpenGL_ReportARBProgramError();
|
||||||
|
GLuint OpenGL_ReportGLError(const char *function, const char *file, int line);
|
||||||
|
bool OpenGL_ReportFBOError(const char *function, const char *file, int line);
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
#define GL_REPORT_ERROR() OpenGL_ReportGLError (__FUNCTION__, __FILE__, __LINE__)
|
||||||
|
#define GL_REPORT_PROGRAM_ERROR() OpenGL_ReportARBProgramError()
|
||||||
|
#define GL_REPORT_FBO_ERROR() OpenGL_ReportFBOError (__FUNCTION__, __FILE__, __LINE__)
|
||||||
|
#else
|
||||||
|
#define GL_REPORT_ERROR() GL_NO_ERROR
|
||||||
|
#define GL_REPORT_PROGRAM_ERROR()
|
||||||
|
#define GL_REPORT_FBO_ERROR()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(_DEBUG) || defined(DEBUGFAST)
|
||||||
|
#define GL_REPORT_ERRORD() OpenGL_ReportGLError(__FUNCTION__, __FILE__, __LINE__)
|
||||||
|
#else
|
||||||
|
#define GL_REPORT_ERRORD() GL_NO_ERROR
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif // GLTEST ??
|
||||||
|
|
||||||
|
#endif // include braces
|
||||||
|
|
|
@ -80,8 +80,7 @@ void PixelShaderCache::Init()
|
||||||
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, s_ColorMatrixProgram);
|
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, s_ColorMatrixProgram);
|
||||||
glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, (GLsizei)strlen(pmatrixprog), pmatrixprog);
|
glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, (GLsizei)strlen(pmatrixprog), pmatrixprog);
|
||||||
|
|
||||||
GLenum err = GL_NO_ERROR;
|
GLenum err = GL_REPORT_ERROR();
|
||||||
GL_REPORT_ERROR();
|
|
||||||
if (err != GL_NO_ERROR) {
|
if (err != GL_NO_ERROR) {
|
||||||
ERROR_LOG(VIDEO, "Failed to create color matrix fragment program");
|
ERROR_LOG(VIDEO, "Failed to create color matrix fragment program");
|
||||||
glDeleteProgramsARB(1, &s_ColorMatrixProgram);
|
glDeleteProgramsARB(1, &s_ColorMatrixProgram);
|
||||||
|
@ -178,6 +177,12 @@ void PixelShaderCache::ProgressiveCleanup()
|
||||||
|
|
||||||
bool PixelShaderCache::CompilePixelShader(FRAGMENTSHADER& ps, const char* pstrprogram)
|
bool PixelShaderCache::CompilePixelShader(FRAGMENTSHADER& ps, const char* pstrprogram)
|
||||||
{
|
{
|
||||||
|
GLenum err = GL_REPORT_ERROR();
|
||||||
|
if (err != GL_NO_ERROR)
|
||||||
|
{
|
||||||
|
ERROR_LOG(VIDEO, "glError %08x before PS!", err);
|
||||||
|
}
|
||||||
|
|
||||||
char stropt[128];
|
char stropt[128];
|
||||||
sprintf(stropt, "MaxLocalParams=32,NumInstructionSlots=%d", s_nMaxPixelInstructions);
|
sprintf(stropt, "MaxLocalParams=32,NumInstructionSlots=%d", s_nMaxPixelInstructions);
|
||||||
const char *opts[] = {"-profileopts", stropt, "-O2", "-q", NULL};
|
const char *opts[] = {"-profileopts", stropt, "-O2", "-q", NULL};
|
||||||
|
@ -218,9 +223,24 @@ bool PixelShaderCache::CompilePixelShader(FRAGMENTSHADER& ps, const char* pstrpr
|
||||||
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, ps.glprogid);
|
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, ps.glprogid);
|
||||||
glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, (GLsizei)strlen(pcompiledprog), pcompiledprog);
|
glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, (GLsizei)strlen(pcompiledprog), pcompiledprog);
|
||||||
|
|
||||||
GLenum err = GL_NO_ERROR;
|
err = GL_REPORT_ERROR();
|
||||||
GL_REPORT_ERROR();
|
if (err != GL_NO_ERROR)
|
||||||
if (err != GL_NO_ERROR) {
|
{
|
||||||
|
GLint error_pos, native_limit;
|
||||||
|
glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &error_pos);
|
||||||
|
glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB, &native_limit);
|
||||||
|
// Error occur
|
||||||
|
if (error_pos != -1) {
|
||||||
|
const char *program_error = (const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB);
|
||||||
|
char line[256];
|
||||||
|
strncpy(line, (const char *)pcompiledprog + error_pos, 255);
|
||||||
|
line[255] = 0;
|
||||||
|
ERROR_LOG(VIDEO, "Error at %i: %s", error_pos, program_error);
|
||||||
|
ERROR_LOG(VIDEO, "Line dump: \n%s", line);
|
||||||
|
} else if (native_limit != -1) {
|
||||||
|
ERROR_LOG(VIDEO, "Hit limit? %i", native_limit);
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
ERROR_LOG(VIDEO, pstrprogram);
|
ERROR_LOG(VIDEO, pstrprogram);
|
||||||
ERROR_LOG(VIDEO, pcompiledprog);
|
ERROR_LOG(VIDEO, pcompiledprog);
|
||||||
}
|
}
|
||||||
|
|
|
@ -156,7 +156,6 @@ void SetDefaultRectTexParams()
|
||||||
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
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);
|
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
if (glGetError() != GL_NO_ERROR) {
|
if (glGetError() != GL_NO_ERROR) {
|
||||||
GLenum err;
|
|
||||||
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP);
|
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP);
|
||||||
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP);
|
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP);
|
||||||
GL_REPORT_ERROR();
|
GL_REPORT_ERROR();
|
||||||
|
@ -188,7 +187,6 @@ bool Renderer::Init()
|
||||||
s_MSAASamples = 1;
|
s_MSAASamples = 1;
|
||||||
}
|
}
|
||||||
GLint numvertexattribs = 0;
|
GLint numvertexattribs = 0;
|
||||||
GLenum err = GL_NO_ERROR;
|
|
||||||
g_cgcontext = cgCreateContext();
|
g_cgcontext = cgCreateContext();
|
||||||
|
|
||||||
cgGetError();
|
cgGetError();
|
||||||
|
@ -264,12 +262,17 @@ bool Renderer::Init()
|
||||||
if (max_texture_size < 1024) {
|
if (max_texture_size < 1024) {
|
||||||
ERROR_LOG(VIDEO, "GL_MAX_TEXTURE_SIZE too small at %i - must be at least 1024", max_texture_size);
|
ERROR_LOG(VIDEO, "GL_MAX_TEXTURE_SIZE too small at %i - must be at least 1024", max_texture_size);
|
||||||
}
|
}
|
||||||
GL_REPORT_ERROR();
|
|
||||||
if (err != GL_NO_ERROR) bSuccess = false;
|
if (GL_REPORT_ERROR() != GL_NO_ERROR)
|
||||||
|
bSuccess = false;
|
||||||
|
|
||||||
if (glDrawBuffers == NULL && !GLEW_ARB_draw_buffers)
|
if (glDrawBuffers == NULL && !GLEW_ARB_draw_buffers)
|
||||||
glDrawBuffers = glDrawBuffersARB;
|
glDrawBuffers = glDrawBuffersARB;
|
||||||
|
|
||||||
|
if (!GLEW_ARB_texture_non_power_of_two) {
|
||||||
|
WARN_LOG(VIDEO, "ARB_texture_non_power_of_two not supported. This extension is not yet used, though.");
|
||||||
|
}
|
||||||
|
|
||||||
// The size of the framebuffer targets should really NOT be the size of the OpenGL viewport.
|
// The size of the framebuffer targets should really NOT be the size of the OpenGL viewport.
|
||||||
// The EFB is larger than 640x480 - in fact, it's 640x528, give or take a couple of lines.
|
// The EFB is larger than 640x480 - in fact, it's 640x528, give or take a couple of lines.
|
||||||
// So the below is wrong.
|
// So the below is wrong.
|
||||||
|
@ -300,7 +303,6 @@ bool Renderer::Init()
|
||||||
// Create our main color render target as a texture rectangle of the desired size.
|
// Create our main color render target as a texture rectangle of the desired size.
|
||||||
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, 4, s_targetwidth, s_targetheight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, 4, s_targetwidth, s_targetheight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||||
SetDefaultRectTexParams();
|
SetDefaultRectTexParams();
|
||||||
GL_REPORT_ERROR();
|
|
||||||
|
|
||||||
GLint nMaxMRT = 0;
|
GLint nMaxMRT = 0;
|
||||||
glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, &nMaxMRT);
|
glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, &nMaxMRT);
|
||||||
|
@ -318,12 +320,11 @@ bool Renderer::Init()
|
||||||
glGenRenderbuffersEXT(1, &s_DepthTarget);
|
glGenRenderbuffersEXT(1, &s_DepthTarget);
|
||||||
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, s_DepthTarget);
|
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, s_DepthTarget);
|
||||||
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH24_STENCIL8_EXT, s_targetwidth, s_targetheight);
|
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH24_STENCIL8_EXT, s_targetwidth, s_targetheight);
|
||||||
GL_REPORT_ERROR();
|
|
||||||
|
|
||||||
// Our framebuffer object is still bound here. Attach the two render targets, color and Z/stencil, to the framebuffer object.
|
// Our framebuffer object is still bound here. Attach the two render targets, color and Z/stencil, to the framebuffer object.
|
||||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_RECTANGLE_ARB, s_RenderTarget, 0);
|
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_RECTANGLE_ARB, s_RenderTarget, 0);
|
||||||
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, s_DepthTarget);
|
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, s_DepthTarget);
|
||||||
GL_REPORT_ERROR();
|
GL_REPORT_FBO_ERROR();
|
||||||
|
|
||||||
if (s_FakeZTarget != 0) {
|
if (s_FakeZTarget != 0) {
|
||||||
// We do a simple test to make sure that MRT works. I don't really know why - this is probably a workaround for
|
// We do a simple test to make sure that MRT works. I don't really know why - this is probably a workaround for
|
||||||
|
@ -371,7 +372,7 @@ bool Renderer::Init()
|
||||||
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, s_RenderTarget);
|
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, s_RenderTarget);
|
||||||
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT1_EXT, GL_RENDERBUFFER_EXT, s_FakeZTarget);
|
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT1_EXT, GL_RENDERBUFFER_EXT, s_FakeZTarget);
|
||||||
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, s_DepthTarget);
|
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, s_DepthTarget);
|
||||||
OpenGL_CheckFBOStatus();
|
GL_REPORT_FBO_ERROR();
|
||||||
|
|
||||||
bool bFailed = glGetError() != GL_NO_ERROR || glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) != GL_FRAMEBUFFER_COMPLETE_EXT;
|
bool bFailed = glGetError() != GL_NO_ERROR || glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) != GL_FRAMEBUFFER_COMPLETE_EXT;
|
||||||
if (bFailed) PanicAlert("Incomplete rt");
|
if (bFailed) PanicAlert("Incomplete rt");
|
||||||
|
@ -401,19 +402,21 @@ bool Renderer::Init()
|
||||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT1_EXT, GL_TEXTURE_RECTANGLE_ARB, s_ResolvedFakeZTarget, 0);
|
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT1_EXT, GL_TEXTURE_RECTANGLE_ARB, s_ResolvedFakeZTarget, 0);
|
||||||
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, s_ResolvedDepthTarget);
|
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, s_ResolvedDepthTarget);
|
||||||
|
|
||||||
OpenGL_CheckFBOStatus();
|
GL_REPORT_FBO_ERROR();
|
||||||
|
|
||||||
bFailed = glGetError() != GL_NO_ERROR || glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) != GL_FRAMEBUFFER_COMPLETE_EXT;
|
bFailed = glGetError() != GL_NO_ERROR || glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) != GL_FRAMEBUFFER_COMPLETE_EXT;
|
||||||
if (bFailed) PanicAlert("Incomplete rt2");
|
if (bFailed) PanicAlert("Incomplete rt2");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (GL_REPORT_ERROR() != GL_NO_ERROR)
|
||||||
|
bSuccess = false;
|
||||||
|
|
||||||
// glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, s_uFramebuffer);
|
// glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, s_uFramebuffer);
|
||||||
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
|
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
|
||||||
|
|
||||||
nZBufferRender = 0; // Initialize the Z render shutoff countdown. We only render Z if it's desired, to save GPU power.
|
nZBufferRender = 0; // Initialize the Z render shutoff countdown. We only render Z if it's desired, to save GPU power.
|
||||||
|
|
||||||
GL_REPORT_ERROR();
|
if (GL_REPORT_ERROR() != GL_NO_ERROR)
|
||||||
if (err != GL_NO_ERROR)
|
|
||||||
bSuccess = false;
|
bSuccess = false;
|
||||||
|
|
||||||
s_pfont = new RasterFont();
|
s_pfont = new RasterFont();
|
||||||
|
@ -504,10 +507,6 @@ bool Renderer::InitializeGL()
|
||||||
|
|
||||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 4); // 4-byte pixel alignment
|
glPixelStorei(GL_UNPACK_ALIGNMENT, 4); // 4-byte pixel alignment
|
||||||
|
|
||||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // perspective correct interpolation of colors and tex coords
|
|
||||||
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
|
|
||||||
glHint(GL_POLYGON_SMOOTH_HINT, GL_DONT_CARE); // Polygon smoothing is ancient junk that doesn't work anymore. MSAA is modern AA.
|
|
||||||
|
|
||||||
glDisable(GL_STENCIL_TEST);
|
glDisable(GL_STENCIL_TEST);
|
||||||
glEnable(GL_SCISSOR_TEST);
|
glEnable(GL_SCISSOR_TEST);
|
||||||
|
|
||||||
|
@ -525,10 +524,7 @@ bool Renderer::InitializeGL()
|
||||||
glClientActiveTexture(GL_TEXTURE0);
|
glClientActiveTexture(GL_TEXTURE0);
|
||||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||||
|
|
||||||
GLenum err = GL_NO_ERROR;
|
return GL_REPORT_ERROR() == GL_NO_ERROR;
|
||||||
GL_REPORT_ERROR();
|
|
||||||
|
|
||||||
return err == GL_NO_ERROR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -800,13 +796,13 @@ void Renderer::FlushZBufferAlphaToTarget()
|
||||||
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE);
|
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE);
|
||||||
glViewport(0, 0, GetTargetWidth(), GetTargetHeight());
|
glViewport(0, 0, GetTargetWidth(), GetTargetHeight());
|
||||||
|
|
||||||
// texture map s_RenderTargets[s_curtarget] onto the main buffer
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
|
||||||
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, s_FakeZTarget);
|
|
||||||
TextureMngr::EnableTexRECT(0);
|
|
||||||
// disable all other stages
|
// disable all other stages
|
||||||
for (int i = 1; i < 8; ++i)
|
for (int i = 1; i < 8; ++i)
|
||||||
TextureMngr::DisableStage(i);
|
TextureMngr::DisableStage(i);
|
||||||
|
// texture map s_RenderTargets[s_curtarget] onto the main buffer
|
||||||
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
glEnable(GL_TEXTURE_RECTANGLE_ARB);
|
||||||
|
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, s_FakeZTarget);
|
||||||
GL_REPORT_ERRORD();
|
GL_REPORT_ERRORD();
|
||||||
|
|
||||||
// setup the stencil to only accept pixels that have been written
|
// setup the stencil to only accept pixels that have been written
|
||||||
|
@ -1053,11 +1049,11 @@ void Renderer::Swap(const TRectangle& rc)
|
||||||
|
|
||||||
// Texture map s_RenderTargets[s_curtarget] onto the main buffer
|
// Texture map s_RenderTargets[s_curtarget] onto the main buffer
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
glEnable(GL_TEXTURE_RECTANGLE_ARB);
|
||||||
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, s_RenderTarget);
|
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, s_RenderTarget);
|
||||||
// Use linear filtering.
|
// Use linear filtering.
|
||||||
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
TextureMngr::EnableTexRECT(0);
|
|
||||||
|
|
||||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
|
@ -1256,6 +1252,13 @@ void Renderer::SwapBuffers()
|
||||||
fpscount = 0;
|
fpscount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < 8; i++) {
|
||||||
|
glActiveTexture(GL_TEXTURE0 + i);
|
||||||
|
glDisable(GL_TEXTURE_2D);
|
||||||
|
glDisable(GL_TEXTURE_RECTANGLE_ARB);
|
||||||
|
}
|
||||||
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
|
||||||
DrawDebugText();
|
DrawDebugText();
|
||||||
|
|
||||||
OSD::DrawMessages();
|
OSD::DrawMessages();
|
||||||
|
@ -1302,6 +1305,7 @@ void Renderer::SwapBuffers()
|
||||||
Renderer::SetRenderMode(RM_Normal); // turn off any zwrites
|
Renderer::SetRenderMode(RM_Normal); // turn off any zwrites
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
GL_REPORT_ERRORD();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::RenderText(const char* pstr, int left, int top, u32 color)
|
void Renderer::RenderText(const char* pstr, int left, int top, u32 color)
|
||||||
|
|
|
@ -171,8 +171,12 @@ void EncodeToRamUsingShader(FRAGMENTSHADER& shader, GLuint srcTexture, const TRe
|
||||||
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, s_dstRenderBuffer);
|
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, s_dstRenderBuffer);
|
||||||
GL_REPORT_ERRORD();
|
GL_REPORT_ERRORD();
|
||||||
|
|
||||||
|
for (int i = 1; i < 8; ++i)
|
||||||
|
TextureMngr::DisableStage(i);
|
||||||
|
|
||||||
// set source texture
|
// set source texture
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
glEnable(GL_TEXTURE_RECTANGLE_ARB);
|
||||||
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, srcTexture);
|
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, srcTexture);
|
||||||
|
|
||||||
if (linearFilter)
|
if (linearFilter)
|
||||||
|
@ -185,10 +189,6 @@ void EncodeToRamUsingShader(FRAGMENTSHADER& shader, GLuint srcTexture, const TRe
|
||||||
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureMngr::EnableTexRECT(0);
|
|
||||||
for (int i = 1; i < 8; ++i)
|
|
||||||
TextureMngr::DisableStage(i);
|
|
||||||
GL_REPORT_ERRORD();
|
GL_REPORT_ERRORD();
|
||||||
|
|
||||||
glViewport(0, 0, (GLsizei)dstWidth, (GLsizei)dstHeight);
|
glViewport(0, 0, (GLsizei)dstWidth, (GLsizei)dstHeight);
|
||||||
|
@ -317,18 +317,18 @@ void DecodeToTexture(u8* srcAddr, int srcWidth, int srcHeight, GLuint destTextur
|
||||||
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, destTexture);
|
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, destTexture);
|
||||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_RECTANGLE_ARB, destTexture, 0);
|
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_RECTANGLE_ARB, destTexture, 0);
|
||||||
|
|
||||||
|
for (int i = 1; i < 8; ++i)
|
||||||
|
TextureMngr::DisableStage(i);
|
||||||
|
|
||||||
// activate source texture
|
// activate source texture
|
||||||
// set srcAddr as data for source texture
|
// set srcAddr as data for source texture
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
glEnable(GL_TEXTURE_RECTANGLE_ARB);
|
||||||
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, s_srcTexture);
|
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, s_srcTexture);
|
||||||
|
|
||||||
// TODO: make this less slow. (How?)
|
// TODO: make this less slow. (How?)
|
||||||
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8, (GLsizei)srcFmtWidth, (GLsizei)srcHeight, 0, GL_BGRA, GL_UNSIGNED_BYTE, srcAddr);
|
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8, (GLsizei)srcFmtWidth, (GLsizei)srcHeight, 0, GL_BGRA, GL_UNSIGNED_BYTE, srcAddr);
|
||||||
|
|
||||||
TextureMngr::EnableTexRECT(0);
|
|
||||||
for (int i = 1; i < 8; ++i)
|
|
||||||
TextureMngr::DisableStage(i);
|
|
||||||
|
|
||||||
glViewport(0, 0, srcWidth, srcHeight);
|
glViewport(0, 0, srcWidth, srcHeight);
|
||||||
|
|
||||||
glEnable(GL_FRAGMENT_PROGRAM_ARB);
|
glEnable(GL_FRAGMENT_PROGRAM_ARB);
|
||||||
|
|
|
@ -51,7 +51,6 @@
|
||||||
u8 *TextureMngr::temp = NULL;
|
u8 *TextureMngr::temp = NULL;
|
||||||
TextureMngr::TexCache TextureMngr::textures;
|
TextureMngr::TexCache TextureMngr::textures;
|
||||||
std::map<u32, TextureMngr::DEPTHTARGET> TextureMngr::mapDepthTargets;
|
std::map<u32, TextureMngr::DEPTHTARGET> TextureMngr::mapDepthTargets;
|
||||||
int TextureMngr::nTex2DEnabled, TextureMngr::nTexRECTEnabled;
|
|
||||||
|
|
||||||
extern int frameCount;
|
extern int frameCount;
|
||||||
static u32 s_TempFramebuffer = 0;
|
static u32 s_TempFramebuffer = 0;
|
||||||
|
@ -59,7 +58,7 @@ static u32 s_TempFramebuffer = 0;
|
||||||
#define TEMP_SIZE (1024*1024*4)
|
#define TEMP_SIZE (1024*1024*4)
|
||||||
#define TEXTURE_KILL_THRESHOLD 200
|
#define TEXTURE_KILL_THRESHOLD 200
|
||||||
|
|
||||||
const GLint c_MinLinearFilter[8] = {
|
static const GLint c_MinLinearFilter[8] = {
|
||||||
GL_NEAREST,
|
GL_NEAREST,
|
||||||
GL_NEAREST_MIPMAP_NEAREST,
|
GL_NEAREST_MIPMAP_NEAREST,
|
||||||
GL_NEAREST_MIPMAP_LINEAR,
|
GL_NEAREST_MIPMAP_LINEAR,
|
||||||
|
@ -67,14 +66,14 @@ const GLint c_MinLinearFilter[8] = {
|
||||||
GL_LINEAR,
|
GL_LINEAR,
|
||||||
GL_LINEAR_MIPMAP_NEAREST,
|
GL_LINEAR_MIPMAP_NEAREST,
|
||||||
GL_LINEAR_MIPMAP_LINEAR,
|
GL_LINEAR_MIPMAP_LINEAR,
|
||||||
GL_LINEAR
|
GL_LINEAR,
|
||||||
};
|
};
|
||||||
|
|
||||||
const GLint c_WrapSettings[4] = {
|
static const GLint c_WrapSettings[4] = {
|
||||||
GL_CLAMP_TO_EDGE,
|
GL_CLAMP_TO_EDGE,
|
||||||
GL_REPEAT,
|
GL_REPEAT,
|
||||||
GL_MIRRORED_REPEAT,
|
GL_MIRRORED_REPEAT,
|
||||||
GL_REPEAT
|
GL_REPEAT,
|
||||||
};
|
};
|
||||||
|
|
||||||
bool SaveTexture(const char* filename, u32 textarget, u32 tex, int width, int height)
|
bool SaveTexture(const char* filename, u32 textarget, u32 tex, int width, int height)
|
||||||
|
@ -82,8 +81,7 @@ bool SaveTexture(const char* filename, u32 textarget, u32 tex, int width, int he
|
||||||
std::vector<u32> data(width * height);
|
std::vector<u32> data(width * height);
|
||||||
glBindTexture(textarget, tex);
|
glBindTexture(textarget, tex);
|
||||||
glGetTexImage(textarget, 0, GL_BGRA, GL_UNSIGNED_BYTE, &data[0]);
|
glGetTexImage(textarget, 0, GL_BGRA, GL_UNSIGNED_BYTE, &data[0]);
|
||||||
GLenum err;
|
GLenum err = GL_REPORT_ERROR();
|
||||||
GL_REPORT_ERROR();
|
|
||||||
if (err != GL_NO_ERROR)
|
if (err != GL_NO_ERROR)
|
||||||
{
|
{
|
||||||
PanicAlert("Can't save texture, GL Error: %s", gluErrorString(err));
|
PanicAlert("Can't save texture, GL Error: %s", gluErrorString(err));
|
||||||
|
@ -157,7 +155,6 @@ void TextureMngr::TCacheEntry::Destroy(bool shutdown)
|
||||||
void TextureMngr::Init()
|
void TextureMngr::Init()
|
||||||
{
|
{
|
||||||
temp = (u8*)AllocateMemoryPages(TEMP_SIZE);
|
temp = (u8*)AllocateMemoryPages(TEMP_SIZE);
|
||||||
nTex2DEnabled = nTexRECTEnabled = 0;
|
|
||||||
TexDecoder_SetTexFmtOverlayOptions(g_Config.bTexFmtOverlayEnable, g_Config.bTexFmtOverlayCenter);
|
TexDecoder_SetTexFmtOverlayOptions(g_Config.bTexFmtOverlayEnable, g_Config.bTexFmtOverlayCenter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -307,7 +304,7 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
|
||||||
if (entry.isRenderTarget || ((address == entry.addr) && (hash_value == entry.hash)))
|
if (entry.isRenderTarget || ((address == entry.addr) && (hash_value == entry.hash)))
|
||||||
{
|
{
|
||||||
entry.frameCount = frameCount;
|
entry.frameCount = frameCount;
|
||||||
//glEnable(entry.isNonPow2?GL_TEXTURE_RECTANGLE_ARB:GL_TEXTURE_2D);
|
glEnable(entry.isNonPow2 ? GL_TEXTURE_RECTANGLE_ARB : GL_TEXTURE_2D);
|
||||||
// entry.isNonPow2 ? TextureMngr::EnableTex2D(texstage) : TextureMngr::EnableTexRECT(texstage);
|
// entry.isNonPow2 ? TextureMngr::EnableTex2D(texstage) : TextureMngr::EnableTexRECT(texstage);
|
||||||
glBindTexture(entry.isNonPow2 ? GL_TEXTURE_RECTANGLE_ARB : GL_TEXTURE_2D, entry.texture);
|
glBindTexture(entry.isNonPow2 ? GL_TEXTURE_RECTANGLE_ARB : GL_TEXTURE_2D, entry.texture);
|
||||||
if (entry.mode.hex != tm0.hex)
|
if (entry.mode.hex != tm0.hex)
|
||||||
|
@ -475,14 +472,13 @@ void TextureMngr::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, bool
|
||||||
{
|
{
|
||||||
_assert_(entry.texture);
|
_assert_(entry.texture);
|
||||||
bool bReInit = true;
|
bool bReInit = true;
|
||||||
|
GL_REPORT_ERROR();
|
||||||
if (entry.w == w && entry.h == h)
|
if (entry.w == w && entry.h == h)
|
||||||
{
|
{
|
||||||
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, entry.texture);
|
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, entry.texture);
|
||||||
// for some reason mario sunshine errors here...
|
// for some reason mario sunshine errors here...
|
||||||
// Beyond Good and Evil does too, occasionally.
|
// Beyond Good and Evil does too, occasionally.
|
||||||
GLenum err = GL_NO_ERROR;
|
GLenum err = GL_REPORT_ERROR();
|
||||||
GL_REPORT_ERROR();
|
|
||||||
if (err == GL_NO_ERROR)
|
if (err == GL_NO_ERROR)
|
||||||
bReInit = false;
|
bReInit = false;
|
||||||
}
|
}
|
||||||
|
@ -651,7 +647,6 @@ void TextureMngr::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, bool
|
||||||
GL_REPORT_ERRORD();
|
GL_REPORT_ERRORD();
|
||||||
|
|
||||||
// We have to run a pixel shader, for color conversion.
|
// We have to run a pixel shader, for color conversion.
|
||||||
|
|
||||||
Renderer::ResetGLState(); // reset any game specific settings
|
Renderer::ResetGLState(); // reset any game specific settings
|
||||||
|
|
||||||
if (s_TempFramebuffer == 0)
|
if (s_TempFramebuffer == 0)
|
||||||
|
@ -685,9 +680,7 @@ void TextureMngr::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, bool
|
||||||
|
|
||||||
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
|
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
glEnable(GL_TEXTURE_RECTANGLE_ARB);
|
||||||
TextureMngr::EnableTexRECT(0);
|
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, read_texture);
|
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, read_texture);
|
||||||
|
|
||||||
glViewport(0, 0, w, h);
|
glViewport(0, 0, w, h);
|
||||||
|
@ -727,46 +720,12 @@ void TextureMngr::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, bool
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureMngr::EnableTex2D(int stage)
|
|
||||||
{
|
|
||||||
if (nTexRECTEnabled & (1<<stage)) {
|
|
||||||
nTexRECTEnabled &= ~(1<<stage);
|
|
||||||
glDisable(GL_TEXTURE_RECTANGLE_ARB);
|
|
||||||
}
|
|
||||||
if (!(nTex2DEnabled & (1<<stage))) {
|
|
||||||
nTex2DEnabled |= (1<<stage);
|
|
||||||
glEnable(GL_TEXTURE_2D);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void TextureMngr::EnableTexRECT(int stage)
|
|
||||||
{
|
|
||||||
if ((nTex2DEnabled & (1 << stage))) {
|
|
||||||
nTex2DEnabled &= ~(1 << stage);
|
|
||||||
glDisable(GL_TEXTURE_2D);
|
|
||||||
}
|
|
||||||
if (!(nTexRECTEnabled & (1 << stage))) {
|
|
||||||
nTexRECTEnabled |= (1 << stage);
|
|
||||||
glEnable(GL_TEXTURE_RECTANGLE_ARB);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void TextureMngr::DisableStage(int stage)
|
void TextureMngr::DisableStage(int stage)
|
||||||
{
|
{
|
||||||
bool bset = false;
|
|
||||||
if (nTex2DEnabled & (1 << stage)) {
|
|
||||||
nTex2DEnabled &= ~(1 << stage);
|
|
||||||
glActiveTexture(GL_TEXTURE0 + stage);
|
glActiveTexture(GL_TEXTURE0 + stage);
|
||||||
glDisable(GL_TEXTURE_2D);
|
glDisable(GL_TEXTURE_2D);
|
||||||
bset = true;
|
|
||||||
}
|
|
||||||
if (nTexRECTEnabled & (1<<stage)) {
|
|
||||||
nTexRECTEnabled &= ~(1 << stage);
|
|
||||||
if (!bset)
|
|
||||||
glActiveTexture(GL_TEXTURE0 + stage);
|
|
||||||
glDisable(GL_TEXTURE_RECTANGLE_ARB);
|
glDisable(GL_TEXTURE_RECTANGLE_ARB);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void TextureMngr::ClearRenderTargets()
|
void TextureMngr::ClearRenderTargets()
|
||||||
{
|
{
|
||||||
|
|
|
@ -68,7 +68,6 @@ private:
|
||||||
static u8 *temp;
|
static u8 *temp;
|
||||||
static TexCache textures;
|
static TexCache textures;
|
||||||
static std::map<u32, DEPTHTARGET> mapDepthTargets;
|
static std::map<u32, DEPTHTARGET> mapDepthTargets;
|
||||||
static int nTex2DEnabled, nTexRECTEnabled;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void Init();
|
static void Init();
|
||||||
|
@ -80,8 +79,6 @@ public:
|
||||||
static TCacheEntry* Load(int texstage, u32 address, int width, int height, int format, int tlutaddr, int tlutfmt);
|
static TCacheEntry* Load(int texstage, u32 address, int width, int height, int format, int tlutaddr, int tlutfmt);
|
||||||
static void CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, bool bIsIntensityFmt, u32 copyfmt, bool bScaleByHalf, const TRectangle &source);
|
static void CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, bool bIsIntensityFmt, u32 copyfmt, bool bScaleByHalf, const TRectangle &source);
|
||||||
|
|
||||||
static void EnableTex2D(int stage);
|
|
||||||
static void EnableTexRECT(int stage);
|
|
||||||
static void DisableStage(int stage); // sets active texture
|
static void DisableStage(int stage); // sets active texture
|
||||||
|
|
||||||
static void ClearRenderTargets(); // sets render target value of all textures to false
|
static void ClearRenderTargets(); // sets render target value of all textures to false
|
||||||
|
|
|
@ -175,7 +175,6 @@ void Flush()
|
||||||
GL_REPORT_ERRORD();
|
GL_REPORT_ERRORD();
|
||||||
|
|
||||||
// set the textures
|
// set the textures
|
||||||
{
|
|
||||||
DVSTARTSUBPROFILE("VertexManager::Flush:textures");
|
DVSTARTSUBPROFILE("VertexManager::Flush:textures");
|
||||||
|
|
||||||
u32 usedtextures = 0;
|
u32 usedtextures = 0;
|
||||||
|
@ -209,14 +208,13 @@ void Flush()
|
||||||
nonpow2tex |= 1 << i;
|
nonpow2tex |= 1 << i;
|
||||||
if (tentry->mode.wrap_s > 0) nonpow2tex |= 1 << (8 + i);
|
if (tentry->mode.wrap_s > 0) nonpow2tex |= 1 << (8 + i);
|
||||||
if (tentry->mode.wrap_t > 0) nonpow2tex |= 1 << (16 + i);
|
if (tentry->mode.wrap_t > 0) nonpow2tex |= 1 << (16 + i);
|
||||||
TextureMngr::EnableTexRECT(i);
|
|
||||||
}
|
}
|
||||||
// if texture is power of two, set to ones (since don't need scaling)
|
// if texture is power of two, set to ones (since don't need scaling)
|
||||||
// (the above seems to have changed - we set the width and height here too.
|
// (the above seems to have changed - we set the width and height here too.
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// 0s are probably for no manual wrapping needed.
|
||||||
PixelShaderManager::SetTexDims(i, tentry->w, tentry->h, 0, 0);
|
PixelShaderManager::SetTexDims(i, tentry->w, tentry->h, 0, 0);
|
||||||
TextureMngr::EnableTex2D(i);
|
|
||||||
}
|
}
|
||||||
if (g_Config.iLog & CONF_SAVETEXTURES) {
|
if (g_Config.iLog & CONF_SAVETEXTURES) {
|
||||||
// save the textures
|
// save the textures
|
||||||
|
@ -226,17 +224,12 @@ void Flush()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ERROR_LOG(VIDEO, "error loading tex");
|
ERROR_LOG(VIDEO, "error loading tex\n");
|
||||||
TextureMngr::DisableStage(i); // disable since won't be used
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
TextureMngr::DisableStage(i); // disable since won't be used
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PixelShaderManager::SetTexturesUsed(nonpow2tex);
|
PixelShaderManager::SetTexturesUsed(nonpow2tex);
|
||||||
}
|
|
||||||
|
|
||||||
FRAGMENTSHADER* ps = PixelShaderCache::GetShader(false);
|
FRAGMENTSHADER* ps = PixelShaderCache::GetShader(false);
|
||||||
VERTEXSHADER* vs = VertexShaderCache::GetShader(g_nativeVertexFmt->m_components);
|
VERTEXSHADER* vs = VertexShaderCache::GetShader(g_nativeVertexFmt->m_components);
|
||||||
|
@ -245,7 +238,9 @@ void Flush()
|
||||||
if (Renderer::UseFakeZTarget()) {
|
if (Renderer::UseFakeZTarget()) {
|
||||||
if (bpmem.zmode.updateenable) {
|
if (bpmem.zmode.updateenable) {
|
||||||
if (!bpmem.blendmode.colorupdate) {
|
if (!bpmem.blendmode.colorupdate) {
|
||||||
Renderer::SetRenderMode(bpmem.blendmode.alphaupdate ? Renderer::RM_ZBufferAlpha : Renderer::RM_ZBufferOnly);
|
Renderer::SetRenderMode(bpmem.blendmode.alphaupdate ?
|
||||||
|
Renderer::RM_ZBufferAlpha :
|
||||||
|
Renderer::RM_ZBufferOnly);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -134,6 +134,13 @@ void VertexShaderCache::ProgressiveCleanup()
|
||||||
|
|
||||||
bool VertexShaderCache::CompileVertexShader(VERTEXSHADER& vs, const char* pstrprogram)
|
bool VertexShaderCache::CompileVertexShader(VERTEXSHADER& vs, const char* pstrprogram)
|
||||||
{
|
{
|
||||||
|
// Reset GL error before compiling shaders. Yeah, we need to investigate the causes of these.
|
||||||
|
GLenum err = GL_REPORT_ERROR();
|
||||||
|
if (err != GL_NO_ERROR)
|
||||||
|
{
|
||||||
|
ERROR_LOG(VIDEO, "glError %08x before VS!", err);
|
||||||
|
}
|
||||||
|
|
||||||
char stropt[64];
|
char stropt[64];
|
||||||
sprintf(stropt, "MaxLocalParams=256,MaxInstructions=%d", s_nMaxVertexInstructions);
|
sprintf(stropt, "MaxLocalParams=256,MaxInstructions=%d", s_nMaxVertexInstructions);
|
||||||
const char *opts[] = {"-profileopts", stropt, "-O2", "-q", NULL};
|
const char *opts[] = {"-profileopts", stropt, "-O2", "-q", NULL};
|
||||||
|
@ -162,8 +169,7 @@ bool VertexShaderCache::CompileVertexShader(VERTEXSHADER& vs, const char* pstrpr
|
||||||
glBindProgramARB(GL_VERTEX_PROGRAM_ARB, vs.glprogid);
|
glBindProgramARB(GL_VERTEX_PROGRAM_ARB, vs.glprogid);
|
||||||
glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, (GLsizei)strlen(pcompiledprog), pcompiledprog);
|
glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, (GLsizei)strlen(pcompiledprog), pcompiledprog);
|
||||||
|
|
||||||
GLenum err = GL_NO_ERROR;
|
err = GL_REPORT_ERROR();
|
||||||
GL_REPORT_ERROR();
|
|
||||||
if (err != GL_NO_ERROR) {
|
if (err != GL_NO_ERROR) {
|
||||||
ERROR_LOG(VIDEO, pstrprogram);
|
ERROR_LOG(VIDEO, pstrprogram);
|
||||||
ERROR_LOG(VIDEO, pcompiledprog);
|
ERROR_LOG(VIDEO, pcompiledprog);
|
||||||
|
|
|
@ -96,11 +96,11 @@ void XFB_Draw(u8 *xfb_in_ram, u32 width, u32 height, s32 yOffset)
|
||||||
|
|
||||||
OpenGL_Update(); // just updates the render window position and the backbuffer size
|
OpenGL_Update(); // just updates the render window position and the backbuffer size
|
||||||
Renderer::ResetGLState();
|
Renderer::ResetGLState();
|
||||||
TextureMngr::EnableTexRECT(0);
|
|
||||||
|
|
||||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); // switch to the backbuffer
|
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); // switch to the backbuffer
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
glEnable(GL_TEXTURE_RECTANGLE_ARB);
|
||||||
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, xfb_decoded_texture);
|
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, xfb_decoded_texture);
|
||||||
|
|
||||||
TRectangle back_rc;
|
TRectangle back_rc;
|
||||||
|
|
|
@ -174,7 +174,7 @@ void RasterFont::printMultilineText(const char *text, double start_x, double sta
|
||||||
{
|
{
|
||||||
double x = start_x;
|
double x = start_x;
|
||||||
double y = start_y;
|
double y = start_y;
|
||||||
static char temp[1024];
|
char temp[1024];
|
||||||
char *t = temp;
|
char *t = temp;
|
||||||
while (*text)
|
while (*text)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue