SPV: Implement Vulkan 1.1 features and extensions.
This commit is contained in:
@@ -1590,6 +1590,10 @@ bool HlslGrammar::acceptType(TType& type, TIntermNode*& nodeList)
|
||||
new(&type) TType(EbtUint, EvqTemporary, 4);
|
||||
break;
|
||||
|
||||
case EHTokUint64:
|
||||
new(&type) TType(EbtUint64);
|
||||
break;
|
||||
|
||||
case EHTokBool:
|
||||
new(&type) TType(EbtBool);
|
||||
break;
|
||||
|
||||
@@ -4559,6 +4559,22 @@ void HlslParseContext::decomposeIntrinsic(const TSourceLoc& loc, TIntermTyped*&
|
||||
return imageAggregate != nullptr && imageAggregate->getOp() == EOpImageLoad;
|
||||
};
|
||||
|
||||
const auto lookupBuiltinVariable = [&](const char* name, TBuiltInVariable builtin, TType& type) -> TIntermTyped* {
|
||||
TSymbol* symbol = symbolTable.find(name);
|
||||
if (nullptr == symbol) {
|
||||
type.getQualifier().builtIn = builtin;
|
||||
|
||||
TVariable* variable = new TVariable(new TString(name), type);
|
||||
|
||||
symbolTable.insert(*variable);
|
||||
|
||||
symbol = symbolTable.find(name);
|
||||
assert(symbol && "Inserted symbol could not be found!");
|
||||
}
|
||||
|
||||
return intermediate.addSymbol(*(symbol->getAsVariable()), loc);
|
||||
};
|
||||
|
||||
// HLSL intrinsics can be pass through to native AST opcodes, or decomposed here to existing AST
|
||||
// opcodes for compatibility with existing software stacks.
|
||||
static const bool decomposeHlslIntrinsics = true;
|
||||
@@ -5115,7 +5131,65 @@ void HlslParseContext::decomposeIntrinsic(const TSourceLoc& loc, TIntermTyped*&
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case EOpWaveGetLaneCount:
|
||||
{
|
||||
// Mapped to gl_SubgroupSize builtin (We preprend @ to the symbol
|
||||
// so that it inhabits the symbol table, but has a user-invalid name
|
||||
// in-case some source HLSL defined the symbol also).
|
||||
TType type(EbtUint, EvqVaryingIn);
|
||||
node = lookupBuiltinVariable("@gl_SubgroupSize", EbvSubgroupSize2, type);
|
||||
break;
|
||||
}
|
||||
case EOpWaveGetLaneIndex:
|
||||
{
|
||||
// Mapped to gl_SubgroupInvocationID builtin (We preprend @ to the
|
||||
// symbol so that it inhabits the symbol table, but has a
|
||||
// user-invalid name in-case some source HLSL defined the symbol
|
||||
// also).
|
||||
TType type(EbtUint, EvqVaryingIn);
|
||||
node = lookupBuiltinVariable("@gl_SubgroupInvocationID", EbvSubgroupInvocation2, type);
|
||||
break;
|
||||
}
|
||||
case EOpWaveActiveCountBits:
|
||||
{
|
||||
// Mapped to subgroupBallotBitCount(subgroupBallot()) builtin
|
||||
|
||||
// uvec4 type.
|
||||
TType uvec4Type(EbtUint, EvqTemporary, 4);
|
||||
|
||||
// Get the uvec4 return from subgroupBallot().
|
||||
TIntermTyped* res = intermediate.addBuiltInFunctionCall(loc,
|
||||
EOpSubgroupBallot, true, arguments, uvec4Type);
|
||||
|
||||
// uint type.
|
||||
TType uintType(EbtUint, EvqTemporary);
|
||||
|
||||
node = intermediate.addBuiltInFunctionCall(loc,
|
||||
EOpSubgroupBallotBitCount, true, res, uintType);
|
||||
|
||||
break;
|
||||
}
|
||||
case EOpWavePrefixCountBits:
|
||||
{
|
||||
// Mapped to subgroupBallotInclusiveBitCount(subgroupBallot())
|
||||
// builtin
|
||||
|
||||
// uvec4 type.
|
||||
TType uvec4Type(EbtUint, EvqTemporary, 4);
|
||||
|
||||
// Get the uvec4 return from subgroupBallot().
|
||||
TIntermTyped* res = intermediate.addBuiltInFunctionCall(loc,
|
||||
EOpSubgroupBallot, true, arguments, uvec4Type);
|
||||
|
||||
// uint type.
|
||||
TType uintType(EbtUint, EvqTemporary);
|
||||
|
||||
node = intermediate.addBuiltInFunctionCall(loc,
|
||||
EOpSubgroupBallotInclusiveBitCount, true, res, uintType);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break; // most pass through unchanged
|
||||
}
|
||||
|
||||
@@ -259,6 +259,8 @@ glslang::TString& AppendTypeName(glslang::TString& s, const char* argOrder, cons
|
||||
case 'D': s += "double"; break;
|
||||
case 'I': s += "int"; break;
|
||||
case 'U': s += "uint"; break;
|
||||
case 'L': s += "int64_t"; break;
|
||||
case 'M': s += "uint64_t"; break;
|
||||
case 'B': s += "bool"; break;
|
||||
case 'S': s += "sampler"; break;
|
||||
case 's': s += "SamplerComparisonState"; break;
|
||||
@@ -544,7 +546,7 @@ void TBuiltInParseablesHlsl::initialize(int /*version*/, EProfile /*profile*/, c
|
||||
// orderKey can be:
|
||||
// S = scalar, V = vector, M = matrix, - = void
|
||||
// typekey can be:
|
||||
// D = double, F = float, U = uint, I = int, B = bool, S = sampler, s = shadowSampler
|
||||
// D = double, F = float, U = uint, I = int, B = bool, S = sampler, s = shadowSampler, M = uint64_t, L = int64_t
|
||||
// An empty order or type key repeats the first one. E.g: SVM,, means 3 args each of SVM.
|
||||
// '>' as first letter of order creates an output parameter
|
||||
// '<' as first letter of order creates an input parameter
|
||||
@@ -902,6 +904,35 @@ void TBuiltInParseablesHlsl::initialize(int /*version*/, EProfile /*profile*/, c
|
||||
{ "DecrementCounter", nullptr, nullptr, "-", "-", EShLangAll, true },
|
||||
{ "Consume", nullptr, nullptr, "-", "-", EShLangAll, true },
|
||||
|
||||
// SM 6.0
|
||||
|
||||
{ "WaveIsFirstLane", "S", "B", "-", "-", EShLangPSCS, false},
|
||||
{ "WaveGetLaneCount", "S", "U", "-", "-", EShLangPSCS, false},
|
||||
{ "WaveGetLaneIndex", "S", "U", "-", "-", EShLangPSCS, false},
|
||||
{ "WaveActiveAnyTrue", "S", "B", "S", "B", EShLangPSCS, false},
|
||||
{ "WaveActiveAllTrue", "S", "B", "S", "B", EShLangPSCS, false},
|
||||
{ "WaveActiveBallot", "V4", "U", "S", "B", EShLangPSCS, false},
|
||||
{ "WaveReadLaneAt", nullptr, nullptr, "SV,S", "DFUI,U", EShLangPSCS, false},
|
||||
{ "WaveReadFirstLane", nullptr, nullptr, "SV", "DFUI", EShLangPSCS, false},
|
||||
{ "WaveActiveAllEqual", "S", "B", "SV", "DFUI", EShLangPSCS, false},
|
||||
{ "WaveActiveAllEqualBool", "S", "B", "S", "B", EShLangPSCS, false},
|
||||
{ "WaveActiveCountBits", "S", "U", "S", "B", EShLangPSCS, false},
|
||||
|
||||
{ "WaveActiveSum", nullptr, nullptr, "SV", "DFUI", EShLangPSCS, false},
|
||||
{ "WaveActiveProduct", nullptr, nullptr, "SV", "DFUI", EShLangPSCS, false},
|
||||
{ "WaveActiveBitAnd", nullptr, nullptr, "SV", "DFUI", EShLangPSCS, false},
|
||||
{ "WaveActiveBitOr", nullptr, nullptr, "SV", "DFUI", EShLangPSCS, false},
|
||||
{ "WaveActiveBitXor", nullptr, nullptr, "SV", "DFUI", EShLangPSCS, false},
|
||||
{ "WaveActiveMin", nullptr, nullptr, "SV", "DFUI", EShLangPSCS, false},
|
||||
{ "WaveActiveMax", nullptr, nullptr, "SV", "DFUI", EShLangPSCS, false},
|
||||
{ "WavePrefixSum", nullptr, nullptr, "SV", "DFUI", EShLangPSCS, false},
|
||||
{ "WavePrefixProduct", nullptr, nullptr, "SV", "DFUI", EShLangPSCS, false},
|
||||
{ "WavePrefixCountBits", "S", "U", "S", "B", EShLangPSCS, false},
|
||||
{ "QuadReadAcrossX", nullptr, nullptr, "SV", "DFUI", EShLangPSCS, false},
|
||||
{ "QuadReadAcrossY", nullptr, nullptr, "SV", "DFUI", EShLangPSCS, false},
|
||||
{ "QuadReadAcrossDiagonal", nullptr, nullptr, "SV", "DFUI", EShLangPSCS, false},
|
||||
{ "QuadReadLaneAt", nullptr, nullptr, "SV,S", "DFUI,U", EShLangPSCS, false},
|
||||
|
||||
// Methods for subpass input objects
|
||||
{ "SubpassLoad", "V4", nullptr, "[", "FIU", EShLangPS, true },
|
||||
{ "SubpassLoad", "V4", nullptr, "],S", "FIU,I", EShLangPS, true },
|
||||
@@ -1244,6 +1275,33 @@ void TBuiltInParseablesHlsl::identifyBuiltIns(int /*version*/, EProfile /*profil
|
||||
symbolTable.relateToOperator(BUILTIN_PREFIX "Append", EOpMethodAppend);
|
||||
symbolTable.relateToOperator(BUILTIN_PREFIX "RestartStrip", EOpMethodRestartStrip);
|
||||
|
||||
// Wave ops
|
||||
symbolTable.relateToOperator("WaveIsFirstLane", EOpSubgroupElect);
|
||||
symbolTable.relateToOperator("WaveGetLaneCount", EOpWaveGetLaneCount);
|
||||
symbolTable.relateToOperator("WaveGetLaneIndex", EOpWaveGetLaneIndex);
|
||||
symbolTable.relateToOperator("WaveActiveAnyTrue", EOpSubgroupAny);
|
||||
symbolTable.relateToOperator("WaveActiveAllTrue", EOpSubgroupAll);
|
||||
symbolTable.relateToOperator("WaveActiveBallot", EOpSubgroupBallot);
|
||||
symbolTable.relateToOperator("WaveReadFirstLane", EOpSubgroupBroadcastFirst);
|
||||
symbolTable.relateToOperator("WaveReadLaneAt", EOpSubgroupShuffle);
|
||||
symbolTable.relateToOperator("WaveActiveAllEqual", EOpSubgroupAllEqual);
|
||||
symbolTable.relateToOperator("WaveActiveAllEqualBool", EOpSubgroupAllEqual);
|
||||
symbolTable.relateToOperator("WaveActiveCountBits", EOpWaveActiveCountBits);
|
||||
symbolTable.relateToOperator("WaveActiveSum", EOpSubgroupAdd);
|
||||
symbolTable.relateToOperator("WaveActiveProduct", EOpSubgroupMul);
|
||||
symbolTable.relateToOperator("WaveActiveBitAnd", EOpSubgroupAnd);
|
||||
symbolTable.relateToOperator("WaveActiveBitOr", EOpSubgroupOr);
|
||||
symbolTable.relateToOperator("WaveActiveBitXor", EOpSubgroupXor);
|
||||
symbolTable.relateToOperator("WaveActiveMin", EOpSubgroupMin);
|
||||
symbolTable.relateToOperator("WaveActiveMax", EOpSubgroupMax);
|
||||
symbolTable.relateToOperator("WavePrefixSum", EOpSubgroupInclusiveAdd);
|
||||
symbolTable.relateToOperator("WavePrefixProduct", EOpSubgroupInclusiveMul);
|
||||
symbolTable.relateToOperator("WavePrefixCountBits", EOpWavePrefixCountBits);
|
||||
symbolTable.relateToOperator("QuadReadAcrossX", EOpSubgroupQuadSwapHorizontal);
|
||||
symbolTable.relateToOperator("QuadReadAcrossY", EOpSubgroupQuadSwapVertical);
|
||||
symbolTable.relateToOperator("QuadReadAcrossDiagonal", EOpSubgroupQuadSwapDiagonal);
|
||||
symbolTable.relateToOperator("QuadReadLaneAt", EOpSubgroupQuadBroadcast);
|
||||
|
||||
// Subpass input methods
|
||||
symbolTable.relateToOperator(BUILTIN_PREFIX "SubpassLoad", EOpSubpassLoad);
|
||||
symbolTable.relateToOperator(BUILTIN_PREFIX "SubpassLoadMS", EOpSubpassLoadMS);
|
||||
|
||||
@@ -143,6 +143,7 @@ void HlslScanContext::fillInKeywordMap()
|
||||
(*KeywordMap)["bool"] = EHTokBool;
|
||||
(*KeywordMap)["int"] = EHTokInt;
|
||||
(*KeywordMap)["uint"] = EHTokUint;
|
||||
(*KeywordMap)["uint64_t"] = EHTokUint64;
|
||||
(*KeywordMap)["dword"] = EHTokDword;
|
||||
(*KeywordMap)["half"] = EHTokHalf;
|
||||
(*KeywordMap)["float"] = EHTokFloat;
|
||||
@@ -650,6 +651,7 @@ EHlslTokenClass HlslScanContext::tokenizeIdentifier()
|
||||
case EHTokBool:
|
||||
case EHTokInt:
|
||||
case EHTokUint:
|
||||
case EHTokUint64:
|
||||
case EHTokDword:
|
||||
case EHTokHalf:
|
||||
case EHTokFloat:
|
||||
|
||||
@@ -95,6 +95,7 @@ enum EHlslTokenClass {
|
||||
EHTokBool,
|
||||
EHTokInt,
|
||||
EHTokUint,
|
||||
EHTokUint64,
|
||||
EHTokDword,
|
||||
EHTokHalf,
|
||||
EHTokFloat,
|
||||
|
||||
Reference in New Issue
Block a user