tint/resolver: Resolve dependencies of parameter attributes

Fixed: chromium:1381883
Change-Id: If93840977407e349ab8d3ea5a2f51b9e03c7d0e5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108920
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
Ben Clayton 2022-11-07 13:15:21 +00:00 committed by Dawn LUCI CQ
parent 6f799d676d
commit ca98b1b1b9
9 changed files with 100 additions and 5 deletions

View File

@ -193,8 +193,6 @@ class DependencyScanner {
},
[&](const ast::Function* func) {
Declare(func->symbol, func);
TraverseAttributes(func->attributes);
TraverseAttributes(func->return_type_attributes);
TraverseFunction(func);
},
[&](const ast::Variable* var) {
@ -216,10 +214,13 @@ class DependencyScanner {
/// Traverses the function, performing symbol resolution and determining
/// global dependencies.
void TraverseFunction(const ast::Function* func) {
TraverseAttributes(func->attributes);
TraverseAttributes(func->return_type_attributes);
// Perform symbol resolution on all the parameter types before registering
// the parameters themselves. This allows the case of declaring a parameter
// with the same identifier as its type.
for (auto* param : func->params) {
TraverseAttributes(param->attributes);
TraverseType(param->type);
}
// Resolve the return type

View File

@ -1237,8 +1237,13 @@ TEST_F(ResolverDependencyGraphTraversalTest, SymbolsReached) {
})});
GlobalVar(Sym(), T, V);
GlobalConst(Sym(), T, V);
Func(Sym(), //
utils::Vector{Param(Sym(), T)}, //
Func(Sym(),
utils::Vector{
Param(Sym(), T,
utils::Vector{
Location(V), // Parameter attributes
}),
},
T, // Return type
utils::Vector{
Decl(Var(Sym(), T, V)), //

View File

@ -0,0 +1,5 @@
const C = 2;
@fragment
fn main(@location(C) none : f32) {
}

View File

@ -0,0 +1,11 @@
struct tint_symbol_1 {
float none : TEXCOORD2;
};
void main_inner(float none) {
}
void main(tint_symbol_1 tint_symbol) {
main_inner(tint_symbol.none);
return;
}

View File

@ -0,0 +1,11 @@
struct tint_symbol_1 {
float none : TEXCOORD2;
};
void main_inner(float none) {
}
void main(tint_symbol_1 tint_symbol) {
main_inner(tint_symbol.none);
return;
}

View File

@ -0,0 +1,11 @@
#version 310 es
precision mediump float;
layout(location = 2) in float none_1;
void tint_symbol(float none) {
}
void main() {
tint_symbol(none_1);
return;
}

View File

@ -0,0 +1,15 @@
#include <metal_stdlib>
using namespace metal;
struct tint_symbol_2 {
float none [[user(locn2)]];
};
void tint_symbol_inner(float none) {
}
fragment void tint_symbol(tint_symbol_2 tint_symbol_1 [[stage_in]]) {
tint_symbol_inner(tint_symbol_1.none);
return;
}

View File

@ -0,0 +1,31 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 14
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %main "main" %none_1
OpExecutionMode %main OriginUpperLeft
OpName %none_1 "none_1"
OpName %main_inner "main_inner"
OpName %none "none"
OpName %main "main"
OpDecorate %none_1 Location 2
%float = OpTypeFloat 32
%_ptr_Input_float = OpTypePointer Input %float
%none_1 = OpVariable %_ptr_Input_float Input
%void = OpTypeVoid
%4 = OpTypeFunction %void %float
%9 = OpTypeFunction %void
%main_inner = OpFunction %void None %4
%none = OpFunctionParameter %float
%8 = OpLabel
OpReturn
OpFunctionEnd
%main = OpFunction %void None %9
%11 = OpLabel
%13 = OpLoad %float %none_1
%12 = OpFunctionCall %void %main_inner %13
OpReturn
OpFunctionEnd

View File

@ -0,0 +1,5 @@
const C = 2;
@fragment
fn main(@location(C) none : f32) {
}