Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions runtime/shims/d3d12_vulkan_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10264,6 +10264,8 @@ class Device final
state_.context->observe_result(state_.context->vk.vkDeviceWaitIdle(state_.info.device),
"vkDeviceWaitIdle");
}
for (auto* buffer : title_buffers_) buffer->Release();
title_buffers_.clear();
state_.context->drain_deleted_resources(UINT64_MAX);
state_.context->set_bindless_release(nullptr, nullptr);
state_.context->set_bindless_current(nullptr); // the retired generations go with state_.bindless below
Expand Down Expand Up @@ -13232,6 +13234,13 @@ class Device final
log_once("a buffer over the title's memory for a vertex or index view could not be made; HRESULT", int(hr));
return;
}
// Internal buffers are owned by the device and must not keep it alive.
auto* resource = Resource::from<Resource>(made);
if (!resource) {
made->Release();
return;
}
resource->attach_device(nullptr);
title_buffers_.push_back(made);
title_buffer_bytes_ += end - start;
if (title_buffers_.size() <= 8 || !(title_buffers_.size() & (title_buffers_.size() - 1)))
Expand Down
26 changes: 19 additions & 7 deletions runtime/test/d3d12_draw_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ static_assert(offsetof(Vertex, wrong_color) == 16);

} // namespace

int main(int argc, char** argv) {
static int run_test(int argc, char** argv) {
const bool title_index = argc == 2 && std::strcmp(argv[1], "--title-index-window") == 0;
const bool title_vertex = argc == 2 && std::strcmp(argv[1], "--title-vertex-window") == 0;
const bool title_window = title_index || title_vertex;
Expand Down Expand Up @@ -544,6 +544,16 @@ int main(int argc, char** argv) {
EXPECT(aliases.shader_va(title_va + 65536) == aliases.shader_va(title_va) + 65536);
EXPECT(aliases.shader_va(title_va + 65536) != title_va + 65536);
readback->Unmap(0, nullptr);
for (auto* r : {&vertex_buffer, &upload, &readback, &target, &uint_target}) r->reset();
for (auto* p : {&mrt, &instanced, &refused, &unfed, &xor_pso, &fullscreen}) p->reset();
pso.reset();
root.reset();
rtv_heap.reset();
list.reset();
allocator.reset();
queue.reset();
fence.reset();
EXPECT(rt::d3d12_xs::device_proxy_ref_count(device.p) == 1);
EXPECT(d.validation_errors() == 0);
return 0;
}
Expand Down Expand Up @@ -1242,12 +1252,7 @@ int main(int argc, char** argv) {
allocator.reset();
queue.reset();
fence.reset();
// The device keeps the buffers it made over the title's vertex pages until it goes (make_title_buffer), and
// each holds a reference: the large batch leaves seven of them.
if (std::getenv("LEONIDA_TEST_GEOMETRY_BATCH"))
EXPECT(rt::d3d12_xs::device_proxy_ref_count(device.p) >= 1);
else
EXPECT(rt::d3d12_xs::device_proxy_ref_count(device.p) == 1);
EXPECT(rt::d3d12_xs::device_proxy_ref_count(device.p) == 1);
}

unsigned mismatches = 0;
Expand Down Expand Up @@ -1400,3 +1405,10 @@ int main(int argc, char** argv) {
size * size, logic_op ? "an XOR logic op" : "(no logicOp on this GPU)");
return 0;
}

int main(int argc, char** argv) {
const int result = run_test(argc, argv);
if (result != 0) return result;
EXPECT(vktest::validation_error_count() == 0);
return 0;
}