Skip to content

Commit

Permalink
Remove vertex_pulling_transfrom from PipelineCompilationOptions.
Browse files Browse the repository at this point in the history
This option was only evaluated for Metal backends, and now it's required
there so the option is going away. It is still configurable for tests
via the PipelineOptions struct, deserialized from .ron files.

This also fixes some type problems with the unpack functions in
writer.rs. Metal << operator extends operand to int-sized, which then
has to be cast back down to the real size before as_type bit conversion.
  • Loading branch information
bradwerth authored and ErichDonGubler committed Jun 18, 2024
1 parent 86fff75 commit ea77dc2
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 85 deletions.
3 changes: 0 additions & 3 deletions deno_webgpu/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ pub fn op_webgpu_create_compute_pipeline(
entry_point: compute.entry_point.map(Cow::from),
constants: Cow::Owned(compute.constants.unwrap_or_default()),
zero_initialize_workgroup_memory: true,
vertex_pulling_transform: false,
},
cache: None,
};
Expand Down Expand Up @@ -364,7 +363,6 @@ pub fn op_webgpu_create_render_pipeline(
constants: Cow::Owned(fragment.constants.unwrap_or_default()),
// Required to be true for WebGPU
zero_initialize_workgroup_memory: true,
vertex_pulling_transform: false,
},
targets: Cow::Owned(fragment.targets),
})
Expand All @@ -390,7 +388,6 @@ pub fn op_webgpu_create_render_pipeline(
constants: Cow::Owned(args.vertex.constants.unwrap_or_default()),
// Required to be true for WebGPU
zero_initialize_workgroup_memory: true,
vertex_pulling_transform: false,
},
buffers: Cow::Owned(vertex_buffers),
},
Expand Down
1 change: 1 addition & 0 deletions naga/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ For changelogs after v0.14, see [the wgpu changelog](../CHANGELOG.md).
- Add and fix minimum Metal version checks for optional functionality. ([#2486](https://github.com/gfx-rs/naga/pull/2486)) **@teoxoy**
- Make varyings' struct members unique. ([#2521](https://github.com/gfx-rs/naga/pull/2521)) **@evahop**
- Add experimental vertex pulling transform flag. ([#5254](https://github.com/gfx-rs/wgpu/pull/5254)) **@bradwerth**
- Make vertex pulling transform on by default. ([#5773](https://github.com/gfx-rs/wgpu/pull/5773)) **@bradwerth**

#### GLSL-OUT

Expand Down
4 changes: 3 additions & 1 deletion naga/src/back/msl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,9 @@ pub struct PipelineOptions {
/// to receive the vertex buffers, lengths, and vertex id as args,
/// and bounds-check the vertex id and use the index into the
/// vertex buffers to access attributes, rather than using Metal's
/// [[stage-in]] assembled attribute data.
/// [[stage-in]] assembled attribute data. This is true by default,
/// but remains configurable for use by tests via deserialization
/// of this struct. There is no user-facing way to set this value.
pub vertex_pulling_transform: bool,

/// vertex_buffer_mappings are used during shader translation to
Expand Down
32 changes: 16 additions & 16 deletions naga/src/back/msl/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3992,8 +3992,8 @@ impl<W: Write> Writer<W> {
)?;
writeln!(
self.out,
"{}return metal::int2(as_type<metal::short>(b1 << 8 | b0), \
as_type<metal::short>(b3 << 8 | b2));",
"{}return metal::int2(as_type<short>(metal::ushort(b1 << 8 | b0)), \
as_type<short>(metal::ushort(b3 << 8 | b2)));",
back::INDENT
)?;
writeln!(self.out, "}}")?;
Expand All @@ -4014,10 +4014,10 @@ impl<W: Write> Writer<W> {
)?;
writeln!(
self.out,
"{}return metal::int4(as_type<metal::short>(b1 << 8 | b0), \
as_type<metal::short>(b3 << 8 | b2), \
as_type<metal::short>(b5 << 8 | b4), \
as_type<metal::short>(b7 << 8 | b6));",
"{}return metal::int4(as_type<short>(metal::ushort(b1 << 8 | b0)), \
as_type<short>(metal::ushort(b3 << 8 | b2)), \
as_type<short>(metal::ushort(b5 << 8 | b4)), \
as_type<short>(metal::ushort(b7 << 8 | b6)));",
back::INDENT
)?;
writeln!(self.out, "}}")?;
Expand Down Expand Up @@ -4118,8 +4118,8 @@ impl<W: Write> Writer<W> {
)?;
writeln!(
self.out,
"{}return metal::float2(as_type<metal::half>(b1 << 8 | b0), \
as_type<metal::half>(b3 << 8 | b2));",
"{}return metal::float2(as_type<metal::half>(metal::ushort(b1 << 8 | b0)), \
as_type<metal::half>(metal::ushort(b3 << 8 | b2)));",
back::INDENT
)?;
writeln!(self.out, "}}")?;
Expand All @@ -4140,10 +4140,10 @@ impl<W: Write> Writer<W> {
)?;
writeln!(
self.out,
"{}return metal::int4(as_type<metal::half>(b1 << 8 | b0), \
as_type<metal::half>(b3 << 8 | b2), \
as_type<metal::half>(b5 << 8 | b4), \
as_type<metal::half>(b7 << 8 | b6));",
"{}return metal::int4(as_type<metal::half>(metal::ushort(b1 << 8 | b0)), \
as_type<metal::half>(metal::ushort(b3 << 8 | b2)), \
as_type<metal::half>(metal::ushort(b5 << 8 | b4)), \
as_type<metal::half>(metal::ushort(b7 << 8 | b6)));",
back::INDENT
)?;
writeln!(self.out, "}}")?;
Expand Down Expand Up @@ -4349,10 +4349,10 @@ impl<W: Write> Writer<W> {
let name = self.namer.call("unpackSint32");
writeln!(
self.out,
"metal::int {name}(uint b0, \
uint b1, \
uint b2, \
uint b3) {{"
"int {name}(uint b0, \
uint b1, \
uint b2, \
uint b3) {{"
)?;
writeln!(
self.out,
Expand Down
53 changes: 9 additions & 44 deletions tests/tests/vertex_indices/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ struct Test {
id_source: IdSource,
draw_call_kind: DrawCallKind,
encoder_kind: EncoderKind,
vertex_pulling_transform: bool,
}

impl Test {
Expand Down Expand Up @@ -299,15 +298,6 @@ async fn vertex_index_common(ctx: TestingContext) {
cache: None,
};
let builtin_pipeline = ctx.device.create_render_pipeline(&pipeline_desc);
pipeline_desc
.vertex
.compilation_options
.vertex_pulling_transform = true;
let builtin_pipeline_vpt = ctx.device.create_render_pipeline(&pipeline_desc);
pipeline_desc
.vertex
.compilation_options
.vertex_pulling_transform = false;

pipeline_desc.vertex.entry_point = "vs_main_buffers";
pipeline_desc.vertex.buffers = &[
Expand All @@ -323,15 +313,6 @@ async fn vertex_index_common(ctx: TestingContext) {
},
];
let buffer_pipeline = ctx.device.create_render_pipeline(&pipeline_desc);
pipeline_desc
.vertex
.compilation_options
.vertex_pulling_transform = true;
let buffer_pipeline_vpt = ctx.device.create_render_pipeline(&pipeline_desc);
pipeline_desc
.vertex
.compilation_options
.vertex_pulling_transform = false;

let dummy = ctx
.device
Expand Down Expand Up @@ -360,22 +341,18 @@ async fn vertex_index_common(ctx: TestingContext) {
TestCase::ARRAY.len()
* IdSource::ARRAY.len()
* DrawCallKind::ARRAY.len()
* EncoderKind::ARRAY.len()
* 2, /* vertex pulling transform: on and off */
* EncoderKind::ARRAY.len(),
);
for case in TestCase::ARRAY {
for id_source in IdSource::ARRAY {
for draw_call_kind in DrawCallKind::ARRAY {
for encoder_kind in EncoderKind::ARRAY {
for vertex_pulling_transform in [false, true] {
tests.push(Test {
case,
id_source,
draw_call_kind,
encoder_kind,
vertex_pulling_transform,
})
}
tests.push(Test {
case,
id_source,
draw_call_kind,
encoder_kind,
})
}
}
}
Expand All @@ -386,20 +363,8 @@ async fn vertex_index_common(ctx: TestingContext) {
let mut failed = false;
for test in tests {
let pipeline = match test.id_source {
IdSource::Buffers => {
if test.vertex_pulling_transform {
&buffer_pipeline_vpt
} else {
&buffer_pipeline
}
}
IdSource::Builtins => {
if test.vertex_pulling_transform {
&builtin_pipeline_vpt
} else {
&builtin_pipeline
}
}
IdSource::Buffers => &buffer_pipeline,
IdSource::Builtins => &builtin_pipeline,
};

let expected = test.expectation(&ctx);
Expand Down
3 changes: 0 additions & 3 deletions wgpu-core/src/device/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2737,7 +2737,6 @@ impl<A: HalApi> Device<A> {
entry_point: final_entry_point_name.as_ref(),
constants: desc.stage.constants.as_ref(),
zero_initialize_workgroup_memory: desc.stage.zero_initialize_workgroup_memory,
vertex_pulling_transform: false,
},
cache: cache.as_ref().and_then(|it| it.raw.as_ref()),
};
Expand Down Expand Up @@ -3166,7 +3165,6 @@ impl<A: HalApi> Device<A> {
entry_point: &vertex_entry_point_name,
constants: stage_desc.constants.as_ref(),
zero_initialize_workgroup_memory: stage_desc.zero_initialize_workgroup_memory,
vertex_pulling_transform: stage_desc.vertex_pulling_transform,
}
};

Expand Down Expand Up @@ -3230,7 +3228,6 @@ impl<A: HalApi> Device<A> {
zero_initialize_workgroup_memory: fragment_state
.stage
.zero_initialize_workgroup_memory,
vertex_pulling_transform: false,
})
}
None => None,
Expand Down
2 changes: 0 additions & 2 deletions wgpu-core/src/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,6 @@ pub struct ProgrammableStageDescriptor<'a> {
/// This is required by the WebGPU spec, but may have overhead which can be avoided
/// for cross-platform applications
pub zero_initialize_workgroup_memory: bool,
/// Should the pipeline attempt to transform vertex shaders to use vertex pulling.
pub vertex_pulling_transform: bool,
}

/// Number of implicit bind groups derived at pipeline creation.
Expand Down
2 changes: 0 additions & 2 deletions wgpu-hal/examples/halmark/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,15 +253,13 @@ impl<A: hal::Api> Example<A> {
entry_point: "vs_main",
constants: &constants,
zero_initialize_workgroup_memory: true,
vertex_pulling_transform: false,
},
vertex_buffers: &[],
fragment_stage: Some(hal::ProgrammableStage {
module: &shader,
entry_point: "fs_main",
constants: &constants,
zero_initialize_workgroup_memory: true,
vertex_pulling_transform: false,
}),
primitive: wgt::PrimitiveState {
topology: wgt::PrimitiveTopology::TriangleStrip,
Expand Down
1 change: 0 additions & 1 deletion wgpu-hal/examples/ray-traced-triangle/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,6 @@ impl<A: hal::Api> Example<A> {
entry_point: "main",
constants: &Default::default(),
zero_initialize_workgroup_memory: true,
vertex_pulling_transform: false,
},
cache: None,
})
Expand Down
3 changes: 0 additions & 3 deletions wgpu-hal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1781,8 +1781,6 @@ pub struct ProgrammableStage<'a, A: Api> {
/// This is required by the WebGPU spec, but may have overhead which can be avoided
/// for cross-platform applications
pub zero_initialize_workgroup_memory: bool,
/// Should the pipeline attempt to transform vertex shaders to use vertex pulling.
pub vertex_pulling_transform: bool,
}

// Rust gets confused about the impl requirements for `A`
Expand All @@ -1793,7 +1791,6 @@ impl<A: Api> Clone for ProgrammableStage<'_, A> {
entry_point: self.entry_point,
constants: self.constants,
zero_initialize_workgroup_memory: self.zero_initialize_workgroup_memory,
vertex_pulling_transform: self.vertex_pulling_transform,
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion wgpu-hal/src/metal/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ impl super::Device {
metal::MTLPrimitiveTopologyClass::Point => true,
_ => false,
},
vertex_pulling_transform: stage.vertex_pulling_transform,
vertex_pulling_transform: true,
vertex_buffer_mappings: vertex_buffer_mappings.to_vec(),
};

Expand Down
6 changes: 0 additions & 6 deletions wgpu/src/backend/wgpu_core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1189,10 +1189,6 @@ impl crate::Context for ContextWgpuCore {
.vertex
.compilation_options
.zero_initialize_workgroup_memory,
vertex_pulling_transform: desc
.vertex
.compilation_options
.vertex_pulling_transform,
},
buffers: Borrowed(&vertex_buffers),
},
Expand All @@ -1207,7 +1203,6 @@ impl crate::Context for ContextWgpuCore {
zero_initialize_workgroup_memory: frag
.compilation_options
.zero_initialize_workgroup_memory,
vertex_pulling_transform: false,
},
targets: Borrowed(frag.targets),
}),
Expand Down Expand Up @@ -1261,7 +1256,6 @@ impl crate::Context for ContextWgpuCore {
zero_initialize_workgroup_memory: desc
.compilation_options
.zero_initialize_workgroup_memory,
vertex_pulling_transform: false,
},
cache: desc.cache.map(|c| c.id.into()),
};
Expand Down
3 changes: 0 additions & 3 deletions wgpu/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1997,8 +1997,6 @@ pub struct PipelineCompilationOptions<'a> {
/// This is required by the WebGPU spec, but may have overhead which can be avoided
/// for cross-platform applications
pub zero_initialize_workgroup_memory: bool,
/// Should the pipeline attempt to transform vertex shaders to use vertex pulling.
pub vertex_pulling_transform: bool,
}

impl<'a> Default for PipelineCompilationOptions<'a> {
Expand All @@ -2012,7 +2010,6 @@ impl<'a> Default for PipelineCompilationOptions<'a> {
Self {
constants,
zero_initialize_workgroup_memory: true,
vertex_pulling_transform: false,
}
}
}
Expand Down

0 comments on commit ea77dc2

Please sign in to comment.