Skip to content

Commit

Permalink
Metal: unbind descriptor sets upon destruction (#8268)
Browse files Browse the repository at this point in the history
  • Loading branch information
bejado authored Nov 12, 2024
1 parent e78691b commit 51392c7
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions filament/backend/src/metal/MetalDriver.mm
Original file line number Diff line number Diff line change
Expand Up @@ -872,10 +872,20 @@

void MetalDriver::destroyDescriptorSet(Handle<HwDescriptorSet> dsh) {
DEBUG_LOG("destroyDescriptorSet(dsh = %d)\n", dsh.getId());
if (dsh) {
executeAfterCurrentCommandBufferCompletes(
[this, dsh]() mutable { destruct_handle<MetalDescriptorSet>(dsh); });
if (!dsh) {
return;
}

// Unbind this descriptor set.
auto* descriptorSet = handle_cast<MetalDescriptorSet>(dsh);
for (size_t i = 0; i < MAX_DESCRIPTOR_SET_COUNT; i++) {
if (UTILS_UNLIKELY(mContext->currentDescriptorSets[i] == descriptorSet)) {
mContext->currentDescriptorSets[i] = nullptr;
}
}

executeAfterCurrentCommandBufferCompletes(
[this, dsh]() mutable { destruct_handle<MetalDescriptorSet>(dsh); });
}

void MetalDriver::terminate() {
Expand Down

0 comments on commit 51392c7

Please sign in to comment.