Merge pull request #2825 from greg-lunarg/i2244
Add --hlsl-dx-position-w option
This commit is contained in:
@@ -2167,8 +2167,21 @@ TIntermNode* HlslParseContext::transformEntryPoint(const TSourceLoc& loc, TFunct
|
||||
TIntermSymbol* arg = intermediate.addSymbol(*argVars.back());
|
||||
handleFunctionArgument(&callee, callingArgs, arg);
|
||||
if (param.type->getQualifier().isParamInput()) {
|
||||
intermediate.growAggregate(synthBody, handleAssign(loc, EOpAssign, arg,
|
||||
intermediate.addSymbol(**inputIt)));
|
||||
TIntermTyped* input = intermediate.addSymbol(**inputIt);
|
||||
if (input->getType().getQualifier().builtIn == EbvFragCoord && intermediate.getDxPositionW()) {
|
||||
// Replace FragCoord W with reciprocal
|
||||
auto pos_xyz = handleDotDereference(loc, input, "xyz");
|
||||
auto pos_w = handleDotDereference(loc, input, "w");
|
||||
auto one = intermediate.addConstantUnion(1.0, EbtFloat, loc);
|
||||
auto recip_w = intermediate.addBinaryMath(EOpDiv, one, pos_w, loc);
|
||||
TIntermAggregate* dst = new TIntermAggregate(EOpConstructVec4);
|
||||
dst->getSequence().push_back(pos_xyz);
|
||||
dst->getSequence().push_back(recip_w);
|
||||
dst->setType(TType(EbtFloat, EvqTemporary, 4));
|
||||
dst->setLoc(loc);
|
||||
input = dst;
|
||||
}
|
||||
intermediate.growAggregate(synthBody, handleAssign(loc, EOpAssign, arg, input));
|
||||
inputIt++;
|
||||
}
|
||||
if (param.type->getQualifier().storage == EvqUniform) {
|
||||
|
||||
@@ -1829,6 +1829,7 @@ void TShader::setUniqueId(unsigned long long id)
|
||||
}
|
||||
|
||||
void TShader::setInvertY(bool invert) { intermediate->setInvertY(invert); }
|
||||
void TShader::setDxPositionW(bool invert) { intermediate->setDxPositionW(invert); }
|
||||
void TShader::setNanMinMaxClamp(bool useNonNan) { intermediate->setNanMinMaxClamp(useNonNan); }
|
||||
|
||||
#ifndef GLSLANG_WEB
|
||||
|
||||
@@ -312,6 +312,7 @@ void TIntermediate::mergeModes(TInfoSink& infoSink, TIntermediate& unit)
|
||||
MERGE_TRUE(autoMapBindings);
|
||||
MERGE_TRUE(autoMapLocations);
|
||||
MERGE_TRUE(invertY);
|
||||
MERGE_TRUE(dxPositionW);
|
||||
MERGE_TRUE(flattenUniformArrays);
|
||||
MERGE_TRUE(useUnknownFormat);
|
||||
MERGE_TRUE(hlslOffsets);
|
||||
|
||||
@@ -290,6 +290,7 @@ public:
|
||||
resources(TBuiltInResource{}),
|
||||
numEntryPoints(0), numErrors(0), numPushConstants(0), recursive(false),
|
||||
invertY(false),
|
||||
dxPositionW(false),
|
||||
useStorageBuffer(false),
|
||||
invariantAll(false),
|
||||
nanMinMaxClamp(false),
|
||||
@@ -460,6 +461,14 @@ public:
|
||||
}
|
||||
bool getInvertY() const { return invertY; }
|
||||
|
||||
void setDxPositionW(bool dxPosW)
|
||||
{
|
||||
dxPositionW = dxPosW;
|
||||
if (dxPositionW)
|
||||
processes.addProcess("dx-position-w");
|
||||
}
|
||||
bool getDxPositionW() const { return dxPositionW; }
|
||||
|
||||
#ifdef ENABLE_HLSL
|
||||
void setSource(EShSource s) { source = s; }
|
||||
EShSource getSource() const { return source; }
|
||||
@@ -1070,6 +1079,7 @@ protected:
|
||||
int numPushConstants;
|
||||
bool recursive;
|
||||
bool invertY;
|
||||
bool dxPositionW;
|
||||
bool useStorageBuffer;
|
||||
bool invariantAll;
|
||||
bool nanMinMaxClamp; // true if desiring min/max/clamp to favor non-NaN over NaN
|
||||
|
||||
@@ -485,6 +485,7 @@ public:
|
||||
GLSLANG_EXPORT void addUniformLocationOverride(const char* name, int loc);
|
||||
GLSLANG_EXPORT void setUniformLocationBase(int base);
|
||||
GLSLANG_EXPORT void setInvertY(bool invert);
|
||||
GLSLANG_EXPORT void setDxPositionW(bool dxPosW);
|
||||
#ifdef ENABLE_HLSL
|
||||
GLSLANG_EXPORT void setHlslIoMapping(bool hlslIoMap);
|
||||
GLSLANG_EXPORT void setFlattenUniformArrays(bool flatten);
|
||||
|
||||
Reference in New Issue
Block a user