Commit 50a27257 by Manh Nguyen Committed by Commit Bot

Adds sampler serialization capability

Adds the ability to serialize sampler objects. Adds serialization of sampler objects to serializeContext method so that capture replay regression testing now compares the states of samplers too. Bug: angleproject:4817 Change-Id: Ic32d442eac9aa3afc5c9eea577522fe7054a755a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2315048 Commit-Queue: Manh Nguyen <nguyenmh@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCody Northrop <cnorthrop@google.com>
parent 68791f89
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "libANGLE/Framebuffer.h" #include "libANGLE/Framebuffer.h"
#include "libANGLE/Query.h" #include "libANGLE/Query.h"
#include "libANGLE/RefCountObject.h" #include "libANGLE/RefCountObject.h"
#include "libANGLE/Sampler.h"
#include "libANGLE/State.h" #include "libANGLE/State.h"
#include "libANGLE/TransformFeedback.h" #include "libANGLE/TransformFeedback.h"
#include "libANGLE/VertexAttribute.h" #include "libANGLE/VertexAttribute.h"
...@@ -472,6 +473,47 @@ Result SerializeBuffer(const gl::Context *context, ...@@ -472,6 +473,47 @@ Result SerializeBuffer(const gl::Context *context,
bos->writeBytes(dataPtr->data(), dataPtr->size()); bos->writeBytes(dataPtr->data(), dataPtr->size());
return Result::Continue; return Result::Continue;
} }
void SerializeColorGeneric(gl::BinaryOutputStream *bos, const ColorGeneric &colorGeneric)
{
ASSERT(colorGeneric.type == ColorGeneric::Type::Float ||
colorGeneric.type == ColorGeneric::Type::Int ||
colorGeneric.type == ColorGeneric::Type::UInt);
bos->writeEnum(colorGeneric.type);
if (colorGeneric.type == ColorGeneric::Type::Float)
{
SerializeColor(bos, colorGeneric.colorF);
}
else if (colorGeneric.type == ColorGeneric::Type::Int)
{
SerializeColor(bos, colorGeneric.colorI);
}
else
{
SerializeColor(bos, colorGeneric.colorUI);
}
}
void SerializeSamplerState(gl::BinaryOutputStream *bos, const gl::SamplerState &samplerState)
{
bos->writeInt(samplerState.getMinFilter());
bos->writeInt(samplerState.getMagFilter());
bos->writeInt(samplerState.getWrapS());
bos->writeInt(samplerState.getWrapT());
bos->writeInt(samplerState.getWrapR());
bos->writeInt(samplerState.getMaxAnisotropy());
bos->writeInt(samplerState.getMinLod());
bos->writeInt(samplerState.getMaxLod());
bos->writeInt(samplerState.getCompareMode());
bos->writeInt(samplerState.getCompareFunc());
bos->writeInt(samplerState.getSRGBDecode());
SerializeColorGeneric(bos, samplerState.getBorderColor());
}
void SerializeSampler(gl::BinaryOutputStream *bos, gl::Sampler *sampler)
{
bos->writeString(sampler->getLabel());
SerializeSamplerState(bos, sampler->getSamplerState());
}
} // namespace } // namespace
...@@ -492,6 +534,12 @@ Result SerializeContext(gl::BinaryOutputStream *bos, const gl::Context *context) ...@@ -492,6 +534,12 @@ Result SerializeContext(gl::BinaryOutputStream *bos, const gl::Context *context)
gl::Buffer *bufferPtr = buffer.second; gl::Buffer *bufferPtr = buffer.second;
ANGLE_TRY(SerializeBuffer(context, bos, &scratchBuffer, bufferPtr)); ANGLE_TRY(SerializeBuffer(context, bos, &scratchBuffer, bufferPtr));
} }
const gl::SamplerManager &samplerManager = context->getState().getSamplerManagerForCapture();
for (const auto &sampler : samplerManager)
{
gl::Sampler *samplerPtr = sampler.second;
SerializeSampler(bos, samplerPtr);
}
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