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)
ASSERT(mLinked);
// Mark implementation-specific unreferenced uniforms as ignored.
mProgram->markUnusedUniformLocations(&mState.mUniformLocations, &mState.mSamplerBindings,
&mState.mImageBindings);
mProgram->markUnusedUniformLocations(
&mState.mUniformLocations, &mState.mExecutable->mSamplerBindings, &mState.mImageBindings);
// Must be called after markUnusedUniformLocations.
postResolveLink(context);
......@@ -1835,7 +1835,6 @@ void Program::unlink()
mState.mDrawBufferTypeMask.reset();
mState.mActiveOutputVariables.reset();
mState.mComputeShaderLocalSize.fill(1);
mState.mSamplerBindings.clear();
mState.mImageBindings.clear();
mState.mNumViews = -1;
mState.mGeometryShaderInputPrimitiveType = PrimitiveMode::Triangles;
......@@ -2130,12 +2129,6 @@ const std::vector<sh::ShaderVariable> &Program::getAttributes() const
return mState.mExecutable->getProgramInputs();
}
const std::vector<SamplerBinding> &Program::getSamplerBindings() const
{
ASSERT(!mLinkingState);
return mState.mSamplerBindings;
}
const sh::WorkGroupSize &Program::getComputeShaderLocalSize() const
{
ASSERT(!mLinkingState);
......@@ -2909,7 +2902,7 @@ GLuint Program::getSamplerUniformBinding(const VariableLocation &uniformLocation
ASSERT(!mLinkingState);
GLuint samplerIndex = mState.getSamplerIndexFromUniformIndex(uniformLocation.index);
const std::vector<GLuint> &boundTextureUnits =
mState.mSamplerBindings[samplerIndex].boundTextureUnits;
mState.mExecutable->mSamplerBindings[samplerIndex].boundTextureUnits;
return boundTextureUnits[uniformLocation.arrayIndex];
}
......@@ -3746,7 +3739,7 @@ void Program::linkSamplerAndImageBindings(GLuint *combinedImageUniforms)
TextureType textureType = SamplerTypeToTextureType(samplerUniform.type);
unsigned int elementCount = samplerUniform.getBasicTypeElementCount();
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.
......@@ -4903,7 +4896,7 @@ void Program::updateSamplerUniform(Context *context,
{
ASSERT(mState.isSamplerUniformIndex(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;
if (samplerBinding.unreferenced)
......@@ -4986,7 +4979,8 @@ void Program::updateSamplerUniform(Context *context,
void ProgramState::setSamplerUniformTextureTypeAndFormat(size_t textureUnitIndex)
{
mExecutable->setSamplerUniformTextureTypeAndFormat(textureUnitIndex, mSamplerBindings);
mExecutable->setSamplerUniformTextureTypeAndFormat(textureUnitIndex,
mExecutable->mSamplerBindings);
}
template <typename T>
......@@ -5500,7 +5494,8 @@ angle::Result Program::deserialize(const Context *context,
SamplerFormat format = stream.readEnum<SamplerFormat>();
size_t bindingCount = stream.readInt<size_t>();
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>();
......
......@@ -258,7 +258,10 @@ class ProgramState final : angle::NonCopyable
return mExecutable->getShaderStorageBlocks();
}
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 sh::WorkGroupSize &getComputeShaderLocalSize() const { return mComputeShaderLocalSize; }
const RangeUI &getDefaultUniformRange() const { return mExecutable->getDefaultUniformRange(); }
......@@ -316,7 +319,6 @@ class ProgramState final : angle::NonCopyable
return *mExecutable;
}
bool hasTextures() const { return !getSamplerBindings().empty(); }
bool hasImages() const { return !getImageBindings().empty(); }
bool hasEarlyFragmentTestsOptimization() const { return mEarlyFramentTestsOptimization; }
......@@ -359,9 +361,6 @@ class ProgramState final : angle::NonCopyable
std::vector<BufferVariable> mBufferVariables;
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
std::vector<ImageBinding> mImageBindings;
......@@ -704,7 +703,6 @@ class Program final : angle::NonCopyable, public LabeledObject
Optional<bool> getCachedValidateSamplersResult() { return mCachedValidateSamplersResult; }
void setCachedValidateSamplersResult(bool result) { mCachedValidateSamplersResult = result; }
const std::vector<SamplerBinding> &getSamplerBindings() const;
const std::vector<ImageBinding> &getImageBindings() const
{
ASSERT(!mLinkingState);
......
......@@ -37,7 +37,9 @@ ProgramExecutable::ProgramExecutable()
mPipelineHasGraphicsAtomicCounterBuffers(false),
mPipelineHasComputeAtomicCounterBuffers(false),
mPipelineHasGraphicsDefaultUniforms(false),
mPipelineHasComputeDefaultUniforms(false)
mPipelineHasComputeDefaultUniforms(false),
mPipelineHasGraphicsTextures(false),
mPipelineHasComputeTextures(false)
{
reset();
}
......@@ -79,7 +81,9 @@ ProgramExecutable::ProgramExecutable(const ProgramExecutable &other)
mPipelineHasGraphicsAtomicCounterBuffers(other.mPipelineHasGraphicsAtomicCounterBuffers),
mPipelineHasComputeAtomicCounterBuffers(other.mPipelineHasComputeAtomicCounterBuffers),
mPipelineHasGraphicsDefaultUniforms(other.mPipelineHasGraphicsDefaultUniforms),
mPipelineHasComputeDefaultUniforms(other.mPipelineHasComputeDefaultUniforms)
mPipelineHasComputeDefaultUniforms(other.mPipelineHasComputeDefaultUniforms),
mPipelineHasGraphicsTextures(other.mPipelineHasGraphicsTextures),
mPipelineHasComputeTextures(other.mPipelineHasComputeTextures)
{
reset();
}
......@@ -109,6 +113,7 @@ void ProgramExecutable::reset()
mAtomicCounterBuffers.clear();
mOutputVariables.clear();
mOutputLocations.clear();
mSamplerBindings.clear();
mPipelineHasGraphicsUniformBuffers = false;
mPipelineHasComputeUniformBuffers = false;
......@@ -118,6 +123,8 @@ void ProgramExecutable::reset()
mPipelineHasComputeAtomicCounterBuffers = false;
mPipelineHasGraphicsDefaultUniforms = false;
mPipelineHasComputeDefaultUniforms = false;
mPipelineHasGraphicsTextures = false;
mPipelineHasComputeTextures = false;
}
void ProgramExecutable::load(gl::BinaryInputStream *stream)
......@@ -141,6 +148,8 @@ void ProgramExecutable::load(gl::BinaryInputStream *stream)
mPipelineHasComputeAtomicCounterBuffers = stream->readBool();
mPipelineHasGraphicsDefaultUniforms = stream->readBool();
mPipelineHasComputeDefaultUniforms = stream->readBool();
mPipelineHasGraphicsTextures = stream->readBool();
mPipelineHasComputeTextures = stream->readBool();
}
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>(mPipelineHasGraphicsDefaultUniforms));
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
......@@ -241,16 +252,10 @@ bool ProgramExecutable::hasDefaultUniforms() const
(isCompute() ? mPipelineHasComputeDefaultUniforms : mPipelineHasGraphicsDefaultUniforms);
}
// TODO: http://anglebug.com/4520: Needs mSamplerBindings moved to ProgramExecutable
bool ProgramExecutable::hasTextures() const
{
ASSERT(mProgramState || mProgramPipelineState);
if (mProgramState)
{
return mProgramState->hasTextures();
}
return mProgramPipelineState->hasTextures();
return !getSamplerBindings().empty() ||
(isCompute() ? mPipelineHasComputeTextures : mPipelineHasGraphicsTextures);
}
// TODO: http://anglebug.com/3570: Remove mHas*UniformBuffers once PPO's have valid data in
......
......@@ -221,6 +221,7 @@ class ProgramExecutable
const std::vector<VariableLocation> &getOutputLocations() const { return mOutputLocations; }
const std::vector<LinkedUniform> &getUniforms() const { return mUniforms; }
const std::vector<InterfaceBlock> &getUniformBlocks() const { return mUniformBlocks; }
const std::vector<SamplerBinding> &getSamplerBindings() const { return mSamplerBindings; }
const RangeUI &getDefaultUniformRange() const { return mDefaultUniformRange; }
const RangeUI &getSamplerUniformRange() const { return mSamplerUniformRange; }
const RangeUI &getImageUniformRange() const { return mImageUniformRange; }
......@@ -360,6 +361,9 @@ class ProgramExecutable
RangeUI mImageUniformRange;
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
// in mUniformBlocks
bool mPipelineHasGraphicsUniformBuffers;
......@@ -370,6 +374,8 @@ class ProgramExecutable
bool mPipelineHasComputeAtomicCounterBuffers;
bool mPipelineHasGraphicsDefaultUniforms;
bool mPipelineHasComputeDefaultUniforms;
bool mPipelineHasGraphicsTextures;
bool mPipelineHasComputeTextures;
ShaderMap<std::vector<sh::ShaderVariable>> mLinkedOutputVaryings;
ShaderMap<std::vector<sh::ShaderVariable>> mLinkedInputVaryings;
......
......@@ -124,20 +124,6 @@ bool ProgramPipelineState::usesShaderProgram(ShaderProgramID programId) const
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
{
for (const gl::ShaderType shaderType : mExecutable->getLinkedShaderStages())
......@@ -298,6 +284,10 @@ void ProgramPipeline::updateHasBooleans()
{
mState.mExecutable->mPipelineHasGraphicsDefaultUniforms = true;
}
if (executable.hasTextures())
{
mState.mExecutable->mPipelineHasGraphicsTextures = true;
}
}
}
......@@ -322,6 +312,10 @@ void ProgramPipeline::updateHasBooleans()
{
mState.mExecutable->mPipelineHasComputeDefaultUniforms = true;
}
if (executable.hasTextures())
{
mState.mExecutable->mPipelineHasComputeTextures = true;
}
}
}
......
......@@ -66,7 +66,6 @@ class ProgramPipelineState final : angle::NonCopyable
bool usesShaderProgram(ShaderProgramID program) const;
bool hasTextures() const;
bool hasImages() const;
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