[Fix] (MG_Impl/VertexArray|Buffer): Fix incorrect name zero operations.

This commit is contained in:
BZLZHH
2025-08-12 16:54:56 +08:00
parent 5127479874
commit 256e947a5d
6 changed files with 19 additions and 8 deletions
+2 -2
View File
@@ -24,7 +24,7 @@ namespace MobileGL {
for (SizeT i = 0; i < static_cast<SizeT>(n); ++i) { for (SizeT i = 0; i < static_cast<SizeT>(n); ++i) {
Uint bufferName = buffers[i]; Uint bufferName = buffers[i];
if (bufferName == 0) continue; if (bufferName == 0) continue;
if (!BufferImpl::ValidateBufferName(bufferName)) continue; if (!BufferImpl::ValidateBufferName(bufferName, true)) continue;
MG_State::pGLContext->MarkBufferObjectForDeletion(bufferName); MG_State::pGLContext->MarkBufferObjectForDeletion(bufferName);
} }
} }
@@ -410,7 +410,7 @@ namespace MobileGL {
} }
void BindBuffer_State(GLenum target, GLuint buffer) { void BindBuffer_State(GLenum target, GLuint buffer) {
if (buffer != 0 && !BufferImpl::ValidateBufferName(buffer)) return; if (!BufferImpl::ValidateBufferName(buffer, true)) return;
BufferTarget bufferTarget = MG_Util::ConvertGLEnumToBufferTarget(target); BufferTarget bufferTarget = MG_Util::ConvertGLEnumToBufferTarget(target);
if (!BufferImpl::ValidateBufferTarget(bufferTarget)) return; if (!BufferImpl::ValidateBufferTarget(bufferTarget)) return;
+10 -1
View File
@@ -31,7 +31,16 @@ namespace MobileGL::MG_Impl::GLImpl {
return true; return true;
} }
Bool ValidateBufferName(Uint index) { Bool ValidateBufferName(Uint index, Bool allowZero) {
if (index == 0) {
if (allowZero) return true;
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl/BufferImpl",
"ValidateBufferName",
"Buffer name 0 is not valid."));
return false;
}
Bool isValid = MG_State::pGLContext->ValidateBufferName(index); Bool isValid = MG_State::pGLContext->ValidateBufferName(index);
if (isValid) return true; if (isValid) return true;
MG_State::pGLContext->RecordError( MG_State::pGLContext->RecordError(
+1 -1
View File
@@ -5,7 +5,7 @@
namespace MobileGL::MG_Impl::GLImpl { namespace MobileGL::MG_Impl::GLImpl {
namespace BufferImpl { namespace BufferImpl {
Bool ValidateBufferTarget(BufferTarget target); Bool ValidateBufferTarget(BufferTarget target);
Bool ValidateBufferName(Uint index); Bool ValidateBufferName(Uint index, Bool allowZero = false);
Bool ValidateBufferUsage(BufferUsage usage); Bool ValidateBufferUsage(BufferUsage usage);
Bool ValidateBufferMappingAccess(Flags<BufferMappingAccessBit> accessBits); Bool ValidateBufferMappingAccess(Flags<BufferMappingAccessBit> accessBits);
} // namespace BufferImpl } // namespace BufferImpl
@@ -107,7 +107,7 @@ namespace MobileGL {
return; return;
} }
if (!VertexArrayImpl::ValidateVertexArrayName(array)) return; if (!VertexArrayImpl::ValidateVertexArrayName(array, true)) return;
if (!MG_State::pGLContext->ValidateVertexArrayObject(array)) { if (!MG_State::pGLContext->ValidateVertexArrayObject(array)) {
MG_State::pGLContext->CreateVertexArrayObject(array); MG_State::pGLContext->CreateVertexArrayObject(array);
@@ -128,7 +128,7 @@ namespace MobileGL {
GLuint vao = arrays[i]; GLuint vao = arrays[i];
if (vao == 0) continue; if (vao == 0) continue;
if (!VertexArrayImpl::ValidateVertexArrayName(vao)) continue; if (!VertexArrayImpl::ValidateVertexArrayName(vao, true)) continue;
if (MG_State::pGLContext->GetBoundVertexArray() && if (MG_State::pGLContext->GetBoundVertexArray() &&
MG_State::pGLContext->GetBoundVertexArray() == MG_State::pGLContext->GetVertexArrayObject(vao)) { MG_State::pGLContext->GetBoundVertexArray() == MG_State::pGLContext->GetVertexArrayObject(vao)) {
@@ -7,8 +7,10 @@
namespace MobileGL::MG_Impl::GLImpl { namespace MobileGL::MG_Impl::GLImpl {
namespace VertexArrayImpl { namespace VertexArrayImpl {
Bool ValidateVertexArrayName(Uint index) { Bool ValidateVertexArrayName(Uint index, Bool allowZero) {
if (index == 0) { if (index == 0) {
if (allowZero) return true;
MG_State::pGLContext->RecordError( MG_State::pGLContext->RecordError(
ErrorCode::InvalidValue, MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "ValidateVertexArrayName", ErrorCode::InvalidValue, MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "ValidateVertexArrayName",
"Vertex array name 0 is not supported.")); "Vertex array name 0 is not supported."));
@@ -4,7 +4,7 @@
namespace MobileGL::MG_Impl::GLImpl { namespace MobileGL::MG_Impl::GLImpl {
namespace VertexArrayImpl { namespace VertexArrayImpl {
Bool ValidateVertexArrayName(Uint index); Bool ValidateVertexArrayName(Uint index, Bool allowZero = false);
Bool ValidateVertexArrayObject(Uint index); Bool ValidateVertexArrayObject(Uint index);
Bool ValidateVertexAttributeIndex(Uint index); Bool ValidateVertexAttributeIndex(Uint index);
Bool ValidateVertexAttribPointerParams(Uint index, SizeT size, DataType type, Int stride); Bool ValidateVertexAttribPointerParams(Uint index, SizeT size, DataType type, Int stride);