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 00:33:47 -0500
committerItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com>2026-11-22 00:33:47 -0500
commit9932fca4d44ee00e7dfc0a800fb3ddd3843e622d (patch)
tree1c2f63ba51ddc3b19b5addf0f4cd5e41ebac45e7 /runtime/src
parent6bb8f4ffca3554bdbf53867ed08366431b9c776f (diff)
parent830fec3bc12000a7542dfe2d5d9aefa142740dd7 (diff)
Merge pull request #922 from sanuk369 (replayed without the removed README commits)
Diffstat (limited to 'runtime/src')
-rw-r--r--runtime/src/vulkan_replay.h52
1 files changed, 52 insertions, 0 deletions
diff --git a/runtime/src/vulkan_replay.h b/runtime/src/vulkan_replay.h
index 6122ccfeb..b68ddf405 100644
--- a/runtime/src/vulkan_replay.h
+++ b/runtime/src/vulkan_replay.h
@@ -1228,6 +1228,54 @@ public:
1228 std::size_t unpredicated_copies = 0; 1228 std::size_t unpredicated_copies = 0;
1229}; 1229};
1230 1230
1231// detail::initialize zero-clears an image piece the tracker holds in UNDEFINED (D3D12 committed resources start
1232// zeroed) the first time a command touches it, with vkCmdClearColorImage or vkCmdClearDepthStencilImage. True when
1233// a command of the list would need one of those and it is unset; replay() then refuses the list as unsupported, as
1234// prepare() does for every other optional function, rather than emit calling a null pointer.
1235inline bool zero_clear_unavailable(const PreparedList& prepared, const ReplayFunctions& vk,
1236 const LayoutTracker& tracker) {
1237 if (vk.clear_color_image && vk.clear_depth_stencil_image) return false;
1238 std::vector<LayoutPiece> pieces;
1239 const auto missing = [&](ResourceId id, const ResourceBinding& resource, const VkImageSubresourceRange& range) {
1240 if (!id || !resource.image || resource.not_zeroed ||
1241 block_format(resource.format, VK_IMAGE_ASPECT_COLOR_BIT).block > 1) // only moved, never cleared
1242 return false;
1243 pieces.clear();
1244 if (!tracker.pieces(id, range, pieces)) return false;
1245 for (const auto& piece : pieces)
1246 if (piece.layout == VK_IMAGE_LAYOUT_UNDEFINED &&
1247 ((piece.range.aspectMask & VK_IMAGE_ASPECT_COLOR_BIT) ? !vk.clear_color_image
1248 : !vk.clear_depth_stencil_image))
1249 return true;
1250 return false;
1251 };
1252 const auto commands = prepared.list->commands();
1253 for (std::size_t i = 0; i < commands.size(); ++i) {
1254 const auto& command = commands[i];
1255 const auto& p = prepared.commands[i];
1256 if (p.skip) continue;
1257 if (const auto [dst, src] = copy_ids(command); dst || src) {
1258 if (missing(dst, p.binding, p.range) || missing(src, p.source, p.source_range)) return true;
1259 continue;
1260 }
1261 const ResourceId id = std::visit(
1262 [](const auto& c) -> ResourceId {
1263 using T = std::decay_t<decltype(c)>;
1264 if constexpr (std::is_same_v<T, ClearRenderTarget> || std::is_same_v<T, ClearDepthStencil>)
1265 return c.target.resource;
1266 else if constexpr (std::is_same_v<T, ClearUnorderedAccess>)
1267 return c.view.resource;
1268 else if constexpr (requires { c.resource; })
1269 return c.resource;
1270 else
1271 return 0;
1272 },
1273 command);
1274 if (missing(id, p.binding, p.range)) return true;
1275 }
1276 return false;
1277}
1278
1231// Resolves and checks every command. Nothing is written to a command buffer. 1279// Resolves and checks every command. Nothing is written to a command buffer.
1232// Resolve maps a ResourceId to a const ResourceBinding* (nullptr: unknown). 1280// Resolve maps a ResourceId to a const ResourceBinding* (nullptr: unknown).
1233template<typename Resolve> 1281template<typename Resolve>
@@ -1322,6 +1370,7 @@ ReplayResult prepare(const CommandList& list, Resolve&& resolve, const ReplayFun
1322 VK_IMAGE_ASPECT_COLOR_BIT); r != ReplayResult::success) return r; 1370 VK_IMAGE_ASPECT_COLOR_BIT); r != ReplayResult::success) return r;
1323 } else if (const auto r = rect_view(clear_rects(color_clear->rects), color_clear->target, VK_IMAGE_ASPECT_COLOR_BIT); 1371 } else if (const auto r = rect_view(clear_rects(color_clear->rects), color_clear->target, VK_IMAGE_ASPECT_COLOR_BIT);
1324 r != ReplayResult::success) return r; 1372 r != ReplayResult::success) return r;
1373 if (!p.skip && p.rects.empty() && !vk.clear_color_image) return ReplayResult::unsupported;
1325 } else if (const auto* depth_clear = std::get_if<ClearDepthStencil>(&command)) { 1374 } else if (const auto* depth_clear = std::get_if<ClearDepthStencil>(&command)) {
1326 if (!bind(depth_clear->target.resource)) return ReplayResult::unresolved_resource; 1375 if (!bind(depth_clear->target.resource)) return ReplayResult::unresolved_resource;
1327 VkImageAspectFlags aspects = 0; 1376 VkImageAspectFlags aspects = 0;
@@ -1335,6 +1384,7 @@ ReplayResult prepare(const CommandList& list, Resolve&& resolve, const ReplayFun
1335 if (const auto r = rect_view(clear_rects(depth_clear->rects), depth_clear->target, p.binding.aspects); 1384 if (const auto r = rect_view(clear_rects(depth_clear->rects), depth_clear->target, p.binding.aspects);
1336 r != ReplayResult::success) 1385 r != ReplayResult::success)
1337 return r; 1386 return r;
1387 if (!p.skip && p.rects.empty() && !vk.clear_depth_stencil_image) return ReplayResult::unsupported;
1338 } else if (const auto* uav = std::get_if<ClearUnorderedAccess>(&command)) { 1388 } else if (const auto* uav = std::get_if<ClearUnorderedAccess>(&command)) {
1339 const UavView& view = uav->view; 1389 const UavView& view = uav->view;
1340 if (!bind(view.resource)) return ReplayResult::unresolved_resource; 1390 if (!bind(view.resource)) return ReplayResult::unresolved_resource;
@@ -1362,6 +1412,7 @@ ReplayResult prepare(const CommandList& list, Resolve&& resolve, const ReplayFun
1362 const auto rects = attachment ? clear_rects(uav->rects) : std::span<const Rect>(uav->rects); 1412 const auto rects = attachment ? clear_rects(uav->rects) : std::span<const Rect>(uav->rects);
1363 if (const auto r = rect_view(rects, target, VK_IMAGE_ASPECT_COLOR_BIT); r != ReplayResult::success) 1413 if (const auto r = rect_view(rects, target, VK_IMAGE_ASPECT_COLOR_BIT); r != ReplayResult::success)
1364 return r; 1414 return r;
1415 if (!p.skip && p.rects.empty() && !vk.clear_color_image) return ReplayResult::unsupported;
1365 } else if (std::holds_alternative<CopyBuffer>(command) || std::holds_alternative<CopyTexture>(command) || 1416 } else if (std::holds_alternative<CopyBuffer>(command) || std::holds_alternative<CopyTexture>(command) ||
1366 std::holds_alternative<CopyResource>(command)) { 1417 std::holds_alternative<CopyResource>(command)) {
1367 if (!copies) return ReplayResult::unsupported; 1418 if (!copies) return ReplayResult::unsupported;
@@ -1924,6 +1975,7 @@ ReplayResult replay(const CommandList& list, VkCommandBuffer command_buffer, Res
1924 return ReplayResult::unsupported; 1975 return ReplayResult::unsupported;
1925 PreparedList prepared; 1976 PreparedList prepared;
1926 if (const auto result = prepare(list, resolve, vk, prepared); result != ReplayResult::success) return result; 1977 if (const auto result = prepare(list, resolve, vk, prepared); result != ReplayResult::success) return result;
1978 if (tracker && zero_clear_unavailable(prepared, vk, *tracker)) return ReplayResult::unsupported;
1927 emit(prepared, command_buffer, vk, tracker); 1979 emit(prepared, command_buffer, vk, tracker);
1928 return ReplayResult::success; 1980 return ReplayResult::success;
1929} 1981}