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)"); 12:34 note: while analysing entry point main)");
} }
// TODO(bclayton): Reenable after CTS is updated TEST_F(ResolverEntryPointValidationTest, VertexShaderMustReturnPosition) {
TEST_F(ResolverEntryPointValidationTest,
DISABLED_VertexShaderMustReturnPosition) {
// [[stage(vertex)]] // [[stage(vertex)]]
// fn main() {} // fn main() {}
Func(Source{{12, 34}}, "main", {}, ty.void_(), {}, 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 (!found) {
if (((false)) && !found) {
diagnostics_.add_error( diagnostics_.add_error(
"a vertex shader must include the 'position' builtin in its return " "a vertex shader must include the 'position' builtin in its return "
"type", "type",

View File

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

View File

@ -1,6 +1,6 @@
[[stage(vertex)]] [[stage(vertex)]]
fn main() { fn main() -> [[builtin(position)]] vec4<f32> {
var light : vec3<f32> = vec3<f32>(1.2, 1., 2.); var light : vec3<f32> = vec3<f32>(1.2, 1., 2.);
var negative_light : vec3<f32> = -light; 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 light = float3(1.200000048f, 1.0f, 2.0f);
float3 negative_light = -(light); 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> #include <metal_stdlib>
using namespace metal; 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 light = float3(1.200000048f, 1.0f, 2.0f);
float3 negative_light = -(light); 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 ; SPIR-V
; Version: 1.3 ; Version: 1.3
; Generator: Google Tint Compiler; 0 ; Generator: Google Tint Compiler; 0
; Bound: 20 ; Bound: 29
; Schema: 0 ; Schema: 0
OpCapability Shader OpCapability Shader
OpMemoryModel Logical GLSL450 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_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 %main "main"
OpName %light "light" OpName %light "light"
OpName %negative_light "negative_light" OpName %negative_light "negative_light"
OpDecorate %tint_pointsize BuiltIn PointSize OpDecorate %tint_pointsize BuiltIn PointSize
OpDecorate %tint_symbol_1 BuiltIn Position
%float = OpTypeFloat 32 %float = OpTypeFloat 32
%_ptr_Output_float = OpTypePointer Output %float %_ptr_Output_float = OpTypePointer Output %float
%4 = OpConstantNull %float %4 = OpConstantNull %float
%tint_pointsize = OpVariable %_ptr_Output_float Output %4 %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 %void = OpTypeVoid
%5 = OpTypeFunction %void %9 = OpTypeFunction %void %v4float
%14 = OpTypeFunction %void
%float_1 = OpConstant %float 1 %float_1 = OpConstant %float 1
%v3float = OpTypeVector %float 3 %v3float = OpTypeVector %float 3
%float_1_20000005 = OpConstant %float 1.20000005 %float_1_20000005 = OpConstant %float 1.20000005
%float_2 = OpConstant %float 2 %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 %_ptr_Function_v3float = OpTypePointer Function %v3float
%16 = OpConstantNull %v3float %24 = OpConstantNull %v3float
%main = OpFunction %void None %5 %tint_symbol_2 = OpFunction %void None %9
%8 = OpLabel %tint_symbol = OpFunctionParameter %v4float
%light = OpVariable %_ptr_Function_v3float Function %16 %13 = OpLabel
%negative_light = OpVariable %_ptr_Function_v3float Function %16 OpStore %tint_symbol_1 %tint_symbol
OpStore %tint_pointsize %float_1 OpReturn
OpStore %light %13 OpFunctionEnd
%18 = OpLoad %v3float %light %main = OpFunction %void None %14
%17 = OpFNegate %v3float %18 %16 = OpLabel
OpStore %negative_light %17 %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 OpReturn
OpFunctionEnd OpFunctionEnd

View File

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