Skip to content

Commit

Permalink
Allow array_index to be unsigned
Browse files Browse the repository at this point in the history
  • Loading branch information
daxpedda committed Apr 2, 2023
1 parent da8e911 commit e4d4369
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/valid/expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ impl super::Validator {
if let Some(expr) = array_index {
match resolver[expr] {
Ti::Scalar {
kind: Sk::Sint,
kind: Sk::Sint | Sk::Uint,
width: _,
} => {}
_ => return Err(ExpressionError::InvalidImageArrayIndexType(expr)),
Expand Down Expand Up @@ -548,7 +548,7 @@ impl super::Validator {
if let Some(expr) = array_index {
match resolver[expr] {
Ti::Scalar {
kind: Sk::Sint,
kind: Sk::Sint | Sk::Uint,
width: _,
} => {}
_ => return Err(ExpressionError::InvalidImageArrayIndexType(expr)),
Expand Down
2 changes: 1 addition & 1 deletion src/valid/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ impl super::Validator {
if let Some(expr) = array_index {
match *context.resolve_type(expr, &self.valid_expression_set)? {
Ti::Scalar {
kind: crate::ScalarKind::Sint,
kind: crate::ScalarKind::Sint | crate::ScalarKind::Uint,
width: _,
} => {}
_ => {
Expand Down
1 change: 1 addition & 0 deletions tests/in/binding-arrays.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ fn main(fragment_in: FragmentIn) -> @location(0) vec4<f32> {
v4 += textureLoad(texture_array_unbounded[non_uniform_index], pix, 0);

u1 += textureNumLayers(texture_array_2darray[0]);
u1 += textureNumLayers(texture_array_2darray[0u]);
u1 += textureNumLayers(texture_array_2darray[uniform_index]);
u1 += textureNumLayers(texture_array_2darray[non_uniform_index]);

Expand Down
4 changes: 2 additions & 2 deletions tests/in/image.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ fn main(@builtin(local_invocation_id) local_id: vec3<u32>) {
let value1 = textureLoad(image_mipmapped_src, itc, i32(local_id.z));
let value2 = textureLoad(image_multisampled_src, itc, i32(local_id.z));
let value4 = textureLoad(image_storage_src, itc);
let value5 = textureLoad(image_array_src, itc, i32(local_id.z), i32(local_id.z) + 1);
let value5 = textureLoad(image_array_src, itc, local_id.z, i32(local_id.z) + 1);
let value6 = textureLoad(image_1d_src, i32(local_id.x), i32(local_id.z));
// loads with uvec2 coords.
let value1u = textureLoad(image_mipmapped_src, vec2<u32>(itc), i32(local_id.z));
let value2u = textureLoad(image_multisampled_src, vec2<u32>(itc), i32(local_id.z));
let value4u = textureLoad(image_storage_src, vec2<u32>(itc));
let value5u = textureLoad(image_array_src, vec2<u32>(itc), i32(local_id.z), i32(local_id.z) + 1);
let value5u = textureLoad(image_array_src, vec2<u32>(itc), local_id.z, i32(local_id.z) + 1);
let value6u = textureLoad(image_1d_src, u32(local_id.x), i32(local_id.z));
// store with ivec2 coords.
textureStore(image_dst, itc.x, value1 + value2 + value4 + value5 + value6);
Expand Down

0 comments on commit e4d4369

Please sign in to comment.