diff --git a/src/modules/graphics/opengl/Shader.cpp b/src/modules/graphics/opengl/Shader.cpp index 9bacf446e..63c1845e0 100644 --- a/src/modules/graphics/opengl/Shader.cpp +++ b/src/modules/graphics/opengl/Shader.cpp @@ -358,6 +358,7 @@ void Shader::mapActiveUniforms() glGetProgramInterfaceiv(program, GL_SHADER_STORAGE_BLOCK, GL_ACTIVE_RESOURCES, &numstoragebuffers); char namebuffer[2048] = { '\0' }; + int nextstoragebufferbinding = 0; for (int sindex = 0; sindex < numstoragebuffers; sindex++) { @@ -405,8 +406,11 @@ void Shader::mapActiveUniforms() memset(u.buffers, 0, sizeof(Buffer*)* u.count); } - GLenum props[] = { GL_BUFFER_BINDING }; - glGetProgramResourceiv(program, GL_SHADER_STORAGE_BLOCK, sindex, 1, props, 1, nullptr, u.ints); + // Unlike local uniforms and attributes, OpenGL doesn't auto-assign storage + // block bindings if they're unspecified in the shader. So we overwrite them + // regardless, here. + u.ints[0] = nextstoragebufferbinding++; + glShaderStorageBlockBinding(program, sindex, u.ints[0]); BufferBinding binding; binding.bindingindex = u.ints[0]; @@ -1198,6 +1202,9 @@ Shader::MatrixSize Shader::getMatrixSize(GLenum type) const m.columns = 4; m.rows = 3; break; + default: + m.columns = m.rows = 0; + break; } return m;