From e62b7f35cead5778a817a0d61908c29733bb2bc8 Mon Sep 17 00:00:00 2001 From: hrydgard Date: Sun, 22 Mar 2009 11:21:44 +0000 Subject: [PATCH] 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 --- Source/Core/Core/Src/PluginManager.cpp | 6 +- Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp | 208 ++++++++---------- Source/Plugins/Plugin_VideoOGL/Src/GLUtil.h | 34 ++- .../Plugin_VideoOGL/Src/PixelShaderCache.cpp | 30 ++- Source/Plugins/Plugin_VideoOGL/Src/Render.cpp | 54 ++--- .../Plugin_VideoOGL/Src/TextureConverter.cpp | 16 +- .../Plugin_VideoOGL/Src/TextureMngr.cpp | 65 +----- .../Plugins/Plugin_VideoOGL/Src/TextureMngr.h | 3 - .../Plugin_VideoOGL/Src/VertexManager.cpp | 95 ++++---- .../Plugin_VideoOGL/Src/VertexShaderCache.cpp | 10 +- Source/Plugins/Plugin_VideoOGL/Src/XFB.cpp | 2 +- .../Plugin_VideoOGL/Src/rasterfont.cpp | 2 +- 12 files changed, 252 insertions(+), 273 deletions(-) diff --git a/Source/Core/Core/Src/PluginManager.cpp b/Source/Core/Core/Src/PluginManager.cpp index 35517c2bc4..6bc5742a4f 100644 --- a/Source/Core/Core/Src/PluginManager.cpp +++ b/Source/Core/Core/Src/PluginManager.cpp @@ -254,11 +254,11 @@ CPluginInfo::CPluginInfo(const char *_rFilename) m_Valid = true; else PanicAlert("Could not get info about plugin %s", _rFilename); - // We are now done with this plugin and will call FreeLibrary() delete plugin; - } else - PanicAlert("PluginInfo: %s is not valid", _rFilename); + } else { + WARN_LOG(CONSOLE, "PluginInfo: %s is not a valid Dolphin plugin. Ignoring.", _rFilename); + } } /////////////////////////////////////////// diff --git a/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp b/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp index 791a2ae6bb..60a57d208d 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp @@ -93,28 +93,6 @@ void OpenGL_SetWindowText(const char *text) #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 // ------------------ @@ -336,22 +314,22 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight }; 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; } if (!(PixelFormat = ChoosePixelFormat(hDC,&pfd))) { - PanicAlert("(2) Can't Find A Suitable PixelFormat."); + PanicAlert("(2) Can't find a suitable PixelFormat."); return false; } - if (!SetPixelFormat(hDC,PixelFormat,&pfd)) { - PanicAlert("(3) Can't Set The PixelFormat."); + if (!SetPixelFormat(hDC, PixelFormat, &pfd)) { + PanicAlert("(3) Can't set the PixelFormat."); return false; } if (!(hRC = wglCreateContext(hDC))) { - PanicAlert("(4) Can't Create A GL Rendering Context."); + PanicAlert("(4) Can't create an OpenGL rendering context."); return false; } // -------------------------------------- @@ -380,10 +358,11 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight GLX_BLUE_SIZE, 8, GLX_DEPTH_SIZE, 24, GLX_SAMPLE_BUFFERS_ARB, g_Config.iMultisampleMode, GLX_SAMPLES_ARB, 1, None }; - GLWin.dpy = XOpenDisplay(0); - g_VideoInitialize.pWindowHandle = (HWND)GLWin.dpy; - GLWin.screen = DefaultScreen(GLWin.dpy); + GLWin.dpy = XOpenDisplay(0); + g_VideoInitialize.pWindowHandle = (HWND)GLWin.dpy; + GLWin.screen = DefaultScreen(GLWin.dpy); + // Fullscreen option. GLWin.fs = g_Config.bFullscreen; //Set to setting in Options /* get an appropriate visual */ @@ -398,21 +377,20 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight NOTICE_LOG(VIDEO, "Got Doublebuffered Visual!"); } - glXQueryVersion(GLWin.dpy, &glxMajorVersion, &glxMinorVersion); - NOTICE_LOG(VIDEO, "glX-Version %d.%d", glxMajorVersion, glxMinorVersion); - /* create a GLX context */ - GLWin.ctx = glXCreateContext(GLWin.dpy, vi, 0, GL_TRUE); - if(!GLWin.ctx) - { - PanicAlert("Couldn't Create GLX context.Quit"); - exit(0); // TODO: Don't bring down entire Emu - } - /* create a color map */ - cmap = XCreateColormap(GLWin.dpy, RootWindow(GLWin.dpy, vi->screen), - vi->visual, AllocNone); - GLWin.attr.colormap = cmap; - GLWin.attr.border_pixel = 0; - XkbSetDetectableAutoRepeat(GLWin.dpy, True, NULL); + glXQueryVersion(GLWin.dpy, &glxMajorVersion, &glxMinorVersion); + NOTICE_LOG(VIDEO, "glX-Version %d.%d", glxMajorVersion, glxMinorVersion); + // Create a GLX context. + GLWin.ctx = glXCreateContext(GLWin.dpy, vi, 0, GL_TRUE); + if(!GLWin.ctx) + { + PanicAlert("Couldn't Create GLX context.Quit"); + exit(0); // TODO: Don't bring down entire Emu + } + // Create a color map. + cmap = XCreateColormap(GLWin.dpy, RootWindow(GLWin.dpy, vi->screen), vi->visual, AllocNone); + GLWin.attr.colormap = cmap; + GLWin.attr.border_pixel = 0; + XkbSetDetectableAutoRepeat(GLWin.dpy, True, NULL); #if defined(HAVE_XXF86VM) && HAVE_XXF86VM // get a connection @@ -691,36 +669,49 @@ void OpenGL_Shutdown() #if USE_SDL SDL_Quit(); #elif defined(HAVE_COCOA) && HAVE_COCOA - cocoaGLDelete(GLWin.cocoaCtx); + cocoaGLDelete(GLWin.cocoaCtx); #elif defined(USE_WX) && USE_WX - delete GLWin.glCanvas; - delete GLWin.frame; + delete GLWin.glCanvas; + delete GLWin.frame; #elif defined(_WIN32) - if (hRC) // Do We Have A Rendering Context? - { - if (!wglMakeCurrent(NULL,NULL)) // Are We Able To Release The DC And RC Contexts? - { + if (hRC) // Do We Have A Rendering Context? + { + if (!wglMakeCurrent(NULL,NULL)) // Are We Able To Release The DC And RC Contexts? + { // [F|RES]: if this fails i dont see the message box and // cant get out of the modal state so i disable it. // This function fails only if i render to main window - // MessageBox(NULL,"Release Of DC And RC Failed.", "SHUTDOWN ERROR", MB_OK | MB_ICONINFORMATION); - } + // MessageBox(NULL,"Release Of DC And RC Failed.", "SHUTDOWN ERROR", MB_OK | MB_ICONINFORMATION); + } - if (!wglDeleteContext(hRC)) // Are We Able To Delete The RC? - { - ERROR_LOG(VIDEO, "Release Rendering Context Failed."); - } - hRC = NULL; // Set RC To NULL - } + if (!wglDeleteContext(hRC)) // Are We Able To Delete The RC? + { + ERROR_LOG(VIDEO, "Release Rendering Context Failed."); + } + hRC = NULL; // Set RC To NULL + } - if (hDC && !ReleaseDC(EmuWindow::GetWnd(), hDC)) // Are We Able To Release The DC - { - #ifndef SETUP_TIMER_WAITING // This fails - ERROR_LOG(VIDEO, "Release Device Context Failed."); - #endif - hDC = NULL; // Set DC To NULL - } + if (hDC && !ReleaseDC(EmuWindow::GetWnd(), hDC)) // Are We Able To Release The DC + { +#ifndef SETUP_TIMER_WAITING // This fails + ERROR_LOG(VIDEO, "Release Device Context Failed."); +#endif + hDC = NULL; // Set DC To NULL + } #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 (!glXMakeCurrent(GLWin.dpy, None, NULL)) @@ -732,19 +723,30 @@ void OpenGL_Shutdown() XCloseDisplay(GLWin.dpy); GLWin.ctx = NULL; } +>>>>>>> .r2724 #if defined(HAVE_XXF86VM) && HAVE_XXF86VM - /* switch back to original desktop resolution if we were in fs */ - if (GLWin.dpy != NULL) { - if (GLWin.fs) { - XF86VidModeSwitchToMode(GLWin.dpy, GLWin.screen, &GLWin.deskMode); - XF86VidModeSetViewPort(GLWin.dpy, GLWin.screen, 0, 0); - } - } + /* switch back to original desktop resolution if we were in fs */ + if (GLWin.dpy != NULL) { + if (GLWin.fs) { + XF86VidModeSwitchToMode(GLWin.dpy, GLWin.screen, &GLWin.deskMode); + XF86VidModeSetViewPort(GLWin.dpy, GLWin.screen, 0, 0); + } + } #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); if (pstr != NULL && pstr[0] != 0) @@ -755,46 +757,28 @@ void HandleGLError() ERROR_LOG(VIDEO, (char*)pstr); 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) +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) { - 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; + 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) diff --git a/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.h b/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.h index de1a7e10a2..514b23c185 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.h @@ -67,15 +67,6 @@ #define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1 #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 #if defined(HAVE_X11) && HAVE_X11 #include @@ -119,6 +110,8 @@ extern GLWindow GLWin; #endif +// Public OpenGL util + // Initialization / upkeep bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _width, int _height); void OpenGL_Shutdown(); @@ -127,12 +120,33 @@ bool OpenGL_MakeCurrent(); void OpenGL_SwapBuffers(); // Get status -bool OpenGL_CheckFBOStatus(); u32 OpenGL_GetBackbufferWidth(); u32 OpenGL_GetBackbufferHeight(); // Set things 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 + +#if defined(_DEBUG) || defined(DEBUGFAST) +#define GL_REPORT_ERRORD() OpenGL_ReportGLError(__FUNCTION__, __FILE__, __LINE__) +#else +#define GL_REPORT_ERRORD() GL_NO_ERROR #endif + +#endif // GLTEST ?? + +#endif // include braces diff --git a/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp b/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp index f6e0bbe1e8..ce20025391 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp @@ -80,8 +80,7 @@ void PixelShaderCache::Init() glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, s_ColorMatrixProgram); glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, (GLsizei)strlen(pmatrixprog), pmatrixprog); - GLenum err = GL_NO_ERROR; - GL_REPORT_ERROR(); + GLenum err = GL_REPORT_ERROR(); if (err != GL_NO_ERROR) { ERROR_LOG(VIDEO, "Failed to create color matrix fragment program"); glDeleteProgramsARB(1, &s_ColorMatrixProgram); @@ -178,6 +177,12 @@ void PixelShaderCache::ProgressiveCleanup() 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]; sprintf(stropt, "MaxLocalParams=32,NumInstructionSlots=%d", s_nMaxPixelInstructions); 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); glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, (GLsizei)strlen(pcompiledprog), pcompiledprog); - GLenum err = GL_NO_ERROR; - GL_REPORT_ERROR(); - if (err != GL_NO_ERROR) { + err = GL_REPORT_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, pcompiledprog); } diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp index 5bde71c4a2..d7a303b3ba 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp @@ -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_T, GL_CLAMP_TO_EDGE); 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_T, GL_CLAMP); GL_REPORT_ERROR(); @@ -188,7 +187,6 @@ bool Renderer::Init() s_MSAASamples = 1; } GLint numvertexattribs = 0; - GLenum err = GL_NO_ERROR; g_cgcontext = cgCreateContext(); cgGetError(); @@ -264,11 +262,16 @@ bool Renderer::Init() if (max_texture_size < 1024) { 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) 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 EFB is larger than 640x480 - in fact, it's 640x528, give or take a couple of lines. @@ -300,7 +303,6 @@ bool Renderer::Init() // 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); SetDefaultRectTexParams(); - GL_REPORT_ERROR(); GLint nMaxMRT = 0; glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, &nMaxMRT); @@ -318,12 +320,11 @@ bool Renderer::Init() glGenRenderbuffersEXT(1, &s_DepthTarget); glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, s_DepthTarget); 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. 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); - GL_REPORT_ERROR(); + GL_REPORT_FBO_ERROR(); 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 @@ -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_ATTACHMENT1_EXT, GL_RENDERBUFFER_EXT, s_FakeZTarget); 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; 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); 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; if (bFailed) PanicAlert("Incomplete rt2"); } + if (GL_REPORT_ERROR() != GL_NO_ERROR) + bSuccess = false; + // glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, s_uFramebuffer); 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. - GL_REPORT_ERROR(); - if (err != GL_NO_ERROR) + if (GL_REPORT_ERROR() != GL_NO_ERROR) bSuccess = false; s_pfont = new RasterFont(); @@ -504,10 +507,6 @@ bool Renderer::InitializeGL() 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); glEnable(GL_SCISSOR_TEST); @@ -525,10 +524,7 @@ bool Renderer::InitializeGL() glClientActiveTexture(GL_TEXTURE0); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - GLenum err = GL_NO_ERROR; - GL_REPORT_ERROR(); - - return err == GL_NO_ERROR; + return GL_REPORT_ERROR() == GL_NO_ERROR; } @@ -800,13 +796,13 @@ void Renderer::FlushZBufferAlphaToTarget() glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE); 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 for (int i = 1; i < 8; ++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(); // 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 glActiveTexture(GL_TEXTURE0); + glEnable(GL_TEXTURE_RECTANGLE_ARB); glBindTexture(GL_TEXTURE_RECTANGLE_ARB, s_RenderTarget); // Use linear filtering. glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - TextureMngr::EnableTexRECT(0); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glBegin(GL_QUADS); @@ -1256,13 +1252,20 @@ void Renderer::SwapBuffers() 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(); OSD::DrawMessages(); // ----------------------------- #if defined(DVPROFILE) - if (g_bWriteProfile) { + if (g_bWriteProfile) { //g_bWriteProfile = 0; static int framenum = 0; const int UPDATE_FRAMES = 8; @@ -1302,6 +1305,7 @@ void Renderer::SwapBuffers() Renderer::SetRenderMode(RM_Normal); // turn off any zwrites } } + GL_REPORT_ERRORD(); } void Renderer::RenderText(const char* pstr, int left, int top, u32 color) diff --git a/Source/Plugins/Plugin_VideoOGL/Src/TextureConverter.cpp b/Source/Plugins/Plugin_VideoOGL/Src/TextureConverter.cpp index 9b03b6a0d8..cba3f45140 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/TextureConverter.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/TextureConverter.cpp @@ -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); GL_REPORT_ERRORD(); + for (int i = 1; i < 8; ++i) + TextureMngr::DisableStage(i); + // set source texture glActiveTexture(GL_TEXTURE0); + glEnable(GL_TEXTURE_RECTANGLE_ARB); glBindTexture(GL_TEXTURE_RECTANGLE_ARB, srcTexture); 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_MIN_FILTER, GL_NEAREST); } - - TextureMngr::EnableTexRECT(0); - for (int i = 1; i < 8; ++i) - TextureMngr::DisableStage(i); GL_REPORT_ERRORD(); 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); 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 // set srcAddr as data for source texture glActiveTexture(GL_TEXTURE0); + glEnable(GL_TEXTURE_RECTANGLE_ARB); glBindTexture(GL_TEXTURE_RECTANGLE_ARB, s_srcTexture); // 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); - TextureMngr::EnableTexRECT(0); - for (int i = 1; i < 8; ++i) - TextureMngr::DisableStage(i); - glViewport(0, 0, srcWidth, srcHeight); glEnable(GL_FRAGMENT_PROGRAM_ARB); diff --git a/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.cpp b/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.cpp index 0a008461e7..bf84abbe11 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.cpp @@ -51,7 +51,6 @@ u8 *TextureMngr::temp = NULL; TextureMngr::TexCache TextureMngr::textures; std::map TextureMngr::mapDepthTargets; -int TextureMngr::nTex2DEnabled, TextureMngr::nTexRECTEnabled; extern int frameCount; static u32 s_TempFramebuffer = 0; @@ -59,7 +58,7 @@ static u32 s_TempFramebuffer = 0; #define TEMP_SIZE (1024*1024*4) #define TEXTURE_KILL_THRESHOLD 200 -const GLint c_MinLinearFilter[8] = { +static const GLint c_MinLinearFilter[8] = { GL_NEAREST, GL_NEAREST_MIPMAP_NEAREST, GL_NEAREST_MIPMAP_LINEAR, @@ -67,14 +66,14 @@ const GLint c_MinLinearFilter[8] = { GL_LINEAR, GL_LINEAR_MIPMAP_NEAREST, GL_LINEAR_MIPMAP_LINEAR, - GL_LINEAR + GL_LINEAR, }; -const GLint c_WrapSettings[4] = { +static const GLint c_WrapSettings[4] = { GL_CLAMP_TO_EDGE, GL_REPEAT, GL_MIRRORED_REPEAT, - GL_REPEAT + GL_REPEAT, }; 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 data(width * height); glBindTexture(textarget, tex); glGetTexImage(textarget, 0, GL_BGRA, GL_UNSIGNED_BYTE, &data[0]); - GLenum err; - GL_REPORT_ERROR(); + GLenum err = GL_REPORT_ERROR(); if (err != GL_NO_ERROR) { PanicAlert("Can't save texture, GL Error: %s", gluErrorString(err)); @@ -157,7 +155,6 @@ void TextureMngr::TCacheEntry::Destroy(bool shutdown) void TextureMngr::Init() { temp = (u8*)AllocateMemoryPages(TEMP_SIZE); - nTex2DEnabled = nTexRECTEnabled = 0; 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))) { 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); glBindTexture(entry.isNonPow2 ? GL_TEXTURE_RECTANGLE_ARB : GL_TEXTURE_2D, entry.texture); if (entry.mode.hex != tm0.hex) @@ -475,14 +472,13 @@ void TextureMngr::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, bool { _assert_(entry.texture); bool bReInit = true; - + GL_REPORT_ERROR(); if (entry.w == w && entry.h == h) { glBindTexture(GL_TEXTURE_RECTANGLE_ARB, entry.texture); // for some reason mario sunshine errors here... // Beyond Good and Evil does too, occasionally. - GLenum err = GL_NO_ERROR; - GL_REPORT_ERROR(); + GLenum err = GL_REPORT_ERROR(); if (err == GL_NO_ERROR) bReInit = false; } @@ -651,7 +647,6 @@ void TextureMngr::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, bool GL_REPORT_ERRORD(); // We have to run a pixel shader, for color conversion. - Renderer::ResetGLState(); // reset any game specific settings if (s_TempFramebuffer == 0) @@ -685,9 +680,7 @@ void TextureMngr::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, bool glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT); glActiveTexture(GL_TEXTURE0); - - TextureMngr::EnableTexRECT(0); - + glEnable(GL_TEXTURE_RECTANGLE_ARB); glBindTexture(GL_TEXTURE_RECTANGLE_ARB, read_texture); glViewport(0, 0, w, h); @@ -727,45 +720,11 @@ void TextureMngr::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, bool } } -void TextureMngr::EnableTex2D(int stage) -{ - if (nTexRECTEnabled & (1< mapDepthTargets; - static int nTex2DEnabled, nTexRECTEnabled; public: 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 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 ClearRenderTargets(); // sets render target value of all textures to false diff --git a/Source/Plugins/Plugin_VideoOGL/Src/VertexManager.cpp b/Source/Plugins/Plugin_VideoOGL/Src/VertexManager.cpp index c51f87c842..ee9e5fb747 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/VertexManager.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/VertexManager.cpp @@ -175,69 +175,62 @@ void Flush() GL_REPORT_ERRORD(); // set the textures - { - DVSTARTSUBPROFILE("VertexManager::Flush:textures"); + DVSTARTSUBPROFILE("VertexManager::Flush:textures"); - u32 usedtextures = 0; + u32 usedtextures = 0; + for (u32 i = 0; i < (u32)bpmem.genMode.numtevstages + 1; ++i) { + if (bpmem.tevorders[i / 2].getEnable(i & 1)) + usedtextures |= 1 << bpmem.tevorders[i/2].getTexMap(i & 1); + } + + if (bpmem.genMode.numindstages > 0) { for (u32 i = 0; i < (u32)bpmem.genMode.numtevstages + 1; ++i) { - if (bpmem.tevorders[i/2].getEnable(i & 1)) - usedtextures |= 1 << bpmem.tevorders[i/2].getTexMap(i & 1); - } - - if (bpmem.genMode.numindstages > 0) { - for (u32 i = 0; i < (u32)bpmem.genMode.numtevstages + 1; ++i) { - if (bpmem.tevind[i].IsActive() && bpmem.tevind[i].bt < bpmem.genMode.numindstages) { - usedtextures |= 1 << bpmem.tevindref.getTexMap(bpmem.tevind[i].bt); - } + if (bpmem.tevind[i].IsActive() && bpmem.tevind[i].bt < bpmem.genMode.numindstages) { + usedtextures |= 1 << bpmem.tevindref.getTexMap(bpmem.tevind[i].bt); } } + } - u32 nonpow2tex = 0; - for (int i = 0; i < 8; i++) { - if (usedtextures & (1 << i)) { - glActiveTexture(GL_TEXTURE0 + i); - - FourTexUnits &tex = bpmem.tex[i >> 2]; - TextureMngr::TCacheEntry* tentry = TextureMngr::Load(i, (tex.texImage3[i&3].image_base/* & 0x1FFFFF*/) << 5, - tex.texImage0[i&3].width+1, tex.texImage0[i&3].height+1, - tex.texImage0[i&3].format, tex.texTlut[i&3].tmem_offset<<9, tex.texTlut[i&3].tlut_format); + u32 nonpow2tex = 0; + for (int i = 0; i < 8; i++) { + if (usedtextures & (1 << i)) { + glActiveTexture(GL_TEXTURE0 + i); - if (tentry != NULL) { - // texture loaded fine, set dims for pixel shader - if (tentry->isNonPow2) { - PixelShaderManager::SetTexDims(i, tentry->w, tentry->h, tentry->mode.wrap_s, tentry->mode.wrap_t); - nonpow2tex |= 1 << i; - if (tentry->mode.wrap_s > 0) nonpow2tex |= 1 << (8 + 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) - // (the above seems to have changed - we set the width and height here too. - else - { - PixelShaderManager::SetTexDims(i, tentry->w, tentry->h, 0, 0); - TextureMngr::EnableTex2D(i); - } - if (g_Config.iLog & CONF_SAVETEXTURES) { - // save the textures - char strfile[255]; - sprintf(strfile, "%sframes/tex%.3d_%d.tga", FULL_DUMP_DIR, g_Config.iSaveTargetId, i); - SaveTexture(strfile, tentry->isNonPow2?GL_TEXTURE_RECTANGLE_ARB:GL_TEXTURE_2D, tentry->texture, tentry->w, tentry->h); - } + FourTexUnits &tex = bpmem.tex[i >> 2]; + TextureMngr::TCacheEntry* tentry = TextureMngr::Load(i, (tex.texImage3[i&3].image_base/* & 0x1FFFFF*/) << 5, + tex.texImage0[i&3].width + 1, tex.texImage0[i&3].height + 1, + tex.texImage0[i&3].format, tex.texTlut[i&3].tmem_offset<<9, tex.texTlut[i&3].tlut_format); + + if (tentry != NULL) { + // texture loaded fine, set dims for pixel shader + if (tentry->isNonPow2) { + PixelShaderManager::SetTexDims(i, tentry->w, tentry->h, tentry->mode.wrap_s, tentry->mode.wrap_t); + nonpow2tex |= 1 << i; + if (tentry->mode.wrap_s > 0) nonpow2tex |= 1 << (8 + i); + if (tentry->mode.wrap_t > 0) nonpow2tex |= 1 << (16 + i); } - else { - ERROR_LOG(VIDEO, "error loading tex"); - TextureMngr::DisableStage(i); // disable since won't be used + // 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. + else + { + // 0s are probably for no manual wrapping needed. + PixelShaderManager::SetTexDims(i, tentry->w, tentry->h, 0, 0); + } + if (g_Config.iLog & CONF_SAVETEXTURES) { + // save the textures + char strfile[255]; + sprintf(strfile, "%sframes/tex%.3d_%d.tga", FULL_DUMP_DIR, g_Config.iSaveTargetId, i); + SaveTexture(strfile, tentry->isNonPow2?GL_TEXTURE_RECTANGLE_ARB:GL_TEXTURE_2D, tentry->texture, tentry->w, tentry->h); } } else { - TextureMngr::DisableStage(i); // disable since won't be used + ERROR_LOG(VIDEO, "error loading tex\n"); } } - - PixelShaderManager::SetTexturesUsed(nonpow2tex); } + PixelShaderManager::SetTexturesUsed(nonpow2tex); + FRAGMENTSHADER* ps = PixelShaderCache::GetShader(false); VERTEXSHADER* vs = VertexShaderCache::GetShader(g_nativeVertexFmt->m_components); @@ -245,7 +238,9 @@ void Flush() if (Renderer::UseFakeZTarget()) { if (bpmem.zmode.updateenable) { 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 { diff --git a/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderCache.cpp b/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderCache.cpp index b257fcafcd..1512e1950a 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderCache.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderCache.cpp @@ -134,6 +134,13 @@ void VertexShaderCache::ProgressiveCleanup() 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]; sprintf(stropt, "MaxLocalParams=256,MaxInstructions=%d", s_nMaxVertexInstructions); 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); glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, (GLsizei)strlen(pcompiledprog), pcompiledprog); - GLenum err = GL_NO_ERROR; - GL_REPORT_ERROR(); + err = GL_REPORT_ERROR(); if (err != GL_NO_ERROR) { ERROR_LOG(VIDEO, pstrprogram); ERROR_LOG(VIDEO, pcompiledprog); diff --git a/Source/Plugins/Plugin_VideoOGL/Src/XFB.cpp b/Source/Plugins/Plugin_VideoOGL/Src/XFB.cpp index 05c0f67e86..091f8b4794 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/XFB.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/XFB.cpp @@ -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 Renderer::ResetGLState(); - TextureMngr::EnableTexRECT(0); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); // switch to the backbuffer glActiveTexture(GL_TEXTURE0); + glEnable(GL_TEXTURE_RECTANGLE_ARB); glBindTexture(GL_TEXTURE_RECTANGLE_ARB, xfb_decoded_texture); TRectangle back_rc; diff --git a/Source/Plugins/Plugin_VideoOGL/Src/rasterfont.cpp b/Source/Plugins/Plugin_VideoOGL/Src/rasterfont.cpp index ebeaa31050..89b46d3516 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/rasterfont.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/rasterfont.cpp @@ -174,7 +174,7 @@ void RasterFont::printMultilineText(const char *text, double start_x, double sta { double x = start_x; double y = start_y; - static char temp[1024]; + char temp[1024]; char *t = temp; while (*text) {