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-21 18:08:03 -0500
committerItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com>2026-11-21 18:08:03 -0500
commit03ff5f4bd8a47d8b32c76282cdaed38e81320fce (patch)
tree7d34215b35aceed9c4746c77002685868ed9378d /runtime/src
parent2f076083fec79795eee4c43fe835ed4c95f568ff (diff)
parent489258fda505ac7be0c66974583749519577e6e7 (diff)
Merge pull request #338 from mrb-eel
Diffstat (limited to 'runtime/src')
-rw-r--r--runtime/src/command_list.h18
-rw-r--r--runtime/src/vulkan_replay.h25
2 files changed, 34 insertions, 9 deletions
diff --git a/runtime/src/command_list.h b/runtime/src/command_list.h
index 83b5df40d..cded8c843 100644
--- a/runtime/src/command_list.h
+++ b/runtime/src/command_list.h
@@ -7,6 +7,7 @@
7 7
8#include <array> 8#include <array>
9#include <cstdint> 9#include <cstdint>
10#include <optional>
10#include <span> 11#include <span>
11#include <variant> 12#include <variant>
12#include <vector> 13#include <vector>
@@ -269,13 +270,20 @@ struct CopyResource {
269 ResourceId src; 270 ResourceId src;
270}; 271};
271 272
272// ResolveSubresource: a multisampled subresource into a single-sampled one of the same size. The call's format is 273struct ResolveRegion {
273// not kept: the resolve uses the textures' own format, which D3D12 requires to be compatible. 274 std::uint32_t dst_x;
275 std::uint32_t dst_y;
276 std::optional<Rect> src_rect;
277};
278
279// Without a region, both subresources have the same extent. A region with no source rectangle takes the
280// entire source to the given destination offset. The resolve uses the images' own format.
274struct ResolveSubresource { 281struct ResolveSubresource {
275 ResourceId dst; 282 ResourceId dst;
276 std::uint32_t dst_subresource; 283 std::uint32_t dst_subresource;
277 ResourceId src; 284 ResourceId src;
278 std::uint32_t src_subresource; 285 std::uint32_t src_subresource;
286 std::optional<ResolveRegion> region = std::nullopt;
279}; 287};
280 288
281// D3D12_TEXTURE_DATA_PITCH_ALIGNMENT and D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT. 289// D3D12_TEXTURE_DATA_PITCH_ALIGNMENT and D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT.
@@ -363,6 +371,12 @@ public:
363 // A resource has one sample count, so it cannot be resolved into itself. 371 // A resource has one sample count, so it cannot be resolved into itself.
364 bool resolve_subresource(const ResolveSubresource& resolve) { 372 bool resolve_subresource(const ResolveSubresource& resolve) {
365 if (!resolve.dst || !resolve.src || resolve.dst == resolve.src) return false; 373 if (!resolve.dst || !resolve.src || resolve.dst == resolve.src) return false;
374 if (const auto& region = resolve.region) {
375 if (region->dst_x > INT32_MAX || region->dst_y > INT32_MAX) return false;
376 if (const auto& r = region->src_rect;
377 r && (r->left < 0 || r->top < 0 || r->right <= r->left || r->bottom <= r->top))
378 return false;
379 }
366 return append(resolve); 380 return append(resolve);
367 } 381 }
368 382
diff --git a/runtime/src/vulkan_replay.h b/runtime/src/vulkan_replay.h
index 4a7806ec7..1bd38ae93 100644
--- a/runtime/src/vulkan_replay.h
+++ b/runtime/src/vulkan_replay.h
@@ -835,9 +835,7 @@ inline ReplayResult prepare_resource_copy(Prepared& p) {
835 return ReplayResult::success; 835 return ReplayResult::success;
836} 836}
837 837
838// ResolveSubresource through vkCmdResolveImage: a multisampled colour subresource into a single-sampled one of 838// Resolve a multisampled colour image into a single-sampled image of the same format.
839// the same size and format. Depth-stencil resolves, and resolves between two formats of a typeless family, are
840// not supported yet.
841inline ReplayResult prepare_resolve(const ResolveSubresource& resolve, Prepared& p) { 839inline ReplayResult prepare_resolve(const ResolveSubresource& resolve, Prepared& p) {
842 VkImageSubresourceRange dst{}, src{}; 840 VkImageSubresourceRange dst{}, src{};
843 if (!copy_subresource(p.binding, resolve.dst_subresource, dst) || 841 if (!copy_subresource(p.binding, resolve.dst_subresource, dst) ||
@@ -845,13 +843,26 @@ inline ReplayResult prepare_resolve(const ResolveSubresource& resolve, Prepared&
845 return ReplayResult::invalid_subresource; 843 return ReplayResult::invalid_subresource;
846 if (p.source.samples <= 1 || p.binding.samples != 1 || p.binding.volume) return ReplayResult::invalid_copy; 844 if (p.source.samples <= 1 || p.binding.samples != 1 || p.binding.volume) return ReplayResult::invalid_copy;
847 const VkExtent2D from = mip_extent(p.source, src.baseMipLevel), to = mip_extent(p.binding, dst.baseMipLevel); 845 const VkExtent2D from = mip_extent(p.source, src.baseMipLevel), to = mip_extent(p.binding, dst.baseMipLevel);
848 if (from.width != to.width || from.height != to.height) return ReplayResult::invalid_copy; 846 VkOffset3D src_offset{}, dst_offset{};
847 VkExtent3D extent{from.width, from.height, 1};
848 if (const auto& region = resolve.region) {
849 dst_offset = {std::int32_t(region->dst_x), std::int32_t(region->dst_y), 0};
850 if (const auto& r = region->src_rect) {
851 if (std::uint32_t(r->right) > from.width || std::uint32_t(r->bottom) > from.height)
852 return ReplayResult::invalid_copy;
853 src_offset = {r->left, r->top, 0};
854 extent = {std::uint32_t(r->right - r->left), std::uint32_t(r->bottom - r->top), 1};
855 }
856 if (!within(region->dst_x, extent.width, to.width) || !within(region->dst_y, extent.height, to.height))
857 return ReplayResult::invalid_copy;
858 } else if (from.width != to.width || from.height != to.height) {
859 return ReplayResult::invalid_copy;
860 }
849 if (src.aspectMask != VK_IMAGE_ASPECT_COLOR_BIT || dst.aspectMask != VK_IMAGE_ASPECT_COLOR_BIT || 861 if (src.aspectMask != VK_IMAGE_ASPECT_COLOR_BIT || dst.aspectMask != VK_IMAGE_ASPECT_COLOR_BIT ||
850 p.source.format != p.binding.format) 862 p.source.format != p.binding.format)
851 return ReplayResult::unsupported; 863 return ReplayResult::unsupported;
852 p.resolve = {{src.aspectMask, src.baseMipLevel, src.baseArrayLayer, 1}, {0, 0, 0}, 864 p.resolve = {{src.aspectMask, src.baseMipLevel, src.baseArrayLayer, 1}, src_offset,
853 {dst.aspectMask, dst.baseMipLevel, dst.baseArrayLayer, 1}, {0, 0, 0}, 865 {dst.aspectMask, dst.baseMipLevel, dst.baseArrayLayer, 1}, dst_offset, extent};
854 {from.width, from.height, 1}};
855 p.range = dst; 866 p.range = dst;
856 p.source_range = src; 867 p.source_range = src;
857 return ReplayResult::success; 868 return ReplayResult::success;