Hash :
29561184
Author :
Date :
2023-09-06T22:08:33
Remove forward-to-executable helpers from program This helps avoid accidental usage of the executable that is in the program instead of the installed executable in the GL context. The program's executable is still accessed in specific cases of: - During link - GL program queries Bug: angleproject:8297 Change-Id: I40a956e740944f2ecfbf6e4a3060aac08c21f7f3 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4864448 Commit-Queue: Yuxin Hu <yuxinhu@google.com> Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Yuxin Hu <yuxinhu@google.com> Auto-Submit: 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 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220
//
// Copyright 2014 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.
//
// DynamicHLSL.h: Interface for link and run-time HLSL generation
//
#ifndef LIBANGLE_RENDERER_D3D_DYNAMICHLSL_H_
#define LIBANGLE_RENDERER_D3D_DYNAMICHLSL_H_
#include <map>
#include <vector>
#include "angle_gl.h"
#include "common/angleutils.h"
#include "libANGLE/Constants.h"
#include "libANGLE/Program.h"
#include "libANGLE/angletypes.h"
#include "libANGLE/formatutils.h"
#include "libANGLE/renderer/d3d/DynamicImage2DHLSL.h"
#include "libANGLE/renderer/d3d/RendererD3D.h"
namespace sh
{
struct ShaderVariable;
} // namespace sh
namespace gl
{
class InfoLog;
struct VariableLocation;
class VaryingPacking;
struct VertexAttribute;
} // namespace gl
namespace rx
{
class ProgramD3DMetadata;
class ShaderD3D;
struct ShaderStorageBlock;
// This class needs to match OutputHLSL::decorate
class DecorateVariable final : angle::NonCopyable
{
public:
explicit DecorateVariable(const std::string &str) : mName(str) {}
const std::string &getName() const { return mName; }
private:
const std::string &mName;
};
inline std::ostream &operator<<(std::ostream &o, const DecorateVariable &dv)
{
if (dv.getName().compare(0, 3, "gl_") != 0)
{
o << "_";
}
o << dv.getName();
return o;
}
struct PixelShaderOutputVariable
{
PixelShaderOutputVariable() {}
PixelShaderOutputVariable(GLenum typeIn,
const std::string &nameIn,
const std::string &sourceIn,
size_t outputLocationIn,
size_t outputIndexIn)
: type(typeIn),
name(nameIn),
source(sourceIn),
outputLocation(outputLocationIn),
outputIndex(outputIndexIn)
{}
GLenum type = GL_NONE;
std::string name;
std::string source;
size_t outputLocation = 0;
size_t outputIndex = 0;
};
struct BuiltinVarying final : private angle::NonCopyable
{
BuiltinVarying();
std::string str() const;
void enableSystem(const std::string &systemValueSemantic);
void enableSystem(const std::string &systemValueSemantic, unsigned int sizeVal);
void enable(const std::string &semanticVal, unsigned int indexVal);
bool enabled;
std::string semantic;
unsigned int indexOrSize;
bool systemValue;
};
struct BuiltinInfo
{
BuiltinInfo();
~BuiltinInfo();
BuiltinVarying dxPosition;
BuiltinVarying glPosition;
BuiltinVarying glClipDistance;
BuiltinVarying glCullDistance;
BuiltinVarying glFragCoord;
BuiltinVarying glPointCoord;
BuiltinVarying glPointSize;
BuiltinVarying glViewIDOVR;
BuiltinVarying glViewportIndex;
BuiltinVarying glLayer;
};
inline std::string GetVaryingSemantic(int majorShaderModel, bool programUsesPointSize)
{
// SM3 reserves the TEXCOORD semantic for point sprite texcoords (gl_PointCoord)
// In D3D11 we manually compute gl_PointCoord in the GS.
return ((programUsesPointSize && majorShaderModel < 4) ? "COLOR" : "TEXCOORD");
}
class BuiltinVaryingsD3D
{
public:
BuiltinVaryingsD3D(const ProgramD3DMetadata &metadata, const gl::VaryingPacking &packing);
~BuiltinVaryingsD3D();
bool usesPointSize() const { return mBuiltinInfo[gl::ShaderType::Vertex].glPointSize.enabled; }
const BuiltinInfo &operator[](gl::ShaderType shaderType) const
{
return mBuiltinInfo[shaderType];
}
BuiltinInfo &operator[](gl::ShaderType shaderType) { return mBuiltinInfo[shaderType]; }
private:
void updateBuiltins(gl::ShaderType shaderType,
const ProgramD3DMetadata &metadata,
const gl::VaryingPacking &packing);
gl::ShaderMap<BuiltinInfo> mBuiltinInfo;
};
class DynamicHLSL : angle::NonCopyable
{
public:
static std::string GenerateVertexShaderForInputLayout(
RendererD3D *renderer,
const std::string &sourceShader,
const gl::InputLayout &inputLayout,
const std::vector<gl::ProgramInput> &shaderAttributes,
const std::vector<rx::ShaderStorageBlock> &shaderStorageBlocks,
size_t baseUAVRegister);
static std::string GeneratePixelShaderForOutputSignature(
RendererD3D *renderer,
const std::string &sourceShader,
const std::vector<PixelShaderOutputVariable> &outputVariables,
FragDepthUsage fragDepthUsage,
bool usesSampleMask,
const std::vector<GLenum> &outputLayout,
const std::vector<rx::ShaderStorageBlock> &shaderStorageBlocks,
size_t baseUAVRegister);
static std::string GenerateShaderForImage2DBindSignature(
ProgramExecutableD3D &executableD3D,
gl::ShaderType shaderType,
const SharedCompiledShaderStateD3D &shaderData,
const std::string &shaderHLSL,
std::vector<sh::ShaderVariable> &image2DUniforms,
const gl::ImageUnitTextureTypeMap &image2DBindLayout,
unsigned int baseUAVRegister);
static void GenerateShaderLinkHLSL(
RendererD3D *renderer,
const gl::Caps &caps,
const gl::ShaderMap<gl::SharedCompiledShaderState> &shaderData,
const gl::ShaderMap<SharedCompiledShaderStateD3D> &shaderDataD3D,
const ProgramD3DMetadata &programMetadata,
const gl::VaryingPacking &varyingPacking,
const BuiltinVaryingsD3D &builtinsD3D,
gl::ShaderMap<std::string> *shaderHLSL);
static std::string GenerateGeometryShaderPreamble(RendererD3D *renderer,
const gl::VaryingPacking &varyingPacking,
const BuiltinVaryingsD3D &builtinsD3D,
const bool hasMultiviewEnabled,
const bool selectViewInVS);
static std::string GenerateGeometryShaderHLSL(RendererD3D *renderer,
const gl::Caps &caps,
gl::PrimitiveMode primitiveType,
const bool useViewScale,
const bool hasMultiviewEnabled,
const bool selectViewInVS,
const bool pointSpriteEmulation,
const std::string &preambleString);
static void GetPixelShaderOutputKey(RendererD3D *renderer,
const gl::Caps &caps,
const gl::Version &clientVersion,
const gl::ProgramExecutable &executable,
const ProgramD3DMetadata &metadata,
std::vector<PixelShaderOutputVariable> *outPixelShaderKey);
private:
static void GenerateVaryingLinkHLSL(RendererD3D *renderer,
const gl::VaryingPacking &varyingPacking,
const BuiltinInfo &builtins,
bool programUsesPointSize,
std::ostringstream &hlslStream);
static void GenerateAttributeConversionHLSL(angle::FormatID vertexFormatID,
const gl::ProgramInput &shaderAttrib,
std::ostringstream &outStream);
};
} // namespace rx
#endif // LIBANGLE_RENDERER_D3D_DYNAMICHLSL_H_