Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
22 changes: 4 additions & 18 deletions render/naga-agal/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1090,27 +1090,13 @@ impl<'a> NagaBuilder<'a> {
value: expr,
});
} else {
// A scalar write occurs when we have exactly one component in the dest write mask.
let scalar_write = [Mask::X, Mask::Y, Mask::Z, Mask::W]
.into_iter()
.filter(|mask| dest.write_mask.contains(*mask))
.count()
== 1;

for (i, mask) in [(0, Mask::X), (1, Mask::Y), (2, Mask::Z), (3, Mask::W)] {
if dest.write_mask.contains(mask) {
let source_component = if scalar_write || source_is_scalar {
if source_is_scalar {
expr
} else {
// Grab the first component of the source expression - all of them should be
// the same when doing a scalar write.
self.evaluate_expr(Expression::AccessIndex {
base: expr,
index: 0,
})
}
let source_component = if source_is_scalar {
expr
} else {
// AGAL swizzles are positional: dest component `i` takes component `i`
// of the (already swizzled) source.
self.evaluate_expr(Expression::AccessIndex {
base: expr,
index: i,
Expand Down
92 changes: 46 additions & 46 deletions render/naga-agal/tests/snapshots/wgsl__complex_fractal-2.snap

Large diffs are not rendered by default.

605 changes: 302 additions & 303 deletions render/naga-agal/tests/snapshots/wgsl__complex_raytrace-2.snap

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions render/naga-agal/tests/snapshots/wgsl__complex_raytrace.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: render/naga-agal/tests/wgsl.rs
assertion_line: 90
expression: output
---
struct VertexOutput {
Expand All @@ -22,7 +21,7 @@ fn main(@location(0) param: vec4<f32>) -> VertexOutput {
temporary0_.y = _e3.y;
temporary0_.z = _e3.z;
let _e13: vec4<f32> = constant_registers[4u];
temporary0_.w = _e13.yyyy.x;
temporary0_.w = _e13.yyyy.w;
let _e19: vec4<f32> = constant_registers[0u];
let _e22: vec4<f32> = constant_registers[1u];
let _e25: vec4<f32> = constant_registers[2u];
Expand Down
Loading
Loading