chromium/third_party/angle/src/libANGLE/ProgramExecutable.cpp

//
// 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.
//
// ProgramExecutable.cpp: Collects the interfaces common to both Programs and
// ProgramPipelines in order to execute/draw with either.

#include "libANGLE/ProgramExecutable.h"

#include "common/string_utils.h"
#include "libANGLE/Context.h"
#include "libANGLE/Program.h"
#include "libANGLE/Shader.h"
#include "libANGLE/queryconversions.h"
#include "libANGLE/renderer/GLImplFactory.h"
#include "libANGLE/renderer/ProgramExecutableImpl.h"
#include "libANGLE/renderer/ProgramImpl.h"

namespace gl
{
namespace
{
ANGLE_ENABLE_STRUCT_PADDING_WARNINGS
// A placeholder struct just to ensure sh::BlockMemberInfo is tightly packed since vulkan backend
// uses it and memcpy the entire vector which requires it tightly packed to make msan happy.
struct BlockMemberInfoPaddingTest
{};
ANGLE_DISABLE_STRUCT_PADDING_WARNINGS

bool IncludeSameArrayElement(const std::set<std::string> &nameSet, const std::string &name)
{}

// Find the matching varying or field by name.
const sh::ShaderVariable *FindOutputVaryingOrField(const ProgramMergedVaryings &varyings,
                                                   ShaderType stage,
                                                   const std::string &name)
{}

bool FindUsedOutputLocation(std::vector<VariableLocation> &outputLocations,
                            unsigned int baseLocation,
                            unsigned int elementCount,
                            const std::vector<VariableLocation> &reservedLocations,
                            unsigned int variableIndex)
{}

void AssignOutputLocations(std::vector<VariableLocation> &outputLocations,
                           unsigned int baseLocation,
                           unsigned int elementCount,
                           const std::vector<VariableLocation> &reservedLocations,
                           unsigned int variableIndex,
                           bool locationAssignedByApi,
                           ProgramOutput &outputVariable)
{}

int GetOutputLocationForLink(const ProgramAliasedBindings &fragmentOutputLocations,
                             const ProgramOutput &outputVariable)
{}

void AssignOutputIndex(const ProgramAliasedBindings &fragmentOutputIndexes,
                       ProgramOutput &outputVariable)
{}

RangeUI AddUniforms(const ShaderMap<SharedProgramExecutable> &executables,
                    ShaderBitSet activeShaders,
                    std::vector<LinkedUniform> *outputUniforms,
                    std::vector<std::string> *outputUniformNames,
                    std::vector<std::string> *outputUniformMappedNames,
                    const std::function<RangeUI(const ProgramExecutable &)> &getRange)
{}

template <typename BlockT>
void AppendActiveBlocks(ShaderType shaderType,
                        const std::vector<BlockT> &blocksIn,
                        std::vector<BlockT> &blocksOut,
                        ProgramUniformBlockArray<GLuint> *ppoBlockMap)
{}

void SaveProgramInputs(BinaryOutputStream *stream, const std::vector<ProgramInput> &programInputs)
{}
void LoadProgramInputs(BinaryInputStream *stream, std::vector<ProgramInput> *programInputs)
{}

void SaveUniforms(BinaryOutputStream *stream,
                  const std::vector<LinkedUniform> &uniforms,
                  const std::vector<std::string> &uniformNames,
                  const std::vector<std::string> &uniformMappedNames,
                  const std::vector<VariableLocation> &uniformLocations)
{}
void LoadUniforms(BinaryInputStream *stream,
                  std::vector<LinkedUniform> *uniforms,
                  std::vector<std::string> *uniformNames,
                  std::vector<std::string> *uniformMappedNames,
                  std::vector<VariableLocation> *uniformLocations)
{}

void SaveSamplerBindings(BinaryOutputStream *stream,
                         const std::vector<SamplerBinding> &samplerBindings,
                         const std::vector<GLuint> &samplerBoundTextureUnits)
{}
void LoadSamplerBindings(BinaryInputStream *stream,
                         std::vector<SamplerBinding> *samplerBindings,
                         std::vector<GLuint> *samplerBoundTextureUnits)
{}

void WriteBufferVariable(BinaryOutputStream *stream, const BufferVariable &var)
{}

void LoadBufferVariable(BinaryInputStream *stream, BufferVariable *var)
{}

void WriteAtomicCounterBuffer(BinaryOutputStream *stream, const AtomicCounterBuffer &var)
{}

void LoadAtomicCounterBuffer(BinaryInputStream *stream, AtomicCounterBuffer *var)
{}

void WriteInterfaceBlock(BinaryOutputStream *stream, const InterfaceBlock &block)
{}

void LoadInterfaceBlock(BinaryInputStream *stream, InterfaceBlock *block)
{}

void CopyStringToBuffer(GLchar *buffer,
                        const std::string &string,
                        GLsizei bufSize,
                        GLsizei *lengthOut)
{}

template <typename T>
GLuint GetResourceMaxNameSize(const T &resource, GLint max)
{}

template <typename T>
GLuint GetResourceLocation(const GLchar *name, const T &variable, GLint location)
{}

template <typename T>
const std::string GetResourceName(const T &resource)
{}

GLint GetVariableLocation(const std::vector<gl::ProgramOutput> &list,
                          const std::vector<VariableLocation> &locationList,
                          const std::string &name)
{}

template <typename VarT>
GLuint GetResourceIndexFromName(const std::vector<VarT> &list, const std::string &name)
{}

GLuint GetUniformIndexFromName(const std::vector<LinkedUniform> &uniformList,
                               const std::vector<std::string> &nameList,
                               const std::string &name)
{}

GLint GetUniformLocation(const std::vector<LinkedUniform> &uniformList,
                         const std::vector<std::string> &nameList,
                         const std::vector<VariableLocation> &locationList,
                         const std::string &name)
{}

GLuint GetInterfaceBlockIndex(const std::vector<InterfaceBlock> &list, const std::string &name)
{}

void GetInterfaceBlockName(const UniformBlockIndex index,
                           const std::vector<InterfaceBlock> &list,
                           GLsizei bufSize,
                           GLsizei *length,
                           GLchar *name)
{}

template <typename T>
GLint GetActiveInterfaceBlockMaxNameLength(const std::vector<T> &resources)
{}

// This simplified cast function doesn't need to worry about advanced concepts like
// depth range values, or casting to bool.
template <typename DestT, typename SrcT>
DestT UniformStateQueryCast(SrcT value);

// From-Float-To-Integer Casts
template <>
GLint UniformStateQueryCast(GLfloat value)
{}

template <>
GLuint UniformStateQueryCast(GLfloat value)
{}

// From-Integer-to-Integer Casts
template <>
GLint UniformStateQueryCast(GLuint value)
{}

template <>
GLuint UniformStateQueryCast(GLint value)
{}

// From-Boolean-to-Anything Casts
template <>
GLfloat UniformStateQueryCast(GLboolean value)
{}

template <>
GLint UniformStateQueryCast(GLboolean value)
{}

template <>
GLuint UniformStateQueryCast(GLboolean value)
{}

// Default to static_cast
template <typename DestT, typename SrcT>
DestT UniformStateQueryCast(SrcT value)
{}

template <typename SrcT, typename DestT>
void UniformStateQueryCastLoop(DestT *dataOut, const uint8_t *srcPointer, int components)
{}
}  // anonymous namespace

// ImageBinding implementation.
ImageBinding::ImageBinding(GLuint imageUnit, size_t count, TextureType textureTypeIn)
    :{}

// ProgramInput implementation.
ProgramInput::ProgramInput(const sh::ShaderVariable &var)
{}

// ProgramOutput implementation.
ProgramOutput::ProgramOutput(const sh::ShaderVariable &var)
{}

// ProgramExecutable implementation.
ProgramExecutable::ProgramExecutable(rx::GLImplFactory *factory, InfoLog *infoLog)
    :{}

ProgramExecutable::~ProgramExecutable()
{}

void ProgramExecutable::destroy(const Context *context)
{}

void ProgramExecutable::reset()
{}

void ProgramExecutable::load(gl::BinaryInputStream *stream)
{}

void ProgramExecutable::save(gl::BinaryOutputStream *stream) const
{}

std::string ProgramExecutable::getInfoLogString() const
{}

ShaderType ProgramExecutable::getFirstLinkedShaderStageType() const
{}

ShaderType ProgramExecutable::getLastLinkedShaderStageType() const
{}

void ProgramExecutable::setActive(size_t textureUnit,
                                  const SamplerBinding &samplerBinding,
                                  const gl::LinkedUniform &samplerUniform)
{}

void ProgramExecutable::setInactive(size_t textureUnit)
{}

void ProgramExecutable::hasSamplerTypeConflict(size_t textureUnit)
{}

void ProgramExecutable::hasSamplerFormatConflict(size_t textureUnit)
{}

void ProgramExecutable::updateActiveSamplers(const ProgramExecutable &executable)
{}

void ProgramExecutable::updateActiveImages(const ProgramExecutable &executable)
{}

void ProgramExecutable::setSamplerUniformTextureTypeAndFormat(size_t textureUnitIndex)
{}

void ProgramExecutable::saveLinkedStateInfo(const ProgramState &state)
{}

bool ProgramExecutable::linkMergedVaryings(const Caps &caps,
                                           const Limitations &limitations,
                                           const Version &clientVersion,
                                           bool webglCompatibility,
                                           const ProgramMergedVaryings &mergedVaryings,
                                           const LinkingVariables &linkingVariables,
                                           ProgramVaryingPacking *varyingPacking)
{}

bool ProgramExecutable::linkValidateTransformFeedback(const Caps &caps,
                                                      const Version &clientVersion,
                                                      const ProgramMergedVaryings &varyings,
                                                      ShaderType stage)
{}

void ProgramExecutable::gatherTransformFeedbackVaryings(const ProgramMergedVaryings &varyings,
                                                        ShaderType stage)
{}

void ProgramExecutable::updateTransformFeedbackStrides()
{}

bool ProgramExecutable::validateSamplersImpl(const Caps &caps) const
{}

bool ProgramExecutable::linkValidateOutputVariables(
    const Caps &caps,
    const Version &version,
    GLuint combinedImageUniformsCount,
    GLuint combinedShaderStorageBlocksCount,
    int fragmentShaderVersion,
    const ProgramAliasedBindings &fragmentOutputLocations,
    const ProgramAliasedBindings &fragmentOutputIndices)
{}

bool ProgramExecutable::gatherOutputTypes()
{}

bool ProgramExecutable::linkUniforms(
    const Caps &caps,
    const ShaderMap<std::vector<sh::ShaderVariable>> &shaderUniforms,
    const ProgramAliasedBindings &uniformLocationBindings,
    GLuint *combinedImageUniformsCountOut,
    std::vector<UnusedUniform> *unusedUniformsOutOrNull)
{}

void ProgramExecutable::linkSamplerAndImageBindings(GLuint *combinedImageUniforms)
{}

bool ProgramExecutable::linkAtomicCounterBuffers(const Caps &caps)
{}

void ProgramExecutable::copyInputsFromProgram(const ProgramExecutable &executable)
{}

void ProgramExecutable::copyUniformBuffersFromProgram(
    const ProgramExecutable &executable,
    ShaderType shaderType,
    ProgramUniformBlockArray<GLuint> *ppoUniformBlockMap)
{}

void ProgramExecutable::copyStorageBuffersFromProgram(const ProgramExecutable &executable,
                                                      ShaderType shaderType)
{}

void ProgramExecutable::clearSamplerBindings()
{}

void ProgramExecutable::copySamplerBindingsFromProgram(const ProgramExecutable &executable)
{}

void ProgramExecutable::copyImageBindingsFromProgram(const ProgramExecutable &executable)
{}

void ProgramExecutable::copyOutputsFromProgram(const ProgramExecutable &executable)
{}

void ProgramExecutable::copyUniformsFromProgramMap(
    const ShaderMap<SharedProgramExecutable> &executables)
{}

void ProgramExecutable::getResourceName(const std::string name,
                                        GLsizei bufSize,
                                        GLsizei *length,
                                        GLchar *dest) const
{}

GLuint ProgramExecutable::getInputResourceIndex(const GLchar *name) const
{}

GLuint ProgramExecutable::getInputResourceMaxNameSize() const
{}

GLuint ProgramExecutable::getOutputResourceMaxNameSize() const
{}

GLuint ProgramExecutable::getInputResourceLocation(const GLchar *name) const
{}

GLuint ProgramExecutable::getOutputResourceLocation(const GLchar *name) const
{}

GLuint ProgramExecutable::getOutputResourceIndex(const GLchar *name) const
{}

void ProgramExecutable::getInputResourceName(GLuint index,
                                             GLsizei bufSize,
                                             GLsizei *length,
                                             GLchar *name) const
{}

void ProgramExecutable::getOutputResourceName(GLuint index,
                                              GLsizei bufSize,
                                              GLsizei *length,
                                              GLchar *name) const
{}

void ProgramExecutable::getUniformResourceName(GLuint index,
                                               GLsizei bufSize,
                                               GLsizei *length,
                                               GLchar *name) const
{}

void ProgramExecutable::getBufferVariableResourceName(GLuint index,
                                                      GLsizei bufSize,
                                                      GLsizei *length,
                                                      GLchar *name) const
{}

const std::string ProgramExecutable::getInputResourceName(GLuint index) const
{}

const std::string ProgramExecutable::getOutputResourceName(GLuint index) const
{}

GLint ProgramExecutable::getFragDataLocation(const std::string &name) const
{}

GLint ProgramExecutable::getFragDataIndex(const std::string &name) const
{}

GLsizei ProgramExecutable::getTransformFeedbackVaryingMaxLength() const
{}

GLuint ProgramExecutable::getTransformFeedbackVaryingResourceIndex(const GLchar *name) const
{}

const TransformFeedbackVarying &ProgramExecutable::getTransformFeedbackVaryingResource(
    GLuint index) const
{}

void ProgramExecutable::getTransformFeedbackVarying(GLuint index,
                                                    GLsizei bufSize,
                                                    GLsizei *length,
                                                    GLsizei *size,
                                                    GLenum *type,
                                                    GLchar *name) const
{}

void ProgramExecutable::getActiveAttribute(GLuint index,
                                           GLsizei bufsize,
                                           GLsizei *length,
                                           GLint *size,
                                           GLenum *type,
                                           GLchar *name) const
{}

GLint ProgramExecutable::getActiveAttributeMaxLength() const
{}

GLuint ProgramExecutable::getAttributeLocation(const std::string &name) const
{}

void ProgramExecutable::getActiveUniform(GLuint index,
                                         GLsizei bufsize,
                                         GLsizei *length,
                                         GLint *size,
                                         GLenum *type,
                                         GLchar *name) const
{}

GLint ProgramExecutable::getActiveUniformMaxLength() const
{}

bool ProgramExecutable::isValidUniformLocation(UniformLocation location) const
{}

const LinkedUniform &ProgramExecutable::getUniformByLocation(UniformLocation location) const
{}

const VariableLocation &ProgramExecutable::getUniformLocation(UniformLocation location) const
{}

UniformLocation ProgramExecutable::getUniformLocation(const std::string &name) const
{}

GLuint ProgramExecutable::getUniformIndex(const std::string &name) const
{}

bool ProgramExecutable::shouldIgnoreUniform(UniformLocation location) const
{}

GLuint ProgramExecutable::getUniformIndexFromName(const std::string &name) const
{}

GLuint ProgramExecutable::getBufferVariableIndexFromName(const std::string &name) const
{}

GLuint ProgramExecutable::getUniformIndexFromLocation(UniformLocation location) const
{}

Optional<GLuint> ProgramExecutable::getSamplerIndex(UniformLocation location) const
{}

bool ProgramExecutable::isSamplerUniformIndex(GLuint index) const
{}

GLuint ProgramExecutable::getSamplerIndexFromUniformIndex(GLuint uniformIndex) const
{}

bool ProgramExecutable::isImageUniformIndex(GLuint index) const
{}

GLuint ProgramExecutable::getImageIndexFromUniformIndex(GLuint uniformIndex) const
{}

void ProgramExecutable::getActiveUniformBlockName(const Context *context,
                                                  const UniformBlockIndex blockIndex,
                                                  GLsizei bufSize,
                                                  GLsizei *length,
                                                  GLchar *blockName) const
{}

void ProgramExecutable::getActiveShaderStorageBlockName(const GLuint blockIndex,
                                                        GLsizei bufSize,
                                                        GLsizei *length,
                                                        GLchar *blockName) const
{}

GLint ProgramExecutable::getActiveUniformBlockMaxNameLength() const
{}

GLint ProgramExecutable::getActiveShaderStorageBlockMaxNameLength() const
{}

GLuint ProgramExecutable::getUniformBlockIndex(const std::string &name) const
{}

GLuint ProgramExecutable::getShaderStorageBlockIndex(const std::string &name) const
{}

GLuint ProgramExecutable::getSamplerUniformBinding(const VariableLocation &uniformLocation) const
{}

GLuint ProgramExecutable::getImageUniformBinding(const VariableLocation &uniformLocation) const
{}

template <typename UniformT,
          GLint UniformSize,
          void (rx::ProgramExecutableImpl::*SetUniformFunc)(GLint, GLsizei, const UniformT *)>
void ProgramExecutable::setUniformGeneric(UniformLocation location,
                                          GLsizei count,
                                          const UniformT *v)
{}

void ProgramExecutable::setUniform1fv(UniformLocation location, GLsizei count, const GLfloat *v)
{}

void ProgramExecutable::setUniform2fv(UniformLocation location, GLsizei count, const GLfloat *v)
{}

void ProgramExecutable::setUniform3fv(UniformLocation location, GLsizei count, const GLfloat *v)
{}

void ProgramExecutable::setUniform4fv(UniformLocation location, GLsizei count, const GLfloat *v)
{}

void ProgramExecutable::setUniform1iv(Context *context,
                                      UniformLocation location,
                                      GLsizei count,
                                      const GLint *v)
{}

void ProgramExecutable::setUniform2iv(UniformLocation location, GLsizei count, const GLint *v)
{}

void ProgramExecutable::setUniform3iv(UniformLocation location, GLsizei count, const GLint *v)
{}

void ProgramExecutable::setUniform4iv(UniformLocation location, GLsizei count, const GLint *v)
{}

void ProgramExecutable::setUniform1uiv(UniformLocation location, GLsizei count, const GLuint *v)
{}

void ProgramExecutable::setUniform2uiv(UniformLocation location, GLsizei count, const GLuint *v)
{}

void ProgramExecutable::setUniform3uiv(UniformLocation location, GLsizei count, const GLuint *v)
{}

void ProgramExecutable::setUniform4uiv(UniformLocation location, GLsizei count, const GLuint *v)
{}

template <typename UniformT,
          GLint MatrixC,
          GLint MatrixR,
          void (rx::ProgramExecutableImpl::*
                    SetUniformMatrixFunc)(GLint, GLsizei, GLboolean, const UniformT *)>
void ProgramExecutable::setUniformMatrixGeneric(UniformLocation location,
                                                GLsizei count,
                                                GLboolean transpose,
                                                const UniformT *v)
{}

void ProgramExecutable::setUniformMatrix2fv(UniformLocation location,
                                            GLsizei count,
                                            GLboolean transpose,
                                            const GLfloat *v)
{}

void ProgramExecutable::setUniformMatrix3fv(UniformLocation location,
                                            GLsizei count,
                                            GLboolean transpose,
                                            const GLfloat *v)
{}

void ProgramExecutable::setUniformMatrix4fv(UniformLocation location,
                                            GLsizei count,
                                            GLboolean transpose,
                                            const GLfloat *v)
{}

void ProgramExecutable::setUniformMatrix2x3fv(UniformLocation location,
                                              GLsizei count,
                                              GLboolean transpose,
                                              const GLfloat *v)
{}

void ProgramExecutable::setUniformMatrix2x4fv(UniformLocation location,
                                              GLsizei count,
                                              GLboolean transpose,
                                              const GLfloat *v)
{}

void ProgramExecutable::setUniformMatrix3x2fv(UniformLocation location,
                                              GLsizei count,
                                              GLboolean transpose,
                                              const GLfloat *v)
{}

void ProgramExecutable::setUniformMatrix3x4fv(UniformLocation location,
                                              GLsizei count,
                                              GLboolean transpose,
                                              const GLfloat *v)
{}

void ProgramExecutable::setUniformMatrix4x2fv(UniformLocation location,
                                              GLsizei count,
                                              GLboolean transpose,
                                              const GLfloat *v)
{}

void ProgramExecutable::setUniformMatrix4x3fv(UniformLocation location,
                                              GLsizei count,
                                              GLboolean transpose,
                                              const GLfloat *v)
{}

void ProgramExecutable::getUniformfv(const Context *context,
                                     UniformLocation location,
                                     GLfloat *v) const
{}

void ProgramExecutable::getUniformiv(const Context *context,
                                     UniformLocation location,
                                     GLint *v) const
{}

void ProgramExecutable::getUniformuiv(const Context *context,
                                      UniformLocation location,
                                      GLuint *v) const
{}

void ProgramExecutable::initInterfaceBlockBindings()
{}

void ProgramExecutable::remapUniformBlockBinding(UniformBlockIndex uniformBlockIndex,
                                                 GLuint uniformBlockBinding)
{}

void ProgramExecutable::setUniformValuesFromBindingQualifiers()
{}

template <typename T>
GLsizei ProgramExecutable::clampUniformCount(const VariableLocation &locationInfo,
                                             GLsizei count,
                                             int vectorSize,
                                             const T *v)
{}

template <size_t cols, size_t rows, typename T>
GLsizei ProgramExecutable::clampMatrixUniformCount(UniformLocation location,
                                                   GLsizei count,
                                                   GLboolean transpose,
                                                   const T *v)
{}

void ProgramExecutable::updateSamplerUniform(Context *context,
                                             const VariableLocation &locationInfo,
                                             GLsizei clampedCount,
                                             const GLint *v)
{}

// Driver differences mean that doing the uniform value cast ourselves gives consistent results.
// EG: on NVIDIA drivers, it was observed that getUniformi for MAX_INT+1 returned MIN_INT.
template <typename DestT>
void ProgramExecutable::getUniformInternal(const Context *context,
                                           DestT *dataOut,
                                           UniformLocation location,
                                           GLenum nativeType,
                                           int components) const
{}

void ProgramExecutable::setDrawIDUniform(GLint drawid)
{}

void ProgramExecutable::setBaseVertexUniform(GLint baseVertex)
{}

void ProgramExecutable::setBaseInstanceUniform(GLuint baseInstance)
{}

void ProgramExecutable::waitForPostLinkTasks(const Context *context)
{}

void InstallExecutable(const Context *context,
                       const SharedProgramExecutable &toInstall,
                       SharedProgramExecutable *executable)
{}

void UninstallExecutable(const Context *context, SharedProgramExecutable *executable)
{}

}  // namespace gl