Commit ce29916b by Tim Van Patten Committed by Commit Bot

Remove mProgramState from ProgramExecutable::isCompute()

ProgramExecutable::isCompute() is being updated to no longer use mProgramState or mProgramPipelineState, as part of the effort to remove those members from ProgramExecutable. Functionally, things are the same for PPOs, but Programs are being updated to use the boolean ProgramExecutable::mIsCompute rather than checking the linked shader stages to determine draw vs compute. Slightly unrelated, but this CL also removes the unused function ProgramPipeline::hasImages() which was missed in one of the earlier CLs in this relation chain. Bug: angleproject:4520 Test: Build/CQ Change-Id: Ief28021310d6d0b1be5b7608a59deb87b0cf591d Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2243326 Commit-Queue: Tim Van Patten <timvp@google.com> Reviewed-by: 's avatarCourtney Goeltzenleuchter <courtneygo@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent a28efb2f
......@@ -1683,6 +1683,15 @@ void Program::updateLinkedShaderStages()
mState.mExecutable->setLinkedShaderStages(shader->getType());
}
}
if (mState.mExecutable->hasLinkedShaderStage(ShaderType::Compute))
{
mState.mExecutable->setIsCompute(true);
}
else
{
mState.mExecutable->setIsCompute(false);
}
}
void ProgramState::updateTransformFeedbackStrides()
......
......@@ -41,7 +41,8 @@ ProgramExecutable::ProgramExecutable()
mPipelineHasGraphicsTextures(false),
mPipelineHasComputeTextures(false),
mPipelineHasGraphicsImages(false),
mPipelineHasComputeImages(false)
mPipelineHasComputeImages(false),
mIsCompute(false)
{
reset();
}
......@@ -87,7 +88,8 @@ ProgramExecutable::ProgramExecutable(const ProgramExecutable &other)
mPipelineHasGraphicsTextures(other.mPipelineHasGraphicsTextures),
mPipelineHasComputeTextures(other.mPipelineHasComputeTextures),
mPipelineHasGraphicsImages(other.mPipelineHasGraphicsImages),
mPipelineHasComputeImages(other.mPipelineHasComputeImages)
mPipelineHasComputeImages(other.mPipelineHasComputeImages),
mIsCompute(other.mIsCompute)
{
reset();
}
......@@ -144,6 +146,7 @@ void ProgramExecutable::load(gl::BinaryInputStream *stream)
mLinkedGraphicsShaderStages = ShaderBitSet(stream->readInt<uint8_t>());
mLinkedComputeShaderStages = ShaderBitSet(stream->readInt<uint8_t>());
mIsCompute = stream->readBool();
mPipelineHasGraphicsUniformBuffers = stream->readBool();
mPipelineHasComputeUniformBuffers = stream->readBool();
......@@ -168,6 +171,7 @@ void ProgramExecutable::save(gl::BinaryOutputStream *stream) const
stream->writeInt(mLinkedGraphicsShaderStages.bits());
stream->writeInt(mLinkedComputeShaderStages.bits());
stream->writeInt(static_cast<bool>(mIsCompute));
stream->writeInt(static_cast<bool>(mPipelineHasGraphicsUniformBuffers));
stream->writeInt(static_cast<bool>(mPipelineHasComputeUniformBuffers));
......@@ -197,30 +201,6 @@ const ProgramState *ProgramExecutable::getProgramState(ShaderType shaderType) co
return nullptr;
}
bool ProgramExecutable::isCompute() const
{
ASSERT(mProgramState || mProgramPipelineState);
if (mProgramState)
{
return mProgramState->isCompute();
}
return mProgramPipelineState->isCompute();
}
void ProgramExecutable::setIsCompute(bool isComputeIn)
{
// A Program can only either be graphics or compute, but never both, so it can answer
// isCompute() based on which shaders it has. However, a PPO can have both graphics and compute
// programs attached, so we don't know if the PPO is a 'graphics' or 'compute' PPO until the
// actual draw/dispatch call, which is why only PPOs need to record the type of call here.
if (mProgramPipelineState)
{
mProgramPipelineState->setIsCompute(isComputeIn);
}
}
int ProgramExecutable::getInfoLogLength() const
{
return static_cast<int>(mInfoLog.getLength());
......
......@@ -151,7 +151,12 @@ class ProgramExecutable
return isCompute() ? mLinkedComputeShaderStages.count()
: mLinkedGraphicsShaderStages.count();
}
bool isCompute() const;
// A PPO can have both graphics and compute programs attached, so
// we don't know if the PPO is a 'graphics' or 'compute' PPO until the
// actual draw/dispatch call.
bool isCompute() const { return mIsCompute; }
void setIsCompute(bool isCompute) { mIsCompute = isCompute; }
const AttributesMask &getActiveAttribLocationsMask() const
{
......@@ -211,8 +216,6 @@ class ProgramExecutable
mProgramPipelineState = state;
}
void setIsCompute(bool isComputeIn);
void updateCanDrawWith();
bool hasVertexAndFragmentShader() const { return mCanDrawWith; }
......@@ -385,6 +388,8 @@ class ProgramExecutable
bool mPipelineHasGraphicsImages;
bool mPipelineHasComputeImages;
bool mIsCompute;
ShaderMap<std::vector<sh::ShaderVariable>> mLinkedOutputVaryings;
ShaderMap<std::vector<sh::ShaderVariable>> mLinkedInputVaryings;
ShaderMap<int> mLinkedShaderVersions;
......
......@@ -24,7 +24,6 @@ namespace gl
ProgramPipelineState::ProgramPipelineState()
: mLabel(),
mIsCompute(false),
mActiveShaderProgram(nullptr),
mValid(false),
mHasBeenBound(false),
......@@ -124,20 +123,6 @@ bool ProgramPipelineState::usesShaderProgram(ShaderProgramID programId) const
return false;
}
bool ProgramPipelineState::hasImages() const
{
for (const gl::ShaderType shaderType : mExecutable->getLinkedShaderStages())
{
const Program *shaderProgram = getShaderProgram(shaderType);
if (shaderProgram && shaderProgram->getState().hasImages())
{
return true;
}
}
return false;
}
ProgramPipeline::ProgramPipeline(rx::GLImplFactory *factory, ProgramPipelineID handle)
: RefCountObject(factory->generateSerial(), handle),
mProgramPipelineImpl(factory->createProgramPipeline(mState))
......
......@@ -38,12 +38,6 @@ class ProgramPipelineState final : angle::NonCopyable
const std::string &getLabel() const;
// A PPO can have both graphics and compute programs attached, so
// we don't know if the PPO is a 'graphics' or 'compute' PPO until the
// actual draw/dispatch call.
bool isCompute() const { return mIsCompute; }
void setIsCompute(bool isCompute) { mIsCompute = isCompute; }
const ProgramExecutable &getProgramExecutable() const
{
ASSERT(mExecutable);
......@@ -66,8 +60,6 @@ class ProgramPipelineState final : angle::NonCopyable
bool usesShaderProgram(ShaderProgramID program) const;
bool hasImages() const;
private:
void useProgramStage(const Context *context, ShaderType shaderType, Program *shaderProgram);
......@@ -75,8 +67,6 @@ class ProgramPipelineState final : angle::NonCopyable
std::string mLabel;
bool mIsCompute;
// The active shader program
Program *mActiveShaderProgram;
// The shader programs for each stage.
......
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