release resources

This commit is contained in:
Samuliak 2024-07-07 12:34:04 +02:00
parent 3431f6d192
commit 23af64ade8
6 changed files with 44 additions and 19 deletions

View file

@ -18,7 +18,7 @@ public:
BlitPipelineCache() = default;
~BlitPipelineCache() {
clear();
reset();
vertexFunction->release();
fragmentFunction->release();
}
@ -55,7 +55,7 @@ public:
return pipeline;
}
void clear() {
void reset() {
for (auto& pair : pipelineCache) {
pair.second->release();
}

View file

@ -18,7 +18,7 @@ public:
DepthStencilCache() = default;
~DepthStencilCache() {
clear();
reset();
}
void set(MTL::Device* dev) {
@ -70,7 +70,7 @@ public:
return depthStencilState;
}
void clear() {
void reset() {
for (auto& pair : depthStencilCache) {
pair.second->release();
}

View file

@ -32,7 +32,7 @@ public:
DrawPipelineCache() = default;
~DrawPipelineCache() {
clear();
reset();
vertexDescriptor->release();
vertexFunction->release();
}
@ -107,7 +107,7 @@ public:
return pipeline;
}
void clear() {
void reset() {
for (auto& pair : pipelineCache) {
pair.second->release();
}

View file

@ -20,7 +20,7 @@ public:
VertexBufferCache() = default;
~VertexBufferCache() {
clear();
reset();
}
void set(MTL::Device* dev) {
@ -57,7 +57,7 @@ public:
return BufferHandle{buffer, oldPtr};
}
void clear() {
void reset() {
endFrame();
buffer->release();
}

View file

@ -42,6 +42,9 @@ class RendererMTL final : public Renderer {
MTL::Device* device;
MTL::CommandQueue* commandQueue;
// Libraries
MTL::Library* library;
// Caches
SurfaceCache<Metal::ColorRenderTarget, 16, true> colorRenderTargetCache;
SurfaceCache<Metal::DepthStencilRenderTarget, 16, true> depthStencilRenderTargetCache;
@ -105,10 +108,12 @@ class RendererMTL final : public Renderer {
void commitCommandBuffer() {
if (renderCommandEncoder) {
renderCommandEncoder->endEncoding();
renderCommandEncoder->release();
renderCommandEncoder = nullptr;
}
if (commandBuffer) {
commandBuffer->commit();
commandBuffer->release();
commandBuffer = nullptr;
}
}