| 1469 | } |
| 1470 | |
| 1471 | void Release(HFactory factory, void* resource) |
| 1472 | { |
| 1473 | DM_PROFILE(__FUNCTION__); |
| 1474 | |
| 1475 | uint64_t* resource_hash = factory->m_ResourceToHash->Get((uintptr_t) resource); |
| 1476 | assert(resource_hash); |
| 1477 | |
| 1478 | ResourceDescriptor* rd = factory->m_Resources->Get(*resource_hash); |
| 1479 | assert(rd); |
| 1480 | assert(rd->m_ReferenceCount > 0); |
| 1481 | rd->m_ReferenceCount--; |
| 1482 | |
| 1483 | if (rd->m_ReferenceCount == 0) |
| 1484 | { |
| 1485 | ResourceType* resource_type = (ResourceType*) rd->m_ResourceType; |
| 1486 | |
| 1487 | DM_PROFILE_DYN(resource_type->m_Extension, 0); |
| 1488 | |
| 1489 | ResourceDestroyParams params; |
| 1490 | params.m_Factory = factory; |
| 1491 | params.m_Type = resource_type; |
| 1492 | params.m_Context = resource_type->m_Context; |
| 1493 | params.m_Resource = rd; |
| 1494 | resource_type->m_DestroyFunction(¶ms); |
| 1495 | |
| 1496 | factory->m_ResourceToHash->Erase((uintptr_t) resource); |
| 1497 | factory->m_Resources->Erase(*resource_hash); |
| 1498 | if (factory->m_ResourceHashToFilename) |
| 1499 | { |
| 1500 | const char** s = factory->m_ResourceHashToFilename->Get(*resource_hash); |
| 1501 | factory->m_ResourceHashToFilename->Erase(*resource_hash); |
| 1502 | assert(s); |
| 1503 | free((void*) *s); |
| 1504 | } |
| 1505 | } |
| 1506 | } |
| 1507 | |
| 1508 | void RegisterResourceReloadedCallback(HFactory factory, FResourceReloadedCallback callback, void* user_data) |
| 1509 | { |