diff options
Diffstat (limited to 'src/3rdparty/angle/src/compiler/translator/blocklayout.h')
-rw-r--r-- | src/3rdparty/angle/src/compiler/translator/blocklayout.h | 75 |
1 files changed, 58 insertions, 17 deletions
diff --git a/src/3rdparty/angle/src/compiler/translator/blocklayout.h b/src/3rdparty/angle/src/compiler/translator/blocklayout.h index dd5fe07376..2b7acf4e60 100644 --- a/src/3rdparty/angle/src/compiler/translator/blocklayout.h +++ b/src/3rdparty/angle/src/compiler/translator/blocklayout.h @@ -11,6 +11,7 @@ #define COMMON_BLOCKLAYOUT_H_ #include <cstddef> +#include <map> #include <vector> #include "angle_gl.h" @@ -24,42 +25,64 @@ struct Uniform; struct Varying; struct InterfaceBlock; -struct COMPILER_EXPORT BlockMemberInfo +struct BlockMemberInfo { - BlockMemberInfo() : offset(-1), arrayStride(-1), matrixStride(-1), isRowMajorMatrix(false) {} + BlockMemberInfo() + : offset(-1), + arrayStride(-1), + matrixStride(-1), + isRowMajorMatrix(false), + topLevelArrayStride(-1) + { + } BlockMemberInfo(int offset, int arrayStride, int matrixStride, bool isRowMajorMatrix) : offset(offset), arrayStride(arrayStride), matrixStride(matrixStride), - isRowMajorMatrix(isRowMajorMatrix) - {} + isRowMajorMatrix(isRowMajorMatrix), + topLevelArrayStride(-1) + { + } - static BlockMemberInfo getDefaultBlockInfo() + BlockMemberInfo(int offset, + int arrayStride, + int matrixStride, + bool isRowMajorMatrix, + int topLevelArrayStride) + : offset(offset), + arrayStride(arrayStride), + matrixStride(matrixStride), + isRowMajorMatrix(isRowMajorMatrix), + topLevelArrayStride(topLevelArrayStride) { - return BlockMemberInfo(-1, -1, -1, false); } + static BlockMemberInfo getDefaultBlockInfo() { return BlockMemberInfo(-1, -1, -1, false, -1); } + int offset; int arrayStride; int matrixStride; bool isRowMajorMatrix; + int topLevelArrayStride; // Only used for shader storage block members. }; -class COMPILER_EXPORT BlockLayoutEncoder +class BlockLayoutEncoder { public: BlockLayoutEncoder(); virtual ~BlockLayoutEncoder() {} - BlockMemberInfo encodeType(GLenum type, unsigned int arraySize, bool isRowMajorMatrix); + BlockMemberInfo encodeType(GLenum type, + const std::vector<unsigned int> &arraySizes, + bool isRowMajorMatrix); size_t getBlockSize() const { return mCurrentOffset * BytesPerComponent; } virtual void enterAggregateType() = 0; - virtual void exitAggregateType() = 0; + virtual void exitAggregateType() = 0; - static const size_t BytesPerComponent = 4u; + static const size_t BytesPerComponent = 4u; static const unsigned int ComponentsPerRegister = 4u; static size_t getBlockRegister(const BlockMemberInfo &info); @@ -70,14 +93,22 @@ class COMPILER_EXPORT BlockLayoutEncoder void nextRegister(); - virtual void getBlockLayoutInfo(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int *arrayStrideOut, int *matrixStrideOut) = 0; - virtual void advanceOffset(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int arrayStride, int matrixStride) = 0; + virtual void getBlockLayoutInfo(GLenum type, + const std::vector<unsigned int> &arraySizes, + bool isRowMajorMatrix, + int *arrayStrideOut, + int *matrixStrideOut) = 0; + virtual void advanceOffset(GLenum type, + const std::vector<unsigned int> &arraySizes, + bool isRowMajorMatrix, + int arrayStride, + int matrixStride) = 0; }; // Block layout according to the std140 block layout // See "Standard Uniform Block Layout" in Section 2.11.6 of the OpenGL ES 3.0 specification -class COMPILER_EXPORT Std140BlockEncoder : public BlockLayoutEncoder +class Std140BlockEncoder : public BlockLayoutEncoder { public: Std140BlockEncoder(); @@ -87,17 +118,27 @@ class COMPILER_EXPORT Std140BlockEncoder : public BlockLayoutEncoder protected: void getBlockLayoutInfo(GLenum type, - unsigned int arraySize, + const std::vector<unsigned int> &arraySizes, bool isRowMajorMatrix, int *arrayStrideOut, int *matrixStrideOut) override; void advanceOffset(GLenum type, - unsigned int arraySize, + const std::vector<unsigned int> &arraySizes, bool isRowMajorMatrix, int arrayStride, int matrixStride) override; }; -} +using BlockLayoutMap = std::map<std::string, BlockMemberInfo>; + +// Only valid to call with ShaderVariable, InterfaceBlockField and Uniform. +template <typename VarT> +void GetUniformBlockInfo(const std::vector<VarT> &fields, + const std::string &prefix, + sh::BlockLayoutEncoder *encoder, + bool inRowMajorLayout, + BlockLayoutMap *blockLayoutMap); + +} // namespace sh -#endif // COMMON_BLOCKLAYOUT_H_ +#endif // COMMON_BLOCKLAYOUT_H_ |