mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
[glsl-in] preserve entrypoint arg names for reflection
This commit is contained in:
@@ -68,6 +68,7 @@ impl From<ShaderStage> for PrologueStage {
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct EntryArg {
|
||||
pub name: Option<String>,
|
||||
pub binding: Binding,
|
||||
pub handle: Handle<GlobalVariable>,
|
||||
pub prologue: PrologueStage,
|
||||
|
||||
@@ -586,7 +586,7 @@ impl Program<'_> {
|
||||
let idx = arguments.len() as u32;
|
||||
|
||||
arguments.push(FunctionArgument {
|
||||
name: None,
|
||||
name: arg.name.clone(),
|
||||
ty,
|
||||
binding: Some(arg.binding.clone()),
|
||||
});
|
||||
|
||||
@@ -52,6 +52,7 @@ impl Program<'_> {
|
||||
|
||||
let idx = self.entry_args.len();
|
||||
self.entry_args.push(EntryArg {
|
||||
name: None,
|
||||
binding: Binding::BuiltIn(builtin),
|
||||
handle,
|
||||
prologue,
|
||||
@@ -359,7 +360,7 @@ impl Program<'_> {
|
||||
});
|
||||
|
||||
let handle = self.module.global_variables.append(GlobalVariable {
|
||||
name: name.clone(),
|
||||
name: name.as_ref().map(|n| format!("gen_entry_{}", n)),
|
||||
class: StorageClass::Private,
|
||||
binding: None,
|
||||
ty,
|
||||
@@ -369,6 +370,7 @@ impl Program<'_> {
|
||||
|
||||
let idx = self.entry_args.len();
|
||||
self.entry_args.push(EntryArg {
|
||||
name: name.clone(),
|
||||
binding: Binding::Location {
|
||||
location,
|
||||
interpolation,
|
||||
|
||||
@@ -7,32 +7,32 @@ struct FragmentOutput {
|
||||
[[location(0), interpolate(perspective)]] member2: vec4<f32>;
|
||||
};
|
||||
|
||||
var<private> a_pos: vec2<f32>;
|
||||
var<private> a_uv: vec2<f32>;
|
||||
var<private> v_uv: vec2<f32>;
|
||||
var<private> gen_entry_a_pos: vec2<f32>;
|
||||
var<private> gen_entry_a_uv: vec2<f32>;
|
||||
var<private> gen_entry_v_uv: vec2<f32>;
|
||||
var<private> gl_Position: vec4<f32>;
|
||||
var<private> v_uv1: vec2<f32>;
|
||||
var<private> o_color: vec4<f32>;
|
||||
var<private> gen_entry_v_uv1: vec2<f32>;
|
||||
var<private> gen_entry_o_color: vec4<f32>;
|
||||
|
||||
fn vert_main() {
|
||||
let _e2: vec2<f32> = a_pos;
|
||||
let _e4: vec2<f32> = a_uv;
|
||||
v_uv = _e4;
|
||||
let _e2: vec2<f32> = gen_entry_a_pos;
|
||||
let _e4: vec2<f32> = gen_entry_a_uv;
|
||||
gen_entry_v_uv = _e4;
|
||||
gl_Position = vec4<f32>((1.2000000476837158 * _e2), 0.0, 1.0);
|
||||
return;
|
||||
}
|
||||
|
||||
fn frag_main() {
|
||||
o_color = vec4<f32>(1.0, 1.0, 1.0, 1.0);
|
||||
gen_entry_o_color = vec4<f32>(1.0, 1.0, 1.0, 1.0);
|
||||
return;
|
||||
}
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn vert_main1([[location(0), interpolate(perspective)]] param: vec2<f32>, [[location(1), interpolate(perspective)]] param1: vec2<f32>) -> VertexOutput {
|
||||
a_pos = param;
|
||||
a_uv = param1;
|
||||
fn vert_main1([[location(0), interpolate(perspective)]] a_pos: vec2<f32>, [[location(1), interpolate(perspective)]] a_uv: vec2<f32>) -> VertexOutput {
|
||||
gen_entry_a_pos = a_pos;
|
||||
gen_entry_a_uv = a_uv;
|
||||
vert_main();
|
||||
let _e5: vec2<f32> = v_uv;
|
||||
let _e5: vec2<f32> = gen_entry_v_uv;
|
||||
let _e7: vec4<f32> = gl_Position;
|
||||
return VertexOutput(_e5, _e7);
|
||||
}
|
||||
@@ -40,6 +40,6 @@ fn vert_main1([[location(0), interpolate(perspective)]] param: vec2<f32>, [[loca
|
||||
[[stage(fragment)]]
|
||||
fn frag_main1() -> FragmentOutput {
|
||||
frag_main();
|
||||
let _e1: vec4<f32> = o_color;
|
||||
let _e1: vec4<f32> = gen_entry_o_color;
|
||||
return FragmentOutput(_e1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user