Commit 03e63fa8 by John Kessenich

HLSL: Add fall-back for opaque initializers to just generate long-term expected code.

This generated code needs an optimization pass to eliminate the assignments to the opaque members.
parent 25495fdf
...@@ -6,8 +6,17 @@ float4 lookUp(FxaaTex tex) ...@@ -6,8 +6,17 @@ float4 lookUp(FxaaTex tex)
return tex.tex.Sample(tex.smpl, float2(0.3, 0.4)); return tex.tex.Sample(tex.smpl, float2(0.3, 0.4));
} }
FxaaTex fillOpaque()
{
FxaaTex t;
t.smpl = g_tInputTexture_sampler;
t.tex = g_tInputTexture;
return t;
}
float4 main() : SV_TARGET0 float4 main() : SV_TARGET0
{ {
FxaaTex tex = { g_tInputTexture_sampler, g_tInputTexture }; FxaaTex tex1 = { g_tInputTexture_sampler, g_tInputTexture };
return lookUp(tex); FxaaTex tex2 = fillOpaque();
return lookUp(tex1);
} }
\ No newline at end of file
...@@ -2416,17 +2416,23 @@ TIntermAggregate* HlslParseContext::assignClipCullDistance(const TSourceLoc& loc ...@@ -2416,17 +2416,23 @@ TIntermAggregate* HlslParseContext::assignClipCullDistance(const TSourceLoc& loc
// and possibly contains opaque values, such that the initializer should never exist // and possibly contains opaque values, such that the initializer should never exist
// as emitted code, because even creating the initializer would write opaques. // as emitted code, because even creating the initializer would write opaques.
// //
// Decompose this into individual member-wise assignments, which themselves are // If possible, decompose this into individual member-wise assignments, which themselves
// expected to then not exist for opaque types, because they will turn into aliases. // are expected to then not exist for opaque types, because they will turn into aliases.
// //
// Return a node that contains the non-aliased assignments that must continue to exist. // Return a node that contains the non-aliased assignments that must continue to exist.
TIntermAggregate* HlslParseContext::executeFlattenedInitializer(const TSourceLoc& loc, TIntermSymbol* symbol, TIntermTyped* HlslParseContext::executeFlattenedInitializer(const TSourceLoc& loc, TIntermSymbol* symbol,
const TIntermAggregate& initializer) TIntermAggregate& initializer)
{ {
// We need individual RHS initializers per member to do this
const TTypeList* typeList = symbol->getType().getStruct();
if (typeList == nullptr || initializer.getSequence().size() != typeList->size()) {
warn(loc, "cannot do member-wise aliasing for opaque members with this initializer", "=", "");
return handleAssign(loc, EOpAssign, symbol, &initializer);
}
TIntermAggregate* initList = nullptr; TIntermAggregate* initList = nullptr;
// synthesize an access to each member, and then an assignment to it // synthesize an access to each member, and then an assignment to it
const TTypeList& typeList = *symbol->getType().getStruct(); for (int member = 0; member < (int)typeList->size(); ++member) {
for (int member = 0; member < (int)typeList.size(); ++member) {
TIntermTyped* memberInitializer = initializer.getSequence()[member]->getAsTyped(); TIntermTyped* memberInitializer = initializer.getSequence()[member]->getAsTyped();
TIntermTyped* flattenedMember = flattenAccess(symbol, member); TIntermTyped* flattenedMember = flattenAccess(symbol, member);
if (flattenedMember->getType().containsOpaque()) if (flattenedMember->getType().containsOpaque())
......
...@@ -89,7 +89,7 @@ public: ...@@ -89,7 +89,7 @@ public:
void remapNonEntryPointIO(TFunction& function); void remapNonEntryPointIO(TFunction& function);
TIntermNode* handleReturnValue(const TSourceLoc&, TIntermTyped*); TIntermNode* handleReturnValue(const TSourceLoc&, TIntermTyped*);
void handleFunctionArgument(TFunction*, TIntermTyped*& arguments, TIntermTyped* newArg); void handleFunctionArgument(TFunction*, TIntermTyped*& arguments, TIntermTyped* newArg);
TIntermAggregate* executeFlattenedInitializer(const TSourceLoc&, TIntermSymbol*, const TIntermAggregate&); TIntermTyped* executeFlattenedInitializer(const TSourceLoc&, TIntermSymbol*, TIntermAggregate&);
TIntermTyped* handleAssign(const TSourceLoc&, TOperator, TIntermTyped* left, TIntermTyped* right); TIntermTyped* handleAssign(const TSourceLoc&, TOperator, TIntermTyped* left, TIntermTyped* right);
TIntermTyped* handleAssignToMatrixSwizzle(const TSourceLoc&, TOperator, TIntermTyped* left, TIntermTyped* right); TIntermTyped* handleAssignToMatrixSwizzle(const TSourceLoc&, TOperator, TIntermTyped* left, TIntermTyped* right);
TIntermTyped* handleFunctionCall(const TSourceLoc&, TFunction*, TIntermTyped*); TIntermTyped* handleFunctionCall(const TSourceLoc&, TFunction*, TIntermTyped*);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment