Support equality between structs containing arrays in HLSL output
This requires sorting all equality functions together so that struct
equality functions can have dependencies on array equality functions, but
support for array equality functions that have dependencies on struct
equality functions is also maintained.
There's no automated test coverage for this specifically. The change was
tested by manually inspecting shader output and ensuring that there were
no test regressions in tests listed below.
TEST=dEQP-GLES3.functional.shaders.*
BUG=angleproject:954
Change-Id: If7199ab2446804afae50f103bb625101172882b9
Reviewed-on: https://chromium-review.googlesource.com/261550
Reviewed-by: Olli Etuaho <oetuaho@nvidia.com>
Tested-by: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/compiler/translator/OutputHLSL.h b/src/compiler/translator/OutputHLSL.h
index 4b85580..4083376 100644
--- a/src/compiler/translator/OutputHLSL.h
+++ b/src/compiler/translator/OutputHLSL.h
@@ -186,25 +186,31 @@
// these static globals after we initialize our other globals.
std::vector<std::pair<TIntermSymbol*, TIntermTyped*>> mDeferredGlobalInitializers;
- // A list of structure equality comparison functions. It's important to preserve the order at
- // which we add the functions, since nested structures call each other recursively.
- struct StructEqualityFunction
+ struct EqualityFunction
+ {
+ TString functionName;
+ TString functionDefinition;
+
+ virtual ~EqualityFunction() {}
+ };
+
+ // A list of all equality comparison functions. It's important to preserve the order at
+ // which we add the functions, since nested structures call each other recursively, and
+ // structure equality functions may need to call array equality functions and vice versa.
+ // The ownership of the pointers is maintained by the type-specific arrays.
+ std::vector<EqualityFunction*> mEqualityFunctions;
+
+ struct StructEqualityFunction : public EqualityFunction
{
const TStructure *structure;
- TString functionName;
- TString functionDefinition;
};
+ std::vector<StructEqualityFunction*> mStructEqualityFunctions;
- std::vector<StructEqualityFunction> mStructEqualityFunctions;
-
- struct ArrayEqualityFunction
+ struct ArrayEqualityFunction : public EqualityFunction
{
TType type;
- TString functionName;
- TString functionDefinition;
};
-
- std::vector<ArrayEqualityFunction> mArrayEqualityFunctions;
+ std::vector<ArrayEqualityFunction*> mArrayEqualityFunctions;
};
}