Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions clang/include/clang/Basic/DiagnosticSemaKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -13231,8 +13231,9 @@ def err_hlsl_semantic_indexing_not_supported
def err_hlsl_init_priority_unsupported : Error<
"initializer priorities are not supported in HLSL">;
def err_hlsl_semantic_index_overlap : Error<"semantic index overlap %0">;
def err_hlsl_semantic_unsupported_direction_for_stage
: Error<"semantic %0 is unsupported as %1 for stage %2">;
def err_hlsl_semantic_unsupported_iotype_for_stage
: Error<"semantic %0 is unsupported in %2 shaders as %1, requires one of "
"the following: %3">;

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>;
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">;
Expand Down
2 changes: 1 addition & 1 deletion clang/include/clang/Sema/SemaHLSL.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ class SemaHLSL : public SemaBase {

struct SemanticStageInfo {
llvm::Triple::EnvironmentType Stage;
IOType Direction;
IOType AllowedIOTypesMask;
};

private:
Expand Down
4 changes: 3 additions & 1 deletion clang/lib/CodeGen/CGHLSLRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -783,8 +783,10 @@ void CGHLSLRuntime::emitSystemSemanticStore(IRBuilder<> &B, llvm::Value *Source,
}
}

if (SemanticName == "SV_TARGET")
if (SemanticName == "SV_TARGET") {
emitUserSemanticStore(B, Source, Decl, Semantic, Index);
return;
}

llvm_unreachable(
"Store hasn't been implemented yet for this system semantic. FIXME");
Expand Down
20 changes: 16 additions & 4 deletions clang/lib/Sema/SemaHLSL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1010,14 +1010,26 @@ void SemaHLSL::diagnoseSemanticStageMismatch(
if (Case.Stage != Stage)
continue;

if (IsInput && Case.Direction & IOType::In)
if (IsInput && Case.AllowedIOTypesMask & IOType::In)
return;
if (!IsInput && Case.Direction & IOType::Out)
if (!IsInput && Case.AllowedIOTypesMask & IOType::Out)
return;

Diag(A->getLoc(), diag::err_hlsl_semantic_unsupported_direction_for_stage)
SmallVector<std::string, 8> ValidCases;
llvm::transform(
Allowed, std::back_inserter(ValidCases), [](SemanticStageInfo Case) {
std::string Type =
Case.AllowedIOTypesMask == IOType::InOut
? " inout"
: (Case.AllowedIOTypesMask & IOType::In ? " in" : " out");
return std::string(
HLSLShaderAttr::ConvertEnvironmentTypeToStr(Case.Stage)) +
Type;
});
Diag(A->getLoc(), diag::err_hlsl_semantic_unsupported_iotype_for_stage)
<< A->getAttrName() << (IsInput ? "input" : "output")
<< llvm::Triple::getEnvironmentTypeName(Case.Stage);
<< llvm::Triple::getEnvironmentTypeName(Case.Stage)
<< join(ValidCases, ", ");
return;
}

Expand Down
2 changes: 1 addition & 1 deletion clang/test/SemaHLSL/Semantics/position.ps.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
// RUN: %clang_cc1 -triple spirv-pc-vulkan1.3-pixel -finclude-default-header -x hlsl -verify -o - %s

float4 main(float4 a : A) : SV_Position {
// expected-error@-1 {{semantic 'SV_Position' is unsupported as output for stage pixel}}
// expected-error@-1 {{semantic 'SV_Position' is unsupported in pixel shaders as output, requires one of the following: vertex inout, pixel in}}
return a;
}
2 changes: 1 addition & 1 deletion clang/test/SemaHLSL/Semantics/target.ps.input.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
// RUN: %clang_cc1 -triple spirv-pc-vulkan1.3-pixel -finclude-default-header -x hlsl -verify -o - %s

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