Commit 846cd169 by Manh Nguyen Committed by Commit Bot

Add vertex array serialization capability

Serializes vertex arrays' states stored on CPU. Adds vertex array serialization to serializeContext method so that capture replay regresssion testing now compares the states of vertex array objects too. Bug: angleproject:4817 Change-Id: Ia2897c056adff9bd433765186240ab07f78db232 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2331737 Commit-Queue: Manh Nguyen <nguyenmh@google.com> Reviewed-by: 's avatarCody Northrop <cnorthrop@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 4c7e3ee3
......@@ -71,6 +71,15 @@ class VertexArrayState final : angle::NonCopyable
// Get all the attributes in an AttributesMask that are using the given binding.
AttributesMask getBindingToAttributesMask(GLuint bindingIndex) const;
ComponentTypeMask getVertexAttributesTypeMask() const { return mVertexAttributesTypeMask; }
AttributesMask getClientMemoryAttribsMask() const { return mClientMemoryAttribsMask; }
gl::AttributesMask getNullPointerClientMemoryAttribsMask() const
{
return mNullPointerClientMemoryAttribsMask;
}
private:
friend class VertexArray;
std::string mLabel;
......@@ -247,6 +256,10 @@ class VertexArray final : public angle::ObserverInterface,
return mState.mCachedEnabledMappedArrayBuffers.any();
}
const VertexArrayState &getState() const { return mState; }
bool isBufferAccessValidationEnabled() const { return mBufferAccessValidationEnabled; }
// Observer implementation
void onSubjectStateChange(angle::SubjectIndex index, angle::SubjectMessage message) override;
......
......@@ -801,6 +801,7 @@ void SerializeProgram(gl::BinaryOutputStream *bos, gl::Program *program)
bos->writeInt(program->getRefCount());
bos->writeInt(program->id().value);
}
void SerializeImageDesc(gl::BinaryOutputStream *bos, const gl::ImageDesc &imageDesc)
{
SerializeExtents(bos, imageDesc.size);
......@@ -908,6 +909,65 @@ Result SerializeTexture(const gl::Context *context,
return Result::Continue;
}
void SerializeFormat(gl::BinaryOutputStream *bos, const angle::Format *format)
{
bos->writeInt(format->glInternalFormat);
}
void SerializeVertexAttributeVector(gl::BinaryOutputStream *bos,
const std::vector<gl::VertexAttribute> &vertexAttributes)
{
for (const gl::VertexAttribute &vertexAttribute : vertexAttributes)
{
bos->writeInt(vertexAttribute.enabled);
ASSERT(vertexAttribute.format);
SerializeFormat(bos, vertexAttribute.format);
bos->writeInt(vertexAttribute.relativeOffset);
bos->writeInt(vertexAttribute.vertexAttribArrayStride);
bos->writeInt(vertexAttribute.bindingIndex);
}
}
void SerializeVertexBindingsVector(gl::BinaryOutputStream *bos,
const std::vector<gl::VertexBinding> &vertexBindings)
{
for (const gl::VertexBinding &vertexBinding : vertexBindings)
{
bos->writeInt(vertexBinding.getStride());
bos->writeInt(vertexBinding.getDivisor());
bos->writeInt(vertexBinding.getOffset());
bos->writeInt(vertexBinding.getBuffer().id().value);
bos->writeInt(vertexBinding.getBoundAttributesMask().to_ulong());
}
}
void SerializeVertexArrayState(gl::BinaryOutputStream *bos,
const gl::VertexArrayState &vertexArrayState)
{
bos->writeString(vertexArrayState.getLabel());
SerializeVertexAttributeVector(bos, vertexArrayState.getVertexAttributes());
if (vertexArrayState.getElementArrayBuffer())
{
bos->writeInt(vertexArrayState.getElementArrayBuffer()->id().value);
}
else
{
bos->writeInt(0);
}
SerializeVertexBindingsVector(bos, vertexArrayState.getVertexBindings());
bos->writeInt(vertexArrayState.getEnabledAttributesMask().to_ulong());
bos->writeInt(vertexArrayState.getVertexAttributesTypeMask().to_ulong());
bos->writeInt(vertexArrayState.getClientMemoryAttribsMask().to_ulong());
bos->writeInt(vertexArrayState.getNullPointerClientMemoryAttribsMask().to_ulong());
}
void SerializeVertexArray(gl::BinaryOutputStream *bos, gl::VertexArray *vertexArray)
{
bos->writeInt(vertexArray->id().value);
SerializeVertexArrayState(bos, vertexArray->getState());
bos->writeInt(vertexArray->isBufferAccessValidationEnabled());
}
} // namespace
Result SerializeContext(gl::BinaryOutputStream *bos, const gl::Context *context)
......@@ -962,6 +1022,12 @@ Result SerializeContext(gl::BinaryOutputStream *bos, const gl::Context *context)
gl::Texture *texturePtr = texture.second;
ANGLE_TRY(SerializeTexture(context, bos, &scratchBuffer, texturePtr));
}
const gl::VertexArrayMap &vertexArrayMap = context->getVertexArraysForCapture();
for (auto &vertexArray : vertexArrayMap)
{
gl::VertexArray *vertexArrayPtr = vertexArray.second;
SerializeVertexArray(bos, vertexArrayPtr);
}
scratchBuffer.clear();
return Result::Continue;
......
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