mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-09 20:58:31 +09:00
[Feat|Fix|Improvement] (All): Continue building the basic structure.
Feat: implement MG_Impl/Buffer Feat: implement MG_State/ErrorState and integrate it into MG_State/GLContext Feat: add buffer deletion management Feat: introduce `INSERTION_POINT` (https://github.com/MobileGL-Dev/MobileGLCodeManager) Feat: add tests about MG_Impl/Buffer and buffer deletion feature Feat: add several converters Fix: fix some compiling errors Fix: fix some incorrect behaviors in MG_State/Buffer Improvement: remove some current statements at the beginning of the source file, which will be added uniformly soon Improvement: optimize some naming
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
#include "../../../Includes.h"
|
||||
|
||||
namespace MobileGL::MG_Impl::GLImpl {
|
||||
namespace BufferImpl {
|
||||
bool ValidateBufferTarget(BufferTarget target) {
|
||||
if (target != BufferTarget::Unknown)
|
||||
return true;
|
||||
|
||||
using namespace MG_Util;
|
||||
String bufferTargetStr = ConvertBufferTargetToString(target);
|
||||
String glTargetStr = ConvertGLEnumToString(ConvertBufferTargetToGLEnum(target));
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidEnum,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl/BufferImpl", "ValidateBufferTarget",
|
||||
std::format("Target {} ({}) is not valid.",
|
||||
bufferTargetStr, glTargetStr)));
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ValidateBufferName(Uint index) {
|
||||
bool isValid = MG_State::pGLContext->ValidateBufferName(index);
|
||||
if (isValid)
|
||||
return true;
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl/BufferImpl", "ValidateBufferName",
|
||||
std::format("Buffer name {} is not valid.", index)));
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ValidateBufferUsage(BufferUsage usage) {
|
||||
if (usage != BufferUsage::Unknown) {
|
||||
return true;
|
||||
}
|
||||
using namespace MG_Util;
|
||||
String bufferUsageStr = ConvertBufferUsageToString(usage);
|
||||
String glUsageStr = ConvertGLEnumToString(ConvertBufferUsageToGLEnum(usage));
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidEnum,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl/BufferImpl", "ValidateBufferUsage",
|
||||
std::format("Usage {} ({}) is not one of the allowable values.",
|
||||
bufferUsageStr, glUsageStr)));
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ValidateBufferMappingAccess(BufferMappingAccessBit accessBits) {
|
||||
if (accessBits == BufferMappingAccessBit::Null) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidEnum,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl/BufferImpl", "ValidateBufferMappingAccess",
|
||||
"Access bits cannot be null."));
|
||||
return false;
|
||||
}
|
||||
|
||||
const BufferMappingAccessBit validBits =
|
||||
BufferMappingAccessBit::Read |
|
||||
BufferMappingAccessBit::Write |
|
||||
BufferMappingAccessBit::InvalidateRange |
|
||||
BufferMappingAccessBit::InvalidateBuffer |
|
||||
BufferMappingAccessBit::FlushExplicit |
|
||||
BufferMappingAccessBit::Unsynchronized |
|
||||
BufferMappingAccessBit::Persistent |
|
||||
BufferMappingAccessBit::Coherent;
|
||||
|
||||
if ((accessBits & validBits) != accessBits) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidEnum,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl/BufferImpl", "ValidateBufferMappingAccess",
|
||||
"Access bits cannot contain invalid flags."));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user