HLSL: Add SampleLevel method

This commit is contained in:
LoopDawg
2016-07-21 15:02:16 -06:00
parent 2f003ac4e6
commit 3ef7852ef6
13 changed files with 2863 additions and 9 deletions

View File

@@ -1189,6 +1189,38 @@ void HlslParseContext::decomposeSampleMethods(const TSourceLoc& loc, TIntermType
break;
}
case EOpMethodSampleLevel:
{
TIntermTyped* argTex = argAggregate->getSequence()[0]->getAsTyped();
TIntermTyped* argSamp = argAggregate->getSequence()[1]->getAsTyped();
TIntermTyped* argCoord = argAggregate->getSequence()[2]->getAsTyped();
TIntermTyped* argLod = argAggregate->getSequence()[3]->getAsTyped();
TIntermTyped* argOffset = nullptr;
const int numArgs = argAggregate->getSequence().size();
if (numArgs == 5) // offset, if present
argOffset = argAggregate->getSequence()[4]->getAsTyped();
const TOperator textureOp = (argOffset == nullptr ? EOpTextureLod : EOpTextureLodOffset);
TIntermAggregate* txsample = new TIntermAggregate(textureOp);
TIntermAggregate* txcombine = handleSamplerTextureCombine(loc, argTex, argSamp);
txsample->getSequence().push_back(txcombine);
txsample->getSequence().push_back(argCoord);
txsample->getSequence().push_back(argLod);
if (argOffset != nullptr)
txsample->getSequence().push_back(argOffset);
txsample->setType(node->getType());
txsample->setLoc(loc);
node = txsample;
break;
}
default:
break; // most pass through unchanged
}

View File

@@ -588,15 +588,15 @@ void TBuiltInParseablesHlsl::initialize(int /*version*/, EProfile /*profile*/, c
{ "SampleGrad", /*!O A*/ "V4", nullptr, "@V,S,V,V,V", "FIU,S,F,F,F", EShLangAll },
{ "SampleGrad", /* O A*/ "V4", nullptr, "@V,S,V,V,V,V", "FIU,S,F,F,F,I", EShLangAll },
// { "SampleLevel", /*!O !A*/ "V4", nullptr, "%V,S,V,S", "FIU,S,F,F", EShLangAll },
// { "SampleLevel", /* O !A*/ "V4", nullptr, "%V,S,V,S,V", "FIU,S,F,F,I", EShLangAll },
// { "SampleLevel", /*!O A*/ "V4", nullptr, "@V,S,V,S", "FIU,S,F,F", EShLangAll },
// { "SampleLevel", /* O A*/ "V4", nullptr, "@V,S,V,S,V", "FIU,S,F,F,I", EShLangAll },
{ "SampleLevel", /*!O !A*/ "V4", nullptr, "%V,S,V,S", "FIU,S,F,F", EShLangAll },
{ "SampleLevel", /* O !A*/ "V4", nullptr, "%V,S,V,S,V", "FIU,S,F,F,I", EShLangAll },
{ "SampleLevel", /*!O A*/ "V4", nullptr, "@V,S,V,S", "FIU,S,F,F", EShLangAll },
{ "SampleLevel", /* O A*/ "V4", nullptr, "@V,S,V,S,V", "FIU,S,F,F,I", EShLangAll },
{ "Load", /*!O !A*/ "V4", nullptr, "%V,V", "FIU,I", EShLangAll },
{ "Load", /*!O A*/ "V4", nullptr, "@V,V", "FIU,I", EShLangAll },
{ "Load", /* O !A*/ "V4", nullptr, "%V,V,V", "FIU,I,I", EShLangAll },
{ "Load", /* O A*/ "V4", nullptr, "@V,V,V", "FIU,I,I", EShLangAll },
{ "Load", /*!O !A*/ "V4", nullptr, "%V,V", "FIU,I", EShLangAll },
{ "Load", /*!O A*/ "V4", nullptr, "@V,V", "FIU,I", EShLangAll },
{ "Load", /* O !A*/ "V4", nullptr, "%V,V,V", "FIU,I,I", EShLangAll },
{ "Load", /* O A*/ "V4", nullptr, "@V,V,V", "FIU,I,I", EShLangAll },
// TODO: MS variants of Load
// { "Load", /* +sampleidex*/ "V4", nullptr, "$V,V,S", "FIU,I,I", EShLangAll },
// { "Load", /* +samplindex, offset*/ "V4", nullptr, "$V,V,S,V", "FIU,I,I,I", EShLangAll },
@@ -943,7 +943,7 @@ void TBuiltInParseablesHlsl::identifyBuiltIns(int /*version*/, EProfile /*profil
symbolTable.relateToOperator("SampleCmp", EOpMethodSampleCmp);
symbolTable.relateToOperator("SampleCmpLevelZero", EOpMethodSampleCmpLevelZero);
symbolTable.relateToOperator("SampleGrad", EOpMethodSampleGrad);
// symbolTable.relateToOperator("SampleLevel", EOpMethodSampleLevel);
symbolTable.relateToOperator("SampleLevel", EOpMethodSampleLevel);
symbolTable.relateToOperator("Load", EOpMethodLoad);
symbolTable.relateToOperator("GetDimensions", EOpMethodGetDimensions);
}