mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-22 14:55:05 +00:00
[glsl-in] Make sure to Load on a ValuePointer as well
Fixes issues with indexing vectors.
This commit is contained in:
parent
78e1304d42
commit
0b9af95793
@ -485,12 +485,15 @@ impl<'function> Context<'function> {
|
||||
self.add_expression(Expression::Access { base, index }, body)
|
||||
});
|
||||
|
||||
if let TypeInner::Pointer { .. } = *program.resolve_type(self, pointer, meta)? {
|
||||
if !lhs {
|
||||
return Ok((
|
||||
Some(self.add_expression(Expression::Load { pointer }, body)),
|
||||
meta,
|
||||
));
|
||||
if !lhs {
|
||||
match *program.resolve_type(self, pointer, meta)? {
|
||||
TypeInner::Pointer { .. } | TypeInner::ValuePointer { .. } => {
|
||||
return Ok((
|
||||
Some(self.add_expression(Expression::Load { pointer }, body)),
|
||||
meta,
|
||||
));
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -673,3 +673,21 @@ fn swizzles() {
|
||||
)
|
||||
.unwrap_err();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn vector_indexing() {
|
||||
let mut entry_points = crate::FastHashMap::default();
|
||||
entry_points.insert("".to_string(), ShaderStage::Fragment);
|
||||
|
||||
parse_program(
|
||||
r#"
|
||||
# version 450
|
||||
float main(int index) {
|
||||
vec4 v = vec4(1.0, 2.0, 3.0, 4.0);
|
||||
return v[index] + 1.0;
|
||||
}
|
||||
"#,
|
||||
&entry_points,
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user