Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit e682bc5

Browse files
cnorthropCommit Bot
authored andcommitted
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/+/2080591 Reviewed-by: Courtney Goeltzenleuchter <courtneygo@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Cody Northrop <cnorthrop@google.com>
1 parent 6125419 commit e682bc5

File tree

3 files changed

+78
-2
lines changed

3 files changed

+78
-2
lines changed

src/libANGLE/FrameCapture.cpp

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1946,6 +1946,80 @@ void CaptureMidExecutionSetup(const gl::Context *context,
19461946
gl::TransformFeedback *currentXFB = apiState.getCurrentTransformFeedback();
19471947
cap(CaptureBindTransformFeedback(replayState, true, GL_TRANSFORM_FEEDBACK, currentXFB->id()));
19481948

1949+
// Capture Sampler Objects
1950+
const gl::SamplerManager &samplers = apiState.getSamplerManagerForCapture();
1951+
for (const auto &samplerIter : samplers)
1952+
{
1953+
gl::SamplerID samplerID = {samplerIter.first};
1954+
cap(CaptureGenSamplers(replayState, true, 1, &samplerID));
1955+
MaybeCaptureUpdateResourceIDs(setupCalls);
1956+
1957+
gl::Sampler *sampler = samplerIter.second;
1958+
if (!sampler)
1959+
{
1960+
continue;
1961+
}
1962+
1963+
gl::SamplerState defaultSamplerState;
1964+
if (sampler->getMinFilter() != defaultSamplerState.getMinFilter())
1965+
{
1966+
cap(CaptureSamplerParameteri(replayState, true, samplerID, GL_TEXTURE_MIN_FILTER,
1967+
sampler->getMinFilter()));
1968+
}
1969+
if (sampler->getMagFilter() != defaultSamplerState.getMagFilter())
1970+
{
1971+
cap(CaptureSamplerParameteri(replayState, true, samplerID, GL_TEXTURE_MAG_FILTER,
1972+
sampler->getMagFilter()));
1973+
}
1974+
if (sampler->getWrapS() != defaultSamplerState.getWrapS())
1975+
{
1976+
cap(CaptureSamplerParameteri(replayState, true, samplerID, GL_TEXTURE_WRAP_S,
1977+
sampler->getWrapS()));
1978+
}
1979+
if (sampler->getWrapR() != defaultSamplerState.getWrapR())
1980+
{
1981+
cap(CaptureSamplerParameteri(replayState, true, samplerID, GL_TEXTURE_WRAP_R,
1982+
sampler->getWrapR()));
1983+
}
1984+
if (sampler->getWrapT() != defaultSamplerState.getWrapT())
1985+
{
1986+
cap(CaptureSamplerParameteri(replayState, true, samplerID, GL_TEXTURE_WRAP_T,
1987+
sampler->getWrapT()));
1988+
}
1989+
if (sampler->getMinLod() != defaultSamplerState.getMinLod())
1990+
{
1991+
cap(CaptureSamplerParameterf(replayState, true, samplerID, GL_TEXTURE_MIN_LOD,
1992+
sampler->getMinLod()));
1993+
}
1994+
if (sampler->getMaxLod() != defaultSamplerState.getMaxLod())
1995+
{
1996+
cap(CaptureSamplerParameterf(replayState, true, samplerID, GL_TEXTURE_MAX_LOD,
1997+
sampler->getMaxLod()));
1998+
}
1999+
if (sampler->getCompareMode() != defaultSamplerState.getCompareMode())
2000+
{
2001+
cap(CaptureSamplerParameteri(replayState, true, samplerID, GL_TEXTURE_COMPARE_MODE,
2002+
sampler->getCompareMode()));
2003+
}
2004+
if (sampler->getCompareFunc() != defaultSamplerState.getCompareFunc())
2005+
{
2006+
cap(CaptureSamplerParameteri(replayState, true, samplerID, GL_TEXTURE_COMPARE_FUNC,
2007+
sampler->getCompareFunc()));
2008+
}
2009+
}
2010+
2011+
// Bind samplers
2012+
gl::SamplerBindingVector samplerBindings = apiState.getSamplers();
2013+
for (GLuint bindingIndex = 0; bindingIndex < static_cast<GLuint>(samplerBindings.size());
2014+
++bindingIndex)
2015+
{
2016+
gl::SamplerID samplerID = samplerBindings[bindingIndex].id();
2017+
if (samplerID.value != 0)
2018+
{
2019+
cap(CaptureBindSampler(replayState, true, bindingIndex, samplerID));
2020+
}
2021+
}
2022+
19492023
// Capture GL Context states.
19502024
// TODO(http://anglebug.com/3662): Complete state capture.
19512025
auto capCap = [cap, &replayState](GLenum capEnum, bool capValue) {

src/libANGLE/State.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ using ContextID = uintptr_t;
5959
template <typename T>
6060
using BufferBindingMap = angle::PackedEnumMap<BufferBinding, T>;
6161
using BoundBufferMap = BufferBindingMap<BindingPointer<Buffer>>;
62+
using SamplerBindingVector = std::vector<BindingPointer<Sampler>>;
6263
using TextureBindingVector = std::vector<BindingPointer<Texture>>;
6364
using TextureBindingMap = angle::PackedEnumMap<TextureType, TextureBindingVector>;
6465
using ActiveQueryMap = angle::PackedEnumMap<QueryType, BindingPointer<Query>>;
@@ -281,7 +282,6 @@ class State : angle::NonCopyable
281282

282283
Sampler *getSampler(GLuint textureUnit) const { return mSamplers[textureUnit].get(); }
283284

284-
using SamplerBindingVector = std::vector<BindingPointer<Sampler>>;
285285
const SamplerBindingVector &getSamplers() const { return mSamplers; }
286286

287287
void detachSampler(const Context *context, SamplerID sampler);
@@ -734,6 +734,8 @@ class State : angle::NonCopyable
734734
{
735735
return *mShaderProgramManager;
736736
}
737+
const SamplerManager &getSamplerManagerForCapture() const { return *mSamplerManager; }
738+
const SamplerBindingVector &getSamplerBindingsForCapture() const { return mSamplers; }
737739

738740
const ActiveQueryMap &getActiveQueriesForCapture() const { return mActiveQueries; }
739741

src/libANGLE/renderer/gl/StateManagerGL.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2123,7 +2123,7 @@ void StateManagerGL::updateMultiviewBaseViewLayerIndexUniformImpl(
21232123

21242124
void StateManagerGL::syncSamplersState(const gl::Context *context)
21252125
{
2126-
const gl::State::SamplerBindingVector &samplers = context->getState().getSamplers();
2126+
const gl::SamplerBindingVector &samplers = context->getState().getSamplers();
21272127

21282128
// This could be optimized by using a separate binding dirty bit per sampler.
21292129
for (size_t samplerIndex = 0; samplerIndex < samplers.size(); ++samplerIndex)

0 commit comments

Comments
 (0)