Skip to content

Commit

Permalink
drivers/glrend/shader: don't call glObjectLabel() until an object's b…
Browse files Browse the repository at this point in the history
…een bound at least once
  • Loading branch information
vs49688 committed Oct 12, 2024
1 parent 85a0e54 commit 7273809
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
8 changes: 4 additions & 4 deletions drivers/glrend/shader_brender.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@
static void VIDEOI_GetShaderVariables(HVIDEO hVideo)
{
glGenBuffers(1, &hVideo->brenderProgram.uboScene);
DeviceGLObjectLabel(GL_BUFFER, hVideo->brenderProgram.uboScene, BR_GLREND_DEBUG_INTERNAL_PREFIX "brender:shader:ubo:scene");

glBindBuffer(GL_UNIFORM_BUFFER, hVideo->brenderProgram.uboScene);
glUniformBlockBinding(hVideo->brenderProgram.program, hVideo->brenderProgram.blockIndexScene,
hVideo->brenderProgram.blockBindingScene);
glBindBufferBase(GL_UNIFORM_BUFFER, hVideo->brenderProgram.blockBindingScene, hVideo->brenderProgram.uboScene);
glBufferData(GL_UNIFORM_BUFFER, sizeof(shader_data_scene), NULL, GL_DYNAMIC_DRAW);

glGenBuffers(1, &hVideo->brenderProgram.uboModel);
DeviceGLObjectLabel(GL_BUFFER, hVideo->brenderProgram.uboModel, BR_GLREND_DEBUG_INTERNAL_PREFIX "brender:shader:ubo:model");
DeviceGLObjectLabel(GL_BUFFER, hVideo->brenderProgram.uboScene, BR_GLREND_DEBUG_INTERNAL_PREFIX "brender:shader:ubo:scene");

glGenBuffers(1, &hVideo->brenderProgram.uboModel);
glBindBuffer(GL_UNIFORM_BUFFER, hVideo->brenderProgram.uboModel);
glUniformBlockBinding(hVideo->brenderProgram.program, hVideo->brenderProgram.blockIndexModel,
hVideo->brenderProgram.blockBindingModel);
glBindBufferBase(GL_UNIFORM_BUFFER, hVideo->brenderProgram.blockBindingModel, hVideo->brenderProgram.uboModel);
glBufferData(GL_UNIFORM_BUFFER, sizeof(shader_data_model), NULL, GL_DYNAMIC_DRAW);

DeviceGLObjectLabel(GL_BUFFER, hVideo->brenderProgram.uboModel, BR_GLREND_DEBUG_INTERNAL_PREFIX "brender:shader:ubo:model");

hVideo->brenderProgram.attributes.aPosition = glGetAttribLocation(hVideo->brenderProgram.program, "aPosition");
hVideo->brenderProgram.attributes.aUV = glGetAttribLocation(hVideo->brenderProgram.program, "aUV");
hVideo->brenderProgram.attributes.aNormal = glGetAttribLocation(hVideo->brenderProgram.program, "aNormal");
Expand Down
9 changes: 6 additions & 3 deletions drivers/glrend/shader_rect.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ br_boolean VIDEOI_CompileRectShader(HVIDEO hVideo)
DeviceGLObjectLabel(GL_PROGRAM, hVideo->rectProgram.program, BR_GLREND_DEBUG_INTERNAL_PREFIX "rect:program");

glGenVertexArrays(1, &hVideo->rectProgram.vao);
DeviceGLObjectLabel(GL_VERTEX_ARRAY, hVideo->rectProgram.vao, BR_GLREND_DEBUG_INTERNAL_PREFIX "rect:vao");
glBindVertexArray(hVideo->rectProgram.vao);
glBindVertexArray(0);

glGenBuffers(1, &hVideo->rectProgram.ubo);
DeviceGLObjectLabel(GL_BUFFER, hVideo->rectProgram.ubo, BR_GLREND_DEBUG_INTERNAL_PREFIX "rect:ubo");
DeviceGLObjectLabel(GL_VERTEX_ARRAY, hVideo->rectProgram.vao, BR_GLREND_DEBUG_INTERNAL_PREFIX "rect:vao");

hVideo->rectProgram.uSampler = glGetUniformLocation(hVideo->rectProgram.program, "uSampler");
hVideo->rectProgram.uIndexTex = glGetUniformLocation(hVideo->rectProgram.program, "uIndexTex");
Expand All @@ -34,10 +34,13 @@ br_boolean VIDEOI_CompileRectShader(HVIDEO hVideo)
glUniformBlockBinding(hVideo->rectProgram.program, hVideo->rectProgram.block_index_rect_data,
hVideo->rectProgram.block_binding_rect_data);

glGenBuffers(1, &hVideo->rectProgram.ubo);
glBindBuffer(GL_UNIFORM_BUFFER, hVideo->rectProgram.ubo);
glBindBufferBase(GL_UNIFORM_BUFFER, hVideo->rectProgram.block_binding_rect_data, hVideo->rectProgram.ubo);
glBindBuffer(GL_UNIFORM_BUFFER, 0);

DeviceGLObjectLabel(GL_BUFFER, hVideo->rectProgram.ubo, BR_GLREND_DEBUG_INTERNAL_PREFIX "rect:ubo");

glBindFragDataLocation(hVideo->rectProgram.program, 0, "main_colour");

prog_failed:
Expand Down
9 changes: 6 additions & 3 deletions drivers/glrend/shader_text.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ br_boolean VIDEOI_CompileTextShader(HVIDEO hVideo)
DeviceGLObjectLabel(GL_PROGRAM, hVideo->textProgram.program, BR_GLREND_DEBUG_INTERNAL_PREFIX "text:program");

glGenVertexArrays(1, &hVideo->textProgram.vao_glyphs);
DeviceGLObjectLabel(GL_VERTEX_ARRAY, hVideo->textProgram.vao_glyphs, BR_GLREND_DEBUG_INTERNAL_PREFIX "text:vao");
glBindVertexArray(hVideo->textProgram.vao_glyphs);
glBindVertexArray(0);

glGenBuffers(1, &hVideo->textProgram.ubo_glyphs);
DeviceGLObjectLabel(GL_BUFFER, hVideo->textProgram.ubo_glyphs, BR_GLREND_DEBUG_INTERNAL_PREFIX "text:ubo");
DeviceGLObjectLabel(GL_VERTEX_ARRAY, hVideo->textProgram.vao_glyphs, BR_GLREND_DEBUG_INTERNAL_PREFIX "text:vao");

hVideo->textProgram.uSampler = glGetUniformLocation(hVideo->textProgram.program, "uSampler");

Expand All @@ -41,10 +41,13 @@ br_boolean VIDEOI_CompileTextShader(HVIDEO hVideo)
glUniformBlockBinding(hVideo->textProgram.program, hVideo->textProgram.block_index_glyphs,
hVideo->textProgram.block_binding_glyphs);

glGenBuffers(1, &hVideo->textProgram.ubo_glyphs);
glBindBuffer(GL_UNIFORM_BUFFER, hVideo->textProgram.ubo_glyphs);
glBindBufferBase(GL_UNIFORM_BUFFER, hVideo->textProgram.block_binding_glyphs, hVideo->textProgram.ubo_glyphs);
glBindBuffer(GL_UNIFORM_BUFFER, 0);

DeviceGLObjectLabel(GL_BUFFER, hVideo->textProgram.ubo_glyphs, BR_GLREND_DEBUG_INTERNAL_PREFIX "text:ubo");

glBindFragDataLocation(hVideo->textProgram.program, 0, "main_colour");

prog_failed:
Expand Down

0 comments on commit 7273809

Please sign in to comment.