From 16eeff387c5578db32cf1c25b369f3dfdb1cb0f7 Mon Sep 17 00:00:00 2001 From: James Price Date: Thu, 31 Mar 2022 22:30:10 +0000 Subject: [PATCH] spirv: Implement compound assignment Use the ExpandCompoundAssignment transform to convert compound assignments to regular assignments. Bug: tint:1325 Change-Id: I193a09815836755bc1f7138fe1947be39f7b7206 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/85285 Reviewed-by: Ben Clayton Kokoro: James Price --- src/tint/writer/spirv/builder.cc | 2 + .../complex_lhs.wgsl.expected.spvasm | 97 ++++++++--- .../divide_by_zero.wgsl.expected.spvasm | 81 ++++++--- .../for_loop.wgsl.expected.spvasm | 155 ++++++++++++++---- .../function.wgsl.expected.spvasm | 64 ++++++-- .../matrix/minus.wgsl.expected.spvasm | 71 ++++++-- .../matrix/plus.wgsl.expected.spvasm | 71 ++++++-- .../matrix/times-scalar.wgsl.expected.spvasm | 59 +++++-- .../matrix/times.wgsl.expected.spvasm | 59 +++++-- .../private.wgsl.expected.spvasm | 67 ++++++-- .../scalar/and.wgsl.expected.spvasm | 55 +++++-- .../scalar/divide.wgsl.expected.spvasm | 55 +++++-- .../scalar/minus.wgsl.expected.spvasm | 55 +++++-- .../scalar/modulo.wgsl.expected.spvasm | 55 +++++-- .../scalar/or.wgsl.expected.spvasm | 55 +++++-- .../scalar/plus.wgsl.expected.spvasm | 55 +++++-- .../scalar/times.wgsl.expected.spvasm | 55 +++++-- .../scalar/xor.wgsl.expected.spvasm | 55 +++++-- .../vector/and.wgsl.expected.spvasm | 57 +++++-- .../vector/divide-scalar.wgsl.expected.spvasm | 60 +++++-- .../vector/divide.wgsl.expected.spvasm | 57 +++++-- .../vector/minus-scalar.wgsl.expected.spvasm | 60 +++++-- .../vector/minus.wgsl.expected.spvasm | 57 +++++-- .../vector/modulo-scalar.wgsl.expected.spvasm | 60 +++++-- .../vector/modulo.wgsl.expected.spvasm | 57 +++++-- .../vector/or.wgsl.expected.spvasm | 57 +++++-- .../vector/plus-scalar.wgsl.expected.spvasm | 60 +++++-- .../vector/plus.wgsl.expected.spvasm | 57 +++++-- .../vector/times-matrix.wgsl.expected.spvasm | 57 +++++-- .../vector/times-scalar.wgsl.expected.spvasm | 56 +++++-- .../vector/times.wgsl.expected.spvasm | 57 +++++-- .../vector/xor.wgsl.expected.spvasm | 57 +++++-- .../workgroup.wgsl.expected.spvasm | 64 ++++++-- 33 files changed, 1550 insertions(+), 489 deletions(-) diff --git a/src/tint/writer/spirv/builder.cc b/src/tint/writer/spirv/builder.cc index 154e360565..52ba914a5f 100644 --- a/src/tint/writer/spirv/builder.cc +++ b/src/tint/writer/spirv/builder.cc @@ -45,6 +45,7 @@ #include "src/tint/transform/add_spirv_block_attribute.h" #include "src/tint/transform/builtin_polyfill.h" #include "src/tint/transform/canonicalize_entry_point_io.h" +#include "src/tint/transform/expand_compound_assignment.h" #include "src/tint/transform/fold_constants.h" #include "src/tint/transform/for_loop_to_loop.h" #include "src/tint/transform/manager.h" @@ -279,6 +280,7 @@ SanitizedResult Sanitize(const Program* in, manager.Add(); } manager.Add(); + manager.Add(); manager.Add(); manager.Add(); manager.Add(); // Required for arrayLength() diff --git a/test/tint/statements/compound_assign/complex_lhs.wgsl.expected.spvasm b/test/tint/statements/compound_assign/complex_lhs.wgsl.expected.spvasm index 32462a3f72..788dae7db8 100644 --- a/test/tint/statements/compound_assign/complex_lhs.wgsl.expected.spvasm +++ b/test/tint/statements/compound_assign/complex_lhs.wgsl.expected.spvasm @@ -1,26 +1,71 @@ -SKIP: FAILED - - -struct S { - a : array, 4>, -} - -var counter : i32; - -fn foo() -> i32 { - counter += 1; - return counter; -} - -fn bar() -> i32 { - counter += 2; - return counter; -} - -fn main() { - var x = S(); - let p = &(x); - (*(p)).a[foo()][bar()] += 5; -} - -Failed to generate: Unknown statement: tint::ast::CompoundAssignmentStatement +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 41 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %unused_entry_point "unused_entry_point" + OpExecutionMode %unused_entry_point LocalSize 1 1 1 + OpName %counter "counter" + OpName %unused_entry_point "unused_entry_point" + OpName %foo "foo" + OpName %bar "bar" + OpName %main "main" + OpName %S "S" + OpMemberName %S 0 "a" + OpName %x "x" + OpMemberDecorate %S 0 Offset 0 + OpDecorate %_arr_v4int_uint_4 ArrayStride 16 + %int = OpTypeInt 32 1 +%_ptr_Private_int = OpTypePointer Private %int + %4 = OpConstantNull %int + %counter = OpVariable %_ptr_Private_int Private %4 + %void = OpTypeVoid + %5 = OpTypeFunction %void + %9 = OpTypeFunction %int + %int_1 = OpConstant %int 1 + %int_2 = OpConstant %int 2 + %v4int = OpTypeVector %int 4 + %uint = OpTypeInt 32 0 + %uint_4 = OpConstant %uint 4 +%_arr_v4int_uint_4 = OpTypeArray %v4int %uint_4 + %S = OpTypeStruct %_arr_v4int_uint_4 + %29 = OpConstantNull %S +%_ptr_Function_S = OpTypePointer Function %S + %uint_0 = OpConstant %uint 0 +%_ptr_Function_int = OpTypePointer Function %int + %int_5 = OpConstant %int 5 +%unused_entry_point = OpFunction %void None %5 + %8 = OpLabel + OpReturn + OpFunctionEnd + %foo = OpFunction %int None %9 + %11 = OpLabel + %12 = OpLoad %int %counter + %14 = OpIAdd %int %12 %int_1 + OpStore %counter %14 + %15 = OpLoad %int %counter + OpReturnValue %15 + OpFunctionEnd + %bar = OpFunction %int None %9 + %17 = OpLabel + %18 = OpLoad %int %counter + %20 = OpIAdd %int %18 %int_2 + OpStore %counter %20 + %21 = OpLoad %int %counter + OpReturnValue %21 + OpFunctionEnd + %main = OpFunction %void None %5 + %23 = OpLabel + %x = OpVariable %_ptr_Function_S Function %29 + OpStore %x %29 + %32 = OpFunctionCall %int %foo + %33 = OpFunctionCall %int %bar + %36 = OpAccessChain %_ptr_Function_int %x %uint_0 %32 %33 + %37 = OpAccessChain %_ptr_Function_int %x %uint_0 %32 %33 + %38 = OpLoad %int %37 + %40 = OpIAdd %int %38 %int_5 + OpStore %36 %40 + OpReturn + OpFunctionEnd diff --git a/test/tint/statements/compound_assign/divide_by_zero.wgsl.expected.spvasm b/test/tint/statements/compound_assign/divide_by_zero.wgsl.expected.spvasm index 13980b3e4a..45e0f0f044 100644 --- a/test/tint/statements/compound_assign/divide_by_zero.wgsl.expected.spvasm +++ b/test/tint/statements/compound_assign/divide_by_zero.wgsl.expected.spvasm @@ -1,19 +1,62 @@ -SKIP: FAILED - - -var a : i32; - -var b : f32; - -fn foo(maybe_zero : i32) { - a /= 0; - a %= 0; - a /= maybe_zero; - a %= maybe_zero; - b /= 0.0; - b %= 0.0; - b /= f32(maybe_zero); - b %= f32(maybe_zero); -} - -Failed to generate: Unknown statement: tint::ast::CompoundAssignmentStatement +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 37 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %unused_entry_point "unused_entry_point" + OpExecutionMode %unused_entry_point LocalSize 1 1 1 + OpName %a "a" + OpName %b "b" + OpName %unused_entry_point "unused_entry_point" + OpName %foo "foo" + OpName %maybe_zero "maybe_zero" + %int = OpTypeInt 32 1 +%_ptr_Private_int = OpTypePointer Private %int + %4 = OpConstantNull %int + %a = OpVariable %_ptr_Private_int Private %4 + %float = OpTypeFloat 32 +%_ptr_Private_float = OpTypePointer Private %float + %8 = OpConstantNull %float + %b = OpVariable %_ptr_Private_float Private %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void + %13 = OpTypeFunction %void %int + %int_0 = OpConstant %int 0 + %float_0 = OpConstant %float 0 +%unused_entry_point = OpFunction %void None %9 + %12 = OpLabel + OpReturn + OpFunctionEnd + %foo = OpFunction %void None %13 + %maybe_zero = OpFunctionParameter %int + %16 = OpLabel + %17 = OpLoad %int %a + %19 = OpSDiv %int %17 %int_0 + OpStore %a %19 + %20 = OpLoad %int %a + %21 = OpSMod %int %20 %int_0 + OpStore %a %21 + %22 = OpLoad %int %a + %23 = OpSDiv %int %22 %maybe_zero + OpStore %a %23 + %24 = OpLoad %int %a + %25 = OpSMod %int %24 %maybe_zero + OpStore %a %25 + %26 = OpLoad %float %b + %28 = OpFDiv %float %26 %float_0 + OpStore %b %28 + %29 = OpLoad %float %b + %30 = OpFRem %float %29 %float_0 + OpStore %b %30 + %31 = OpLoad %float %b + %32 = OpConvertSToF %float %maybe_zero + %33 = OpFDiv %float %31 %32 + OpStore %b %33 + %34 = OpLoad %float %b + %35 = OpConvertSToF %float %maybe_zero + %36 = OpFRem %float %34 %35 + OpStore %b %36 + OpReturn + OpFunctionEnd diff --git a/test/tint/statements/compound_assign/for_loop.wgsl.expected.spvasm b/test/tint/statements/compound_assign/for_loop.wgsl.expected.spvasm index 7c8a0de36a..de44b9bb76 100644 --- a/test/tint/statements/compound_assign/for_loop.wgsl.expected.spvasm +++ b/test/tint/statements/compound_assign/for_loop.wgsl.expected.spvasm @@ -1,35 +1,120 @@ -SKIP: FAILED - - -struct S { - a : i32, - b : vec4, - c : mat2x2, -} - -@group(0) @binding(0) var v : S; - -var i : u32; - -fn idx1() -> i32 { - i += 1u; - return 1; -} - -fn idx2() -> i32 { - i += 2u; - return 1; -} - -fn idx3() -> i32 { - i += 3u; - return 1; -} - -fn foo() { - var a = array(); - for(a[idx1()] *= 2.0; (a[idx2()] < 10.0); a[idx3()] += 1.0) { - } -} - -Failed to generate: Unknown statement: tint::ast::CompoundAssignmentStatement +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 67 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %unused_entry_point "unused_entry_point" + OpExecutionMode %unused_entry_point LocalSize 1 1 1 + OpName %S "S" + OpMemberName %S 0 "a" + OpMemberName %S 1 "b" + OpMemberName %S 2 "c" + OpName %v "v" + OpName %i "i" + OpName %unused_entry_point "unused_entry_point" + OpName %idx1 "idx1" + OpName %idx2 "idx2" + OpName %idx3 "idx3" + OpName %foo "foo" + OpName %a "a" + OpDecorate %S Block + OpMemberDecorate %S 0 Offset 0 + OpMemberDecorate %S 1 Offset 16 + OpMemberDecorate %S 2 Offset 32 + OpMemberDecorate %S 2 ColMajor + OpMemberDecorate %S 2 MatrixStride 8 + OpDecorate %v DescriptorSet 0 + OpDecorate %v Binding 0 + OpDecorate %_arr_float_uint_4 ArrayStride 4 + %int = OpTypeInt 32 1 + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %v2float = OpTypeVector %float 2 +%mat2v2float = OpTypeMatrix %v2float 2 + %S = OpTypeStruct %int %v4float %mat2v2float +%_ptr_StorageBuffer_S = OpTypePointer StorageBuffer %S + %v = OpVariable %_ptr_StorageBuffer_S StorageBuffer + %uint = OpTypeInt 32 0 +%_ptr_Private_uint = OpTypePointer Private %uint + %12 = OpConstantNull %uint + %i = OpVariable %_ptr_Private_uint Private %12 + %void = OpTypeVoid + %13 = OpTypeFunction %void + %17 = OpTypeFunction %int + %uint_1 = OpConstant %uint 1 + %int_1 = OpConstant %int 1 + %uint_2 = OpConstant %uint 2 + %uint_3 = OpConstant %uint 3 + %uint_4 = OpConstant %uint 4 +%_arr_float_uint_4 = OpTypeArray %float %uint_4 + %38 = OpConstantNull %_arr_float_uint_4 +%_ptr_Function__arr_float_uint_4 = OpTypePointer Function %_arr_float_uint_4 +%_ptr_Function_float = OpTypePointer Function %float + %float_2 = OpConstant %float 2 + %float_10 = OpConstant %float 10 + %bool = OpTypeBool + %float_1 = OpConstant %float 1 +%unused_entry_point = OpFunction %void None %13 + %16 = OpLabel + OpReturn + OpFunctionEnd + %idx1 = OpFunction %int None %17 + %19 = OpLabel + %20 = OpLoad %uint %i + %22 = OpIAdd %uint %20 %uint_1 + OpStore %i %22 + OpReturnValue %int_1 + OpFunctionEnd + %idx2 = OpFunction %int None %17 + %25 = OpLabel + %26 = OpLoad %uint %i + %28 = OpIAdd %uint %26 %uint_2 + OpStore %i %28 + OpReturnValue %int_1 + OpFunctionEnd + %idx3 = OpFunction %int None %17 + %30 = OpLabel + %31 = OpLoad %uint %i + %33 = OpIAdd %uint %31 %uint_3 + OpStore %i %33 + OpReturnValue %int_1 + OpFunctionEnd + %foo = OpFunction %void None %13 + %35 = OpLabel + %a = OpVariable %_ptr_Function__arr_float_uint_4 Function %38 + OpStore %a %38 + %41 = OpFunctionCall %int %idx1 + %43 = OpAccessChain %_ptr_Function_float %a %41 + %44 = OpAccessChain %_ptr_Function_float %a %41 + %45 = OpLoad %float %44 + %47 = OpFMul %float %45 %float_2 + OpStore %43 %47 + OpBranch %48 + %48 = OpLabel + OpLoopMerge %49 %50 None + OpBranch %51 + %51 = OpLabel + %52 = OpFunctionCall %int %idx2 + %54 = OpAccessChain %_ptr_Function_float %a %52 + %55 = OpLoad %float %54 + %57 = OpFOrdLessThan %bool %55 %float_10 + %53 = OpLogicalNot %bool %57 + OpSelectionMerge %59 None + OpBranchConditional %53 %60 %59 + %60 = OpLabel + OpBranch %49 + %59 = OpLabel + OpBranch %50 + %50 = OpLabel + %61 = OpFunctionCall %int %idx3 + %62 = OpAccessChain %_ptr_Function_float %a %61 + %63 = OpAccessChain %_ptr_Function_float %a %61 + %64 = OpLoad %float %63 + %66 = OpFAdd %float %64 %float_1 + OpStore %62 %66 + OpBranch %48 + %49 = OpLabel + OpReturn + OpFunctionEnd diff --git a/test/tint/statements/compound_assign/function.wgsl.expected.spvasm b/test/tint/statements/compound_assign/function.wgsl.expected.spvasm index 231a8b39fe..eee238313c 100644 --- a/test/tint/statements/compound_assign/function.wgsl.expected.spvasm +++ b/test/tint/statements/compound_assign/function.wgsl.expected.spvasm @@ -1,13 +1,51 @@ -SKIP: FAILED - - -fn foo() { - var a : i32; - var b : vec4; - var c : mat2x2; - a /= 2; - b *= mat4x4(); - c *= 2.0; -} - -Failed to generate: Unknown statement: tint::ast::CompoundAssignmentStatement +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 31 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %unused_entry_point "unused_entry_point" + OpExecutionMode %unused_entry_point LocalSize 1 1 1 + OpName %unused_entry_point "unused_entry_point" + OpName %foo "foo" + OpName %a "a" + OpName %b "b" + OpName %c "c" + %void = OpTypeVoid + %1 = OpTypeFunction %void + %int = OpTypeInt 32 1 +%_ptr_Function_int = OpTypePointer Function %int + %10 = OpConstantNull %int + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Function_v4float = OpTypePointer Function %v4float + %15 = OpConstantNull %v4float + %v2float = OpTypeVector %float 2 +%mat2v2float = OpTypeMatrix %v2float 2 +%_ptr_Function_mat2v2float = OpTypePointer Function %mat2v2float + %20 = OpConstantNull %mat2v2float + %int_2 = OpConstant %int 2 +%mat4v4float = OpTypeMatrix %v4float 4 + %26 = OpConstantNull %mat4v4float + %float_2 = OpConstant %float 2 +%unused_entry_point = OpFunction %void None %1 + %4 = OpLabel + OpReturn + OpFunctionEnd + %foo = OpFunction %void None %1 + %6 = OpLabel + %a = OpVariable %_ptr_Function_int Function %10 + %b = OpVariable %_ptr_Function_v4float Function %15 + %c = OpVariable %_ptr_Function_mat2v2float Function %20 + %21 = OpLoad %int %a + %23 = OpSDiv %int %21 %int_2 + OpStore %a %23 + %24 = OpLoad %v4float %b + %27 = OpVectorTimesMatrix %v4float %24 %26 + OpStore %b %27 + %28 = OpLoad %mat2v2float %c + %30 = OpMatrixTimesScalar %mat2v2float %28 %float_2 + OpStore %c %30 + OpReturn + OpFunctionEnd diff --git a/test/tint/statements/compound_assign/matrix/minus.wgsl.expected.spvasm b/test/tint/statements/compound_assign/matrix/minus.wgsl.expected.spvasm index 6f439ad1b0..2c93a1c7a2 100644 --- a/test/tint/statements/compound_assign/matrix/minus.wgsl.expected.spvasm +++ b/test/tint/statements/compound_assign/matrix/minus.wgsl.expected.spvasm @@ -1,14 +1,57 @@ -SKIP: FAILED - - -struct S { - a : mat4x4, -} - -@group(0) @binding(0) var v : S; - -fn foo() { - v.a -= mat4x4(); -} - -Failed to generate: Unknown statement: tint::ast::CompoundAssignmentStatement +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 34 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %unused_entry_point "unused_entry_point" + OpExecutionMode %unused_entry_point LocalSize 1 1 1 + OpName %S "S" + OpMemberName %S 0 "a" + OpName %v "v" + OpName %unused_entry_point "unused_entry_point" + OpName %foo "foo" + OpDecorate %S Block + OpMemberDecorate %S 0 Offset 0 + OpMemberDecorate %S 0 ColMajor + OpMemberDecorate %S 0 MatrixStride 16 + OpDecorate %v DescriptorSet 0 + OpDecorate %v Binding 0 + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%mat4v4float = OpTypeMatrix %v4float 4 + %S = OpTypeStruct %mat4v4float +%_ptr_StorageBuffer_S = OpTypePointer StorageBuffer %S + %v = OpVariable %_ptr_StorageBuffer_S StorageBuffer + %void = OpTypeVoid + %7 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 +%_ptr_StorageBuffer_mat4v4float = OpTypePointer StorageBuffer %mat4v4float + %19 = OpConstantNull %mat4v4float +%unused_entry_point = OpFunction %void None %7 + %10 = OpLabel + OpReturn + OpFunctionEnd + %foo = OpFunction %void None %7 + %12 = OpLabel + %16 = OpAccessChain %_ptr_StorageBuffer_mat4v4float %v %uint_0 + %17 = OpAccessChain %_ptr_StorageBuffer_mat4v4float %v %uint_0 + %18 = OpLoad %mat4v4float %17 + %21 = OpCompositeExtract %v4float %18 0 + %22 = OpCompositeExtract %v4float %19 0 + %23 = OpFSub %v4float %21 %22 + %24 = OpCompositeExtract %v4float %18 1 + %25 = OpCompositeExtract %v4float %19 1 + %26 = OpFSub %v4float %24 %25 + %27 = OpCompositeExtract %v4float %18 2 + %28 = OpCompositeExtract %v4float %19 2 + %29 = OpFSub %v4float %27 %28 + %30 = OpCompositeExtract %v4float %18 3 + %31 = OpCompositeExtract %v4float %19 3 + %32 = OpFSub %v4float %30 %31 + %33 = OpCompositeConstruct %mat4v4float %23 %26 %29 %32 + OpStore %16 %33 + OpReturn + OpFunctionEnd diff --git a/test/tint/statements/compound_assign/matrix/plus.wgsl.expected.spvasm b/test/tint/statements/compound_assign/matrix/plus.wgsl.expected.spvasm index 046e3b9a89..d0c518517a 100644 --- a/test/tint/statements/compound_assign/matrix/plus.wgsl.expected.spvasm +++ b/test/tint/statements/compound_assign/matrix/plus.wgsl.expected.spvasm @@ -1,14 +1,57 @@ -SKIP: FAILED - - -struct S { - a : mat4x4, -} - -@group(0) @binding(0) var v : S; - -fn foo() { - v.a += mat4x4(); -} - -Failed to generate: Unknown statement: tint::ast::CompoundAssignmentStatement +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 34 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %unused_entry_point "unused_entry_point" + OpExecutionMode %unused_entry_point LocalSize 1 1 1 + OpName %S "S" + OpMemberName %S 0 "a" + OpName %v "v" + OpName %unused_entry_point "unused_entry_point" + OpName %foo "foo" + OpDecorate %S Block + OpMemberDecorate %S 0 Offset 0 + OpMemberDecorate %S 0 ColMajor + OpMemberDecorate %S 0 MatrixStride 16 + OpDecorate %v DescriptorSet 0 + OpDecorate %v Binding 0 + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%mat4v4float = OpTypeMatrix %v4float 4 + %S = OpTypeStruct %mat4v4float +%_ptr_StorageBuffer_S = OpTypePointer StorageBuffer %S + %v = OpVariable %_ptr_StorageBuffer_S StorageBuffer + %void = OpTypeVoid + %7 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 +%_ptr_StorageBuffer_mat4v4float = OpTypePointer StorageBuffer %mat4v4float + %19 = OpConstantNull %mat4v4float +%unused_entry_point = OpFunction %void None %7 + %10 = OpLabel + OpReturn + OpFunctionEnd + %foo = OpFunction %void None %7 + %12 = OpLabel + %16 = OpAccessChain %_ptr_StorageBuffer_mat4v4float %v %uint_0 + %17 = OpAccessChain %_ptr_StorageBuffer_mat4v4float %v %uint_0 + %18 = OpLoad %mat4v4float %17 + %21 = OpCompositeExtract %v4float %18 0 + %22 = OpCompositeExtract %v4float %19 0 + %23 = OpFAdd %v4float %21 %22 + %24 = OpCompositeExtract %v4float %18 1 + %25 = OpCompositeExtract %v4float %19 1 + %26 = OpFAdd %v4float %24 %25 + %27 = OpCompositeExtract %v4float %18 2 + %28 = OpCompositeExtract %v4float %19 2 + %29 = OpFAdd %v4float %27 %28 + %30 = OpCompositeExtract %v4float %18 3 + %31 = OpCompositeExtract %v4float %19 3 + %32 = OpFAdd %v4float %30 %31 + %33 = OpCompositeConstruct %mat4v4float %23 %26 %29 %32 + OpStore %16 %33 + OpReturn + OpFunctionEnd diff --git a/test/tint/statements/compound_assign/matrix/times-scalar.wgsl.expected.spvasm b/test/tint/statements/compound_assign/matrix/times-scalar.wgsl.expected.spvasm index 79a3b00047..c120639478 100644 --- a/test/tint/statements/compound_assign/matrix/times-scalar.wgsl.expected.spvasm +++ b/test/tint/statements/compound_assign/matrix/times-scalar.wgsl.expected.spvasm @@ -1,14 +1,45 @@ -SKIP: FAILED - - -struct S { - a : mat4x4, -} - -@group(0) @binding(0) var v : S; - -fn foo() { - v.a *= 2.0; -} - -Failed to generate: Unknown statement: tint::ast::CompoundAssignmentStatement +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 21 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %unused_entry_point "unused_entry_point" + OpExecutionMode %unused_entry_point LocalSize 1 1 1 + OpName %S "S" + OpMemberName %S 0 "a" + OpName %v "v" + OpName %unused_entry_point "unused_entry_point" + OpName %foo "foo" + OpDecorate %S Block + OpMemberDecorate %S 0 Offset 0 + OpMemberDecorate %S 0 ColMajor + OpMemberDecorate %S 0 MatrixStride 16 + OpDecorate %v DescriptorSet 0 + OpDecorate %v Binding 0 + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%mat4v4float = OpTypeMatrix %v4float 4 + %S = OpTypeStruct %mat4v4float +%_ptr_StorageBuffer_S = OpTypePointer StorageBuffer %S + %v = OpVariable %_ptr_StorageBuffer_S StorageBuffer + %void = OpTypeVoid + %7 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 +%_ptr_StorageBuffer_mat4v4float = OpTypePointer StorageBuffer %mat4v4float + %float_2 = OpConstant %float 2 +%unused_entry_point = OpFunction %void None %7 + %10 = OpLabel + OpReturn + OpFunctionEnd + %foo = OpFunction %void None %7 + %12 = OpLabel + %16 = OpAccessChain %_ptr_StorageBuffer_mat4v4float %v %uint_0 + %17 = OpAccessChain %_ptr_StorageBuffer_mat4v4float %v %uint_0 + %18 = OpLoad %mat4v4float %17 + %20 = OpMatrixTimesScalar %mat4v4float %18 %float_2 + OpStore %16 %20 + OpReturn + OpFunctionEnd diff --git a/test/tint/statements/compound_assign/matrix/times.wgsl.expected.spvasm b/test/tint/statements/compound_assign/matrix/times.wgsl.expected.spvasm index f7f54479c9..12cf6b3620 100644 --- a/test/tint/statements/compound_assign/matrix/times.wgsl.expected.spvasm +++ b/test/tint/statements/compound_assign/matrix/times.wgsl.expected.spvasm @@ -1,14 +1,45 @@ -SKIP: FAILED - - -struct S { - a : mat4x4, -} - -@group(0) @binding(0) var v : S; - -fn foo() { - v.a *= mat4x4(); -} - -Failed to generate: Unknown statement: tint::ast::CompoundAssignmentStatement +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 21 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %unused_entry_point "unused_entry_point" + OpExecutionMode %unused_entry_point LocalSize 1 1 1 + OpName %S "S" + OpMemberName %S 0 "a" + OpName %v "v" + OpName %unused_entry_point "unused_entry_point" + OpName %foo "foo" + OpDecorate %S Block + OpMemberDecorate %S 0 Offset 0 + OpMemberDecorate %S 0 ColMajor + OpMemberDecorate %S 0 MatrixStride 16 + OpDecorate %v DescriptorSet 0 + OpDecorate %v Binding 0 + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%mat4v4float = OpTypeMatrix %v4float 4 + %S = OpTypeStruct %mat4v4float +%_ptr_StorageBuffer_S = OpTypePointer StorageBuffer %S + %v = OpVariable %_ptr_StorageBuffer_S StorageBuffer + %void = OpTypeVoid + %7 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 +%_ptr_StorageBuffer_mat4v4float = OpTypePointer StorageBuffer %mat4v4float + %19 = OpConstantNull %mat4v4float +%unused_entry_point = OpFunction %void None %7 + %10 = OpLabel + OpReturn + OpFunctionEnd + %foo = OpFunction %void None %7 + %12 = OpLabel + %16 = OpAccessChain %_ptr_StorageBuffer_mat4v4float %v %uint_0 + %17 = OpAccessChain %_ptr_StorageBuffer_mat4v4float %v %uint_0 + %18 = OpLoad %mat4v4float %17 + %20 = OpMatrixTimesMatrix %mat4v4float %18 %19 + OpStore %16 %20 + OpReturn + OpFunctionEnd diff --git a/test/tint/statements/compound_assign/private.wgsl.expected.spvasm b/test/tint/statements/compound_assign/private.wgsl.expected.spvasm index 8166138b65..473958d590 100644 --- a/test/tint/statements/compound_assign/private.wgsl.expected.spvasm +++ b/test/tint/statements/compound_assign/private.wgsl.expected.spvasm @@ -1,16 +1,51 @@ -SKIP: FAILED - - -var a : i32; - -var b : vec4; - -var c : mat2x2; - -fn foo() { - a /= 2; - b *= mat4x4(); - c *= 2.0; -} - -Failed to generate: Unknown statement: tint::ast::CompoundAssignmentStatement +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 31 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %unused_entry_point "unused_entry_point" + OpExecutionMode %unused_entry_point LocalSize 1 1 1 + OpName %a "a" + OpName %b "b" + OpName %c "c" + OpName %unused_entry_point "unused_entry_point" + OpName %foo "foo" + %int = OpTypeInt 32 1 +%_ptr_Private_int = OpTypePointer Private %int + %4 = OpConstantNull %int + %a = OpVariable %_ptr_Private_int Private %4 + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Private_v4float = OpTypePointer Private %v4float + %9 = OpConstantNull %v4float + %b = OpVariable %_ptr_Private_v4float Private %9 + %v2float = OpTypeVector %float 2 +%mat2v2float = OpTypeMatrix %v2float 2 +%_ptr_Private_mat2v2float = OpTypePointer Private %mat2v2float + %14 = OpConstantNull %mat2v2float + %c = OpVariable %_ptr_Private_mat2v2float Private %14 + %void = OpTypeVoid + %15 = OpTypeFunction %void + %int_2 = OpConstant %int 2 +%mat4v4float = OpTypeMatrix %v4float 4 + %26 = OpConstantNull %mat4v4float + %float_2 = OpConstant %float 2 +%unused_entry_point = OpFunction %void None %15 + %18 = OpLabel + OpReturn + OpFunctionEnd + %foo = OpFunction %void None %15 + %20 = OpLabel + %21 = OpLoad %int %a + %23 = OpSDiv %int %21 %int_2 + OpStore %a %23 + %24 = OpLoad %v4float %b + %27 = OpVectorTimesMatrix %v4float %24 %26 + OpStore %b %27 + %28 = OpLoad %mat2v2float %c + %30 = OpMatrixTimesScalar %mat2v2float %28 %float_2 + OpStore %c %30 + OpReturn + OpFunctionEnd diff --git a/test/tint/statements/compound_assign/scalar/and.wgsl.expected.spvasm b/test/tint/statements/compound_assign/scalar/and.wgsl.expected.spvasm index b5bbca9e9f..3018c77426 100644 --- a/test/tint/statements/compound_assign/scalar/and.wgsl.expected.spvasm +++ b/test/tint/statements/compound_assign/scalar/and.wgsl.expected.spvasm @@ -1,14 +1,41 @@ -SKIP: FAILED - - -struct S { - a : i32, -} - -@group(0) @binding(0) var v : S; - -fn foo() { - v.a &= 2; -} - -Failed to generate: Unknown statement: tint::ast::CompoundAssignmentStatement +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 19 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %unused_entry_point "unused_entry_point" + OpExecutionMode %unused_entry_point LocalSize 1 1 1 + OpName %S "S" + OpMemberName %S 0 "a" + OpName %v "v" + OpName %unused_entry_point "unused_entry_point" + OpName %foo "foo" + OpDecorate %S Block + OpMemberDecorate %S 0 Offset 0 + OpDecorate %v DescriptorSet 0 + OpDecorate %v Binding 0 + %int = OpTypeInt 32 1 + %S = OpTypeStruct %int +%_ptr_StorageBuffer_S = OpTypePointer StorageBuffer %S + %v = OpVariable %_ptr_StorageBuffer_S StorageBuffer + %void = OpTypeVoid + %5 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 +%_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int + %int_2 = OpConstant %int 2 +%unused_entry_point = OpFunction %void None %5 + %8 = OpLabel + OpReturn + OpFunctionEnd + %foo = OpFunction %void None %5 + %10 = OpLabel + %14 = OpAccessChain %_ptr_StorageBuffer_int %v %uint_0 + %15 = OpAccessChain %_ptr_StorageBuffer_int %v %uint_0 + %16 = OpLoad %int %15 + %18 = OpBitwiseAnd %int %16 %int_2 + OpStore %14 %18 + OpReturn + OpFunctionEnd diff --git a/test/tint/statements/compound_assign/scalar/divide.wgsl.expected.spvasm b/test/tint/statements/compound_assign/scalar/divide.wgsl.expected.spvasm index d1cbd51114..7aa32b7f8e 100644 --- a/test/tint/statements/compound_assign/scalar/divide.wgsl.expected.spvasm +++ b/test/tint/statements/compound_assign/scalar/divide.wgsl.expected.spvasm @@ -1,14 +1,41 @@ -SKIP: FAILED - - -struct S { - a : i32, -} - -@group(0) @binding(0) var v : S; - -fn foo() { - v.a /= 2; -} - -Failed to generate: Unknown statement: tint::ast::CompoundAssignmentStatement +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 19 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %unused_entry_point "unused_entry_point" + OpExecutionMode %unused_entry_point LocalSize 1 1 1 + OpName %S "S" + OpMemberName %S 0 "a" + OpName %v "v" + OpName %unused_entry_point "unused_entry_point" + OpName %foo "foo" + OpDecorate %S Block + OpMemberDecorate %S 0 Offset 0 + OpDecorate %v DescriptorSet 0 + OpDecorate %v Binding 0 + %int = OpTypeInt 32 1 + %S = OpTypeStruct %int +%_ptr_StorageBuffer_S = OpTypePointer StorageBuffer %S + %v = OpVariable %_ptr_StorageBuffer_S StorageBuffer + %void = OpTypeVoid + %5 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 +%_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int + %int_2 = OpConstant %int 2 +%unused_entry_point = OpFunction %void None %5 + %8 = OpLabel + OpReturn + OpFunctionEnd + %foo = OpFunction %void None %5 + %10 = OpLabel + %14 = OpAccessChain %_ptr_StorageBuffer_int %v %uint_0 + %15 = OpAccessChain %_ptr_StorageBuffer_int %v %uint_0 + %16 = OpLoad %int %15 + %18 = OpSDiv %int %16 %int_2 + OpStore %14 %18 + OpReturn + OpFunctionEnd diff --git a/test/tint/statements/compound_assign/scalar/minus.wgsl.expected.spvasm b/test/tint/statements/compound_assign/scalar/minus.wgsl.expected.spvasm index 9cafcb93c7..13e9c6897b 100644 --- a/test/tint/statements/compound_assign/scalar/minus.wgsl.expected.spvasm +++ b/test/tint/statements/compound_assign/scalar/minus.wgsl.expected.spvasm @@ -1,14 +1,41 @@ -SKIP: FAILED - - -struct S { - a : i32, -} - -@group(0) @binding(0) var v : S; - -fn foo() { - v.a -= 2; -} - -Failed to generate: Unknown statement: tint::ast::CompoundAssignmentStatement +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 19 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %unused_entry_point "unused_entry_point" + OpExecutionMode %unused_entry_point LocalSize 1 1 1 + OpName %S "S" + OpMemberName %S 0 "a" + OpName %v "v" + OpName %unused_entry_point "unused_entry_point" + OpName %foo "foo" + OpDecorate %S Block + OpMemberDecorate %S 0 Offset 0 + OpDecorate %v DescriptorSet 0 + OpDecorate %v Binding 0 + %int = OpTypeInt 32 1 + %S = OpTypeStruct %int +%_ptr_StorageBuffer_S = OpTypePointer StorageBuffer %S + %v = OpVariable %_ptr_StorageBuffer_S StorageBuffer + %void = OpTypeVoid + %5 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 +%_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int + %int_2 = OpConstant %int 2 +%unused_entry_point = OpFunction %void None %5 + %8 = OpLabel + OpReturn + OpFunctionEnd + %foo = OpFunction %void None %5 + %10 = OpLabel + %14 = OpAccessChain %_ptr_StorageBuffer_int %v %uint_0 + %15 = OpAccessChain %_ptr_StorageBuffer_int %v %uint_0 + %16 = OpLoad %int %15 + %18 = OpISub %int %16 %int_2 + OpStore %14 %18 + OpReturn + OpFunctionEnd diff --git a/test/tint/statements/compound_assign/scalar/modulo.wgsl.expected.spvasm b/test/tint/statements/compound_assign/scalar/modulo.wgsl.expected.spvasm index 40d64ce25d..d109e993c6 100644 --- a/test/tint/statements/compound_assign/scalar/modulo.wgsl.expected.spvasm +++ b/test/tint/statements/compound_assign/scalar/modulo.wgsl.expected.spvasm @@ -1,14 +1,41 @@ -SKIP: FAILED - - -struct S { - a : i32, -} - -@group(0) @binding(0) var v : S; - -fn foo() { - v.a %= 2; -} - -Failed to generate: Unknown statement: tint::ast::CompoundAssignmentStatement +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 19 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %unused_entry_point "unused_entry_point" + OpExecutionMode %unused_entry_point LocalSize 1 1 1 + OpName %S "S" + OpMemberName %S 0 "a" + OpName %v "v" + OpName %unused_entry_point "unused_entry_point" + OpName %foo "foo" + OpDecorate %S Block + OpMemberDecorate %S 0 Offset 0 + OpDecorate %v DescriptorSet 0 + OpDecorate %v Binding 0 + %int = OpTypeInt 32 1 + %S = OpTypeStruct %int +%_ptr_StorageBuffer_S = OpTypePointer StorageBuffer %S + %v = OpVariable %_ptr_StorageBuffer_S StorageBuffer + %void = OpTypeVoid + %5 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 +%_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int + %int_2 = OpConstant %int 2 +%unused_entry_point = OpFunction %void None %5 + %8 = OpLabel + OpReturn + OpFunctionEnd + %foo = OpFunction %void None %5 + %10 = OpLabel + %14 = OpAccessChain %_ptr_StorageBuffer_int %v %uint_0 + %15 = OpAccessChain %_ptr_StorageBuffer_int %v %uint_0 + %16 = OpLoad %int %15 + %18 = OpSMod %int %16 %int_2 + OpStore %14 %18 + OpReturn + OpFunctionEnd diff --git a/test/tint/statements/compound_assign/scalar/or.wgsl.expected.spvasm b/test/tint/statements/compound_assign/scalar/or.wgsl.expected.spvasm index 573dbf1803..d90f474605 100644 --- a/test/tint/statements/compound_assign/scalar/or.wgsl.expected.spvasm +++ b/test/tint/statements/compound_assign/scalar/or.wgsl.expected.spvasm @@ -1,14 +1,41 @@ -SKIP: FAILED - - -struct S { - a : i32, -} - -@group(0) @binding(0) var v : S; - -fn foo() { - v.a |= 2; -} - -Failed to generate: Unknown statement: tint::ast::CompoundAssignmentStatement +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 19 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %unused_entry_point "unused_entry_point" + OpExecutionMode %unused_entry_point LocalSize 1 1 1 + OpName %S "S" + OpMemberName %S 0 "a" + OpName %v "v" + OpName %unused_entry_point "unused_entry_point" + OpName %foo "foo" + OpDecorate %S Block + OpMemberDecorate %S 0 Offset 0 + OpDecorate %v DescriptorSet 0 + OpDecorate %v Binding 0 + %int = OpTypeInt 32 1 + %S = OpTypeStruct %int +%_ptr_StorageBuffer_S = OpTypePointer StorageBuffer %S + %v = OpVariable %_ptr_StorageBuffer_S StorageBuffer + %void = OpTypeVoid + %5 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 +%_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int + %int_2 = OpConstant %int 2 +%unused_entry_point = OpFunction %void None %5 + %8 = OpLabel + OpReturn + OpFunctionEnd + %foo = OpFunction %void None %5 + %10 = OpLabel + %14 = OpAccessChain %_ptr_StorageBuffer_int %v %uint_0 + %15 = OpAccessChain %_ptr_StorageBuffer_int %v %uint_0 + %16 = OpLoad %int %15 + %18 = OpBitwiseOr %int %16 %int_2 + OpStore %14 %18 + OpReturn + OpFunctionEnd diff --git a/test/tint/statements/compound_assign/scalar/plus.wgsl.expected.spvasm b/test/tint/statements/compound_assign/scalar/plus.wgsl.expected.spvasm index 5ff170056f..1f6c345d1a 100644 --- a/test/tint/statements/compound_assign/scalar/plus.wgsl.expected.spvasm +++ b/test/tint/statements/compound_assign/scalar/plus.wgsl.expected.spvasm @@ -1,14 +1,41 @@ -SKIP: FAILED - - -struct S { - a : i32, -} - -@group(0) @binding(0) var v : S; - -fn foo() { - v.a += 2; -} - -Failed to generate: Unknown statement: tint::ast::CompoundAssignmentStatement +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 19 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %unused_entry_point "unused_entry_point" + OpExecutionMode %unused_entry_point LocalSize 1 1 1 + OpName %S "S" + OpMemberName %S 0 "a" + OpName %v "v" + OpName %unused_entry_point "unused_entry_point" + OpName %foo "foo" + OpDecorate %S Block + OpMemberDecorate %S 0 Offset 0 + OpDecorate %v DescriptorSet 0 + OpDecorate %v Binding 0 + %int = OpTypeInt 32 1 + %S = OpTypeStruct %int +%_ptr_StorageBuffer_S = OpTypePointer StorageBuffer %S + %v = OpVariable %_ptr_StorageBuffer_S StorageBuffer + %void = OpTypeVoid + %5 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 +%_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int + %int_2 = OpConstant %int 2 +%unused_entry_point = OpFunction %void None %5 + %8 = OpLabel + OpReturn + OpFunctionEnd + %foo = OpFunction %void None %5 + %10 = OpLabel + %14 = OpAccessChain %_ptr_StorageBuffer_int %v %uint_0 + %15 = OpAccessChain %_ptr_StorageBuffer_int %v %uint_0 + %16 = OpLoad %int %15 + %18 = OpIAdd %int %16 %int_2 + OpStore %14 %18 + OpReturn + OpFunctionEnd diff --git a/test/tint/statements/compound_assign/scalar/times.wgsl.expected.spvasm b/test/tint/statements/compound_assign/scalar/times.wgsl.expected.spvasm index c4bf38af9d..f2df422742 100644 --- a/test/tint/statements/compound_assign/scalar/times.wgsl.expected.spvasm +++ b/test/tint/statements/compound_assign/scalar/times.wgsl.expected.spvasm @@ -1,14 +1,41 @@ -SKIP: FAILED - - -struct S { - a : i32, -} - -@group(0) @binding(0) var v : S; - -fn foo() { - v.a *= 2; -} - -Failed to generate: Unknown statement: tint::ast::CompoundAssignmentStatement +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 19 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %unused_entry_point "unused_entry_point" + OpExecutionMode %unused_entry_point LocalSize 1 1 1 + OpName %S "S" + OpMemberName %S 0 "a" + OpName %v "v" + OpName %unused_entry_point "unused_entry_point" + OpName %foo "foo" + OpDecorate %S Block + OpMemberDecorate %S 0 Offset 0 + OpDecorate %v DescriptorSet 0 + OpDecorate %v Binding 0 + %int = OpTypeInt 32 1 + %S = OpTypeStruct %int +%_ptr_StorageBuffer_S = OpTypePointer StorageBuffer %S + %v = OpVariable %_ptr_StorageBuffer_S StorageBuffer + %void = OpTypeVoid + %5 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 +%_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int + %int_2 = OpConstant %int 2 +%unused_entry_point = OpFunction %void None %5 + %8 = OpLabel + OpReturn + OpFunctionEnd + %foo = OpFunction %void None %5 + %10 = OpLabel + %14 = OpAccessChain %_ptr_StorageBuffer_int %v %uint_0 + %15 = OpAccessChain %_ptr_StorageBuffer_int %v %uint_0 + %16 = OpLoad %int %15 + %18 = OpIMul %int %16 %int_2 + OpStore %14 %18 + OpReturn + OpFunctionEnd diff --git a/test/tint/statements/compound_assign/scalar/xor.wgsl.expected.spvasm b/test/tint/statements/compound_assign/scalar/xor.wgsl.expected.spvasm index 43c47127f4..e37d5bbe6b 100644 --- a/test/tint/statements/compound_assign/scalar/xor.wgsl.expected.spvasm +++ b/test/tint/statements/compound_assign/scalar/xor.wgsl.expected.spvasm @@ -1,14 +1,41 @@ -SKIP: FAILED - - -struct S { - a : i32, -} - -@group(0) @binding(0) var v : S; - -fn foo() { - v.a ^= 2; -} - -Failed to generate: Unknown statement: tint::ast::CompoundAssignmentStatement +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 19 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %unused_entry_point "unused_entry_point" + OpExecutionMode %unused_entry_point LocalSize 1 1 1 + OpName %S "S" + OpMemberName %S 0 "a" + OpName %v "v" + OpName %unused_entry_point "unused_entry_point" + OpName %foo "foo" + OpDecorate %S Block + OpMemberDecorate %S 0 Offset 0 + OpDecorate %v DescriptorSet 0 + OpDecorate %v Binding 0 + %int = OpTypeInt 32 1 + %S = OpTypeStruct %int +%_ptr_StorageBuffer_S = OpTypePointer StorageBuffer %S + %v = OpVariable %_ptr_StorageBuffer_S StorageBuffer + %void = OpTypeVoid + %5 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 +%_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int + %int_2 = OpConstant %int 2 +%unused_entry_point = OpFunction %void None %5 + %8 = OpLabel + OpReturn + OpFunctionEnd + %foo = OpFunction %void None %5 + %10 = OpLabel + %14 = OpAccessChain %_ptr_StorageBuffer_int %v %uint_0 + %15 = OpAccessChain %_ptr_StorageBuffer_int %v %uint_0 + %16 = OpLoad %int %15 + %18 = OpBitwiseXor %int %16 %int_2 + OpStore %14 %18 + OpReturn + OpFunctionEnd diff --git a/test/tint/statements/compound_assign/vector/and.wgsl.expected.spvasm b/test/tint/statements/compound_assign/vector/and.wgsl.expected.spvasm index 302714331c..10f27ff919 100644 --- a/test/tint/statements/compound_assign/vector/and.wgsl.expected.spvasm +++ b/test/tint/statements/compound_assign/vector/and.wgsl.expected.spvasm @@ -1,14 +1,43 @@ -SKIP: FAILED - - -struct S { - a : vec4, -} - -@group(0) @binding(0) var v : S; - -fn foo() { - v.a &= vec4(2); -} - -Failed to generate: Unknown statement: tint::ast::CompoundAssignmentStatement +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 21 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %unused_entry_point "unused_entry_point" + OpExecutionMode %unused_entry_point LocalSize 1 1 1 + OpName %S "S" + OpMemberName %S 0 "a" + OpName %v "v" + OpName %unused_entry_point "unused_entry_point" + OpName %foo "foo" + OpDecorate %S Block + OpMemberDecorate %S 0 Offset 0 + OpDecorate %v DescriptorSet 0 + OpDecorate %v Binding 0 + %int = OpTypeInt 32 1 + %v4int = OpTypeVector %int 4 + %S = OpTypeStruct %v4int +%_ptr_StorageBuffer_S = OpTypePointer StorageBuffer %S + %v = OpVariable %_ptr_StorageBuffer_S StorageBuffer + %void = OpTypeVoid + %6 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 +%_ptr_StorageBuffer_v4int = OpTypePointer StorageBuffer %v4int + %int_2 = OpConstant %int 2 + %19 = OpConstantComposite %v4int %int_2 %int_2 %int_2 %int_2 +%unused_entry_point = OpFunction %void None %6 + %9 = OpLabel + OpReturn + OpFunctionEnd + %foo = OpFunction %void None %6 + %11 = OpLabel + %15 = OpAccessChain %_ptr_StorageBuffer_v4int %v %uint_0 + %16 = OpAccessChain %_ptr_StorageBuffer_v4int %v %uint_0 + %17 = OpLoad %v4int %16 + %20 = OpBitwiseAnd %v4int %17 %19 + OpStore %15 %20 + OpReturn + OpFunctionEnd diff --git a/test/tint/statements/compound_assign/vector/divide-scalar.wgsl.expected.spvasm b/test/tint/statements/compound_assign/vector/divide-scalar.wgsl.expected.spvasm index 3a337b8a06..b25b02d019 100644 --- a/test/tint/statements/compound_assign/vector/divide-scalar.wgsl.expected.spvasm +++ b/test/tint/statements/compound_assign/vector/divide-scalar.wgsl.expected.spvasm @@ -1,14 +1,46 @@ -SKIP: FAILED - - -struct S { - a : vec4, -} - -@group(0) @binding(0) var v : S; - -fn foo() { - v.a /= 2.0; -} - -Failed to generate: Unknown statement: tint::ast::CompoundAssignmentStatement +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 24 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %unused_entry_point "unused_entry_point" + OpExecutionMode %unused_entry_point LocalSize 1 1 1 + OpName %S "S" + OpMemberName %S 0 "a" + OpName %v "v" + OpName %unused_entry_point "unused_entry_point" + OpName %foo "foo" + OpDecorate %S Block + OpMemberDecorate %S 0 Offset 0 + OpDecorate %v DescriptorSet 0 + OpDecorate %v Binding 0 + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %S = OpTypeStruct %v4float +%_ptr_StorageBuffer_S = OpTypePointer StorageBuffer %S + %v = OpVariable %_ptr_StorageBuffer_S StorageBuffer + %void = OpTypeVoid + %6 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 +%_ptr_StorageBuffer_v4float = OpTypePointer StorageBuffer %v4float + %float_2 = OpConstant %float 2 +%_ptr_Function_v4float = OpTypePointer Function %v4float + %22 = OpConstantNull %v4float +%unused_entry_point = OpFunction %void None %6 + %9 = OpLabel + OpReturn + OpFunctionEnd + %foo = OpFunction %void None %6 + %11 = OpLabel + %20 = OpVariable %_ptr_Function_v4float Function %22 + %15 = OpAccessChain %_ptr_StorageBuffer_v4float %v %uint_0 + %16 = OpAccessChain %_ptr_StorageBuffer_v4float %v %uint_0 + %17 = OpLoad %v4float %16 + %23 = OpCompositeConstruct %v4float %float_2 %float_2 %float_2 %float_2 + %19 = OpFDiv %v4float %17 %23 + OpStore %15 %19 + OpReturn + OpFunctionEnd diff --git a/test/tint/statements/compound_assign/vector/divide.wgsl.expected.spvasm b/test/tint/statements/compound_assign/vector/divide.wgsl.expected.spvasm index 3843576d4e..5eaea4102c 100644 --- a/test/tint/statements/compound_assign/vector/divide.wgsl.expected.spvasm +++ b/test/tint/statements/compound_assign/vector/divide.wgsl.expected.spvasm @@ -1,14 +1,43 @@ -SKIP: FAILED - - -struct S { - a : vec4, -} - -@group(0) @binding(0) var v : S; - -fn foo() { - v.a /= vec4(2); -} - -Failed to generate: Unknown statement: tint::ast::CompoundAssignmentStatement +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 21 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %unused_entry_point "unused_entry_point" + OpExecutionMode %unused_entry_point LocalSize 1 1 1 + OpName %S "S" + OpMemberName %S 0 "a" + OpName %v "v" + OpName %unused_entry_point "unused_entry_point" + OpName %foo "foo" + OpDecorate %S Block + OpMemberDecorate %S 0 Offset 0 + OpDecorate %v DescriptorSet 0 + OpDecorate %v Binding 0 + %int = OpTypeInt 32 1 + %v4int = OpTypeVector %int 4 + %S = OpTypeStruct %v4int +%_ptr_StorageBuffer_S = OpTypePointer StorageBuffer %S + %v = OpVariable %_ptr_StorageBuffer_S StorageBuffer + %void = OpTypeVoid + %6 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 +%_ptr_StorageBuffer_v4int = OpTypePointer StorageBuffer %v4int + %int_2 = OpConstant %int 2 + %19 = OpConstantComposite %v4int %int_2 %int_2 %int_2 %int_2 +%unused_entry_point = OpFunction %void None %6 + %9 = OpLabel + OpReturn + OpFunctionEnd + %foo = OpFunction %void None %6 + %11 = OpLabel + %15 = OpAccessChain %_ptr_StorageBuffer_v4int %v %uint_0 + %16 = OpAccessChain %_ptr_StorageBuffer_v4int %v %uint_0 + %17 = OpLoad %v4int %16 + %20 = OpSDiv %v4int %17 %19 + OpStore %15 %20 + OpReturn + OpFunctionEnd diff --git a/test/tint/statements/compound_assign/vector/minus-scalar.wgsl.expected.spvasm b/test/tint/statements/compound_assign/vector/minus-scalar.wgsl.expected.spvasm index 6fe6c15f52..5723fffbe2 100644 --- a/test/tint/statements/compound_assign/vector/minus-scalar.wgsl.expected.spvasm +++ b/test/tint/statements/compound_assign/vector/minus-scalar.wgsl.expected.spvasm @@ -1,14 +1,46 @@ -SKIP: FAILED - - -struct S { - a : vec4, -} - -@group(0) @binding(0) var v : S; - -fn foo() { - v.a -= 2.0; -} - -Failed to generate: Unknown statement: tint::ast::CompoundAssignmentStatement +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 24 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %unused_entry_point "unused_entry_point" + OpExecutionMode %unused_entry_point LocalSize 1 1 1 + OpName %S "S" + OpMemberName %S 0 "a" + OpName %v "v" + OpName %unused_entry_point "unused_entry_point" + OpName %foo "foo" + OpDecorate %S Block + OpMemberDecorate %S 0 Offset 0 + OpDecorate %v DescriptorSet 0 + OpDecorate %v Binding 0 + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %S = OpTypeStruct %v4float +%_ptr_StorageBuffer_S = OpTypePointer StorageBuffer %S + %v = OpVariable %_ptr_StorageBuffer_S StorageBuffer + %void = OpTypeVoid + %6 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 +%_ptr_StorageBuffer_v4float = OpTypePointer StorageBuffer %v4float + %float_2 = OpConstant %float 2 +%_ptr_Function_v4float = OpTypePointer Function %v4float + %22 = OpConstantNull %v4float +%unused_entry_point = OpFunction %void None %6 + %9 = OpLabel + OpReturn + OpFunctionEnd + %foo = OpFunction %void None %6 + %11 = OpLabel + %20 = OpVariable %_ptr_Function_v4float Function %22 + %15 = OpAccessChain %_ptr_StorageBuffer_v4float %v %uint_0 + %16 = OpAccessChain %_ptr_StorageBuffer_v4float %v %uint_0 + %17 = OpLoad %v4float %16 + %23 = OpCompositeConstruct %v4float %float_2 %float_2 %float_2 %float_2 + %19 = OpFSub %v4float %17 %23 + OpStore %15 %19 + OpReturn + OpFunctionEnd diff --git a/test/tint/statements/compound_assign/vector/minus.wgsl.expected.spvasm b/test/tint/statements/compound_assign/vector/minus.wgsl.expected.spvasm index fa2bc43198..b670da2dac 100644 --- a/test/tint/statements/compound_assign/vector/minus.wgsl.expected.spvasm +++ b/test/tint/statements/compound_assign/vector/minus.wgsl.expected.spvasm @@ -1,14 +1,43 @@ -SKIP: FAILED - - -struct S { - a : vec4, -} - -@group(0) @binding(0) var v : S; - -fn foo() { - v.a -= vec4(2); -} - -Failed to generate: Unknown statement: tint::ast::CompoundAssignmentStatement +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 21 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %unused_entry_point "unused_entry_point" + OpExecutionMode %unused_entry_point LocalSize 1 1 1 + OpName %S "S" + OpMemberName %S 0 "a" + OpName %v "v" + OpName %unused_entry_point "unused_entry_point" + OpName %foo "foo" + OpDecorate %S Block + OpMemberDecorate %S 0 Offset 0 + OpDecorate %v DescriptorSet 0 + OpDecorate %v Binding 0 + %int = OpTypeInt 32 1 + %v4int = OpTypeVector %int 4 + %S = OpTypeStruct %v4int +%_ptr_StorageBuffer_S = OpTypePointer StorageBuffer %S + %v = OpVariable %_ptr_StorageBuffer_S StorageBuffer + %void = OpTypeVoid + %6 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 +%_ptr_StorageBuffer_v4int = OpTypePointer StorageBuffer %v4int + %int_2 = OpConstant %int 2 + %19 = OpConstantComposite %v4int %int_2 %int_2 %int_2 %int_2 +%unused_entry_point = OpFunction %void None %6 + %9 = OpLabel + OpReturn + OpFunctionEnd + %foo = OpFunction %void None %6 + %11 = OpLabel + %15 = OpAccessChain %_ptr_StorageBuffer_v4int %v %uint_0 + %16 = OpAccessChain %_ptr_StorageBuffer_v4int %v %uint_0 + %17 = OpLoad %v4int %16 + %20 = OpISub %v4int %17 %19 + OpStore %15 %20 + OpReturn + OpFunctionEnd diff --git a/test/tint/statements/compound_assign/vector/modulo-scalar.wgsl.expected.spvasm b/test/tint/statements/compound_assign/vector/modulo-scalar.wgsl.expected.spvasm index ea9d76d2b7..eee788af06 100644 --- a/test/tint/statements/compound_assign/vector/modulo-scalar.wgsl.expected.spvasm +++ b/test/tint/statements/compound_assign/vector/modulo-scalar.wgsl.expected.spvasm @@ -1,14 +1,46 @@ -SKIP: FAILED - - -struct S { - a : vec4, -} - -@group(0) @binding(0) var v : S; - -fn foo() { - v.a %= 2; -} - -Failed to generate: Unknown statement: tint::ast::CompoundAssignmentStatement +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 24 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %unused_entry_point "unused_entry_point" + OpExecutionMode %unused_entry_point LocalSize 1 1 1 + OpName %S "S" + OpMemberName %S 0 "a" + OpName %v "v" + OpName %unused_entry_point "unused_entry_point" + OpName %foo "foo" + OpDecorate %S Block + OpMemberDecorate %S 0 Offset 0 + OpDecorate %v DescriptorSet 0 + OpDecorate %v Binding 0 + %int = OpTypeInt 32 1 + %v4int = OpTypeVector %int 4 + %S = OpTypeStruct %v4int +%_ptr_StorageBuffer_S = OpTypePointer StorageBuffer %S + %v = OpVariable %_ptr_StorageBuffer_S StorageBuffer + %void = OpTypeVoid + %6 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 +%_ptr_StorageBuffer_v4int = OpTypePointer StorageBuffer %v4int + %int_2 = OpConstant %int 2 +%_ptr_Function_v4int = OpTypePointer Function %v4int + %22 = OpConstantNull %v4int +%unused_entry_point = OpFunction %void None %6 + %9 = OpLabel + OpReturn + OpFunctionEnd + %foo = OpFunction %void None %6 + %11 = OpLabel + %20 = OpVariable %_ptr_Function_v4int Function %22 + %15 = OpAccessChain %_ptr_StorageBuffer_v4int %v %uint_0 + %16 = OpAccessChain %_ptr_StorageBuffer_v4int %v %uint_0 + %17 = OpLoad %v4int %16 + %23 = OpCompositeConstruct %v4int %int_2 %int_2 %int_2 %int_2 + %19 = OpSMod %v4int %17 %23 + OpStore %15 %19 + OpReturn + OpFunctionEnd diff --git a/test/tint/statements/compound_assign/vector/modulo.wgsl.expected.spvasm b/test/tint/statements/compound_assign/vector/modulo.wgsl.expected.spvasm index 5286c69bc0..c34ad91737 100644 --- a/test/tint/statements/compound_assign/vector/modulo.wgsl.expected.spvasm +++ b/test/tint/statements/compound_assign/vector/modulo.wgsl.expected.spvasm @@ -1,14 +1,43 @@ -SKIP: FAILED - - -struct S { - a : vec4, -} - -@group(0) @binding(0) var v : S; - -fn foo() { - v.a %= vec4(2); -} - -Failed to generate: Unknown statement: tint::ast::CompoundAssignmentStatement +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 21 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %unused_entry_point "unused_entry_point" + OpExecutionMode %unused_entry_point LocalSize 1 1 1 + OpName %S "S" + OpMemberName %S 0 "a" + OpName %v "v" + OpName %unused_entry_point "unused_entry_point" + OpName %foo "foo" + OpDecorate %S Block + OpMemberDecorate %S 0 Offset 0 + OpDecorate %v DescriptorSet 0 + OpDecorate %v Binding 0 + %int = OpTypeInt 32 1 + %v4int = OpTypeVector %int 4 + %S = OpTypeStruct %v4int +%_ptr_StorageBuffer_S = OpTypePointer StorageBuffer %S + %v = OpVariable %_ptr_StorageBuffer_S StorageBuffer + %void = OpTypeVoid + %6 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 +%_ptr_StorageBuffer_v4int = OpTypePointer StorageBuffer %v4int + %int_2 = OpConstant %int 2 + %19 = OpConstantComposite %v4int %int_2 %int_2 %int_2 %int_2 +%unused_entry_point = OpFunction %void None %6 + %9 = OpLabel + OpReturn + OpFunctionEnd + %foo = OpFunction %void None %6 + %11 = OpLabel + %15 = OpAccessChain %_ptr_StorageBuffer_v4int %v %uint_0 + %16 = OpAccessChain %_ptr_StorageBuffer_v4int %v %uint_0 + %17 = OpLoad %v4int %16 + %20 = OpSMod %v4int %17 %19 + OpStore %15 %20 + OpReturn + OpFunctionEnd diff --git a/test/tint/statements/compound_assign/vector/or.wgsl.expected.spvasm b/test/tint/statements/compound_assign/vector/or.wgsl.expected.spvasm index 62bc8a65a0..d11137f184 100644 --- a/test/tint/statements/compound_assign/vector/or.wgsl.expected.spvasm +++ b/test/tint/statements/compound_assign/vector/or.wgsl.expected.spvasm @@ -1,14 +1,43 @@ -SKIP: FAILED - - -struct S { - a : vec4, -} - -@group(0) @binding(0) var v : S; - -fn foo() { - v.a |= vec4(2); -} - -Failed to generate: Unknown statement: tint::ast::CompoundAssignmentStatement +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 21 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %unused_entry_point "unused_entry_point" + OpExecutionMode %unused_entry_point LocalSize 1 1 1 + OpName %S "S" + OpMemberName %S 0 "a" + OpName %v "v" + OpName %unused_entry_point "unused_entry_point" + OpName %foo "foo" + OpDecorate %S Block + OpMemberDecorate %S 0 Offset 0 + OpDecorate %v DescriptorSet 0 + OpDecorate %v Binding 0 + %int = OpTypeInt 32 1 + %v4int = OpTypeVector %int 4 + %S = OpTypeStruct %v4int +%_ptr_StorageBuffer_S = OpTypePointer StorageBuffer %S + %v = OpVariable %_ptr_StorageBuffer_S StorageBuffer + %void = OpTypeVoid + %6 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 +%_ptr_StorageBuffer_v4int = OpTypePointer StorageBuffer %v4int + %int_2 = OpConstant %int 2 + %19 = OpConstantComposite %v4int %int_2 %int_2 %int_2 %int_2 +%unused_entry_point = OpFunction %void None %6 + %9 = OpLabel + OpReturn + OpFunctionEnd + %foo = OpFunction %void None %6 + %11 = OpLabel + %15 = OpAccessChain %_ptr_StorageBuffer_v4int %v %uint_0 + %16 = OpAccessChain %_ptr_StorageBuffer_v4int %v %uint_0 + %17 = OpLoad %v4int %16 + %20 = OpBitwiseOr %v4int %17 %19 + OpStore %15 %20 + OpReturn + OpFunctionEnd diff --git a/test/tint/statements/compound_assign/vector/plus-scalar.wgsl.expected.spvasm b/test/tint/statements/compound_assign/vector/plus-scalar.wgsl.expected.spvasm index dba101e852..787c30db69 100644 --- a/test/tint/statements/compound_assign/vector/plus-scalar.wgsl.expected.spvasm +++ b/test/tint/statements/compound_assign/vector/plus-scalar.wgsl.expected.spvasm @@ -1,14 +1,46 @@ -SKIP: FAILED - - -struct S { - a : vec4, -} - -@group(0) @binding(0) var v : S; - -fn foo() { - v.a += 2.0; -} - -Failed to generate: Unknown statement: tint::ast::CompoundAssignmentStatement +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 24 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %unused_entry_point "unused_entry_point" + OpExecutionMode %unused_entry_point LocalSize 1 1 1 + OpName %S "S" + OpMemberName %S 0 "a" + OpName %v "v" + OpName %unused_entry_point "unused_entry_point" + OpName %foo "foo" + OpDecorate %S Block + OpMemberDecorate %S 0 Offset 0 + OpDecorate %v DescriptorSet 0 + OpDecorate %v Binding 0 + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %S = OpTypeStruct %v4float +%_ptr_StorageBuffer_S = OpTypePointer StorageBuffer %S + %v = OpVariable %_ptr_StorageBuffer_S StorageBuffer + %void = OpTypeVoid + %6 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 +%_ptr_StorageBuffer_v4float = OpTypePointer StorageBuffer %v4float + %float_2 = OpConstant %float 2 +%_ptr_Function_v4float = OpTypePointer Function %v4float + %22 = OpConstantNull %v4float +%unused_entry_point = OpFunction %void None %6 + %9 = OpLabel + OpReturn + OpFunctionEnd + %foo = OpFunction %void None %6 + %11 = OpLabel + %20 = OpVariable %_ptr_Function_v4float Function %22 + %15 = OpAccessChain %_ptr_StorageBuffer_v4float %v %uint_0 + %16 = OpAccessChain %_ptr_StorageBuffer_v4float %v %uint_0 + %17 = OpLoad %v4float %16 + %23 = OpCompositeConstruct %v4float %float_2 %float_2 %float_2 %float_2 + %19 = OpFAdd %v4float %17 %23 + OpStore %15 %19 + OpReturn + OpFunctionEnd diff --git a/test/tint/statements/compound_assign/vector/plus.wgsl.expected.spvasm b/test/tint/statements/compound_assign/vector/plus.wgsl.expected.spvasm index 03bdb8c18c..718656a82a 100644 --- a/test/tint/statements/compound_assign/vector/plus.wgsl.expected.spvasm +++ b/test/tint/statements/compound_assign/vector/plus.wgsl.expected.spvasm @@ -1,14 +1,43 @@ -SKIP: FAILED - - -struct S { - a : vec4, -} - -@group(0) @binding(0) var v : S; - -fn foo() { - v.a += vec4(2); -} - -Failed to generate: Unknown statement: tint::ast::CompoundAssignmentStatement +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 21 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %unused_entry_point "unused_entry_point" + OpExecutionMode %unused_entry_point LocalSize 1 1 1 + OpName %S "S" + OpMemberName %S 0 "a" + OpName %v "v" + OpName %unused_entry_point "unused_entry_point" + OpName %foo "foo" + OpDecorate %S Block + OpMemberDecorate %S 0 Offset 0 + OpDecorate %v DescriptorSet 0 + OpDecorate %v Binding 0 + %int = OpTypeInt 32 1 + %v4int = OpTypeVector %int 4 + %S = OpTypeStruct %v4int +%_ptr_StorageBuffer_S = OpTypePointer StorageBuffer %S + %v = OpVariable %_ptr_StorageBuffer_S StorageBuffer + %void = OpTypeVoid + %6 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 +%_ptr_StorageBuffer_v4int = OpTypePointer StorageBuffer %v4int + %int_2 = OpConstant %int 2 + %19 = OpConstantComposite %v4int %int_2 %int_2 %int_2 %int_2 +%unused_entry_point = OpFunction %void None %6 + %9 = OpLabel + OpReturn + OpFunctionEnd + %foo = OpFunction %void None %6 + %11 = OpLabel + %15 = OpAccessChain %_ptr_StorageBuffer_v4int %v %uint_0 + %16 = OpAccessChain %_ptr_StorageBuffer_v4int %v %uint_0 + %17 = OpLoad %v4int %16 + %20 = OpIAdd %v4int %17 %19 + OpStore %15 %20 + OpReturn + OpFunctionEnd diff --git a/test/tint/statements/compound_assign/vector/times-matrix.wgsl.expected.spvasm b/test/tint/statements/compound_assign/vector/times-matrix.wgsl.expected.spvasm index 6a230617fa..6e5cef7c75 100644 --- a/test/tint/statements/compound_assign/vector/times-matrix.wgsl.expected.spvasm +++ b/test/tint/statements/compound_assign/vector/times-matrix.wgsl.expected.spvasm @@ -1,14 +1,43 @@ -SKIP: FAILED - - -struct S { - a : vec4, -} - -@group(0) @binding(0) var v : S; - -fn foo() { - v.a *= mat4x4(); -} - -Failed to generate: Unknown statement: tint::ast::CompoundAssignmentStatement +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 21 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %unused_entry_point "unused_entry_point" + OpExecutionMode %unused_entry_point LocalSize 1 1 1 + OpName %S "S" + OpMemberName %S 0 "a" + OpName %v "v" + OpName %unused_entry_point "unused_entry_point" + OpName %foo "foo" + OpDecorate %S Block + OpMemberDecorate %S 0 Offset 0 + OpDecorate %v DescriptorSet 0 + OpDecorate %v Binding 0 + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %S = OpTypeStruct %v4float +%_ptr_StorageBuffer_S = OpTypePointer StorageBuffer %S + %v = OpVariable %_ptr_StorageBuffer_S StorageBuffer + %void = OpTypeVoid + %6 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 +%_ptr_StorageBuffer_v4float = OpTypePointer StorageBuffer %v4float +%mat4v4float = OpTypeMatrix %v4float 4 + %19 = OpConstantNull %mat4v4float +%unused_entry_point = OpFunction %void None %6 + %9 = OpLabel + OpReturn + OpFunctionEnd + %foo = OpFunction %void None %6 + %11 = OpLabel + %15 = OpAccessChain %_ptr_StorageBuffer_v4float %v %uint_0 + %16 = OpAccessChain %_ptr_StorageBuffer_v4float %v %uint_0 + %17 = OpLoad %v4float %16 + %20 = OpVectorTimesMatrix %v4float %17 %19 + OpStore %15 %20 + OpReturn + OpFunctionEnd diff --git a/test/tint/statements/compound_assign/vector/times-scalar.wgsl.expected.spvasm b/test/tint/statements/compound_assign/vector/times-scalar.wgsl.expected.spvasm index 095e2b063e..733b250162 100644 --- a/test/tint/statements/compound_assign/vector/times-scalar.wgsl.expected.spvasm +++ b/test/tint/statements/compound_assign/vector/times-scalar.wgsl.expected.spvasm @@ -1,14 +1,42 @@ -SKIP: FAILED - - -struct S { - a : vec4, -} - -@group(0) @binding(0) var v : S; - -fn foo() { - v.a *= 2.0; -} - -Failed to generate: Unknown statement: tint::ast::CompoundAssignmentStatement +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 20 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %unused_entry_point "unused_entry_point" + OpExecutionMode %unused_entry_point LocalSize 1 1 1 + OpName %S "S" + OpMemberName %S 0 "a" + OpName %v "v" + OpName %unused_entry_point "unused_entry_point" + OpName %foo "foo" + OpDecorate %S Block + OpMemberDecorate %S 0 Offset 0 + OpDecorate %v DescriptorSet 0 + OpDecorate %v Binding 0 + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %S = OpTypeStruct %v4float +%_ptr_StorageBuffer_S = OpTypePointer StorageBuffer %S + %v = OpVariable %_ptr_StorageBuffer_S StorageBuffer + %void = OpTypeVoid + %6 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 +%_ptr_StorageBuffer_v4float = OpTypePointer StorageBuffer %v4float + %float_2 = OpConstant %float 2 +%unused_entry_point = OpFunction %void None %6 + %9 = OpLabel + OpReturn + OpFunctionEnd + %foo = OpFunction %void None %6 + %11 = OpLabel + %15 = OpAccessChain %_ptr_StorageBuffer_v4float %v %uint_0 + %16 = OpAccessChain %_ptr_StorageBuffer_v4float %v %uint_0 + %17 = OpLoad %v4float %16 + %19 = OpVectorTimesScalar %v4float %17 %float_2 + OpStore %15 %19 + OpReturn + OpFunctionEnd diff --git a/test/tint/statements/compound_assign/vector/times.wgsl.expected.spvasm b/test/tint/statements/compound_assign/vector/times.wgsl.expected.spvasm index a658717ecd..28e4545b18 100644 --- a/test/tint/statements/compound_assign/vector/times.wgsl.expected.spvasm +++ b/test/tint/statements/compound_assign/vector/times.wgsl.expected.spvasm @@ -1,14 +1,43 @@ -SKIP: FAILED - - -struct S { - a : vec4, -} - -@group(0) @binding(0) var v : S; - -fn foo() { - v.a *= vec4(2); -} - -Failed to generate: Unknown statement: tint::ast::CompoundAssignmentStatement +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 21 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %unused_entry_point "unused_entry_point" + OpExecutionMode %unused_entry_point LocalSize 1 1 1 + OpName %S "S" + OpMemberName %S 0 "a" + OpName %v "v" + OpName %unused_entry_point "unused_entry_point" + OpName %foo "foo" + OpDecorate %S Block + OpMemberDecorate %S 0 Offset 0 + OpDecorate %v DescriptorSet 0 + OpDecorate %v Binding 0 + %int = OpTypeInt 32 1 + %v4int = OpTypeVector %int 4 + %S = OpTypeStruct %v4int +%_ptr_StorageBuffer_S = OpTypePointer StorageBuffer %S + %v = OpVariable %_ptr_StorageBuffer_S StorageBuffer + %void = OpTypeVoid + %6 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 +%_ptr_StorageBuffer_v4int = OpTypePointer StorageBuffer %v4int + %int_2 = OpConstant %int 2 + %19 = OpConstantComposite %v4int %int_2 %int_2 %int_2 %int_2 +%unused_entry_point = OpFunction %void None %6 + %9 = OpLabel + OpReturn + OpFunctionEnd + %foo = OpFunction %void None %6 + %11 = OpLabel + %15 = OpAccessChain %_ptr_StorageBuffer_v4int %v %uint_0 + %16 = OpAccessChain %_ptr_StorageBuffer_v4int %v %uint_0 + %17 = OpLoad %v4int %16 + %20 = OpIMul %v4int %17 %19 + OpStore %15 %20 + OpReturn + OpFunctionEnd diff --git a/test/tint/statements/compound_assign/vector/xor.wgsl.expected.spvasm b/test/tint/statements/compound_assign/vector/xor.wgsl.expected.spvasm index c2f83b7f15..105fc009f8 100644 --- a/test/tint/statements/compound_assign/vector/xor.wgsl.expected.spvasm +++ b/test/tint/statements/compound_assign/vector/xor.wgsl.expected.spvasm @@ -1,14 +1,43 @@ -SKIP: FAILED - - -struct S { - a : vec4, -} - -@group(0) @binding(0) var v : S; - -fn foo() { - v.a ^= vec4(2); -} - -Failed to generate: Unknown statement: tint::ast::CompoundAssignmentStatement +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 21 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %unused_entry_point "unused_entry_point" + OpExecutionMode %unused_entry_point LocalSize 1 1 1 + OpName %S "S" + OpMemberName %S 0 "a" + OpName %v "v" + OpName %unused_entry_point "unused_entry_point" + OpName %foo "foo" + OpDecorate %S Block + OpMemberDecorate %S 0 Offset 0 + OpDecorate %v DescriptorSet 0 + OpDecorate %v Binding 0 + %int = OpTypeInt 32 1 + %v4int = OpTypeVector %int 4 + %S = OpTypeStruct %v4int +%_ptr_StorageBuffer_S = OpTypePointer StorageBuffer %S + %v = OpVariable %_ptr_StorageBuffer_S StorageBuffer + %void = OpTypeVoid + %6 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 +%_ptr_StorageBuffer_v4int = OpTypePointer StorageBuffer %v4int + %int_2 = OpConstant %int 2 + %19 = OpConstantComposite %v4int %int_2 %int_2 %int_2 %int_2 +%unused_entry_point = OpFunction %void None %6 + %9 = OpLabel + OpReturn + OpFunctionEnd + %foo = OpFunction %void None %6 + %11 = OpLabel + %15 = OpAccessChain %_ptr_StorageBuffer_v4int %v %uint_0 + %16 = OpAccessChain %_ptr_StorageBuffer_v4int %v %uint_0 + %17 = OpLoad %v4int %16 + %20 = OpBitwiseXor %v4int %17 %19 + OpStore %15 %20 + OpReturn + OpFunctionEnd diff --git a/test/tint/statements/compound_assign/workgroup.wgsl.expected.spvasm b/test/tint/statements/compound_assign/workgroup.wgsl.expected.spvasm index f670d77e32..ddf0b14c93 100644 --- a/test/tint/statements/compound_assign/workgroup.wgsl.expected.spvasm +++ b/test/tint/statements/compound_assign/workgroup.wgsl.expected.spvasm @@ -1,16 +1,48 @@ -SKIP: FAILED - - -var a : i32; - -var b : vec4; - -var c : mat2x2; - -fn foo() { - a /= 2; - b *= mat4x4(); - c *= 2.0; -} - -Failed to generate: Unknown statement: tint::ast::CompoundAssignmentStatement +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 28 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %unused_entry_point "unused_entry_point" + OpExecutionMode %unused_entry_point LocalSize 1 1 1 + OpName %a "a" + OpName %b "b" + OpName %c "c" + OpName %unused_entry_point "unused_entry_point" + OpName %foo "foo" + %int = OpTypeInt 32 1 +%_ptr_Workgroup_int = OpTypePointer Workgroup %int + %a = OpVariable %_ptr_Workgroup_int Workgroup + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Workgroup_v4float = OpTypePointer Workgroup %v4float + %b = OpVariable %_ptr_Workgroup_v4float Workgroup + %v2float = OpTypeVector %float 2 +%mat2v2float = OpTypeMatrix %v2float 2 +%_ptr_Workgroup_mat2v2float = OpTypePointer Workgroup %mat2v2float + %c = OpVariable %_ptr_Workgroup_mat2v2float Workgroup + %void = OpTypeVoid + %12 = OpTypeFunction %void + %int_2 = OpConstant %int 2 +%mat4v4float = OpTypeMatrix %v4float 4 + %23 = OpConstantNull %mat4v4float + %float_2 = OpConstant %float 2 +%unused_entry_point = OpFunction %void None %12 + %15 = OpLabel + OpReturn + OpFunctionEnd + %foo = OpFunction %void None %12 + %17 = OpLabel + %18 = OpLoad %int %a + %20 = OpSDiv %int %18 %int_2 + OpStore %a %20 + %21 = OpLoad %v4float %b + %24 = OpVectorTimesMatrix %v4float %21 %23 + OpStore %b %24 + %25 = OpLoad %mat2v2float %c + %27 = OpMatrixTimesScalar %mat2v2float %25 %float_2 + OpStore %c %27 + OpReturn + OpFunctionEnd