mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-07 19:58:32 +09:00
[Fix] (MG_Impl): report the draw-indirect binding and the buffer access state
Three pieces of queryable buffer state were missing, all of them read by the KHR-GL40.draw_indirect basic-binding-* and basic-buffer-* cases: - GL_DRAW_INDIRECT_BUFFER_BINDING had no case in glGetIntegerv, so it raised GL_INVALID_ENUM and left the caller's variable untouched (the test read back its own -9999 sentinel). GL_DISPATCH_INDIRECT_BUFFER_BINDING right next to it was already handled; this is the same two lines against BufferTarget::DrawIndirect. Because glGetBooleanv/glGetFloatv/glGetDoublev all widen from the integer path, one case fixes all four getters. - GL_BUFFER_ACCESS answered 0 for an unmapped buffer. Its initial value is GL_READ_WRITE and glUnmapBuffer restores it (GL 4.6 core table 6.2); 0 is not a legal value of that state at all, and the test threw on the unrecognised enum. - GL_BUFFER_ACCESS_FLAGS was not implemented, so it fell through to the invalid-pname arm. It is the MapBufferRange bitfield verbatim, which the mapping access flags already hold in normalised form - glMapBuffer's access enum is converted on the way in - so it converts straight back out, and reads zero while unmapped.
This commit is contained in:
@@ -330,12 +330,21 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
} else if (access & BufferMappingAccessBit::Write) {
|
||||
*params = GL_WRITE_ONLY;
|
||||
} else {
|
||||
*params = 0;
|
||||
*params = GL_READ_WRITE;
|
||||
}
|
||||
} else {
|
||||
*params = 0;
|
||||
// Initial value, and what glUnmapBuffer restores (GL 4.6 core table 6.2).
|
||||
*params = GL_READ_WRITE;
|
||||
}
|
||||
break;
|
||||
case GL_BUFFER_ACCESS_FLAGS:
|
||||
// The MapBufferRange flags verbatim; glMapBuffer's access enum has already been
|
||||
// normalised into the same bits. Zero while the buffer is not mapped.
|
||||
*params = bufferObject->IsMapped()
|
||||
? static_cast<GLint>(
|
||||
MG_Util::ConvertBufferMappingAccessToGLEnum(bufferObject->GetMappingAccess()))
|
||||
: 0;
|
||||
break;
|
||||
case GL_BUFFER_MAPPED:
|
||||
*params = bufferObject->IsMapped() ? GL_TRUE : GL_FALSE;
|
||||
break;
|
||||
|
||||
@@ -1030,6 +1030,11 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
*params = obj ? static_cast<GLint>(obj->GetExternalIndex()) : 0;
|
||||
return;
|
||||
}
|
||||
case GL_DRAW_INDIRECT_BUFFER_BINDING: {
|
||||
auto& obj = MG_State::pGLContext->GetBufferBindingSlot(BufferTarget::DrawIndirect).GetBoundObject();
|
||||
*params = obj ? static_cast<GLint>(obj->GetExternalIndex()) : 0;
|
||||
return;
|
||||
}
|
||||
case GL_MAX_DEBUG_GROUP_STACK_DEPTH:
|
||||
*params = 0; // debug-group entrypoints are stubbed
|
||||
return;
|
||||
|
||||
@@ -73,7 +73,7 @@ namespace MobileGL {
|
||||
}
|
||||
}
|
||||
|
||||
GLbitfield ConvertBufferMappingAccessToGLEnum(BufferMappingAccessBit access) {
|
||||
GLbitfield ConvertBufferMappingAccessToGLEnum(Flags<BufferMappingAccessBit> access) {
|
||||
GLbitfield result = 0;
|
||||
if (access & BufferMappingAccessBit::Read) result |= GL_MAP_READ_BIT;
|
||||
if (access & BufferMappingAccessBit::Write) result |= GL_MAP_WRITE_BIT;
|
||||
|
||||
@@ -14,6 +14,6 @@ namespace MobileGL {
|
||||
namespace MG_Util {
|
||||
GLenum ConvertBufferTargetToGLEnum(BufferTarget bufferTarget);
|
||||
GLenum ConvertBufferUsageToGLEnum(BufferUsage usage);
|
||||
GLbitfield ConvertBufferMappingAccessToGLEnum(BufferMappingAccessBit access);
|
||||
GLbitfield ConvertBufferMappingAccessToGLEnum(Flags<BufferMappingAccessBit> access);
|
||||
} // namespace MG_Util
|
||||
} // namespace MobileGL
|
||||
Reference in New Issue
Block a user