Cache isSeparable in the executable

For convenience, particularly for the next CL.

Bug: angleproject:8297
Change-Id: I55690aecf3936a51a2a2163d7c354a710b81d7f8
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4864069
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Yuxin Hu <yuxinhu@google.com>
Reviewed-by: Charlie Lao <cclao@google.com>
Auto-Submit: Shahbaz Youssefi <syoussefi@chromium.org>
This commit is contained in:
Shahbaz Youssefi
2023-09-15 16:03:25 -04:00
committed by Angle LUCI CQ
parent c8e16b071e
commit 936694e3e8
4 changed files with 28 additions and 23 deletions

View File

@@ -1106,9 +1106,13 @@ angle::Result Program::linkImpl(const Context *context)
// The transform feedback varying names are duplicated because the program pipeline link is not
// currently able to use the link result of the program directly (and redoes the link, using
// these names).
//
// The isSeparable state is duplicated for convenience; it is used when setting sampler/image
// uniforms.
mState.mExecutable->mPODStruct.transformFeedbackBufferMode =
mState.mTransformFeedbackBufferMode;
mState.mExecutable->mTransformFeedbackVaryingNames = mState.mTransformFeedbackVaryingNames;
mState.mExecutable->mPODStruct.isSeparable = mState.mSeparable;
mState.mInfoLog.reset();
@@ -1303,7 +1307,7 @@ angle::Result Program::linkJobImpl(const Caps &caps,
*mergedVaryingsOut = GetMergedVaryingsFromLinkingVariables(*linkingVariables);
if (!mState.mExecutable->linkMergedVaryings(caps, limitations, clientVersion, isWebGL,
*mergedVaryingsOut, *linkingVariables,
isSeparable(), &resources->varyingPacking))
&resources->varyingPacking))
{
return angle::Result::Stop;
}
@@ -2835,7 +2839,7 @@ angle::Result Program::serialize(const Context *context, angle::MemoryBuffer *bi
stream.writeString(name);
}
mState.mExecutable->save(mState.mSeparable, &stream);
mState.mExecutable->save(&stream);
// Warn the app layer if saving a binary with unsupported transform feedback.
if (!mState.mExecutable->getLinkedTransformFeedbackVaryings().empty() &&
@@ -2928,7 +2932,6 @@ angle::Result Program::deserialize(const Context *context, BinaryInputStream &st
return angle::Result::Stop;
}
// mSeparable must be before mExecutable->load(), since it uses the value.
mState.mSeparable = stream.readBool();
mState.mTransformFeedbackBufferMode = stream.readInt<GLenum>();
@@ -2938,7 +2941,10 @@ angle::Result Program::deserialize(const Context *context, BinaryInputStream &st
name = stream.readString();
}
mState.mExecutable->load(mState.mSeparable, &stream);
// mSeparable must be before mExecutable->load(), since it uses the value. This state is
// duplicated in the executable for convenience.
mState.mExecutable->mPODStruct.isSeparable = mState.mSeparable;
mState.mExecutable->load(&stream);
static_assert(static_cast<unsigned long>(ShaderType::EnumCount) <= sizeof(unsigned long) * 8,
"Too many shader types");

View File

@@ -703,7 +703,7 @@ void ProgramExecutable::reset()
mImageBindings.clear();
}
void ProgramExecutable::load(bool isSeparable, gl::BinaryInputStream *stream)
void ProgramExecutable::load(gl::BinaryInputStream *stream)
{
static_assert(MAX_VERTEX_ATTRIBS * 2 <= sizeof(uint32_t) * 8,
"Too many vertex attribs for mask: All bits of mAttributesTypeMask types and "
@@ -802,7 +802,7 @@ void ProgramExecutable::load(bool isSeparable, gl::BinaryInputStream *stream)
// These values are currently only used by PPOs, so only load them when the program is marked
// separable to save memory.
if (isSeparable)
if (mPODStruct.isSeparable)
{
for (ShaderType shaderType : getLinkedShaderStages())
{
@@ -830,7 +830,7 @@ void ProgramExecutable::load(bool isSeparable, gl::BinaryInputStream *stream)
}
}
void ProgramExecutable::save(bool isSeparable, gl::BinaryOutputStream *stream) const
void ProgramExecutable::save(gl::BinaryOutputStream *stream) const
{
static_assert(MAX_VERTEX_ATTRIBS * 2 <= sizeof(uint32_t) * 8,
"All bits of mAttributesTypeMask types and mask fit into 32 bits each");
@@ -903,7 +903,7 @@ void ProgramExecutable::save(bool isSeparable, gl::BinaryOutputStream *stream) c
// These values are currently only used by PPOs, so only save them when the program is marked
// separable to save memory.
if (isSeparable)
if (mPODStruct.isSeparable)
{
for (ShaderType shaderType : getLinkedShaderStages())
{
@@ -1118,7 +1118,6 @@ bool ProgramExecutable::linkMergedVaryings(const Caps &caps,
bool webglCompatibility,
const ProgramMergedVaryings &mergedVaryings,
const LinkingVariables &linkingVariables,
bool isSeparable,
ProgramVaryingPacking *varyingPacking)
{
ShaderType tfStage = GetLastPreFragmentStage(linkingVariables.isShaderStageUsedBitset);
@@ -1158,7 +1157,7 @@ bool ProgramExecutable::linkMergedVaryings(const Caps &caps,
if (!varyingPacking->collectAndPackUserVaryings(*mInfoLog, caps, packMode, activeShadersMask,
mergedVaryings, mTransformFeedbackVaryingNames,
isSeparable))
mPODStruct.isSeparable))
{
return false;
}
@@ -1269,7 +1268,6 @@ bool ProgramExecutable::linkValidateTransformFeedback(const Caps &caps,
elementCount = 1;
}
// TODO(jmadill): Investigate implementation limits on D3D11
componentCount = VariableComponentCount(var->type) * elementCount;
if (mPODStruct.transformFeedbackBufferMode == GL_SEPARATE_ATTRIBS &&
componentCount > static_cast<GLuint>(caps.maxTransformFeedbackSeparateComponents))

View File

@@ -248,8 +248,8 @@ class ProgramExecutable final : public angle::Subject
ANGLE_INLINE rx::ProgramExecutableImpl *getImplementation() const { return mImplementation; }
void save(bool isSeparable, gl::BinaryOutputStream *stream) const;
void load(bool isSeparable, gl::BinaryInputStream *stream);
void save(gl::BinaryOutputStream *stream) const;
void load(gl::BinaryInputStream *stream);
InfoLog &getInfoLog() const { return *mInfoLog; }
std::string getInfoLogString() const;
@@ -666,7 +666,6 @@ class ProgramExecutable final : public angle::Subject
bool webglCompatibility,
const ProgramMergedVaryings &mergedVaryings,
const LinkingVariables &linkingVariables,
bool isSeparable,
ProgramVaryingPacking *varyingPacking);
bool linkValidateTransformFeedback(const Caps &caps,
@@ -727,11 +726,16 @@ class ProgramExecutable final : public angle::Subject
ShaderBitSet linkedShaderStages;
DrawBufferMask activeOutputVariablesMask;
DrawBufferMask activeSecondaryOutputVariablesMask;
bool hasClipDistance;
bool hasDiscard;
bool hasYUVOutput;
bool enablesPerSampleShading;
bool canDrawWith;
uint8_t hasClipDistance : 1;
uint8_t hasDiscard : 1;
uint8_t hasYUVOutput : 1;
uint8_t enablesPerSampleShading : 1;
uint8_t canDrawWith : 1;
uint8_t isSeparable : 1;
uint8_t pad : 2;
// 12 bytes
sh::WorkGroupSize computeShaderLocalSize;
// 8 bytes each
RangeUI defaultUniformRange;
@@ -771,9 +775,6 @@ class ProgramExecutable final : public angle::Subject
UniformBlockBindingMask activeUniformBlockBindings;
// 24 bytes
ShaderMap<int> linkedShaderVersions;
// 12 bytes
sh::WorkGroupSize computeShaderLocalSize;
uint8_t pads[4];
} mPODStruct;
ANGLE_DISABLE_STRUCT_PADDING_WARNINGS

View File

@@ -592,7 +592,7 @@ angle::Result ProgramPipeline::link(const Context *context)
(*tfExecutable)->mTransformFeedbackVaryingNames;
if (!mState.mExecutable->linkMergedVaryings(caps, limitations, clientVersion, isWebGL,
mergedVaryings, linkingVariables, false,
mergedVaryings, linkingVariables,
&varyingPacking))
{
return angle::Result::Stop;