webkit  2cdf99a9e3038c7e01b3c37e8ad903ecbe5eecf1
https://github.com/WebKit/webkit
blocklayoutHLSL.h
Go to the documentation of this file.
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_BLOCKLAYOUTHLSL_H_
11 #define COMMON_BLOCKLAYOUTHLSL_H_
12 
13 #include <cstddef>
14 #include <vector>
15 
16 #include "angle_gl.h"
17 #include "blocklayout.h"
18 #include <GLSLANG/ShaderLang.h>
19 
20 namespace sh
21 {
22 // Block layout packed according to the D3D9 or default D3D10+ register packing rules
23 // See http://msdn.microsoft.com/en-us/library/windows/desktop/bb509632(v=vs.85).aspx
24 // The strategy should be ENCODE_LOOSE for D3D9 constant blocks, and ENCODE_PACKED
25 // for everything else (D3D10+ constant blocks and all attributes/varyings).
26 
28 {
29  public:
31  {
33  ENCODE_LOOSE
34  };
35 
37 
38  virtual void enterAggregateType();
39  virtual void exitAggregateType();
40  void skipRegisters(unsigned int numRegisters);
41 
42  bool isPacked() const { return mEncoderStrategy == ENCODE_PACKED; }
43  void setTransposeMatrices(bool enabled) { mTransposeMatrices = enabled; }
44 
45  static HLSLBlockEncoderStrategy GetStrategyFor(ShShaderOutput outputType);
46 
47  protected:
48  virtual void getBlockLayoutInfo(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int *arrayStrideOut, int *matrixStrideOut);
49  virtual void advanceOffset(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int arrayStride, int matrixStride);
50 
53 };
54 
55 // This method returns the number of used registers for a ShaderVariable. It is dependent on the HLSLBlockEncoder
56 // class to count the number of used registers in a struct (which are individually packed according to the same rules).
57 COMPILER_EXPORT unsigned int HLSLVariableRegisterCount(const Varying &variable, bool transposeMatrices);
58 COMPILER_EXPORT unsigned int HLSLVariableRegisterCount(const Uniform &variable, ShShaderOutput outputType);
59 
60 }
61 
62 #endif // COMMON_BLOCKLAYOUTHLSL_H_
#define COMPILER_EXPORT
Definition: ShaderLang.h:23
Definition: blocklayoutHLSL.h:32
bool isPacked() const
Definition: blocklayoutHLSL.h:42
HLSLBlockEncoderStrategy mEncoderStrategy
Definition: blocklayoutHLSL.h:51
GLenum GLenum GLsizei const GLuint GLboolean enabled
Definition: gl2ext.h:133
void setTransposeMatrices(bool enabled)
Definition: blocklayoutHLSL.h:43
Definition: ShaderLang.h:40
HLSLBlockEncoderStrategy
Definition: blocklayoutHLSL.h:30
Definition: blocklayout.h:49
Definition: blocklayoutHLSL.h:27
EGLenum type
Definition: eglext.h:63
unsigned int GLenum
Definition: ShaderLang.h:43
void HLSLVariableRegisterCount(const ShaderVarType &variable, HLSLBlockEncoder *encoder)
Definition: blocklayoutHLSL.cpp:128
Definition: ShaderVars.h:170
bool mTransposeMatrices
Definition: blocklayoutHLSL.h:52
Definition: ShaderVars.h:95
ShShaderOutput
Definition: ShaderLang.h:66