Commit c117e360 by Tim Van Patten Committed by Commit Bot

Move ProgramState::mSamplerBindings to ProgramExecutable

The member ProgramState::mSamplerBindings is being moved to ProgramExecutable to allow ProgramExecutable::getSamplerBindings() to answer the query without relying on the Program[Pipeline]State. Bug: angleproject:4520 Test: Build/CQ Change-Id: I0daa997424d6e2aa5172e0731da221db72063435 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2233363Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCourtney Goeltzenleuchter <courtneygo@google.com> Commit-Queue: Tim Van Patten <timvp@google.com>
parent 11e26fa0
...@@ -1655,8 +1655,8 @@ void Program::resolveLinkImpl(const Context *context) ...@@ -1655,8 +1655,8 @@ void Program::resolveLinkImpl(const Context *context)
ASSERT(mLinked); ASSERT(mLinked);
// Mark implementation-specific unreferenced uniforms as ignored. // Mark implementation-specific unreferenced uniforms as ignored.
mProgram->markUnusedUniformLocations(&mState.mUniformLocations, &mState.mSamplerBindings, mProgram->markUnusedUniformLocations(
&mState.mImageBindings); &mState.mUniformLocations, &mState.mExecutable->mSamplerBindings, &mState.mImageBindings);
// Must be called after markUnusedUniformLocations. // Must be called after markUnusedUniformLocations.
postResolveLink(context); postResolveLink(context);
...@@ -1835,7 +1835,6 @@ void Program::unlink() ...@@ -1835,7 +1835,6 @@ void Program::unlink()
mState.mDrawBufferTypeMask.reset(); mState.mDrawBufferTypeMask.reset();
mState.mActiveOutputVariables.reset(); mState.mActiveOutputVariables.reset();
mState.mComputeShaderLocalSize.fill(1); mState.mComputeShaderLocalSize.fill(1);
mState.mSamplerBindings.clear();
mState.mImageBindings.clear(); mState.mImageBindings.clear();
mState.mNumViews = -1; mState.mNumViews = -1;
mState.mGeometryShaderInputPrimitiveType = PrimitiveMode::Triangles; mState.mGeometryShaderInputPrimitiveType = PrimitiveMode::Triangles;
...@@ -2130,12 +2129,6 @@ const std::vector<sh::ShaderVariable> &Program::getAttributes() const ...@@ -2130,12 +2129,6 @@ const std::vector<sh::ShaderVariable> &Program::getAttributes() const
return mState.mExecutable->getProgramInputs(); return mState.mExecutable->getProgramInputs();
} }
const std::vector<SamplerBinding> &Program::getSamplerBindings() const
{
ASSERT(!mLinkingState);
return mState.mSamplerBindings;
}
const sh::WorkGroupSize &Program::getComputeShaderLocalSize() const const sh::WorkGroupSize &Program::getComputeShaderLocalSize() const
{ {
ASSERT(!mLinkingState); ASSERT(!mLinkingState);
...@@ -2909,7 +2902,7 @@ GLuint Program::getSamplerUniformBinding(const VariableLocation &uniformLocation ...@@ -2909,7 +2902,7 @@ GLuint Program::getSamplerUniformBinding(const VariableLocation &uniformLocation
ASSERT(!mLinkingState); ASSERT(!mLinkingState);
GLuint samplerIndex = mState.getSamplerIndexFromUniformIndex(uniformLocation.index); GLuint samplerIndex = mState.getSamplerIndexFromUniformIndex(uniformLocation.index);
const std::vector<GLuint> &boundTextureUnits = const std::vector<GLuint> &boundTextureUnits =
mState.mSamplerBindings[samplerIndex].boundTextureUnits; mState.mExecutable->mSamplerBindings[samplerIndex].boundTextureUnits;
return boundTextureUnits[uniformLocation.arrayIndex]; return boundTextureUnits[uniformLocation.arrayIndex];
} }
...@@ -3746,7 +3739,7 @@ void Program::linkSamplerAndImageBindings(GLuint *combinedImageUniforms) ...@@ -3746,7 +3739,7 @@ void Program::linkSamplerAndImageBindings(GLuint *combinedImageUniforms)
TextureType textureType = SamplerTypeToTextureType(samplerUniform.type); TextureType textureType = SamplerTypeToTextureType(samplerUniform.type);
unsigned int elementCount = samplerUniform.getBasicTypeElementCount(); unsigned int elementCount = samplerUniform.getBasicTypeElementCount();
SamplerFormat format = samplerUniform.typeInfo->samplerFormat; SamplerFormat format = samplerUniform.typeInfo->samplerFormat;
mState.mSamplerBindings.emplace_back(textureType, format, elementCount, false); mState.mExecutable->mSamplerBindings.emplace_back(textureType, format, elementCount, false);
} }
// Whatever is left constitutes the default uniforms. // Whatever is left constitutes the default uniforms.
...@@ -4903,7 +4896,7 @@ void Program::updateSamplerUniform(Context *context, ...@@ -4903,7 +4896,7 @@ void Program::updateSamplerUniform(Context *context,
{ {
ASSERT(mState.isSamplerUniformIndex(locationInfo.index)); ASSERT(mState.isSamplerUniformIndex(locationInfo.index));
GLuint samplerIndex = mState.getSamplerIndexFromUniformIndex(locationInfo.index); GLuint samplerIndex = mState.getSamplerIndexFromUniformIndex(locationInfo.index);
SamplerBinding &samplerBinding = mState.mSamplerBindings[samplerIndex]; SamplerBinding &samplerBinding = mState.mExecutable->mSamplerBindings[samplerIndex];
std::vector<GLuint> &boundTextureUnits = samplerBinding.boundTextureUnits; std::vector<GLuint> &boundTextureUnits = samplerBinding.boundTextureUnits;
if (samplerBinding.unreferenced) if (samplerBinding.unreferenced)
...@@ -4986,7 +4979,8 @@ void Program::updateSamplerUniform(Context *context, ...@@ -4986,7 +4979,8 @@ void Program::updateSamplerUniform(Context *context,
void ProgramState::setSamplerUniformTextureTypeAndFormat(size_t textureUnitIndex) void ProgramState::setSamplerUniformTextureTypeAndFormat(size_t textureUnitIndex)
{ {
mExecutable->setSamplerUniformTextureTypeAndFormat(textureUnitIndex, mSamplerBindings); mExecutable->setSamplerUniformTextureTypeAndFormat(textureUnitIndex,
mExecutable->mSamplerBindings);
} }
template <typename T> template <typename T>
...@@ -5500,7 +5494,8 @@ angle::Result Program::deserialize(const Context *context, ...@@ -5500,7 +5494,8 @@ angle::Result Program::deserialize(const Context *context,
SamplerFormat format = stream.readEnum<SamplerFormat>(); SamplerFormat format = stream.readEnum<SamplerFormat>();
size_t bindingCount = stream.readInt<size_t>(); size_t bindingCount = stream.readInt<size_t>();
bool unreferenced = stream.readBool(); bool unreferenced = stream.readBool();
mState.mSamplerBindings.emplace_back(textureType, format, bindingCount, unreferenced); mState.mExecutable->mSamplerBindings.emplace_back(textureType, format, bindingCount,
unreferenced);
} }
unsigned int imageRangeLow = stream.readInt<unsigned int>(); unsigned int imageRangeLow = stream.readInt<unsigned int>();
......
...@@ -258,7 +258,10 @@ class ProgramState final : angle::NonCopyable ...@@ -258,7 +258,10 @@ class ProgramState final : angle::NonCopyable
return mExecutable->getShaderStorageBlocks(); return mExecutable->getShaderStorageBlocks();
} }
const std::vector<BufferVariable> &getBufferVariables() const { return mBufferVariables; } const std::vector<BufferVariable> &getBufferVariables() const { return mBufferVariables; }
const std::vector<SamplerBinding> &getSamplerBindings() const { return mSamplerBindings; } const std::vector<SamplerBinding> &getSamplerBindings() const
{
return mExecutable->getSamplerBindings();
}
const std::vector<ImageBinding> &getImageBindings() const { return mImageBindings; } const std::vector<ImageBinding> &getImageBindings() const { return mImageBindings; }
const sh::WorkGroupSize &getComputeShaderLocalSize() const { return mComputeShaderLocalSize; } const sh::WorkGroupSize &getComputeShaderLocalSize() const { return mComputeShaderLocalSize; }
const RangeUI &getDefaultUniformRange() const { return mExecutable->getDefaultUniformRange(); } const RangeUI &getDefaultUniformRange() const { return mExecutable->getDefaultUniformRange(); }
...@@ -316,7 +319,6 @@ class ProgramState final : angle::NonCopyable ...@@ -316,7 +319,6 @@ class ProgramState final : angle::NonCopyable
return *mExecutable; return *mExecutable;
} }
bool hasTextures() const { return !getSamplerBindings().empty(); }
bool hasImages() const { return !getImageBindings().empty(); } bool hasImages() const { return !getImageBindings().empty(); }
bool hasEarlyFragmentTestsOptimization() const { return mEarlyFramentTestsOptimization; } bool hasEarlyFragmentTestsOptimization() const { return mEarlyFramentTestsOptimization; }
...@@ -359,9 +361,6 @@ class ProgramState final : angle::NonCopyable ...@@ -359,9 +361,6 @@ class ProgramState final : angle::NonCopyable
std::vector<BufferVariable> mBufferVariables; std::vector<BufferVariable> mBufferVariables;
RangeUI mAtomicCounterUniformRange; RangeUI mAtomicCounterUniformRange;
// An array of the samplers that are used by the program
std::vector<SamplerBinding> mSamplerBindings;
// An array of the images that are used by the program // An array of the images that are used by the program
std::vector<ImageBinding> mImageBindings; std::vector<ImageBinding> mImageBindings;
...@@ -704,7 +703,6 @@ class Program final : angle::NonCopyable, public LabeledObject ...@@ -704,7 +703,6 @@ class Program final : angle::NonCopyable, public LabeledObject
Optional<bool> getCachedValidateSamplersResult() { return mCachedValidateSamplersResult; } Optional<bool> getCachedValidateSamplersResult() { return mCachedValidateSamplersResult; }
void setCachedValidateSamplersResult(bool result) { mCachedValidateSamplersResult = result; } void setCachedValidateSamplersResult(bool result) { mCachedValidateSamplersResult = result; }
const std::vector<SamplerBinding> &getSamplerBindings() const;
const std::vector<ImageBinding> &getImageBindings() const const std::vector<ImageBinding> &getImageBindings() const
{ {
ASSERT(!mLinkingState); ASSERT(!mLinkingState);
......
...@@ -37,7 +37,9 @@ ProgramExecutable::ProgramExecutable() ...@@ -37,7 +37,9 @@ ProgramExecutable::ProgramExecutable()
mPipelineHasGraphicsAtomicCounterBuffers(false), mPipelineHasGraphicsAtomicCounterBuffers(false),
mPipelineHasComputeAtomicCounterBuffers(false), mPipelineHasComputeAtomicCounterBuffers(false),
mPipelineHasGraphicsDefaultUniforms(false), mPipelineHasGraphicsDefaultUniforms(false),
mPipelineHasComputeDefaultUniforms(false) mPipelineHasComputeDefaultUniforms(false),
mPipelineHasGraphicsTextures(false),
mPipelineHasComputeTextures(false)
{ {
reset(); reset();
} }
...@@ -79,7 +81,9 @@ ProgramExecutable::ProgramExecutable(const ProgramExecutable &other) ...@@ -79,7 +81,9 @@ ProgramExecutable::ProgramExecutable(const ProgramExecutable &other)
mPipelineHasGraphicsAtomicCounterBuffers(other.mPipelineHasGraphicsAtomicCounterBuffers), mPipelineHasGraphicsAtomicCounterBuffers(other.mPipelineHasGraphicsAtomicCounterBuffers),
mPipelineHasComputeAtomicCounterBuffers(other.mPipelineHasComputeAtomicCounterBuffers), mPipelineHasComputeAtomicCounterBuffers(other.mPipelineHasComputeAtomicCounterBuffers),
mPipelineHasGraphicsDefaultUniforms(other.mPipelineHasGraphicsDefaultUniforms), mPipelineHasGraphicsDefaultUniforms(other.mPipelineHasGraphicsDefaultUniforms),
mPipelineHasComputeDefaultUniforms(other.mPipelineHasComputeDefaultUniforms) mPipelineHasComputeDefaultUniforms(other.mPipelineHasComputeDefaultUniforms),
mPipelineHasGraphicsTextures(other.mPipelineHasGraphicsTextures),
mPipelineHasComputeTextures(other.mPipelineHasComputeTextures)
{ {
reset(); reset();
} }
...@@ -109,6 +113,7 @@ void ProgramExecutable::reset() ...@@ -109,6 +113,7 @@ void ProgramExecutable::reset()
mAtomicCounterBuffers.clear(); mAtomicCounterBuffers.clear();
mOutputVariables.clear(); mOutputVariables.clear();
mOutputLocations.clear(); mOutputLocations.clear();
mSamplerBindings.clear();
mPipelineHasGraphicsUniformBuffers = false; mPipelineHasGraphicsUniformBuffers = false;
mPipelineHasComputeUniformBuffers = false; mPipelineHasComputeUniformBuffers = false;
...@@ -118,6 +123,8 @@ void ProgramExecutable::reset() ...@@ -118,6 +123,8 @@ void ProgramExecutable::reset()
mPipelineHasComputeAtomicCounterBuffers = false; mPipelineHasComputeAtomicCounterBuffers = false;
mPipelineHasGraphicsDefaultUniforms = false; mPipelineHasGraphicsDefaultUniforms = false;
mPipelineHasComputeDefaultUniforms = false; mPipelineHasComputeDefaultUniforms = false;
mPipelineHasGraphicsTextures = false;
mPipelineHasComputeTextures = false;
} }
void ProgramExecutable::load(gl::BinaryInputStream *stream) void ProgramExecutable::load(gl::BinaryInputStream *stream)
...@@ -141,6 +148,8 @@ void ProgramExecutable::load(gl::BinaryInputStream *stream) ...@@ -141,6 +148,8 @@ void ProgramExecutable::load(gl::BinaryInputStream *stream)
mPipelineHasComputeAtomicCounterBuffers = stream->readBool(); mPipelineHasComputeAtomicCounterBuffers = stream->readBool();
mPipelineHasGraphicsDefaultUniforms = stream->readBool(); mPipelineHasGraphicsDefaultUniforms = stream->readBool();
mPipelineHasComputeDefaultUniforms = stream->readBool(); mPipelineHasComputeDefaultUniforms = stream->readBool();
mPipelineHasGraphicsTextures = stream->readBool();
mPipelineHasComputeTextures = stream->readBool();
} }
void ProgramExecutable::save(gl::BinaryOutputStream *stream) const void ProgramExecutable::save(gl::BinaryOutputStream *stream) const
...@@ -163,6 +172,8 @@ void ProgramExecutable::save(gl::BinaryOutputStream *stream) const ...@@ -163,6 +172,8 @@ void ProgramExecutable::save(gl::BinaryOutputStream *stream) const
stream->writeInt(static_cast<bool>(mPipelineHasComputeAtomicCounterBuffers)); stream->writeInt(static_cast<bool>(mPipelineHasComputeAtomicCounterBuffers));
stream->writeInt(static_cast<bool>(mPipelineHasGraphicsDefaultUniforms)); stream->writeInt(static_cast<bool>(mPipelineHasGraphicsDefaultUniforms));
stream->writeInt(static_cast<bool>(mPipelineHasComputeDefaultUniforms)); stream->writeInt(static_cast<bool>(mPipelineHasComputeDefaultUniforms));
stream->writeInt(static_cast<bool>(mPipelineHasGraphicsTextures));
stream->writeInt(static_cast<bool>(mPipelineHasComputeTextures));
} }
const ProgramState *ProgramExecutable::getProgramState(ShaderType shaderType) const const ProgramState *ProgramExecutable::getProgramState(ShaderType shaderType) const
...@@ -241,16 +252,10 @@ bool ProgramExecutable::hasDefaultUniforms() const ...@@ -241,16 +252,10 @@ bool ProgramExecutable::hasDefaultUniforms() const
(isCompute() ? mPipelineHasComputeDefaultUniforms : mPipelineHasGraphicsDefaultUniforms); (isCompute() ? mPipelineHasComputeDefaultUniforms : mPipelineHasGraphicsDefaultUniforms);
} }
// TODO: http://anglebug.com/4520: Needs mSamplerBindings moved to ProgramExecutable
bool ProgramExecutable::hasTextures() const bool ProgramExecutable::hasTextures() const
{ {
ASSERT(mProgramState || mProgramPipelineState); return !getSamplerBindings().empty() ||
if (mProgramState) (isCompute() ? mPipelineHasComputeTextures : mPipelineHasGraphicsTextures);
{
return mProgramState->hasTextures();
}
return mProgramPipelineState->hasTextures();
} }
// TODO: http://anglebug.com/3570: Remove mHas*UniformBuffers once PPO's have valid data in // TODO: http://anglebug.com/3570: Remove mHas*UniformBuffers once PPO's have valid data in
......
...@@ -221,6 +221,7 @@ class ProgramExecutable ...@@ -221,6 +221,7 @@ class ProgramExecutable
const std::vector<VariableLocation> &getOutputLocations() const { return mOutputLocations; } const std::vector<VariableLocation> &getOutputLocations() const { return mOutputLocations; }
const std::vector<LinkedUniform> &getUniforms() const { return mUniforms; } const std::vector<LinkedUniform> &getUniforms() const { return mUniforms; }
const std::vector<InterfaceBlock> &getUniformBlocks() const { return mUniformBlocks; } const std::vector<InterfaceBlock> &getUniformBlocks() const { return mUniformBlocks; }
const std::vector<SamplerBinding> &getSamplerBindings() const { return mSamplerBindings; }
const RangeUI &getDefaultUniformRange() const { return mDefaultUniformRange; } const RangeUI &getDefaultUniformRange() const { return mDefaultUniformRange; }
const RangeUI &getSamplerUniformRange() const { return mSamplerUniformRange; } const RangeUI &getSamplerUniformRange() const { return mSamplerUniformRange; }
const RangeUI &getImageUniformRange() const { return mImageUniformRange; } const RangeUI &getImageUniformRange() const { return mImageUniformRange; }
...@@ -360,6 +361,9 @@ class ProgramExecutable ...@@ -360,6 +361,9 @@ class ProgramExecutable
RangeUI mImageUniformRange; RangeUI mImageUniformRange;
std::vector<InterfaceBlock> mShaderStorageBlocks; std::vector<InterfaceBlock> mShaderStorageBlocks;
// An array of the samplers that are used by the program
std::vector<SamplerBinding> mSamplerBindings;
// TODO: http://anglebug.com/3570: Remove mPipelineHas*UniformBuffers once PPO's have valid data // TODO: http://anglebug.com/3570: Remove mPipelineHas*UniformBuffers once PPO's have valid data
// in mUniformBlocks // in mUniformBlocks
bool mPipelineHasGraphicsUniformBuffers; bool mPipelineHasGraphicsUniformBuffers;
...@@ -370,6 +374,8 @@ class ProgramExecutable ...@@ -370,6 +374,8 @@ class ProgramExecutable
bool mPipelineHasComputeAtomicCounterBuffers; bool mPipelineHasComputeAtomicCounterBuffers;
bool mPipelineHasGraphicsDefaultUniforms; bool mPipelineHasGraphicsDefaultUniforms;
bool mPipelineHasComputeDefaultUniforms; bool mPipelineHasComputeDefaultUniforms;
bool mPipelineHasGraphicsTextures;
bool mPipelineHasComputeTextures;
ShaderMap<std::vector<sh::ShaderVariable>> mLinkedOutputVaryings; ShaderMap<std::vector<sh::ShaderVariable>> mLinkedOutputVaryings;
ShaderMap<std::vector<sh::ShaderVariable>> mLinkedInputVaryings; ShaderMap<std::vector<sh::ShaderVariable>> mLinkedInputVaryings;
......
...@@ -124,20 +124,6 @@ bool ProgramPipelineState::usesShaderProgram(ShaderProgramID programId) const ...@@ -124,20 +124,6 @@ bool ProgramPipelineState::usesShaderProgram(ShaderProgramID programId) const
return false; return false;
} }
bool ProgramPipelineState::hasTextures() const
{
for (const gl::ShaderType shaderType : mExecutable->getLinkedShaderStages())
{
const Program *shaderProgram = getShaderProgram(shaderType);
if (shaderProgram && shaderProgram->getState().hasTextures())
{
return true;
}
}
return false;
}
bool ProgramPipelineState::hasImages() const bool ProgramPipelineState::hasImages() const
{ {
for (const gl::ShaderType shaderType : mExecutable->getLinkedShaderStages()) for (const gl::ShaderType shaderType : mExecutable->getLinkedShaderStages())
...@@ -298,6 +284,10 @@ void ProgramPipeline::updateHasBooleans() ...@@ -298,6 +284,10 @@ void ProgramPipeline::updateHasBooleans()
{ {
mState.mExecutable->mPipelineHasGraphicsDefaultUniforms = true; mState.mExecutable->mPipelineHasGraphicsDefaultUniforms = true;
} }
if (executable.hasTextures())
{
mState.mExecutable->mPipelineHasGraphicsTextures = true;
}
} }
} }
...@@ -322,6 +312,10 @@ void ProgramPipeline::updateHasBooleans() ...@@ -322,6 +312,10 @@ void ProgramPipeline::updateHasBooleans()
{ {
mState.mExecutable->mPipelineHasComputeDefaultUniforms = true; mState.mExecutable->mPipelineHasComputeDefaultUniforms = true;
} }
if (executable.hasTextures())
{
mState.mExecutable->mPipelineHasComputeTextures = true;
}
} }
} }
......
...@@ -66,7 +66,6 @@ class ProgramPipelineState final : angle::NonCopyable ...@@ -66,7 +66,6 @@ class ProgramPipelineState final : angle::NonCopyable
bool usesShaderProgram(ShaderProgramID program) const; bool usesShaderProgram(ShaderProgramID program) const;
bool hasTextures() const;
bool hasImages() const; bool hasImages() const;
private: private:
......
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