Metal: Move ObjectCache constructor and destructor

Move the constructor and destructor after the definition of the class
`Internal`.

This fixes an error generated by Clang from the destructor of
`std::unique_ptr<Internal>` when setting the standard version to c++23:

`invalid application of 'sizeof' to an incomplete type 'Metal::ObjectCache::Internal'`.
This commit is contained in:
Dentomologist
2026-01-04 15:47:20 -08:00
parent b1c9c13ca3
commit af585e0bd0

View File

@@ -27,16 +27,6 @@ std::unique_ptr<Metal::ObjectCache> Metal::g_object_cache;
static void SetupDepthStencil(
MRCOwned<id<MTLDepthStencilState>> (&dss)[Metal::DepthStencilSelector::N_VALUES]);
Metal::ObjectCache::ObjectCache()
{
m_internal = std::make_unique<Internal>();
SetupDepthStencil(m_dss);
}
Metal::ObjectCache::~ObjectCache()
{
}
void Metal::ObjectCache::Initialize(MRCOwned<id<MTLDevice>> device)
{
g_device = std::move(device);
@@ -554,6 +544,17 @@ public:
}
};
Metal::ObjectCache::ObjectCache()
{
m_internal = std::make_unique<Internal>();
SetupDepthStencil(m_dss);
}
// This is defined here instead of the header so that the definition of Internal is visible when
// m_internal is destroyed, preventing a compile error caused by calling unique_ptr's destructor
// with an incomplete type.
Metal::ObjectCache::~ObjectCache() = default;
std::unique_ptr<AbstractPipeline>
Metal::ObjectCache::CreatePipeline(const AbstractPipelineConfig& config)
{