Fix(buffer): use real buffer when glTexBuffer(Range)

This commit is contained in:
Tungstend 2025-03-30 19:21:22 +08:00
parent 094a8bb3b3
commit f11ba3f11b
3 changed files with 43 additions and 2 deletions

View File

@ -241,6 +241,43 @@ void glBindVertexBuffer(GLuint bindingindex, GLuint buffer, GLintptr offset, GLs
CHECK_GL_ERROR
}
// Todo: any glGet* related to this function?
void glTexBuffer(GLenum target, GLenum internalformat, GLuint buffer) {
LOG()
LOG_D("glTexBuffer, target = %s, internalformat = %s, buffer = %d", glEnumToString(target), glEnumToString(internalformat), buffer)
if (!has_buffer(buffer) || buffer == 0) {
GLES.glTexBuffer(target, internalformat, 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.glTexBuffer(target, internalformat, real_buffer);
CHECK_GL_ERROR
}
void glTexBufferRange(GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size) {
LOG()
LOG_D("glTexBufferRange, target = %s, internalformat = %s, buffer = %d, offset = %p, size = %zi", glEnumToString(target), glEnumToString(internalformat), buffer, (void*) offset, size)
if (!has_buffer(buffer) || buffer == 0) {
GLES.glTexBufferRange(target, internalformat, 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.glTexBufferRange(target, internalformat, real_buffer, offset, size);
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",

View File

@ -69,6 +69,10 @@ GLAPI GLAPIENTRY void glBindBufferBase(GLenum target, GLuint index, GLuint buffe
GLAPI GLAPIENTRY void glBindVertexBuffer(GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride);
GLAPI GLAPIENTRY void glTexBuffer(GLenum target, GLenum internalformat, GLuint buffer);
GLAPI GLAPIENTRY void glTexBufferRange(GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size);
GLAPI GLAPIENTRY GLboolean glUnmapBuffer(GLenum target);
GLAPI GLAPIENTRY void *glMapBuffer(GLenum target, GLenum access);

View File

@ -364,7 +364,7 @@ NATIVE_FUNCTION_HEAD(void, glSamplerParameterIiv, GLuint sampler, GLenum pname,
NATIVE_FUNCTION_HEAD(void, glSamplerParameterIuiv, GLuint sampler, GLenum pname, const GLuint *param) NATIVE_FUNCTION_END_NO_RETURN(void, glSamplerParameterIuiv, sampler,pname,param)
NATIVE_FUNCTION_HEAD(void, glGetSamplerParameterIiv, GLuint sampler, GLenum pname, GLint *params) NATIVE_FUNCTION_END_NO_RETURN(void, glGetSamplerParameterIiv, sampler,pname,params)
NATIVE_FUNCTION_HEAD(void, glGetSamplerParameterIuiv, GLuint sampler, GLenum pname, GLuint *params) NATIVE_FUNCTION_END_NO_RETURN(void, glGetSamplerParameterIuiv, sampler,pname,params)
NATIVE_FUNCTION_HEAD(void, glTexBuffer, GLenum target, GLenum internalformat, GLuint buffer) NATIVE_FUNCTION_END_NO_RETURN(void, glTexBuffer, target,internalformat,buffer)
NATIVE_FUNCTION_HEAD(void, glTexBufferRange, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size) NATIVE_FUNCTION_END_NO_RETURN(void, glTexBufferRange, target,internalformat,buffer,offset,size)
//NATIVE_FUNCTION_HEAD(void, glTexBuffer, GLenum target, GLenum internalformat, GLuint buffer) NATIVE_FUNCTION_END_NO_RETURN(void, glTexBuffer, target,internalformat,buffer)
//NATIVE_FUNCTION_HEAD(void, glTexBufferRange, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size) NATIVE_FUNCTION_END_NO_RETURN(void, glTexBufferRange, target,internalformat,buffer,offset,size)
NATIVE_FUNCTION_HEAD(void, glTexStorage3DMultisample, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations) NATIVE_FUNCTION_END_NO_RETURN(void, glTexStorage3DMultisample, target,samples,internalformat,width,height,depth,fixedsamplelocations)
NATIVE_FUNCTION_HEAD(void*, glMapBufferRange, GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) NATIVE_FUNCTION_END(void*, glMapBufferRange, target,offset,length,access)