Merge pull request #1402 from shinovon/7

Check glGetError after glBufferData
This commit is contained in:
UnknownShadow200 2025-07-23 07:00:21 +10:00 committed by GitHub
commit 6f6eba3d2c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 28 additions and 3 deletions

View File

@ -106,3 +106,5 @@ typedef cc_uintptr GLpointer;
#define GL_COMPILE_STATUS 0x8B81
#define GL_LINK_STATUS 0x8B82
#define GL_INFO_LOG_LENGTH 0x8B84
#define GL_OUT_OF_MEMORY 0x0505

View File

@ -39,6 +39,8 @@ extern cc_string Game_Mppass;
#if defined CC_BUILD_N64 || defined CC_BUILD_PS1 || defined CC_BUILD_SATURN
#define DEFAULT_VIEWDIST 20
#elif defined CC_BUILD_SYMBIAN
#define DEFAULT_VIEWDIST 64
#elif defined CC_BUILD_NDS
#define DEFAULT_VIEWDIST 192
#else

View File

@ -146,8 +146,13 @@ void* Gfx_LockVb(GfxResourceID vb, VertexFormat fmt, int count) {
return FastAllocTempMem(count * strideSizes[fmt]);
}
void Gfx_UnlockVb(GfxResourceID vb) {
static cc_bool UnlockVb(GfxResourceID vb) {
_glBufferData(GL_ARRAY_BUFFER, tmpSize, tmpData, GL_STATIC_DRAW);
#if defined CC_BUILD_SYMBIAN
return _glGetError() != GL_OUT_OF_MEMORY;
#else
return true;
#endif
}

View File

@ -91,8 +91,9 @@ void* Gfx_LockVb(GfxResourceID vb, VertexFormat fmt, int count) {
return FastAllocTempMem(count * strideSizes[fmt]);
}
void Gfx_UnlockVb(GfxResourceID vb) {
static cc_bool UnlockVb(GfxResourceID vb) {
UpdateDisplayList(ptr_to_uint(vb), tmpData, tmpFormat, tmpCount);
return true;
}
GfxResourceID Gfx_CreateVb2(void* vertices, VertexFormat fmt, int count) {

View File

@ -118,8 +118,13 @@ void* Gfx_LockVb(GfxResourceID vb, VertexFormat fmt, int count) {
return FastAllocTempMem(count * strideSizes[fmt]);
}
void Gfx_UnlockVb(GfxResourceID vb) {
static cc_bool UnlockVb(GfxResourceID vb) {
glBufferData(GL_ARRAY_BUFFER, tmpSize, tmpData, GL_STATIC_DRAW);
#if defined CC_BUILD_SYMBIAN
return glGetError() != GL_OUT_OF_MEMORY;
#else
return true;
#endif
}

View File

@ -419,3 +419,13 @@ void Gfx_SetScissor(int x, int y, int w, int h) {
_glScissor(x, Game.Height - h - y, w, h);
}
static cc_bool UnlockVb(GfxResourceID vb);
void Gfx_UnlockVb(GfxResourceID vb) {
for (;;) {
if (UnlockVb(vb)) return;
if (!Game_ReduceVRAM()) Process_Abort("Out of video memory! (updating static VB)");
}
}