Handle differences between EXT_debug_label and KHR_debug

* In particular they have different behaviour for what length value
  indicates that the length should be fetched from the NULL
  terminated string.
This commit is contained in:
baldurk
2018-02-02 18:39:46 +00:00
parent 96c487c8c0
commit 3b94095201
2 changed files with 17 additions and 3 deletions
+3 -1
View File
@@ -267,7 +267,9 @@ typically it is one parent to many derived.
DOCUMENT("Utility function for setting up a custom name to overwrite the auto-generated one.");
inline void SetCustomName(const rdcstr &givenName)
{
autogeneratedName = false;
// consider an empty name to be un-setting any previous set name, and revert to the
// auto-generated name.
autogeneratedName = !givenName.isEmpty();
name = givenName;
}
};
@@ -36,10 +36,22 @@ bool WrappedOpenGL::Serialise_glObjectLabel(SerialiserType &ser, GLenum identifi
if(ser.IsWriting())
{
if(length == 0 || label == NULL)
// we share implementations between KHR_debug and EXT_debug_label, however KHR_debug follows the
// pattern elsewhere (e.g. in glShaderSource) of a length of -1 meaning indeterminate
// NULL-terminated length, but EXT_debug_label takes length of 0 to mean that.
GLsizei realLength = length;
if(gl_CurChunk == GLChunk::glLabelObjectEXT && length == 0)
realLength = -1;
// if length is negative (after above twiddling), it's taken from strlen and the label must be
// NULL-terminated
if(realLength < 0)
realLength = label ? (GLsizei)strlen(label) : 0;
if(realLength == 0 || label == NULL)
Label = "";
else
Label = std::string(label, label + (length > 0 ? length : strlen(label)));
Label = std::string(label, label + realLength);
switch(identifier)
{