[glsl-out] Add stage postfix for block structs

This commit is contained in:
Gordon-F
2021-07-20 21:42:15 +03:00
committed by Dzmitry Malyshau
parent 140a9bfa8f
commit e017cb402e
5 changed files with 13 additions and 8 deletions

View File

@@ -1200,7 +1200,12 @@ impl<'a, W: Write> Writer<'a, W> {
// generated number so it's unique and `members` are the same as in a struct
if block {
// Write the block name, it's just the struct name appended with `_block_ID`
let block_name = format!("{}_block_{}", name, self.block_id.generate());
let stage_postfix = match self.entry_point.stage {
ShaderStage::Vertex => "Vs",
ShaderStage::Fragment => "Fs",
ShaderStage::Compute => "Cs",
};
let block_name = format!("{}_block_{}{}", name, self.block_id.generate(), stage_postfix);
writeln!(self.out, "{} {{", block_name)?;
self.reflection_names.insert(handle, block_name);

View File

@@ -10,7 +10,7 @@ struct Particle {
vec2 vel;
};
uniform SimParams_block_0 {
uniform SimParams_block_0Cs {
float deltaT;
float rule1Distance;
float rule2Distance;
@@ -20,11 +20,11 @@ uniform SimParams_block_0 {
float rule3Scale;
} _group_0_binding_0;
readonly buffer Particles_block_1 {
readonly buffer Particles_block_1Cs {
Particle particles[];
} _group_0_binding_1;
buffer Particles_block_2 {
buffer Particles_block_2Cs {
Particle particles[];
} _group_0_binding_2;

View File

@@ -15,7 +15,7 @@ vec2 v_uv = vec2(0, 0);
vec2 a_uv1 = vec2(0, 0);
struct gen_gl_PerVertex_block_0 {
struct gen_gl_PerVertex_block_0Vs {
vec4 gen_gl_Position;
float gen_gl_PointSize;
float gen_gl_ClipDistance[1];

View File

@@ -9,11 +9,11 @@ struct Light {
vec4 color;
};
uniform Globals_block_0 {
uniform Globals_block_0Fs {
uvec4 num_lights;
} _group_0_binding_0;
readonly buffer Lights_block_1 {
readonly buffer Lights_block_1Fs {
Light data[];
} _group_0_binding_1;

View File

@@ -8,7 +8,7 @@ struct VertexOutput {
vec3 uv;
};
layout(binding = 0) uniform Data_block_0 {
layout(binding = 0) uniform Data_block_0Vs {
mat4x4 proj_inv;
mat4x4 view;
} _group_0_binding_0;