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
...@@ -1096,15 +1096,18 @@ ProgramState::ProgramState() ...@@ -1096,15 +1096,18 @@ ProgramState::ProgramState()
mBaseVertexLocation(-1), mBaseVertexLocation(-1),
mBaseInstanceLocation(-1), mBaseInstanceLocation(-1),
mCachedBaseVertex(0), mCachedBaseVertex(0),
mCachedBaseInstance(0) mCachedBaseInstance(0),
mExecutable(new ProgramExecutable())
{ {
mComputeShaderLocalSize.fill(1); mComputeShaderLocalSize.fill(1);
mExecutable.setProgramState(this);
mExecutable->setProgramState(this);
} }
ProgramState::~ProgramState() ProgramState::~ProgramState()
{ {
ASSERT(!hasAttachedShader()); ASSERT(!hasAttachedShader());
SafeDelete(mExecutable);
} }
const std::string &ProgramState::getLabel() const std::string &ProgramState::getLabel()
...@@ -1211,12 +1214,12 @@ bool ProgramState::hasAttachedShader() const ...@@ -1211,12 +1214,12 @@ bool ProgramState::hasAttachedShader() const
ShaderType ProgramState::getFirstAttachedShaderStageType() const ShaderType ProgramState::getFirstAttachedShaderStageType() const
{ {
if (mExecutable.getLinkedShaderStages().none()) if (mExecutable->getLinkedShaderStages().none())
{ {
return ShaderType::InvalidEnum; return ShaderType::InvalidEnum;
} }
return *mExecutable.getLinkedShaderStages().begin(); return *mExecutable->getLinkedShaderStages().begin();
} }
ShaderType ProgramState::getLastAttachedShaderStageType() const ShaderType ProgramState::getLastAttachedShaderStageType() const
...@@ -1225,13 +1228,13 @@ ShaderType ProgramState::getLastAttachedShaderStageType() const ...@@ -1225,13 +1228,13 @@ ShaderType ProgramState::getLastAttachedShaderStageType() const
{ {
const gl::ShaderType shaderType = gl::kAllGraphicsShaderTypes[i]; const gl::ShaderType shaderType = gl::kAllGraphicsShaderTypes[i];
if (mExecutable.hasLinkedShaderStage(shaderType)) if (mExecutable->hasLinkedShaderStage(shaderType))
{ {
return shaderType; return shaderType;
} }
} }
if (mExecutable.hasLinkedShaderStage(ShaderType::Compute)) if (mExecutable->hasLinkedShaderStage(ShaderType::Compute))
{ {
return ShaderType::Compute; return ShaderType::Compute;
} }
...@@ -1414,7 +1417,7 @@ angle::Result Program::link(const Context *context) ...@@ -1414,7 +1417,7 @@ angle::Result Program::link(const Context *context)
{ {
ASSERT(mLinkResolved); ASSERT(mLinkResolved);
const auto &data = context->getState(); const auto &data = context->getState();
InfoLog &infoLog = mState.mExecutable.getInfoLog(); InfoLog &infoLog = mState.mExecutable->getInfoLog();
auto *platform = ANGLEPlatformCurrent(); auto *platform = ANGLEPlatformCurrent();
double startTime = platform->currentTime(platform); double startTime = platform->currentTime(platform);
...@@ -1546,7 +1549,7 @@ angle::Result Program::link(const Context *context) ...@@ -1546,7 +1549,7 @@ angle::Result Program::link(const Context *context)
return angle::Result::Continue; return angle::Result::Continue;
} }
if (!mState.mExecutable.linkValidateGlobalNames(infoLog)) if (!mState.mExecutable->linkValidateGlobalNames(infoLog))
{ {
return angle::Result::Continue; return angle::Result::Continue;
} }
...@@ -1660,13 +1663,13 @@ void Program::resolveLinkImpl(const Context *context) ...@@ -1660,13 +1663,13 @@ void Program::resolveLinkImpl(const Context *context)
void Program::updateLinkedShaderStages() void Program::updateLinkedShaderStages()
{ {
mState.mExecutable.resetLinkedShaderStages(); mState.mExecutable->resetLinkedShaderStages();
for (const Shader *shader : mState.mAttachedShaders) for (const Shader *shader : mState.mAttachedShaders)
{ {
if (shader) if (shader)
{ {
mState.mExecutable.setLinkedShaderStages(shader->getType()); mState.mExecutable->setLinkedShaderStages(shader->getType());
} }
} }
} }
...@@ -1697,13 +1700,13 @@ void ProgramState::updateTransformFeedbackStrides() ...@@ -1697,13 +1700,13 @@ void ProgramState::updateTransformFeedbackStrides()
void ProgramState::updateActiveSamplers() void ProgramState::updateActiveSamplers()
{ {
mExecutable.mActiveSamplerRefCounts.fill(0); mExecutable->mActiveSamplerRefCounts.fill(0);
mExecutable.updateActiveSamplers(*this); mExecutable->updateActiveSamplers(*this);
} }
void ProgramState::updateActiveImages() void ProgramState::updateActiveImages()
{ {
mExecutable.updateActiveImages(mImageBindings); mExecutable->updateActiveImages(mImageBindings);
} }
void ProgramState::updateProgramInterfaceInputs() void ProgramState::updateProgramInterfaceInputs()
...@@ -1832,7 +1835,7 @@ void Program::unlink() ...@@ -1832,7 +1835,7 @@ void Program::unlink()
mLinked = false; mLinked = false;
mState.mExecutable.reset(); mState.mExecutable->reset();
} }
angle::Result Program::loadBinary(const Context *context, angle::Result Program::loadBinary(const Context *context,
...@@ -1840,7 +1843,7 @@ angle::Result Program::loadBinary(const Context *context, ...@@ -1840,7 +1843,7 @@ angle::Result Program::loadBinary(const Context *context,
const void *binary, const void *binary,
GLsizei length) GLsizei length)
{ {
InfoLog &infoLog = mState.mExecutable.getInfoLog(); InfoLog &infoLog = mState.mExecutable->getInfoLog();
ASSERT(mLinkResolved); ASSERT(mLinkResolved);
unlink(); unlink();
...@@ -2971,8 +2974,8 @@ bool Program::isFlaggedForDeletion() const ...@@ -2971,8 +2974,8 @@ bool Program::isFlaggedForDeletion() const
void Program::validate(const Caps &caps) void Program::validate(const Caps &caps)
{ {
ASSERT(mLinkResolved); ASSERT(mLinkResolved);
mState.mExecutable.resetInfoLog(); mState.mExecutable->resetInfoLog();
InfoLog &infoLog = mState.mExecutable.getInfoLog(); InfoLog &infoLog = mState.mExecutable->getInfoLog();
if (mLinked) if (mLinked)
{ {
...@@ -2986,15 +2989,15 @@ void Program::validate(const Caps &caps) ...@@ -2986,15 +2989,15 @@ void Program::validate(const Caps &caps)
bool Program::validateSamplersImpl(InfoLog *infoLog, const Caps &caps) bool Program::validateSamplersImpl(InfoLog *infoLog, const Caps &caps)
{ {
const ProgramExecutable &executable = mState.mExecutable; const ProgramExecutable *executable = mState.mExecutable;
ASSERT(mLinkResolved); ASSERT(mLinkResolved);
// if any two active samplers in a program are of different types, but refer to the same // if any two active samplers in a program are of different types, but refer to the same
// texture image unit, and this is the current program, then ValidateProgram will fail, and // texture image unit, and this is the current program, then ValidateProgram will fail, and
// DrawArrays and DrawElements will issue the INVALID_OPERATION error. // DrawArrays and DrawElements will issue the INVALID_OPERATION error.
for (size_t textureUnit : executable.mActiveSamplersMask) for (size_t textureUnit : executable->mActiveSamplersMask)
{ {
if (executable.mActiveSamplerTypes[textureUnit] == TextureType::InvalidEnum) if (executable->mActiveSamplerTypes[textureUnit] == TextureType::InvalidEnum)
{ {
if (infoLog) if (infoLog)
{ {
...@@ -3835,8 +3838,8 @@ bool Program::linkAttributes(const Context *context, InfoLog &infoLog) ...@@ -3835,8 +3838,8 @@ bool Program::linkAttributes(const Context *context, InfoLog &infoLog)
} }
} }
ASSERT(mState.mExecutable.mAttributesTypeMask.none()); ASSERT(mState.mExecutable->mAttributesTypeMask.none());
ASSERT(mState.mExecutable.mAttributesMask.none()); ASSERT(mState.mExecutable->mAttributesMask.none());
// Prune inactive attributes. This step is only needed on shaderVersion >= 300 since on earlier // Prune inactive attributes. This step is only needed on shaderVersion >= 300 since on earlier
// shader versions we're only processing active attributes to begin with. // shader versions we're only processing active attributes to begin with.
...@@ -3868,16 +3871,16 @@ bool Program::linkAttributes(const Context *context, InfoLog &infoLog) ...@@ -3868,16 +3871,16 @@ bool Program::linkAttributes(const Context *context, InfoLog &infoLog)
// Built-in active program inputs don't have a bound attribute. // Built-in active program inputs don't have a bound attribute.
if (!attribute.isBuiltIn()) if (!attribute.isBuiltIn())
{ {
mState.mExecutable.mActiveAttribLocationsMask.set(location); mState.mExecutable->mActiveAttribLocationsMask.set(location);
mState.mExecutable.mMaxActiveAttribLocation = mState.mExecutable->mMaxActiveAttribLocation =
std::max(mState.mExecutable.mMaxActiveAttribLocation, location + 1); std::max(mState.mExecutable->mMaxActiveAttribLocation, location + 1);
ComponentType componentType = ComponentType componentType =
GLenumToComponentType(VariableComponentType(attribute.type)); GLenumToComponentType(VariableComponentType(attribute.type));
SetComponentTypeMask(componentType, location, SetComponentTypeMask(componentType, location,
&mState.mExecutable.mAttributesTypeMask); &mState.mExecutable->mAttributesTypeMask);
mState.mExecutable.mAttributesMask.set(location); mState.mExecutable->mAttributesMask.set(location);
location++; location++;
} }
...@@ -4545,7 +4548,7 @@ bool Program::linkOutputVariables(const Caps &caps, ...@@ -4545,7 +4548,7 @@ bool Program::linkOutputVariables(const Caps &caps,
GLuint combinedImageUniformsCount, GLuint combinedImageUniformsCount,
GLuint combinedShaderStorageBlocksCount) GLuint combinedShaderStorageBlocksCount)
{ {
InfoLog &infoLog = mState.mExecutable.getInfoLog(); InfoLog &infoLog = mState.mExecutable->getInfoLog();
Shader *fragmentShader = mState.mAttachedShaders[ShaderType::Fragment]; Shader *fragmentShader = mState.mAttachedShaders[ShaderType::Fragment];
ASSERT(mState.mOutputVariableTypes.empty()); ASSERT(mState.mOutputVariableTypes.empty());
...@@ -4853,25 +4856,25 @@ void Program::updateSamplerUniform(Context *context, ...@@ -4853,25 +4856,25 @@ void Program::updateSamplerUniform(Context *context,
boundTextureUnits[arrayIndex + locationInfo.arrayIndex] = newTextureUnit; boundTextureUnits[arrayIndex + locationInfo.arrayIndex] = newTextureUnit;
// Update the reference counts. // Update the reference counts.
uint32_t &oldRefCount = mState.mExecutable.mActiveSamplerRefCounts[oldTextureUnit]; uint32_t &oldRefCount = mState.mExecutable->mActiveSamplerRefCounts[oldTextureUnit];
uint32_t &newRefCount = mState.mExecutable.mActiveSamplerRefCounts[newTextureUnit]; uint32_t &newRefCount = mState.mExecutable->mActiveSamplerRefCounts[newTextureUnit];
ASSERT(oldRefCount > 0); ASSERT(oldRefCount > 0);
ASSERT(newRefCount < std::numeric_limits<uint32_t>::max()); ASSERT(newRefCount < std::numeric_limits<uint32_t>::max());
oldRefCount--; oldRefCount--;
newRefCount++; newRefCount++;
// Check for binding type change. // Check for binding type change.
TextureType &newSamplerType = mState.mExecutable.mActiveSamplerTypes[newTextureUnit]; TextureType &newSamplerType = mState.mExecutable->mActiveSamplerTypes[newTextureUnit];
TextureType &oldSamplerType = mState.mExecutable.mActiveSamplerTypes[oldTextureUnit]; TextureType &oldSamplerType = mState.mExecutable->mActiveSamplerTypes[oldTextureUnit];
SamplerFormat &newSamplerFormat = mState.mExecutable.mActiveSamplerFormats[newTextureUnit]; SamplerFormat &newSamplerFormat = mState.mExecutable->mActiveSamplerFormats[newTextureUnit];
SamplerFormat &oldSamplerFormat = mState.mExecutable.mActiveSamplerFormats[oldTextureUnit]; SamplerFormat &oldSamplerFormat = mState.mExecutable->mActiveSamplerFormats[oldTextureUnit];
if (newRefCount == 1) if (newRefCount == 1)
{ {
newSamplerType = samplerBinding.textureType; newSamplerType = samplerBinding.textureType;
newSamplerFormat = samplerBinding.format; newSamplerFormat = samplerBinding.format;
mState.mExecutable.mActiveSamplersMask.set(newTextureUnit); mState.mExecutable->mActiveSamplersMask.set(newTextureUnit);
mState.mExecutable.mActiveSamplerShaderBits[newTextureUnit] = mState.mExecutable->mActiveSamplerShaderBits[newTextureUnit] =
mState.mUniforms[locationInfo.index].activeShaders(); mState.mUniforms[locationInfo.index].activeShaders();
} }
else else
...@@ -4892,7 +4895,7 @@ void Program::updateSamplerUniform(Context *context, ...@@ -4892,7 +4895,7 @@ void Program::updateSamplerUniform(Context *context,
{ {
oldSamplerType = TextureType::InvalidEnum; oldSamplerType = TextureType::InvalidEnum;
oldSamplerFormat = SamplerFormat::InvalidEnum; oldSamplerFormat = SamplerFormat::InvalidEnum;
mState.mExecutable.mActiveSamplersMask.reset(oldTextureUnit); mState.mExecutable->mActiveSamplersMask.reset(oldTextureUnit);
} }
else else
{ {
...@@ -4918,7 +4921,7 @@ void Program::updateSamplerUniform(Context *context, ...@@ -4918,7 +4921,7 @@ void Program::updateSamplerUniform(Context *context,
void ProgramState::setSamplerUniformTextureTypeAndFormat(size_t textureUnitIndex) void ProgramState::setSamplerUniformTextureTypeAndFormat(size_t textureUnitIndex)
{ {
mExecutable.setSamplerUniformTextureTypeAndFormat(textureUnitIndex, mSamplerBindings); mExecutable->setSamplerUniformTextureTypeAndFormat(textureUnitIndex, mSamplerBindings);
} }
template <typename T> template <typename T>
...@@ -5209,7 +5212,7 @@ angle::Result Program::serialize(const Context *context, angle::MemoryBuffer *bi ...@@ -5209,7 +5212,7 @@ angle::Result Program::serialize(const Context *context, angle::MemoryBuffer *bi
stream.writeInt(mState.getAtomicCounterUniformRange().low()); stream.writeInt(mState.getAtomicCounterUniformRange().low());
stream.writeInt(mState.getAtomicCounterUniformRange().high()); stream.writeInt(mState.getAtomicCounterUniformRange().high());
mState.mExecutable.save(&stream); mState.mExecutable->save(&stream);
mProgram->save(context, &stream); mProgram->save(context, &stream);
...@@ -5461,10 +5464,10 @@ angle::Result Program::deserialize(const Context *context, ...@@ -5461,10 +5464,10 @@ angle::Result Program::deserialize(const Context *context,
mState.updateTransformFeedbackStrides(); mState.updateTransformFeedbackStrides();
} }
mState.mExecutable.load(&stream); mState.mExecutable->load(&stream);
postResolveLink(context); postResolveLink(context);
mState.mExecutable.updateCanDrawWith(); mState.mExecutable->updateCanDrawWith();
return angle::Result::Continue; return angle::Result::Continue;
} }
......
...@@ -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