chromium/gpu/command_buffer/service/program_manager.cc

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "gpu/command_buffer/service/program_manager.h"

#include <stddef.h>
#include <stdint.h>

#include <algorithm>
#include <limits>
#include <memory>
#include <set>
#include <string_view>
#include <utility>
#include <vector>

#include "base/command_line.h"
#include "base/containers/heap_array.h"
#include "base/logging.h"
#include "base/metrics/histogram_macros.h"
#include "base/numerics/safe_math.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "gpu/command_buffer/common/gles2_cmd_format.h"
#include "gpu/command_buffer/common/gles2_cmd_utils.h"
#include "gpu/command_buffer/service/decoder_context.h"
#include "gpu/command_buffer/service/feature_info.h"
#include "gpu/command_buffer/service/program_cache.h"
#include "gpu/command_buffer/service/shader_manager.h"
#include "gpu/config/gpu_preferences.h"
#include "third_party/re2/src/re2/re2.h"
#include "ui/gl/gl_version_info.h"
#include "ui/gl/progress_reporter.h"

namespace gpu {
namespace gles2 {

namespace {

int ShaderTypeToIndex(GLenum shader_type) {}

// Given a name like "foo.bar[123].moo[456]" sets new_name to "foo.bar[123].moo"
// and sets element_index to 456. returns false if element expression was not a
// whole decimal number. For example: "foo[1b2]"
bool GetUniformNameSansElement(
    const std::string& name, int* element_index, std::string* new_name) {}

bool IsBuiltInFragmentVarying(const std::string& name) {}

bool IsBuiltInInvariant(
    const VaryingMap& varyings, const std::string& name) {}

uint32_t ComputeOffset(const void* start, const void* position) {}

// This is used for vertex shader input variables and fragment shader output
// variables.
ShaderVariableBaseType InputOutputTypeToBaseType(bool is_input, GLenum type) {}

GLsizeiptr VertexShaderOutputBaseTypeToSize(GLenum type) {}

GLsizeiptr VertexShaderOutputTypeToSize(const sh::Varying& varying) {}

size_t LocationCountForAttribType(GLenum type) {}

}  // anonymous namespace.

Program::UniformInfo::UniformInfo()
    :{}

Program::UniformInfo::UniformInfo(const std::string& client_name,
                                  int client_location_base,
                                  GLenum _type,
                                  bool _is_array,
                                  const std::vector<GLint>& service_locations)
    :{}

Program::UniformInfo::UniformInfo(const UniformInfo& other) = default;

Program::UniformInfo::~UniformInfo() = default;

bool ProgramManager::HasBuiltInPrefix(const std::string& name) {}

Program::Program(ProgramManager* manager, GLuint service_id)
    :{}

void Program::Reset() {}

void Program::ClearVertexInputMasks() {}

void Program::UpdateFragmentOutputBaseTypes() {}

void Program::UpdateVertexInputBaseTypes() {}

void Program::UpdateUniformBlockSizeInfo() {}

void Program::SetUniformBlockBinding(GLuint index, GLuint binding) {}

void Program::UpdateTransformFeedbackInfo() {}

void Program::UpdateDrawIDUniformLocation() {}

void Program::UpdateBaseVertexUniformLocation() {}

void Program::UpdateBaseInstanceUniformLocation() {}

std::string Program::ProcessLogInfo(const std::string& log) {}

void Program::UpdateLogInfo() {}

void Program::Update() {}

bool Program::UpdateUniforms() {}

void Program::UpdateProgramOutputs() {}

void Program::ExecuteBindAttribLocationCalls() {}

bool Program::ExecuteTransformFeedbackVaryingsCall() {}

void Program::ExecuteProgramOutputBindCalls() {}

bool Program::Link(ShaderManager* manager,
                   DecoderClient* client) {}

void Program::Validate() {}

GLint Program::GetUniformFakeLocation(
    const std::string& name) const {}

GLint Program::GetAttribLocation(
    const std::string& original_name) const {}

const Program::UniformInfo*
    Program::GetUniformInfoByFakeLocation(
        GLint fake_location, GLint* real_location, GLint* array_index) const {}

bool Program::IsInactiveUniformLocationByFakeLocation(
    GLint fake_location) const {}

const std::string* Program::GetAttribMappedName(
    const std::string& original_name) const {}

const std::string* Program::GetUniformMappedName(
    const std::string& original_name) const {}

const std::string* Program::GetOriginalNameFromHashedName(
    const std::string& hashed_name) const {}

const sh::Varying* Program::GetVaryingInfo(
    const std::string& hashed_name) const {}

const sh::InterfaceBlock* Program::GetInterfaceBlockInfo(
    const std::string& hashed_name) const {}

bool Program::SetUniformLocationBinding(
    const std::string& name, GLint location) {}

void Program::SetProgramOutputLocationBinding(const std::string& name,
                                              GLuint color_name) {}

void Program::SetProgramOutputLocationIndexedBinding(const std::string& name,
                                                     GLuint color_name,
                                                     GLuint index) {}

void Program::GetVertexAttribData(
    const std::string& name, std::string* original_name, GLenum* type) const {}

const Program::UniformInfo*
    Program::GetUniformInfo(
        GLint index) const {}

bool Program::SetSamplers(
    GLint num_texture_units, GLint fake_location,
    GLsizei count, const GLint* value) {}

void Program::GetProgramiv(GLenum pname, GLint* params) {}

bool Program::AttachShader(
    ShaderManager* shader_manager,
    Shader* shader) {}

bool Program::IsShaderAttached(Shader* shader) {}

void Program::DetachShader(
    ShaderManager* shader_manager,
    Shader* shader) {}

void Program::DetachShaders(ShaderManager* shader_manager) {}

void Program::CompileAttachedShaders() {}

bool Program::AttachedShadersExist() const {}

bool Program::CanLink() const {}

bool Program::DetectShaderVersionMismatch() const {}

bool Program::DetectAttribLocationBindingConflicts() const {}

bool Program::DetectUniformLocationBindingConflicts() const {}

bool Program::DetectUniformsMismatch(std::string* conflicting_name) const {}

bool Program::DetectInterfaceBlocksMismatch(
    std::string* conflicting_name) const {}

bool Program::DetectVaryingsMismatch(std::string* conflicting_name) const {}

bool Program::DetectProgramOutputLocationBindingConflicts() const {}

bool Program::DetectBuiltInInvariantConflicts() const {}

bool Program::DetectGlobalNameConflicts(std::string* conflicting_name) const {}

bool Program::CheckVaryingsPacking() const {}

void Program::GetProgramInfo(
    ProgramManager* manager, CommonDecoder::Bucket* bucket) const {}

bool Program::GetUniformBlocks(CommonDecoder::Bucket* bucket) const {}

bool Program::GetTransformFeedbackVaryings(
    CommonDecoder::Bucket* bucket) const {}

bool Program::GetUniformsES3(CommonDecoder::Bucket* bucket) const {}

const Program::ProgramOutputInfo* Program::GetProgramOutputInfo(
    const std::string& name) const {}

GLint Program::GetFragDataLocation(const std::string& original_name) const {}

GLint Program::GetFragDataIndex(const std::string& original_name) const {}

void Program::TransformFeedbackVaryings(GLsizei count,
                                        const char* const* varyings,
                                        GLenum buffer_mode) {}

Program::~Program() {}

ProgramManager::ProgramManager(ProgramCache* program_cache,
                               uint32_t max_varying_vectors,
                               uint32_t max_draw_buffers,
                               uint32_t max_dual_source_draw_buffers,
                               uint32_t max_vertex_attribs,
                               const GpuPreferences& gpu_preferences,
                               FeatureInfo* feature_info,
                               gl::ProgressReporter* progress_reporter)
    :{}

ProgramManager::~ProgramManager() {}

void ProgramManager::Destroy(bool have_context) {}

void ProgramManager::StartTracking(Program* /* program */) {}

void ProgramManager::StopTracking(Program* /* program */) {}

Program* ProgramManager::CreateProgram(
    GLuint client_id, GLuint service_id) {}

Program* ProgramManager::GetProgram(GLuint client_id) {}

bool ProgramManager::GetClientId(GLuint service_id, GLuint* client_id) const {}

ProgramCache* ProgramManager::program_cache() const {}

bool ProgramManager::IsOwned(Program* program) const {}

bool ProgramManager::HasCachedCompileStatus(Shader* shader) const {}

void ProgramManager::RemoveProgramInfoIfUnused(
    ShaderManager* shader_manager, Program* program) {}

void ProgramManager::MarkAsDeleted(
    ShaderManager* shader_manager,
    Program* program) {}

void ProgramManager::UseProgram(Program* program) {}

void ProgramManager::UnuseProgram(
    ShaderManager* shader_manager,
    Program* program) {}

void ProgramManager::UpdateDrawIDUniformLocation(Program* program) {}

void ProgramManager::UpdateBaseVertexUniformLocation(Program* program) {}

void ProgramManager::UpdateBaseInstanceUniformLocation(Program* program) {}

int32_t ProgramManager::MakeFakeLocation(int32_t index, int32_t element) {}

}  // namespace gles2
}  // namespace gpu