upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/shims/d3d12_com.cpp
diff options
context:
space:
mode:
authoraslan2142 <jan.trencansky@protonmail.com>2026-11-25 04:26:54 +0100
committerGitHub <noreply@github.com>2026-11-25 04:26:54 +0100
commitbfef489cb6307fa4e1dc6ed2c40bfc0ce120d066 (patch)
tree19e2f01d50809de00ecba664b4044eed1aad2c36 /runtime/shims/d3d12_com.cpp
parent98efc22ca3d2841b985eb36d4afbe7d434628670 (diff)
parent3ee0037fd3accba459d0d5ecd8acad831174d4d7 (diff)
Merge pull request #1232 from iFeyz/feat/direct-heap-graphics
d3d12: graphics draws supply the directly indexed heaps after their root arguments (RT-DIRECT-HEAP-GRAPHICS)
Diffstat (limited to 'runtime/shims/d3d12_com.cpp')
-rw-r--r--runtime/shims/d3d12_com.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/runtime/shims/d3d12_com.cpp b/runtime/shims/d3d12_com.cpp
index de448ddc4..883cce32a 100644
--- a/runtime/shims/d3d12_com.cpp
+++ b/runtime/shims/d3d12_com.cpp
@@ -534,6 +534,21 @@ public:
534 stub("DispatchMesh(root signature larger than a mesh shader's root window)"); 534 stub("DispatchMesh(root signature larger than a mesh shader's root window)");
535 return check(false); 535 return check(false);
536 } 536 }
537 // The directly indexed heaps follow the arguments (graphics_user_data). The window shows a mesh shader push
538 // dwords 8..23 only (s16..s31), so a signature that fills it leaves a heap where the mesh stage cannot read.
539 {
540 constexpr std::uint32_t window_end = rt::rootsig::stage_base(rt::rootsig::Stage::Pixel) +
541 rt::rootsig::kMaxUserSgprs -
542 rt::rootsig::stage_base(rt::rootsig::Stage::Mesh);
543 const auto flags = graphics_.layout->flags;
544 const bool resource = flags & D3D12_ROOT_SIGNATURE_FLAG_CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED;
545 const bool sampler = flags & D3D12_ROOT_SIGNATURE_FLAG_SAMPLER_HEAP_DIRECTLY_INDEXED;
546 const std::uint32_t end = graphics_.layout->graphics_arguments_end;
547 if (resource && end >= window_end)
548 note_once("mesh direct heaps: no SGPR left in the mesh window (s16..s31) for the resource heap");
549 if (sampler && end + (resource ? 1u : 0u) >= window_end)
550 note_once("mesh direct heaps: no SGPR left in the mesh window (s16..s31) for the sampler heap");
551 }
537 if (!any_nonempty_viewport()) return; // as record_draw: nothing is rasterized 552 if (!any_nonempty_viewport()) return; // as record_draw: nothing is rasterized
538 leonida::Draw draw{graphics_pipeline_, graphics_user_data(), draw_views(), depth_, {}, 0, viewport_, 553 leonida::Draw draw{graphics_pipeline_, graphics_user_data(), draw_views(), depth_, {}, 0, viewport_,
539 scissor_, blend_factor_, front_stencil_ref_, back_stencil_ref_, false, x, y, z, 0, 0}; 554 scissor_, blend_factor_, front_stencil_ref_, back_stencil_ref_, false, x, y, z, 0, 0};
@@ -1703,9 +1718,10 @@ private:
1703 1718
1704 // Graphics: vertex, pixel and geometry shaders share one user-data block and the s8 layout, so the heaps after 1719 // Graphics: vertex, pixel and geometry shaders share one user-data block and the s8 layout, so the heaps after
1705 // the explicit arguments serve every one of those stages (a pixel shader of a signature whose arguments end at 1720 // the explicit arguments serve every one of those stages (a pixel shader of a signature whose arguments end at
1706 // s11 reads the resource heap from s11). A mesh shader reads its arguments from s16, which is not modelled 1721 // s11 reads the resource heap from s11). A mesh shader reads push dword d as s(d + 8) through its root window
1707 // (RootArgumentLayout, D3D-448): its pixel shader gets the heaps, the mesh stage does not. 1722 // (RootArgumentLayout::mesh_ok), so the same dwords give it the heaps after its arguments from s16, where the
1708 // LEONIDA_GRAPHICS_DIRECT_HEAPS=0 restores the previous arguments. 1723 // console puts them (issue #14 comment 7143020922, RT-DIRECT-HEAP-GRAPHICS); DispatchMesh reports a heap that
1724 // falls past the window. LEONIDA_GRAPHICS_DIRECT_HEAPS=0 restores the previous arguments.
1709 std::array<std::uint32_t, rt::rootsig::kMaxUserSgprs> graphics_user_data() const { 1725 std::array<std::uint32_t, rt::rootsig::kMaxUserSgprs> graphics_user_data() const {
1710 constexpr UINT direct = D3D12_ROOT_SIGNATURE_FLAG_CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED | 1726 constexpr UINT direct = D3D12_ROOT_SIGNATURE_FLAG_CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED |
1711 D3D12_ROOT_SIGNATURE_FLAG_SAMPLER_HEAP_DIRECTLY_INDEXED; 1727 D3D12_ROOT_SIGNATURE_FLAG_SAMPLER_HEAP_DIRECTLY_INDEXED;