Skip to content

Commit 4192164

Browse files
SuchAFuriousDeathLord-McSweeney
authored andcommitted
naga-agal: Fix indirect addressing with Float1 vertex attributes
1 parent aaa3e2c commit 4192164

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

render/naga-agal/src/builder.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -844,12 +844,19 @@ impl<'a> NagaBuilder<'a> {
844844
RegisterType::Constant => {
845845
// Load the index register (e.g. 'va0') as normal, and access the component
846846
// given by 'index_select' (e.g. 'x'). This is 'va0.x' in the above example.
847-
let (base_index, _format) =
847+
let (base_index, format) =
848848
load_register(&source.index_type, source.reg_num as usize)?;
849-
let index_expr = self.evaluate_expr(Expression::AccessIndex {
850-
base: base_index,
851-
index: source.index_select as u32,
852-
});
849+
850+
// If the index register is a scalar (Float1), use it directly.
851+
// Otherwise, extract the component given by 'index_select'.
852+
let index_expr = if format == VertexAttributeFormat::Float1 {
853+
base_index
854+
} else {
855+
self.evaluate_expr(Expression::AccessIndex {
856+
base: base_index,
857+
index: source.index_select as u32,
858+
})
859+
};
853860

854861
// Convert to an integer, since we're going to be indexing an array
855862
let index_integer = self.evaluate_expr(Expression::As {

0 commit comments

Comments
 (0)