mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-25 16:24:24 +00:00
Emit std430 layout qualifiers for storage buffers (#1435)
* Remove unused petgraph dependency from glsl-out * Emit std430 layout qualifiers for storage buffers
This commit is contained in:
parent
2e73e48657
commit
a4bf25a0d5
@ -35,7 +35,7 @@ default = []
|
||||
dot-out = []
|
||||
glsl-in = ["pp-rs"]
|
||||
glsl-validate = []
|
||||
glsl-out = ["petgraph"]
|
||||
glsl-out = []
|
||||
msl-out = []
|
||||
serialize = ["serde", "indexmap/serde-1"]
|
||||
deserialize = ["serde", "indexmap/serde-1"]
|
||||
|
@ -129,6 +129,10 @@ impl Version {
|
||||
fn supports_early_depth_test(&self) -> bool {
|
||||
*self >= Version::Desktop(130) || *self >= Version::Embedded(310)
|
||||
}
|
||||
|
||||
fn supports_std430_layout(&self) -> bool {
|
||||
*self >= Version::Desktop(430) || *self >= Version::Embedded(310)
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialOrd for Version {
|
||||
@ -816,8 +820,28 @@ impl<'a, W: Write> Writer<'a, W> {
|
||||
if self.options.version.supports_explicit_locations() {
|
||||
if let Some(ref br) = global.binding {
|
||||
match self.options.binding_map.get(br) {
|
||||
Some(binding) => write!(self.out, "layout(binding = {}) ", binding)?,
|
||||
None => log::debug!("unassigned binding for {:?}", global.name),
|
||||
Some(binding) => {
|
||||
let layout = match global.class {
|
||||
crate::StorageClass::Storage { .. } => {
|
||||
if self.options.version.supports_std430_layout() {
|
||||
"std430, "
|
||||
} else {
|
||||
"std140, "
|
||||
}
|
||||
}
|
||||
crate::StorageClass::Uniform => "std140, ",
|
||||
_ => "",
|
||||
};
|
||||
write!(self.out, "layout({}binding = {}) ", layout, binding)?
|
||||
}
|
||||
None => {
|
||||
log::debug!("unassigned binding for {:?}", global.name);
|
||||
if let crate::StorageClass::Storage { .. } = global.class {
|
||||
if self.options.version.supports_std430_layout() {
|
||||
write!(self.out, "layout(std430) ")?
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ precision highp int;
|
||||
|
||||
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
|
||||
|
||||
buffer Bar_block_0Cs {
|
||||
layout(std430) buffer Bar_block_0Cs {
|
||||
mat4x4 matrix;
|
||||
int atom;
|
||||
uvec2 arr[2];
|
||||
|
@ -3,7 +3,7 @@
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
|
||||
buffer Bar_block_0Vs {
|
||||
layout(std430) buffer Bar_block_0Vs {
|
||||
mat4x4 matrix;
|
||||
int atom;
|
||||
uvec2 arr[2];
|
||||
|
@ -20,11 +20,11 @@ uniform SimParams_block_0Cs {
|
||||
float rule3Scale;
|
||||
} _group_0_binding_0;
|
||||
|
||||
readonly buffer Particles_block_1Cs {
|
||||
layout(std430) readonly buffer Particles_block_1Cs {
|
||||
Particle particles[];
|
||||
} _group_0_binding_1;
|
||||
|
||||
buffer Particles_block_2Cs {
|
||||
layout(std430) buffer Particles_block_2Cs {
|
||||
Particle particles[];
|
||||
} _group_0_binding_2;
|
||||
|
||||
|
@ -13,7 +13,7 @@ uniform Globals_block_0Fs {
|
||||
uvec4 num_lights;
|
||||
} _group_0_binding_0;
|
||||
|
||||
readonly buffer Lights_block_1Fs {
|
||||
layout(std430) readonly buffer Lights_block_1Fs {
|
||||
Light data[];
|
||||
} _group_0_binding_1;
|
||||
|
||||
|
@ -8,7 +8,7 @@ struct VertexOutput {
|
||||
vec3 uv;
|
||||
};
|
||||
|
||||
layout(binding = 0) uniform Data_block_0Vs {
|
||||
layout(std140, binding = 0) uniform Data_block_0Vs {
|
||||
mat4x4 proj_inv;
|
||||
mat4x4 view;
|
||||
} _group_0_binding_0;
|
||||
|
Loading…
Reference in New Issue
Block a user