HLSL: Add CalculateLevelOfDetail, and unimplemented errors for *Unclamped and GetSamplePosition

This commit is contained in:
steve-lunarg 2016-07-26 08:57:53 -06:00
parent 00957f8110
commit 68f2c144e3
9 changed files with 1048 additions and 2 deletions

View file

@ -1273,6 +1273,38 @@ void HlslParseContext::decomposeSampleMethods(const TSourceLoc& loc, TIntermType
break;
}
case EOpMethodCalculateLevelOfDetail:
case EOpMethodCalculateLevelOfDetailUnclamped:
{
TIntermTyped* argTex = argAggregate->getSequence()[0]->getAsTyped();
TIntermTyped* argSamp = argAggregate->getSequence()[1]->getAsTyped();
TIntermTyped* argCoord = argAggregate->getSequence()[2]->getAsTyped();
TIntermAggregate* txquerylod = new TIntermAggregate(EOpTextureQueryLod);
TIntermAggregate* txcombine = handleSamplerTextureCombine(loc, argTex, argSamp);
txquerylod->getSequence().push_back(txcombine);
txquerylod->getSequence().push_back(argCoord);
TIntermTyped* lodComponent = intermediate.addConstantUnion(0, loc, true);
TIntermTyped* lodComponentIdx = intermediate.addIndex(EOpIndexDirect, txquerylod, lodComponent, loc);
lodComponentIdx->setType(TType(EbtFloat, EvqTemporary, 1));
node = lodComponentIdx;
// We cannot currently obtain the unclamped LOD
if (op == EOpMethodCalculateLevelOfDetailUnclamped)
error(loc, "unimplemented: CalculateLevelOfDetailUnclamped", "", "");
break;
}
case EOpMethodGetSamplePosition:
{
error(loc, "unimplemented: GetSamplePosition", "", "");
break;
}
default:
break; // most pass through unchanged
}

View file

@ -132,6 +132,12 @@ bool HasMipInCoord(const glslang::TString& name, bool isMS)
return name == "Load" && !isMS;
}
// LOD calculations don't pass the array level in the coordinate.
bool NoArrayCoord(const glslang::TString& name)
{
return name == "CalculateLevelOfDetail" || name == "CalculateLevelOfDetailUnclamped";
}
// Handle IO params marked with > or <
const char* IoParam(glslang::TString& s, const char* nthArgOrder)
{
@ -632,6 +638,11 @@ void TBuiltInParseablesHlsl::initialize(int /*version*/, EProfile /*profile*/, c
{ "Gather", /*!O*/ "V4", nullptr, "%@,S,V", "FIU,S,F", EShLangVSPSGS },
{ "Gather", /* O*/ "V4", nullptr, "%@,S,V,V", "FIU,S,F,I", EShLangVSPSGS },
{ "CalculateLevelOfDetail", "S", "F", "%@,S,V", "FUI,S,F", EShLangFragmentMask },
{ "CalculateLevelOfDetailUnclamped", "S", "F", "%@,S,V", "FUI,S,F", EShLangFragmentMask },
{ "GetSamplePosition", "V2", "F", "$&2,S", "FUI,I", EShLangVSPSGS },
// table of overloads from: https://msdn.microsoft.com/en-us/library/windows/desktop/bb509693(v=vs.85).aspx
//
// UINT Width
@ -770,8 +781,9 @@ void TBuiltInParseablesHlsl::initialize(int /*version*/, EProfile /*profile*/, c
// In case the repeated arg has its own I/O marker
nthArgOrder = IoParam(s, nthArgOrder);
// arrayed textures have one extra coordinate dimension
if (isArrayed && arg == coordArg)
// arrayed textures have one extra coordinate dimension, except for
// the CalculateLevelOfDetail family.
if (isArrayed && arg == coordArg && !NoArrayCoord(intrinsic.name))
argDim0++;
// Some texture methods use an addition arg dimension to hold mip
@ -982,7 +994,10 @@ void TBuiltInParseablesHlsl::identifyBuiltIns(int /*version*/, EProfile /*profil
symbolTable.relateToOperator("SampleLevel", EOpMethodSampleLevel);
symbolTable.relateToOperator("Load", EOpMethodLoad);
symbolTable.relateToOperator("GetDimensions", EOpMethodGetDimensions);
symbolTable.relateToOperator("GetSamplePosition", EOpMethodGetSamplePosition);
symbolTable.relateToOperator("Gather", EOpMethodGather);
symbolTable.relateToOperator("CalculateLevelOfDetail", EOpMethodCalculateLevelOfDetail);
symbolTable.relateToOperator("CalculateLevelOfDetailUnclamped", EOpMethodCalculateLevelOfDetailUnclamped);
}
//