Hash :
b3545b42
Author :
Date :
2020-07-29T16:50:53
Get storage buffers/images from ProgramExecutable Update StateCache::updateActiveShaderStorageBufferIndices() and StateCache::updateActiveImageUnitIndices to get the storage buffers and image bindings from the ProgramExecutable, respectively. This requires updating the ProgramPipeline's ProgramExecutable to build up its vector of buffers/images from each Program's ProgramExecutable. Bug: angleproject:4869 Test: VertexAttributeTestES31.UsePpoComputeShaderToUpdateVertexBuffer Test: SimpleStateChangeTestES31.InvalidateThenStorageWriteThenBlendPpo Change-Id: I68b7d23eedda910c3dcbf5f9c50b74b5e80134d8 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2327701 Commit-Queue: Tim Van Patten <timvp@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com>
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
//
// Copyright 2017 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.
//
// ProgramPipeline.h: Defines the gl::ProgramPipeline class.
// Implements GL program pipeline objects and related functionality.
// [OpenGL ES 3.1] section 7.4 page 105.
#ifndef LIBANGLE_PROGRAMPIPELINE_H_
#define LIBANGLE_PROGRAMPIPELINE_H_
#include <memory>
#include "common/angleutils.h"
#include "libANGLE/Debug.h"
#include "libANGLE/Program.h"
#include "libANGLE/ProgramExecutable.h"
#include "libANGLE/RefCountObject.h"
namespace rx
{
class GLImplFactory;
class ProgramPipelineImpl;
} // namespace rx
namespace gl
{
class Context;
class ProgramPipeline;
class ProgramPipelineState final : angle::NonCopyable
{
public:
ProgramPipelineState();
~ProgramPipelineState();
const std::string &getLabel() const;
const ProgramExecutable &getProgramExecutable() const
{
ASSERT(mExecutable);
return *mExecutable;
}
ProgramExecutable &getProgramExecutable()
{
ASSERT(mExecutable);
return *mExecutable;
}
void activeShaderProgram(Program *shaderProgram);
void useProgramStages(const Context *context,
GLbitfield stages,
Program *shaderProgram,
std::vector<angle::ObserverBinding> *programObserverBindings);
Program *getActiveShaderProgram() { return mActiveShaderProgram; }
GLboolean isValid() const { return mValid; }
const Program *getShaderProgram(ShaderType shaderType) const { return mPrograms[shaderType]; }
bool usesShaderProgram(ShaderProgramID program) const;
void updateExecutableTextures();
private:
void useProgramStage(const Context *context,
ShaderType shaderType,
Program *shaderProgram,
angle::ObserverBinding *programObserverBindings);
friend class ProgramPipeline;
std::string mLabel;
// The active shader program
Program *mActiveShaderProgram;
// The shader programs for each stage.
ShaderMap<Program *> mPrograms;
GLboolean mValid;
ProgramExecutable *mExecutable;
};
class ProgramPipeline final : public RefCountObject<ProgramPipelineID>,
public LabeledObject,
public angle::ObserverInterface,
public angle::Subject
{
public:
ProgramPipeline(rx::GLImplFactory *factory, ProgramPipelineID handle);
~ProgramPipeline() override;
void onDestroy(const Context *context) override;
void setLabel(const Context *context, const std::string &label) override;
const std::string &getLabel() const override;
const ProgramPipelineState &getState() const { return mState; }
const ProgramExecutable &getExecutable() const { return mState.getProgramExecutable(); }
ProgramExecutable &getExecutable() { return mState.getProgramExecutable(); }
rx::ProgramPipelineImpl *getImplementation() const;
Program *getActiveShaderProgram() { return mState.getActiveShaderProgram(); }
void activeShaderProgram(Program *shaderProgram);
Program *getLinkedActiveShaderProgram(const Context *context)
{
Program *program = mState.getActiveShaderProgram();
if (program)
{
program->resolveLink(context);
}
return program;
}
void useProgramStages(const Context *context, GLbitfield stages, Program *shaderProgram);
Program *getShaderProgram(ShaderType shaderType) const { return mState.mPrograms[shaderType]; }
ProgramMergedVaryings getMergedVaryings() const;
angle::Result link(const gl::Context *context);
bool linkVaryings(InfoLog &infoLog) const;
void validate(const gl::Context *context);
bool validateSamplers(InfoLog *infoLog, const Caps &caps);
bool usesShaderProgram(ShaderProgramID program) const
{
return mState.usesShaderProgram(program);
}
bool hasAnyDirtyBit() const { return mDirtyBits.any(); }
GLboolean isValid() const { return mState.isValid(); }
// Program pipeline dirty bits.
enum DirtyBitType
{
// One of the program stages in the PPO changed.
DIRTY_BIT_PROGRAM_STAGE,
DIRTY_BIT_DRAW_DISPATCH_CHANGE,
DIRTY_BIT_COUNT = DIRTY_BIT_DRAW_DISPATCH_CHANGE + 1,
};
using DirtyBits = angle::BitSet<DIRTY_BIT_COUNT>;
angle::Result syncState(const Context *context);
void setDirtyBit(DirtyBitType dirtyBitType) { mDirtyBits.set(dirtyBitType); }
// ObserverInterface implementation.
void onSubjectStateChange(angle::SubjectIndex index, angle::SubjectMessage message) override;
void fillProgramStateMap(gl::ShaderMap<const gl::ProgramState *> *programStatesOut);
private:
void updateLinkedShaderStages();
void updateExecutableAttributes();
void updateTransformFeedbackMembers();
void updateShaderStorageBlocks();
void updateImageBindings();
void updateHasBooleans();
void updateExecutable();
std::unique_ptr<rx::ProgramPipelineImpl> mProgramPipelineImpl;
ProgramPipelineState mState;
DirtyBits mDirtyBits;
std::vector<angle::ObserverBinding> mProgramObserverBindings;
angle::ObserverBinding mExecutableObserverBinding;
};
} // namespace gl
#endif // LIBANGLE_PROGRAMPIPELINE_H_