chromium/third_party/angle/src/compiler/translator/spirv/TranslatorSPIRV.cpp

//
// 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.
//
// TranslatorSPIRV:
//   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
//

#include "compiler/translator/spirv/TranslatorSPIRV.h"

#include "angle_gl.h"
#include "common/PackedEnums.h"
#include "common/utilities.h"
#include "compiler/translator/ImmutableStringBuilder.h"
#include "compiler/translator/IntermNode.h"
#include "compiler/translator/StaticType.h"
#include "compiler/translator/spirv/BuiltinsWorkaround.h"
#include "compiler/translator/spirv/OutputSPIRV.h"
#include "compiler/translator/tree_ops/DeclarePerVertexBlocks.h"
#include "compiler/translator/tree_ops/MonomorphizeUnsupportedFunctions.h"
#include "compiler/translator/tree_ops/RecordConstantPrecision.h"
#include "compiler/translator/tree_ops/RemoveAtomicCounterBuiltins.h"
#include "compiler/translator/tree_ops/RemoveInactiveInterfaceVariables.h"
#include "compiler/translator/tree_ops/RewriteArrayOfArrayOfOpaqueUniforms.h"
#include "compiler/translator/tree_ops/RewriteAtomicCounters.h"
#include "compiler/translator/tree_ops/RewriteDfdy.h"
#include "compiler/translator/tree_ops/RewriteStructSamplers.h"
#include "compiler/translator/tree_ops/SeparateStructFromUniformDeclarations.h"
#include "compiler/translator/tree_ops/spirv/EmulateAdvancedBlendEquations.h"
#include "compiler/translator/tree_ops/spirv/EmulateDithering.h"
#include "compiler/translator/tree_ops/spirv/EmulateFragColorData.h"
#include "compiler/translator/tree_ops/spirv/EmulateFramebufferFetch.h"
#include "compiler/translator/tree_ops/spirv/EmulateYUVBuiltIns.h"
#include "compiler/translator/tree_ops/spirv/FlagSamplersWithTexelFetch.h"
#include "compiler/translator/tree_ops/spirv/ReswizzleYUVOps.h"
#include "compiler/translator/tree_ops/spirv/RewriteInterpolateAtOffset.h"
#include "compiler/translator/tree_ops/spirv/RewriteR32fImages.h"
#include "compiler/translator/tree_util/BuiltIn.h"
#include "compiler/translator/tree_util/DriverUniform.h"
#include "compiler/translator/tree_util/FindFunction.h"
#include "compiler/translator/tree_util/FindMain.h"
#include "compiler/translator/tree_util/FindSymbolNode.h"
#include "compiler/translator/tree_util/IntermNode_util.h"
#include "compiler/translator/tree_util/ReplaceClipCullDistanceVariable.h"
#include "compiler/translator/tree_util/ReplaceVariable.h"
#include "compiler/translator/tree_util/RewriteSampleMaskVariable.h"
#include "compiler/translator/tree_util/RunAtTheBeginningOfShader.h"
#include "compiler/translator/tree_util/RunAtTheEndOfShader.h"
#include "compiler/translator/tree_util/SpecializationConstant.h"
#include "compiler/translator/util.h"

namespace sh
{

namespace
{
constexpr ImmutableString kFlippedPointCoordName    =;
constexpr ImmutableString kFlippedFragCoordName     =;
constexpr ImmutableString kDefaultUniformsBlockName =;

bool IsDefaultUniform(const TType &type)
{}

class ReplaceDefaultUniformsTraverser : public TIntermTraverser
{};

bool DeclareDefaultUniforms(TranslatorSPIRV *compiler,
                            TIntermBlock *root,
                            TSymbolTable *symbolTable,
                            gl::ShaderType shaderType)
{}

// Replaces a builtin variable with a version that is rotated and corrects the X and Y coordinates.
[[nodiscard]] bool RotateAndFlipBuiltinVariable(TCompiler *compiler,
                                                TIntermBlock *root,
                                                TIntermSequence *insertSequence,
                                                TIntermTyped *swapXY,
                                                TIntermTyped *flipXY,
                                                TSymbolTable *symbolTable,
                                                const TVariable *builtin,
                                                const ImmutableString &flippedVariableName,
                                                TIntermTyped *pivot)
{}

TIntermSequence *GetMainSequence(TIntermBlock *root)
{}

// Declares a new variable to replace gl_DepthRange, its values are fed from a driver uniform.
[[nodiscard]] bool ReplaceGLDepthRangeWithDriverUniform(TCompiler *compiler,
                                                        TIntermBlock *root,
                                                        const DriverUniform *driverUniforms,
                                                        TSymbolTable *symbolTable)
{}

// Declares a new variable to replace gl_BoundingBoxEXT, its values are fed from a global temporary
// variable.
[[nodiscard]] bool ReplaceGLBoundingBoxWithGlobal(TCompiler *compiler,
                                                  TIntermBlock *root,
                                                  TSymbolTable *symbolTable,
                                                  int shaderVersion)
{}

[[nodiscard]] bool AddXfbEmulationSupport(TranslatorSPIRV *compiler,
                                          TIntermBlock *root,
                                          TSymbolTable *symbolTable,
                                          const DriverUniform *driverUniforms)
{}

[[nodiscard]] bool AddXfbExtensionSupport(TranslatorSPIRV *compiler,
                                          TIntermBlock *root,
                                          TSymbolTable *symbolTable,
                                          const DriverUniform *driverUniforms)
{}

[[nodiscard]] bool AddVertexTransformationSupport(TranslatorSPIRV *compiler,
                                                  const ShCompileOptions &compileOptions,
                                                  TIntermBlock *root,
                                                  TSymbolTable *symbolTable,
                                                  SpecConst *specConst,
                                                  const DriverUniform *driverUniforms)
{}

[[nodiscard]] bool InsertFragCoordCorrection(TCompiler *compiler,
                                             const ShCompileOptions &compileOptions,
                                             TIntermBlock *root,
                                             TIntermSequence *insertSequence,
                                             TSymbolTable *symbolTable,
                                             SpecConst *specConst,
                                             const DriverUniform *driverUniforms)
{}

bool HasFramebufferFetch(const TExtensionBehavior &extBehavior,
                         const ShCompileOptions &compileOptions)
{}

template <typename Variable>
Variable *FindShaderVariable(std::vector<Variable> *vars, const ImmutableString &name)
{}

ShaderVariable *FindIOBlockShaderVariable(std::vector<ShaderVariable> *vars,
                                          const ImmutableString &name)
{}

ShaderVariable *FindUniformFieldShaderVariable(std::vector<ShaderVariable> *vars,
                                               const ImmutableString &name,
                                               const char *prefix)
{}

ShaderVariable *FindUniformShaderVariable(std::vector<ShaderVariable> *vars,
                                          const ImmutableString &name)
{}

void SetSpirvIdInFields(uint32_t id, std::vector<ShaderVariable> *fields)
{}
}  // anonymous namespace

TranslatorSPIRV::TranslatorSPIRV(sh::GLenum type, ShShaderSpec spec)
    :{}

bool TranslatorSPIRV::translateImpl(TIntermBlock *root,
                                    const ShCompileOptions &compileOptions,
                                    PerformanceDiagnostics * /*perfDiagnostics*/,
                                    SpecConst *specConst,
                                    DriverUniform *driverUniforms)
{}

bool TranslatorSPIRV::translate(TIntermBlock *root,
                                const ShCompileOptions &compileOptions,
                                PerformanceDiagnostics *perfDiagnostics)
{}

bool TranslatorSPIRV::shouldFlattenPragmaStdglInvariantAll()
{}

void TranslatorSPIRV::assignSpirvId(TSymbolUniqueId uniqueId, uint32_t spirvId)
{}

void TranslatorSPIRV::assignInputAttachmentIds(const InputAttachmentMap &inputAttachmentMap)
{}

void TranslatorSPIRV::assignSpirvIds(TIntermBlock *root)
{}
}  // namespace sh