Skip to content

Refactor RefObject and ComObject internal reference count #374

@skallweitNV

Description

@skallweitNV

PR #369 introduced internal reference count to RefObject, to allow Texture objects to hold on to a cached TextureView. The TextureView object needs a strong reference to it's originating Texture when handed to a client and when stored on a command list to keep textures alive. However, this introduces a reference cycle between Texture and TextureView which needs to be broken up if no extra reference is active. To achieve this, RefObject now has an internal reference count allowing to detect if the object is only internally referenced (i.e. just the m_defaultView reference), in which case we can break up the strong reference from TextureView to Texture.

There exists a similar concept for ComObject, where ComObject has it's own reference count and only increments the RefObjects reference by one when created. Once the ComObject goes out of scope, it calls a virtual comFree before decrementing RefObjects refcount. This allows do break up a strong reference once the object goes out of scope from the client API side, but it doesn't allow us to deal with internal references such as the cached texture view.

We should unify the two concepts:

  • Remove ComObject::comFree
  • Remove ComObjects separate reference counter and just delegate to RefObject
  • Improve handling of the internal reference count on RefObject to automatically call something like RefObject::makeInternal and RefObject::makeExternal
  • Update existing code that makes use of comFree (CommandQueue as well as cached pipelines/programs)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions