diff --git a/renderdoc/driver/gl/gl_driver.cpp b/renderdoc/driver/gl/gl_driver.cpp index 990cd508f..3a2f9851e 100644 --- a/renderdoc/driver/gl/gl_driver.cpp +++ b/renderdoc/driver/gl/gl_driver.cpp @@ -351,6 +351,8 @@ const uint32_t GLInitParams::GL_OLD_VERSIONS[GLInitParams::GL_NUM_SUPPORTED_OLD_ 0x000013, // Serialised vertex attribute and fragdata bindings for programs as initial // contents data 0x000014, // Added support for primitive bounding boxes on GLES + 0x000015, // Changed serialisation of client-side index buffers which removed a bool even + // when they aren't used. }; ReplayStatus GLInitParams::Serialise() diff --git a/renderdoc/driver/gl/gl_driver.h b/renderdoc/driver/gl/gl_driver.h index 0dfdde833..d125fca92 100644 --- a/renderdoc/driver/gl/gl_driver.h +++ b/renderdoc/driver/gl/gl_driver.h @@ -53,10 +53,10 @@ struct GLInitParams : public RDCInitParams uint32_t width; uint32_t height; - static const uint32_t GL_SERIALISE_VERSION = 0x0000015; + static const uint32_t GL_SERIALISE_VERSION = 0x0000016; // backwards compatibility for old logs described at the declaration of this array - static const uint32_t GL_NUM_SUPPORTED_OLD_VERSIONS = 5; + static const uint32_t GL_NUM_SUPPORTED_OLD_VERSIONS = 6; static const uint32_t GL_OLD_VERSIONS[GL_NUM_SUPPORTED_OLD_VERSIONS]; // version number internal to opengl stream @@ -475,6 +475,9 @@ private: const void *&indices); void RestoreClientMemoryArrays(ClientMemoryData *clientMemoryArrays, GLenum indexType); + // used to match serialisation with older GL captures + void Legacy_preElements(GLenum Type, uint32_t Count); + map m_ContextData; ContextData &GetCtxData(); diff --git a/renderdoc/driver/gl/wrappers/gl_draw_funcs.cpp b/renderdoc/driver/gl/wrappers/gl_draw_funcs.cpp index 0c3a5975a..8fed9b1db 100644 --- a/renderdoc/driver/gl/wrappers/gl_draw_funcs.cpp +++ b/renderdoc/driver/gl/wrappers/gl_draw_funcs.cpp @@ -1121,6 +1121,36 @@ bool WrappedOpenGL::Check_preElements() return true; } +void WrappedOpenGL::Legacy_preElements(GLenum Type, uint32_t Count) +{ + if(m_State <= EXECUTING && GetLogVersion() <= 0x000015) + { + // in older logs there used to be a different way of manually saving client-side memory + // indices. + // We don't support replaying this anymore, but we need to match serialisation to be able to + // open older captures - in 99% of cases the bool will be false. When it's true, we just add + // an error message about it. + SERIALISE_ELEMENT(bool, IndicesFromMemory, false); + + if(IndicesFromMemory) + { + uint32_t IdxSize = Type == eGL_UNSIGNED_BYTE ? 1 : Type == eGL_UNSIGNED_SHORT + ? 2 + : /*Type == eGL_UNSIGNED_INT*/ 4; + + // serialise the data, even unused + SERIALISE_ELEMENT_BUF(byte *, idxdata, NULL, size_t(IdxSize * Count)); + + AddDebugMessage(MessageCategory::Deprecated, MessageSeverity::High, + MessageSource::UnsupportedConfiguration, + "Client-side index data used at drawcall, re-capture with a new version to " + "replay this draw."); + + SAFE_DELETE_ARRAY(idxdata); + } + } +} + bool WrappedOpenGL::Serialise_glDrawElements(GLenum mode, GLsizei count, GLenum type, const void *indices) { @@ -1131,6 +1161,8 @@ bool WrappedOpenGL::Serialise_glDrawElements(GLenum mode, GLsizei count, GLenum if(m_State <= EXECUTING) { + Legacy_preElements(Type, Count); + if(Check_preElements()) m_Real.glDrawElements(Mode, Count, Type, (const void *)IdxOffset); } @@ -1285,6 +1317,8 @@ bool WrappedOpenGL::Serialise_glDrawRangeElements(GLenum mode, GLuint start, GLu if(m_State <= EXECUTING) { + Legacy_preElements(Type, Count); + if(Check_preElements()) m_Real.glDrawRangeElements(Mode, Start, End, Count, Type, (const void *)IdxOffset); } @@ -1364,6 +1398,8 @@ bool WrappedOpenGL::Serialise_glDrawRangeElementsBaseVertex(GLenum mode, GLuint if(m_State <= EXECUTING) { + Legacy_preElements(Type, Count); + if(Check_preElements()) m_Real.glDrawRangeElementsBaseVertex(Mode, Start, End, Count, Type, (const void *)IdxOffset, BaseVtx); @@ -1442,6 +1478,8 @@ bool WrappedOpenGL::Serialise_glDrawElementsBaseVertex(GLenum mode, GLsizei coun if(m_State <= EXECUTING) { + Legacy_preElements(Type, Count); + if(Check_preElements()) m_Real.glDrawElementsBaseVertex(Mode, Count, Type, (const void *)IdxOffset, BaseVtx); } @@ -1518,6 +1556,8 @@ bool WrappedOpenGL::Serialise_glDrawElementsInstanced(GLenum mode, GLsizei count if(m_State <= EXECUTING) { + Legacy_preElements(Type, Count); + if(Check_preElements()) m_Real.glDrawElementsInstanced(Mode, Count, Type, (const void *)IdxOffset, InstCount); } @@ -1597,6 +1637,8 @@ bool WrappedOpenGL::Serialise_glDrawElementsInstancedBaseInstance(GLenum mode, G if(m_State <= EXECUTING) { + Legacy_preElements(Type, Count); + if(Check_preElements()) m_Real.glDrawElementsInstancedBaseInstance(Mode, Count, Type, (const void *)IdxOffset, InstCount, BaseInstance); @@ -1679,6 +1721,8 @@ bool WrappedOpenGL::Serialise_glDrawElementsInstancedBaseVertex(GLenum mode, GLs if(m_State <= EXECUTING) { + Legacy_preElements(Type, Count); + if(Check_preElements()) m_Real.glDrawElementsInstancedBaseVertex(Mode, Count, Type, (const void *)IdxOffset, InstCount, BaseVertex); @@ -1762,6 +1806,8 @@ bool WrappedOpenGL::Serialise_glDrawElementsInstancedBaseVertexBaseInstance( if(m_State <= EXECUTING) { + Legacy_preElements(Type, Count); + if(Check_preElements()) m_Real.glDrawElementsInstancedBaseVertexBaseInstance( Mode, Count, Type, (const void *)IdxOffset, InstCount, BaseVertex, BaseInstance);