From dc35083392fe04935f8d0395aeb59903b1afe6e5 Mon Sep 17 00:00:00 2001 From: baldurk Date: Mon, 1 Mar 2021 11:38:04 +0000 Subject: [PATCH] Check for clip origin on GL to enable Y-flipping for output meshes --- renderdoc/driver/gl/gl_postvs.cpp | 19 +++++++++++++++++++ renderdoc/driver/gl/gl_replay.h | 2 ++ 2 files changed, 21 insertions(+) diff --git a/renderdoc/driver/gl/gl_postvs.cpp b/renderdoc/driver/gl/gl_postvs.cpp index 33f07a461..dc3b2883b 100644 --- a/renderdoc/driver/gl/gl_postvs.cpp +++ b/renderdoc/driver/gl/gl_postvs.cpp @@ -739,6 +739,17 @@ void GLReplay::InitPostVSBuffers(uint32_t eventId) if(HasExt[ARB_transform_feedback2]) drv.glBindTransformFeedback(eGL_TRANSFORM_FEEDBACK, DebugData.feedbackObj); + bool flipY = false; + + if(HasExt[ARB_clip_control]) + { + GLenum clipOrigin = eGL_LOWER_LEFT; + GL.glGetIntegerv(eGL_CLIP_ORIGIN, (GLint *)&clipOrigin); + + if(clipOrigin == eGL_UPPER_LEFT) + flipY = true; + } + GLuint idxBuf = 0; if(vsRefl->outputSignature.empty()) @@ -1867,6 +1878,8 @@ void GLReplay::InitPostVSBuffers(uint32_t eventId) m_PostVSData[eventId].gsout.useIndices = false; + m_PostVSData[eventId].gsout.flipY = flipY; + m_PostVSData[eventId].gsout.hasPosOut = hasPosition; m_PostVSData[eventId].gsout.idxBuf = 0; @@ -1877,6 +1890,10 @@ void GLReplay::InitPostVSBuffers(uint32_t eventId) m_PostVSData[eventId].gsout.instData = instData; } } + else + { + m_PostVSData[eventId].vsout.flipY = flipY; + } // delete temporary program we made drv.glDeleteProgram(feedbackProg); @@ -1989,6 +2006,8 @@ MeshFormat GLReplay::GetPostVSBuffers(uint32_t eventId, uint32_t instID, uint32_ ret.nearPlane = s.nearPlane; ret.farPlane = s.farPlane; + ret.flipY = s.flipY; + if(instID < s.instData.size()) { GLPostVSData::InstData inst = s.instData[instID]; diff --git a/renderdoc/driver/gl/gl_replay.h b/renderdoc/driver/gl/gl_replay.h index 1a8286e96..bba676f25 100644 --- a/renderdoc/driver/gl/gl_replay.h +++ b/renderdoc/driver/gl/gl_replay.h @@ -62,6 +62,8 @@ struct GLPostVSData GLuint idxBuf = 0; uint32_t idxByteWidth = 0; + bool flipY = false; + bool hasPosOut = false; float nearPlane = 0.0f;