mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-16 00:17:03 +00:00
Add support for >>= and <<=.
This CL adds `<<=` and `>>=` to the supported operators in WGSL. The ExpandCompoundAssignment transform is used to convert to the expanded form. Bug: tint:1594 Change-Id: I20519052c52d4b69bc90def1acc5c0a30c36fd8a Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97980 Auto-Submit: Dan Sinclair <dsinclair@chromium.org> Reviewed-by: Ben Clayton <bclayton@google.com> Commit-Queue: Dan Sinclair <dsinclair@chromium.org> Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
committed by
Dawn LUCI CQ
parent
6f0884983f
commit
73778d3b0b
@@ -0,0 +1,9 @@
|
||||
struct S {
|
||||
a : i32,
|
||||
}
|
||||
@group(0) @binding(0)
|
||||
var<storage, read_write> v : S;
|
||||
|
||||
fn foo() {
|
||||
v.a <<= 2;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
[numthreads(1, 1, 1)]
|
||||
void unused_entry_point() {
|
||||
return;
|
||||
}
|
||||
|
||||
RWByteAddressBuffer v : register(u0, space0);
|
||||
|
||||
void foo() {
|
||||
v.Store(0u, asuint((asint(v.Load(0u)) << 2u)));
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
[numthreads(1, 1, 1)]
|
||||
void unused_entry_point() {
|
||||
return;
|
||||
}
|
||||
|
||||
RWByteAddressBuffer v : register(u0, space0);
|
||||
|
||||
void foo() {
|
||||
v.Store(0u, asuint((asint(v.Load(0u)) << 2u)));
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
#version 310 es
|
||||
|
||||
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
|
||||
void unused_entry_point() {
|
||||
return;
|
||||
}
|
||||
struct S {
|
||||
int a;
|
||||
};
|
||||
|
||||
layout(binding = 0, std430) buffer S_1 {
|
||||
int a;
|
||||
} v;
|
||||
void foo() {
|
||||
v.a = (v.a << 2u);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
struct S {
|
||||
/* 0x0000 */ int a;
|
||||
};
|
||||
|
||||
void foo(device S* const tint_symbol) {
|
||||
(*(tint_symbol)).a = as_type<int>((as_type<uint>((*(tint_symbol)).a) << 2u));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
; 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
|
||||
%uint_2 = OpConstant %uint 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 = OpShiftLeftLogical %int %16 %uint_2
|
||||
OpStore %14 %18
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
@@ -0,0 +1,9 @@
|
||||
struct S {
|
||||
a : i32,
|
||||
}
|
||||
|
||||
@group(0) @binding(0) var<storage, read_write> v : S;
|
||||
|
||||
fn foo() {
|
||||
v.a <<= 2;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
struct S {
|
||||
a : i32,
|
||||
}
|
||||
@group(0) @binding(0)
|
||||
var<storage, read_write> v : S;
|
||||
|
||||
fn foo() {
|
||||
v.a >>= 2;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
[numthreads(1, 1, 1)]
|
||||
void unused_entry_point() {
|
||||
return;
|
||||
}
|
||||
|
||||
RWByteAddressBuffer v : register(u0, space0);
|
||||
|
||||
void foo() {
|
||||
v.Store(0u, asuint((asint(v.Load(0u)) >> 2u)));
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
[numthreads(1, 1, 1)]
|
||||
void unused_entry_point() {
|
||||
return;
|
||||
}
|
||||
|
||||
RWByteAddressBuffer v : register(u0, space0);
|
||||
|
||||
void foo() {
|
||||
v.Store(0u, asuint((asint(v.Load(0u)) >> 2u)));
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
#version 310 es
|
||||
|
||||
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
|
||||
void unused_entry_point() {
|
||||
return;
|
||||
}
|
||||
struct S {
|
||||
int a;
|
||||
};
|
||||
|
||||
layout(binding = 0, std430) buffer S_1 {
|
||||
int a;
|
||||
} v;
|
||||
void foo() {
|
||||
v.a = (v.a >> 2u);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
struct S {
|
||||
/* 0x0000 */ int a;
|
||||
};
|
||||
|
||||
void foo(device S* const tint_symbol) {
|
||||
(*(tint_symbol)).a = ((*(tint_symbol)).a >> 2u);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
; 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
|
||||
%uint_2 = OpConstant %uint 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 = OpShiftRightArithmetic %int %16 %uint_2
|
||||
OpStore %14 %18
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
@@ -0,0 +1,9 @@
|
||||
struct S {
|
||||
a : i32,
|
||||
}
|
||||
|
||||
@group(0) @binding(0) var<storage, read_write> v : S;
|
||||
|
||||
fn foo() {
|
||||
v.a >>= 2;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
struct S {
|
||||
a : vec4<i32>,
|
||||
}
|
||||
@group(0) @binding(0)
|
||||
var<storage, read_write> v : S;
|
||||
|
||||
fn foo() {
|
||||
v.a <<= vec4<u32>(2);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
[numthreads(1, 1, 1)]
|
||||
void unused_entry_point() {
|
||||
return;
|
||||
}
|
||||
|
||||
RWByteAddressBuffer v : register(u0, space0);
|
||||
|
||||
void foo() {
|
||||
v.Store4(0u, asuint((asint(v.Load4(0u)) << (2u).xxxx)));
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
[numthreads(1, 1, 1)]
|
||||
void unused_entry_point() {
|
||||
return;
|
||||
}
|
||||
|
||||
RWByteAddressBuffer v : register(u0, space0);
|
||||
|
||||
void foo() {
|
||||
v.Store4(0u, asuint((asint(v.Load4(0u)) << (2u).xxxx)));
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
#version 310 es
|
||||
|
||||
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
|
||||
void unused_entry_point() {
|
||||
return;
|
||||
}
|
||||
struct S {
|
||||
ivec4 a;
|
||||
};
|
||||
|
||||
layout(binding = 0, std430) buffer S_1 {
|
||||
ivec4 a;
|
||||
} v;
|
||||
void foo() {
|
||||
v.a = (v.a << uvec4(2u));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
struct S {
|
||||
/* 0x0000 */ int4 a;
|
||||
};
|
||||
|
||||
void foo(device S* const tint_symbol) {
|
||||
(*(tint_symbol)).a = as_type<int4>((as_type<uint4>((*(tint_symbol)).a) << uint4(2u)));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 22
|
||||
; 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
|
||||
%v4uint = OpTypeVector %uint 4
|
||||
%uint_2 = OpConstant %uint 2
|
||||
%20 = OpConstantComposite %v4uint %uint_2 %uint_2 %uint_2 %uint_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
|
||||
%21 = OpShiftLeftLogical %v4int %17 %20
|
||||
OpStore %15 %21
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
@@ -0,0 +1,9 @@
|
||||
struct S {
|
||||
a : vec4<i32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(0) var<storage, read_write> v : S;
|
||||
|
||||
fn foo() {
|
||||
v.a <<= vec4<u32>(2);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
struct S {
|
||||
a : vec4<i32>,
|
||||
}
|
||||
@group(0) @binding(0)
|
||||
var<storage, read_write> v : S;
|
||||
|
||||
fn foo() {
|
||||
v.a >>= vec4<u32>(2);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
[numthreads(1, 1, 1)]
|
||||
void unused_entry_point() {
|
||||
return;
|
||||
}
|
||||
|
||||
RWByteAddressBuffer v : register(u0, space0);
|
||||
|
||||
void foo() {
|
||||
v.Store4(0u, asuint((asint(v.Load4(0u)) >> (2u).xxxx)));
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
[numthreads(1, 1, 1)]
|
||||
void unused_entry_point() {
|
||||
return;
|
||||
}
|
||||
|
||||
RWByteAddressBuffer v : register(u0, space0);
|
||||
|
||||
void foo() {
|
||||
v.Store4(0u, asuint((asint(v.Load4(0u)) >> (2u).xxxx)));
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
#version 310 es
|
||||
|
||||
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
|
||||
void unused_entry_point() {
|
||||
return;
|
||||
}
|
||||
struct S {
|
||||
ivec4 a;
|
||||
};
|
||||
|
||||
layout(binding = 0, std430) buffer S_1 {
|
||||
ivec4 a;
|
||||
} v;
|
||||
void foo() {
|
||||
v.a = (v.a >> uvec4(2u));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
struct S {
|
||||
/* 0x0000 */ int4 a;
|
||||
};
|
||||
|
||||
void foo(device S* const tint_symbol) {
|
||||
(*(tint_symbol)).a = ((*(tint_symbol)).a >> uint4(2u));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 22
|
||||
; 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
|
||||
%v4uint = OpTypeVector %uint 4
|
||||
%uint_2 = OpConstant %uint 2
|
||||
%20 = OpConstantComposite %v4uint %uint_2 %uint_2 %uint_2 %uint_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
|
||||
%21 = OpShiftRightArithmetic %v4int %17 %20
|
||||
OpStore %15 %21
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
@@ -0,0 +1,9 @@
|
||||
struct S {
|
||||
a : vec4<i32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(0) var<storage, read_write> v : S;
|
||||
|
||||
fn foo() {
|
||||
v.a >>= vec4<u32>(2);
|
||||
}
|
||||
Reference in New Issue
Block a user