1 // 2 // Copyright 2016 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 // TranslatorSPIRV: 7 // A set of transformations that prepare the AST to be compatible with GL_KHR_vulkan_glsl followed 8 // by a pass that generates SPIR-V. 9 // See: https://www.khronos.org/registry/vulkan/specs/misc/GL_KHR_vulkan_glsl.txt 10 // 11 12 #ifndef COMPILER_TRANSLATOR_SPIRV_TRANSLATORSPIRV_H_ 13 #define COMPILER_TRANSLATOR_SPIRV_TRANSLATORSPIRV_H_ 14 15 #include "compiler/translator/Compiler.h" 16 17 namespace sh 18 { 19 20 class TOutputVulkanGLSL; 21 class SpecConst; 22 class DriverUniform; 23 24 class TranslatorSPIRV final : public TCompiler 25 { 26 public: 27 TranslatorSPIRV(sh::GLenum type, ShShaderSpec spec); 28 29 void assignSpirvId(TSymbolUniqueId uniqueId, uint32_t spirvId); 30 31 protected: 32 [[nodiscard]] bool translate(TIntermBlock *root, 33 const ShCompileOptions &compileOptions, 34 PerformanceDiagnostics *perfDiagnostics) override; 35 bool shouldFlattenPragmaStdglInvariantAll() override; 36 37 [[nodiscard]] bool translateImpl(TIntermBlock *root, 38 const ShCompileOptions &compileOptions, 39 PerformanceDiagnostics *perfDiagnostics, 40 SpecConst *specConst, 41 DriverUniform *driverUniforms); 42 void assignSpirvIds(TIntermBlock *root); 43 44 // A map from TSymbolUniqueId::mId to SPIR-V reserved ids. Used by the SPIR-V generator to 45 // quickly know when to use a reserved id and not have to resort to name matching. 46 angle::HashMap<int, uint32_t> mUniqueToSpirvIdMap; 47 uint32_t mFirstUnusedSpirvId; 48 }; 49 50 } // namespace sh 51 52 #endif // COMPILER_TRANSLATOR_SPIRV_TRANSLATORSPIRV_H_ 53