Commit e682bc57 by Cody Northrop Committed by Commit Bot

Capture/Replay: Add Sampler Object support to mid-execution capture

Test: Manhattan mid-execution capture working Bug: angleproject:3662 Bug: angleproject:4091 Change-Id: Iafa528e2a25efe1c49eb49ecc429eac8f25c162c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2080591Reviewed-by: 's avatarCourtney Goeltzenleuchter <courtneygo@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Cody Northrop <cnorthrop@google.com>
parent 6125419c
......@@ -1946,6 +1946,80 @@ void CaptureMidExecutionSetup(const gl::Context *context,
gl::TransformFeedback *currentXFB = apiState.getCurrentTransformFeedback();
cap(CaptureBindTransformFeedback(replayState, true, GL_TRANSFORM_FEEDBACK, currentXFB->id()));
// Capture Sampler Objects
const gl::SamplerManager &samplers = apiState.getSamplerManagerForCapture();
for (const auto &samplerIter : samplers)
{
gl::SamplerID samplerID = {samplerIter.first};
cap(CaptureGenSamplers(replayState, true, 1, &samplerID));
MaybeCaptureUpdateResourceIDs(setupCalls);
gl::Sampler *sampler = samplerIter.second;
if (!sampler)
{
continue;
}
gl::SamplerState defaultSamplerState;
if (sampler->getMinFilter() != defaultSamplerState.getMinFilter())
{
cap(CaptureSamplerParameteri(replayState, true, samplerID, GL_TEXTURE_MIN_FILTER,
sampler->getMinFilter()));
}
if (sampler->getMagFilter() != defaultSamplerState.getMagFilter())
{
cap(CaptureSamplerParameteri(replayState, true, samplerID, GL_TEXTURE_MAG_FILTER,
sampler->getMagFilter()));
}
if (sampler->getWrapS() != defaultSamplerState.getWrapS())
{
cap(CaptureSamplerParameteri(replayState, true, samplerID, GL_TEXTURE_WRAP_S,
sampler->getWrapS()));
}
if (sampler->getWrapR() != defaultSamplerState.getWrapR())
{
cap(CaptureSamplerParameteri(replayState, true, samplerID, GL_TEXTURE_WRAP_R,
sampler->getWrapR()));
}
if (sampler->getWrapT() != defaultSamplerState.getWrapT())
{
cap(CaptureSamplerParameteri(replayState, true, samplerID, GL_TEXTURE_WRAP_T,
sampler->getWrapT()));
}
if (sampler->getMinLod() != defaultSamplerState.getMinLod())
{
cap(CaptureSamplerParameterf(replayState, true, samplerID, GL_TEXTURE_MIN_LOD,
sampler->getMinLod()));
}
if (sampler->getMaxLod() != defaultSamplerState.getMaxLod())
{
cap(CaptureSamplerParameterf(replayState, true, samplerID, GL_TEXTURE_MAX_LOD,
sampler->getMaxLod()));
}
if (sampler->getCompareMode() != defaultSamplerState.getCompareMode())
{
cap(CaptureSamplerParameteri(replayState, true, samplerID, GL_TEXTURE_COMPARE_MODE,
sampler->getCompareMode()));
}
if (sampler->getCompareFunc() != defaultSamplerState.getCompareFunc())
{
cap(CaptureSamplerParameteri(replayState, true, samplerID, GL_TEXTURE_COMPARE_FUNC,
sampler->getCompareFunc()));
}
}
// Bind samplers
gl::SamplerBindingVector samplerBindings = apiState.getSamplers();
for (GLuint bindingIndex = 0; bindingIndex < static_cast<GLuint>(samplerBindings.size());
++bindingIndex)
{
gl::SamplerID samplerID = samplerBindings[bindingIndex].id();
if (samplerID.value != 0)
{
cap(CaptureBindSampler(replayState, true, bindingIndex, samplerID));
}
}
// Capture GL Context states.
// TODO(http://anglebug.com/3662): Complete state capture.
auto capCap = [cap, &replayState](GLenum capEnum, bool capValue) {
......
......@@ -59,6 +59,7 @@ using ContextID = uintptr_t;
template <typename T>
using BufferBindingMap = angle::PackedEnumMap<BufferBinding, T>;
using BoundBufferMap = BufferBindingMap<BindingPointer<Buffer>>;
using SamplerBindingVector = std::vector<BindingPointer<Sampler>>;
using TextureBindingVector = std::vector<BindingPointer<Texture>>;
using TextureBindingMap = angle::PackedEnumMap<TextureType, TextureBindingVector>;
using ActiveQueryMap = angle::PackedEnumMap<QueryType, BindingPointer<Query>>;
......@@ -281,7 +282,6 @@ class State : angle::NonCopyable
Sampler *getSampler(GLuint textureUnit) const { return mSamplers[textureUnit].get(); }
using SamplerBindingVector = std::vector<BindingPointer<Sampler>>;
const SamplerBindingVector &getSamplers() const { return mSamplers; }
void detachSampler(const Context *context, SamplerID sampler);
......@@ -734,6 +734,8 @@ class State : angle::NonCopyable
{
return *mShaderProgramManager;
}
const SamplerManager &getSamplerManagerForCapture() const { return *mSamplerManager; }
const SamplerBindingVector &getSamplerBindingsForCapture() const { return mSamplers; }
const ActiveQueryMap &getActiveQueriesForCapture() const { return mActiveQueries; }
......
......@@ -2123,7 +2123,7 @@ void StateManagerGL::updateMultiviewBaseViewLayerIndexUniformImpl(
void StateManagerGL::syncSamplersState(const gl::Context *context)
{
const gl::State::SamplerBindingVector &samplers = context->getState().getSamplers();
const gl::SamplerBindingVector &samplers = context->getState().getSamplers();
// This could be optimized by using a separate binding dirty bit per sampler.
for (size_t samplerIndex = 0; samplerIndex < samplers.size(); ++samplerIndex)
......
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