Commit 39d187b8 by Tim Van Patten Committed by Commit Bot

Update Program[Pipeline]State to hold a ProgramExecutable Pointer

This is a refactor CL to convert mExecutable in ProgramState and ProgramPipelineState to a pointer, so it can be changed to point to a different ProgramExecutable in a future CL. Bug: angleproject:4514 Test: end2end Change-Id: Id8ee9e5f2d1b02313973519cb2b4b0d5f7533b09 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2181447 Commit-Queue: Tim Van Patten <timvp@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 08e0df62
...@@ -333,8 +333,16 @@ class ProgramState final : angle::NonCopyable ...@@ -333,8 +333,16 @@ class ProgramState final : angle::NonCopyable
return mUniformLocationBindings; return mUniformLocationBindings;
} }
const ProgramExecutable &getProgramExecutable() const { return mExecutable; } const ProgramExecutable &getProgramExecutable() const
ProgramExecutable &getProgramExecutable() { return mExecutable; } {
ASSERT(mExecutable);
return *mExecutable;
}
ProgramExecutable &getProgramExecutable()
{
ASSERT(mExecutable);
return *mExecutable;
}
bool hasDefaultUniforms() const { return !getDefaultUniformRange().empty(); } bool hasDefaultUniforms() const { return !getDefaultUniformRange().empty(); }
bool hasTextures() const { return !getSamplerBindings().empty(); } bool hasTextures() const { return !getSamplerBindings().empty(); }
...@@ -355,7 +363,7 @@ class ProgramState final : angle::NonCopyable ...@@ -355,7 +363,7 @@ class ProgramState final : angle::NonCopyable
// A Program can only either be graphics or compute, but never both, so it // A Program can only either be graphics or compute, but never both, so it
// can answer isCompute() based on which shaders it has. // can answer isCompute() based on which shaders it has.
bool isCompute() const { return mExecutable.hasLinkedShaderStage(ShaderType::Compute); } bool isCompute() const { return mExecutable->hasLinkedShaderStage(ShaderType::Compute); }
private: private:
friend class MemoryProgramCache; friend class MemoryProgramCache;
...@@ -462,7 +470,7 @@ class ProgramState final : angle::NonCopyable ...@@ -462,7 +470,7 @@ class ProgramState final : angle::NonCopyable
// uniforms in GLES3.1+. It is used to pre-set the location of uniforms. // uniforms in GLES3.1+. It is used to pre-set the location of uniforms.
ProgramAliasedBindings mUniformLocationBindings; ProgramAliasedBindings mUniformLocationBindings;
ProgramExecutable mExecutable; ProgramExecutable *mExecutable;
}; };
struct ProgramVaryingRef struct ProgramVaryingRef
......
...@@ -27,9 +27,10 @@ ProgramPipelineState::ProgramPipelineState() ...@@ -27,9 +27,10 @@ ProgramPipelineState::ProgramPipelineState()
mIsCompute(false), mIsCompute(false),
mActiveShaderProgram(nullptr), mActiveShaderProgram(nullptr),
mValid(false), mValid(false),
mHasBeenBound(false) mHasBeenBound(false),
mExecutable(new ProgramExecutable())
{ {
mExecutable.setProgramPipelineState(this); mExecutable->setProgramPipelineState(this);
for (const ShaderType shaderType : gl::AllShaderTypes()) for (const ShaderType shaderType : gl::AllShaderTypes())
{ {
...@@ -37,7 +38,10 @@ ProgramPipelineState::ProgramPipelineState() ...@@ -37,7 +38,10 @@ ProgramPipelineState::ProgramPipelineState()
} }
} }
ProgramPipelineState::~ProgramPipelineState() {} ProgramPipelineState::~ProgramPipelineState()
{
SafeDelete(mExecutable);
}
const std::string &ProgramPipelineState::getLabel() const const std::string &ProgramPipelineState::getLabel() const
{ {
...@@ -122,7 +126,7 @@ bool ProgramPipelineState::usesShaderProgram(ShaderProgramID programId) const ...@@ -122,7 +126,7 @@ bool ProgramPipelineState::usesShaderProgram(ShaderProgramID programId) const
bool ProgramPipelineState::hasDefaultUniforms() const bool ProgramPipelineState::hasDefaultUniforms() const
{ {
for (const gl::ShaderType shaderType : mExecutable.getLinkedShaderStages()) for (const gl::ShaderType shaderType : mExecutable->getLinkedShaderStages())
{ {
const Program *shaderProgram = getShaderProgram(shaderType); const Program *shaderProgram = getShaderProgram(shaderType);
if (shaderProgram && shaderProgram->getState().hasDefaultUniforms()) if (shaderProgram && shaderProgram->getState().hasDefaultUniforms())
...@@ -136,7 +140,7 @@ bool ProgramPipelineState::hasDefaultUniforms() const ...@@ -136,7 +140,7 @@ bool ProgramPipelineState::hasDefaultUniforms() const
bool ProgramPipelineState::hasTextures() const bool ProgramPipelineState::hasTextures() const
{ {
for (const gl::ShaderType shaderType : mExecutable.getLinkedShaderStages()) for (const gl::ShaderType shaderType : mExecutable->getLinkedShaderStages())
{ {
const Program *shaderProgram = getShaderProgram(shaderType); const Program *shaderProgram = getShaderProgram(shaderType);
if (shaderProgram && shaderProgram->getState().hasTextures()) if (shaderProgram && shaderProgram->getState().hasTextures())
...@@ -150,7 +154,7 @@ bool ProgramPipelineState::hasTextures() const ...@@ -150,7 +154,7 @@ bool ProgramPipelineState::hasTextures() const
bool ProgramPipelineState::hasUniformBuffers() const bool ProgramPipelineState::hasUniformBuffers() const
{ {
for (const gl::ShaderType shaderType : mExecutable.getLinkedShaderStages()) for (const gl::ShaderType shaderType : mExecutable->getLinkedShaderStages())
{ {
const Program *shaderProgram = getShaderProgram(shaderType); const Program *shaderProgram = getShaderProgram(shaderType);
if (shaderProgram && shaderProgram->getState().hasUniformBuffers()) if (shaderProgram && shaderProgram->getState().hasUniformBuffers())
...@@ -164,7 +168,7 @@ bool ProgramPipelineState::hasUniformBuffers() const ...@@ -164,7 +168,7 @@ bool ProgramPipelineState::hasUniformBuffers() const
bool ProgramPipelineState::hasStorageBuffers() const bool ProgramPipelineState::hasStorageBuffers() const
{ {
for (const gl::ShaderType shaderType : mExecutable.getLinkedShaderStages()) for (const gl::ShaderType shaderType : mExecutable->getLinkedShaderStages())
{ {
const Program *shaderProgram = getShaderProgram(shaderType); const Program *shaderProgram = getShaderProgram(shaderType);
if (shaderProgram && shaderProgram->getState().hasStorageBuffers()) if (shaderProgram && shaderProgram->getState().hasStorageBuffers())
...@@ -178,7 +182,7 @@ bool ProgramPipelineState::hasStorageBuffers() const ...@@ -178,7 +182,7 @@ bool ProgramPipelineState::hasStorageBuffers() const
bool ProgramPipelineState::hasAtomicCounterBuffers() const bool ProgramPipelineState::hasAtomicCounterBuffers() const
{ {
for (const gl::ShaderType shaderType : mExecutable.getLinkedShaderStages()) for (const gl::ShaderType shaderType : mExecutable->getLinkedShaderStages())
{ {
const Program *shaderProgram = getShaderProgram(shaderType); const Program *shaderProgram = getShaderProgram(shaderType);
if (shaderProgram && shaderProgram->getState().hasAtomicCounterBuffers()) if (shaderProgram && shaderProgram->getState().hasAtomicCounterBuffers())
...@@ -192,7 +196,7 @@ bool ProgramPipelineState::hasAtomicCounterBuffers() const ...@@ -192,7 +196,7 @@ bool ProgramPipelineState::hasAtomicCounterBuffers() const
bool ProgramPipelineState::hasImages() const bool ProgramPipelineState::hasImages() const
{ {
for (const gl::ShaderType shaderType : mExecutable.getLinkedShaderStages()) for (const gl::ShaderType shaderType : mExecutable->getLinkedShaderStages())
{ {
const Program *shaderProgram = getShaderProgram(shaderType); const Program *shaderProgram = getShaderProgram(shaderType);
if (shaderProgram && shaderProgram->getState().hasImages()) if (shaderProgram && shaderProgram->getState().hasImages())
...@@ -206,7 +210,7 @@ bool ProgramPipelineState::hasImages() const ...@@ -206,7 +210,7 @@ bool ProgramPipelineState::hasImages() const
bool ProgramPipelineState::hasTransformFeedbackOutput() const bool ProgramPipelineState::hasTransformFeedbackOutput() const
{ {
for (const gl::ShaderType shaderType : mExecutable.getLinkedShaderStages()) for (const gl::ShaderType shaderType : mExecutable->getLinkedShaderStages())
{ {
const Program *shaderProgram = getShaderProgram(shaderType); const Program *shaderProgram = getShaderProgram(shaderType);
if (shaderProgram && shaderProgram->getState().hasTransformFeedbackOutput()) if (shaderProgram && shaderProgram->getState().hasTransformFeedbackOutput())
...@@ -277,18 +281,18 @@ void ProgramPipeline::useProgramStages(const Context *context, ...@@ -277,18 +281,18 @@ void ProgramPipeline::useProgramStages(const Context *context,
void ProgramPipeline::updateLinkedShaderStages() void ProgramPipeline::updateLinkedShaderStages()
{ {
mState.mExecutable.resetLinkedShaderStages(); mState.mExecutable->resetLinkedShaderStages();
for (const ShaderType shaderType : gl::AllShaderTypes()) for (const ShaderType shaderType : gl::AllShaderTypes())
{ {
Program *program = mState.mPrograms[shaderType]; Program *program = mState.mPrograms[shaderType];
if (program) if (program)
{ {
mState.mExecutable.setLinkedShaderStages(shaderType); mState.mExecutable->setLinkedShaderStages(shaderType);
} }
} }
mState.mExecutable.updateCanDrawWith(); mState.mExecutable->updateCanDrawWith();
} }
void ProgramPipeline::updateExecutableAttributes() void ProgramPipeline::updateExecutableAttributes()
...@@ -300,32 +304,32 @@ void ProgramPipeline::updateExecutableAttributes() ...@@ -300,32 +304,32 @@ void ProgramPipeline::updateExecutableAttributes()
return; return;
} }
const ProgramExecutable &vertexExecutable = vertexProgram->getExecutable(); const ProgramExecutable &vertexExecutable = vertexProgram->getExecutable();
mState.mExecutable.mActiveAttribLocationsMask = vertexExecutable.mActiveAttribLocationsMask; mState.mExecutable->mActiveAttribLocationsMask = vertexExecutable.mActiveAttribLocationsMask;
mState.mExecutable.mMaxActiveAttribLocation = vertexExecutable.mMaxActiveAttribLocation; mState.mExecutable->mMaxActiveAttribLocation = vertexExecutable.mMaxActiveAttribLocation;
mState.mExecutable.mAttributesTypeMask = vertexExecutable.mAttributesTypeMask; mState.mExecutable->mAttributesTypeMask = vertexExecutable.mAttributesTypeMask;
mState.mExecutable.mAttributesMask = vertexExecutable.mAttributesMask; mState.mExecutable->mAttributesMask = vertexExecutable.mAttributesMask;
} }
void ProgramPipeline::updateExecutableTextures() void ProgramPipeline::updateExecutableTextures()
{ {
for (const ShaderType shaderType : mState.mExecutable.getLinkedShaderStages()) for (const ShaderType shaderType : mState.mExecutable->getLinkedShaderStages())
{ {
const Program *program = getShaderProgram(shaderType); const Program *program = getShaderProgram(shaderType);
if (program) if (program)
{ {
mState.mExecutable.mActiveSamplersMask |= mState.mExecutable->mActiveSamplersMask |=
program->getExecutable().getActiveSamplersMask(); program->getExecutable().getActiveSamplersMask();
mState.mExecutable.mActiveImagesMask |= program->getExecutable().getActiveImagesMask(); mState.mExecutable->mActiveImagesMask |= program->getExecutable().getActiveImagesMask();
// Updates mActiveSamplerRefCounts, mActiveSamplerTypes, and mActiveSamplerFormats // Updates mActiveSamplerRefCounts, mActiveSamplerTypes, and mActiveSamplerFormats
mState.mExecutable.updateActiveSamplers(program->getState()); mState.mExecutable->updateActiveSamplers(program->getState());
} }
} }
} }
void ProgramPipeline::updateExecutable() void ProgramPipeline::updateExecutable()
{ {
mState.mExecutable.reset(); mState.mExecutable->reset();
// Vertex Shader ProgramExecutable properties // Vertex Shader ProgramExecutable properties
updateExecutableAttributes(); updateExecutableAttributes();
...@@ -336,7 +340,7 @@ void ProgramPipeline::updateExecutable() ...@@ -336,7 +340,7 @@ void ProgramPipeline::updateExecutable()
ProgramMergedVaryings ProgramPipeline::getMergedVaryings() const ProgramMergedVaryings ProgramPipeline::getMergedVaryings() const
{ {
ASSERT(!mState.mExecutable.isCompute()); ASSERT(!mState.mExecutable->isCompute());
// Varyings are matched between pairs of consecutive stages, by location if assigned or // Varyings are matched between pairs of consecutive stages, by location if assigned or
// by name otherwise. Note that it's possible for one stage to specify location and the other // by name otherwise. Note that it's possible for one stage to specify location and the other
...@@ -458,7 +462,7 @@ angle::Result ProgramPipeline::link(const Context *context) ...@@ -458,7 +462,7 @@ angle::Result ProgramPipeline::link(const Context *context)
{ {
if (!getExecutable().isCompute()) if (!getExecutable().isCompute())
{ {
InfoLog &infoLog = mState.mExecutable.getInfoLog(); InfoLog &infoLog = mState.mExecutable->getInfoLog();
infoLog.reset(); infoLog.reset();
const State &state = context->getState(); const State &state = context->getState();
...@@ -480,7 +484,7 @@ angle::Result ProgramPipeline::link(const Context *context) ...@@ -480,7 +484,7 @@ angle::Result ProgramPipeline::link(const Context *context)
return angle::Result::Stop; return angle::Result::Stop;
} }
if (!mState.mExecutable.linkValidateGlobalNames(infoLog)) if (!mState.mExecutable->linkValidateGlobalNames(infoLog))
{ {
return angle::Result::Stop; return angle::Result::Stop;
} }
...@@ -548,10 +552,10 @@ void ProgramPipeline::validate(const gl::Context *context) ...@@ -548,10 +552,10 @@ void ProgramPipeline::validate(const gl::Context *context)
{ {
const Caps &caps = context->getCaps(); const Caps &caps = context->getCaps();
mState.mValid = true; mState.mValid = true;
InfoLog &infoLog = mState.mExecutable.getInfoLog(); InfoLog &infoLog = mState.mExecutable->getInfoLog();
infoLog.reset(); infoLog.reset();
for (const ShaderType shaderType : mState.mExecutable.getLinkedShaderStages()) for (const ShaderType shaderType : mState.mExecutable->getLinkedShaderStages())
{ {
Program *shaderProgram = mState.mPrograms[shaderType]; Program *shaderProgram = mState.mPrograms[shaderType];
if (shaderProgram) if (shaderProgram)
...@@ -579,7 +583,7 @@ void ProgramPipeline::validate(const gl::Context *context) ...@@ -579,7 +583,7 @@ void ProgramPipeline::validate(const gl::Context *context)
{ {
mState.mValid = false; mState.mValid = false;
for (const ShaderType shaderType : mState.mExecutable.getLinkedShaderStages()) for (const ShaderType shaderType : mState.mExecutable->getLinkedShaderStages())
{ {
Program *shaderProgram = mState.mPrograms[shaderType]; Program *shaderProgram = mState.mPrograms[shaderType];
ASSERT(shaderProgram); ASSERT(shaderProgram);
......
...@@ -44,8 +44,16 @@ class ProgramPipelineState final : angle::NonCopyable ...@@ -44,8 +44,16 @@ class ProgramPipelineState final : angle::NonCopyable
bool isCompute() const { return mIsCompute; } bool isCompute() const { return mIsCompute; }
void setIsCompute(bool isCompute) { mIsCompute = isCompute; } void setIsCompute(bool isCompute) { mIsCompute = isCompute; }
const ProgramExecutable &getProgramExecutable() const { return mExecutable; } const ProgramExecutable &getProgramExecutable() const
ProgramExecutable &getProgramExecutable() { return mExecutable; } {
ASSERT(mExecutable);
return *mExecutable;
}
ProgramExecutable &getProgramExecutable()
{
ASSERT(mExecutable);
return *mExecutable;
}
void activeShaderProgram(Program *shaderProgram); void activeShaderProgram(Program *shaderProgram);
void useProgramStages(const Context *context, GLbitfield stages, Program *shaderProgram); void useProgramStages(const Context *context, GLbitfield stages, Program *shaderProgram);
...@@ -84,7 +92,7 @@ class ProgramPipelineState final : angle::NonCopyable ...@@ -84,7 +92,7 @@ class ProgramPipelineState final : angle::NonCopyable
GLboolean mHasBeenBound; GLboolean mHasBeenBound;
ProgramExecutable mExecutable; ProgramExecutable *mExecutable;
}; };
class ProgramPipeline final : public RefCountObject<ProgramPipelineID>, public LabeledObject class ProgramPipeline final : public RefCountObject<ProgramPipelineID>, public LabeledObject
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment