Hash :
06411d16
Author :
Date :
2023-09-06T13:23:34
GL: Use the executable instead of program In a few places, the program was still being directly referenced instead of the executable (in particular when dealing with multiview). Bug: angleproject:8297 Change-Id: I15d0865bf58376a9f85efeec739dd93b49ceaea7 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4846475 Reviewed-by: Geoff Lang <geofflang@chromium.org> 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 113 114 115 116 117 118 119
//
// Copyright 2023 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.
//
// ProgramExecutableGL.cpp: Implementation of ProgramExecutableGL.
#include "libANGLE/renderer/gl/ProgramExecutableGL.h"
#include "common/string_utils.h"
#include "libANGLE/Program.h"
#include "libANGLE/Uniform.h"
#include "libANGLE/renderer/gl/FunctionsGL.h"
#include "libANGLE/renderer/gl/RendererGL.h"
namespace rx
{
ProgramExecutableGL::ProgramExecutableGL(const gl::ProgramExecutable *executable)
: ProgramExecutableImpl(executable),
mHasAppliedTransformFeedbackVaryings(false),
mClipDistanceEnabledUniformLocation(-1),
mMultiviewBaseViewLayerIndexUniformLocation(-1),
mProgramID(0),
mFunctions(nullptr)
{}
ProgramExecutableGL::~ProgramExecutableGL() {}
void ProgramExecutableGL::destroy(const gl::Context *context) {}
void ProgramExecutableGL::reset()
{
mUniformRealLocationMap.clear();
mUniformBlockRealLocationMap.clear();
mClipDistanceEnabledUniformLocation = -1;
mMultiviewBaseViewLayerIndexUniformLocation = -1;
}
void ProgramExecutableGL::postLink(const FunctionsGL *functions,
const angle::FeaturesGL &features,
GLuint programID)
{
// Cache the following so the executable is capable of making the appropriate GL calls without
// having to involve ProgramGL.
mProgramID = programID;
mFunctions = functions;
// Query the uniform information
ASSERT(mUniformRealLocationMap.empty());
const auto &uniformLocations = mExecutable->getUniformLocations();
const auto &uniforms = mExecutable->getUniforms();
mUniformRealLocationMap.resize(uniformLocations.size(), GL_INVALID_INDEX);
for (size_t uniformLocation = 0; uniformLocation < uniformLocations.size(); uniformLocation++)
{
const auto &entry = uniformLocations[uniformLocation];
if (!entry.used())
{
continue;
}
// From the GLES 3.0.5 spec:
// "Locations for sequential array indices are not required to be sequential."
const gl::LinkedUniform &uniform = uniforms[entry.index];
const std::string &uniformMappedName = mExecutable->getUniformMappedNames()[entry.index];
std::stringstream fullNameStr;
if (uniform.isArray())
{
ASSERT(angle::EndsWith(uniformMappedName, "[0]"));
fullNameStr << uniformMappedName.substr(0, uniformMappedName.length() - 3);
fullNameStr << "[" << entry.arrayIndex << "]";
}
else
{
fullNameStr << uniformMappedName;
}
const std::string &fullName = fullNameStr.str();
GLint realLocation = functions->getUniformLocation(programID, fullName.c_str());
mUniformRealLocationMap[uniformLocation] = realLocation;
}
if (features.emulateClipDistanceState.enabled && mExecutable->hasClipDistance())
{
ASSERT(functions->standard == STANDARD_GL_ES);
mClipDistanceEnabledUniformLocation =
functions->getUniformLocation(programID, "angle_ClipDistanceEnabled");
ASSERT(mClipDistanceEnabledUniformLocation != -1);
}
if (mExecutable->usesMultiview())
{
mMultiviewBaseViewLayerIndexUniformLocation =
functions->getUniformLocation(programID, "multiviewBaseViewLayerIndex");
ASSERT(mMultiviewBaseViewLayerIndexUniformLocation != -1);
}
}
void ProgramExecutableGL::updateEnabledClipDistances(uint8_t enabledClipDistancesPacked) const
{
ASSERT(mExecutable->hasClipDistance());
ASSERT(mClipDistanceEnabledUniformLocation != -1);
ASSERT(mFunctions->programUniform1ui != nullptr);
mFunctions->programUniform1ui(mProgramID, mClipDistanceEnabledUniformLocation,
enabledClipDistancesPacked);
}
void ProgramExecutableGL::enableLayeredRenderingPath(int baseViewIndex) const
{
ASSERT(mExecutable->usesMultiview());
ASSERT(mMultiviewBaseViewLayerIndexUniformLocation != -1);
ASSERT(mFunctions->programUniform1i != nullptr);
mFunctions->programUniform1i(mProgramID, mMultiviewBaseViewLayerIndexUniformLocation,
baseViewIndex);
}
} // namespace rx