Skip to content

Commit

Permalink
glsl-out: Add test for push constants
Browse files Browse the repository at this point in the history
  • Loading branch information
JCapucho authored and kvark committed Jan 17, 2022
1 parent 91ca923 commit a1840be
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/in/push-constants.param.ron
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
(
god_mode: true,
glsl: (
version: Embedded(320),
writer_flags: (bits: 0),
binding_map: {},
push_constant_binding: 4,
),
)
13 changes: 13 additions & 0 deletions tests/in/push-constants.wgsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
struct PushConstants {
multiplier: f32;
};
var<push_constant> pc: PushConstants;

struct FragmentIn {
[[location(0)]] color: vec4<f32>;
};

[[stage(fragment)]]
fn main(in: FragmentIn) -> [[location(0)]] vec4<f32> {
return in.color * pc.multiplier;
}
23 changes: 23 additions & 0 deletions tests/out/glsl/push-constants.main.Fragment.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#version 320 es

precision highp float;
precision highp int;

struct PushConstants {
float multiplier;
};
struct FragmentIn {
vec4 color;
};
layout(std140, binding = 4) uniform PushConstants_block_0Fragment { PushConstants pc; };

layout(location = 0) smooth in vec4 _vs2fs_location0;
layout(location = 0) out vec4 _fs2p_location0;

void main() {
FragmentIn in_ = FragmentIn(_vs2fs_location0);
float _e4 = pc.multiplier;
_fs2p_location0 = (in_.color * _e4);
return;
}

1 change: 1 addition & 0 deletions tests/snapshots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ fn convert_wgsl() {
Targets::SPIRV | Targets::METAL | Targets::HLSL | Targets::WGSL | Targets::GLSL,
),
("extra", Targets::SPIRV | Targets::METAL | Targets::WGSL),
("push-constants", Targets::GLSL),
(
"operators",
Targets::SPIRV | Targets::METAL | Targets::GLSL | Targets::HLSL | Targets::WGSL,
Expand Down

0 comments on commit a1840be

Please sign in to comment.