diff options
| author | Vonsek <45567075+Vonsek@users.noreply.github.com> | 2026-11-22 10:00:25 +0100 |
|---|---|---|
| committer | Vonsek <45567075+Vonsek@users.noreply.github.com> | 2026-11-22 10:00:25 +0100 |
| commit | 23962cb6d683d0c87a1d2d2a0ba91c243013c163 (patch) | |
| tree | bf88d8b0eab9d4a3b3c3cc97adde79e1fb3ac72f /runtime/src/depth24_convert.comp | |
| parent | 426023a585b47ba04509d5f3e5e52d6ae40e1109 (diff) | |
fix(runtime): classify D24 readback depth from its raw bits
Intel UHD 770 reports maximum depth for NaNs in the float comparison path. Check the input encoding before rounding finite values and exercise both signs of every NaN payload on the GPU.
Diffstat (limited to 'runtime/src/depth24_convert.comp')
| -rw-r--r-- | runtime/src/depth24_convert.comp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/runtime/src/depth24_convert.comp b/runtime/src/depth24_convert.comp index eb4795a35..688f68d78 100644 --- a/runtime/src/depth24_convert.comp +++ b/runtime/src/depth24_convert.comp | |||
| @@ -36,10 +36,11 @@ float depth24_to_float(uint d) { | |||
| 36 | // The 24-bit UNORM of f as WARP and AMD's D3D12 drivers write it: the product with 2^24 - 1 is rounded to a float | 36 | // The 24-bit UNORM of f as WARP and AMD's D3D12 drivers write it: the product with 2^24 - 1 is rounded to a float |
| 37 | // first, then to the nearest integer with ties to even (NVIDIA's hardware breaks some ties the other way; see | 37 | // first, then to the nearest integer with ties to even (NVIDIA's hardware breaks some ties the other way; see |
| 38 | // depth24.h). NaN and negatives give 0, 1 and above the maximum. | 38 | // depth24.h). NaN and negatives give 0, 1 and above the maximum. |
| 39 | uint depth24_from_float(float f) { | 39 | uint depth24_from_bits(uint bits) { |
| 40 | if (!(f > 0.0)) return 0u; | 40 | // In unsigned order, all negative encodings and positive NaNs lie above positive infinity. |
| 41 | if (f >= 1.0) return 0xffffffu; | 41 | if (bits > 0x7f800000u) return 0u; |
| 42 | return uint(roundEven(f * 16777215.0)); | 42 | if (bits >= 0x3f800000u) return 0xffffffu; |
| 43 | return uint(roundEven(uintBitsToFloat(bits) * 16777215.0)); | ||
| 43 | } | 44 | } |
| 44 | 45 | ||
| 45 | void main() { | 46 | void main() { |
| @@ -48,5 +49,5 @@ void main() { | |||
| 48 | uint a = pc.app_base + g.z * pc.app_slice + g.y * pc.app_row + g.x; | 49 | uint a = pc.app_base + g.z * pc.app_slice + g.y * pc.app_row + g.x; |
| 49 | uint s = pc.scratch_base + (g.z * pc.height + g.y) * pc.width + g.x; | 50 | uint s = pc.scratch_base + (g.z * pc.height + g.y) * pc.width + g.x; |
| 50 | if (pc.to_float != 0u) scratch[s] = floatBitsToUint(depth24_to_float(app[a] & 0xffffffu)); | 51 | if (pc.to_float != 0u) scratch[s] = floatBitsToUint(depth24_to_float(app[a] & 0xffffffu)); |
| 51 | else app[a] = depth24_from_float(uintBitsToFloat(scratch[s])); | 52 | else app[a] = depth24_from_bits(scratch[s]); |
| 52 | } | 53 | } |