diff options
Diffstat (limited to 'src/3rdparty/angle/src/compiler/translator/blocklayoutHLSL.cpp')
-rw-r--r-- | src/3rdparty/angle/src/compiler/translator/blocklayoutHLSL.cpp | 63 |
1 files changed, 29 insertions, 34 deletions
diff --git a/src/3rdparty/angle/src/compiler/translator/blocklayoutHLSL.cpp b/src/3rdparty/angle/src/compiler/translator/blocklayoutHLSL.cpp index 43119248eb..867821f1ea 100644 --- a/src/3rdparty/angle/src/compiler/translator/blocklayoutHLSL.cpp +++ b/src/3rdparty/angle/src/compiler/translator/blocklayoutHLSL.cpp @@ -15,9 +15,8 @@ namespace sh { -HLSLBlockEncoder::HLSLBlockEncoder(HLSLBlockEncoderStrategy strategy) - : mEncoderStrategy(strategy), - mTransposeMatrices(false) +HLSLBlockEncoder::HLSLBlockEncoder(HLSLBlockEncoderStrategy strategy, bool transposeMatrices) + : mEncoderStrategy(strategy), mTransposeMatrices(transposeMatrices) { } @@ -30,7 +29,11 @@ void HLSLBlockEncoder::exitAggregateType() { } -void HLSLBlockEncoder::getBlockLayoutInfo(GLenum typeIn, unsigned int arraySize, bool isRowMajorMatrix, int *arrayStrideOut, int *matrixStrideOut) +void HLSLBlockEncoder::getBlockLayoutInfo(GLenum typeIn, + const std::vector<unsigned int> &arraySizes, + bool isRowMajorMatrix, + int *arrayStrideOut, + int *matrixStrideOut) { GLenum type = (mTransposeMatrices ? gl::TransposeMatrixType(typeIn) : typeIn); @@ -38,14 +41,12 @@ void HLSLBlockEncoder::getBlockLayoutInfo(GLenum typeIn, unsigned int arraySize, ASSERT(gl::VariableComponentSize(gl::VariableComponentType(type)) == BytesPerComponent); int matrixStride = 0; - int arrayStride = 0; + int arrayStride = 0; // if variables are not to be packed, or we're about to // pack a matrix or array, skip to the start of the next // register - if (!isPacked() || - gl::IsMatrixType(type) || - arraySize > 0) + if (!isPacked() || gl::IsMatrixType(type) || !arraySizes.empty()) { nextRegister(); } @@ -54,13 +55,13 @@ void HLSLBlockEncoder::getBlockLayoutInfo(GLenum typeIn, unsigned int arraySize, { matrixStride = ComponentsPerRegister; - if (arraySize > 0) + if (!arraySizes.empty()) { const int numRegisters = gl::MatrixRegisterCount(type, isRowMajorMatrix); - arrayStride = ComponentsPerRegister * numRegisters; + arrayStride = ComponentsPerRegister * numRegisters; } } - else if (arraySize > 0) + else if (!arraySizes.empty()) { arrayStride = ComponentsPerRegister; } @@ -74,22 +75,26 @@ void HLSLBlockEncoder::getBlockLayoutInfo(GLenum typeIn, unsigned int arraySize, } *matrixStrideOut = matrixStride; - *arrayStrideOut = arrayStride; + *arrayStrideOut = arrayStride; } -void HLSLBlockEncoder::advanceOffset(GLenum typeIn, unsigned int arraySize, bool isRowMajorMatrix, int arrayStride, int matrixStride) +void HLSLBlockEncoder::advanceOffset(GLenum typeIn, + const std::vector<unsigned int> &arraySizes, + bool isRowMajorMatrix, + int arrayStride, + int matrixStride) { GLenum type = (mTransposeMatrices ? gl::TransposeMatrixType(typeIn) : typeIn); - if (arraySize > 0) + if (!arraySizes.empty()) { - mCurrentOffset += arrayStride * (arraySize - 1); + mCurrentOffset += arrayStride * (gl::ArraySizeProduct(arraySizes) - 1); } if (gl::IsMatrixType(type)) { ASSERT(matrixStride == ComponentsPerRegister); - const int numRegisters = gl::MatrixRegisterCount(type, isRowMajorMatrix); + const int numRegisters = gl::MatrixRegisterCount(type, isRowMajorMatrix); const int numComponents = gl::MatrixComponentCount(type, isRowMajorMatrix); mCurrentOffset += ComponentsPerRegister * (numRegisters - 1); mCurrentOffset += numComponents; @@ -109,7 +114,8 @@ void HLSLBlockEncoder::skipRegisters(unsigned int numRegisters) mCurrentOffset += (numRegisters * ComponentsPerRegister); } -HLSLBlockEncoder::HLSLBlockEncoderStrategy HLSLBlockEncoder::GetStrategyFor(ShShaderOutput outputType) +HLSLBlockEncoder::HLSLBlockEncoderStrategy HLSLBlockEncoder::GetStrategyFor( + ShShaderOutput outputType) { switch (outputType) { @@ -129,7 +135,7 @@ void HLSLVariableRegisterCount(const ShaderVarType &variable, HLSLBlockEncoder * { if (variable.isStruct()) { - for (size_t arrayElement = 0; arrayElement < variable.elementCount(); arrayElement++) + for (size_t arrayElement = 0; arrayElement < variable.getArraySizeProduct(); arrayElement++) { encoder->enterAggregateType(); @@ -144,28 +150,17 @@ void HLSLVariableRegisterCount(const ShaderVarType &variable, HLSLBlockEncoder * else { // We operate only on varyings and uniforms, which do not have matrix layout qualifiers - encoder->encodeType(variable.type, variable.arraySize, false); + encoder->encodeType(variable.type, variable.arraySizes, false); } } -unsigned int HLSLVariableRegisterCount(const Varying &variable, bool transposeMatrices) -{ - HLSLBlockEncoder encoder(HLSLBlockEncoder::ENCODE_PACKED); - encoder.setTransposeMatrices(transposeMatrices); - HLSLVariableRegisterCount(variable, &encoder); - - const size_t registerBytes = (encoder.BytesPerComponent * encoder.ComponentsPerRegister); - return static_cast<unsigned int>(rx::roundUp<size_t>(encoder.getBlockSize(), registerBytes) / registerBytes); -} - unsigned int HLSLVariableRegisterCount(const Uniform &variable, ShShaderOutput outputType) { - HLSLBlockEncoder encoder(HLSLBlockEncoder::GetStrategyFor(outputType)); - encoder.setTransposeMatrices(true); + HLSLBlockEncoder encoder(HLSLBlockEncoder::GetStrategyFor(outputType), true); HLSLVariableRegisterCount(variable, &encoder); const size_t registerBytes = (encoder.BytesPerComponent * encoder.ComponentsPerRegister); - return static_cast<unsigned int>(rx::roundUp<size_t>(encoder.getBlockSize(), registerBytes) / registerBytes); -} - + return static_cast<unsigned int>(rx::roundUp<size_t>(encoder.getBlockSize(), registerBytes) / + registerBytes); } +} // namespace sh |