resolver: Reenable VS validation for returning position

Fixed: tint:730
Change-Id: I7d5ebeffe2d522182d07f554a671bebab1cce2e6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/54420
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
This commit is contained in:
Ben Clayton 2021-06-16 09:50:11 +00:00 committed by Ben Clayton
parent 7e00263c01
commit 677437d650
8 changed files with 56 additions and 30 deletions

View File

@ -530,9 +530,7 @@ TEST_F(ResolverEntryPointValidationTest, Parameter_Struct_DuplicateLocation) {
12:34 note: while analysing entry point main)");
}
// TODO(bclayton): Reenable after CTS is updated
TEST_F(ResolverEntryPointValidationTest,
DISABLED_VertexShaderMustReturnPosition) {
TEST_F(ResolverEntryPointValidationTest, VertexShaderMustReturnPosition) {
// [[stage(vertex)]]
// fn main() {}
Func(Source{{12, 34}}, "main", {}, ty.void_(), {},

View File

@ -1119,8 +1119,7 @@ bool Resolver::ValidateEntryPoint(const ast::Function* func,
}
}
}
// TODO(bclayton): Reenable after CTS is updated
if (((false)) && !found) {
if (!found) {
diagnostics_.add_error(
"a vertex shader must include the 'position' builtin in its return "
"type",

View File

@ -103,7 +103,8 @@ fn main() {
TEST_F(SingleEntryPointTest, MultipleEntryPoints) {
auto* src = R"(
[[stage(vertex)]]
fn vert_main() {
fn vert_main() -> [[builtin(position)]] vec4<f32> {
return vec4<f32>();
}
[[stage(fragment)]]
@ -145,8 +146,9 @@ var<private> c : f32;
var<private> d : f32;
[[stage(vertex)]]
fn vert_main() {
fn vert_main() -> [[builtin(position)]] vec4<f32> {
a = 0.0;
return vec4<f32>();
}
[[stage(fragment)]]
@ -194,8 +196,9 @@ let c : f32 = 1.0;
let d : f32 = 1.0;
[[stage(vertex)]]
fn vert_main() {
fn vert_main() -> [[builtin(position)]] vec4<f32> {
let local_a : f32 = a;
return vec4<f32>();
}
[[stage(fragment)]]

View File

@ -1,6 +1,6 @@
[[stage(vertex)]]
fn main() {
fn main() -> [[builtin(position)]] vec4<f32> {
var light : vec3<f32> = vec3<f32>(1.2, 1., 2.);
var negative_light : vec3<f32> = -light;
return;
return vec4<f32>();
}

View File

@ -1,5 +1,10 @@
void main() {
struct tint_symbol {
float4 value : SV_Position;
};
tint_symbol main() {
float3 light = float3(1.200000048f, 1.0f, 2.0f);
float3 negative_light = -(light);
return;
const tint_symbol tint_symbol_1 = {float4(0.0f, 0.0f, 0.0f, 0.0f)};
return tint_symbol_1;
}

View File

@ -1,9 +1,14 @@
#include <metal_stdlib>
using namespace metal;
vertex void tint_symbol() {
struct tint_symbol_1 {
float4 value [[position]];
};
vertex tint_symbol_1 tint_symbol() {
float3 light = float3(1.200000048f, 1.0f, 2.0f);
float3 negative_light = -(light);
return;
tint_symbol_1 const tint_symbol_2 = {.value=float4()};
return tint_symbol_2;
}

View File

@ -1,37 +1,53 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 20
; Bound: 29
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %main "main" %tint_pointsize
OpEntryPoint Vertex %main "main" %tint_pointsize %tint_symbol_1
OpName %tint_pointsize "tint_pointsize"
OpName %tint_symbol_1 "tint_symbol_1"
OpName %tint_symbol_2 "tint_symbol_2"
OpName %tint_symbol "tint_symbol"
OpName %main "main"
OpName %light "light"
OpName %negative_light "negative_light"
OpDecorate %tint_pointsize BuiltIn PointSize
OpDecorate %tint_symbol_1 BuiltIn Position
%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
%8 = OpConstantNull %v4float
%tint_symbol_1 = OpVariable %_ptr_Output_v4float Output %8
%void = OpTypeVoid
%5 = OpTypeFunction %void
%9 = OpTypeFunction %void %v4float
%14 = OpTypeFunction %void
%float_1 = OpConstant %float 1
%v3float = OpTypeVector %float 3
%float_1_20000005 = OpConstant %float 1.20000005
%float_2 = OpConstant %float 2
%13 = OpConstantComposite %v3float %float_1_20000005 %float_1 %float_2
%21 = OpConstantComposite %v3float %float_1_20000005 %float_1 %float_2
%_ptr_Function_v3float = OpTypePointer Function %v3float
%16 = OpConstantNull %v3float
%main = OpFunction %void None %5
%8 = OpLabel
%light = OpVariable %_ptr_Function_v3float Function %16
%negative_light = OpVariable %_ptr_Function_v3float Function %16
OpStore %tint_pointsize %float_1
OpStore %light %13
%18 = OpLoad %v3float %light
%17 = OpFNegate %v3float %18
OpStore %negative_light %17
%24 = OpConstantNull %v3float
%tint_symbol_2 = OpFunction %void None %9
%tint_symbol = OpFunctionParameter %v4float
%13 = OpLabel
OpStore %tint_symbol_1 %tint_symbol
OpReturn
OpFunctionEnd
%main = OpFunction %void None %14
%16 = OpLabel
%light = OpVariable %_ptr_Function_v3float Function %24
%negative_light = OpVariable %_ptr_Function_v3float Function %24
OpStore %tint_pointsize %float_1
OpStore %light %21
%26 = OpLoad %v3float %light
%25 = OpFNegate %v3float %26
OpStore %negative_light %25
%28 = OpFunctionCall %void %tint_symbol_2 %8
OpReturn
OpFunctionEnd

View File

@ -1,6 +1,6 @@
[[stage(vertex)]]
fn main() {
fn main() -> [[builtin(position)]] vec4<f32> {
var light : vec3<f32> = vec3<f32>(1.200000048, 1.0, 2.0);
var negative_light : vec3<f32> = -(light);
return;
return vec4<f32>();
}