MCPcopy Create free account
hub / github.com/defold/defold / DestroyResourceDeferred

Function DestroyResourceDeferred

engine/graphics/src/vulkan/graphics_vulkan.cpp:212–254  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

210
211 template <typename T>
212 static void DestroyResourceDeferred(VulkanContext* context, T* resource)
213 {
214 if (resource == 0x0 || resource->m_Destroyed)
215 {
216 return;
217 }
218
219 ResourceToDestroy resource_to_destroy;
220 resource_to_destroy.m_ResourceType = resource->GetType();
221
222 switch(resource_to_destroy.m_ResourceType)
223 {
224 case RESOURCE_TYPE_TEXTURE:
225 {
226 VulkanTexture* tex = (VulkanTexture*) resource;
227 resource_to_destroy.m_Texture = tex->m_Handle;
228 DestroyResourceDeferred(context, &tex->m_DeviceBuffer);
229 memset(tex->m_ImageLayout, 0, sizeof(tex->m_ImageLayout));
230 } break;
231 case RESOURCE_TYPE_DEVICE_BUFFER:
232 resource_to_destroy.m_DeviceBuffer = ((DeviceBuffer*) resource)->m_Handle;
233 ((DeviceBuffer*) resource)->UnmapMemory(context->m_LogicalDevice.m_Device);
234 break;
235 case RESOURCE_TYPE_PROGRAM:
236 resource_to_destroy.m_Program = ((VulkanProgram*) resource)->m_Handle;
237 break;
238 case RESOURCE_TYPE_RENDER_TARGET:
239 resource_to_destroy.m_RenderTarget = ((VulkanRenderTarget*) resource)->m_Handle;
240 break;
241 default:
242 assert(0);
243 break;
244 }
245
246 uint32_t frame_ix = resource->m_Handle.m_LastUsedFrame;
247 if (context->m_MainResourcesToDestroy[frame_ix]->Full())
248 {
249 context->m_MainResourcesToDestroy[frame_ix]->OffsetCapacity(8);
250 }
251
252 context->m_MainResourcesToDestroy[frame_ix]->Push(resource_to_destroy);
253 resource->m_Destroyed = 1;
254 }
255
256 static inline bool IsTextureMemoryless(VulkanTexture* texture)
257 {

Callers 12

SetDeviceBufferFunction · 0.70
VulkanDeleteVertexBufferFunction · 0.70
VulkanDeleteIndexBufferFunction · 0.70
ResizeScratchBufferFunction · 0.70
DestroyProgramFunction · 0.70
DestroyRenderTargetFunction · 0.70
VulkanSetTextureInternalFunction · 0.70
VulkanReadPixelsFunction · 0.70

Calls 6

UnmapMemoryMethod · 0.80
assertFunction · 0.50
GetTypeMethod · 0.45
FullMethod · 0.45
OffsetCapacityMethod · 0.45
PushMethod · 0.45

Tested by

no test coverage detected