mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-09 13:38:00 +00:00
writer[spirv,hlsl]: Call UnwrapRef() for splats
The TypeConstructorExpression logic that tested for splats was not considering references. This led to broken emission for the SPIR-V and HLSL backends. Fixed: tint:992 Change-Id: I9824b71f526997f91d380c09b459f4fd73065b19 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/58397 Auto-Submit: Ben Clayton <bclayton@google.com> Commit-Queue: David Neto <dneto@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
committed by
Tint LUCI CQ
parent
76feb6b626
commit
595b0547d4
6
test/expressions/splat/var/bool.wgsl
Normal file
6
test/expressions/splat/var/bool.wgsl
Normal file
@@ -0,0 +1,6 @@
|
||||
fn f() {
|
||||
var v = true || false;
|
||||
var v2 : vec2<bool> = vec2<bool>(v);
|
||||
var v3 : vec3<bool> = vec3<bool>(v);
|
||||
var v4 : vec4<bool> = vec4<bool>(v);
|
||||
}
|
||||
15
test/expressions/splat/var/bool.wgsl.expected.hlsl
Normal file
15
test/expressions/splat/var/bool.wgsl.expected.hlsl
Normal file
@@ -0,0 +1,15 @@
|
||||
[numthreads(1, 1, 1)]
|
||||
void unused_entry_point() {
|
||||
return;
|
||||
}
|
||||
|
||||
void f() {
|
||||
bool tint_tmp = true;
|
||||
if (!tint_tmp) {
|
||||
tint_tmp = false;
|
||||
}
|
||||
bool v = (tint_tmp);
|
||||
bool2 v2 = bool2((v).xx);
|
||||
bool3 v3 = bool3((v).xxx);
|
||||
bool4 v4 = bool4((v).xxxx);
|
||||
}
|
||||
10
test/expressions/splat/var/bool.wgsl.expected.msl
Normal file
10
test/expressions/splat/var/bool.wgsl.expected.msl
Normal file
@@ -0,0 +1,10 @@
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
void f() {
|
||||
bool v = (true || false);
|
||||
bool2 v2 = bool2(v);
|
||||
bool3 v3 = bool3(v);
|
||||
bool4 v4 = bool4(v);
|
||||
}
|
||||
|
||||
59
test/expressions/splat/var/bool.wgsl.expected.spvasm
Normal file
59
test/expressions/splat/var/bool.wgsl.expected.spvasm
Normal file
@@ -0,0 +1,59 @@
|
||||
; 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 %unused_entry_point "unused_entry_point"
|
||||
OpName %f "f"
|
||||
OpName %v "v"
|
||||
OpName %v2 "v2"
|
||||
OpName %v3 "v3"
|
||||
OpName %v4 "v4"
|
||||
%void = OpTypeVoid
|
||||
%1 = OpTypeFunction %void
|
||||
%bool = OpTypeBool
|
||||
%true = OpConstantTrue %bool
|
||||
%false = OpConstantFalse %bool
|
||||
%_ptr_Function_bool = OpTypePointer Function %bool
|
||||
%15 = OpConstantNull %bool
|
||||
%v2bool = OpTypeVector %bool 2
|
||||
%_ptr_Function_v2bool = OpTypePointer Function %v2bool
|
||||
%21 = OpConstantNull %v2bool
|
||||
%v3bool = OpTypeVector %bool 3
|
||||
%_ptr_Function_v3bool = OpTypePointer Function %v3bool
|
||||
%27 = OpConstantNull %v3bool
|
||||
%v4bool = OpTypeVector %bool 4
|
||||
%_ptr_Function_v4bool = OpTypePointer Function %v4bool
|
||||
%33 = OpConstantNull %v4bool
|
||||
%unused_entry_point = OpFunction %void None %1
|
||||
%4 = OpLabel
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%f = OpFunction %void None %1
|
||||
%6 = OpLabel
|
||||
%v = OpVariable %_ptr_Function_bool Function %15
|
||||
%v2 = OpVariable %_ptr_Function_v2bool Function %21
|
||||
%v3 = OpVariable %_ptr_Function_v3bool Function %27
|
||||
%v4 = OpVariable %_ptr_Function_v4bool Function %33
|
||||
OpSelectionMerge %9 None
|
||||
OpBranchConditional %true %9 %10
|
||||
%10 = OpLabel
|
||||
OpBranch %9
|
||||
%9 = OpLabel
|
||||
%12 = OpPhi %bool %true %6 %false %10
|
||||
OpStore %v %12
|
||||
%17 = OpLoad %bool %v
|
||||
%18 = OpCompositeConstruct %v2bool %17 %17
|
||||
OpStore %v2 %18
|
||||
%23 = OpLoad %bool %v
|
||||
%24 = OpCompositeConstruct %v3bool %23 %23 %23
|
||||
OpStore %v3 %24
|
||||
%29 = OpLoad %bool %v
|
||||
%30 = OpCompositeConstruct %v4bool %29 %29 %29 %29
|
||||
OpStore %v4 %30
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
6
test/expressions/splat/var/bool.wgsl.expected.wgsl
Normal file
6
test/expressions/splat/var/bool.wgsl.expected.wgsl
Normal file
@@ -0,0 +1,6 @@
|
||||
fn f() {
|
||||
var v = (true || false);
|
||||
var v2 : vec2<bool> = vec2<bool>(v);
|
||||
var v3 : vec3<bool> = vec3<bool>(v);
|
||||
var v4 : vec4<bool> = vec4<bool>(v);
|
||||
}
|
||||
6
test/expressions/splat/var/f32.wgsl
Normal file
6
test/expressions/splat/var/f32.wgsl
Normal file
@@ -0,0 +1,6 @@
|
||||
fn f() {
|
||||
var v = 1.0 + 2.0;
|
||||
var v2 : vec2<f32> = vec2<f32>(v);
|
||||
var v3 : vec3<f32> = vec3<f32>(v);
|
||||
var v4 : vec4<f32> = vec4<f32>(v);
|
||||
}
|
||||
11
test/expressions/splat/var/f32.wgsl.expected.hlsl
Normal file
11
test/expressions/splat/var/f32.wgsl.expected.hlsl
Normal file
@@ -0,0 +1,11 @@
|
||||
[numthreads(1, 1, 1)]
|
||||
void unused_entry_point() {
|
||||
return;
|
||||
}
|
||||
|
||||
void f() {
|
||||
float v = (1.0f + 2.0f);
|
||||
float2 v2 = float2((v).xx);
|
||||
float3 v3 = float3((v).xxx);
|
||||
float4 v4 = float4((v).xxxx);
|
||||
}
|
||||
10
test/expressions/splat/var/f32.wgsl.expected.msl
Normal file
10
test/expressions/splat/var/f32.wgsl.expected.msl
Normal file
@@ -0,0 +1,10 @@
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
void f() {
|
||||
float v = (1.0f + 2.0f);
|
||||
float2 v2 = float2(v);
|
||||
float3 v3 = float3(v);
|
||||
float4 v4 = float4(v);
|
||||
}
|
||||
|
||||
54
test/expressions/splat/var/f32.wgsl.expected.spvasm
Normal file
54
test/expressions/splat/var/f32.wgsl.expected.spvasm
Normal file
@@ -0,0 +1,54 @@
|
||||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 32
|
||||
; 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 %f "f"
|
||||
OpName %v "v"
|
||||
OpName %v2 "v2"
|
||||
OpName %v3 "v3"
|
||||
OpName %v4 "v4"
|
||||
%void = OpTypeVoid
|
||||
%1 = OpTypeFunction %void
|
||||
%float = OpTypeFloat 32
|
||||
%float_1 = OpConstant %float 1
|
||||
%float_2 = OpConstant %float 2
|
||||
%_ptr_Function_float = OpTypePointer Function %float
|
||||
%13 = OpConstantNull %float
|
||||
%v2float = OpTypeVector %float 2
|
||||
%_ptr_Function_v2float = OpTypePointer Function %v2float
|
||||
%19 = OpConstantNull %v2float
|
||||
%v3float = OpTypeVector %float 3
|
||||
%_ptr_Function_v3float = OpTypePointer Function %v3float
|
||||
%25 = OpConstantNull %v3float
|
||||
%v4float = OpTypeVector %float 4
|
||||
%_ptr_Function_v4float = OpTypePointer Function %v4float
|
||||
%31 = OpConstantNull %v4float
|
||||
%unused_entry_point = OpFunction %void None %1
|
||||
%4 = OpLabel
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%f = OpFunction %void None %1
|
||||
%6 = OpLabel
|
||||
%v = OpVariable %_ptr_Function_float Function %13
|
||||
%v2 = OpVariable %_ptr_Function_v2float Function %19
|
||||
%v3 = OpVariable %_ptr_Function_v3float Function %25
|
||||
%v4 = OpVariable %_ptr_Function_v4float Function %31
|
||||
%10 = OpFAdd %float %float_1 %float_2
|
||||
OpStore %v %10
|
||||
%15 = OpLoad %float %v
|
||||
%16 = OpCompositeConstruct %v2float %15 %15
|
||||
OpStore %v2 %16
|
||||
%21 = OpLoad %float %v
|
||||
%22 = OpCompositeConstruct %v3float %21 %21 %21
|
||||
OpStore %v3 %22
|
||||
%27 = OpLoad %float %v
|
||||
%28 = OpCompositeConstruct %v4float %27 %27 %27 %27
|
||||
OpStore %v4 %28
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
6
test/expressions/splat/var/f32.wgsl.expected.wgsl
Normal file
6
test/expressions/splat/var/f32.wgsl.expected.wgsl
Normal file
@@ -0,0 +1,6 @@
|
||||
fn f() {
|
||||
var v = (1.0 + 2.0);
|
||||
var v2 : vec2<f32> = vec2<f32>(v);
|
||||
var v3 : vec3<f32> = vec3<f32>(v);
|
||||
var v4 : vec4<f32> = vec4<f32>(v);
|
||||
}
|
||||
6
test/expressions/splat/var/i32.wgsl
Normal file
6
test/expressions/splat/var/i32.wgsl
Normal file
@@ -0,0 +1,6 @@
|
||||
fn f() {
|
||||
var v = 1 + 2;
|
||||
var v2 : vec2<i32> = vec2<i32>(v);
|
||||
var v3 : vec3<i32> = vec3<i32>(v);
|
||||
var v4 : vec4<i32> = vec4<i32>(v);
|
||||
}
|
||||
11
test/expressions/splat/var/i32.wgsl.expected.hlsl
Normal file
11
test/expressions/splat/var/i32.wgsl.expected.hlsl
Normal file
@@ -0,0 +1,11 @@
|
||||
[numthreads(1, 1, 1)]
|
||||
void unused_entry_point() {
|
||||
return;
|
||||
}
|
||||
|
||||
void f() {
|
||||
int v = (1 + 2);
|
||||
int2 v2 = int2((v).xx);
|
||||
int3 v3 = int3((v).xxx);
|
||||
int4 v4 = int4((v).xxxx);
|
||||
}
|
||||
10
test/expressions/splat/var/i32.wgsl.expected.msl
Normal file
10
test/expressions/splat/var/i32.wgsl.expected.msl
Normal file
@@ -0,0 +1,10 @@
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
void f() {
|
||||
int v = (1 + 2);
|
||||
int2 v2 = int2(v);
|
||||
int3 v3 = int3(v);
|
||||
int4 v4 = int4(v);
|
||||
}
|
||||
|
||||
54
test/expressions/splat/var/i32.wgsl.expected.spvasm
Normal file
54
test/expressions/splat/var/i32.wgsl.expected.spvasm
Normal file
@@ -0,0 +1,54 @@
|
||||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 32
|
||||
; 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 %f "f"
|
||||
OpName %v "v"
|
||||
OpName %v2 "v2"
|
||||
OpName %v3 "v3"
|
||||
OpName %v4 "v4"
|
||||
%void = OpTypeVoid
|
||||
%1 = OpTypeFunction %void
|
||||
%int = OpTypeInt 32 1
|
||||
%int_1 = OpConstant %int 1
|
||||
%int_2 = OpConstant %int 2
|
||||
%_ptr_Function_int = OpTypePointer Function %int
|
||||
%13 = OpConstantNull %int
|
||||
%v2int = OpTypeVector %int 2
|
||||
%_ptr_Function_v2int = OpTypePointer Function %v2int
|
||||
%19 = OpConstantNull %v2int
|
||||
%v3int = OpTypeVector %int 3
|
||||
%_ptr_Function_v3int = OpTypePointer Function %v3int
|
||||
%25 = OpConstantNull %v3int
|
||||
%v4int = OpTypeVector %int 4
|
||||
%_ptr_Function_v4int = OpTypePointer Function %v4int
|
||||
%31 = OpConstantNull %v4int
|
||||
%unused_entry_point = OpFunction %void None %1
|
||||
%4 = OpLabel
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%f = OpFunction %void None %1
|
||||
%6 = OpLabel
|
||||
%v = OpVariable %_ptr_Function_int Function %13
|
||||
%v2 = OpVariable %_ptr_Function_v2int Function %19
|
||||
%v3 = OpVariable %_ptr_Function_v3int Function %25
|
||||
%v4 = OpVariable %_ptr_Function_v4int Function %31
|
||||
%10 = OpIAdd %int %int_1 %int_2
|
||||
OpStore %v %10
|
||||
%15 = OpLoad %int %v
|
||||
%16 = OpCompositeConstruct %v2int %15 %15
|
||||
OpStore %v2 %16
|
||||
%21 = OpLoad %int %v
|
||||
%22 = OpCompositeConstruct %v3int %21 %21 %21
|
||||
OpStore %v3 %22
|
||||
%27 = OpLoad %int %v
|
||||
%28 = OpCompositeConstruct %v4int %27 %27 %27 %27
|
||||
OpStore %v4 %28
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
6
test/expressions/splat/var/i32.wgsl.expected.wgsl
Normal file
6
test/expressions/splat/var/i32.wgsl.expected.wgsl
Normal file
@@ -0,0 +1,6 @@
|
||||
fn f() {
|
||||
var v = (1 + 2);
|
||||
var v2 : vec2<i32> = vec2<i32>(v);
|
||||
var v3 : vec3<i32> = vec3<i32>(v);
|
||||
var v4 : vec4<i32> = vec4<i32>(v);
|
||||
}
|
||||
6
test/expressions/splat/var/u32.wgsl
Normal file
6
test/expressions/splat/var/u32.wgsl
Normal file
@@ -0,0 +1,6 @@
|
||||
fn f() {
|
||||
var v = 1u + 2u;
|
||||
var v2 : vec2<u32> = vec2<u32>(v);
|
||||
var v3 : vec3<u32> = vec3<u32>(v);
|
||||
var v4 : vec4<u32> = vec4<u32>(v);
|
||||
}
|
||||
11
test/expressions/splat/var/u32.wgsl.expected.hlsl
Normal file
11
test/expressions/splat/var/u32.wgsl.expected.hlsl
Normal file
@@ -0,0 +1,11 @@
|
||||
[numthreads(1, 1, 1)]
|
||||
void unused_entry_point() {
|
||||
return;
|
||||
}
|
||||
|
||||
void f() {
|
||||
uint v = (1u + 2u);
|
||||
uint2 v2 = uint2((v).xx);
|
||||
uint3 v3 = uint3((v).xxx);
|
||||
uint4 v4 = uint4((v).xxxx);
|
||||
}
|
||||
10
test/expressions/splat/var/u32.wgsl.expected.msl
Normal file
10
test/expressions/splat/var/u32.wgsl.expected.msl
Normal file
@@ -0,0 +1,10 @@
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
void f() {
|
||||
uint v = (1u + 2u);
|
||||
uint2 v2 = uint2(v);
|
||||
uint3 v3 = uint3(v);
|
||||
uint4 v4 = uint4(v);
|
||||
}
|
||||
|
||||
54
test/expressions/splat/var/u32.wgsl.expected.spvasm
Normal file
54
test/expressions/splat/var/u32.wgsl.expected.spvasm
Normal file
@@ -0,0 +1,54 @@
|
||||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 32
|
||||
; 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 %f "f"
|
||||
OpName %v "v"
|
||||
OpName %v2 "v2"
|
||||
OpName %v3 "v3"
|
||||
OpName %v4 "v4"
|
||||
%void = OpTypeVoid
|
||||
%1 = OpTypeFunction %void
|
||||
%uint = OpTypeInt 32 0
|
||||
%uint_1 = OpConstant %uint 1
|
||||
%uint_2 = OpConstant %uint 2
|
||||
%_ptr_Function_uint = OpTypePointer Function %uint
|
||||
%13 = OpConstantNull %uint
|
||||
%v2uint = OpTypeVector %uint 2
|
||||
%_ptr_Function_v2uint = OpTypePointer Function %v2uint
|
||||
%19 = OpConstantNull %v2uint
|
||||
%v3uint = OpTypeVector %uint 3
|
||||
%_ptr_Function_v3uint = OpTypePointer Function %v3uint
|
||||
%25 = OpConstantNull %v3uint
|
||||
%v4uint = OpTypeVector %uint 4
|
||||
%_ptr_Function_v4uint = OpTypePointer Function %v4uint
|
||||
%31 = OpConstantNull %v4uint
|
||||
%unused_entry_point = OpFunction %void None %1
|
||||
%4 = OpLabel
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%f = OpFunction %void None %1
|
||||
%6 = OpLabel
|
||||
%v = OpVariable %_ptr_Function_uint Function %13
|
||||
%v2 = OpVariable %_ptr_Function_v2uint Function %19
|
||||
%v3 = OpVariable %_ptr_Function_v3uint Function %25
|
||||
%v4 = OpVariable %_ptr_Function_v4uint Function %31
|
||||
%10 = OpIAdd %uint %uint_1 %uint_2
|
||||
OpStore %v %10
|
||||
%15 = OpLoad %uint %v
|
||||
%16 = OpCompositeConstruct %v2uint %15 %15
|
||||
OpStore %v2 %16
|
||||
%21 = OpLoad %uint %v
|
||||
%22 = OpCompositeConstruct %v3uint %21 %21 %21
|
||||
OpStore %v3 %22
|
||||
%27 = OpLoad %uint %v
|
||||
%28 = OpCompositeConstruct %v4uint %27 %27 %27 %27
|
||||
OpStore %v4 %28
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
6
test/expressions/splat/var/u32.wgsl.expected.wgsl
Normal file
6
test/expressions/splat/var/u32.wgsl.expected.wgsl
Normal file
@@ -0,0 +1,6 @@
|
||||
fn f() {
|
||||
var v = (1u + 2u);
|
||||
var v2 : vec2<u32> = vec2<u32>(v);
|
||||
var v3 : vec3<u32> = vec3<u32>(v);
|
||||
var v4 : vec4<u32> = vec4<u32>(v);
|
||||
}
|
||||
Reference in New Issue
Block a user