upleb.uk

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

summaryrefslogtreecommitdiff
path: root/runtime/src
diff options
context:
space:
mode:
authorItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com>2026-11-22 11:41:37 -0500
committerItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com>2026-11-22 11:41:37 -0500
commit2fe08d7e18d8a11307ced0b7c04eb650b72bc157 (patch)
tree032470a666cd2f94257323c9f8c84fe09e59ebe8 /runtime/src
parentad021b4a2f4617bd36f10f4a5075acaa0107f8ed (diff)
parent8af232c5e54906b3b5cc98417d7d3904c82c7b99 (diff)
Merge pull request #2084 from Luis Baker
Diffstat (limited to 'runtime/src')
-rw-r--r--runtime/src/vulkan_backend.h6
-rw-r--r--runtime/src/vulkan_replay.h34
2 files changed, 33 insertions, 7 deletions
diff --git a/runtime/src/vulkan_backend.h b/runtime/src/vulkan_backend.h
index 93d7e5259..57615f6f8 100644
--- a/runtime/src/vulkan_backend.h
+++ b/runtime/src/vulkan_backend.h
@@ -1017,6 +1017,12 @@ public:
1017 replay_.zero_offset = offset; 1017 replay_.zero_offset = offset;
1018 replay_.zero_size = size; 1018 replay_.zero_size = size;
1019 } 1019 }
1020
1021 // Physical-device COLOR_ATTACHMENT format check for reinterpreted UAV clears.
1022 void set_color_attachment_format(std::function<bool(VkFormat)> check) {
1023 std::unique_lock lock(resource_mutex_);
1024 replay_.color_attachment_format = std::move(check);
1025 }
1020 std::uint64_t heap_base() { 1026 std::uint64_t heap_base() {
1021 std::shared_lock lock(resource_mutex_); 1027 std::shared_lock lock(resource_mutex_);
1022 return replay_.heap_base; 1028 return replay_.heap_base;
diff --git a/runtime/src/vulkan_replay.h b/runtime/src/vulkan_replay.h
index 8ece08d1e..967b310d4 100644
--- a/runtime/src/vulkan_replay.h
+++ b/runtime/src/vulkan_replay.h
@@ -855,6 +855,9 @@ struct ReplayFunctions {
855 std::function<void(VkCommandBuffer, const std::vector<PredicatedCopyDispatch>&)> emit_predicated_copy; 855 std::function<void(VkCommandBuffer, const std::vector<PredicatedCopyDispatch>&)> emit_predicated_copy;
856 // Returns a 2D-array view of the range (caller-owned, alive until execution completes); rectangle clears. 856 // Returns a 2D-array view of the range (caller-owned, alive until execution completes); rectangle clears.
857 std::function<VkImageView(const ResourceBinding&, const VkImageSubresourceRange&)> image_view; 857 std::function<VkImageView(const ResourceBinding&, const VkImageSubresourceRange&)> image_view;
858 // Optional format check for color-attachment reinterpretation on mutable UAV clears; unset assumes every format
859 // except E5B9G9R9_UFLOAT_PACK32 supports COLOR_ATTACHMENT.
860 std::function<bool(VkFormat)> color_attachment_format;
858 // Footprint copies of a depth24_as_float texture (depth24.h): `depth24_prepare` makes the scratch and descriptors 861 // Footprint copies of a depth24_as_float texture (depth24.h): `depth24_prepare` makes the scratch and descriptors
859 // for a job while the list is checked, `depth24_run` records its dispatch. Without them such a copy is unsupported. 862 // for a job while the list is checked, `depth24_run` records its dispatch. Without them such a copy is unsupported.
860 std::function<bool(Depth24Job&, std::vector<Depth24Job>&)> depth24_prepare; // whole copy in, dispatches out 863 std::function<bool(Depth24Job&, std::vector<Depth24Job>&)> depth24_prepare; // whole copy in, dispatches out
@@ -917,7 +920,7 @@ struct Prepared {
917 ResourceBinding binding; 920 ResourceBinding binding;
918 VkImageSubresourceRange range{}; // the barrier range, or the cleared view (cleared aspects only) 921 VkImageSubresourceRange range{}; // the barrier range, or the cleared view (cleared aspects only)
919 VkImageView view = VK_NULL_HANDLE; 922 VkImageView view = VK_NULL_HANDLE;
920 VkFormat clear_format = VK_FORMAT_UNDEFINED; // The RTV format, without changing the resource binding. 923 VkFormat clear_format = VK_FORMAT_UNDEFINED; // The clear view format (RTV or reinterpreted UAV), without changing the resource binding.
921 std::vector<VkClearRect> rects; // rectangle clears, clipped to the mip 924 std::vector<VkClearRect> rects; // rectangle clears, clipped to the mip
922 bool skip = false; // every rectangle was empty 925 bool skip = false; // every rectangle was empty
923 ResourceBinding source; // copies: the source resource 926 ResourceBinding source; // copies: the source resource
@@ -2234,18 +2237,35 @@ ReplayResult prepare(const CommandList& list, Resolve&& resolve, const ReplayFun
2234 const TargetView target{view.resource, view.mip, view.first_layer, view.layer_count}; 2237 const TargetView target{view.resource, view.mip, view.first_layer, view.layer_count};
2235 if (!detail::view_range(p.binding, target, VK_IMAGE_ASPECT_COLOR_BIT, p.range)) 2238 if (!detail::view_range(p.binding, target, VK_IMAGE_ASPECT_COLOR_BIT, p.range))
2236 return ReplayResult::invalid_subresource; 2239 return ReplayResult::invalid_subresource;
2237 // The view's format turns the values into bytes; the image's own format clears them in. 2240 // The view's format turns the values into bytes. When the view format differs from the image's backing
2241 // format (a typeless or castable texture) and can be cleared as a color attachment, clear through a view of
2242 // view_format instead of decoding into the backing format (which turns non-float bit patterns like
2243 // R16G16_UNORM 1.0 = 0xffff or R32_UINT 0x7f800001 into SFLOAT NaNs that vkCmdClearColorImage quiets).
2244 // Emulated R9G9B9E5_SHAREDEXP images (backed by R32_UINT) lack COLOR_ATTACHMENT on E5B9G9R9 and keep the
2245 // bit-exact R32_UINT backing path.
2238 const VkFormat view_format = view.format ? VkFormat(view.format) : p.binding.format; 2246 const VkFormat view_format = view.format ? VkFormat(view.format) : p.binding.format;
2239 if (!uav_clear::encode(view_format, uav->is_float, uav->values, p.element) || 2247 if (!uav_clear::encode(view_format, uav->is_float, uav->values, p.element))
2240 !uav_clear::decode(p.binding.format, p.element, p.clear_color))
2241 return ReplayResult::unsupported; 2248 return ReplayResult::unsupported;
2242 if (!uav->rects.empty() && (!p.binding.color_attachment || p.binding.volume)) 2249 const auto* image_layout = uav_clear::layout(p.binding.format);
2250 if (!image_layout || image_layout->bytes != p.element.size)
2251 return ReplayResult::unsupported;
2252 const bool attachment = p.binding.color_attachment && !p.binding.volume;
2253 const bool view_attachable = vk.color_attachment_format
2254 ? vk.color_attachment_format(view_format)
2255 : view_format != VK_FORMAT_E5B9G9R9_UFLOAT_PACK32;
2256 const bool reinterpret = view_format != p.binding.format && attachment && view_attachable;
2257 const VkFormat clear_format = reinterpret ? view_format : p.binding.format;
2258 if (!uav_clear::decode(clear_format, p.element, p.clear_color))
2259 return ReplayResult::unsupported;
2260 if (reinterpret) p.clear_format = view_format;
2261 if (!uav->rects.empty() && !attachment)
2243 return ReplayResult::unsupported; 2262 return ReplayResult::unsupported;
2244 // Under a predicate a whole view is cleared as one rectangle where the image can be an attachment, as 2263 // Under a predicate a whole view is cleared as one rectangle where the image can be an attachment, as
2245 // render targets are; otherwise vkCmdClearColorImage runs unconditionally and is counted. 2264 // render targets are; otherwise vkCmdClearColorImage runs unconditionally and is counted.
2246 const bool attachment = p.binding.color_attachment && !p.binding.volume;
2247 if (predicated && uav->rects.empty() && !attachment) ++out.unpredicated_copies; 2265 if (predicated && uav->rects.empty() && !attachment) ++out.unpredicated_copies;
2248 const auto rects = attachment ? clear_rects(uav->rects) : std::span<const Rect>(uav->rects); 2266 const auto rects = (reinterpret && uav->rects.empty())
2267 ? std::span<const Rect>(&whole_view, 1)
2268 : attachment ? clear_rects(uav->rects) : std::span<const Rect>(uav->rects);
2249 if (const auto r = rect_view(rects, target, VK_IMAGE_ASPECT_COLOR_BIT); r != ReplayResult::success) 2269 if (const auto r = rect_view(rects, target, VK_IMAGE_ASPECT_COLOR_BIT); r != ReplayResult::success)
2250 return r; 2270 return r;
2251 if (!p.skip && p.rects.empty() && !vk.clear_color_image) return ReplayResult::unsupported; 2271 if (!p.skip && p.rects.empty() && !vk.clear_color_image) return ReplayResult::unsupported;