Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

glsl-out: Add support for push constant emulation #1672

Merged
merged 2 commits into from
Jan 17, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since extra enables push constants, could we just enable it instead of the new test?

Copy link
Collaborator Author

@JCapucho JCapucho Jan 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wrote about it in my comment, extra.wgsl uses f64s which gles doesn't support

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh sorry, didn't see this

(
"operators",
Targets::SPIRV | Targets::METAL | Targets::GLSL | Targets::HLSL | Targets::WGSL,
Expand Down