upleb.uk

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

summaryrefslogtreecommitdiff
path: root/runtime/shims/d3d12_com.cpp
diff options
context:
space:
mode:
authoraslan2142 <jan.trencansky@protonmail.com>2026-11-25 20:29:08 +0100
committerGitHub <noreply@github.com>2026-11-25 20:29:08 +0100
commitcee965560c09255fc5294e1a78734f4ed5a9fb84 (patch)
treeee4fb5b6c48799a464d17df1191de169807b8bb8 /runtime/shims/d3d12_com.cpp
parent75a41f5dc213a6b1b0e65483140a93f013871277 (diff)
parent926e9d3ef34649d2b39375fd12657d1f700aa779 (diff)
Merge pull request #1814 from timbot103/d3d-clear-uav-3d-slice
D3D-CLEAR-UAV-3D-SLICE: clear selected 3D UAV slices and rectangles
Diffstat (limited to 'runtime/shims/d3d12_com.cpp')
-rw-r--r--runtime/shims/d3d12_com.cpp28
1 files changed, 19 insertions, 9 deletions
diff --git a/runtime/shims/d3d12_com.cpp b/runtime/shims/d3d12_com.cpp
index b47ee0bdd..961514bcf 100644
--- a/runtime/shims/d3d12_com.cpp
+++ b/runtime/shims/d3d12_com.cpp
@@ -1352,7 +1352,8 @@ private:
1352 1352
1353 void clear_unordered_access(D3D12_CPU_DESCRIPTOR_HANDLE view, ID3D12Resource* resource, bool is_float, 1353 void clear_unordered_access(D3D12_CPU_DESCRIPTOR_HANDLE view, ID3D12Resource* resource, bool is_float,
1354 const std::array<std::uint32_t, 4>& values, UINT count, const D3D12_RECT* rects) { 1354 const std::array<std::uint32_t, 4>& values, UINT count, const D3D12_RECT* rects) {
1355 if (type_ == D3D12_COMMAND_LIST_TYPE_BUNDLE) return check(false); // no clear is allowed in a bundle 1355 if (type_ != D3D12_COMMAND_LIST_TYPE_DIRECT && type_ != D3D12_COMMAND_LIST_TYPE_COMPUTE)
1356 return check(false);
1356 leonida::UavView target{}; 1357 leonida::UavView target{};
1357 if (!view.ptr || !resource || !unordered_access_view(view, resource, target)) return check(false); 1358 if (!view.ptr || !resource || !unordered_access_view(view, resource, target)) return check(false);
1358 check(list_.clear_unordered_access(target, is_float, values, to_rects(count, rects))); 1359 check(list_.clear_unordered_access(target, is_float, values, to_rects(count, rects)));
@@ -1384,17 +1385,26 @@ private:
1384 const bool volume = image.type == g::ImageType::image_3d; 1385 const bool volume = image.type == g::ImageType::image_3d;
1385 const auto pair = xbox_depth_storage(resource); 1386 const auto pair = xbox_depth_storage(resource);
1386 if (pair.colour) out.resource = pair.colour; 1387 if (pair.colour) out.resource = pair.colour;
1387 if (g::partial_volume_uav(words, image)) {
1388 // Transfer clears operate on a whole 3D mip, not a storage image view. Refuse instead of
1389 // overwriting slices outside the UAV; a sliced clear needs a separate replay path.
1390 stub("ClearUnorderedAccessView of a partial 3D mip");
1391 return false;
1392 }
1393 out.buffer = false; 1388 out.buffer = false;
1394 out.format = std::uint32_t(descriptor_format(image.format, image.swizzle)); 1389 out.format = std::uint32_t(descriptor_format(image.format, image.swizzle));
1395 out.mip = image.first_mip; 1390 out.mip = image.first_mip;
1396 out.first_layer = volume ? 0 : image.first_layer; // a 3D view clears every slice of its mip 1391 if (volume) {
1397 out.layer_count = volume ? 1 : image.layer_count; 1392 g::VolumeUavRange slices{};
1393 if (g::volume_uav_range(words, image, slices)) {
1394 out.first_layer = slices.first_w;
1395 out.layer_count = slices.w_size;
1396 } else {
1397 // Untagged T#s select the entire resource mip, even if DEPTH describes a smaller or larger view.
1398 const auto desc = resource->GetDesc();
1399 const auto depth = desc.Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE3D
1400 ? std::uint32_t(desc.DepthOrArraySize) : image.depth;
1401 out.first_layer = 0;
1402 out.layer_count = std::max(1u, depth >> image.first_mip);
1403 }
1404 } else {
1405 out.first_layer = image.first_layer;
1406 out.layer_count = image.layer_count;
1407 }
1398 out.exact_clear_format = volume || image.type == g::ImageType::image_1d || 1408 out.exact_clear_format = volume || image.type == g::ImageType::image_1d ||
1399 image.type == g::ImageType::image_1d_array; 1409 image.type == g::ImageType::image_1d_array;
1400 return out.format != VK_FORMAT_UNDEFINED; 1410 return out.format != VK_FORMAT_UNDEFINED;