OpenGL: Allow separate VS and FS push constants

This commit is contained in:
Corentin Wallez 2017-08-17 16:16:00 -04:00 committed by Corentin Wallez
parent 1b6f7535aa
commit 91b475f369
1 changed files with 23 additions and 0 deletions

View File

@ -14,6 +14,7 @@
#include "backend/opengl/ShaderModuleGL.h"
#include "common/Assert.h"
#include "common/Platform.h"
#include <spirv-cross/spirv_glsl.hpp>
@ -58,6 +59,28 @@ namespace opengl {
#endif
compiler.set_options(options);
// Rename the push constant block to be prefixed with the shader stage type so that uniform names
// don't match between the FS and the VS.
const auto& resources = compiler.get_shader_resources();
if (resources.push_constant_buffers.size() > 0) {
const char* prefix = nullptr;
switch (compiler.get_execution_model()) {
case spv::ExecutionModelVertex:
prefix = "vs_";
break;
case spv::ExecutionModelFragment:
prefix = "fs_";
break;
case spv::ExecutionModelGLCompute:
prefix = "cs_";
break;
default:
UNREACHABLE();
}
auto interfaceBlock = resources.push_constant_buffers[0];
compiler.set_name(interfaceBlock.id, prefix + interfaceBlock.name);
}
ExtractSpirvInfo(compiler);
const auto& bindingInfo = GetBindingInfo();