Commit aca14d47 by Manh Nguyen Committed by Commit Bot

Add renderbuffer serialization capability

Serializes renderbuffers' states stored on CPU. Gets renderbuffers content from GPU then serialize them. Adds renderbuffers serialization to serializeContext method so that capture replay regresssion testing now compares the states of renderbuffers too. Bug: angleproject:4817 Change-Id: I537b11ee85decb14eea461ebbd62ce6ab0402f85 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2327173 Commit-Queue: Manh Nguyen <nguyenmh@google.com> Reviewed-by: 's avatarCody Northrop <cnorthrop@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent bd7cef28
...@@ -54,6 +54,11 @@ GLsizei RenderbufferState::getSamples() const ...@@ -54,6 +54,11 @@ GLsizei RenderbufferState::getSamples() const
return mSamples; return mSamples;
} }
InitState RenderbufferState::getInitState() const
{
return mInitState;
}
void RenderbufferState::update(GLsizei width, void RenderbufferState::update(GLsizei width,
GLsizei height, GLsizei height,
const Format &format, const Format &format,
...@@ -207,6 +212,11 @@ GLuint Renderbuffer::getStencilSize() const ...@@ -207,6 +212,11 @@ GLuint Renderbuffer::getStencilSize() const
return mState.mFormat.info->stencilBits; return mState.mFormat.info->stencilBits;
} }
const RenderbufferState &Renderbuffer::getState() const
{
return mState;
}
GLint Renderbuffer::getMemorySize() const GLint Renderbuffer::getMemorySize() const
{ {
GLint implSize = mImplementation->getMemorySize(); GLint implSize = mImplementation->getMemorySize();
......
...@@ -42,6 +42,7 @@ class RenderbufferState final : angle::NonCopyable ...@@ -42,6 +42,7 @@ class RenderbufferState final : angle::NonCopyable
GLsizei getHeight() const; GLsizei getHeight() const;
const Format &getFormat() const; const Format &getFormat() const;
GLsizei getSamples() const; GLsizei getSamples() const;
InitState getInitState() const;
private: private:
friend class Renderbuffer; friend class Renderbuffer;
...@@ -97,6 +98,7 @@ class Renderbuffer final : public RefCountObject<RenderbufferID>, ...@@ -97,6 +98,7 @@ class Renderbuffer final : public RefCountObject<RenderbufferID>,
GLuint getAlphaSize() const; GLuint getAlphaSize() const;
GLuint getDepthSize() const; GLuint getDepthSize() const;
GLuint getStencilSize() const; GLuint getStencilSize() const;
const RenderbufferState &getState() const;
GLint getMemorySize() const; GLint getMemorySize() const;
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "libANGLE/VertexAttribute.h" #include "libANGLE/VertexAttribute.h"
#include "libANGLE/angletypes.h" #include "libANGLE/angletypes.h"
#include "libANGLE/renderer/FramebufferImpl.h" #include "libANGLE/renderer/FramebufferImpl.h"
#include "libANGLE/renderer/RenderbufferImpl.h"
namespace angle namespace angle
{ {
...@@ -514,6 +515,46 @@ void SerializeSampler(gl::BinaryOutputStream *bos, gl::Sampler *sampler) ...@@ -514,6 +515,46 @@ void SerializeSampler(gl::BinaryOutputStream *bos, gl::Sampler *sampler)
SerializeSamplerState(bos, sampler->getSamplerState()); SerializeSamplerState(bos, sampler->getSamplerState());
} }
void SerializeInternalFormat(gl::BinaryOutputStream *bos, const gl::InternalFormat *internalFormat)
{
bos->writeInt(internalFormat->internalFormat);
}
void SerializeFormat(gl::BinaryOutputStream *bos, const gl::Format &format)
{
SerializeInternalFormat(bos, format.info);
}
void SerializeRenderbufferState(gl::BinaryOutputStream *bos,
const gl::RenderbufferState &renderbufferState)
{
bos->writeInt(renderbufferState.getWidth());
bos->writeInt(renderbufferState.getHeight());
SerializeFormat(bos, renderbufferState.getFormat());
bos->writeInt(renderbufferState.getSamples());
bos->writeEnum(renderbufferState.getInitState());
}
Result SerializeRenderbuffer(const gl::Context *context,
gl::BinaryOutputStream *bos,
ScratchBuffer *scratchBuffer,
gl::Renderbuffer *renderbuffer)
{
SerializeRenderbufferState(bos, renderbuffer->getState());
bos->writeString(renderbuffer->getLabel());
MemoryBuffer *pixelsPtr = nullptr;
ANGLE_CHECK_GL_ALLOC(
const_cast<gl::Context *>(context),
scratchBuffer->getInitialized(renderbuffer->getMemorySize(), &pixelsPtr, 0));
gl::PixelPackState packState;
packState.alignment = 1;
ANGLE_TRY(renderbuffer->getImplementation()->getRenderbufferImage(
context, packState, nullptr, renderbuffer->getImplementationColorReadFormat(context),
renderbuffer->getImplementationColorReadType(context), pixelsPtr->data()));
bos->writeBytes(pixelsPtr->data(), pixelsPtr->size());
return Result::Continue;
}
} // namespace } // namespace
Result SerializeContext(gl::BinaryOutputStream *bos, const gl::Context *context) Result SerializeContext(gl::BinaryOutputStream *bos, const gl::Context *context)
...@@ -539,6 +580,13 @@ Result SerializeContext(gl::BinaryOutputStream *bos, const gl::Context *context) ...@@ -539,6 +580,13 @@ Result SerializeContext(gl::BinaryOutputStream *bos, const gl::Context *context)
gl::Sampler *samplerPtr = sampler.second; gl::Sampler *samplerPtr = sampler.second;
SerializeSampler(bos, samplerPtr); SerializeSampler(bos, samplerPtr);
} }
const gl::RenderbufferManager &renderbufferManager =
context->getState().getRenderbufferManagerForCapture();
for (const auto &renderbuffer : renderbufferManager)
{
gl::Renderbuffer *renderbufferPtr = renderbuffer.second;
ANGLE_TRY(SerializeRenderbuffer(context, bos, &scratchBuffer, renderbufferPtr));
}
scratchBuffer.clear(); scratchBuffer.clear();
return Result::Continue; 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