LCOV - code coverage report
Current view: top level - gfx/angle/src/compiler/translator - blocklayout.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 7 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 6 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //
       2             : // Copyright (c) 2013-2014 The ANGLE Project Authors. All rights reserved.
       3             : // Use of this source code is governed by a BSD-style license that can be
       4             : // found in the LICENSE file.
       5             : //
       6             : // blocklayout.h:
       7             : //   Methods and classes related to uniform layout and packing in GLSL and HLSL.
       8             : //
       9             : 
      10             : #ifndef COMMON_BLOCKLAYOUT_H_
      11             : #define COMMON_BLOCKLAYOUT_H_
      12             : 
      13             : #include <cstddef>
      14             : #include <vector>
      15             : 
      16             : #include "angle_gl.h"
      17             : #include <GLSLANG/ShaderLang.h>
      18             : 
      19             : namespace sh
      20             : {
      21             : struct ShaderVariable;
      22             : struct InterfaceBlockField;
      23             : struct Uniform;
      24             : struct Varying;
      25             : struct InterfaceBlock;
      26             : 
      27             : struct BlockMemberInfo
      28             : {
      29             :     BlockMemberInfo() : offset(-1), arrayStride(-1), matrixStride(-1), isRowMajorMatrix(false) {}
      30             : 
      31           0 :     BlockMemberInfo(int offset, int arrayStride, int matrixStride, bool isRowMajorMatrix)
      32           0 :         : offset(offset),
      33             :           arrayStride(arrayStride),
      34             :           matrixStride(matrixStride),
      35           0 :           isRowMajorMatrix(isRowMajorMatrix)
      36           0 :     {}
      37             : 
      38             :     static BlockMemberInfo getDefaultBlockInfo()
      39             :     {
      40             :         return BlockMemberInfo(-1, -1, -1, false);
      41             :     }
      42             : 
      43             :     int offset;
      44             :     int arrayStride;
      45             :     int matrixStride;
      46             :     bool isRowMajorMatrix;
      47             : };
      48             : 
      49             : class BlockLayoutEncoder
      50             : {
      51             :   public:
      52             :     BlockLayoutEncoder();
      53           0 :     virtual ~BlockLayoutEncoder() {}
      54             : 
      55             :     BlockMemberInfo encodeType(GLenum type, unsigned int arraySize, bool isRowMajorMatrix);
      56             : 
      57           0 :     size_t getBlockSize() const { return mCurrentOffset * BytesPerComponent; }
      58             : 
      59             :     virtual void enterAggregateType() = 0;
      60             :     virtual void exitAggregateType() = 0;
      61             : 
      62             :     static const size_t BytesPerComponent = 4u;
      63             :     static const unsigned int ComponentsPerRegister = 4u;
      64             : 
      65             :     static size_t getBlockRegister(const BlockMemberInfo &info);
      66             :     static size_t getBlockRegisterElement(const BlockMemberInfo &info);
      67             : 
      68             :   protected:
      69             :     size_t mCurrentOffset;
      70             : 
      71             :     void nextRegister();
      72             : 
      73             :     virtual void getBlockLayoutInfo(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int *arrayStrideOut, int *matrixStrideOut) = 0;
      74             :     virtual void advanceOffset(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int arrayStride, int matrixStride) = 0;
      75             : };
      76             : 
      77             : // Block layout according to the std140 block layout
      78             : // See "Standard Uniform Block Layout" in Section 2.11.6 of the OpenGL ES 3.0 specification
      79             : 
      80           0 : class Std140BlockEncoder : public BlockLayoutEncoder
      81             : {
      82             :   public:
      83             :     Std140BlockEncoder();
      84             : 
      85             :     void enterAggregateType() override;
      86             :     void exitAggregateType() override;
      87             : 
      88             :   protected:
      89             :     void getBlockLayoutInfo(GLenum type,
      90             :                             unsigned int arraySize,
      91             :                             bool isRowMajorMatrix,
      92             :                             int *arrayStrideOut,
      93             :                             int *matrixStrideOut) override;
      94             :     void advanceOffset(GLenum type,
      95             :                        unsigned int arraySize,
      96             :                        bool isRowMajorMatrix,
      97             :                        int arrayStride,
      98             :                        int matrixStride) override;
      99             : };
     100             : 
     101             : }
     102             : 
     103             : #endif // COMMON_BLOCKLAYOUT_H_

Generated by: LCOV version 1.13