Hash :
47c66901
Author :
Date :
2024-10-21T12:47:22
Vulkan: Set gl_Layer to 0 if the framebuffer is not layered Bug: angleproject:372390039 Change-Id: I29067c9488e06f6dd2e90f207fecb843267fb77c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5949263 Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Yuxin Hu <yuxinhu@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
//
// Copyright 2020 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.
//
// DriverUniform.h: Add code to support driver uniforms
//
#ifndef COMPILER_TRANSLATOR_TREEUTIL_DRIVERUNIFORM_H_
#define COMPILER_TRANSLATOR_TREEUTIL_DRIVERUNIFORM_H_
#include "common/angleutils.h"
#include "compiler/translator/Types.h"
namespace sh
{
class TCompiler;
class TIntermBlock;
class TIntermNode;
class TSymbolTable;
class TIntermTyped;
class TIntermSwizzle;
class TIntermBinary;
enum class DriverUniformMode
{
// Define the driver uniforms as an interface block. Used by the
// Vulkan and Metal/SPIR-V backends.
InterfaceBlock,
// Define the driver uniforms as a structure. Used by the
// direct-to-MSL Metal backend.
Structure
};
enum class DriverUniformFlip
{
// Flip uniforms for fragment shaders
Fragment,
// Flip uniforms for pre-rasterization stages. These differ from the fragment values by whether
// the viewport needs to be flipped, and whether negative viewports are supported.
PreFragment,
};
class DriverUniform
{
public:
DriverUniform(DriverUniformMode mode)
: mMode(mode), mDriverUniforms(nullptr), mEmulatedDepthRangeType(nullptr)
{}
virtual ~DriverUniform() = default;
bool addComputeDriverUniformsToShader(TIntermBlock *root, TSymbolTable *symbolTable);
bool addGraphicsDriverUniformsToShader(TIntermBlock *root, TSymbolTable *symbolTable);
TIntermTyped *getAcbBufferOffsets() const;
TIntermTyped *getDepthRange() const;
TIntermTyped *getViewportZScale() const;
TIntermTyped *getHalfRenderArea() const;
TIntermTyped *getFlipXY(TSymbolTable *symbolTable, DriverUniformFlip stage) const;
// Returns vec2(flip.x, -flip.y)
TIntermTyped *getNegFlipXY(TSymbolTable *symbolTable, DriverUniformFlip stage) const;
TIntermTyped *getDither() const;
TIntermTyped *getSwapXY() const;
TIntermTyped *getAdvancedBlendEquation() const;
TIntermTyped *getNumSamples() const;
TIntermTyped *getClipDistancesEnabled() const;
TIntermTyped *getTransformDepth() const;
TIntermTyped *getAlphaToCoverage() const;
TIntermTyped *getLayeredFramebuffer() const;
virtual TIntermTyped *getViewport() const { return nullptr; }
virtual TIntermTyped *getXfbBufferOffsets() const { return nullptr; }
virtual TIntermTyped *getXfbVerticesPerInstance() const { return nullptr; }
const TVariable *getDriverUniformsVariable() const { return mDriverUniforms; }
protected:
TIntermTyped *createDriverUniformRef(const char *fieldName) const;
virtual TFieldList *createUniformFields(TSymbolTable *symbolTable);
const TType *createEmulatedDepthRangeType(TSymbolTable *symbolTable);
const DriverUniformMode mMode;
const TVariable *mDriverUniforms;
TType *mEmulatedDepthRangeType;
};
class DriverUniformExtended : public DriverUniform
{
public:
DriverUniformExtended(DriverUniformMode mode) : DriverUniform(mode) {}
~DriverUniformExtended() override {}
TIntermTyped *getXfbBufferOffsets() const override;
TIntermTyped *getXfbVerticesPerInstance() const override;
protected:
TFieldList *createUniformFields(TSymbolTable *symbolTable) override;
};
// Returns either (1,0) or (0,1) based on whether X and Y should remain as-is or swapped
// respectively. dot((x,y), multiplier) will yield x, and dot((x,y), multiplier.yx) will yield y in
// the possibly-swapped coordinates.
//
// Each component is separately returned by a function
TIntermTyped *MakeSwapXMultiplier(TIntermTyped *swapped);
TIntermTyped *MakeSwapYMultiplier(TIntermTyped *swapped);
} // namespace sh
#endif // COMPILER_TRANSLATOR_TREEUTIL_DRIVERUNIFORM_H_