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