diff options
| author | Tauwni <102470988+Tauwni@users.noreply.github.com> | 2026-11-26 12:19:12 +0100 |
|---|---|---|
| committer | Tauwni <102470988+Tauwni@users.noreply.github.com> | 2026-11-26 12:19:12 +0100 |
| commit | beffaa9a476ca1b3dfd9cfa55e39eafbb1f5eec6 (patch) | |
| tree | 32877805bf4eb46d9a89d5753db6b5a2b06dc845 /runtime/shims/d3d12_com.cpp | |
| parent | f29ca7bacae9507f83e8c56abdb604bd4efb4cf1 (diff) | |
| parent | a73a57e1339be072baf5522351c8ec7f1482b56b (diff) | |
Merge main into fix/null-descriptor-generated-dir
Diffstat (limited to 'runtime/shims/d3d12_com.cpp')
| -rw-r--r-- | runtime/shims/d3d12_com.cpp | 275 |
1 files changed, 233 insertions, 42 deletions
diff --git a/runtime/shims/d3d12_com.cpp b/runtime/shims/d3d12_com.cpp index 6dee464a8..4a61ffadb 100644 --- a/runtime/shims/d3d12_com.cpp +++ b/runtime/shims/d3d12_com.cpp | |||
| @@ -222,8 +222,11 @@ public: | |||
| 222 | const leonida::CommandList& commands() const { return list_; } | 222 | const leonida::CommandList& commands() const { return list_; } |
| 223 | // The descriptor tables this recording binds (console VAs), for the scan before a submission. | 223 | // The descriptor tables this recording binds (console VAs), for the scan before a submission. |
| 224 | const std::vector<std::pair<std::uint64_t, std::uint32_t>>& tables() const { return tables_; } | 224 | const std::vector<std::pair<std::uint64_t, std::uint32_t>>& tables() const { return tables_; } |
| 225 | // The pipeline states and root signatures the recording names (it holds a reference to each until Reset). | 225 | // The pipeline states and root signatures the recording names (it holds a reference to each until Reset), and |
| 226 | // the objects a shim handed it with hold_until_reset. | ||
| 226 | const std::vector<IUnknown*>& pinned() const { return held_; } | 227 | const std::vector<IUnknown*>& pinned() const { return held_; } |
| 228 | // rt::d3d12::hold_until_reset: an object the recording uses that its caller does not keep (a shim's own scratch). | ||
| 229 | void hold_for_recording(IUnknown* object) { hold(object); } | ||
| 227 | bool needs_all_sampled_views() const { | 230 | bool needs_all_sampled_views() const { |
| 228 | if (directly_indexed_) return true; | 231 | if (directly_indexed_) return true; |
| 229 | for (const auto& command : list_.commands()) { | 232 | for (const auto& command : list_.commands()) { |
| @@ -512,6 +515,15 @@ public: | |||
| 512 | blend_factor_ = value; | 515 | blend_factor_ = value; |
| 513 | } | 516 | } |
| 514 | 517 | ||
| 518 | // ID3D12GraphicsCommandList1: the depth-bounds test's range for the draws after it, read by pipelines that enable | ||
| 519 | // the test (DEPTH_STENCIL1/2). D3D12's default is [0, 1]. | ||
| 520 | void STDMETHODCALLTYPE OMSetDepthBounds(FLOAT min, FLOAT max) override { | ||
| 521 | if (list_.closed()) return; | ||
| 522 | const std::array<float, 2> value{min, max}; | ||
| 523 | if (defer([=](GraphicsCommandList& l) { l.depth_bounds_ = value; })) return; | ||
| 524 | depth_bounds_ = value; | ||
| 525 | } | ||
| 526 | |||
| 515 | void STDMETHODCALLTYPE OMSetStencilRef(UINT reference) override { | 527 | void STDMETHODCALLTYPE OMSetStencilRef(UINT reference) override { |
| 516 | if (list_.closed()) return; | 528 | if (list_.closed()) return; |
| 517 | if (defer([=](GraphicsCommandList& l) { l.front_stencil_ref_ = l.back_stencil_ref_ = reference; })) return; | 529 | if (defer([=](GraphicsCommandList& l) { l.front_stencil_ref_ = l.back_stencil_ref_ = reference; })) return; |
| @@ -569,6 +581,8 @@ public: | |||
| 569 | note_direct_heap_indexing(graphics_.layout); | 581 | note_direct_heap_indexing(graphics_.layout); |
| 570 | draw.mesh = true; | 582 | draw.mesh = true; |
| 571 | draw.viewports = draw_viewports(); | 583 | draw.viewports = draw_viewports(); |
| 584 | draw.depth_bounds = depth_bounds_; | ||
| 585 | request_draw_pipeline(); | ||
| 572 | check(list_.draw(std::move(draw))); | 586 | check(list_.draw(std::move(draw))); |
| 573 | } | 587 | } |
| 574 | 588 | ||
| @@ -837,8 +851,7 @@ public: | |||
| 837 | d3d12_trace::record("ID3D12GraphicsCommandList::ClearRenderTargetView"); | 851 | d3d12_trace::record("ID3D12GraphicsCommandList::ClearRenderTargetView"); |
| 838 | if (type_ == D3D12_COMMAND_LIST_TYPE_BUNDLE) return check(false); | 852 | if (type_ == D3D12_COMMAND_LIST_TYPE_BUNDLE) return check(false); |
| 839 | if (!view.ptr || !color) return check(false); | 853 | if (!view.ptr || !color) return check(false); |
| 840 | // LOCAL DIAGNOSTIC: what the title clears, and with which colour | 854 | if (leonida::fsdraw::enabled()) { // LOCAL DIAGNOSTIC: what the title clears, and with which colour |
| 841 | if (leonida::local_diagnostics()) { | ||
| 842 | static std::atomic<std::uint64_t> clears{0}; | 855 | static std::atomic<std::uint64_t> clears{0}; |
| 843 | const std::uint64_t n = ++clears; | 856 | const std::uint64_t n = ++clears; |
| 844 | if (n <= 6 || n % 600 == 0) { | 857 | if (n <= 6 || n % 600 == 0) { |
| @@ -1014,10 +1027,11 @@ public: | |||
| 1014 | if (!leonida::indirect_records_fit(arg_desc.Width, argument_buffer_offset, max_command_count, | 1027 | if (!leonida::indirect_records_fit(arg_desc.Width, argument_buffer_offset, max_command_count, |
| 1015 | stride, sig->packed_size())) | 1028 | stride, sig->packed_size())) |
| 1016 | return check(false); | 1029 | return check(false); |
| 1017 | if (kind == leonida::IndirectKind::dispatch_mesh) { | 1030 | if (kind == leonida::IndirectKind::dispatch_mesh && !terminal_only) { |
| 1018 | // Not replayed yet (#3777 replays it as vkCmdDrawMeshTasksIndirectEXT): nothing is recorded, and the | 1031 | // A DISPATCH_MESH signature with root arguments before it is not replayed: nothing is recorded, and the |
| 1019 | // first such call says so. The list stays valid. | 1032 | // first such call says so. The list stays valid. A terminal-only one is recorded below as a mesh draw |
| 1020 | leonida::indirect_stats::skip(leonida::indirect_stats::Event::record_skip, leonida::indirect_stats::mesh); | 1033 | // (vkCmdDrawMeshTasksIndirect(Count)EXT). |
| 1034 | leonida::indirect_stats::skip(leonida::indirect_stats::Event::record_skip, leonida::indirect_stats::compound); | ||
| 1021 | return; | 1035 | return; |
| 1022 | } | 1036 | } |
| 1023 | if (!terminal_only && (kind == leonida::IndirectKind::draw || kind == leonida::IndirectKind::draw_indexed)) { | 1037 | if (!terminal_only && (kind == leonida::IndirectKind::draw || kind == leonida::IndirectKind::draw_indexed)) { |
| @@ -1352,7 +1366,8 @@ private: | |||
| 1352 | 1366 | ||
| 1353 | void clear_unordered_access(D3D12_CPU_DESCRIPTOR_HANDLE view, ID3D12Resource* resource, bool is_float, | 1367 | void clear_unordered_access(D3D12_CPU_DESCRIPTOR_HANDLE view, ID3D12Resource* resource, bool is_float, |
| 1354 | const std::array<std::uint32_t, 4>& values, UINT count, const D3D12_RECT* rects) { | 1368 | const std::array<std::uint32_t, 4>& values, UINT count, const D3D12_RECT* rects) { |
| 1355 | if (type_ == D3D12_COMMAND_LIST_TYPE_BUNDLE) return check(false); // no clear is allowed in a bundle | 1369 | if (type_ != D3D12_COMMAND_LIST_TYPE_DIRECT && type_ != D3D12_COMMAND_LIST_TYPE_COMPUTE) |
| 1370 | return check(false); | ||
| 1356 | leonida::UavView target{}; | 1371 | leonida::UavView target{}; |
| 1357 | if (!view.ptr || !resource || !unordered_access_view(view, resource, target)) return check(false); | 1372 | if (!view.ptr || !resource || !unordered_access_view(view, resource, target)) return check(false); |
| 1358 | check(list_.clear_unordered_access(target, is_float, values, to_rects(count, rects))); | 1373 | check(list_.clear_unordered_access(target, is_float, values, to_rects(count, rects))); |
| @@ -1384,17 +1399,26 @@ private: | |||
| 1384 | const bool volume = image.type == g::ImageType::image_3d; | 1399 | const bool volume = image.type == g::ImageType::image_3d; |
| 1385 | const auto pair = xbox_depth_storage(resource); | 1400 | const auto pair = xbox_depth_storage(resource); |
| 1386 | if (pair.colour) out.resource = pair.colour; | 1401 | if (pair.colour) out.resource = pair.colour; |
| 1387 | if (g::partial_volume_uav(words, image)) { | ||
| 1388 | // Transfer clears operate on a whole 3D mip, not a storage image view. Refuse instead of | ||
| 1389 | // overwriting slices outside the UAV; a sliced clear needs a separate replay path. | ||
| 1390 | stub("ClearUnorderedAccessView of a partial 3D mip"); | ||
| 1391 | return false; | ||
| 1392 | } | ||
| 1393 | out.buffer = false; | 1402 | out.buffer = false; |
| 1394 | out.format = std::uint32_t(descriptor_format(image.format, image.swizzle)); | 1403 | out.format = std::uint32_t(descriptor_format(image.format, image.swizzle)); |
| 1395 | out.mip = image.first_mip; | 1404 | out.mip = image.first_mip; |
| 1396 | out.first_layer = volume ? 0 : image.first_layer; // a 3D view clears every slice of its mip | 1405 | if (volume) { |
| 1397 | out.layer_count = volume ? 1 : image.layer_count; | 1406 | g::VolumeUavRange slices{}; |
| 1407 | if (g::volume_uav_range(words, image, slices)) { | ||
| 1408 | out.first_layer = slices.first_w; | ||
| 1409 | out.layer_count = slices.w_size; | ||
| 1410 | } else { | ||
| 1411 | // Untagged T#s select the entire resource mip, even if DEPTH describes a smaller or larger view. | ||
| 1412 | const auto desc = resource->GetDesc(); | ||
| 1413 | const auto depth = desc.Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE3D | ||
| 1414 | ? std::uint32_t(desc.DepthOrArraySize) : image.depth; | ||
| 1415 | out.first_layer = 0; | ||
| 1416 | out.layer_count = std::max(1u, depth >> image.first_mip); | ||
| 1417 | } | ||
| 1418 | } else { | ||
| 1419 | out.first_layer = image.first_layer; | ||
| 1420 | out.layer_count = image.layer_count; | ||
| 1421 | } | ||
| 1398 | out.exact_clear_format = volume || image.type == g::ImageType::image_1d || | 1422 | out.exact_clear_format = volume || image.type == g::ImageType::image_1d || |
| 1399 | image.type == g::ImageType::image_1d_array; | 1423 | image.type == g::ImageType::image_1d_array; |
| 1400 | return out.format != VK_FORMAT_UNDEFINED; | 1424 | return out.format != VK_FORMAT_UNDEFINED; |
| @@ -1533,8 +1557,10 @@ private: | |||
| 1533 | // No copy for the title's memory: the root view is 0, so the shader reads the arena's zero page instead | 1557 | // No copy for the title's memory: the root view is 0, so the shader reads the arena's zero page instead |
| 1534 | // of storing at heap_base + a raw title address. | 1558 | // of storing at heap_base + a raw title address. |
| 1535 | if (!va && raw) leonida::note_unbacked_view("root view", raw, kRootViewBytes); | 1559 | if (!va && raw) leonida::note_unbacked_view("root view", raw, kRootViewBytes); |
| 1536 | } else | 1560 | } else { |
| 1561 | if (descriptor_ring_diagnostics()) note_table_slots(va, p->table_descriptors); | ||
| 1537 | va = console_descriptor_table_va(va); | 1562 | va = console_descriptor_table_va(va); |
| 1563 | } | ||
| 1538 | if (type != rt::rootsig::ParamType::Descriptor && va && p->table_descriptors) | 1564 | if (type != rt::rootsig::ParamType::Descriptor && va && p->table_descriptors) |
| 1539 | remember_table(va, p->table_descriptors); | 1565 | remember_table(va, p->table_descriptors); |
| 1540 | const std::uint32_t first = first_dword(state, *p); | 1566 | const std::uint32_t first = first_dword(state, *p); |
| @@ -1561,6 +1587,9 @@ private: | |||
| 1561 | ID3D12DescriptorHeap* sampler_heap_ = nullptr; | 1587 | ID3D12DescriptorHeap* sampler_heap_ = nullptr; |
| 1562 | D3D12_GPU_VIRTUAL_ADDRESS cbv_srv_uav_base_ = 0; | 1588 | D3D12_GPU_VIRTUAL_ADDRESS cbv_srv_uav_base_ = 0; |
| 1563 | D3D12_GPU_VIRTUAL_ADDRESS sampler_base_ = 0; | 1589 | D3D12_GPU_VIRTUAL_ADDRESS sampler_base_ = 0; |
| 1590 | UINT heap_slots_[2]{}; // NumDescriptors of the bound view and sampler heaps | ||
| 1591 | std::uint64_t table_high_[3]{}; // this list's descriptor-ring marks: view, sampler, console heap (note_table_slots) | ||
| 1592 | std::uint64_t console_high_base_ = 0; // the console heap table_high_[2] is for | ||
| 1564 | std::uint32_t topology_ = 0; // D3D_PRIMITIVE_TOPOLOGY_UNDEFINED | 1593 | std::uint32_t topology_ = 0; // D3D_PRIMITIVE_TOPOLOGY_UNDEFINED |
| 1565 | std::array<leonida::VertexBufferView, D3D12_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT> vertex_buffers_{}; | 1594 | std::array<leonida::VertexBufferView, D3D12_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT> vertex_buffers_{}; |
| 1566 | leonida::IndexBufferView index_{}; | 1595 | leonida::IndexBufferView index_{}; |
| @@ -1585,6 +1614,7 @@ private: | |||
| 1585 | bool draw_views_stale_ = true; | 1614 | bool draw_views_stale_ = true; |
| 1586 | leonida::TargetView depth_{}; | 1615 | leonida::TargetView depth_{}; |
| 1587 | std::array<float, 4> blend_factor_{1, 1, 1, 1}; | 1616 | std::array<float, 4> blend_factor_{1, 1, 1, 1}; |
| 1617 | std::array<float, 2> depth_bounds_{0, 1}; | ||
| 1588 | 1618 | ||
| 1589 | // The root signatures and pipeline states this recording uses. D3D12 lets an application release them right | 1619 | // The root signatures and pipeline states this recording uses. D3D12 lets an application release them right |
| 1590 | // after Set*RootSignature / SetPipelineState; the list keeps them until Reset or its own release, so the root | 1620 | // after Set*RootSignature / SetPipelineState; the list keeps them until Reset or its own release, so the root |
| @@ -1632,6 +1662,7 @@ private: | |||
| 1632 | hold(state); | 1662 | hold(state); |
| 1633 | compute_pipeline_ = compute_pipeline_id(state); | 1663 | compute_pipeline_ = compute_pipeline_id(state); |
| 1634 | graphics_pipeline_ = graphics_pipeline_id(state); | 1664 | graphics_pipeline_ = graphics_pipeline_id(state); |
| 1665 | if (compute_pipeline_) request_pipeline_build(compute_pipeline_, 0, false); // starts its build, if asynchronous | ||
| 1635 | // A pipeline this device never registered: a LEONIDA_STUB_PIPELINES stub (its translated shader is missing), | 1666 | // A pipeline this device never registered: a LEONIDA_STUB_PIPELINES stub (its translated shader is missing), |
| 1636 | // or one from another device. Its draws resolve to nothing in replay; its dispatches are no-ops too | 1667 | // or one from another device. Its draws resolve to nothing in replay; its dispatches are no-ops too |
| 1637 | // (record_dispatch), so the list still closes. | 1668 | // (record_dispatch), so the list still closes. |
| @@ -1646,6 +1677,81 @@ private: | |||
| 1646 | cbv_srv_uav_base_ = cbv_base; | 1677 | cbv_srv_uav_base_ = cbv_base; |
| 1647 | sampler_heap_ = smp; | 1678 | sampler_heap_ = smp; |
| 1648 | sampler_base_ = smp_base; | 1679 | sampler_base_ = smp_base; |
| 1680 | if (!descriptor_ring_diagnostics()) return; | ||
| 1681 | for (int h = 0; h < 2; ++h) { | ||
| 1682 | D3D12_DESCRIPTOR_HEAP_DESC desc{}; | ||
| 1683 | D3D12_GPU_VIRTUAL_ADDRESS base = 0; | ||
| 1684 | heap_slots_[h] = descriptor_heap_info(h ? smp : cbv, desc, base) ? desc.NumDescriptors : 0; | ||
| 1685 | table_high_[h] = 0; | ||
| 1686 | } | ||
| 1687 | } | ||
| 1688 | |||
| 1689 | // note_table_slots runs on every descriptor-table bind of the title's recording threads, and takes a global lock | ||
| 1690 | // whenever a list's mark rises (almost every bind of a ring): only with LEONIDA_DEVICE_FAULT=1 or | ||
| 1691 | // LEONIDA_DESCRIPTOR_RING=1. | ||
| 1692 | static bool descriptor_ring_diagnostics() { | ||
| 1693 | static const bool on = [] { | ||
| 1694 | char v[2]{}; | ||
| 1695 | return (GetEnvironmentVariableA("LEONIDA_DEVICE_FAULT", v, 2) == 1 && (v[0] == '1' || v[0] == '2')) || | ||
| 1696 | (GetEnvironmentVariableA("LEONIDA_DESCRIPTOR_RING", v, 2) == 1 && v[0] == '1'); | ||
| 1697 | }(); | ||
| 1698 | return on; | ||
| 1699 | } | ||
| 1700 | |||
| 1701 | // LOCAL DIAGNOSTIC (early device loss; VIctory 3827767, a title table ring past the slots the layer backs hung | ||
| 1702 | // NVIDIA ~45 s in): the highest slot a descriptor table reaches in each bound heap, against the heap's slots. Logged | ||
| 1703 | // when a heap's high-water mark passes another eighth of the heap, every new mark past its end, and the first | ||
| 1704 | // tables that lie in no bound heap. A list only takes the shared lock when its own mark rises. | ||
| 1705 | void note_table_slots(std::uint64_t va, std::uint32_t declared) { | ||
| 1706 | if (!va) return; | ||
| 1707 | D3D12_GPU_VIRTUAL_ADDRESS bases[3]{cbv_srv_uav_base_, sampler_base_, 0}; | ||
| 1708 | std::uint64_t counts[3]{heap_slots_[0], heap_slots_[1], 0}; | ||
| 1709 | int heap = -1; | ||
| 1710 | for (int h = 0; h < 2; ++h) | ||
| 1711 | if (bases[h] && counts[h] && va >= bases[h] && va < bases[h] + counts[h] * descriptor_size) | ||
| 1712 | heap = h; | ||
| 1713 | std::uint64_t console_bytes = 0; | ||
| 1714 | if (heap < 0 && console_descriptor_heap_range(va, bases[2], console_bytes)) { | ||
| 1715 | heap = 2; // a console descriptor heap (Xbox slot 14) in title memory, read from its arena copy | ||
| 1716 | counts[2] = console_bytes / descriptor_size; | ||
| 1717 | } | ||
| 1718 | if (heap < 0) { | ||
| 1719 | static std::atomic<int> outside{0}; | ||
| 1720 | if (outside.fetch_add(1) < 8) | ||
| 1721 | std::fprintf(stderr, "[rt] descriptor-ring: table 0x%llx in no bound heap (view heap 0x%llx, %u slots; " | ||
| 1722 | "sampler heap 0x%llx, %u slots)\n", | ||
| 1723 | (unsigned long long)va, (unsigned long long)bases[0], heap_slots_[0], | ||
| 1724 | (unsigned long long)bases[1], heap_slots_[1]); | ||
| 1725 | return; | ||
| 1726 | } | ||
| 1727 | const std::uint64_t first = (va - bases[heap]) / descriptor_size; | ||
| 1728 | const std::uint64_t end = first + (declared ? declared : 1); | ||
| 1729 | if (heap == 2 && console_high_base_ != bases[2]) { | ||
| 1730 | console_high_base_ = bases[2]; | ||
| 1731 | table_high_[2] = 0; | ||
| 1732 | } | ||
| 1733 | if (end <= table_high_[heap]) return; | ||
| 1734 | table_high_[heap] = end; | ||
| 1735 | struct Mark { | ||
| 1736 | std::uint64_t high = 0; | ||
| 1737 | std::uint64_t logged = 0; | ||
| 1738 | }; | ||
| 1739 | static std::mutex mutex; | ||
| 1740 | static std::map<std::uint64_t, Mark> marks; // by heap base | ||
| 1741 | std::lock_guard lock(mutex); | ||
| 1742 | Mark& mark = marks[bases[heap]]; | ||
| 1743 | if (end <= mark.high) return; | ||
| 1744 | mark.high = end; | ||
| 1745 | const std::uint64_t slots = counts[heap]; | ||
| 1746 | const std::uint64_t step = (std::max)(slots / 8, std::uint64_t{1}); | ||
| 1747 | if (end > slots || end >= mark.logged + step) { | ||
| 1748 | mark.logged = end; | ||
| 1749 | std::fprintf(stderr, "[rt] descriptor-ring: %s heap 0x%llx: highest slot %llu (table at %llu, %u declared) " | ||
| 1750 | "of %llu backed%s\n", | ||
| 1751 | heap == 2 ? "console" : heap ? "sampler" : "view", (unsigned long long)bases[heap], (unsigned long long)(end - 1), | ||
| 1752 | (unsigned long long)first, declared, (unsigned long long)slots, | ||
| 1753 | end > slots ? " -- PAST THE HEAP" : ""); | ||
| 1754 | } | ||
| 1649 | } | 1755 | } |
| 1650 | 1756 | ||
| 1651 | // D3D12 bundle rule: every non-null heap bound by a bundle's SetDescriptorHeaps must match the parent list's | 1757 | // D3D12 bundle rule: every non-null heap bound by a bundle's SetDescriptorHeaps must match the parent list's |
| @@ -1663,19 +1769,26 @@ private: | |||
| 1663 | 1769 | ||
| 1664 | void note_direct_heap_indexing(const RootArgumentLayout* layout) { | 1770 | void note_direct_heap_indexing(const RootArgumentLayout* layout) { |
| 1665 | if (!layout) return; | 1771 | if (!layout) return; |
| 1772 | // Called at every draw and dispatch: each note has its own flag, so after its first time a site skips | ||
| 1773 | // note_once's process-wide mutex, std::string and set lookup. | ||
| 1774 | static std::atomic<bool> told[4]; | ||
| 1775 | const auto once = [](int site, const char* what) { | ||
| 1776 | if (!told[site].load(std::memory_order_relaxed) && !told[site].exchange(true)) note_once(what); | ||
| 1777 | }; | ||
| 1666 | if (layout->flags & D3D12_ROOT_SIGNATURE_FLAG_CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED) { | 1778 | if (layout->flags & D3D12_ROOT_SIGNATURE_FLAG_CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED) { |
| 1667 | if (!cbv_srv_uav_heap_) | 1779 | if (!cbv_srv_uav_heap_) |
| 1668 | note_once("draw/dispatch uses CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED with no CBV/SRV/UAV heap bound"); | 1780 | once(0, "draw/dispatch uses CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED with no CBV/SRV/UAV heap bound"); |
| 1669 | else { | 1781 | else { |
| 1670 | remember_table(cbv_srv_uav_base_, cbv_srv_uav_heap_->GetDesc().NumDescriptors); | 1782 | const auto shader_va = console_descriptor_table_va(cbv_srv_uav_base_); |
| 1671 | note_once("CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED heap base tracked on list"); | 1783 | remember_table(shader_va, cbv_srv_uav_heap_->GetDesc().NumDescriptors); |
| 1784 | once(1, "CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED heap base tracked on list"); | ||
| 1672 | } | 1785 | } |
| 1673 | } | 1786 | } |
| 1674 | if (layout->flags & D3D12_ROOT_SIGNATURE_FLAG_SAMPLER_HEAP_DIRECTLY_INDEXED) { | 1787 | if (layout->flags & D3D12_ROOT_SIGNATURE_FLAG_SAMPLER_HEAP_DIRECTLY_INDEXED) { |
| 1675 | if (!sampler_heap_) | 1788 | if (!sampler_heap_) |
| 1676 | note_once("draw/dispatch uses SAMPLER_HEAP_DIRECTLY_INDEXED with no sampler heap bound"); | 1789 | once(2, "draw/dispatch uses SAMPLER_HEAP_DIRECTLY_INDEXED with no sampler heap bound"); |
| 1677 | else | 1790 | else |
| 1678 | note_once("SAMPLER_HEAP_DIRECTLY_INDEXED heap base tracked on list"); | 1791 | once(3, "SAMPLER_HEAP_DIRECTLY_INDEXED heap base tracked on list"); |
| 1679 | } | 1792 | } |
| 1680 | } | 1793 | } |
| 1681 | 1794 | ||
| @@ -1703,6 +1816,7 @@ private: | |||
| 1703 | draw_views_stale_ = true; | 1816 | draw_views_stale_ = true; |
| 1704 | depth_ = {}; | 1817 | depth_ = {}; |
| 1705 | blend_factor_ = {1, 1, 1, 1}; | 1818 | blend_factor_ = {1, 1, 1, 1}; |
| 1819 | depth_bounds_ = {0, 1}; | ||
| 1706 | set_pipeline(state); | 1820 | set_pipeline(state); |
| 1707 | } | 1821 | } |
| 1708 | 1822 | ||
| @@ -1771,10 +1885,14 @@ private: | |||
| 1771 | void write_direct_heaps(const RootState& state, std::uint32_t slot, | 1885 | void write_direct_heaps(const RootState& state, std::uint32_t slot, |
| 1772 | std::array<std::uint32_t, rt::rootsig::kMaxUserSgprs>& data) const { | 1886 | std::array<std::uint32_t, rt::rootsig::kMaxUserSgprs>& data) const { |
| 1773 | const auto flags = state.layout->flags; | 1887 | const auto flags = state.layout->flags; |
| 1774 | if ((flags & D3D12_ROOT_SIGNATURE_FLAG_CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED) && slot < data.size()) | 1888 | if ((flags & D3D12_ROOT_SIGNATURE_FLAG_CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED) && slot < data.size()) { |
| 1775 | data[slot++] = static_cast<std::uint32_t>(cbv_srv_uav_base_); | 1889 | const D3D12_GPU_VIRTUAL_ADDRESS va = console_descriptor_table_va(cbv_srv_uav_base_); |
| 1776 | if ((flags & D3D12_ROOT_SIGNATURE_FLAG_SAMPLER_HEAP_DIRECTLY_INDEXED) && slot < data.size()) | 1890 | data[slot++] = static_cast<std::uint32_t>(va); |
| 1777 | data[slot] = static_cast<std::uint32_t>(sampler_base_); | 1891 | } |
| 1892 | if ((flags & D3D12_ROOT_SIGNATURE_FLAG_SAMPLER_HEAP_DIRECTLY_INDEXED) && slot < data.size()) { | ||
| 1893 | const D3D12_GPU_VIRTUAL_ADDRESS va = console_descriptor_table_va(sampler_base_); | ||
| 1894 | data[slot] = static_cast<std::uint32_t>(va); | ||
| 1895 | } | ||
| 1778 | } | 1896 | } |
| 1779 | 1897 | ||
| 1780 | std::array<std::uint32_t, rt::rootsig::kMaxUserSgprs> with_direct_heaps(const RootState& state, | 1898 | std::array<std::uint32_t, rt::rootsig::kMaxUserSgprs> with_direct_heaps(const RootState& state, |
| @@ -1830,9 +1948,12 @@ private: | |||
| 1830 | } | 1948 | } |
| 1831 | const std::uint32_t end = layout.graphics_arguments_end; | 1949 | const std::uint32_t end = layout.graphics_arguments_end; |
| 1832 | if (end >= rt::rootsig::kMaxUserSgprs) { | 1950 | if (end >= rt::rootsig::kMaxUserSgprs) { |
| 1833 | note_once(layout.graphics_console | 1951 | static std::atomic<bool> told[2]; // per draw: the site's own flag before note_once's mutex |
| 1834 | ? "graphics direct heaps: not supplied, the explicit arguments fill s8..s31" | 1952 | const int site = layout.graphics_console ? 0 : 1; |
| 1835 | : "graphics direct heaps: not supplied, the signature keeps the s0 graphics layout"); | 1953 | if (!told[site].load(std::memory_order_relaxed) && !told[site].exchange(true)) |
| 1954 | note_once(layout.graphics_console | ||
| 1955 | ? "graphics direct heaps: not supplied, the explicit arguments fill s8..s31" | ||
| 1956 | : "graphics direct heaps: not supplied, the signature keeps the s0 graphics layout"); | ||
| 1836 | return graphics_.data; | 1957 | return graphics_.data; |
| 1837 | } | 1958 | } |
| 1838 | static std::atomic<bool> logged{false}; | 1959 | static std::atomic<bool> logged{false}; |
| @@ -1840,13 +1961,17 @@ private: | |||
| 1840 | const bool resource = layout.flags & D3D12_ROOT_SIGNATURE_FLAG_CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED; | 1961 | const bool resource = layout.flags & D3D12_ROOT_SIGNATURE_FLAG_CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED; |
| 1841 | const bool sampler = layout.flags & D3D12_ROOT_SIGNATURE_FLAG_SAMPLER_HEAP_DIRECTLY_INDEXED; | 1962 | const bool sampler = layout.flags & D3D12_ROOT_SIGNATURE_FLAG_SAMPLER_HEAP_DIRECTLY_INDEXED; |
| 1842 | char resource_at[48] = "none", sampler_at[48] = "none"; | 1963 | char resource_at[48] = "none", sampler_at[48] = "none"; |
| 1843 | if (resource) | 1964 | if (resource) { |
| 1965 | const auto va = console_descriptor_table_va(cbv_srv_uav_base_); | ||
| 1844 | std::snprintf(resource_at, sizeof resource_at, "0x%llx at s%u", | 1966 | std::snprintf(resource_at, sizeof resource_at, "0x%llx at s%u", |
| 1845 | static_cast<unsigned long long>(std::uint32_t(cbv_srv_uav_base_)), end); | 1967 | static_cast<unsigned long long>(std::uint32_t(va)), end); |
| 1846 | if (sampler && end + (resource ? 1u : 0u) < rt::rootsig::kMaxUserSgprs) | 1968 | } |
| 1969 | if (sampler && end + (resource ? 1u : 0u) < rt::rootsig::kMaxUserSgprs) { | ||
| 1970 | const auto va = console_descriptor_table_va(sampler_base_); | ||
| 1847 | std::snprintf(sampler_at, sizeof sampler_at, "0x%llx at s%u", | 1971 | std::snprintf(sampler_at, sizeof sampler_at, "0x%llx at s%u", |
| 1848 | static_cast<unsigned long long>(std::uint32_t(sampler_base_)), | 1972 | static_cast<unsigned long long>(std::uint32_t(va)), |
| 1849 | end + (resource ? 1u : 0u)); | 1973 | end + (resource ? 1u : 0u)); |
| 1974 | } | ||
| 1850 | std::fprintf(stderr, | 1975 | std::fprintf(stderr, |
| 1851 | "[rt] d3d12: graphics direct heaps: resource heap %s, sampler heap %s, after %u dwords of " | 1976 | "[rt] d3d12: graphics direct heaps: resource heap %s, sampler heap %s, after %u dwords of " |
| 1852 | "explicit arguments from s8 (first draw; LEONIDA_GRAPHICS_DIRECT_HEAPS=0 " | 1977 | "explicit arguments from s8 (first draw; LEONIDA_GRAPHICS_DIRECT_HEAPS=0 " |
| @@ -1912,7 +2037,41 @@ private: | |||
| 1912 | return draw_viewports_; | 2037 | return draw_viewports_; |
| 1913 | } | 2038 | } |
| 1914 | 2039 | ||
| 2040 | // LEONIDA_ASYNC_PIPELINES=1: the variant this draw needs (by the targets it binds) starts building on the compile | ||
| 2041 | // worker now, before the list is submitted (request_pipeline_build). | ||
| 2042 | void request_draw_pipeline() const { | ||
| 2043 | std::uint32_t bound = 0; | ||
| 2044 | for (UINT slot = 0; slot < render_target_count_ && slot < render_targets_.size(); ++slot) | ||
| 2045 | if (render_targets_[slot].resource) bound |= 1u << slot; | ||
| 2046 | request_pipeline_build(graphics_pipeline_, bound, depth_.resource != 0); | ||
| 2047 | } | ||
| 2048 | |||
| 2049 | // One recorder for both entry points: the direct ExecuteIndirect call and a bundle call deferred into its | ||
| 2050 | // parent list. A simple DRAW or DRAW_INDEXED signature becomes a stateful Draw (IndirectRasterDraw) carrying the | ||
| 2051 | // graphics state frozen at the call; anything else stays a legacy ExecuteIndirect command. | ||
| 1915 | void record_indirect(leonida::IndirectKind kind, bool terminal_only, const leonida::IndirectDrawArgs& args) { | 2052 | void record_indirect(leonida::IndirectKind kind, bool terminal_only, const leonida::IndirectDrawArgs& args) { |
| 2053 | if (kind == leonida::IndirectKind::dispatch_mesh) { | ||
| 2054 | // As DispatchMesh, with the group counts in the argument buffer: the replay draws the records with | ||
| 2055 | // vkCmdDrawMeshTasksIndirect(Count)EXT after its clamp pass bounds them. | ||
| 2056 | if (type_ != D3D12_COMMAND_LIST_TYPE_DIRECT) return check(false); | ||
| 2057 | if (!args.max_count) return; | ||
| 2058 | namespace stats = leonida::indirect_stats; | ||
| 2059 | const auto skip = [](stats::Reason reason) { stats::skip(stats::Event::record_skip, reason); }; | ||
| 2060 | if (indirect_draws_disabled()) return skip(stats::disabled); | ||
| 2061 | if (!terminal_only) return skip(stats::compound); | ||
| 2062 | if (!graphics_pipeline_) return skip(stats::pipeline); | ||
| 2063 | if (!graphics_.layout) return skip(stats::root_layout); | ||
| 2064 | if (!(viewport_.width > 0) || !(viewport_.height > 0)) return skip(stats::viewport); | ||
| 2065 | leonida::Draw draw{graphics_pipeline_, graphics_user_data(), draw_views(), depth_, {}, 0, viewport_, | ||
| 2066 | scissor_, blend_factor_, front_stencil_ref_, back_stencil_ref_, false, 0, 0, 0, 0, 0}; | ||
| 2067 | note_direct_heap_indexing(graphics_.layout); | ||
| 2068 | draw.mesh = true; | ||
| 2069 | draw.depth_bounds = depth_bounds_; | ||
| 2070 | request_draw_pipeline(); | ||
| 2071 | const bool recorded = list_.draw_indirect(std::move(draw), args); | ||
| 2072 | if (recorded) stats::note(stats::Event::recorded); | ||
| 2073 | return check(recorded); | ||
| 2074 | } | ||
| 1916 | if (kind == leonida::IndirectKind::draw || kind == leonida::IndirectKind::draw_indexed) { | 2075 | if (kind == leonida::IndirectKind::draw || kind == leonida::IndirectKind::draw_indexed) { |
| 1917 | if (type_ != D3D12_COMMAND_LIST_TYPE_DIRECT) return check(false); | 2076 | if (type_ != D3D12_COMMAND_LIST_TYPE_DIRECT) return check(false); |
| 1918 | // A valid zero-count call records nothing, even if graphics state has not been set. | 2077 | // A valid zero-count call records nothing, even if graphics state has not been set. |
| @@ -1931,11 +2090,11 @@ private: | |||
| 1931 | if (!terminal_only) return skip(stats::compound); | 2090 | if (!terminal_only) return skip(stats::compound); |
| 1932 | if (!graphics_pipeline_) return skip(stats::pipeline); | 2091 | if (!graphics_pipeline_) return skip(stats::pipeline); |
| 1933 | if (!graphics_.layout) return skip(stats::root_layout); | 2092 | if (!graphics_.layout) return skip(stats::root_layout); |
| 1934 | if (topology_ != D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST) return skip(stats::topology); | 2093 | if (!stats::topology_supported(topology_)) return skip(stats::topology); |
| 1935 | if (indexed && (!index_.va || !index_.size || | 2094 | if (indexed && (!index_.va || !index_.size || |
| 1936 | (index_.format != DXGI_FORMAT_R16_UINT && index_.format != DXGI_FORMAT_R32_UINT))) | 2095 | (index_.format != DXGI_FORMAT_R16_UINT && index_.format != DXGI_FORMAT_R32_UINT))) |
| 1937 | return skip(stats::index_view); | 2096 | return skip(stats::index_view); |
| 1938 | if (!(viewport_.width > 0) || !(viewport_.height > 0)) return skip(stats::viewport); | 2097 | if (!any_nonempty_viewport()) return skip(stats::viewport); |
| 1939 | note_direct_heap_indexing(graphics_.layout); | 2098 | note_direct_heap_indexing(graphics_.layout); |
| 1940 | record_raster_draw(indexed, 0, 0, 0, 0, 0, &args); | 2099 | record_raster_draw(indexed, 0, 0, 0, 0, 0, &args); |
| 1941 | return; | 2100 | return; |
| @@ -1963,8 +2122,12 @@ private: | |||
| 1963 | note_direct_heap_indexing(graphics_.layout); | 2122 | note_direct_heap_indexing(graphics_.layout); |
| 1964 | // No viewport (never set, or unbound with RSSetViewports(0)) or every bound viewport empty: D3D12 rasterizes | 2123 | // No viewport (never set, or unbound with RSSetViewports(0)) or every bound viewport empty: D3D12 rasterizes |
| 1965 | // nothing, and Vulkan forbids a 0x0 viewport, so the draw is not recorded. | 2124 | // nothing, and Vulkan forbids a 0x0 viewport, so the draw is not recorded. |
| 1966 | // LOCAL DIAGNOSTIC: the state each draw is recorded with | 2125 | static const bool draw_diag = [] { |
| 1967 | if (leonida::local_diagnostics()) { | 2126 | const char* value = std::getenv("LEONIDA_DRAW_DIAG"); |
| 2127 | if (value) return std::strcmp(value, "0") != 0; | ||
| 2128 | return leonida::local_diagnostics() || leonida::fsdraw::enabled(); | ||
| 2129 | }(); | ||
| 2130 | if (draw_diag) { | ||
| 1968 | static std::atomic<std::uint64_t> draws{0}, skipped{0}; | 2131 | static std::atomic<std::uint64_t> draws{0}, skipped{0}; |
| 1969 | const bool skip = !any_nonempty_viewport(); | 2132 | const bool skip = !any_nonempty_viewport(); |
| 1970 | const std::uint64_t n = ++draws, k = skip ? ++skipped : skipped.load(); | 2133 | const std::uint64_t n = ++draws, k = skip ? ++skipped : skipped.load(); |
| @@ -1978,16 +2141,18 @@ private: | |||
| 1978 | scissor_.left, scissor_.top, scissor_.right, scissor_.bottom, count, instances); | 2141 | scissor_.left, scissor_.top, scissor_.right, scissor_.bottom, count, instances); |
| 1979 | // LOCAL DIAGNOSTIC (fsdraw): the first draw of each pipeline, and one frame's draws every ~300 frames, | 2142 | // LOCAL DIAGNOSTIC (fsdraw): the first draw of each pipeline, and one frame's draws every ~300 frames, |
| 1980 | // with the pipeline's description, the root data and what the bound descriptor tables hold. | 2143 | // with the pipeline's description, the root data and what the bound descriptor tables hold. |
| 2144 | // Only with LEONIDA_FSDRAW_PROBE=1. | ||
| 1981 | static std::mutex seen_mutex; | 2145 | static std::mutex seen_mutex; |
| 1982 | static std::set<std::uintptr_t> seen; | 2146 | static std::set<std::uintptr_t> seen; |
| 1983 | bool first_seen; | 2147 | const bool fsdraw = leonida::fsdraw::enabled(); |
| 1984 | { | 2148 | bool first_seen = false; |
| 2149 | if (fsdraw) { | ||
| 1985 | std::lock_guard lock(seen_mutex); | 2150 | std::lock_guard lock(seen_mutex); |
| 1986 | first_seen = seen.insert(graphics_pipeline_).second; | 2151 | first_seen = seen.insert(graphics_pipeline_).second; |
| 1987 | } | 2152 | } |
| 1988 | const bool fullscreen = render_target_count_ >= 1 && count == 3 && viewport_.width >= 1000; | 2153 | const bool fullscreen = render_target_count_ >= 1 && count == 3 && viewport_.width >= 1000; |
| 1989 | if (fullscreen) leonida::fsdraw::note_target(render_targets_[0].resource); | 2154 | if (fullscreen) leonida::fsdraw::note_target(render_targets_[0].resource); |
| 1990 | if (first_seen || (n - 1) % 600 < 2 || (n > 2 && n < 9)) { | 2155 | if (fsdraw && (first_seen || (n - 1) % 600 < 2 || (n > 2 && n < 9))) { |
| 1991 | std::fprintf(stderr, "[rt] fsdraw: draw #%llu pso %p%s rt0 0x%llx rts %u depth 0x%llx count %u x%u: %s\n", | 2156 | std::fprintf(stderr, "[rt] fsdraw: draw #%llu pso %p%s rt0 0x%llx rts %u depth 0x%llx count %u x%u: %s\n", |
| 1992 | static_cast<unsigned long long>(n), reinterpret_cast<const void*>(graphics_pipeline_), | 2157 | static_cast<unsigned long long>(n), reinterpret_cast<const void*>(graphics_pipeline_), |
| 1993 | first_seen ? " (first use)" : "", static_cast<unsigned long long>(render_targets_[0].resource), | 2158 | first_seen ? " (first use)" : "", static_cast<unsigned long long>(render_targets_[0].resource), |
| @@ -2055,6 +2220,8 @@ private: | |||
| 2055 | scissor_, blend_factor_, front_stencil_ref_, back_stencil_ref_, indexed, count, instances, | 2220 | scissor_, blend_factor_, front_stencil_ref_, back_stencil_ref_, indexed, count, instances, |
| 2056 | first, base_vertex, first_instance}; | 2221 | first, base_vertex, first_instance}; |
| 2057 | draw.viewports = draw_viewports(); | 2222 | draw.viewports = draw_viewports(); |
| 2223 | draw.depth_bounds = depth_bounds_; | ||
| 2224 | request_draw_pipeline(); | ||
| 2058 | const bool recorded = indirect ? list_.draw_indirect(std::move(draw), *indirect) : list_.draw(std::move(draw)); | 2225 | const bool recorded = indirect ? list_.draw_indirect(std::move(draw), *indirect) : list_.draw(std::move(draw)); |
| 2059 | if (indirect && recorded) leonida::indirect_stats::note(leonida::indirect_stats::Event::recorded); | 2226 | if (indirect && recorded) leonida::indirect_stats::note(leonida::indirect_stats::Event::recorded); |
| 2060 | check(recorded); | 2227 | check(recorded); |
| @@ -2137,6 +2304,11 @@ public: | |||
| 2137 | return S_OK; | 2304 | return S_OK; |
| 2138 | } | 2305 | } |
| 2139 | 2306 | ||
| 2307 | // `fn` on the dispatcher's thread once the fence reaches `value` (rt::d3d12::fence_callback_at). | ||
| 2308 | void callback_at(UINT64 value, std::function<void()> fn) { | ||
| 2309 | context_.enqueue_fence_callback(fence_.semaphore(), value, std::move(fn)); | ||
| 2310 | } | ||
| 2311 | |||
| 2140 | // Counts `waiter` down once this fence reaches `value`: now if it has, else via the centralized dispatcher. | 2312 | // Counts `waiter` down once this fence reaches `value`: now if it has, else via the centralized dispatcher. |
| 2141 | void notify(UINT64 value, std::shared_ptr<FenceWaiter> waiter) { | 2313 | void notify(UINT64 value, std::shared_ptr<FenceWaiter> waiter) { |
| 2142 | if (context_.is_device_lost() || fence_.completed() >= value) { | 2314 | if (context_.is_device_lost() || fence_.completed() >= value) { |
| @@ -2178,7 +2350,8 @@ public: | |||
| 2178 | 2350 | ||
| 2179 | // What a held batch (queue_holds.h) keeps alive until it has run: the pipeline states and root signatures its | 2351 | // What a held batch (queue_holds.h) keeps alive until it has run: the pipeline states and root signatures its |
| 2180 | // lists name, which the application may release and Reset away as soon as ExecuteCommandLists returns. Resources | 2352 | // lists name, which the application may release and Reset away as soon as ExecuteCommandLists returns. Resources |
| 2181 | // are not held (a D3D12 application keeps them until the fence it signals; the docs, section 4.4, list this). | 2353 | // are not held (a D3D12 application keeps them until the fence it signals; the docs, section 4.4, list this), |
| 2354 | // except a shim's own the recording uses (hold_until_reset), which are pinned with them. | ||
| 2182 | static std::shared_ptr<void> pin_lists(const std::vector<const GraphicsCommandList*>& lists) { | 2355 | static std::shared_ptr<void> pin_lists(const std::vector<const GraphicsCommandList*>& lists) { |
| 2183 | auto objects = std::shared_ptr<std::vector<IUnknown*>>(new std::vector<IUnknown*>, [](auto* held) { | 2356 | auto objects = std::shared_ptr<std::vector<IUnknown*>>(new std::vector<IUnknown*>, [](auto* held) { |
| 2184 | for (IUnknown* object : *held) object->Release(); | 2357 | for (IUnknown* object : *held) object->Release(); |
| @@ -2309,7 +2482,7 @@ public: | |||
| 2309 | // LOCAL DIAGNOSTIC (fsdraw): what the bound tables hold when the lists are submitted | 2482 | // LOCAL DIAGNOSTIC (fsdraw): what the bound tables hold when the lists are submitted |
| 2310 | if (leonida::local_diagnostics()) { | 2483 | if (leonida::local_diagnostics()) { |
| 2311 | static std::atomic<std::uint64_t> submits{0}; | 2484 | static std::atomic<std::uint64_t> submits{0}; |
| 2312 | const std::uint64_t n = tables.empty() ? 0 : ++submits; | 2485 | const std::uint64_t n = tables.empty() || !leonida::fsdraw::enabled() ? 0 : ++submits; |
| 2313 | if (n && (n <= 6 || n % 300 == 0)) { | 2486 | if (n && (n <= 6 || n % 300 == 0)) { |
| 2314 | char tag[48]; | 2487 | char tag[48]; |
| 2315 | std::snprintf(tag, sizeof tag, "submit #%llu", static_cast<unsigned long long>(n)); | 2488 | std::snprintf(tag, sizeof tag, "submit #%llu", static_cast<unsigned long long>(n)); |
| @@ -2367,6 +2540,10 @@ public: | |||
| 2367 | if (last_result_ != leonida::ReplayResult::success) | 2540 | if (last_result_ != leonida::ReplayResult::success) |
| 2368 | std::fprintf(stderr, "[rt] d3d12: ExecuteCommandLists failed: %s; nothing was submitted\n", | 2541 | std::fprintf(stderr, "[rt] d3d12: ExecuteCommandLists failed: %s; nothing was submitted\n", |
| 2369 | name(last_result_)); | 2542 | name(last_result_)); |
| 2543 | // A batch or Signal that failed after its call returned (held, or on the queue's worker with | ||
| 2544 | // LEONIDA_SUBMIT_ASYNC; reported on stderr there) is this call's result, one call late. | ||
| 2545 | if (last_result_ == leonida::ReplayResult::success) | ||
| 2546 | if (const auto held = queue_.take_held_failure(); held != leonida::ReplayResult::success) last_result_ = held; | ||
| 2370 | } | 2547 | } |
| 2371 | 2548 | ||
| 2372 | // A copy list's timestamps go to COPY_QUEUE_TIMESTAMP heaps and every other list's to TIMESTAMP heaps. | 2549 | // A copy list's timestamps go to COPY_QUEUE_TIMESTAMP heaps and every other list's to TIMESTAMP heaps. |
| @@ -2793,6 +2970,13 @@ bool command_signature_info(ID3D12CommandSignature* signature, leonida::Indirect | |||
| 2793 | return true; | 2970 | return true; |
| 2794 | } | 2971 | } |
| 2795 | 2972 | ||
| 2973 | bool fence_callback_at(ID3D12Fence* fence, std::uint64_t value, std::function<void()> fn) { | ||
| 2974 | Fence* f = Fence::from(fence); | ||
| 2975 | if (!f) return false; | ||
| 2976 | f->callback_at(value, std::move(fn)); | ||
| 2977 | return true; | ||
| 2978 | } | ||
| 2979 | |||
| 2796 | leonida::ReplayResult last_execute_result(ID3D12CommandQueue* queue) { | 2980 | leonida::ReplayResult last_execute_result(ID3D12CommandQueue* queue) { |
| 2797 | if (ID3D12CommandQueue* real = d3d12_xs::queue_proxy_real_queue(queue)) queue = real; // the Xbox-ABI proxy | 2981 | if (ID3D12CommandQueue* real = d3d12_xs::queue_proxy_real_queue(queue)) queue = real; // the Xbox-ABI proxy |
| 2798 | CommandQueue* q = CommandQueue::from(queue); | 2982 | CommandQueue* q = CommandQueue::from(queue); |
| @@ -2807,6 +2991,13 @@ bool front_back_stencil_ref(ID3D12GraphicsCommandList8* list, UINT& front, UINT& | |||
| 2807 | return true; | 2991 | return true; |
| 2808 | } | 2992 | } |
| 2809 | 2993 | ||
| 2994 | bool hold_until_reset(ID3D12GraphicsCommandList* list, IUnknown* object) { | ||
| 2995 | GraphicsCommandList* l = GraphicsCommandList::from(list); | ||
| 2996 | if (!l || !object) return false; | ||
| 2997 | l->hold_for_recording(object); | ||
| 2998 | return true; | ||
| 2999 | } | ||
| 3000 | |||
| 2810 | bool recorded_commands(ID3D12GraphicsCommandList* list, std::vector<leonida::Command>& commands) { | 3001 | bool recorded_commands(ID3D12GraphicsCommandList* list, std::vector<leonida::Command>& commands) { |
| 2811 | const GraphicsCommandList* l = GraphicsCommandList::from(list); | 3002 | const GraphicsCommandList* l = GraphicsCommandList::from(list); |
| 2812 | if (!l) return false; | 3003 | if (!l) return false; |