Hash :
10380f4b
Author :
Date :
2023-06-06T11:52:08
Vulkan: Output SPIR-V ids from compiler In this change, the shader interface variables are given SPIR-V ids by the compiler before SPIR-V generation. Those ids are made available through the ShaderVariable interface. The transformer does not yet rely on this information. A follow up change will rework the backend's name->info map and the transformer to directly use ids instead of names. Bug: angleproject:7220 Change-Id: Ic0a62681d4bcf3ed171c39c3ecd83e438ea068c8 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4600609 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Roman Lavrov <romanl@google.com> Reviewed-by: Yuxin Hu <yuxinhu@google.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
//
// Copyright 2016 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// TranslatorVulkan:
// A set of transformations that prepare the AST to be compatible with GL_KHR_vulkan_glsl followed
// by a pass that generates SPIR-V.
// See: https://www.khronos.org/registry/vulkan/specs/misc/GL_KHR_vulkan_glsl.txt
//
#ifndef COMPILER_TRANSLATOR_TRANSLATORVULKAN_H_
#define COMPILER_TRANSLATOR_TRANSLATORVULKAN_H_
#include "compiler/translator/Compiler.h"
namespace sh
{
class TOutputVulkanGLSL;
class SpecConst;
class DriverUniform;
class TranslatorVulkan final : public TCompiler
{
public:
TranslatorVulkan(sh::GLenum type, ShShaderSpec spec);
void assignSpirvId(TSymbolUniqueId uniqueId, uint32_t spirvId);
protected:
[[nodiscard]] bool translate(TIntermBlock *root,
const ShCompileOptions &compileOptions,
PerformanceDiagnostics *perfDiagnostics) override;
bool shouldFlattenPragmaStdglInvariantAll() override;
[[nodiscard]] bool translateImpl(TIntermBlock *root,
const ShCompileOptions &compileOptions,
PerformanceDiagnostics *perfDiagnostics,
SpecConst *specConst,
DriverUniform *driverUniforms);
void assignSpirvIds(TIntermBlock *root);
// A map from TSymbolUniqueId::mId to SPIR-V reserved ids. Used by the SPIR-V generator to
// quickly know when to use a reserved id and not have to resort to name matching.
angle::HashMap<int, uint32_t> mUniqueToSpirvIdMap;
uint32_t mFirstUnusedSpirvId;
};
} // namespace sh
#endif // COMPILER_TRANSLATOR_TRANSLATORVULKAN_H_