upleb.uk

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

summaryrefslogtreecommitdiff
path: root/runtime/src/depth24.h
diff options
context:
space:
mode:
authorzneel <14263028+zneel@users.noreply.github.com>2026-11-22 10:50:10 +0100
committerzneel <14263028+zneel@users.noreply.github.com>2026-11-22 11:26:48 +0100
commit983862e2a885a3d7082cf9678e863fdce1bd6f4e (patch)
tree57ecd89e512f1d7e3fe5e34b37bfce2d0eff7125 /runtime/src/depth24.h
parentf85582e23d4ab9e19acbf694358f137d6b8531b1 (diff)
Runtime: 96-bit R32G32B32 textures on the Vulkan layer (D3D-62)
R32G32B32_FLOAT/UINT/SINT/TYPELESS textures were refused ("texture format not supported yet"). They are now R32G32B32A32 images on every GPU: most have no optimal-tiling RGB32 image, and one that has would not avoid the repack, since D3D12 places subresources at multiples of 512 bytes and Vulkan wants a copy's buffer offset to be a multiple of the texel size (VUID-vkCmdCopyBufferToImage-dstImage-07975). - Footprints keep D3D12's 12-byte texels (compared with WARP). - CopyTextureRegion between a texture and a buffer is repacked by the D24 compute pass (depth24_convert.comp modes 2 and 3, Depth24Job::rgb96): the same scratch, parts and lifetime, texels of three words in the footprint and four in the scratch, copied uninterpreted. depth24_convert.inc is regenerated with the documented glslc command; the same glslc reproduces the previous blob byte for byte from the previous source. - WriteToSubresource/ReadFromSubresource take the staged copy, as D24-as-D32. - A view's T# names GFX10_FORMAT_32_32_32_*, so alpha reads as one. - Refused: unordered access and depth (as WARP), render targets (WARP has them; not done, and FORMAT_SUPPORT and GetResourceAllocationInfo agree), copies between a 96-bit and a four-channel texture, views of another format family. Tested on an RX 9070 XT (AMD 26.11.2), Windows 11: d3d12_rgb96_test matches WARP and the expected texels bit for bit for 4 formats as 2D arrays with mips and as volumes; d3d12_descriptor_test samples FLOAT, UINT and TYPELESS views. Clean under the validation layer with sync validation; depth24_convert_test and ctest (62) pass. AI-assisted (Claude Code). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Diffstat (limited to 'runtime/src/depth24.h')
-rw-r--r--runtime/src/depth24.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/runtime/src/depth24.h b/runtime/src/depth24.h
index ced51bcb1..b9100297b 100644
--- a/runtime/src/depth24.h
+++ b/runtime/src/depth24.h
@@ -50,8 +50,15 @@ inline float depth24_clear_value(float value) { return depth24_to_float(depth24_
50// One copy between a footprint (words of 24-bit depth) and the D32 aspect of a texture, as the compute pass sees it. 50// One copy between a footprint (words of 24-bit depth) and the D32 aspect of a texture, as the compute pass sees it.
51// The pass converts between the application's buffer and a tight scratch buffer of floats; a copy command moves the 51// The pass converts between the application's buffer and a tight scratch buffer of floats; a copy command moves the
52// scratch to or from the image. vulkan_depth24.h fills the scratch and descriptor fields in `prepare`. 52// scratch to or from the image. vulkan_depth24.h fills the scratch and descriptor fields in `prepare`.
53//
54// The same pass, scratch and job repack 96-bit R32G32B32 texels (`rgb96`, D3D-62): the footprint then has three
55// words a texel and the scratch four (the layer's R32G32B32A32 image), copied as they are. The row and slice
56// distances stay in words; only the texel's width differs (app_texel_words, scratch_texel_words).
53struct Depth24Job { 57struct Depth24Job {
54 bool to_float = false; // an upload (D24 words to floats); false: a readback (floats to words) 58 bool to_float = false; // an upload (D24 words to floats); false: a readback (floats to words)
59 bool rgb96 = false; // 96-bit texels: `to_float` is only the direction (true: the upload)
60 std::uint32_t app_texel_words() const { return rgb96 ? 3 : 1; }
61 std::uint32_t scratch_texel_words() const { return rgb96 ? 4 : 1; }
55 VkBuffer app = VK_NULL_HANDLE; // the application's buffer 62 VkBuffer app = VK_NULL_HANDLE; // the application's buffer
56 std::uint64_t app_offset = 0; // bytes, a multiple of 4 63 std::uint64_t app_offset = 0; // bytes, a multiple of 4
57 std::uint64_t app_size = 0; // bytes in the buffer 64 std::uint64_t app_size = 0; // bytes in the buffer
@@ -59,7 +66,7 @@ struct Depth24Job {
59 std::uint32_t app_row_words = 0; // words between rows and between slices of the footprint 66 std::uint32_t app_row_words = 0; // words between rows and between slices of the footprint
60 std::uint32_t app_slice_words = 0; 67 std::uint32_t app_slice_words = 0;
61 // Set by prepare: 68 // Set by prepare:
62 VkBuffer scratch = VK_NULL_HANDLE; // width * height * slices floats, tightly packed 69 VkBuffer scratch = VK_NULL_HANDLE; // width * height * slices texels (floats, or four words), tightly packed
63 VkDeviceSize scratch_offset = 0; 70 VkDeviceSize scratch_offset = 0;
64 VkDescriptorSet set = VK_NULL_HANDLE; 71 VkDescriptorSet set = VK_NULL_HANDLE;
65 std::uint32_t app_base_words = 0; // the region's first word in the descriptor's window 72 std::uint32_t app_base_words = 0; // the region's first word in the descriptor's window