Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HLSL: Recognize POSITION semantic et al in DX9 compatibility mode #2255

Merged
merged 1 commit into from
Jun 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion StandAlone/StandAlone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1593,7 +1593,8 @@ void usage()
" --hlsl-iomap perform IO mapping in HLSL register space\n"
" --hlsl-enable-16bit-types allow 16-bit types in SPIR-V for HLSL\n"
" --hlsl-dx9-compatible interprets sampler declarations as a\n"
" texture/sampler combo like DirectX9 would.\n"
" texture/sampler combo like DirectX9 would,\n"
" and recognizes DirectX9-specific semantics\n"
" --invert-y | --iy invert position.Y output in vertex shader\n"
" --keep-uncalled | --ku don't eliminate uncalled functions\n"
" --nan-clamp favor non-NaN operand in min, max, and clamp\n"
Expand Down
2 changes: 1 addition & 1 deletion glslang/Public/ShaderLang.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ enum EShMessages : unsigned {
EShMsgDebugInfo = (1 << 10), // save debug information
EShMsgHlslEnable16BitTypes = (1 << 11), // enable use of 16-bit types in SPIR-V for HLSL
EShMsgHlslLegalization = (1 << 12), // enable HLSL Legalization messages
EShMsgHlslDX9Compatible = (1 << 13), // enable HLSL DX9 compatible mode (right now only for samplers)
EShMsgHlslDX9Compatible = (1 << 13), // enable HLSL DX9 compatible mode (for samplers and semantics)
EShMsgBuiltinSymbolTable = (1 << 14), // print the builtin symbol table
LAST_ELEMENT_MARKER(EShMsgCount),
};
Expand Down
26 changes: 26 additions & 0 deletions hlsl/hlslParseHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6100,6 +6100,32 @@ void HlslParseContext::handleSemantic(TSourceLoc loc, TQualifier& qualifier, TBu
return semanticNum;
};

if (builtIn == EbvNone && hlslDX9Compatible()) {
if (language == EShLangVertex) {
if (qualifier.isParamOutput()) {
if (upperCase == "POSITION") {
builtIn = EbvPosition;
}
if (upperCase == "PSIZE") {
builtIn = EbvPointSize;
}
}
} else if (language == EShLangFragment) {
if (qualifier.isParamInput() && upperCase == "VPOS") {
builtIn = EbvFragCoord;
}
if (qualifier.isParamOutput()) {
if (upperCase.compare(0, 5, "COLOR") == 0) {
qualifier.layoutLocation = getSemanticNumber(upperCase, 0, nullptr);
nextOutLocation = std::max(nextOutLocation, qualifier.layoutLocation + 1u);
}
if (upperCase == "DEPTH") {
builtIn = EbvFragDepth;
}
}
}
}

switch(builtIn) {
case EbvNone:
// Get location numbers from fragment outputs, instead of
Expand Down