Fix(buffer): gen buffers before glBindBufferRange/Base

This commit is contained in:
Tungstend 2025-03-24 12:03:55 +08:00
parent bceac247ca
commit 46972beced
3 changed files with 44 additions and 4 deletions

View File

@ -111,7 +111,7 @@ GLboolean glIsBuffer(GLuint buffer) {
void glBindBuffer(GLenum target, GLuint buffer) {
LOG()
LOG_D("glBindBuffer, target = %s, buffer = %d", glEnumToString(target), buffer)
if (buffer == 0) {
if (!has_buffer(buffer) || buffer == 0) {
GLES.glBindBuffer(target, buffer);
CHECK_GL_ERROR
return;
@ -126,6 +126,42 @@ void glBindBuffer(GLenum target, GLuint buffer) {
CHECK_GL_ERROR
}
void glBindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size) {
LOG()
LOG_D("glBindBufferRange, target = %s, index = %d, buffer = %d, offset = %p, size = %zi", glEnumToString(target), index, buffer, (void*) offset, size)
if (!has_buffer(buffer) || buffer == 0) {
GLES.glBindBufferRange(target, index, buffer, offset, size);
CHECK_GL_ERROR
return;
}
GLuint real_buffer = find_real_buffer(buffer);
if (!real_buffer) {
GLES.glGenBuffers(1, &real_buffer);
modify_buffer(buffer, real_buffer);
CHECK_GL_ERROR
}
GLES.glBindBufferRange(target, index, real_buffer, offset, size);
CHECK_GL_ERROR
}
void glBindBufferBase(GLenum target, GLuint index, GLuint buffer) {
LOG()
LOG_D("glBindBufferBase, target = %s, index = %d, buffer = %d", glEnumToString(target), index, buffer)
if (!has_buffer(buffer) || buffer == 0) {
GLES.glBindBufferBase(target, index, buffer);
CHECK_GL_ERROR
return;
}
GLuint real_buffer = find_real_buffer(buffer);
if (!real_buffer) {
GLES.glGenBuffers(1, &real_buffer);
modify_buffer(buffer, real_buffer);
CHECK_GL_ERROR
}
GLES.glBindBufferBase(target, index, real_buffer);
CHECK_GL_ERROR
}
void glBufferData(GLenum target, GLsizeiptr size, const void *data, GLenum usage) {
LOG()
LOG_D("glBufferData, target = %s, size = %d, data = 0x%x, usage = %s",
@ -280,7 +316,7 @@ GLboolean glIsVertexArray(GLuint array) {
void glBindVertexArray(GLuint array) {
LOG()
LOG_D("glBindVertexArray(%d)", array)
if (array == 0) {
if (!has_array(array) || array == 0) {
GLES.glBindVertexArray(array);
CHECK_GL_ERROR
return;

View File

@ -59,6 +59,10 @@ GLAPI GLAPIENTRY GLboolean glIsBuffer(GLuint buffer);
GLAPI GLAPIENTRY void glBindBuffer(GLenum target, GLuint buffer);
GLAPI GLAPIENTRY void glBindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);
GLAPI GLAPIENTRY void glBindBufferBase(GLenum target, GLuint index, GLuint buffer);
GLAPI GLAPIENTRY GLboolean glUnmapBuffer(GLenum target);
GLAPI GLAPIENTRY void *glMapBuffer(GLenum target, GLenum access);

View File

@ -187,8 +187,8 @@ NATIVE_FUNCTION_HEAD(void, glFlushMappedBufferRange, GLenum target, GLintptr off
NATIVE_FUNCTION_HEAD(void, glGetIntegeri_v, GLenum target, GLuint index, GLint *data) NATIVE_FUNCTION_END_NO_RETURN(void, glGetIntegeri_v, target,index,data)
NATIVE_FUNCTION_HEAD(void, glBeginTransformFeedback, GLenum primitiveMode) NATIVE_FUNCTION_END_NO_RETURN(void, glBeginTransformFeedback, primitiveMode)
NATIVE_FUNCTION_HEAD(void, glEndTransformFeedback) NATIVE_FUNCTION_END_NO_RETURN(void, glEndTransformFeedback)
NATIVE_FUNCTION_HEAD(void, glBindBufferRange, GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size) NATIVE_FUNCTION_END_NO_RETURN(void, glBindBufferRange, target,index,buffer,offset,size)
NATIVE_FUNCTION_HEAD(void, glBindBufferBase, GLenum target, GLuint index, GLuint buffer) NATIVE_FUNCTION_END_NO_RETURN(void, glBindBufferBase, target,index,buffer)
//NATIVE_FUNCTION_HEAD(void, glBindBufferRange, GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size) NATIVE_FUNCTION_END_NO_RETURN(void, glBindBufferRange, target,index,buffer,offset,size)
//NATIVE_FUNCTION_HEAD(void, glBindBufferBase, GLenum target, GLuint index, GLuint buffer) NATIVE_FUNCTION_END_NO_RETURN(void, glBindBufferBase, target,index,buffer)
NATIVE_FUNCTION_HEAD(void, glTransformFeedbackVaryings, GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode) NATIVE_FUNCTION_END_NO_RETURN(void, glTransformFeedbackVaryings, program,count,varyings,bufferMode)
NATIVE_FUNCTION_HEAD(void, glGetTransformFeedbackVarying, GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name) NATIVE_FUNCTION_END_NO_RETURN(void, glGetTransformFeedbackVarying, program,index,bufSize,length,size,type,name)
NATIVE_FUNCTION_HEAD(void, glVertexAttribIPointer, GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer) NATIVE_FUNCTION_END_NO_RETURN(void, glVertexAttribIPointer, index,size,type,stride,pointer)