Manually merge ClemensRognerSD-dx9-sampler and resolve conflicts.
This commit is contained in:
parent
5d43c4aac7
commit
bd1c1831d5
13 changed files with 1060 additions and 8 deletions
|
|
@ -1163,6 +1163,49 @@ bool HlslGrammar::acceptSubpassInputType(TType& type)
|
|||
return true;
|
||||
}
|
||||
|
||||
// sampler_type for DX9 compatibility
|
||||
// : SAMPLER
|
||||
// | SAMPLER1D
|
||||
// | SAMPLER2D
|
||||
// | SAMPLER3D
|
||||
// | SAMPLERCUBE
|
||||
bool HlslGrammar::acceptSamplerTypeDX9(TType &type)
|
||||
{
|
||||
// read sampler type
|
||||
const EHlslTokenClass samplerType = peek();
|
||||
|
||||
TSamplerDim dim = EsdNone;
|
||||
TType txType(EbtFloat, EvqUniform, 4); // default type is float4
|
||||
|
||||
bool isShadow = false;
|
||||
|
||||
switch (samplerType)
|
||||
{
|
||||
case EHTokSampler: dim = Esd2D; break;
|
||||
case EHTokSampler1d: dim = Esd1D; break;
|
||||
case EHTokSampler2d: dim = Esd2D; break;
|
||||
case EHTokSampler3d: dim = Esd3D; break;
|
||||
case EHTokSamplerCube: dim = EsdCube; break;
|
||||
default:
|
||||
return false; // not a dx9 sampler declaration
|
||||
}
|
||||
|
||||
advanceToken(); // consume the sampler type keyword
|
||||
|
||||
TArraySizes *arraySizes = nullptr; // TODO: array
|
||||
|
||||
TSampler sampler;
|
||||
sampler.set(txType.getBasicType(), dim, false, isShadow, false);
|
||||
|
||||
if (!parseContext.setTextureReturnType(sampler, txType, token.loc))
|
||||
return false;
|
||||
|
||||
type.shallowCopy(TType(sampler, EvqUniform, arraySizes));
|
||||
type.getQualifier().layoutFormat = ElfNone;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// sampler_type
|
||||
// : SAMPLER
|
||||
// | SAMPLER1D
|
||||
|
|
@ -1445,7 +1488,13 @@ bool HlslGrammar::acceptType(TType& type, TIntermNode*& nodeList)
|
|||
case EHTokSampler2d: // ...
|
||||
case EHTokSampler3d: // ...
|
||||
case EHTokSamplerCube: // ...
|
||||
case EHTokSamplerState: // ...
|
||||
if (parseContext.hlslDX9Compatible())
|
||||
return acceptSamplerTypeDX9(type);
|
||||
else
|
||||
return acceptSamplerType(type);
|
||||
break;
|
||||
|
||||
case EHTokSamplerState: // fall through
|
||||
case EHTokSamplerComparisonState: // ...
|
||||
return acceptSamplerType(type);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -84,6 +84,7 @@ namespace glslang {
|
|||
bool acceptStreamOutTemplateType(TType&, TLayoutGeometry&);
|
||||
bool acceptOutputPrimitiveGeometry(TLayoutGeometry&);
|
||||
bool acceptAnnotations(TQualifier&);
|
||||
bool acceptSamplerTypeDX9(TType &);
|
||||
bool acceptSamplerType(TType&);
|
||||
bool acceptTextureType(TType&);
|
||||
bool acceptSubpassInputType(TType&);
|
||||
|
|
|
|||
|
|
@ -3770,6 +3770,43 @@ void HlslParseContext::decomposeSampleMethods(const TSourceLoc& loc, TIntermType
|
|||
|
||||
break;
|
||||
}
|
||||
case EOpTextureLod: //is almost EOpTextureBias (only args & operations are different)
|
||||
{
|
||||
TIntermTyped *argSamp = argAggregate->getSequence()[0]->getAsTyped(); // sampler
|
||||
TIntermTyped *argCoord = argAggregate->getSequence()[1]->getAsTyped(); // coord
|
||||
|
||||
assert(argCoord->getVectorSize() == 4);
|
||||
TIntermTyped *w = intermediate.addConstantUnion(3, loc, true);
|
||||
TIntermTyped *argLod = intermediate.addIndex(EOpIndexDirect, argCoord, w, loc);
|
||||
|
||||
TOperator constructOp = EOpNull;
|
||||
const TSampler &sampler = argSamp->getType().getSampler();
|
||||
int coordSize = 0;
|
||||
|
||||
switch (sampler.dim)
|
||||
{
|
||||
case Esd1D: constructOp = EOpConstructFloat; coordSize = 1; break; // 1D
|
||||
case Esd2D: constructOp = EOpConstructVec2; coordSize = 2; break; // 2D
|
||||
case Esd3D: constructOp = EOpConstructVec3; coordSize = 3; break; // 3D
|
||||
case EsdCube: constructOp = EOpConstructVec3; coordSize = 3; break; // also 3D
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
TIntermAggregate *constructCoord = new TIntermAggregate(constructOp);
|
||||
constructCoord->getSequence().push_back(argCoord);
|
||||
constructCoord->setLoc(loc);
|
||||
constructCoord->setType(TType(argCoord->getBasicType(), EvqTemporary, coordSize));
|
||||
|
||||
TIntermAggregate *tex = new TIntermAggregate(EOpTextureLod);
|
||||
tex->getSequence().push_back(argSamp); // sampler
|
||||
tex->getSequence().push_back(constructCoord); // coordinate
|
||||
tex->getSequence().push_back(argLod); // lod
|
||||
|
||||
node = convertReturn(tex, sampler);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case EOpTextureBias:
|
||||
{
|
||||
|
|
|
|||
|
|
@ -698,17 +698,17 @@ void TBuiltInParseablesHlsl::initialize(int /*version*/, EProfile /*profile*/, c
|
|||
{ "step", nullptr, nullptr, "SVM,", "F,", EShLangAll, false },
|
||||
{ "tan", nullptr, nullptr, "SVM", "F", EShLangAll, false },
|
||||
{ "tanh", nullptr, nullptr, "SVM", "F", EShLangAll, false },
|
||||
{ "tex1D", "V4", "F", "V1,S", "S,F", EShLangPS, false },
|
||||
{ "tex1D", "V4", "F", "V1,S,V1,", "S,F,,", EShLangPS, false },
|
||||
{ "tex1Dbias", "V4", "F", "V1,V4", "S,F", EShLangPS, false },
|
||||
{ "tex1Dgrad", "V4", "F", "V1,,,", "S,F,,", EShLangPS, false },
|
||||
{ "tex1Dlod", "V4", "F", "V1,V4", "S,F", EShLangPS, false },
|
||||
{ "tex1Dproj", "V4", "F", "V1,V4", "S,F", EShLangPS, false },
|
||||
{ "tex1D", "V4", "F", "S,S", "S,F", EShLangPS, false },
|
||||
{ "tex1D", "V4", "F", "S,S,V1,", "S,F,,", EShLangPS, false },
|
||||
{ "tex1Dbias", "V4", "F", "S,V4", "S,F", EShLangPS, false },
|
||||
{ "tex1Dgrad", "V4", "F", "S,,,", "S,F,,", EShLangPS, false },
|
||||
{ "tex1Dlod", "V4", "F", "S,V4", "S,F", EShLangPS, false },
|
||||
{ "tex1Dproj", "V4", "F", "S,V4", "S,F", EShLangPS, false },
|
||||
{ "tex2D", "V4", "F", "V2,", "S,F", EShLangPS, false },
|
||||
{ "tex2D", "V4", "F", "V2,,,", "S,F,,", EShLangPS, false },
|
||||
{ "tex2Dbias", "V4", "F", "V2,V4", "S,F", EShLangPS, false },
|
||||
{ "tex2Dgrad", "V4", "F", "V2,,,", "S,F,,", EShLangPS, false },
|
||||
{ "tex2Dlod", "V4", "F", "V2,V4", "S,F", EShLangPS, false },
|
||||
{ "tex2Dlod", "V4", "F", "V2,V4", "S,F", EShLangAll, false },
|
||||
{ "tex2Dproj", "V4", "F", "V2,V4", "S,F", EShLangPS, false },
|
||||
{ "tex3D", "V4", "F", "V3,", "S,F", EShLangPS, false },
|
||||
{ "tex3D", "V4", "F", "V3,,,", "S,F,,", EShLangPS, false },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue