OpenGL: Don't bind non-existent shader resources.
In OpenGL we have to query a resource's location or index before we can bind it. The driver can tell us that the resource doesn't exist using special values (-1 for locations, GL_INVALID_INDEX for indices). This happens when Dawn compiles a pipeline that has bind group bindings that none of the shader modules uses. This was found while enable OpenGL debug output. BUG=dawn:190 Change-Id: I58b3a1a65f87b4408985c1258f1a95379e6b540e Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9203 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
parent
69f1db7248
commit
9dffe11696
|
@ -120,13 +120,18 @@ namespace dawn_native { namespace opengl {
|
|||
switch (groupInfo.types[binding]) {
|
||||
case dawn::BindingType::UniformBuffer: {
|
||||
GLint location = gl.GetUniformBlockIndex(mProgram, name.c_str());
|
||||
if (location != -1) {
|
||||
gl.UniformBlockBinding(mProgram, location, indices[group][binding]);
|
||||
}
|
||||
} break;
|
||||
|
||||
case dawn::BindingType::StorageBuffer: {
|
||||
GLuint location = gl.GetProgramResourceIndex(
|
||||
mProgram, GL_SHADER_STORAGE_BLOCK, name.c_str());
|
||||
gl.ShaderStorageBlockBinding(mProgram, location, indices[group][binding]);
|
||||
if (location != GL_INVALID_INDEX) {
|
||||
gl.ShaderStorageBlockBinding(mProgram, location,
|
||||
indices[group][binding]);
|
||||
}
|
||||
} break;
|
||||
|
||||
case dawn::BindingType::Sampler:
|
||||
|
@ -161,6 +166,11 @@ namespace dawn_native { namespace opengl {
|
|||
for (const auto& combined : combinedSamplersSet) {
|
||||
std::string name = combined.GetName();
|
||||
GLint location = gl.GetUniformLocation(mProgram, name.c_str());
|
||||
|
||||
if (location == -1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
gl.Uniform1i(location, textureUnit);
|
||||
|
||||
GLuint samplerIndex =
|
||||
|
|
Loading…
Reference in New Issue