1 // 2 // Copyright 2002 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 7 #ifndef COMPILER_TRANSLATOR_TRANSLATORHLSL_H_ 8 #define COMPILER_TRANSLATOR_TRANSLATORHLSL_H_ 9 10 #include "compiler/translator/Compiler.h" 11 12 namespace sh 13 { 14 15 class TranslatorHLSL : public TCompiler 16 { 17 public: 18 TranslatorHLSL(sh::GLenum type, ShShaderSpec spec, ShShaderOutput output); getAsTranslatorHLSL()19 TranslatorHLSL *getAsTranslatorHLSL() override { return this; } 20 21 bool hasShaderStorageBlock(const std::string &interfaceBlockName) const; 22 unsigned int getShaderStorageBlockRegister(const std::string &interfaceBlockName) const; 23 24 bool hasUniformBlock(const std::string &interfaceBlockName) const; 25 unsigned int getUniformBlockRegister(const std::string &interfaceBlockName) const; 26 bool shouldUniformBlockUseStructuredBuffer(const std::string &uniformBlockName) const; 27 28 const std::map<std::string, unsigned int> *getUniformRegisterMap() const; 29 unsigned int getReadonlyImage2DRegisterIndex() const; 30 unsigned int getImage2DRegisterIndex() const; 31 const std::set<std::string> *getUsedImage2DFunctionNames() const; 32 33 protected: 34 ANGLE_NO_DISCARD bool translate(TIntermBlock *root, 35 ShCompileOptions compileOptions, 36 PerformanceDiagnostics *perfDiagnostics) override; 37 bool shouldFlattenPragmaStdglInvariantAll() override; 38 39 // collectVariables needs to be run always so registers can be assigned. shouldCollectVariables(ShCompileOptions compileOptions)40 bool shouldCollectVariables(ShCompileOptions compileOptions) override { return true; } 41 42 std::map<std::string, unsigned int> mShaderStorageBlockRegisterMap; 43 std::map<std::string, unsigned int> mUniformBlockRegisterMap; 44 std::map<std::string, bool> mUniformBlockUseStructuredBufferMap; 45 std::map<std::string, unsigned int> mUniformRegisterMap; 46 unsigned int mReadonlyImage2DRegisterIndex; 47 unsigned int mImage2DRegisterIndex; 48 std::set<std::string> mUsedImage2DFunctionNames; 49 std::map<int, const TInterfaceBlock *> mUniformBlocksTranslatedToStructuredBuffers; 50 }; 51 52 } // namespace sh 53 54 #endif // COMPILER_TRANSLATOR_TRANSLATORHLSL_H_ 55