#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)
{ … }
[[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)
{ … }
[[nodiscard]] bool ReplaceGLDepthRangeWithDriverUniform(TCompiler *compiler,
TIntermBlock *root,
const DriverUniform *driverUniforms,
TSymbolTable *symbolTable)
{ … }
[[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)
{ … }
}
TranslatorSPIRV::TranslatorSPIRV(sh::GLenum type, ShShaderSpec spec)
: … { … }
bool TranslatorSPIRV::translateImpl(TIntermBlock *root,
const ShCompileOptions &compileOptions,
PerformanceDiagnostics * ,
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)
{ … }
}