diff options
| author | zneel <14263028+zneel@users.noreply.github.com> | 2026-11-22 10:50:10 +0100 |
|---|---|---|
| committer | zneel <14263028+zneel@users.noreply.github.com> | 2026-11-22 11:26:48 +0100 |
| commit | 983862e2a885a3d7082cf9678e863fdce1bd6f4e (patch) | |
| tree | 57ecd89e512f1d7e3fe5e34b37bfce2d0eff7125 /runtime/src/depth24_convert.comp | |
| parent | f85582e23d4ab9e19acbf694358f137d6b8531b1 (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_convert.comp')
| -rw-r--r-- | runtime/src/depth24_convert.comp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/runtime/src/depth24_convert.comp b/runtime/src/depth24_convert.comp index 688f68d78..822a67459 100644 --- a/runtime/src/depth24_convert.comp +++ b/runtime/src/depth24_convert.comp | |||
| @@ -7,6 +7,11 @@ | |||
| 7 | // NaN and negatives 0, 1 and above 16777215), the unspecified top byte written as 0 | 7 | // NaN and negatives 0, 1 and above 16777215), the unspecified top byte written as 0 |
| 8 | // The upload direction is integer arithmetic (no float division, whose rounding is the GPU's choice); the readback | 8 | // The upload direction is integer arithmetic (no float division, whose rounding is the GPU's choice); the readback |
| 9 | // uses one float multiply, which Vulkan requires to be correctly rounded, and roundEven. | 9 | // uses one float multiply, which Vulkan requires to be correctly rounded, and roundEven. |
| 10 | // | ||
| 11 | // The same pass repacks 96-bit R32G32B32 texels, which the layer holds in R32G32B32A32 images (D3D-62; `to_float` | ||
| 12 | // 2 and 3). A footprint texel is then three words and a scratch texel four, and the words are copied as they are: | ||
| 13 | // to_float == 3 (upload): scratch[s .. s+2] = app[a .. a+2], scratch[s+3] = 0 (never read: views read alpha as one) | ||
| 14 | // to_float == 2 (readback): app[a .. a+2] = scratch[s .. s+2] | ||
| 10 | #version 450 | 15 | #version 450 |
| 11 | 16 | ||
| 12 | layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in; | 17 | layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in; |
| @@ -16,7 +21,7 @@ layout(set = 0, binding = 1) buffer Scratch { uint scratch[]; }; | |||
| 16 | 21 | ||
| 17 | layout(push_constant) uniform Push { | 22 | layout(push_constant) uniform Push { |
| 18 | uint width, height, slices; | 23 | uint width, height, slices; |
| 19 | uint to_float; | 24 | uint to_float; // 0 and 1: D24 words and floats; 2 and 3: 96-bit texels of 3 and 4 words (see above) |
| 20 | uint app_base; // first word of the region in `app`, within the bound window | 25 | uint app_base; // first word of the region in `app`, within the bound window |
| 21 | uint app_row; // words between rows and between slices of the app buffer | 26 | uint app_row; // words between rows and between slices of the app buffer |
| 22 | uint app_slice; | 27 | uint app_slice; |
| @@ -46,6 +51,21 @@ uint depth24_from_bits(uint bits) { | |||
| 46 | void main() { | 51 | void main() { |
| 47 | uvec3 g = gl_GlobalInvocationID; | 52 | uvec3 g = gl_GlobalInvocationID; |
| 48 | if (g.x >= pc.width || g.y >= pc.height || g.z >= pc.slices) return; | 53 | if (g.x >= pc.width || g.y >= pc.height || g.z >= pc.slices) return; |
| 54 | if (pc.to_float >= 2u) { | ||
| 55 | uint a = pc.app_base + g.z * pc.app_slice + g.y * pc.app_row + g.x * 3u; | ||
| 56 | uint s = pc.scratch_base + ((g.z * pc.height + g.y) * pc.width + g.x) * 4u; | ||
| 57 | if (pc.to_float == 3u) { | ||
| 58 | scratch[s] = app[a]; | ||
| 59 | scratch[s + 1u] = app[a + 1u]; | ||
| 60 | scratch[s + 2u] = app[a + 2u]; | ||
| 61 | scratch[s + 3u] = 0u; | ||
| 62 | } else { | ||
| 63 | app[a] = scratch[s]; | ||
| 64 | app[a + 1u] = scratch[s + 1u]; | ||
| 65 | app[a + 2u] = scratch[s + 2u]; | ||
| 66 | } | ||
| 67 | return; | ||
| 68 | } | ||
| 49 | uint a = pc.app_base + g.z * pc.app_slice + g.y * pc.app_row + g.x; | 69 | uint a = pc.app_base + g.z * pc.app_slice + g.y * pc.app_row + g.x; |
| 50 | uint s = pc.scratch_base + (g.z * pc.height + g.y) * pc.width + g.x; | 70 | uint s = pc.scratch_base + (g.z * pc.height + g.y) * pc.width + g.x; |
| 51 | if (pc.to_float != 0u) scratch[s] = floatBitsToUint(depth24_to_float(app[a] & 0xffffffu)); | 71 | if (pc.to_float != 0u) scratch[s] = floatBitsToUint(depth24_to_float(app[a] & 0xffffffu)); |