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_HLSL_TRANSLATORHLSL_H_ 8 #define COMPILER_TRANSLATOR_HLSL_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 const std::set<std::string> *getSlowCompilingUniformBlockSet() const; 28 29 const std::map<std::string, unsigned int> *getUniformRegisterMap() const; 30 unsigned int getReadonlyImage2DRegisterIndex() const; 31 unsigned int getImage2DRegisterIndex() const; 32 const std::set<std::string> *getUsedImage2DFunctionNames() const; 33 34 protected: 35 [[nodiscard]] bool translate(TIntermBlock *root, 36 const ShCompileOptions &compileOptions, 37 PerformanceDiagnostics *perfDiagnostics) override; 38 bool shouldFlattenPragmaStdglInvariantAll() override; 39 40 std::map<std::string, unsigned int> mShaderStorageBlockRegisterMap; 41 std::map<std::string, unsigned int> mUniformBlockRegisterMap; 42 std::map<std::string, bool> mUniformBlockUseStructuredBufferMap; 43 std::map<std::string, unsigned int> mUniformRegisterMap; 44 unsigned int mReadonlyImage2DRegisterIndex; 45 unsigned int mImage2DRegisterIndex; 46 std::set<std::string> mUsedImage2DFunctionNames; 47 std::map<int, const TInterfaceBlock *> mUniformBlockOptimizedMap; 48 std::set<std::string> mSlowCompilingUniformBlockSet; 49 }; 50 51 } // namespace sh 52 53 #endif // COMPILER_TRANSLATOR_HLSL_TRANSLATORHLSL_H_ 54