diff options
| author | Jan Trencansky <jan.trencansky@protonmail.com> | 2026-11-25 14:37:34 -0500 |
|---|---|---|
| committer | Jan Trencansky <jan.trencansky@protonmail.com> | 2026-11-25 14:37:34 -0500 |
| commit | ef205eec98801521ac19792432f4bc2d0ed26503 (patch) | |
| tree | a3606f4eab910a3b972cfa3aa0e419e27e0d6b43 /runtime/shims/d3d12_com.cpp | |
| parent | 65235f36add54df162eef5cca1a30d24a21adc78 (diff) | |
xbox_bvh_builder: review fixes for batched rehydration (RT-XDXR-BVH-REHYDRATE-BATCHED2X)
Maintainer fixes on top of the author's rehydration, carried over from the
reviewed branch onto the rewritten head:
- Scratch: each element of a batch gets a region of its own in one buffer
per call, at D3D12's acceleration-structure alignment, and the command list
holds that buffer until its next Reset (rt::d3d12::hold_until_reset). Before,
every element and every list shared one builder-wide buffer with no barrier
between the builds, and growing it released a buffer that builds already
recorded could still use.
- Fresh builds: a rehydrate always builds from geometry. PERFORM_UPDATE is
cleared together with SourceAccelerationStructureData, so the layer never
refits from the dehydrated stream's bytes.
- The leaf frame compressionParams gives is described as not applied yet,
which is what the code does.
- The test reads back rehydrated builds made without scratch
(ScratchAccelerationStructureData = 0), the shape the title uses.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'runtime/shims/d3d12_com.cpp')
| -rw-r--r-- | runtime/shims/d3d12_com.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/runtime/shims/d3d12_com.cpp b/runtime/shims/d3d12_com.cpp index 6dee464a8..62b70d921 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()) { |
| @@ -2178,7 +2181,8 @@ public: | |||
| 2178 | 2181 | ||
| 2179 | // What a held batch (queue_holds.h) keeps alive until it has run: the pipeline states and root signatures its | 2182 | // 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 | 2183 | // 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). | 2184 | // are not held (a D3D12 application keeps them until the fence it signals; the docs, section 4.4, list this), |
| 2185 | // 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) { | 2186 | 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) { | 2187 | auto objects = std::shared_ptr<std::vector<IUnknown*>>(new std::vector<IUnknown*>, [](auto* held) { |
| 2184 | for (IUnknown* object : *held) object->Release(); | 2188 | for (IUnknown* object : *held) object->Release(); |
| @@ -2807,6 +2811,13 @@ bool front_back_stencil_ref(ID3D12GraphicsCommandList8* list, UINT& front, UINT& | |||
| 2807 | return true; | 2811 | return true; |
| 2808 | } | 2812 | } |
| 2809 | 2813 | ||
| 2814 | bool hold_until_reset(ID3D12GraphicsCommandList* list, IUnknown* object) { | ||
| 2815 | GraphicsCommandList* l = GraphicsCommandList::from(list); | ||
| 2816 | if (!l || !object) return false; | ||
| 2817 | l->hold_for_recording(object); | ||
| 2818 | return true; | ||
| 2819 | } | ||
| 2820 | |||
| 2810 | bool recorded_commands(ID3D12GraphicsCommandList* list, std::vector<leonida::Command>& commands) { | 2821 | bool recorded_commands(ID3D12GraphicsCommandList* list, std::vector<leonida::Command>& commands) { |
| 2811 | const GraphicsCommandList* l = GraphicsCommandList::from(list); | 2822 | const GraphicsCommandList* l = GraphicsCommandList::from(list); |
| 2812 | if (!l) return false; | 2823 | if (!l) return false; |