spirv-reader: switch to HLSL-style pipeline IO
- When storing to sample_mask output, write to the 0th element
- Only make a return struct if it has members
- Adjust type signedness coercion when loading special builtins.
- Adapt tests
- Update expectations for end-to-end tests
- Handle sample_mask with stride
Input variables normally don't have layout. But they can have it
up through SPIR-V 1.4.
Handle this case in the SPIR-V reader, by seeing through the
intermediate alias type created for the strided array type.
Bug: tint:508
Change-Id: I0f19dc1305d3f250dbbc0698a602288c34245274
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/54743
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
diff --git a/test/access/let/matrix.spvasm.expected.hlsl b/test/access/let/matrix.spvasm.expected.hlsl
index 669ba11..7f13ac2a 100644
--- a/test/access/let/matrix.spvasm.expected.hlsl
+++ b/test/access/let/matrix.spvasm.expected.hlsl
@@ -1,5 +1,10 @@
+void main_1() {
+ const float x_24 = float3x3(float3(1.0f, 2.0f, 3.0f), float3(4.0f, 5.0f, 6.0f), float3(7.0f, 8.0f, 9.0f))[1u].y;
+ return;
+}
+
[numthreads(1, 1, 1)]
void main() {
- const float x_24 = float3x3(float3(1.0f, 2.0f, 3.0f), float3(4.0f, 5.0f, 6.0f), float3(7.0f, 8.0f, 9.0f))[1u].y;
+ main_1();
return;
}
diff --git a/test/access/let/matrix.spvasm.expected.msl b/test/access/let/matrix.spvasm.expected.msl
index 2f5de98..2123a38 100644
--- a/test/access/let/matrix.spvasm.expected.msl
+++ b/test/access/let/matrix.spvasm.expected.msl
@@ -1,8 +1,13 @@
#include <metal_stdlib>
using namespace metal;
-kernel void tint_symbol() {
+void main_1() {
float const x_24 = float3x3(float3(1.0f, 2.0f, 3.0f), float3(4.0f, 5.0f, 6.0f), float3(7.0f, 8.0f, 9.0f))[1u].y;
return;
}
+kernel void tint_symbol() {
+ main_1();
+ return;
+}
+
diff --git a/test/access/let/matrix.spvasm.expected.spvasm b/test/access/let/matrix.spvasm.expected.spvasm
index fac85ae..7556cb3 100644
--- a/test/access/let/matrix.spvasm.expected.spvasm
+++ b/test/access/let/matrix.spvasm.expected.spvasm
@@ -1,12 +1,13 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 25
+; Bound: 28
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %main "main"
OpExecutionMode %main LocalSize 1 1 1
+ OpName %main_1 "main_1"
OpName %main "main"
%void = OpTypeVoid
%1 = OpTypeFunction %void
@@ -28,9 +29,14 @@
%20 = OpConstantComposite %mat3v3float %11 %15 %19
%uint = OpTypeInt 32 0
%uint_1 = OpConstant %uint 1
- %main = OpFunction %void None %1
+ %main_1 = OpFunction %void None %1
%4 = OpLabel
%23 = OpCompositeExtract %v3float %20 1
%24 = OpCompositeExtract %float %23 1
OpReturn
OpFunctionEnd
+ %main = OpFunction %void None %1
+ %26 = OpLabel
+ %27 = OpFunctionCall %void %main_1
+ OpReturn
+ OpFunctionEnd
diff --git a/test/access/let/matrix.spvasm.expected.wgsl b/test/access/let/matrix.spvasm.expected.wgsl
index 1dc7497..156324f 100644
--- a/test/access/let/matrix.spvasm.expected.wgsl
+++ b/test/access/let/matrix.spvasm.expected.wgsl
@@ -1,5 +1,9 @@
-[[stage(compute)]]
-fn main() {
+fn main_1() {
let x_24 : f32 = mat3x3<f32>(vec3<f32>(1.0, 2.0, 3.0), vec3<f32>(4.0, 5.0, 6.0), vec3<f32>(7.0, 8.0, 9.0))[1u].y;
return;
}
+
+[[stage(compute)]]
+fn main() {
+ main_1();
+}
diff --git a/test/access/let/vector.spvasm.expected.hlsl b/test/access/let/vector.spvasm.expected.hlsl
index d6ea890..cc37e54 100644
--- a/test/access/let/vector.spvasm.expected.hlsl
+++ b/test/access/let/vector.spvasm.expected.hlsl
@@ -1,7 +1,12 @@
-[numthreads(1, 1, 1)]
-void main() {
+void main_1() {
const float x_11 = float3(1.0f, 2.0f, 3.0f).y;
const float2 x_13 = float2(float3(1.0f, 2.0f, 3.0f).x, float3(1.0f, 2.0f, 3.0f).z);
const float3 x_14 = float3(float3(1.0f, 2.0f, 3.0f).x, float3(1.0f, 2.0f, 3.0f).z, float3(1.0f, 2.0f, 3.0f).y);
return;
}
+
+[numthreads(1, 1, 1)]
+void main() {
+ main_1();
+ return;
+}
diff --git a/test/access/let/vector.spvasm.expected.msl b/test/access/let/vector.spvasm.expected.msl
index 60e701c..d644226 100644
--- a/test/access/let/vector.spvasm.expected.msl
+++ b/test/access/let/vector.spvasm.expected.msl
@@ -1,10 +1,15 @@
#include <metal_stdlib>
using namespace metal;
-kernel void tint_symbol() {
+void main_1() {
float const x_11 = float3(1.0f, 2.0f, 3.0f).y;
float2 const x_13 = float2(float3(1.0f, 2.0f, 3.0f).x, float3(1.0f, 2.0f, 3.0f).z);
float3 const x_14 = float3(float3(1.0f, 2.0f, 3.0f).x, float3(1.0f, 2.0f, 3.0f).z, float3(1.0f, 2.0f, 3.0f).y);
return;
}
+kernel void tint_symbol() {
+ main_1();
+ return;
+}
+
diff --git a/test/access/let/vector.spvasm.expected.spvasm b/test/access/let/vector.spvasm.expected.spvasm
index 67e9f43..5b2e162 100644
--- a/test/access/let/vector.spvasm.expected.spvasm
+++ b/test/access/let/vector.spvasm.expected.spvasm
@@ -1,12 +1,13 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 20
+; Bound: 23
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %main "main"
OpExecutionMode %main LocalSize 1 1 1
+ OpName %main_1 "main_1"
OpName %main "main"
%void = OpTypeVoid
%1 = OpTypeFunction %void
@@ -17,7 +18,7 @@
%float_3 = OpConstant %float 3
%10 = OpConstantComposite %v3float %float_1 %float_2 %float_3
%v2float = OpTypeVector %float 2
- %main = OpFunction %void None %1
+ %main_1 = OpFunction %void None %1
%4 = OpLabel
%11 = OpCompositeExtract %float %10 1
%13 = OpCompositeExtract %float %10 0
@@ -29,3 +30,8 @@
%19 = OpCompositeConstruct %v3float %16 %17 %18
OpReturn
OpFunctionEnd
+ %main = OpFunction %void None %1
+ %21 = OpLabel
+ %22 = OpFunctionCall %void %main_1
+ OpReturn
+ OpFunctionEnd
diff --git a/test/access/let/vector.spvasm.expected.wgsl b/test/access/let/vector.spvasm.expected.wgsl
index c739e6c..3c3957f 100644
--- a/test/access/let/vector.spvasm.expected.wgsl
+++ b/test/access/let/vector.spvasm.expected.wgsl
@@ -1,7 +1,11 @@
-[[stage(compute)]]
-fn main() {
+fn main_1() {
let x_11 : f32 = vec3<f32>(1.0, 2.0, 3.0).y;
let x_13 : vec2<f32> = vec2<f32>(vec3<f32>(1.0, 2.0, 3.0).x, vec3<f32>(1.0, 2.0, 3.0).z);
let x_14 : vec3<f32> = vec3<f32>(vec3<f32>(1.0, 2.0, 3.0).x, vec3<f32>(1.0, 2.0, 3.0).z, vec3<f32>(1.0, 2.0, 3.0).y);
return;
}
+
+[[stage(compute)]]
+fn main() {
+ main_1();
+}