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,13 +1,23 @@
#include <metal_stdlib>
using namespace metal;
struct tint_symbol_out {
struct main_out {
float4 gl_Position;
};
struct tint_symbol_1 {
float4 gl_Position [[position]];
};
vertex tint_symbol_out tint_symbol() {
tint_symbol_out _tint_out = {};
_tint_out.gl_Position = float4(0.0f, 0.0f, 0.0f, 0.0f);
return _tint_out;
void main_1(thread float4* const tint_symbol_4) {
*(tint_symbol_4) = float4(0.0f, 0.0f, 0.0f, 0.0f);
return;
}
vertex tint_symbol_1 tint_symbol() {
thread float4 tint_symbol_5 = 0.0f;
main_1(&(tint_symbol_5));
main_out const tint_symbol_2 = {.gl_Position=tint_symbol_5};
tint_symbol_1 const tint_symbol_3 = {.gl_Position=tint_symbol_2.gl_Position};
return tint_symbol_3;
}

View File

@@ -1,32 +1,58 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 16
; Bound: 30
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %main "main" %tint_pointsize %gl_Position
OpEntryPoint Vertex %main "main" %tint_pointsize %tint_symbol_1
OpName %tint_pointsize "tint_pointsize"
OpName %gl_Position "gl_Position"
OpName %tint_symbol_1 "tint_symbol_1"
OpName %main_1 "main_1"
OpName %main_out "main_out"
OpMemberName %main_out 0 "gl_Position"
OpName %tint_symbol_2 "tint_symbol_2"
OpName %tint_symbol "tint_symbol"
OpName %main "main"
OpDecorate %tint_pointsize BuiltIn PointSize
OpDecorate %gl_Position BuiltIn Position
OpDecorate %tint_symbol_1 BuiltIn Position
OpMemberDecorate %main_out 0 Offset 0
%float = OpTypeFloat 32
%_ptr_Output_float = OpTypePointer Output %float
%4 = OpConstantNull %float
%tint_pointsize = OpVariable %_ptr_Output_float Output %4
%v4float = OpTypeVector %float 4
%_ptr_Output_v4float = OpTypePointer Output %v4float
%_ptr_Private_v4float = OpTypePointer Private %v4float
%8 = OpConstantNull %v4float
%gl_Position = OpVariable %_ptr_Output_v4float Output %8
%gl_Position = OpVariable %_ptr_Private_v4float Private %8
%_ptr_Output_v4float = OpTypePointer Output %v4float
%tint_symbol_1 = OpVariable %_ptr_Output_v4float Output %8
%void = OpTypeVoid
%9 = OpTypeFunction %void
%float_1 = OpConstant %float 1
%11 = OpTypeFunction %void
%float_0 = OpConstant %float 0
%15 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_0
%main = OpFunction %void None %9
%12 = OpLabel
OpStore %tint_pointsize %float_1
OpStore %gl_Position %15
%16 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_0
%main_out = OpTypeStruct %v4float
%17 = OpTypeFunction %void %main_out
%float_1 = OpConstant %float 1
%main_1 = OpFunction %void None %11
%14 = OpLabel
OpStore %gl_Position %16
OpReturn
OpFunctionEnd
%tint_symbol_2 = OpFunction %void None %17
%tint_symbol = OpFunctionParameter %main_out
%21 = OpLabel
%22 = OpCompositeExtract %v4float %tint_symbol 0
OpStore %tint_symbol_1 %22
OpReturn
OpFunctionEnd
%main = OpFunction %void None %11
%24 = OpLabel
OpStore %tint_pointsize %float_1
%26 = OpFunctionCall %void %main_1
%28 = OpLoad %v4float %gl_Position
%29 = OpCompositeConstruct %main_out %28
%27 = OpFunctionCall %void %tint_symbol_2 %29
OpReturn
OpFunctionEnd

View File

@@ -1,7 +1,17 @@
[[builtin(position)]] var<out> gl_Position : vec4<f32>;
var<private> gl_Position : vec4<f32>;
[[stage(vertex)]]
fn main() {
fn main_1() {
gl_Position = vec4<f32>(0.0, 0.0, 0.0, 0.0);
return;
}
struct main_out {
[[builtin(position)]]
gl_Position : vec4<f32>;
};
[[stage(vertex)]]
fn main() -> main_out {
main_1();
return main_out(gl_Position);
}