diff options
| author | TheGeogeo <57634077+TheGeogeo@users.noreply.github.com> | 2026-11-25 02:56:13 +0100 |
|---|---|---|
| committer | TheGeogeo <57634077+TheGeogeo@users.noreply.github.com> | 2026-11-25 04:46:33 +0100 |
| commit | 3e1c49e1bd0ab725c00400a52326fdd80add4840 (patch) | |
| tree | 6c939858a57457492a5b79a5613bf2f5c382a1e8 /runtime/src | |
| parent | a3980cd437b28a047f8e0da3a698df32a34ecbc0 (diff) | |
d3d12: compile a submission's pipelines on worker threads (RT-PIPELINE-COMPILE-WORKERS)
prepare() leaves the pipelines that are not built yet to PipelineCompiles, once per pipeline and variant. VulkanQueue::execute_now compiles them together on the device's workers with the resource lock held, places them in the prepared commands and then writes the command buffer, so every draw and dispatch has its own pipeline. A refused compile gives the result prepare() alone would have given. LEONIDA_PIPELINE_THREADS=0 keeps the path of before. Graphics pipelines of 1 MiB of SPIR-V or more and compute pipelines over 128 KiB compile one after another, and LEONIDA_ASYNC_PIPELINES keeps its own worker.
Diffstat (limited to 'runtime/src')
| -rw-r--r-- | runtime/src/vulkan_backend.h | 30 | ||||
| -rw-r--r-- | runtime/src/vulkan_replay.h | 148 |
2 files changed, 165 insertions, 13 deletions
diff --git a/runtime/src/vulkan_backend.h b/runtime/src/vulkan_backend.h index 5c3e884ba..9946331f9 100644 --- a/runtime/src/vulkan_backend.h +++ b/runtime/src/vulkan_backend.h | |||
| @@ -14,6 +14,7 @@ | |||
| 14 | #include "buffer_va_index.h" | 14 | #include "buffer_va_index.h" |
| 15 | #include "image_memory.h" | 15 | #include "image_memory.h" |
| 16 | #include "occlusion_sum_spirv.h" | 16 | #include "occlusion_sum_spirv.h" |
| 17 | #include "pipeline_workers.h" | ||
| 17 | #include "queue_holds.h" | 18 | #include "queue_holds.h" |
| 18 | #include "retire_tickets.h" | 19 | #include "retire_tickets.h" |
| 19 | #include "statistics_sum_spirv.h" | 20 | #include "statistics_sum_spirv.h" |
| @@ -1428,6 +1429,17 @@ public: | |||
| 1428 | graphics_pipelines_[id] = pipeline; | 1429 | graphics_pipelines_[id] = pipeline; |
| 1429 | if (shaders && device_fault_) device_fault_->pipeline_names[id] = *shaders; | 1430 | if (shaders && device_fault_) device_fault_->pipeline_names[id] = *shaders; |
| 1430 | } | 1431 | } |
| 1432 | // Workers for the pipelines a submission needs and that are not built yet. Null (the default): each is built where | ||
| 1433 | // prepare() meets it, on the submitting thread. Replacing it waits for submissions that are compiling, and ends the | ||
| 1434 | // workers it had. | ||
| 1435 | void set_pipeline_workers(std::unique_ptr<PipelineWorkers> workers) { | ||
| 1436 | std::unique_lock lock(resource_mutex_); | ||
| 1437 | pipeline_workers_.swap(workers); | ||
| 1438 | } | ||
| 1439 | PipelineWorkers::Stats pipeline_worker_stats() { | ||
| 1440 | std::shared_lock lock(resource_mutex_); | ||
| 1441 | return pipeline_workers_ ? pipeline_workers_->stats() : PipelineWorkers::Stats{}; | ||
| 1442 | } | ||
| 1431 | // Configure before queue creation, when the selected queue family supports compute. | 1443 | // Configure before queue creation, when the selected queue family supports compute. |
| 1432 | void set_occlusion_resolve_memory(const VkPhysicalDeviceMemoryProperties& memory) { | 1444 | void set_occlusion_resolve_memory(const VkPhysicalDeviceMemoryProperties& memory) { |
| 1433 | occlusion_resolve_memory_ = memory; | 1445 | occlusion_resolve_memory_ = memory; |
| @@ -2003,6 +2015,7 @@ private: | |||
| 2003 | std::unordered_map<ResourceId, std::shared_ptr<SparseResource>> sparse_resources_; | 2015 | std::unordered_map<ResourceId, std::shared_ptr<SparseResource>> sparse_resources_; |
| 2004 | std::unordered_map<std::uintptr_t, ComputePipeline> pipelines_; | 2016 | std::unordered_map<std::uintptr_t, ComputePipeline> pipelines_; |
| 2005 | std::unordered_map<std::uintptr_t, GraphicsPipeline> graphics_pipelines_; | 2017 | std::unordered_map<std::uintptr_t, GraphicsPipeline> graphics_pipelines_; |
| 2018 | std::unique_ptr<PipelineWorkers> pipeline_workers_; | ||
| 2006 | std::unordered_map<std::uint64_t, VkAccelerationStructureKHR> acceleration_structures_; | 2019 | std::unordered_map<std::uint64_t, VkAccelerationStructureKHR> acceleration_structures_; |
| 2007 | LayoutTracker tracker_; | 2020 | LayoutTracker tracker_; |
| 2008 | std::mutex storage_mutex_; // a leaf lock: guards storage_pending_ and zero_pending_ only | 2021 | std::mutex storage_mutex_; // a leaf lock: guards storage_pending_ and zero_pending_ only |
| @@ -2803,9 +2816,18 @@ private: | |||
| 2803 | const auto resolve = [this](ResourceId id) { return context_.resolve(id); }; | 2816 | const auto resolve = [this](ResourceId id) { return context_.resolve(id); }; |
| 2804 | std::uint32_t segments = 0, statistics_segments = 0; | 2817 | std::uint32_t segments = 0, statistics_segments = 0; |
| 2805 | bool has_queries = false; | 2818 | bool has_queries = false; |
| 2819 | // With workers, the pipelines the lists need and that are not built yet are compiled together below instead of | ||
| 2820 | // one after another in prepare(). resource_lock is held until they are all built, which keeps the pipeline | ||
| 2821 | // states that own them alive (remove_pipeline takes it uniquely). | ||
| 2822 | PipelineCompiles compiles; | ||
| 2823 | if (context_.pipeline_workers_) replay.compiles = &compiles; | ||
| 2824 | ReplayResult prepare_result = ReplayResult::success; | ||
| 2806 | for (std::size_t i = 0; i < lists.size(); ++i) { | 2825 | for (std::size_t i = 0; i < lists.size(); ++i) { |
| 2807 | const auto result = prepare(*lists[i], resolve, replay, prepared[i], can_resolve_occlusion); | 2826 | const auto result = prepare(*lists[i], resolve, replay, prepared[i], can_resolve_occlusion); |
| 2808 | if (result != ReplayResult::success) return result; | 2827 | if (result != ReplayResult::success) { |
| 2828 | prepare_result = result; | ||
| 2829 | break; | ||
| 2830 | } | ||
| 2809 | if (prepared[i].segment_count > UINT32_MAX - segments || | 2831 | if (prepared[i].segment_count > UINT32_MAX - segments || |
| 2810 | prepared[i].statistics_segment_count > UINT32_MAX - statistics_segments) | 2832 | prepared[i].statistics_segment_count > UINT32_MAX - statistics_segments) |
| 2811 | return queue_unsupported(__LINE__); | 2833 | return queue_unsupported(__LINE__); |
| @@ -2813,6 +2835,12 @@ private: | |||
| 2813 | statistics_segments += prepared[i].statistics_segment_count; | 2835 | statistics_segments += prepared[i].statistics_segment_count; |
| 2814 | has_queries = has_queries || !prepared[i].queries.empty(); | 2836 | has_queries = has_queries || !prepared[i].queries.empty(); |
| 2815 | } | 2837 | } |
| 2838 | prepare_result = build_pipelines( | ||
| 2839 | compiles, std::span(prepared).first(lists.size()), prepare_result, | ||
| 2840 | [this](std::size_t count, const std::function<void(std::size_t)>& job) { | ||
| 2841 | context_.pipeline_workers_->run(count, job); | ||
| 2842 | }); | ||
| 2843 | if (prepare_result != ReplayResult::success) return prepare_result; | ||
| 2816 | const auto segment_pool = [this](VkQueryType type, std::uint32_t count, | 2844 | const auto segment_pool = [this](VkQueryType type, std::uint32_t count, |
| 2817 | std::shared_ptr<OcclusionSegmentPool>& out) { | 2845 | std::shared_ptr<OcclusionSegmentPool>& out) { |
| 2818 | const auto& vk = context_.vk; | 2846 | const auto& vk = context_.vk; |
diff --git a/runtime/src/vulkan_replay.h b/runtime/src/vulkan_replay.h index 2fef87194..6d1d60f03 100644 --- a/runtime/src/vulkan_replay.h +++ b/runtime/src/vulkan_replay.h | |||
| @@ -803,6 +803,10 @@ struct ComputePipeline { | |||
| 803 | VkPipeline (*build)(void*) = nullptr; | 803 | VkPipeline (*build)(void*) = nullptr; |
| 804 | void* build_context = nullptr; | 804 | void* build_context = nullptr; |
| 805 | bool async_build = false; // a null handle may be waiting for the compile worker | 805 | bool async_build = false; // a null handle may be waiting for the compile worker |
| 806 | // What `build` would return when it is built already and nobody is building it, else null; builds nothing. Null: a | ||
| 807 | // first use is always built where prepare() meets it. Not used with async_build. See PipelineCompiles. | ||
| 808 | VkPipeline (*built)(void*) = nullptr; | ||
| 809 | bool large = false; // compiled one after another with the other large ones (PipelineCompiles) | ||
| 806 | bool skipped = false; // never built on request (LEONIDA_SKIP_COMPUTE): its dispatches are dropped | 810 | bool skipped = false; // never built on request (LEONIDA_SKIP_COMPUTE): its dispatches are dropped |
| 807 | }; | 811 | }; |
| 808 | 812 | ||
| @@ -830,6 +834,10 @@ struct GraphicsPipeline { | |||
| 830 | // IA topology requiring a fourth-corner geometry stage. Zero when the PSO already contains the stage. | 834 | // IA topology requiring a fourth-corner geometry stage. Zero when the PSO already contains the stage. |
| 831 | std::uint32_t rectangle_variant_topology = 0; | 835 | std::uint32_t rectangle_variant_topology = 0; |
| 832 | std::function<VkPipeline(std::uint32_t flags)> variant; | 836 | std::function<VkPipeline(std::uint32_t flags)> variant; |
| 837 | // What `variant` would return when it is built already and nobody is building one, else null; builds nothing. See | ||
| 838 | // ComputePipeline::built. | ||
| 839 | std::function<VkPipeline(std::uint32_t flags)> built; | ||
| 840 | bool large = false; // as ComputePipeline::large | ||
| 833 | std::uint32_t samples = 1; // rasterizationSamples; every bound attachment must have this count | 841 | std::uint32_t samples = 1; // rasterizationSamples; every bound attachment must have this count |
| 834 | bool async_build = false; | 842 | bool async_build = false; |
| 835 | }; | 843 | }; |
| @@ -915,7 +923,75 @@ inline ReplayResult unsupported_at(int line) { | |||
| 915 | } | 923 | } |
| 916 | 924 | ||
| 917 | 925 | ||
| 926 | // The pipelines of a submission that are not built yet. prepare() adds each of them once and goes on; build_pipelines() | ||
| 927 | // then compiles them all and puts them where prepare() left them out. Holds pointers to registered pipelines: valid | ||
| 928 | // while the context's resource lock is held. | ||
| 929 | class PipelineCompiles { | ||
| 930 | public: | ||
| 931 | // Where a prepared command finds its pipeline: an index for `built`, plus one; 0 when it needs none. | ||
| 932 | using Ticket = std::uint32_t; | ||
| 933 | // Which command needs a pipeline: it decides what a pipeline that cannot be built means (build_pipelines). | ||
| 934 | enum class User : std::uint8_t { draw, dispatch, indirect_dispatch }; | ||
| 935 | struct Use { | ||
| 936 | Ticket ticket; | ||
| 937 | User user; | ||
| 938 | }; | ||
| 939 | // A compile takes the driver some hundred bytes of memory for each byte of SPIR-V (docs/pipeline_check.md): graphics | ||
| 940 | // pipelines of this much or more are `large`. | ||
| 941 | static constexpr std::uint64_t large_spirv_bytes = 1u << 20; | ||
| 942 | |||
| 943 | Ticket add(const GraphicsPipeline& pipeline, std::uint32_t flags) { | ||
| 944 | return add({&pipeline, nullptr, flags}, User::draw); | ||
| 945 | } | ||
| 946 | Ticket add(const ComputePipeline& pipeline, User user) { return add({nullptr, &pipeline, 0}, user); } | ||
| 947 | |||
| 948 | bool empty() const { return jobs_.empty(); } | ||
| 949 | std::size_t size() const { return jobs_.size(); } | ||
| 950 | VkPipeline built(Ticket ticket) const { return jobs_[ticket - 1].built; } | ||
| 951 | const std::vector<Use>& uses() const { return uses_; } // in the order of the commands | ||
| 952 | |||
| 953 | // Compiles all of them through run(count, job) (PipelineWorkers::run): the large ones one after another, as without | ||
| 954 | // workers, beside the others. | ||
| 955 | template<typename Run> | ||
| 956 | void build(Run&& run) { | ||
| 957 | std::vector<std::size_t> single, large; | ||
| 958 | for (std::size_t i = 0; i < jobs_.size(); ++i) (is_large(jobs_[i]) ? large : single).push_back(i); | ||
| 959 | const auto compile = [this](std::size_t i) { | ||
| 960 | Job& job = jobs_[i]; | ||
| 961 | job.built = job.graphics ? job.graphics->variant(job.flags) : job.compute->build(job.compute->build_context); | ||
| 962 | }; | ||
| 963 | const std::size_t chain = large.empty() ? 0 : 1; // the large ones are one unit, the first | ||
| 964 | run(chain + single.size(), [&](std::size_t i) { | ||
| 965 | if (i >= chain) | ||
| 966 | compile(single[i - chain]); | ||
| 967 | else | ||
| 968 | for (const std::size_t each : large) compile(each); | ||
| 969 | }); | ||
| 970 | } | ||
| 971 | |||
| 972 | private: | ||
| 973 | struct Job { | ||
| 974 | const GraphicsPipeline* graphics; // one of the two | ||
| 975 | const ComputePipeline* compute; | ||
| 976 | std::uint32_t flags; | ||
| 977 | VkPipeline built = VK_NULL_HANDLE; | ||
| 978 | }; | ||
| 979 | static bool is_large(const Job& job) { return job.graphics ? job.graphics->large : job.compute->large; } | ||
| 980 | Ticket add(const Job& job, User user) { | ||
| 981 | const void* const pipeline = job.graphics ? static_cast<const void*>(job.graphics) : job.compute; | ||
| 982 | const auto [it, added] = tickets_.try_emplace({pipeline, job.flags}, Ticket(jobs_.size() + 1)); | ||
| 983 | if (added) jobs_.push_back(job); | ||
| 984 | uses_.push_back({it->second, user}); | ||
| 985 | return it->second; | ||
| 986 | } | ||
| 987 | std::vector<Job> jobs_; | ||
| 988 | std::vector<Use> uses_; | ||
| 989 | std::map<std::pair<const void*, std::uint32_t>, Ticket> tickets_; | ||
| 990 | }; | ||
| 991 | |||
| 918 | struct ReplayFunctions { | 992 | struct ReplayFunctions { |
| 993 | // Set: prepare() leaves pipelines that are not built to it instead of building each on the spot. | ||
| 994 | PipelineCompiles* compiles = nullptr; | ||
| 919 | std::function<void(VkCommandBuffer, const label::Write&)> gpu_label; | 995 | std::function<void(VkCommandBuffer, const label::Write&)> gpu_label; |
| 920 | // Set 0 for the pipelines that declare one (their own `bindless_set` is only the marker): the device's current | 996 | // Set 0 for the pipelines that declare one (their own `bindless_set` is only the marker): the device's current |
| 921 | // generation of it, which a flush may have replaced since the pipeline was made. Null: the pipeline's. | 997 | // generation of it, which a flush may have replaced since the pipeline was made. Null: the pipeline's. |
| @@ -1179,6 +1255,7 @@ struct Prepared { | |||
| 1179 | VkDeviceSize fill_scratch_offset = 0; | 1255 | VkDeviceSize fill_scratch_offset = 0; |
| 1180 | QueryPool* queries = nullptr; // query commands: the heap | 1256 | QueryPool* queries = nullptr; // query commands: the heap |
| 1181 | ComputePipeline pipeline; // dispatches | 1257 | ComputePipeline pipeline; // dispatches |
| 1258 | PipelineCompiles::Ticket compile = 0; // dispatches: where the pipeline comes from when it was not built yet | ||
| 1182 | std::uint32_t draw = 0; // draws: its PreparedDraw in PreparedList::draws | 1259 | std::uint32_t draw = 0; // draws: its PreparedDraw in PreparedList::draws |
| 1183 | std::uint32_t depth_uav_copy = UINT32_MAX; | 1260 | std::uint32_t depth_uav_copy = UINT32_MAX; |
| 1184 | bool order_depth_uav = false; | 1261 | bool order_depth_uav = false; |
| @@ -1224,6 +1301,7 @@ struct PreparedDraw { | |||
| 1224 | // lock across both), so it is not copied. | 1301 | // lock across both), so it is not copied. |
| 1225 | const GraphicsPipeline* graphics = nullptr; | 1302 | const GraphicsPipeline* graphics = nullptr; |
| 1226 | VkPipeline pipeline = VK_NULL_HANDLE; // graphics->pipeline, or its variant for the slots the draw leaves unbound | 1303 | VkPipeline pipeline = VK_NULL_HANDLE; // graphics->pipeline, or its variant for the slots the draw leaves unbound |
| 1304 | PipelineCompiles::Ticket compile = 0; // where `pipeline` comes from when it was not built yet | ||
| 1227 | std::vector<Attachment> colors; // by slot; id 0 = unbound | 1305 | std::vector<Attachment> colors; // by slot; id 0 = unbound |
| 1228 | Attachment depth; | 1306 | Attachment depth; |
| 1229 | std::vector<VkBuffer> vertex_buffers; | 1307 | std::vector<VkBuffer> vertex_buffers; |
| @@ -1244,6 +1322,7 @@ struct PreparedDraw { | |||
| 1244 | skipped = false; | 1322 | skipped = false; |
| 1245 | graphics = nullptr; | 1323 | graphics = nullptr; |
| 1246 | pipeline = VK_NULL_HANDLE; | 1324 | pipeline = VK_NULL_HANDLE; |
| 1325 | compile = 0; | ||
| 1247 | colors.clear(); | 1326 | colors.clear(); |
| 1248 | depth = {}; | 1327 | depth = {}; |
| 1249 | vertex_buffers.clear(); | 1328 | vertex_buffers.clear(); |
| @@ -2462,12 +2541,17 @@ ReplayResult prepare_draw(const Draw& draw, Resolve&& resolve, const ReplayFunct | |||
| 2462 | if (pipeline->color_formats[slot] != VK_FORMAT_UNDEFINED && !p.colors[slot].id) unbound |= 1u << slot; | 2541 | if (pipeline->color_formats[slot] != VK_FORMAT_UNDEFINED && !p.colors[slot].id) unbound |= 1u << slot; |
| 2463 | if (pipeline->depth_format != VK_FORMAT_UNDEFINED && !p.depth.id) unbound |= GraphicsPipeline::unbound_depth; | 2542 | if (pipeline->depth_format != VK_FORMAT_UNDEFINED && !p.depth.id) unbound |= GraphicsPipeline::unbound_depth; |
| 2464 | if (unbound || !p.pipeline) { | 2543 | if (unbound || !p.pipeline) { |
| 2465 | p.pipeline = pipeline->variant ? pipeline->variant(unbound) : VK_NULL_HANDLE; | 2544 | if (vk.compiles && pipeline->variant && pipeline->built && !pipeline->async_build) { |
| 2466 | if (!p.pipeline && pipeline->async_build && !strict_replay()) { | 2545 | p.pipeline = pipeline->built(unbound); |
| 2467 | p.skipped = true; | 2546 | if (!p.pipeline) p.compile = vk.compiles->add(*pipeline, unbound); |
| 2468 | return ReplayResult::success; | 2547 | } else { |
| 2548 | p.pipeline = pipeline->variant ? pipeline->variant(unbound) : VK_NULL_HANDLE; | ||
| 2549 | if (!p.pipeline && pipeline->async_build && !strict_replay()) { | ||
| 2550 | p.skipped = true; | ||
| 2551 | return ReplayResult::success; | ||
| 2552 | } | ||
| 2553 | if (!p.pipeline) return unsupported_at(__LINE__); | ||
| 2469 | } | 2554 | } |
| 2470 | if (!p.pipeline) return unsupported_at(__LINE__); | ||
| 2471 | } | 2555 | } |
| 2472 | 2556 | ||
| 2473 | // An unbound vertex-buffer slot reads zeros, as in D3D12: the zero page with stride 0. Per-instance slots with | 2557 | // An unbound vertex-buffer slot reads zeros, as in D3D12: the zero page with stride 0. Per-instance slots with |
| @@ -2534,6 +2618,20 @@ ReplayResult prepare_draw(const Draw& draw, Resolve&& resolve, const ReplayFunct | |||
| 2534 | return ReplayResult::success; | 2618 | return ReplayResult::success; |
| 2535 | } | 2619 | } |
| 2536 | 2620 | ||
| 2621 | // A compute pipeline that is built on first use: the one built already, the one vk.compiles will build with the | ||
| 2622 | // submission's others (true, with p.compile set and no pipeline yet), or the one built here. | ||
| 2623 | inline bool first_use(const ComputePipeline& pipeline, PipelineCompiles::User user, const ReplayFunctions& vk, Prepared& p) { | ||
| 2624 | if (p.pipeline.pipeline || !pipeline.build) return p.pipeline.pipeline != VK_NULL_HANDLE; | ||
| 2625 | if (vk.compiles && pipeline.built && !pipeline.async_build && !pipeline.skipped && | ||
| 2626 | (!pipeline.bindless_set || vk.bind_descriptor_sets)) { | ||
| 2627 | p.pipeline.pipeline = pipeline.built(pipeline.build_context); | ||
| 2628 | if (!p.pipeline.pipeline) p.compile = vk.compiles->add(pipeline, user); | ||
| 2629 | return true; | ||
| 2630 | } | ||
| 2631 | p.pipeline.pipeline = pipeline.build(pipeline.build_context); | ||
| 2632 | return p.pipeline.pipeline != VK_NULL_HANDLE; | ||
| 2633 | } | ||
| 2634 | |||
| 2537 | // An indexed quad list (D3D_PRIMITIVE_TOPOLOGY 19): the scratch and the compute job that turn the application's | 2635 | // An indexed quad list (D3D_PRIMITIVE_TOPOLOGY 19): the scratch and the compute job that turn the application's |
| 2538 | // indices into triangle-list indices (quad_index_expand.h). `p` is the draw as prepare_draw left it. A draw of | 2636 | // indices into triangle-list indices (quad_index_expand.h). `p` is the draw as prepare_draw left it. A draw of |
| 2539 | // fewer than four indices has no quad and needs nothing. | 2637 | // fewer than four indices has no quad and needs nothing. |
| @@ -2665,6 +2763,32 @@ public: | |||
| 2665 | std::vector<detail::PreparedKhrPostbuild> khr_postbuilds; | 2763 | std::vector<detail::PreparedKhrPostbuild> khr_postbuilds; |
| 2666 | }; | 2764 | }; |
| 2667 | 2765 | ||
| 2766 | // Ends the preparation of a submission whose prepare() calls used `compiles` and returned `result` (the first that | ||
| 2767 | // failed, if any): builds the pipelines through run(count, job), puts them into `lists`, and returns what the calls would | ||
| 2768 | // have returned had they built each pipeline themselves. Every use in `compiles` comes from a command before the one that | ||
| 2769 | // failed, so a pipeline that cannot be built counts first, at the earliest command that uses it: it fails the list of a | ||
| 2770 | // draw or an indirect dispatch, and a dispatch is dropped as prepare() drops one. | ||
| 2771 | template<typename Run> | ||
| 2772 | ReplayResult build_pipelines(PipelineCompiles& compiles, std::span<PreparedList> lists, ReplayResult result, | ||
| 2773 | Run&& run) { | ||
| 2774 | if (compiles.empty()) return result; | ||
| 2775 | compiles.build(run); | ||
| 2776 | for (const PipelineCompiles::Use& use : compiles.uses()) { | ||
| 2777 | if (compiles.built(use.ticket)) continue; | ||
| 2778 | if (use.user == PipelineCompiles::User::draw) return unsupported_at(__LINE__); | ||
| 2779 | if (use.user == PipelineCompiles::User::indirect_dispatch || strict_replay()) return unresolved_at(__LINE__); | ||
| 2780 | unresolved_at(__LINE__); | ||
| 2781 | } | ||
| 2782 | if (result != ReplayResult::success) return result; | ||
| 2783 | for (PreparedList& list : lists) { | ||
| 2784 | for (detail::Prepared& command : list.commands) | ||
| 2785 | if (command.compile) command.pipeline.pipeline = compiles.built(command.compile); | ||
| 2786 | for (std::size_t i = 0; i < list.draw_count; ++i) | ||
| 2787 | if (list.draws[i].compile) list.draws[i].pipeline = compiles.built(list.draws[i].compile); | ||
| 2788 | } | ||
| 2789 | return result; | ||
| 2790 | } | ||
| 2791 | |||
| 2668 | inline ReplayResult plan_occlusion_segments(PreparedList& out) { | 2792 | inline ReplayResult plan_occlusion_segments(PreparedList& out) { |
| 2669 | // Active logical queries cover a contiguous range of physical slots. A Begin or End closes the old | 2793 | // Active logical queries cover a contiguous range of physical slots. A Begin or End closes the old |
| 2670 | // slot and opens a new one if any query remains active. Each shared interval is recorded only once. | 2794 | // slot and opens a new one if any query remains active. Each shared interval is recorded only once. |
| @@ -3568,10 +3692,10 @@ ReplayResult prepare(const CommandList& list, Resolve&& resolve, const ReplayFun | |||
| 3568 | const ComputePipeline* pipeline = vk.compute_pipeline(ind->pipeline); | 3692 | const ComputePipeline* pipeline = vk.compute_pipeline(ind->pipeline); |
| 3569 | if (!pipeline) return unresolved_at(__LINE__); | 3693 | if (!pipeline) return unresolved_at(__LINE__); |
| 3570 | p.pipeline = *pipeline; | 3694 | p.pipeline = *pipeline; |
| 3571 | if (!p.pipeline.pipeline && p.pipeline.build) p.pipeline.pipeline = p.pipeline.build(p.pipeline.build_context); | 3695 | const bool found = detail::first_use(*pipeline, PipelineCompiles::User::indirect_dispatch, vk, p); |
| 3572 | if (!p.pipeline.pipeline && p.pipeline.skipped) continue; // dropped on request, strict or not | 3696 | if (!found && p.pipeline.skipped) continue; // dropped on request, strict or not |
| 3573 | if (!p.pipeline.pipeline && p.pipeline.async_build && !strict_replay()) continue; | 3697 | if (!found && p.pipeline.async_build && !strict_replay()) continue; |
| 3574 | if (!p.pipeline.pipeline) return unresolved_at(__LINE__); | 3698 | if (!found) return unresolved_at(__LINE__); |
| 3575 | if (pipeline->bindless_set && !vk.bind_descriptor_sets) return unsupported_at(__LINE__); | 3699 | if (pipeline->bindless_set && !vk.bind_descriptor_sets) return unsupported_at(__LINE__); |
| 3576 | } | 3700 | } |
| 3577 | } else if (const auto* build = std::get_if<BuildAccelerationStructure>(&command)) { | 3701 | } else if (const auto* build = std::get_if<BuildAccelerationStructure>(&command)) { |
| @@ -3676,9 +3800,9 @@ ReplayResult prepare(const CommandList& list, Resolve&& resolve, const ReplayFun | |||
| 3676 | continue; | 3800 | continue; |
| 3677 | } | 3801 | } |
| 3678 | p.pipeline = *pipeline; | 3802 | p.pipeline = *pipeline; |
| 3679 | if (!p.pipeline.pipeline && p.pipeline.build) p.pipeline.pipeline = p.pipeline.build(p.pipeline.build_context); | 3803 | const bool found = detail::first_use(*pipeline, PipelineCompiles::User::dispatch, vk, p); |
| 3680 | if (!p.pipeline.pipeline && p.pipeline.skipped) continue; // dropped on request, strict or not | 3804 | if (!found && p.pipeline.skipped) continue; // dropped on request, strict or not |
| 3681 | if (!p.pipeline.pipeline) { | 3805 | if (!found) { |
| 3682 | if (strict) return unresolved_at(__LINE__); | 3806 | if (strict) return unresolved_at(__LINE__); |
| 3683 | if (!p.pipeline.async_build) unresolved_at(__LINE__); | 3807 | if (!p.pipeline.async_build) unresolved_at(__LINE__); |
| 3684 | continue; | 3808 | continue; |