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>
This commit is contained in:
David Neto
2021-06-17 09:10:04 +00:00
committed by Tint LUCI CQ
parent c932b5535f
commit 1e19b55d19
102 changed files with 6487 additions and 3194 deletions

View File

@@ -1,8 +1,7 @@
Texture2D<uint4> Src : register(t0, space0);
RWTexture2D<uint4> Dst : register(u1, space0);
[numthreads(1, 1, 1)]
void main() {
void main_1() {
uint4 srcValue = uint4(0u, 0u, 0u, 0u);
const uint4 x_18 = Src.Load(int3(0, 0, 0));
srcValue = x_18;
@@ -12,3 +11,9 @@ void main() {
Dst[int2(0, 0)] = x_27;
return;
}
[numthreads(1, 1, 1)]
void main() {
main_1();
return;
}

View File

@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 32
; Bound: 35
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@@ -9,8 +9,9 @@
OpExecutionMode %main LocalSize 1 1 1
OpName %Src "Src"
OpName %Dst "Dst"
OpName %main "main"
OpName %main_1 "main_1"
OpName %srcValue "srcValue"
OpName %main "main"
OpDecorate %Src NonWritable
OpDecorate %Src DescriptorSet 0
OpDecorate %Src Binding 0
@@ -35,7 +36,7 @@
%uint_0 = OpConstant %uint 0
%_ptr_Function_uint = OpTypePointer Function %uint
%int_1 = OpConstant %int 1
%main = OpFunction %void None %7
%main_1 = OpFunction %void None %7
%10 = OpLabel
%srcValue = OpVariable %_ptr_Function_v4uint Function %14
%16 = OpLoad %3 %Src
@@ -52,3 +53,8 @@
OpImageWrite %31 %20 %29
OpReturn
OpFunctionEnd
%main = OpFunction %void None %7
%33 = OpLabel
%34 = OpFunctionCall %void %main_1
OpReturn
OpFunctionEnd

View File

@@ -2,8 +2,7 @@
[[group(0), binding(1)]] var Dst : texture_storage_2d<r32uint, write>;
[[stage(compute)]]
fn main() {
fn main_1() {
var srcValue : vec4<u32>;
let x_18 : vec4<u32> = textureLoad(Src, vec2<i32>(0, 0));
srcValue = x_18;
@@ -14,3 +13,8 @@ fn main() {
textureStore(Dst, vec2<i32>(0, 0), x_27);
return;
}
[[stage(compute)]]
fn main() {
main_1();
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -9,11 +9,11 @@ struct buf0 {
var<private> obj : QuicksortObject;
[[builtin(position)]] var<in> gl_FragCoord : vec4<f32>;
var<private> gl_FragCoord : vec4<f32>;
[[group(0), binding(0)]] var<uniform> x_188 : buf0;
[[location(0)]] var<out> x_GLF_color : vec4<f32>;
var<private> x_GLF_color : vec4<f32>;
fn swap_i1_i1_(i : ptr<function, i32>, j : ptr<function, i32>) {
var temp : i32;
@@ -770,8 +770,7 @@ fn quicksort_() {
return;
}
[[stage(fragment)]]
fn main() {
fn main_1() {
var color : vec3<f32>;
var i_2 : i32;
var uv : vec2<f32>;
@@ -1492,3 +1491,15 @@ fn main() {
*(x_208) = x_931;
return;
}
struct main_out {
[[location(0)]]
x_GLF_color : vec4<f32>;
};
[[stage(fragment)]]
fn main([[builtin(position)]] gl_FragCoord_param : vec4<f32>) -> main_out {
gl_FragCoord = gl_FragCoord_param;
main_1();
return main_out(x_GLF_color);
}

View File

@@ -1,19 +1,34 @@
SKIP: FAILED
#include <metal_stdlib>
bug/tint/757.wgsl:3:5 warning: use of deprecated language feature: [[offset]] has been replaced with [[size]] and [[align]]
[[offset(0)]] level : i32;
^^^^^^
using namespace metal;
struct Constants {
/* 0x0000 */ int level;
};
struct Result {
/* 0x0000 */ float values[1];
};
bug/tint/757.wgsl:10:5 warning: use of deprecated language feature: [[offset]] has been replaced with [[size]] and [[align]]
[[offset(0)]] values : [[stride(4)]] array<f32>;
^^^^^^
kernel void tint_symbol(texture2d_array<float, access::sample> tint_symbol_2 [[texture(1)]], uint3 GlobalInvocationID [[thread_position_in_grid]], device Result& result [[buffer(3)]]) {
uint flatIndex = ((((2u * 2u) * GlobalInvocationID.z) + (2u * GlobalInvocationID.y)) + GlobalInvocationID.x);
flatIndex = (flatIndex * 1u);
float4 texel = tint_symbol_2.read(uint2(int2(GlobalInvocationID.xy)), 0, 0);
{
uint i = 0u;
{
bool tint_msl_is_first_1 = true;
for(;;) {
if (!tint_msl_is_first_1) {
i = (i + 1u);
}
tint_msl_is_first_1 = false;
if (!((i < 1u))) {
break;
}
result.values[(flatIndex + i)] = texel.r;
}
}
}
return;
}
Validation Failure:
Compilation failed:
program_source:14:18: error: use of undeclared identifier 'myTexture'
float4 texel = myTexture.read(int2(GlobalInvocationID.xy), 0, 0);
^

View File

@@ -1,15 +1,13 @@
SKIP: FAILED
#include <metal_stdlib>
bug/tint/827.wgsl:8:26 warning: use of deprecated language feature: declare access with var<storage, read_write> instead of using [[access]] decoration
[[group(0), binding(1)]] var<storage> result : [[access(read_write)]] Result;
^^^
using namespace metal;
struct Result {
/* 0x0000 */ float values[1];
};
constant uint width = 128u;
kernel void tint_symbol(depth2d<float, access::sample> tint_symbol_2 [[texture(0)]], uint3 GlobalInvocationId [[thread_position_in_grid]], device Result& result [[buffer(1)]]) {
result.values[((GlobalInvocationId.y * width) + GlobalInvocationId.x)] = tint_symbol_2.read(uint2(int2(int(GlobalInvocationId.x), int(GlobalInvocationId.y))), 0);
return;
}
Validation Failure:
Compilation failed:
program_source:10:76: error: use of undeclared identifier 'tex'
result.values[((GlobalInvocationId.y * width) + GlobalInvocationId.x)] = tex.read(int2(int(GlobalInvocationId.x), int(GlobalInvocationId.y)), 0);
^

View File

@@ -9,7 +9,7 @@ tint_array_wrapper tint_symbol_1(ByteAddressBuffer buffer, uint offset) {
ByteAddressBuffer sspp962805860buildInformation : register(t2, space0);
void main() {
void main_1() {
tint_array_wrapper orientation = {{0, 0, 0, 0, 0, 0}};
const tint_array_wrapper x_23 = tint_symbol_1(sspp962805860buildInformation, 36u);
orientation.arr[0] = x_23.arr[0u];
@@ -20,3 +20,8 @@ void main() {
orientation.arr[5] = x_23.arr[5u];
return;
}
void main() {
main_1();
return;
}

View File

@@ -14,7 +14,7 @@ struct x_B4_BuildInformation {
/* 0x0000 */ sspp962805860buildInformationS passthru;
};
fragment void tint_symbol(const device x_B4_BuildInformation& sspp962805860buildInformation [[buffer(2)]]) {
void main_1(const device x_B4_BuildInformation& sspp962805860buildInformation) {
tint_array_wrapper orientation = {};
tint_array_wrapper const x_23 = sspp962805860buildInformation.passthru.orientation;
orientation.arr[0] = x_23.arr[0u];
@@ -26,3 +26,8 @@ fragment void tint_symbol(const device x_B4_BuildInformation& sspp962805860build
return;
}
fragment void tint_symbol(const device x_B4_BuildInformation& sspp962805860buildInformation [[buffer(2)]]) {
main_1(sspp962805860buildInformation);
return;
}

View File

@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 46
; Bound: 49
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@@ -15,8 +15,9 @@
OpMemberName %sspp962805860buildInformationS 2 "essence"
OpMemberName %sspp962805860buildInformationS 3 "orientation"
OpName %sspp962805860buildInformation "sspp962805860buildInformation"
OpName %main "main"
OpName %main_1 "main_1"
OpName %orientation "orientation"
OpName %main "main"
OpDecorate %x_B4_BuildInformation Block
OpMemberDecorate %x_B4_BuildInformation 0 Offset 0
OpMemberDecorate %sspp962805860buildInformationS 0 Offset 0
@@ -55,7 +56,7 @@
%uint_4 = OpConstant %uint 4
%int_5 = OpConstant %int 5
%uint_5 = OpConstant %uint 5
%main = OpFunction %void None %11
%main_1 = OpFunction %void None %11
%14 = OpLabel
%orientation = OpVariable %_ptr_Function__arr_int_uint_6 Function %17
%21 = OpAccessChain %_ptr_StorageBuffer__arr_int_uint_6 %sspp962805860buildInformation %uint_0 %uint_3
@@ -80,3 +81,8 @@
OpStore %43 %45
OpReturn
OpFunctionEnd
%main = OpFunction %void None %11
%47 = OpLabel
%48 = OpFunctionCall %void %main_1
OpReturn
OpFunctionEnd

View File

@@ -14,8 +14,7 @@ struct x_B4_BuildInformation {
[[group(0), binding(2)]] var<storage, read> sspp962805860buildInformation : x_B4_BuildInformation;
[[stage(fragment)]]
fn main() {
fn main_1() {
var orientation : array<i32, 6>;
let x_23 : Arr = sspp962805860buildInformation.passthru.orientation;
orientation[0] = x_23[0u];
@@ -26,3 +25,8 @@ fn main() {
orientation[5] = x_23[5u];
return;
}
[[stage(fragment)]]
fn main() {
main_1();
}