From f3eb38cca96a3463fa50a564dbc0ee5fe7bb55d3 Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Fri, 23 Oct 2026 10:54:50 +0300 Subject: [PATCH] Port the half NaN storage writes into conformance cases Content: the tree of `development` at 57d58cfc0e, unchanged. --- .../recordings/half-write-nans-r16f.json | 269 ++++++++++++++ .../recordings/half-write-nans-r32f.json | 269 ++++++++++++++ .../recordings/half-write-nans-rg11b10f.json | 269 ++++++++++++++ .../recordings/half-write-nans-rg16f.json | 269 ++++++++++++++ .../recordings/half-write-nans-rg32f.json | 269 ++++++++++++++ .../recordings/half-write-nans-rgba16f.json | 269 ++++++++++++++ .../recordings/half-write-nans-rgba32f.json | 269 ++++++++++++++ crates/metal2vulkan-conformance/src/cases.rs | 4 + .../src/cases/half_write_nans.rs | 333 ++++++++++++++++++ 9 files changed, 2220 insertions(+) create mode 100644 crates/metal2vulkan-conformance/recordings/half-write-nans-r16f.json create mode 100644 crates/metal2vulkan-conformance/recordings/half-write-nans-r32f.json create mode 100644 crates/metal2vulkan-conformance/recordings/half-write-nans-rg11b10f.json create mode 100644 crates/metal2vulkan-conformance/recordings/half-write-nans-rg16f.json create mode 100644 crates/metal2vulkan-conformance/recordings/half-write-nans-rg32f.json create mode 100644 crates/metal2vulkan-conformance/recordings/half-write-nans-rgba16f.json create mode 100644 crates/metal2vulkan-conformance/recordings/half-write-nans-rgba32f.json create mode 100644 crates/metal2vulkan-conformance/src/cases/half_write_nans.rs diff --git a/crates/metal2vulkan-conformance/recordings/half-write-nans-r16f.json b/crates/metal2vulkan-conformance/recordings/half-write-nans-r16f.json new file mode 100644 index 000000000..47ad6a63a --- /dev/null +++ b/crates/metal2vulkan-conformance/recordings/half-write-nans-r16f.json @@ -0,0 +1,269 @@ +{ + "format": 1, + "case": "half-write-nans-r16f", + "suite_version": 1, + "shaders": [ + { + "fixture": "xr_two_planes.ll", + "entry": "xr2p_write_half", + "source_sha256": "305db9bdf0064ff785c347dd6208391a9c302c284cac61ecae4fbc7128877844" + }, + { + "fixture": "xr_two_planes.air.ll", + "entry": "xr2p_write_half", + "source_sha256": "ae50a7261f3dc11bc2b8e6b9ccce82e0907b13e8183e3474239452f538d397a7" + } + ], + "answers": [ + { + "key": { + "chip": "apple-m3-max", + "os_version": "27.0.1", + "os_build": "26A434", + "metal_level": "27.0.1" + }, + "provenance": "metal_run", + "device": "Apple M3 Max", + "runs": 3, + "outcomes": [ + { + "runs": 3, + "transcript": { + "root": { + "name": "case", + "observed": { + "value": "absent" + }, + "children": [ + { + "name": "inputs", + "observed": { + "value": "absent" + }, + "children": [ + { + "name": "air", + "observed": { + "value": "absent", + "digest": { + "kind": "sha256", + "hex": "305db9bdf0064ff785c347dd6208391a9c302c284cac61ecae4fbc7128877844" + } + } + }, + { + "name": "air-typed", + "observed": { + "value": "absent", + "digest": { + "kind": "sha256", + "hex": "ae50a7261f3dc11bc2b8e6b9ccce82e0907b13e8183e3474239452f538d397a7" + } + } + }, + { + "name": "format", + "observed": { + "value": "absent", + "digest": { + "kind": "sha256", + "hex": "0623ccb9b1619bd388284a438034d8cb6431964ba727d8b1c450303105735488" + } + } + }, + { + "name": "buffer:0", + "observed": { + "value": "absent", + "digest": { + "kind": "sha256", + "hex": "90355e56d93316913e1c14d865ed1e41e49c6067385791e6e350e0a94bc143ed" + } + } + }, + { + "name": "buffer:1", + "observed": { + "value": "absent", + "digest": { + "kind": "sha256", + "hex": "0623ccb9b1619bd388284a438034d8cb6431964ba727d8b1c450303105735488" + } + } + }, + { + "name": "texture:blank", + "observed": { + "value": "absent", + "digest": { + "kind": "sha256", + "hex": "968787d8bc08027fa907c8a1906c9178699ab939978caff86c31a98bee5138bd" + } + } + } + ] + }, + { + "name": "library", + "observed": { + "value": { + "variant": { + "name": "Ok", + "payload": "absent" + } + } + } + }, + { + "name": "pipeline", + "observed": { + "value": { + "variant": { + "name": "Ok", + "payload": "absent" + } + } + } + }, + { + "name": "buffer/0", + "observed": { + "value": { + "variant": { + "name": "Ok", + "payload": "absent" + } + } + } + }, + { + "name": "buffer/1", + "observed": { + "value": { + "variant": { + "name": "Ok", + "payload": "absent" + } + } + } + }, + { + "name": "texture", + "observed": { + "value": { + "variant": { + "name": "Ok", + "payload": "absent" + } + } + } + }, + { + "name": "dispatch", + "observed": { + "value": { + "variant": { + "name": "Ok", + "payload": "absent" + } + } + } + }, + { + "name": "status", + "observed": { + "value": { + "variant": { + "name": "Ok", + "payload": { + "variant": { + "name": "Completed", + "payload": "absent" + } + } + } + } + } + }, + { + "name": "read-back", + "observed": { + "value": { + "variant": { + "name": "Ok", + "payload": "absent" + } + } + } + }, + { + "name": "stored", + "observed": { + "value": { + "bytes": "AH4BfjB//39VfgF8SX0wff99gHwA/gH+//8B/En9//0AfAD8AAAAgAEAAYD/AwA8/3s=" + }, + "shape": { + "bytes": { + "region": { + "texture": { + "level": 0, + "slice": 0, + "aspect": "color", + "sample": 0, + "origin": [ + 0, + 0, + 0 + ], + "size": [ + 25, + 1, + 1 + ] + } + }, + "element": "u16", + "row_offset": 0, + "row_elements": 25, + "row_pitch": 50, + "rows": 1, + "image_pitch": 50, + "images": 1, + "gaps": "ignored" + } + } + } + }, + { + "name": "notices", + "observed": { + "value": "absent" + }, + "children": [ + { + "name": "set", + "observed": { + "value": { + "nothing": "announced_nothing" + } + } + }, + { + "name": "counts", + "observed": { + "value": { + "fields": {} + } + } + } + ] + } + ] + } + } + } + ], + "validated": "ran" + } + ] +} diff --git a/crates/metal2vulkan-conformance/recordings/half-write-nans-r32f.json b/crates/metal2vulkan-conformance/recordings/half-write-nans-r32f.json new file mode 100644 index 000000000..77c439549 --- /dev/null +++ b/crates/metal2vulkan-conformance/recordings/half-write-nans-r32f.json @@ -0,0 +1,269 @@ +{ + "format": 1, + "case": "half-write-nans-r32f", + "suite_version": 1, + "shaders": [ + { + "fixture": "xr_two_planes.ll", + "entry": "xr2p_write_half", + "source_sha256": "305db9bdf0064ff785c347dd6208391a9c302c284cac61ecae4fbc7128877844" + }, + { + "fixture": "xr_two_planes.air.ll", + "entry": "xr2p_write_half", + "source_sha256": "ae50a7261f3dc11bc2b8e6b9ccce82e0907b13e8183e3474239452f538d397a7" + } + ], + "answers": [ + { + "key": { + "chip": "apple-m3-max", + "os_version": "27.0.1", + "os_build": "26A434", + "metal_level": "27.0.1" + }, + "provenance": "metal_run", + "device": "Apple M3 Max", + "runs": 3, + "outcomes": [ + { + "runs": 3, + "transcript": { + "root": { + "name": "case", + "observed": { + "value": "absent" + }, + "children": [ + { + "name": "inputs", + "observed": { + "value": "absent" + }, + "children": [ + { + "name": "air", + "observed": { + "value": "absent", + "digest": { + "kind": "sha256", + "hex": "305db9bdf0064ff785c347dd6208391a9c302c284cac61ecae4fbc7128877844" + } + } + }, + { + "name": "air-typed", + "observed": { + "value": "absent", + "digest": { + "kind": "sha256", + "hex": "ae50a7261f3dc11bc2b8e6b9ccce82e0907b13e8183e3474239452f538d397a7" + } + } + }, + { + "name": "format", + "observed": { + "value": "absent", + "digest": { + "kind": "sha256", + "hex": "e2733b3db9d93b0ac4e656aa12b839b92d1b7e1a4c5d97c74cb05c700672cc87" + } + } + }, + { + "name": "buffer:0", + "observed": { + "value": "absent", + "digest": { + "kind": "sha256", + "hex": "90355e56d93316913e1c14d865ed1e41e49c6067385791e6e350e0a94bc143ed" + } + } + }, + { + "name": "buffer:1", + "observed": { + "value": "absent", + "digest": { + "kind": "sha256", + "hex": "0623ccb9b1619bd388284a438034d8cb6431964ba727d8b1c450303105735488" + } + } + }, + { + "name": "texture:blank", + "observed": { + "value": "absent", + "digest": { + "kind": "sha256", + "hex": "bfca652f5e96a3de2157627a800b350e7798ded367fb74a7eb52ef0aa35d9cfb" + } + } + } + ] + }, + { + "name": "library", + "observed": { + "value": { + "variant": { + "name": "Ok", + "payload": "absent" + } + } + } + }, + { + "name": "pipeline", + "observed": { + "value": { + "variant": { + "name": "Ok", + "payload": "absent" + } + } + } + }, + { + "name": "buffer/0", + "observed": { + "value": { + "variant": { + "name": "Ok", + "payload": "absent" + } + } + } + }, + { + "name": "buffer/1", + "observed": { + "value": { + "variant": { + "name": "Ok", + "payload": "absent" + } + } + } + }, + { + "name": "texture", + "observed": { + "value": { + "variant": { + "name": "Ok", + "payload": "absent" + } + } + } + }, + { + "name": "dispatch", + "observed": { + "value": { + "variant": { + "name": "Ok", + "payload": "absent" + } + } + } + }, + { + "name": "status", + "observed": { + "value": { + "variant": { + "name": "Ok", + "payload": { + "variant": { + "name": "Completed", + "payload": "absent" + } + } + } + } + } + }, + { + "name": "read-back", + "observed": { + "value": { + "variant": { + "name": "Ok", + "payload": "absent" + } + } + } + }, + { + "name": "stored", + "observed": { + "value": { + "bytes": "AADAfwAAwH8AAMB/AADAfwAAwH8AAMB/AADAfwAAwH8AAMB/AADAfwAAwH8AAMB/AADAfwAAwH8AAMB/AADAfwAAgH8AAID/AAAAAAAAAIAAAIAzAACAswDAfzgAAIA/AOB/Rw==" + }, + "shape": { + "bytes": { + "region": { + "texture": { + "level": 0, + "slice": 0, + "aspect": "color", + "sample": 0, + "origin": [ + 0, + 0, + 0 + ], + "size": [ + 25, + 1, + 1 + ] + } + }, + "element": "u32", + "row_offset": 0, + "row_elements": 25, + "row_pitch": 100, + "rows": 1, + "image_pitch": 100, + "images": 1, + "gaps": "ignored" + } + } + } + }, + { + "name": "notices", + "observed": { + "value": "absent" + }, + "children": [ + { + "name": "set", + "observed": { + "value": { + "nothing": "announced_nothing" + } + } + }, + { + "name": "counts", + "observed": { + "value": { + "fields": {} + } + } + } + ] + } + ] + } + } + } + ], + "validated": "ran" + } + ] +} diff --git a/crates/metal2vulkan-conformance/recordings/half-write-nans-rg11b10f.json b/crates/metal2vulkan-conformance/recordings/half-write-nans-rg11b10f.json new file mode 100644 index 000000000..0ed4b5074 --- /dev/null +++ b/crates/metal2vulkan-conformance/recordings/half-write-nans-rg11b10f.json @@ -0,0 +1,269 @@ +{ + "format": 1, + "case": "half-write-nans-rg11b10f", + "suite_version": 1, + "shaders": [ + { + "fixture": "xr_two_planes.ll", + "entry": "xr2p_write_half", + "source_sha256": "305db9bdf0064ff785c347dd6208391a9c302c284cac61ecae4fbc7128877844" + }, + { + "fixture": "xr_two_planes.air.ll", + "entry": "xr2p_write_half", + "source_sha256": "ae50a7261f3dc11bc2b8e6b9ccce82e0907b13e8183e3474239452f538d397a7" + } + ], + "answers": [ + { + "key": { + "chip": "apple-m3-max", + "os_version": "27.0.1", + "os_build": "26A434", + "metal_level": "27.0.1" + }, + "provenance": "metal_run", + "device": "Apple M3 Max", + "runs": 3, + "outcomes": [ + { + "runs": 3, + "transcript": { + "root": { + "name": "case", + "observed": { + "value": "absent" + }, + "children": [ + { + "name": "inputs", + "observed": { + "value": "absent" + }, + "children": [ + { + "name": "air", + "observed": { + "value": "absent", + "digest": { + "kind": "sha256", + "hex": "305db9bdf0064ff785c347dd6208391a9c302c284cac61ecae4fbc7128877844" + } + } + }, + { + "name": "air-typed", + "observed": { + "value": "absent", + "digest": { + "kind": "sha256", + "hex": "ae50a7261f3dc11bc2b8e6b9ccce82e0907b13e8183e3474239452f538d397a7" + } + } + }, + { + "name": "format", + "observed": { + "value": "absent", + "digest": { + "kind": "sha256", + "hex": "b7fc02907b1fe26a09f41a20cbcb2899ecd2b028a973d1997530873bcd349966" + } + } + }, + { + "name": "buffer:0", + "observed": { + "value": "absent", + "digest": { + "kind": "sha256", + "hex": "90355e56d93316913e1c14d865ed1e41e49c6067385791e6e350e0a94bc143ed" + } + } + }, + { + "name": "buffer:1", + "observed": { + "value": "absent", + "digest": { + "kind": "sha256", + "hex": "0623ccb9b1619bd388284a438034d8cb6431964ba727d8b1c450303105735488" + } + } + }, + { + "name": "texture:blank", + "observed": { + "value": "absent", + "digest": { + "kind": "sha256", + "hex": "bfca652f5e96a3de2157627a800b350e7798ded367fb74a7eb52ef0aa35d9cfb" + } + } + } + ] + }, + { + "name": "library", + "observed": { + "value": { + "variant": { + "name": "Ok", + "payload": "absent" + } + } + } + }, + { + "name": "pipeline", + "observed": { + "value": { + "variant": { + "name": "Ok", + "payload": "absent" + } + } + } + }, + { + "name": "buffer/0", + "observed": { + "value": { + "variant": { + "name": "Ok", + "payload": "absent" + } + } + } + }, + { + "name": "buffer/1", + "observed": { + "value": { + "variant": { + "name": "Ok", + "payload": "absent" + } + } + } + }, + { + "name": "texture", + "observed": { + "value": { + "variant": { + "name": "Ok", + "payload": "absent" + } + } + } + }, + { + "name": "dispatch", + "observed": { + "value": { + "variant": { + "name": "Ok", + "payload": "absent" + } + } + } + }, + { + "name": "status", + "observed": { + "value": { + "variant": { + "name": "Ok", + "payload": { + "variant": { + "name": "Completed", + "payload": "absent" + } + } + } + } + } + }, + { + "name": "read-back", + "observed": { + "value": { + "variant": { + "name": "Ok", + "payload": "absent" + } + } + } + }, + { + "name": "stored", + "observed": { + "value": { + "bytes": "4Ac//OAHP/zgBz/84Ac//OAHP/zgBz/84Ac//OAHP/zgBz/84Ac//OAHP/zgBz/84Ac//OAHP/zgBz/44Ac+AMAHAAAAAAAAAAAAAAAAAAAAAMAHAPgBeD8A3vfA+z38vwc//A==" + }, + "shape": { + "bytes": { + "region": { + "texture": { + "level": 0, + "slice": 0, + "aspect": "color", + "sample": 0, + "origin": [ + 0, + 0, + 0 + ], + "size": [ + 25, + 1, + 1 + ] + } + }, + "element": "u32", + "row_offset": 0, + "row_elements": 25, + "row_pitch": 100, + "rows": 1, + "image_pitch": 100, + "images": 1, + "gaps": "ignored" + } + } + } + }, + { + "name": "notices", + "observed": { + "value": "absent" + }, + "children": [ + { + "name": "set", + "observed": { + "value": { + "nothing": "announced_nothing" + } + } + }, + { + "name": "counts", + "observed": { + "value": { + "fields": {} + } + } + } + ] + } + ] + } + } + } + ], + "validated": "ran" + } + ] +} diff --git a/crates/metal2vulkan-conformance/recordings/half-write-nans-rg16f.json b/crates/metal2vulkan-conformance/recordings/half-write-nans-rg16f.json new file mode 100644 index 000000000..5889004c3 --- /dev/null +++ b/crates/metal2vulkan-conformance/recordings/half-write-nans-rg16f.json @@ -0,0 +1,269 @@ +{ + "format": 1, + "case": "half-write-nans-rg16f", + "suite_version": 1, + "shaders": [ + { + "fixture": "xr_two_planes.ll", + "entry": "xr2p_write_half", + "source_sha256": "305db9bdf0064ff785c347dd6208391a9c302c284cac61ecae4fbc7128877844" + }, + { + "fixture": "xr_two_planes.air.ll", + "entry": "xr2p_write_half", + "source_sha256": "ae50a7261f3dc11bc2b8e6b9ccce82e0907b13e8183e3474239452f538d397a7" + } + ], + "answers": [ + { + "key": { + "chip": "apple-m3-max", + "os_version": "27.0.1", + "os_build": "26A434", + "metal_level": "27.0.1" + }, + "provenance": "metal_run", + "device": "Apple M3 Max", + "runs": 3, + "outcomes": [ + { + "runs": 3, + "transcript": { + "root": { + "name": "case", + "observed": { + "value": "absent" + }, + "children": [ + { + "name": "inputs", + "observed": { + "value": "absent" + }, + "children": [ + { + "name": "air", + "observed": { + "value": "absent", + "digest": { + "kind": "sha256", + "hex": "305db9bdf0064ff785c347dd6208391a9c302c284cac61ecae4fbc7128877844" + } + } + }, + { + "name": "air-typed", + "observed": { + "value": "absent", + "digest": { + "kind": "sha256", + "hex": "ae50a7261f3dc11bc2b8e6b9ccce82e0907b13e8183e3474239452f538d397a7" + } + } + }, + { + "name": "format", + "observed": { + "value": "absent", + "digest": { + "kind": "sha256", + "hex": "daaf62de76f04e09a55d751f98b97c440bd2dba3f4d9d55a6e93ce8446266f92" + } + } + }, + { + "name": "buffer:0", + "observed": { + "value": "absent", + "digest": { + "kind": "sha256", + "hex": "90355e56d93316913e1c14d865ed1e41e49c6067385791e6e350e0a94bc143ed" + } + } + }, + { + "name": "buffer:1", + "observed": { + "value": "absent", + "digest": { + "kind": "sha256", + "hex": "0623ccb9b1619bd388284a438034d8cb6431964ba727d8b1c450303105735488" + } + } + }, + { + "name": "texture:blank", + "observed": { + "value": "absent", + "digest": { + "kind": "sha256", + "hex": "bfca652f5e96a3de2157627a800b350e7798ded367fb74a7eb52ef0aa35d9cfb" + } + } + } + ] + }, + { + "name": "library", + "observed": { + "value": { + "variant": { + "name": "Ok", + "payload": "absent" + } + } + } + }, + { + "name": "pipeline", + "observed": { + "value": { + "variant": { + "name": "Ok", + "payload": "absent" + } + } + } + }, + { + "name": "buffer/0", + "observed": { + "value": { + "variant": { + "name": "Ok", + "payload": "absent" + } + } + } + }, + { + "name": "buffer/1", + "observed": { + "value": { + "variant": { + "name": "Ok", + "payload": "absent" + } + } + } + }, + { + "name": "texture", + "observed": { + "value": { + "variant": { + "name": "Ok", + "payload": "absent" + } + } + } + }, + { + "name": "dispatch", + "observed": { + "value": { + "variant": { + "name": "Ok", + "payload": "absent" + } + } + } + }, + { + "name": "status", + "observed": { + "value": { + "variant": { + "name": "Ok", + "payload": { + "variant": { + "name": "Completed", + "payload": "absent" + } + } + } + } + } + }, + { + "name": "read-back", + "observed": { + "value": { + "variant": { + "name": "Ok", + "payload": "absent" + } + } + } + }, + { + "name": "stored", + "observed": { + "value": { + "bytes": "AH4BfgF+MH8wf/9//39VflV+AXwBfEl9SX0wfTB9/33/fYB8gHwA/gD+Af4B/v////8B/AH8Sf1J/f/9//0AfAB8APwA/AAAAAAAgACAAQABAAGAAYD/A/8DADwAPP97/3sAfg==" + }, + "shape": { + "bytes": { + "region": { + "texture": { + "level": 0, + "slice": 0, + "aspect": "color", + "sample": 0, + "origin": [ + 0, + 0, + 0 + ], + "size": [ + 25, + 1, + 1 + ] + } + }, + "element": "u16", + "row_offset": 0, + "row_elements": 50, + "row_pitch": 100, + "rows": 1, + "image_pitch": 100, + "images": 1, + "gaps": "ignored" + } + } + } + }, + { + "name": "notices", + "observed": { + "value": "absent" + }, + "children": [ + { + "name": "set", + "observed": { + "value": { + "nothing": "announced_nothing" + } + } + }, + { + "name": "counts", + "observed": { + "value": { + "fields": {} + } + } + } + ] + } + ] + } + } + } + ], + "validated": "ran" + } + ] +} diff --git a/crates/metal2vulkan-conformance/recordings/half-write-nans-rg32f.json b/crates/metal2vulkan-conformance/recordings/half-write-nans-rg32f.json new file mode 100644 index 000000000..66281c85e --- /dev/null +++ b/crates/metal2vulkan-conformance/recordings/half-write-nans-rg32f.json @@ -0,0 +1,269 @@ +{ + "format": 1, + "case": "half-write-nans-rg32f", + "suite_version": 1, + "shaders": [ + { + "fixture": "xr_two_planes.ll", + "entry": "xr2p_write_half", + "source_sha256": "305db9bdf0064ff785c347dd6208391a9c302c284cac61ecae4fbc7128877844" + }, + { + "fixture": "xr_two_planes.air.ll", + "entry": "xr2p_write_half", + "source_sha256": "ae50a7261f3dc11bc2b8e6b9ccce82e0907b13e8183e3474239452f538d397a7" + } + ], + "answers": [ + { + "key": { + "chip": "apple-m3-max", + "os_version": "27.0.1", + "os_build": "26A434", + "metal_level": "27.0.1" + }, + "provenance": "metal_run", + "device": "Apple M3 Max", + "runs": 3, + "outcomes": [ + { + "runs": 3, + "transcript": { + "root": { + "name": "case", + "observed": { + "value": "absent" + }, + "children": [ + { + "name": "inputs", + "observed": { + "value": "absent" + }, + "children": [ + { + "name": "air", + "observed": { + "value": "absent", + "digest": { + "kind": "sha256", + "hex": "305db9bdf0064ff785c347dd6208391a9c302c284cac61ecae4fbc7128877844" + } + } + }, + { + "name": "air-typed", + "observed": { + "value": "absent", + "digest": { + "kind": "sha256", + "hex": "ae50a7261f3dc11bc2b8e6b9ccce82e0907b13e8183e3474239452f538d397a7" + } + } + }, + { + "name": "format", + "observed": { + "value": "absent", + "digest": { + "kind": "sha256", + "hex": "4a11c2997424cd7a381eca1948dd4c442cb4b2a8086b676ecf67eff032eaacec" + } + } + }, + { + "name": "buffer:0", + "observed": { + "value": "absent", + "digest": { + "kind": "sha256", + "hex": "90355e56d93316913e1c14d865ed1e41e49c6067385791e6e350e0a94bc143ed" + } + } + }, + { + "name": "buffer:1", + "observed": { + "value": "absent", + "digest": { + "kind": "sha256", + "hex": "0623ccb9b1619bd388284a438034d8cb6431964ba727d8b1c450303105735488" + } + } + }, + { + "name": "texture:blank", + "observed": { + "value": "absent", + "digest": { + "kind": "sha256", + "hex": "f12bda299b22b57f431e70d83967358382982db262504c395bb5bbd6a13fe0b5" + } + } + } + ] + }, + { + "name": "library", + "observed": { + "value": { + "variant": { + "name": "Ok", + "payload": "absent" + } + } + } + }, + { + "name": "pipeline", + "observed": { + "value": { + "variant": { + "name": "Ok", + "payload": "absent" + } + } + } + }, + { + "name": "buffer/0", + "observed": { + "value": { + "variant": { + "name": "Ok", + "payload": "absent" + } + } + } + }, + { + "name": "buffer/1", + "observed": { + "value": { + "variant": { + "name": "Ok", + "payload": "absent" + } + } + } + }, + { + "name": "texture", + "observed": { + "value": { + "variant": { + "name": "Ok", + "payload": "absent" + } + } + } + }, + { + "name": "dispatch", + "observed": { + "value": { + "variant": { + "name": "Ok", + "payload": "absent" + } + } + } + }, + { + "name": "status", + "observed": { + "value": { + "variant": { + "name": "Ok", + "payload": { + "variant": { + "name": "Completed", + "payload": "absent" + } + } + } + } + } + }, + { + "name": "read-back", + "observed": { + "value": { + "variant": { + "name": "Ok", + "payload": "absent" + } + } + } + }, + { + "name": "stored", + "observed": { + "value": { + "bytes": "AADAfwAAwH8AAMB/AADAfwAAwH8AAMB/AADAfwAAwH8AAMB/AADAfwAAwH8AAMB/AADAfwAAwH8AAMB/AADAfwAAwH8AAMB/AADAfwAAwH8AAMB/AADAfwAAwH8AAMB/AADAfwAAwH8AAMB/AADAfwAAwH8AAMB/AADAfwAAgH8AAIB/AACA/wAAgP8AAAAAAAAAAAAAAIAAAACAAACAMwAAgDMAAICzAACAswDAfzgAwH84AACAPwAAgD8A4H9HAOB/RwAAwH8=" + }, + "shape": { + "bytes": { + "region": { + "texture": { + "level": 0, + "slice": 0, + "aspect": "color", + "sample": 0, + "origin": [ + 0, + 0, + 0 + ], + "size": [ + 25, + 1, + 1 + ] + } + }, + "element": "u32", + "row_offset": 0, + "row_elements": 50, + "row_pitch": 200, + "rows": 1, + "image_pitch": 200, + "images": 1, + "gaps": "ignored" + } + } + } + }, + { + "name": "notices", + "observed": { + "value": "absent" + }, + "children": [ + { + "name": "set", + "observed": { + "value": { + "nothing": "announced_nothing" + } + } + }, + { + "name": "counts", + "observed": { + "value": { + "fields": {} + } + } + } + ] + } + ] + } + } + } + ], + "validated": "ran" + } + ] +} diff --git a/crates/metal2vulkan-conformance/recordings/half-write-nans-rgba16f.json b/crates/metal2vulkan-conformance/recordings/half-write-nans-rgba16f.json new file mode 100644 index 000000000..d4181c7fc --- /dev/null +++ b/crates/metal2vulkan-conformance/recordings/half-write-nans-rgba16f.json @@ -0,0 +1,269 @@ +{ + "format": 1, + "case": "half-write-nans-rgba16f", + "suite_version": 1, + "shaders": [ + { + "fixture": "xr_two_planes.ll", + "entry": "xr2p_write_half", + "source_sha256": "305db9bdf0064ff785c347dd6208391a9c302c284cac61ecae4fbc7128877844" + }, + { + "fixture": "xr_two_planes.air.ll", + "entry": "xr2p_write_half", + "source_sha256": "ae50a7261f3dc11bc2b8e6b9ccce82e0907b13e8183e3474239452f538d397a7" + } + ], + "answers": [ + { + "key": { + "chip": "apple-m3-max", + "os_version": "27.0.1", + "os_build": "26A434", + "metal_level": "27.0.1" + }, + "provenance": "metal_run", + "device": "Apple M3 Max", + "runs": 3, + "outcomes": [ + { + "runs": 3, + "transcript": { + "root": { + "name": "case", + "observed": { + "value": "absent" + }, + "children": [ + { + "name": "inputs", + "observed": { + "value": "absent" + }, + "children": [ + { + "name": "air", + "observed": { + "value": "absent", + "digest": { + "kind": "sha256", + "hex": "305db9bdf0064ff785c347dd6208391a9c302c284cac61ecae4fbc7128877844" + } + } + }, + { + "name": "air-typed", + "observed": { + "value": "absent", + "digest": { + "kind": "sha256", + "hex": "ae50a7261f3dc11bc2b8e6b9ccce82e0907b13e8183e3474239452f538d397a7" + } + } + }, + { + "name": "format", + "observed": { + "value": "absent", + "digest": { + "kind": "sha256", + "hex": "52e9e3add38bf08350e260942004423cf95fce71609ae1a46b260442db2608bb" + } + } + }, + { + "name": "buffer:0", + "observed": { + "value": "absent", + "digest": { + "kind": "sha256", + "hex": "90355e56d93316913e1c14d865ed1e41e49c6067385791e6e350e0a94bc143ed" + } + } + }, + { + "name": "buffer:1", + "observed": { + "value": "absent", + "digest": { + "kind": "sha256", + "hex": "0623ccb9b1619bd388284a438034d8cb6431964ba727d8b1c450303105735488" + } + } + }, + { + "name": "texture:blank", + "observed": { + "value": "absent", + "digest": { + "kind": "sha256", + "hex": "f12bda299b22b57f431e70d83967358382982db262504c395bb5bbd6a13fe0b5" + } + } + } + ] + }, + { + "name": "library", + "observed": { + "value": { + "variant": { + "name": "Ok", + "payload": "absent" + } + } + } + }, + { + "name": "pipeline", + "observed": { + "value": { + "variant": { + "name": "Ok", + "payload": "absent" + } + } + } + }, + { + "name": "buffer/0", + "observed": { + "value": { + "variant": { + "name": "Ok", + "payload": "absent" + } + } + } + }, + { + "name": "buffer/1", + "observed": { + "value": { + "variant": { + "name": "Ok", + "payload": "absent" + } + } + } + }, + { + "name": "texture", + "observed": { + "value": { + "variant": { + "name": "Ok", + "payload": "absent" + } + } + } + }, + { + "name": "dispatch", + "observed": { + "value": { + "variant": { + "name": "Ok", + "payload": "absent" + } + } + } + }, + { + "name": "status", + "observed": { + "value": { + "variant": { + "name": "Ok", + "payload": { + "variant": { + "name": "Completed", + "payload": "absent" + } + } + } + } + } + }, + { + "name": "read-back", + "observed": { + "value": { + "variant": { + "name": "Ok", + "payload": "absent" + } + } + } + }, + { + "name": "stored", + "observed": { + "value": { + "bytes": "AH4BfjB//38BfjB//39VfjB//39VfgF8/39VfgF8SX1VfgF8SX0wfQF8SX0wff99SX0wff99gHwwff99gHwA/v99gHwA/gH+gHwA/gH+//8A/gH+//8B/AH+//8B/En9//8B/En9//0B/En9//0AfEn9//0AfAD8//0AfAD8AAAAfAD8AAAAgAD8AAAAgAEAAAAAgAEAAYAAgAEAAYD/AwEAAYD/AwA8AYD/AwA8/3v/AwA8/3sAfgA8/3sAfgF+/3sAfgF+MH8=" + }, + "shape": { + "bytes": { + "region": { + "texture": { + "level": 0, + "slice": 0, + "aspect": "color", + "sample": 0, + "origin": [ + 0, + 0, + 0 + ], + "size": [ + 25, + 1, + 1 + ] + } + }, + "element": "u16", + "row_offset": 0, + "row_elements": 100, + "row_pitch": 200, + "rows": 1, + "image_pitch": 200, + "images": 1, + "gaps": "ignored" + } + } + } + }, + { + "name": "notices", + "observed": { + "value": "absent" + }, + "children": [ + { + "name": "set", + "observed": { + "value": { + "nothing": "announced_nothing" + } + } + }, + { + "name": "counts", + "observed": { + "value": { + "fields": {} + } + } + } + ] + } + ] + } + } + } + ], + "validated": "ran" + } + ] +} diff --git a/crates/metal2vulkan-conformance/recordings/half-write-nans-rgba32f.json b/crates/metal2vulkan-conformance/recordings/half-write-nans-rgba32f.json new file mode 100644 index 000000000..3eff885b2 --- /dev/null +++ b/crates/metal2vulkan-conformance/recordings/half-write-nans-rgba32f.json @@ -0,0 +1,269 @@ +{ + "format": 1, + "case": "half-write-nans-rgba32f", + "suite_version": 1, + "shaders": [ + { + "fixture": "xr_two_planes.ll", + "entry": "xr2p_write_half", + "source_sha256": "305db9bdf0064ff785c347dd6208391a9c302c284cac61ecae4fbc7128877844" + }, + { + "fixture": "xr_two_planes.air.ll", + "entry": "xr2p_write_half", + "source_sha256": "ae50a7261f3dc11bc2b8e6b9ccce82e0907b13e8183e3474239452f538d397a7" + } + ], + "answers": [ + { + "key": { + "chip": "apple-m3-max", + "os_version": "27.0.1", + "os_build": "26A434", + "metal_level": "27.0.1" + }, + "provenance": "metal_run", + "device": "Apple M3 Max", + "runs": 3, + "outcomes": [ + { + "runs": 3, + "transcript": { + "root": { + "name": "case", + "observed": { + "value": "absent" + }, + "children": [ + { + "name": "inputs", + "observed": { + "value": "absent" + }, + "children": [ + { + "name": "air", + "observed": { + "value": "absent", + "digest": { + "kind": "sha256", + "hex": "305db9bdf0064ff785c347dd6208391a9c302c284cac61ecae4fbc7128877844" + } + } + }, + { + "name": "air-typed", + "observed": { + "value": "absent", + "digest": { + "kind": "sha256", + "hex": "ae50a7261f3dc11bc2b8e6b9ccce82e0907b13e8183e3474239452f538d397a7" + } + } + }, + { + "name": "format", + "observed": { + "value": "absent", + "digest": { + "kind": "sha256", + "hex": "dd5e8ff17033e3d207902e855fc1f6d5ff1b0b34c5edfb94234d9e86078aca5a" + } + } + }, + { + "name": "buffer:0", + "observed": { + "value": "absent", + "digest": { + "kind": "sha256", + "hex": "90355e56d93316913e1c14d865ed1e41e49c6067385791e6e350e0a94bc143ed" + } + } + }, + { + "name": "buffer:1", + "observed": { + "value": "absent", + "digest": { + "kind": "sha256", + "hex": "0623ccb9b1619bd388284a438034d8cb6431964ba727d8b1c450303105735488" + } + } + }, + { + "name": "texture:blank", + "observed": { + "value": "absent", + "digest": { + "kind": "sha256", + "hex": "e979e31a669e9f6ca11f8a6bf625f659eabdfe12f3fa24f0287744afe1f73f50" + } + } + } + ] + }, + { + "name": "library", + "observed": { + "value": { + "variant": { + "name": "Ok", + "payload": "absent" + } + } + } + }, + { + "name": "pipeline", + "observed": { + "value": { + "variant": { + "name": "Ok", + "payload": "absent" + } + } + } + }, + { + "name": "buffer/0", + "observed": { + "value": { + "variant": { + "name": "Ok", + "payload": "absent" + } + } + } + }, + { + "name": "buffer/1", + "observed": { + "value": { + "variant": { + "name": "Ok", + "payload": "absent" + } + } + } + }, + { + "name": "texture", + "observed": { + "value": { + "variant": { + "name": "Ok", + "payload": "absent" + } + } + } + }, + { + "name": "dispatch", + "observed": { + "value": { + "variant": { + "name": "Ok", + "payload": "absent" + } + } + } + }, + { + "name": "status", + "observed": { + "value": { + "variant": { + "name": "Ok", + "payload": { + "variant": { + "name": "Completed", + "payload": "absent" + } + } + } + } + } + }, + { + "name": "read-back", + "observed": { + "value": { + "variant": { + "name": "Ok", + "payload": "absent" + } + } + } + }, + { + "name": "stored", + "observed": { + "value": { + "bytes": "AADAfwAAwH8AAMB/AADAfwAAwH8AAMB/AADAfwAAwH8AAMB/AADAfwAAwH8AAMB/AADAfwAAwH8AAMB/AADAfwAAwH8AAMB/AADAfwAAwH8AAMB/AADAfwAAwH8AAMB/AADAfwAAwH8AAMB/AADAfwAAwH8AAMB/AADAfwAAwH8AAMB/AADAfwAAwH8AAMB/AADAfwAAwH8AAMB/AADAfwAAwH8AAMB/AADAfwAAwH8AAMB/AADAfwAAwH8AAMB/AADAfwAAwH8AAMB/AADAfwAAwH8AAMB/AADAfwAAgH8AAMB/AADAfwAAgH8AAID/AADAfwAAgH8AAID/AAAAAAAAgH8AAID/AAAAAAAAAIAAAID/AAAAAAAAAIAAAIAzAAAAAAAAAIAAAIAzAACAswAAAIAAAIAzAACAswDAfzgAAIAzAACAswDAfzgAAIA/AACAswDAfzgAAIA/AOB/RwDAfzgAAIA/AOB/RwAAwH8AAIA/AOB/RwAAwH8AAMB/AOB/RwAAwH8AAMB/AADAfw==" + }, + "shape": { + "bytes": { + "region": { + "texture": { + "level": 0, + "slice": 0, + "aspect": "color", + "sample": 0, + "origin": [ + 0, + 0, + 0 + ], + "size": [ + 25, + 1, + 1 + ] + } + }, + "element": "u32", + "row_offset": 0, + "row_elements": 100, + "row_pitch": 400, + "rows": 1, + "image_pitch": 400, + "images": 1, + "gaps": "ignored" + } + } + } + }, + { + "name": "notices", + "observed": { + "value": "absent" + }, + "children": [ + { + "name": "set", + "observed": { + "value": { + "nothing": "announced_nothing" + } + } + }, + { + "name": "counts", + "observed": { + "value": { + "fields": {} + } + } + } + ] + } + ] + } + } + } + ], + "validated": "ran" + } + ] +} diff --git a/crates/metal2vulkan-conformance/src/cases.rs b/crates/metal2vulkan-conformance/src/cases.rs index 586fd3e41..ee9d596c4 100644 --- a/crates/metal2vulkan-conformance/src/cases.rs +++ b/crates/metal2vulkan-conformance/src/cases.rs @@ -28,6 +28,7 @@ pub mod command_queues; pub mod depth_texel_reads; pub mod extended_range_planes; pub mod extended_range_two_planes; +pub mod half_write_nans; pub mod heap_metal_sizes; pub mod indirect_private_types; pub mod math_routines; @@ -85,6 +86,9 @@ pub fn all() -> Vec> { for case in pixel_downscales::all() { cases.push(Box::new(case)); } + for case in half_write_nans::all() { + cases.push(Box::new(case)); + } cases.push(Box::new(texture_buffer_fills::streams())); cases.push(Box::new(texture_buffer_fills::groups())); cases.push(Box::new(texture_buffer_fills::long_fills())); diff --git a/crates/metal2vulkan-conformance/src/cases/half_write_nans.rs b/crates/metal2vulkan-conformance/src/cases/half_write_nans.rs new file mode 100644 index 000000000..2c7afa7e2 --- /dev/null +++ b/crates/metal2vulkan-conformance/src/cases/half_write_nans.rs @@ -0,0 +1,333 @@ +//! A `half4` written to a float storage texture: the bits each format stores. +//! +//! This is where Metal's odd float rules live, so the case records **bits** and compares them +//! exactly: a 16-bit float texel keeps the half's own bits, a signalling NaN's payload included +//! (`0x7d49` stays `0x7d49`); a 32-bit float texel keeps the half's exact widening, but +//! `0x7fc00000` for every NaN, so a signalling NaN's payload is gone and a quiet one's is +//! rewritten; and an `RG11B10Float` texel packs each NaN channel as the format's own canonical NaN. +//! A signed zero is its own code in each. None of that survives a comparison in floats, which is +//! why every site here reads as unsigned words. +//! +//! One case per format, so a format whose storage writes a venue honestly lacks is that venue's gap +//! ([`crate::verdict::Verdict::LacksFeature`]) at its own row rather than a hole in the others. +//! +//! The kernel is the owned fixture `xr_two_planes`'s `xr2p_write_half`, a +//! `texture2d` that writes buffer 0's `half4` at the thread's texel, with the +//! row's width in buffer 1 — the same call shape as the lane's own `write` kernel, and a committed +//! fixture, so Metal's assembler and a host without Metal read the same shader. The lane's two +//! other accesses (a `texture2d`, and a texture an argument buffer holds) +//! have no committed fixture that writes a `half4` from a buffer, so they are not ported; the +//! module docs of `runtime_lane::half_write_nans` record that plain Metal stored the same bits +//! through all three. +//! +//! Every texel of the texture holds [`FILL`] before the dispatch, so a texel the kernel did not +//! reach is a recorded value rather than whatever the allocator left. +//! +//! Nothing here can fault a GPU: one compute pass, one texture, one thread a texel inside it, no +//! loop and no sampling. + +use crate::allowance::Allowance; +use crate::case::{call, made, Abort, Bindings, Case, Failure, Input, MetalSource, Side}; +use crate::fixture::{Fixture, METAL_TEXT, RUNTIME_TEXT}; +use crate::recording::ShaderRef; +use crate::transcript::{ + Aspect, ByteLayout, Digest, Element, Gaps, Node, Observed, Region, Sites, Value, +}; +use metal2vulkan::metal::PixelFormat; +use metal2vulkan_runtime::Degradation; + +/// The fixture the kernel lives in. +const FIXTURE: &str = "xr_two_planes"; + +/// The kernel: `half4` from buffer 0 at the thread's texel, the row's width in buffer 1. +const WRITE: &str = "xr2p_write_half"; + +/// The halves written, in the lane's order: quiet NaNs, signalling NaNs, negative NaNs, then the +/// infinities, the zeros, the denormals and two normals. +/// +/// A signalling NaN is in here on purpose: it is the one input that tells a 16-bit float store +/// (which keeps `0x7d49`) from a 32-bit float one (which rewrites every NaN to `0x7fc00000`). +const V: [u16; 25] = [ + 0x7e00, 0x7e01, 0x7f30, 0x7fff, 0x7e55, // quiet + 0x7c01, 0x7d49, 0x7d30, 0x7dff, 0x7c80, // signalling + 0xfe00, 0xfe01, 0xffff, 0xfc01, 0xfd49, 0xfdff, // negative + 0x7c00, 0xfc00, 0x0000, 0x8000, 0x0001, 0x8001, 0x03ff, 0x3c00, 0x7bff, // controls +]; + +/// The texture's width: one texel per value. +const N: u32 = V.len() as u32; + +/// The byte every texel holds before the kernel runs. +const FILL: u8 = 0xab; + +/// Texel `x`'s four halves: each value at every channel position across the texels, so a store +/// that treated one channel differently from another shows as a texel rather than as a hash. +fn texel(x: usize) -> [u16; 4] { + std::array::from_fn(|channel| V[(x + channel) % V.len()]) +} + +/// Buffer 0's bytes: one `half4` a texel. +fn halves() -> Vec { + (0..V.len()) + .flat_map(texel) + .flat_map(u16::to_le_bytes) + .collect() +} + +/// Buffer 1's bytes: the row's width, as the kernel's `constant uint &w`. +fn width() -> Vec { + N.to_le_bytes().to_vec() +} + +/// A format the case writes: its name, the bytes of one texel, and what one stored word is. +struct Shape { + /// The word a channel is read back as: a 16-bit float format's own half, a 32-bit float one's + /// `float`, and a packed format's whole 32-bit texel. + word: Element, + /// The words one texel holds. + words: u32, +} + +/// The case: one pixel format's stored words. +pub struct HalfWriteNans { + name: &'static str, + format: PixelFormat, + shape: Shape, +} + +/// Every format the lane writes: the three 16-bit float widths, the three 32-bit float widths, and +/// the packed one whose NaN is the format's own. +pub fn all() -> Vec { + let shape = |word, words| Shape { word, words }; + vec![ + HalfWriteNans { + name: "half-write-nans-r16f", + format: PixelFormat::R16Float, + shape: shape(Element::U16, 1), + }, + HalfWriteNans { + name: "half-write-nans-rg16f", + format: PixelFormat::RG16Float, + shape: shape(Element::U16, 2), + }, + HalfWriteNans { + name: "half-write-nans-rgba16f", + format: PixelFormat::RGBA16Float, + shape: shape(Element::U16, 4), + }, + HalfWriteNans { + name: "half-write-nans-r32f", + format: PixelFormat::R32Float, + shape: shape(Element::U32, 1), + }, + HalfWriteNans { + name: "half-write-nans-rg32f", + format: PixelFormat::RG32Float, + shape: shape(Element::U32, 2), + }, + HalfWriteNans { + name: "half-write-nans-rgba32f", + format: PixelFormat::RGBA32Float, + shape: shape(Element::U32, 4), + }, + HalfWriteNans { + name: "half-write-nans-rg11b10f", + format: PixelFormat::RG11B10Float, + shape: shape(Element::U32, 1), + }, + ] +} + +impl HalfWriteNans { + /// The fixture, under the kernel this case runs. + fn fixture() -> Fixture { + Fixture { + name: FIXTURE, + entry: WRITE, + } + } + + /// The bytes one texel of the format takes. + fn texel_bytes(&self) -> u32 { + self.shape.words * self.shape.word.size() + } + + /// The bytes of the whole level, which is also the bytes the case hands in. + fn level_bytes(&self) -> usize { + (N * self.texel_bytes()) as usize + } + + /// The layout the stored texels are read under: one row of unsigned words, so a diff names the + /// word that moved and prints it as the bits Metal stored rather than as a float. + fn layout(&self) -> ByteLayout { + let pitch = N * self.texel_bytes(); + ByteLayout { + region: Region::Texture { + level: 0, + slice: 0, + aspect: Aspect::Color, + sample: 0, + origin: [0, 0, 0], + size: [N, 1, 1], + }, + element: self.shape.word, + row_offset: 0, + row_elements: N * self.shape.words, + row_pitch: pitch, + rows: 1, + image_pitch: pitch, + images: 1, + // The row is the whole level and the words cover every byte of it, so there is no gap. + gaps: Gaps::Ignored, + } + } +} + +impl Case for HalfWriteNans { + fn name(&self) -> &'static str { + self.name + } + + fn metal_source(&self) -> MetalSource { + MetalSource::Run + } + + fn allowances(&self) -> Vec { + // The kernel writes `half` into a storage texture. A device whose half texel writes are not + // Metal's encodes its own way, and the runtime announces that; only the notice set is + // loosened, so every stored word still compares exactly. A device that does encode as Metal + // shows as exact with the allowance unused, and one that does not shows the word it stored + // beside Metal's. The allowance fails the case if the notice stops firing, so it cannot + // outlive its reason. + vec![crate::replay::notice_allowance( + Degradation::DeviceNanEncoding.code(), + )] + } + + fn shaders(&self) -> Result, String> { + let mut shaders = Vec::new(); + for extension in [RUNTIME_TEXT, METAL_TEXT] { + shaders.push(ShaderRef { + fixture: format!("{FIXTURE}{extension}"), + entry: WRITE.to_owned(), + source_sha256: crate::sha256_hex(Self::fixture().text(extension)?.as_bytes()), + }); + } + Ok(shaders) + } + + fn inputs(&self) -> Result, String> { + let fixture = Self::fixture(); + Ok(vec![ + Input { + name: "air".to_owned(), + digest: Digest::sha256(fixture.text(RUNTIME_TEXT)?.as_bytes()), + }, + Input { + name: "air-typed".to_owned(), + digest: Digest::sha256(fixture.text(METAL_TEXT)?.as_bytes()), + }, + // The format is the question the case asks, so a case re-pointed at another one is + // `Unrecorded` rather than compared against the first's words. + Input::bytes("format", &self.format.as_raw().to_le_bytes()), + Input::bytes("buffer:0", &halves()), + Input::bytes("buffer:1", &width()), + // What the texture holds before the dispatch. + Input::bytes("texture:blank", &vec![FILL; self.level_bytes()]), + ]) + } + + fn run(&self, side: &mut dyn Side, sites: &mut Sites) -> Result<(), Abort> { + let loaded = Self::fixture().loaded().map_err(|why| Abort { + at: "library".to_owned(), + failure: Failure::named("FixtureNotRead", why), + })?; + let library = made(sites, "library", side.library(&loaded.source()))?; + let pipeline = made( + sites, + "pipeline", + side.compute_pipeline(library, loaded.entry), + )?; + let values = made(sites, "buffer/0", side.buffer(&halves()))?; + let shape = made(sites, "buffer/1", side.buffer(&width()))?; + let pitch = N * self.texel_bytes(); + let texture = made( + sites, + "texture", + side.texture_2d(self.format, [N, 1], pitch, &vec![FILL; self.level_bytes()]), + )?; + let command_buffer = made( + sites, + "dispatch", + side.dispatch_threads( + pipeline, + &Bindings::new(&[texture], &[values, shape]), + &[], + [N, 1, 1], + [N, 1, 1], + ), + )?; + call(sites, "status", side.wait(command_buffer), Clone::clone)?; + let stored = call( + sites, + "read-back", + side.read_texture(texture, [N, 1], pitch), + |_| Value::Absent, + )?; + sites.push(Node::leaf("stored", Observed::bytes(stored, self.layout()))); + Ok(()) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use std::collections::BTreeSet; + + /// Each case's layout covers exactly the bytes its texture holds: a layout that reached further + /// would read past the level, and one that stopped short would leave stored words uncompared. + #[test] + fn every_layout_covers_its_whole_level() { + for case in all() { + assert_eq!( + case.layout().extent(), + case.level_bytes(), + "{}: its layout reaches {} of {} bytes", + case.name, + case.layout().extent(), + case.level_bytes() + ); + } + } + + /// The cases name distinct rows and distinct formats, so no two share a recording. + #[test] + fn the_cases_name_distinct_formats() { + let named: BTreeSet<&str> = all().iter().map(|case| case.name).collect(); + let formats: BTreeSet = all().iter().map(|case| case.format.as_raw()).collect(); + assert_eq!(named.len(), all().len()); + assert_eq!(formats.len(), all().len()); + } + + /// The input the whole family turns on: a signalling NaN, whose payload a 16-bit float store + /// keeps and a 32-bit one rewrites. A sweep that lost it would compare NaN handling without + /// asking the one question that separates the formats. + #[test] + fn the_values_hold_a_signalling_nan_and_both_zeros() { + let signalling = V + .iter() + .filter(|&&bits| bits & 0x7c00 == 0x7c00 && bits & 0x3ff != 0 && bits & 0x200 == 0) + .count(); + assert!(signalling >= 2, "{signalling} signalling NaNs"); + assert!(V.contains(&0x0000) && V.contains(&0x8000), "both zeros"); + } + + /// Every texel holds its own four halves, so a store that mixed two texels up could not pass, + /// and the buffer is one `half4` a texel. + #[test] + fn every_texel_is_its_own_word() { + let distinct: BTreeSet<[u16; 4]> = (0..V.len()).map(texel).collect(); + assert_eq!(distinct.len(), V.len()); + assert_eq!(halves().len(), V.len() * 8); + } +}