upleb.uk

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

summaryrefslogtreecommitdiff
path: root/runtime/src/depth24_convert.comp
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/src/depth24_convert.comp')
-rw-r--r--runtime/src/depth24_convert.comp22
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
12layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in; 17layout(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
17layout(push_constant) uniform Push { 22layout(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) {
46void main() { 51void 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));