mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-07-13 16:45:56 +00:00
OpenGL: Allow separate VS and FS push constants
This commit is contained in:
parent
1b6f7535aa
commit
91b475f369
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
#include "backend/opengl/ShaderModuleGL.h"
|
#include "backend/opengl/ShaderModuleGL.h"
|
||||||
|
|
||||||
|
#include "common/Assert.h"
|
||||||
#include "common/Platform.h"
|
#include "common/Platform.h"
|
||||||
|
|
||||||
#include <spirv-cross/spirv_glsl.hpp>
|
#include <spirv-cross/spirv_glsl.hpp>
|
||||||
@ -58,6 +59,28 @@ namespace opengl {
|
|||||||
#endif
|
#endif
|
||||||
compiler.set_options(options);
|
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);
|
ExtractSpirvInfo(compiler);
|
||||||
|
|
||||||
const auto& bindingInfo = GetBindingInfo();
|
const auto& bindingInfo = GetBindingInfo();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user