OGL: Get rid of error macros

This commit is contained in:
Lioncash 2014-10-26 04:53:22 -04:00
parent f895648eb9
commit 49b94e5285
12 changed files with 18 additions and 161 deletions

View File

@ -135,7 +135,6 @@ FramebufferManager::FramebufferManager(int targetWidth, int targetHeight, int ms
glBindFramebuffer(GL_FRAMEBUFFER, m_resolvedFramebuffer);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_resolvedColorTexture, 0);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, m_resolvedDepthTexture, 0);
GL_REPORT_FBO_ERROR();
}
// Create XFB framebuffer; targets will be created elsewhere.
@ -146,7 +145,6 @@ FramebufferManager::FramebufferManager(int targetWidth, int targetHeight, int ms
glBindFramebuffer(GL_FRAMEBUFFER, m_efbFramebuffer);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, m_textureType, m_efbColor, 0);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, m_textureType, m_efbDepth, 0);
GL_REPORT_FBO_ERROR();
// EFB framebuffer is currently bound, make sure to clear its alpha value to 1.f
glViewport(0, 0, m_targetWidth, m_targetHeight);
@ -400,7 +398,6 @@ void XFBSource::CopyEFB(float Gamma)
// Bind texture.
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
GL_REPORT_FBO_ERROR();
glBlitFramebuffer(
0, 0, texWidth, texHeight,

View File

@ -113,46 +113,3 @@ GLuint OpenGL_CompileProgram(const char* vertexShader, const char* fragmentShade
return programID;
}
GLenum OpenGL_ReportGLError(const char *function, const char *file, int line)
{
GLenum err = glGetError();
if (err != GL_NO_ERROR)
{
ERROR_LOG(VIDEO, "%s:%d: (%s) OpenGL error 0x%x\n",
file, line, function, err);
}
return err;
}
bool OpenGL_ReportFBOError(const char *function, const char *file, int line)
{
GLenum fbo_status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
if (fbo_status != GL_FRAMEBUFFER_COMPLETE)
{
const char *error = "unknown error";
switch (fbo_status)
{
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
error = "INCOMPLETE_ATTACHMENT";
break;
case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
error = "INCOMPLETE_MISSING_ATTACHMENT";
break;
case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER:
error = "INCOMPLETE_DRAW_BUFFER";
break;
case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER:
error = "INCOMPLETE_READ_BUFFER";
break;
case GL_FRAMEBUFFER_UNSUPPORTED:
error = "UNSUPPORTED";
break;
}
ERROR_LOG(VIDEO, "%s:%d: (%s) OpenGL FBO error - %s\n",
file, line, function, error);
return false;
}
return true;
}

View File

@ -18,20 +18,6 @@ void InitInterface();
// Helpers
GLuint OpenGL_CompileProgram(const char *vertexShader, const char *fragmentShader);
// Error reporting - use the convenient macros.
GLenum OpenGL_ReportGLError(const char *function, const char *file, int line);
bool OpenGL_ReportFBOError(const char *function, const char *file, int line);
#if defined(_DEBUG) || defined(DEBUGFAST)
#define GL_REPORT_ERROR() OpenGL_ReportGLError(__FUNCTION__, __FILE__, __LINE__)
#define GL_REPORT_ERRORD() OpenGL_ReportGLError(__FUNCTION__, __FILE__, __LINE__)
#define GL_REPORT_FBO_ERROR() OpenGL_ReportFBOError(__FUNCTION__, __FILE__, __LINE__)
#else
__forceinline GLenum GL_REPORT_ERROR() { return GL_NO_ERROR; }
#define GL_REPORT_ERRORD() (void)GL_NO_ERROR
#define GL_REPORT_FBO_ERROR() (void)true
#endif
// this should be removed in future, but as long as glsl is unstable, we should really read this messages
#if defined(_DEBUG) || defined(DEBUGFAST)
#define DEBUG_GLSL 1

View File

@ -357,7 +357,7 @@ GLuint ProgramShaderCache::CompileSingleShader(GLuint type, const char* code)
glDeleteShader(result);
return 0;
}
(void)GL_REPORT_ERROR();
return result;
}

View File

@ -878,8 +878,6 @@ void Renderer::RenderText(const std::string& text, int left, int top, u32 color)
left * 2.0f / (float)nBackbufferWidth - 1,
1 - top * 2.0f / (float)nBackbufferHeight,
0, nBackbufferWidth, nBackbufferHeight, color);
GL_REPORT_ERRORD();
}
TargetRectangle Renderer::ConvertEFBRectangle(const EFBRectangle& rc)
@ -1015,7 +1013,6 @@ u32 Renderer::AccessEFB(EFBAccessType type, u32 x, u32 y, u32 poke_data)
glReadPixels(targetPixelRc.left, targetPixelRc.bottom, targetPixelRcWidth, targetPixelRcHeight,
GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, depthMap);
GL_REPORT_ERRORD();
UpdateEFBCache(type, cacheRectIdx, efbPixelRc, targetPixelRc, depthMap);
@ -1073,7 +1070,6 @@ u32 Renderer::AccessEFB(EFBAccessType type, u32 x, u32 y, u32 poke_data)
else
glReadPixels(targetPixelRc.left, targetPixelRc.bottom, targetPixelRcWidth, targetPixelRcHeight,
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, colorMap);
GL_REPORT_ERRORD();
UpdateEFBCache(type, cacheRectIdx, efbPixelRc, targetPixelRc, colorMap);
@ -1409,8 +1405,6 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co
std::swap(flipped_trc.top, flipped_trc.bottom);
}
GL_REPORT_ERRORD();
// Copy the framebuffer to screen.
const XFBSource* xfbSource = nullptr;
@ -1501,7 +1495,7 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co
}
glPixelStorei(GL_PACK_ALIGNMENT, 1);
glReadPixels(flipped_trc.left, flipped_trc.bottom, w, h, GL_BGR, GL_UNSIGNED_BYTE, &frame_data[0]);
if (GL_REPORT_ERROR() == GL_NO_ERROR && w > 0 && h > 0)
if (w > 0 && h > 0)
{
if (!bLastFrameDumped)
{
@ -1559,29 +1553,27 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co
frame_data.resize(3 * w * h);
glPixelStorei(GL_PACK_ALIGNMENT, 1);
glReadPixels(GetTargetRectangle().left, GetTargetRectangle().bottom, w, h, GL_BGR, GL_UNSIGNED_BYTE, &frame_data[0]);
if (GL_REPORT_ERROR() == GL_NO_ERROR)
if (!bLastFrameDumped)
{
if (!bLastFrameDumped)
movie_file_name = File::GetUserPath(D_DUMPFRAMES_IDX) + "framedump.raw";
pFrameDump.Open(movie_file_name, "wb");
if (!pFrameDump)
{
movie_file_name = File::GetUserPath(D_DUMPFRAMES_IDX) + "framedump.raw";
pFrameDump.Open(movie_file_name, "wb");
if (!pFrameDump)
{
OSD::AddMessage("Error opening framedump.raw for writing.", 2000);
}
else
{
OSD::AddMessage(StringFromFormat("Dumping Frames to \"%s\" (%dx%d RGB24)", movie_file_name.c_str(), w, h), 2000);
}
OSD::AddMessage("Error opening framedump.raw for writing.", 2000);
}
if (pFrameDump)
else
{
FlipImageData(&frame_data[0], w, h);
pFrameDump.WriteBytes(&frame_data[0], w * 3 * h);
pFrameDump.Flush();
OSD::AddMessage(StringFromFormat("Dumping Frames to \"%s\" (%dx%d RGB24)", movie_file_name.c_str(), w, h), 2000);
}
bLastFrameDumped = true;
}
if (pFrameDump)
{
FlipImageData(&frame_data[0], w, h);
pFrameDump.WriteBytes(&frame_data[0], w * 3 * h);
pFrameDump.Flush();
}
bLastFrameDumped = true;
}
else
{
@ -1638,32 +1630,24 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co
// ---------------------------------------------------------------------
if (!DriverDetails::HasBug(DriverDetails::BUG_BROKENSWAP))
{
GL_REPORT_ERRORD();
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
DrawDebugInfo();
DrawDebugText();
GL_REPORT_ERRORD();
// Do our OSD callbacks
OSD::DoCallbacks(OSD::OSD_ONFRAME);
OSD::DrawMessages();
GL_REPORT_ERRORD();
}
// Copy the rendered frame to the real window
GLInterface->Swap();
GL_REPORT_ERRORD();
// Clear framebuffer
if (!DriverDetails::HasBug(DriverDetails::BUG_BROKENSWAP))
{
glClearColor(0, 0, 0, 0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
GL_REPORT_ERRORD();
}
if (s_vsync != g_ActiveConfig.IsVSync())
@ -1678,11 +1662,8 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co
// Render to the framebuffer.
FramebufferManager::SetFramebuffer(0);
GL_REPORT_ERRORD();
RestoreAPIState();
GL_REPORT_ERRORD();
g_Config.iSaveTargetId = 0;
UpdateActiveConfig();
@ -1875,14 +1856,6 @@ bool Renderer::SaveScreenshot(const std::string &filename, const TargetRectangle
glReadPixels(back_rc.left, back_rc.bottom, W, H, GL_RGBA, GL_UNSIGNED_BYTE, data);
// Show failure message
if (GL_REPORT_ERROR() != GL_NO_ERROR)
{
delete[] data;
OSD::AddMessage("Error capturing or saving screenshot.", 2000);
return false;
}
// Turn image upside down
FlipImageData(data, W, H, 4);
bool success = TextureToPng(data, W*4, filename, W, H, false);

View File

@ -60,13 +60,6 @@ bool SaveTexture(const std::string& filename, u32 textarget, u32 tex, int virtua
glBindTexture(textarget, 0);
TextureCache::SetStage();
const GLenum err = GL_REPORT_ERROR();
if (GL_NO_ERROR != err)
{
PanicAlert("Can't save texture, GL Error: %d", err);
return false;
}
return TextureToPng(data.data(), width * 4, filename, width, height, true);
}
@ -91,7 +84,6 @@ TextureCache::TCacheEntry::~TCacheEntry()
TextureCache::TCacheEntry::TCacheEntry()
{
glGenTextures(1, &texture);
GL_REPORT_ERRORD();
framebuffer = 0;
}
@ -214,7 +206,6 @@ void TextureCache::TCacheEntry::Load(unsigned int width, unsigned int height,
//width, height, 0, expanded_width * expanded_height/2, temp);
}
TextureCache::SetStage();
GL_REPORT_ERRORD();
}
TextureCache::TCacheEntryBase* TextureCache::CreateRenderTargetTexture(
@ -223,7 +214,6 @@ TextureCache::TCacheEntryBase* TextureCache::CreateRenderTargetTexture(
TCacheEntry *const entry = new TCacheEntry;
glActiveTexture(GL_TEXTURE0+9);
glBindTexture(GL_TEXTURE_2D, entry->texture);
GL_REPORT_ERRORD();
const GLenum
gl_format = GL_RGBA,
@ -238,12 +228,9 @@ TextureCache::TCacheEntryBase* TextureCache::CreateRenderTargetTexture(
glGenFramebuffers(1, &entry->framebuffer);
FramebufferManager::SetFramebuffer(entry->framebuffer);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, entry->texture, 0);
GL_REPORT_FBO_ERROR();
SetStage();
GL_REPORT_ERRORD();
return entry;
}
@ -259,14 +246,10 @@ void TextureCache::TCacheEntry::FromRenderTarget(u32 dstAddr, unsigned int dstFo
FramebufferManager::ResolveAndGetDepthTarget(srcRect) :
FramebufferManager::ResolveAndGetRenderTarget(srcRect);
GL_REPORT_ERRORD();
if (type != TCET_EC_DYNAMIC || g_ActiveConfig.bCopyEFBToTexture)
{
FramebufferManager::SetFramebuffer(framebuffer);
GL_REPORT_ERRORD();
glActiveTexture(GL_TEXTURE0+9);
glBindTexture(GL_TEXTURE_2D, read_texture);
@ -293,11 +276,8 @@ void TextureCache::TCacheEntry::FromRenderTarget(u32 dstAddr, unsigned int dstFo
TargetRectangle R = g_renderer->ConvertEFBRectangle(srcRect);
glUniform4f(uniform_location, static_cast<float>(R.left), static_cast<float>(R.top),
static_cast<float>(R.right), static_cast<float>(R.bottom));
GL_REPORT_ERRORD();
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
GL_REPORT_ERRORD();
}
if (false == g_ActiveConfig.bCopyEFBToTexture)
@ -325,8 +305,6 @@ void TextureCache::TCacheEntry::FromRenderTarget(u32 dstAddr, unsigned int dstFo
FramebufferManager::SetFramebuffer(0);
GL_REPORT_ERRORD();
if (g_ActiveConfig.bDumpEFBTarget)
{
static int count = 0;

View File

@ -221,7 +221,6 @@ static void EncodeToRamUsingShader(GLuint srcTexture,
// switch to texture converter frame buffer
// attach render buffer as color destination
FramebufferManager::SetFramebuffer(s_texConvFrameBuffer[0]);
GL_REPORT_ERRORD();
// set source texture
glActiveTexture(GL_TEXTURE0+9);
@ -238,14 +237,10 @@ static void EncodeToRamUsingShader(GLuint srcTexture,
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
}
GL_REPORT_ERRORD();
glViewport(0, 0, (GLsizei)dstWidth, (GLsizei)dstHeight);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
GL_REPORT_ERRORD();
// .. and then read back the results.
// TODO: make this less slow.
@ -280,9 +275,6 @@ static void EncodeToRamUsingShader(GLuint srcTexture,
{
glReadPixels(0, 0, (GLsizei)dstWidth, (GLsizei)dstHeight, GL_BGRA, GL_UNSIGNED_BYTE, destAddr);
}
GL_REPORT_ERRORD();
}
int EncodeToRamFromTexture(u32 address,GLuint source_texture, bool bFromZBuffer, bool bIsIntensityFmt, u32 copyfmt, int bScaleByHalf, const EFBRectangle& source)
@ -355,7 +347,6 @@ void EncodeToRamYUYV(GLuint srcTexture, const TargetRectangle& sourceRc, u8* des
FramebufferManager::SetFramebuffer(0);
TextureCache::DisableStage(0);
g_renderer->RestoreAPIState();
GL_REPORT_ERRORD();
}
@ -376,8 +367,6 @@ void DecodeToTexture(u32 xfbAddr, int srcWidth, int srcHeight, GLuint destTextur
FramebufferManager::SetFramebuffer(s_texConvFrameBuffer[1]);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, destTexture, 0);
GL_REPORT_FBO_ERROR();
// activate source texture
// set srcAddr as data for source texture
glActiveTexture(GL_TEXTURE0+9);
@ -392,7 +381,6 @@ void DecodeToTexture(u32 xfbAddr, int srcWidth, int srcHeight, GLuint destTextur
FramebufferManager::SetFramebuffer(0);
g_renderer->RestoreAPIState();
GL_REPORT_ERRORD();
}
} // namespace

View File

@ -63,14 +63,11 @@ void VertexManager::CreateDeviceObjects()
void VertexManager::DestroyDeviceObjects()
{
GL_REPORT_ERRORD();
glBindBuffer(GL_ARRAY_BUFFER, 0 );
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0 );
GL_REPORT_ERROR();
delete s_vertexBuffer;
delete s_indexBuffer;
GL_REPORT_ERROR();
}
void VertexManager::PrepareDrawBuffers(u32 stride)
@ -140,7 +137,6 @@ void VertexManager::vFlush(bool useDstAlpha)
}
PrepareDrawBuffers(stride);
GL_REPORT_ERRORD();
// Makes sure we can actually do Dual source blending
bool dualSourcePossible = g_ActiveConfig.backend_info.bSupportsDualSourceBlend;
@ -161,7 +157,6 @@ void VertexManager::vFlush(bool useDstAlpha)
// setup the pointers
nativeVertexFmt->SetupVertexPointers();
GL_REPORT_ERRORD();
Draw(stride);
@ -214,8 +209,6 @@ void VertexManager::vFlush(bool useDstAlpha)
g_Config.iSaveTargetId++;
ClearEFBCache();
GL_REPORT_ERRORD();
}

View File

@ -203,7 +203,6 @@ void VideoBackend::Video_Prepare()
g_texture_cache = new TextureCache();
g_sampler_cache = new SamplerCache();
Renderer::Init();
GL_REPORT_ERRORD();
VertexLoaderManager::Init();
TextureConverter::Init();

View File

@ -152,8 +152,6 @@ namespace HwRasterizer
texType = GL_TEXTURE_RECTANGLE;
else
texType = GL_TEXTURE_2D;
GL_REPORT_ERRORD();
}
static float width, height;
static void LoadTexture()
@ -178,7 +176,6 @@ namespace HwRasterizer
glBindTexture(texType, cacheEntry.texture);
glTexParameteri(texType, GL_TEXTURE_MAG_FILTER, texUnit.texMode0[0].mag_filter ? GL_LINEAR : GL_NEAREST);
glTexParameteri(texType, GL_TEXTURE_MIN_FILTER, (texUnit.texMode0[0].min_filter >= 4) ? GL_LINEAR : GL_NEAREST);
GL_REPORT_ERRORD();
}
void BeginTriangles()
@ -247,7 +244,6 @@ namespace HwRasterizer
glDisableVertexAttribArray(col_atex);
glDisableVertexAttribArray(col_apos);
}
GL_REPORT_ERRORD();
}
static void DrawTextureVertex(OutputVertexData *v0, OutputVertexData *v1, OutputVertexData *v2)
@ -295,7 +291,6 @@ namespace HwRasterizer
glDisableVertexAttribArray(tex_atex);
glDisableVertexAttribArray(tex_apos);
}
GL_REPORT_ERRORD();
}
void DrawTriangleFrontFace(OutputVertexData *v0, OutputVertexData *v1, OutputVertexData *v2)
@ -332,7 +327,6 @@ namespace HwRasterizer
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
glDisableVertexAttribArray(col_apos);
}
GL_REPORT_ERRORD();
}
TexCacheEntry::TexCacheEntry()
@ -358,8 +352,6 @@ namespace HwRasterizer
glGenTextures(1, (GLuint *)&texture);
glBindTexture(texType, texture);
glTexImage2D(texType, 0, GL_RGBA, (GLsizei)image_width, (GLsizei)image_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, temp);
GL_REPORT_ERRORD();
}
void TexCacheEntry::Destroy()

View File

@ -148,14 +148,12 @@ void RasterFont::printString(const char *s, double x, double y, double z)
// go to the right spot
glRasterPos3d(x, y, z);
GL_REPORT_ERRORD();
glPushAttrib (GL_LIST_BIT);
glListBase(fontOffset);
glCallLists((GLsizei)strlen(s2), GL_UNSIGNED_BYTE, (GLubyte *) s2);
GL_REPORT_ERRORD();
glPopAttrib();
GL_REPORT_ERRORD();
}
void RasterFont::printCenteredString(const char *s, double y, int screen_width, double z)

View File

@ -103,7 +103,6 @@ void SWRenderer::Prepare()
s_pfont = new RasterFont();
glEnable(GL_TEXTURE_2D);
}
GL_REPORT_ERRORD();
}
void SWRenderer::SetScreenshot(const char *_szFilename)
@ -271,7 +270,6 @@ void SWRenderer::DrawTexture(u8 *texture, int width, int height)
glDisableVertexAttribArray(attr_tex);
glBindTexture(GL_TEXTURE_2D, 0);
GL_REPORT_ERRORD();
}
void SWRenderer::SwapBuffer()
@ -288,6 +286,4 @@ void SWRenderer::SwapBuffer()
swstats.ResetFrame();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
GL_REPORT_ERRORD();
}