Skip to content

Commit 2ebbc27

Browse files
committed
pr-feedback
1 parent 8305fe2 commit 2ebbc27

File tree

6 files changed

+25
-10
lines changed

6 files changed

+25
-10
lines changed

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13231,8 +13231,9 @@ def err_hlsl_semantic_indexing_not_supported
1323113231
def err_hlsl_init_priority_unsupported : Error<
1323213232
"initializer priorities are not supported in HLSL">;
1323313233
def err_hlsl_semantic_index_overlap : Error<"semantic index overlap %0">;
13234-
def err_hlsl_semantic_unsupported_direction_for_stage
13235-
: Error<"semantic %0 is unsupported as %1 for stage %2">;
13234+
def err_hlsl_semantic_unsupported_iotype_for_stage
13235+
: Error<"semantic %0 is unsupported in %2 shaders as %1, requires one of "
13236+
"the following: %3">;
1323613237

1323713238
def warn_hlsl_user_defined_type_missing_member: Warning<"binding type '%select{t|u|b|s|c}0' only applies to types containing %select{SRV resources|UAV resources|constant buffer resources|sampler state|numeric types}0">, InGroup<LegacyConstantRegisterBinding>;
1323813239
def err_hlsl_binding_type_mismatch: Error<"binding type '%select{t|u|b|s|c}0' only applies to %select{SRV resources|UAV resources|constant buffer resources|sampler state|numeric variables in the global scope}0">;

clang/include/clang/Sema/SemaHLSL.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ class SemaHLSL : public SemaBase {
249249

250250
struct SemanticStageInfo {
251251
llvm::Triple::EnvironmentType Stage;
252-
IOType Direction;
252+
IOType AllowedIOTypesMask;
253253
};
254254

255255
private:

clang/lib/CodeGen/CGHLSLRuntime.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -783,8 +783,10 @@ void CGHLSLRuntime::emitSystemSemanticStore(IRBuilder<> &B, llvm::Value *Source,
783783
}
784784
}
785785

786-
if (SemanticName == "SV_TARGET")
786+
if (SemanticName == "SV_TARGET") {
787787
emitUserSemanticStore(B, Source, Decl, Semantic, Index);
788+
return;
789+
}
788790

789791
llvm_unreachable(
790792
"Store hasn't been implemented yet for this system semantic. FIXME");

clang/lib/Sema/SemaHLSL.cpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,14 +1010,26 @@ void SemaHLSL::diagnoseSemanticStageMismatch(
10101010
if (Case.Stage != Stage)
10111011
continue;
10121012

1013-
if (IsInput && Case.Direction & IOType::In)
1013+
if (IsInput && Case.AllowedIOTypesMask & IOType::In)
10141014
return;
1015-
if (!IsInput && Case.Direction & IOType::Out)
1015+
if (!IsInput && Case.AllowedIOTypesMask & IOType::Out)
10161016
return;
10171017

1018-
Diag(A->getLoc(), diag::err_hlsl_semantic_unsupported_direction_for_stage)
1018+
SmallVector<std::string, 8> ValidCases;
1019+
llvm::transform(
1020+
Allowed, std::back_inserter(ValidCases), [](SemanticStageInfo Case) {
1021+
std::string Type =
1022+
Case.AllowedIOTypesMask == IOType::InOut
1023+
? " inout"
1024+
: (Case.AllowedIOTypesMask & IOType::In ? " in" : " out");
1025+
return std::string(
1026+
HLSLShaderAttr::ConvertEnvironmentTypeToStr(Case.Stage)) +
1027+
Type;
1028+
});
1029+
Diag(A->getLoc(), diag::err_hlsl_semantic_unsupported_iotype_for_stage)
10191030
<< A->getAttrName() << (IsInput ? "input" : "output")
1020-
<< llvm::Triple::getEnvironmentTypeName(Case.Stage);
1031+
<< llvm::Triple::getEnvironmentTypeName(Case.Stage)
1032+
<< join(ValidCases, ", ");
10211033
return;
10221034
}
10231035

clang/test/SemaHLSL/Semantics/position.ps.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
// RUN: %clang_cc1 -triple spirv-pc-vulkan1.3-pixel -finclude-default-header -x hlsl -verify -o - %s
33

44
float4 main(float4 a : A) : SV_Position {
5-
// expected-error@-1 {{semantic 'SV_Position' is unsupported as output for stage pixel}}
5+
// expected-error@-1 {{semantic 'SV_Position' is unsupported in pixel shaders as output, requires one of the following: vertex inout, pixel in}}
66
return a;
77
}

clang/test/SemaHLSL/Semantics/target.ps.input.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
// RUN: %clang_cc1 -triple spirv-pc-vulkan1.3-pixel -finclude-default-header -x hlsl -verify -o - %s
33

44
float4 main(float4 a : SV_Target) : A {
5-
// expected-error@-1 {{semantic 'SV_Target' is unsupported as input for stage pixel}}
5+
// expected-error@-1 {{semantic 'SV_Target' is unsupported in pixel shaders as input, requires one of the following: pixel out}}
66
return a;
77
}

0 commit comments

Comments
 (0)