Commit c431d596 by Jamie Madill Committed by Commit Bot

Add Serial to all GL resources.

The Serial will help track active resources for filtering out inactive setup calls in capture/replay. Bug: angleproject:4223 Change-Id: I64ba50f27d656c12d45155dc735e9b6f9c04528f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1969062 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCody Northrop <cnorthrop@google.com> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 99c274ba
......@@ -39,7 +39,7 @@ BufferState::BufferState()
BufferState::~BufferState() {}
Buffer::Buffer(rx::GLImplFactory *factory, BufferID id)
: RefCountObject(id),
: RefCountObject(factory->generateSerial(), id),
mImpl(factory->createBuffer(mState)),
mImplObserver(this, kImplementationSubjectIndex)
{
......
......@@ -59,7 +59,7 @@ angle::Result FenceNV::finish(const Context *context)
}
Sync::Sync(rx::GLImplFactory *factory, GLuint id)
: RefCountObject(id),
: RefCountObject(factory->generateSerial(), id),
mFence(factory->createSync()),
mLabel(),
mCondition(GL_SYNC_GPU_COMMANDS_COMPLETE),
......
......@@ -674,7 +674,8 @@ bool FramebufferState::isDefault() const
const FramebufferID Framebuffer::kDefaultDrawFramebufferHandle = {0};
Framebuffer::Framebuffer(const Caps &caps, rx::GLImplFactory *factory, FramebufferID id)
: mState(caps, id),
: mSerial(factory->generateSerial()),
mState(caps, id),
mImpl(factory->createFramebuffer(mState)),
mCachedStatus(),
mDirtyDepthAttachmentBinding(this, DIRTY_BIT_DEPTH_ATTACHMENT),
......@@ -692,7 +693,8 @@ Framebuffer::Framebuffer(const Caps &caps, rx::GLImplFactory *factory, Framebuff
}
Framebuffer::Framebuffer(const Context *context, egl::Surface *surface, egl::Surface *readSurface)
: mState(),
: mSerial(context->getImplementation()->generateSerial()),
mState(),
mImpl(surface->getImplementation()->createDefaultFramebuffer(context, mState)),
mCachedStatus(GL_FRAMEBUFFER_COMPLETE),
mDirtyDepthAttachmentBinding(this, DIRTY_BIT_DEPTH_ATTACHMENT),
......
......@@ -392,6 +392,8 @@ class Framebuffer final : public angle::ObserverInterface,
static const FramebufferID kDefaultDrawFramebufferHandle;
rx::Serial serial() const { return mSerial; }
private:
bool detachResourceById(const Context *context, GLenum resourceType, GLuint resourceId);
bool detachMatchingAttachment(const Context *context,
......@@ -457,6 +459,7 @@ class Framebuffer final : public angle::ObserverInterface,
mFloat32ColorAttachmentBits.set(index, format->type == GL_FLOAT);
}
rx::Serial mSerial;
FramebufferState mState;
rx::FramebufferImpl *mImpl;
......
......@@ -15,7 +15,7 @@ namespace gl
{
MemoryObject::MemoryObject(rx::GLImplFactory *factory, MemoryObjectID id)
: RefCountObject(id), mImplementation(factory->createMemoryObject())
: RefCountObject(factory->generateSerial(), id), mImplementation(factory->createMemoryObject())
{}
MemoryObject::~MemoryObject() {}
......
......@@ -1232,7 +1232,8 @@ ShaderType ProgramState::getLastAttachedShaderStageType() const
}
Program::Program(rx::GLImplFactory *factory, ShaderProgramManager *manager, ShaderProgramID handle)
: mProgram(factory->createProgram(mState)),
: mSerial(factory->generateSerial()),
mProgram(factory->createProgram(mState)),
mValidated(false),
mLinked(false),
mLinkResolved(true),
......
......@@ -971,6 +971,8 @@ class Program final : angle::NonCopyable, public LabeledObject
// Writes a program's binary to the output memory buffer.
void serialize(const Context *context, angle::MemoryBuffer *binaryOut) const;
rx::Serial serial() const { return mSerial; }
private:
struct LinkingState;
......@@ -1078,6 +1080,7 @@ class Program final : angle::NonCopyable, public LabeledObject
void postResolveLink(const gl::Context *context);
rx::Serial mSerial;
ProgramState mState;
rx::ProgramImpl *mProgram;
......
......@@ -27,7 +27,8 @@ const std::string &ProgramPipelineState::getLabel() const
}
ProgramPipeline::ProgramPipeline(rx::GLImplFactory *factory, ProgramPipelineID handle)
: RefCountObject(handle), mProgramPipeline(factory->createProgramPipeline(mState))
: RefCountObject(factory->generateSerial(), handle),
mProgramPipeline(factory->createProgramPipeline(mState))
{
ASSERT(mProgramPipeline);
}
......
......@@ -14,7 +14,7 @@
namespace gl
{
Query::Query(rx::GLImplFactory *factory, QueryType type, QueryID id)
: RefCountObject(id), mQuery(factory->createQuery(type)), mLabel()
: RefCountObject(factory->generateSerial(), id), mQuery(factory->createQuery(type)), mLabel()
{}
Query::~Query()
......
......@@ -17,6 +17,7 @@
#include "common/debug.h"
#include "libANGLE/Error.h"
#include "libANGLE/Observer.h"
#include "libANGLE/renderer/serial_utils.h"
#include <cstddef>
......@@ -140,14 +141,17 @@ template <typename IDType>
class RefCountObject : public gl::RefCountObjectNoID
{
public:
explicit RefCountObject(IDType id) : mId(id) {}
explicit RefCountObject(rx::Serial serial, IDType id) : mSerial(serial), mId(id) {}
rx::Serial serial() const { return mSerial; }
IDType id() const { return mId; }
protected:
~RefCountObject() override {}
private:
// Unique serials are used to identify resources for frame capture.
rx::Serial mSerial;
IDType mId;
};
......
......@@ -64,7 +64,7 @@ void RenderbufferState::update(GLsizei width,
// Renderbuffer implementation.
Renderbuffer::Renderbuffer(rx::GLImplFactory *implFactory, RenderbufferID id)
: RefCountObject(id),
: RefCountObject(implFactory->generateSerial(), id),
mState(),
mImplementation(implFactory->createRenderbuffer(mState)),
mLabel()
......
......@@ -16,7 +16,11 @@ namespace gl
{
Sampler::Sampler(rx::GLImplFactory *factory, SamplerID id)
: RefCountObject(id), mState(), mDirty(true), mSampler(factory->createSampler(mState)), mLabel()
: RefCountObject(factory->generateSerial(), id),
mState(),
mDirty(true),
mSampler(factory->createSampler(mState)),
mLabel()
{}
Sampler::~Sampler()
......
......@@ -15,7 +15,7 @@ namespace gl
{
Semaphore::Semaphore(rx::GLImplFactory *factory, SemaphoreID id)
: RefCountObject(id), mImplementation(factory->createSemaphore())
: RefCountObject(factory->generateSerial(), id), mImplementation(factory->createSemaphore())
{}
Semaphore::~Semaphore() {}
......
......@@ -639,7 +639,7 @@ void TextureState::clearImageDescs()
}
Texture::Texture(rx::GLImplFactory *factory, TextureID id, TextureType type)
: RefCountObject(id),
: RefCountObject(factory->generateSerial(), id),
mState(type),
mTexture(factory->createTexture(mState)),
mImplObserver(this, rx::kTextureImageImplObserverMessageIndex),
......
......@@ -87,7 +87,7 @@ GLsizeiptr TransformFeedbackState::getPrimitivesDrawn() const
TransformFeedback::TransformFeedback(rx::GLImplFactory *implFactory,
TransformFeedbackID id,
const Caps &caps)
: RefCountObject(id),
: RefCountObject(implFactory->generateSerial(), id),
mState(caps.maxTransformFeedbackSeparateAttributes),
mImplementation(implFactory->createTransformFeedback(mState))
{
......
......@@ -22,6 +22,7 @@
#include "libANGLE/Texture.h"
#include "libANGLE/TransformFeedback.h"
#include "libANGLE/VertexArray.h"
#include "libANGLE/renderer/serial_utils.h"
namespace gl
{
......@@ -53,8 +54,8 @@ class VertexArrayImpl;
class GLImplFactory : angle::NonCopyable
{
public:
GLImplFactory() {}
virtual ~GLImplFactory() {}
GLImplFactory();
virtual ~GLImplFactory();
// Shader creation
virtual CompilerImpl *createCompiler() = 0;
......@@ -101,8 +102,17 @@ class GLImplFactory : angle::NonCopyable
// Overlay creation
virtual OverlayImpl *createOverlay(const gl::OverlayState &state) = 0;
rx::Serial generateSerial() { return mSerialFactory.generate(); }
private:
rx::SerialFactory mSerialFactory;
};
inline GLImplFactory::GLImplFactory() = default;
inline GLImplFactory::~GLImplFactory() = default;
} // namespace rx
#endif // LIBANGLE_RENDERER_GLIMPLFACTORY_H_
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