Line data Source code
1 : //
2 : // Copyright (c) 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 : // UniformHLSL.h:
7 : // Methods for GLSL to HLSL translation for uniforms and interface blocks.
8 : //
9 :
10 : #ifndef COMPILER_TRANSLATOR_UNIFORMHLSL_H_
11 : #define COMPILER_TRANSLATOR_UNIFORMHLSL_H_
12 :
13 : #include "compiler/translator/OutputHLSL.h"
14 : #include "compiler/translator/UtilsHLSL.h"
15 :
16 : namespace sh
17 : {
18 : class StructureHLSL;
19 :
20 0 : class UniformHLSL : angle::NonCopyable
21 : {
22 : public:
23 : UniformHLSL(StructureHLSL *structureHLSL, ShShaderOutput outputType, const std::vector<Uniform> &uniforms);
24 :
25 : void reserveUniformRegisters(unsigned int registerCount);
26 : void reserveInterfaceBlockRegisters(unsigned int registerCount);
27 : void uniformsHeader(TInfoSinkBase &out,
28 : ShShaderOutput outputType,
29 : const ReferencedSymbols &referencedUniforms);
30 :
31 : // Must be called after uniformsHeader
32 : void samplerMetadataUniforms(TInfoSinkBase &out, const char *reg);
33 :
34 : TString interfaceBlocksHeader(const ReferencedSymbols &referencedInterfaceBlocks);
35 :
36 : // Used for direct index references
37 : static TString interfaceBlockInstanceString(const TInterfaceBlock& interfaceBlock, unsigned int arrayIndex);
38 :
39 0 : const std::map<std::string, unsigned int> &getInterfaceBlockRegisterMap() const
40 : {
41 0 : return mInterfaceBlockRegisterMap;
42 : }
43 0 : const std::map<std::string, unsigned int> &getUniformRegisterMap() const
44 : {
45 0 : return mUniformRegisterMap;
46 : }
47 :
48 : private:
49 : TString interfaceBlockString(const TInterfaceBlock &interfaceBlock, unsigned int registerIndex, unsigned int arrayIndex);
50 : TString interfaceBlockMembersString(const TInterfaceBlock &interfaceBlock, TLayoutBlockStorage blockStorage);
51 : TString interfaceBlockStructString(const TInterfaceBlock &interfaceBlock);
52 : const Uniform *findUniformByName(const TString &name) const;
53 :
54 : void outputHLSL4_0_FL9_3Sampler(TInfoSinkBase &out,
55 : const TType &type,
56 : const TName &name,
57 : const unsigned int registerIndex);
58 :
59 : void outputUniform(TInfoSinkBase &out,
60 : const TType &type,
61 : const TName &name,
62 : const unsigned int registerIndex);
63 :
64 : // Returns the uniform's register index
65 : unsigned int assignUniformRegister(const TType &type,
66 : const TString &name,
67 : unsigned int *outRegisterCount);
68 : unsigned int assignSamplerInStructUniformRegister(const TType &type,
69 : const TString &name,
70 : unsigned int *outRegisterCount);
71 :
72 : void outputHLSLSamplerUniformGroup(
73 : TInfoSinkBase &out,
74 : const HLSLTextureSamplerGroup textureGroup,
75 : const TVector<const TIntermSymbol *> &group,
76 : const TMap<const TIntermSymbol *, TString> &samplerInStructSymbolsToAPINames,
77 : unsigned int *groupTextureRegisterIndex);
78 :
79 : unsigned int mUniformRegister;
80 : unsigned int mInterfaceBlockRegister;
81 : unsigned int mSamplerRegister;
82 : StructureHLSL *mStructureHLSL;
83 : ShShaderOutput mOutputType;
84 :
85 : const std::vector<Uniform> &mUniforms;
86 : std::map<std::string, unsigned int> mInterfaceBlockRegisterMap;
87 : std::map<std::string, unsigned int> mUniformRegisterMap;
88 : };
89 :
90 : }
91 :
92 : #endif // COMPILER_TRANSLATOR_UNIFORMHLSL_H_
|