From bd3c50d7417056b079d138741e66eb24636ea239 Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Wed, 28 Oct 2026 21:00:56 +0200 Subject: [PATCH] Take the device's own Depth16 bias and its store of an extended-range, padded or bfloat attachment's untouched texels The device's depth bias unit on every format, and the device's store of untouched texels in place of the unused-bits load pass (deleted with its capture machinery); the NaN depth discard documented as capability. SEMANTICS 1910, RUNTIME 1682. One work packet, landed as 7 commit(s) (88bcfeaea8..6aec9db4e9 on archive/development-linear-2026-10-28-evening), in order: * Take the device's depth bias on a Depth16Unorm depth Rule 1: the device's depth bias is its native form, so it is the only one. A constant bias (or a slope alone) on a Depth16Unorm depth was recorded through VK_EXT_depth_bias_control's depthBiasExact as Metal's own rule, c + 1 units of 1/65535 for c of 0 or more and c - 1 below (one unit for a slope alone), in depth (floatRepresentation) or in 2^-16. Now `metal::state::depth_bias` hands Metal's constant to vkCmdSetDepthBias in the device's own unit r on every depth format; Vulkan leaves a fixed-point format's r to the implementation, at most 2 x 2^-16 ("Depth Bias", primsrast.adoc). Deleted, nothing reading them any more: `depth16_units`, `DepthBiasUnit` and `DepthBias::unit`, the `depth_format` parameter of `depth_bias` and of the runtime's `vk_depth_bias`; the runtime's vkCmdSetDepthBias2EXT path (`DepthBiasCommand`, `depth_bias_command`, the record's pinned representation, the device's command, its priming and `DEPTH_BIAS_CALLS`, the exit guard's and recorder's `CmdSetDepthBias2`, `Logged::SetDepthBias2` and its thunk, so `CommandsReplayed::cmd_set_depth_bias2` goes). VK_EXT_depth_bias_control is still described but no longer consumed, so the core recommends enabling neither it nor its three features. RADV on the 780M no longer takes DriverDeviation::MetalDepth16BiasedStores: it was measured through the exact unit. MoltenVK keeps it (it hands Metal its constant, by construction). Elsewhere `unorm-depth-bias` announces the device's bias; its cost text, docs/API.md's entry, the deviation and property docs and a new FAST-PATHS device-gap row state it. Tests: `metal::state::a_unorm_depth_bias_is_metals_constant_in_the_devices_unit` (the constant as given on lavapipe, NVIDIA and MoltenVK, which have depthBiasExact or not); the recommendation test leaves the extension and its features out; the driver-facts test drops RADV's row; the exit-guard tests lose the priming group and render_state.rs as a keeper of the device's functions. api_signatures blessed (DepthBiasUnit, DepthBias::unit, depth_bias's signature); the refusal surface is unchanged. Not bumped here: RUNTIME_VERSION (the versions commit) and the runtime-sources pin (landing). Verified: cargo clippy -p metal2vulkan -p metal2vulkan-runtime -p metal2vulkan-validation --all-targets --all-features -D warnings; nextest of metal::state, device::tests::{enables,driver_facts,profile}, tests::fast_paths, api_surface, api_signatures, exit_guard, render_state, degradation_catalogue, draw_shape_notices and ash_interop: 159 passed. * Cite the spec that leaves a NaN fragment depth undefined, which makes its discard capability The native-arithmetic audit asked whether `clamp_depth`'s discard of a positive NaN depth, on every profile, emulates Metal where the device has a native form. It does not: Vulkan defines no answer for such a depth. "Depth Clamping and Range Adjustment" (fragops.adoc, 35.10.1): "If zf is not in the range [zmin, zmax], then zf is undefined following this step", with or without depthClampEnable, and a NaN lies in no range; only depthClampZeroOne, which no profile enables, keeps a float depth unchanged (and then the comparison of a NaN would still pass ALWAYS and NOT_EQUAL, where Metal's fails every test). So the discard stays, as capability, and the comment says why, so a later audit does not re-raise it. Docs only (a doc comment); no behaviour changes. Verified: cargo fmt --all. * Drop the cube's unmeasured gradient route from the anisotropic tests' profile comment The route was deleted with the native cube gradients; the comment still named it as a second home of the anisotropic emulation. Only a profile without samplerAnisotropy emulates it now. Verified: comment only; git grep finds no other mention of the unmeasured gradient route. * Keep the device's store of an extended-range, padded or bfloat attachment's untouched texels What: a render pass that loads and stores a color attachment of an extended-range, padded 10-bit or bfloat format now keeps the bytes its draws do not write, the device's own load and store (VK_ATTACHMENT_STORE_OP_STORE of a loaded attachment), on every device. The runtime no longer reproduces Metal's tile store: the load pass that rewrote the texels' unused bits before the pass (render/unused_bits_load.rs, bind::unused_bits_module), the capture replay that found the tiles a pass's draws reach for it (render/capture.rs, bind::capture_assembly_module, capture_settle_module, tile_reach_module, the translator's capture form LoweringInputs/VariantKey::captured_positions, CaptureForm, RuntimeFact::CapturedPositions, PushField/PushHole::CaptureAddress, Feature::TileReach, StatusBits::CAPTURED_REACH_UNMEASURED, StatusReport::captured_reach_unmeasured) and the pipeline states' capture forms are deleted, with ExtendedRange::load_code, Degradation::UnreachedTilesRewritten and the WorkCounts fields unused_bits_load_passes, unused_bits_load_texels and capture_reach_*. Every draw in such a pass announces extended-range-bits-kept, naming the attachments (render/tile_store.rs, the renamed module); its catalogue entry, the FAST-PATHS device-gap row and the format docs state what differs: the unused bits, BGRA10_XR's alpha clamp, a padded sRGB twin's table and a bfloat code through half, which Metal's pass rewrites in each tile a draw reaches. snorm-minimum-kept and shared-exponent-kept are unchanged (TileStoreIsMetals still says where the device's store is Metal's). The de-indexed and private list forms keep the index read the capture form shared (PushField::CaptureIndexAddress, CaptureLayout, CapturedIndex); the binder's de-indexed draw no longer goes through the capture draw, and the vertex function's strip restart return, which only the capture form's layout could take (a de-indexed strip is NotImplemented(PrimitiveId)), is gone. Why: the owner's rule 1. The device has a native load and store; reproducing Metal's tile store emulated Metal's bits where the device has a native form. The difference is recorded and announced (rule 2). Verified: cargo clippy -D warnings, all targets and features, over metal2vulkan, metal2vulkan-runtime, metal2vulkan-validation and metal2vulkan-conformance, plain and with --cfg m2v_gpu: clean. api_signatures blessed, REFUSALS.md regenerated. The test runs (translator and runtime suites, the touched validation lanes on lavapipe and on the M3 Max's MoltenVK) follow this commit and are reported with the lane. * Bump the semantics and runtime versions for the device's tile store and depth bias What: SEMANTICS_VERSION 1907 -> 1908 and RUNTIME_VERSION 1681 -> 1682. Why: SEMANTICS_VERSION, because the translator's output changes under unchanged keys: the de-indexed and private list vertex forms no longer carry the strip restart return, and the capture form, its runtime fact and its push field are gone. RUNTIME_VERSION, because runs of unchanged artifacts now do something else: a Depth16Unorm depth takes the device's depth bias (no depthBiasExact or unit rescale), and a pass that loads an extended-range, padded or bfloat attachment keeps its untouched texels' bytes (no unused-bits load pass, no capture replay) and announces extended-range-bits-kept. ARTIFACT_FORMAT_VERSION stays: the codec tags variants by name, and the removed ones (CaptureForm, PushField::CaptureAddress, RuntimeFact::CapturedPositions) leave their tags unused, so an old entry holding one is a miss. Verified: the constants alone change; the golden tables and the runtime-sources pin are re-blessed at landing. * Hold the lanes and the fact census to the device's store of untouched texels What: three runtime lanes still expected Metal's tile store after 5e710fb988 made the device's store the only form, and the mechanism test still counted the deleted RuntimeFact::CapturedPositions. - extended_range_blends::a_pass_of_extended_range_and_padded_colors_names_each_loaded_color: the padded colors, which the function does not write, keep their bytes (all ones), where Metal's pass leaves each word 0xffc0. - extended_range_blends::a_fetched_two_plane_attachment_written_unblended_stores_metals_write: color 2, loaded and unwritten, keeps its bytes, where Metal's pass zeroes its color words' top two bits. - extended_range_blend_table::a_memoryless_color_2_blends_as_a_stored_color_does: the stored color 0's bands are compared with the unused bits as Metal's pass leaves them (as_metal_leaves), the codes exactly, as the table's other passes already are. - device::tests::mechanism: the variant census is 0..89 (MergedDraws takes the freed index). Why: the lanes held the deleted exact form; the device's store is now the contract and extended-range-bits-kept announces the difference. Verified: on the M3 Max (MoltenVK, --cfg m2v_gpu, under maclock and memcap) the three lanes and the rest of extended_range_blends pass (11 of 11, with waiter_submits, which failed once under a load of 40 and passed on its rerun); on plain, device::tests::mechanism and tests::fast_paths pass (12 of 12); clippy -D warnings clean, plain and --cfg m2v_gpu, over the four crates. * Re-pin the runtime sources at the landing tip The landed packet changed a runtime-sources input, so the committed digest no longer described the sources and `the_runtime_sources_are_the_committed_ones` would fail. Recomputed over the same inputs and committed by land-pkt.sh. --- .../src/cases/extended_range_blends.rs | 16 +- .../src/cases/snorm_tile_store.rs | 4 - .../examples/host_ab/runtime.rs | 12 - crates/metal2vulkan-runtime/src/binding.rs | 49 +- .../metal2vulkan-runtime/src/clear_reach.rs | 17 +- .../src/command_buffer/gate.rs | 2 +- .../src/command_buffer/mod.rs | 64 +- .../src/command_buffer/rebound_use.rs | 9 +- .../metal2vulkan-runtime/src/degradation.rs | 81 +- crates/metal2vulkan-runtime/src/device/mod.rs | 17 +- .../metal2vulkan-runtime/src/device/prime.rs | 15 +- crates/metal2vulkan-runtime/src/error.rs | 2 +- crates/metal2vulkan-runtime/src/exit_guard.rs | 2 - .../metal2vulkan-runtime/src/owned_kernel.rs | 55 +- .../src/pipeline/graphics.rs | 1 - .../src/pipeline/piece_holds.rs | 3 +- .../src/pipeline/render.rs | 185 +- .../metal2vulkan-runtime/src/recorder/log.rs | 49 - .../src/recorder/thunks.rs | 2 - crates/metal2vulkan-runtime/src/render.rs | 291 +-- .../src/render/capture.rs | 660 ----- .../src/render/color_groups.rs | 16 +- .../src/render/draw_shape.rs | 4 +- .../src/render/executions.rs | 11 +- .../src/render/extended_shadow.rs | 9 +- .../src/render/inline_first.rs | 14 +- .../src/render/inline_splits.rs | 5 +- .../metal2vulkan-runtime/src/render/replay.rs | 4 +- .../src/render/reroute.rs | 44 - .../src/render/shadows.rs | 5 +- .../src/render/snapshot.rs | 5 +- .../src/render/tile_dispatch.rs | 2 - .../src/render/tile_store.rs | 150 ++ .../src/render/unused_bits_load.rs | 877 ------- .../metal2vulkan-runtime/src/render_state.rs | 178 +- .../metal2vulkan-runtime/src/render_target.rs | 10 - .../src/tests/descriptor_key_at_draw.rs | 84 +- .../src/tests/exit_guard.rs | 21 +- .../src/tests/upload_chunk_zeros.rs | 5 +- crates/metal2vulkan-runtime/src/upload.rs | 18 - .../metal2vulkan-runtime/src/work_counts.rs | 84 +- crates/metal2vulkan-runtime/src/ycbcr.rs | 4 +- .../public/tile_reach/device_passes.txt | 1797 ------------- .../runtime-sources.sha256 | 2 +- .../platform/runtime_probe/depth_source.rs | 7 - .../src/runtime_lane.rs | 6 - .../src/runtime_lane/bfloat_targets.rs | 29 +- .../src/runtime_lane/capture_costs.rs | 342 --- .../src/runtime_lane/capture_reach.rs | 448 ---- .../src/runtime_lane/degrade_notices.rs | 3 +- .../extended_range_blend_table.rs | 15 +- .../src/runtime_lane/extended_range_blends.rs | 129 +- .../src/runtime_lane/padded_loads.rs | 114 +- .../src/runtime_lane/rgb10a2_srgb.rs | 15 +- .../src/runtime_lane/rotated_textures.rs | 75 +- .../src/runtime_lane/snorm_tile_store.rs | 26 +- .../src/runtime_lane/tile_reach_kernel.rs | 656 ----- .../src/runtime_lane/unorm_depth_bias.rs | 24 +- .../metal2vulkan/src/bind/capture_assembly.rs | 345 --- .../src/bind/capture_assembly/kernel.rs | 731 ------ .../src/bind/capture_assembly/tests.rs | 691 ----- crates/metal2vulkan/src/bind/graphics.rs | 294 +-- .../metal2vulkan/src/bind/graphics/tests.rs | 6 - crates/metal2vulkan/src/bind/instantiate.rs | 30 +- crates/metal2vulkan/src/bind/mod.rs | 16 +- crates/metal2vulkan/src/bind/plan.rs | 6 +- crates/metal2vulkan/src/bind/replay/tests.rs | 4 +- crates/metal2vulkan/src/bind/state.rs | 14 +- crates/metal2vulkan/src/bind/status.rs | 22 +- crates/metal2vulkan/src/bind/tile_reach.rs | 290 --- .../src/bind/tile_reach/kernel.rs | 2247 ----------------- .../metal2vulkan/src/bind/tile_reach/tests.rs | 381 --- .../src/bind/tile_reach/tests/assembly.rs | 77 - .../src/bind/tile_reach/tests/device.rs | 159 -- .../src/bind/tile_reach/tests/kernel.rs | 831 ------ .../src/bind/tile_reach/tests/measured.rs | 1115 -------- .../src/bind/tile_reach/tests/points.rs | 2187 ---------------- .../src/bind/tile_reach/tests/reference.rs | 526 ---- crates/metal2vulkan/src/bind/unused_bits.rs | 602 ----- .../src/bind/unused_bits/tests.rs | 316 --- crates/metal2vulkan/src/cache/codec.rs | 7 +- crates/metal2vulkan/src/cache/mod.rs | 20 +- crates/metal2vulkan/src/cache/tests.rs | 70 - .../metal2vulkan/src/device/driver_facts.rs | 27 +- crates/metal2vulkan/src/device/enables.rs | 4 +- crates/metal2vulkan/src/device/mechanism.rs | 3 - .../metal2vulkan/src/device/requirements.rs | 6 +- .../src/device/tests/driver_facts.rs | 1 - .../metal2vulkan/src/device/tests/enables.rs | 14 +- .../src/device/tests/mechanism.rs | 11 +- crates/metal2vulkan/src/error/mod.rs | 32 +- .../src/lower/arith/extended_range/tests.rs | 25 +- crates/metal2vulkan/src/lower/push.rs | 27 +- .../src/lower/sampler/anisotropic/tests.rs | 4 +- .../metal2vulkan/src/lower/stage_io/fetch.rs | 8 +- crates/metal2vulkan/src/lower/stage_io/mod.rs | 312 +-- .../metal2vulkan/src/lower/stage_io/plan.rs | 138 +- crates/metal2vulkan/src/metal/format/mod.rs | 46 +- .../src/metal/format/padded_srgb.rs | 4 +- crates/metal2vulkan/src/metal/state.rs | 173 +- crates/metal2vulkan/src/pipeline/api_tests.rs | 4 - crates/metal2vulkan/src/pipeline/compile.rs | 11 +- .../metal2vulkan/src/pipeline/compile/key.rs | 7 - .../src/pipeline/compile/tests.rs | 20 - crates/metal2vulkan/src/pipeline/facts.rs | 9 - crates/metal2vulkan/src/pipeline/link.rs | 9 - .../src/pipeline/link/graphics.rs | 13 +- .../metal2vulkan/src/pipeline/link/vertex.rs | 26 +- .../metal2vulkan/src/pipeline/lower_inputs.rs | 61 +- crates/metal2vulkan/src/pipeline/mod.rs | 6 +- crates/metal2vulkan/src/pipeline/sym.rs | 31 +- .../src/spirv/requirements/writes.rs | 27 +- .../src/spirv/requirements/writes/tests.rs | 16 +- .../tests/engine_extended_range/targets.rs | 5 +- .../src/tests/engine_vertex_capture.rs | 1228 --------- crates/metal2vulkan/src/tests/mod.rs | 1 - .../metal2vulkan/src/tests/owned_divisions.rs | 33 +- crates/metal2vulkan/tests/api_signatures.tsv | 127 +- crates/metal2vulkan/tests/api_surface.rs | 11 - docs/API.md | 52 +- docs/FAST-PATHS.md | 2 + docs/REFUSALS.md | 10 +- scripts/refusal-surface/reach.tsv | 1 - 123 files changed, 955 insertions(+), 19351 deletions(-) delete mode 100644 crates/metal2vulkan-runtime/src/render/capture.rs create mode 100644 crates/metal2vulkan-runtime/src/render/tile_store.rs delete mode 100644 crates/metal2vulkan-runtime/src/render/unused_bits_load.rs delete mode 100644 crates/metal2vulkan-validation/fixtures/public/tile_reach/device_passes.txt delete mode 100644 crates/metal2vulkan-validation/src/runtime_lane/capture_costs.rs delete mode 100644 crates/metal2vulkan-validation/src/runtime_lane/capture_reach.rs delete mode 100644 crates/metal2vulkan-validation/src/runtime_lane/tile_reach_kernel.rs delete mode 100644 crates/metal2vulkan/src/bind/capture_assembly.rs delete mode 100644 crates/metal2vulkan/src/bind/capture_assembly/kernel.rs delete mode 100644 crates/metal2vulkan/src/bind/capture_assembly/tests.rs delete mode 100644 crates/metal2vulkan/src/bind/tile_reach.rs delete mode 100644 crates/metal2vulkan/src/bind/tile_reach/kernel.rs delete mode 100644 crates/metal2vulkan/src/bind/tile_reach/tests.rs delete mode 100644 crates/metal2vulkan/src/bind/tile_reach/tests/assembly.rs delete mode 100644 crates/metal2vulkan/src/bind/tile_reach/tests/device.rs delete mode 100644 crates/metal2vulkan/src/bind/tile_reach/tests/kernel.rs delete mode 100644 crates/metal2vulkan/src/bind/tile_reach/tests/measured.rs delete mode 100644 crates/metal2vulkan/src/bind/tile_reach/tests/points.rs delete mode 100644 crates/metal2vulkan/src/bind/tile_reach/tests/reference.rs delete mode 100644 crates/metal2vulkan/src/bind/unused_bits.rs delete mode 100644 crates/metal2vulkan/src/bind/unused_bits/tests.rs delete mode 100644 crates/metal2vulkan/src/tests/engine_vertex_capture.rs diff --git a/crates/metal2vulkan-conformance/src/cases/extended_range_blends.rs b/crates/metal2vulkan-conformance/src/cases/extended_range_blends.rs index 44b49b42a..857d40ce1 100644 --- a/crates/metal2vulkan-conformance/src/cases/extended_range_blends.rs +++ b/crates/metal2vulkan-conformance/src/cases/extended_range_blends.rs @@ -241,13 +241,13 @@ impl Case for ExtendedRangeBlend { // what this M3 Max and lavapipe both show -- and one that does not shows the code. The // allowance fails the case if the notice stops firing, so it cannot outlive its reason. // - // The pass loads and stores an extended-range colour attachment, so our load pass - // (`render/unused_bits_load.rs`) rewrites every 32 x 32 tile of the render area where - // Metal's rewrites only the tiles a draw's primitives reach, announced as - // `unreached-tiles-rewritten`. The difference it names cannot reach this case: the draw is - // one full-screen triangle over the whole 128 x 64 target, so every tile is a reached - // tile, and every stored code compares exactly on MoltenVK and on lavapipe alike. So this - // is a declaration of what our side announced and not a tolerance -- no code is loosened. + // The pass loads and stores an extended-range colour attachment, so its draw announces + // `extended-range-bits-kept`: the device's store keeps the bits the codes leave unused in + // the texels the draw does not write, where Metal's pass makes them canonical. The + // difference it names cannot reach this case: the draw is one full-screen triangle over + // the whole 128 x 64 target under every channel, so it writes every texel, and every + // stored code compares exactly. So this is a declaration of what our side announced and + // not a tolerance -- no code is loosened. // // The two extended-range blend kinds (`extended-range-blend-source` and // `extended-range-blends-stored-codes`) are deliberately **not** named here: neither fired @@ -268,7 +268,7 @@ impl Case for ExtendedRangeBlend { .chain( [ Degradation::HalfOutputFastMathBlend, - Degradation::UnreachedTilesRewritten, + Degradation::ExtendedRangeBitsKept, ] .into_iter() .map(|kind| crate::replay::notice_allowance(kind.code())), diff --git a/crates/metal2vulkan-conformance/src/cases/snorm_tile_store.rs b/crates/metal2vulkan-conformance/src/cases/snorm_tile_store.rs index 4e52e92a3..2c90e9b66 100644 --- a/crates/metal2vulkan-conformance/src/cases/snorm_tile_store.rs +++ b/crates/metal2vulkan-conformance/src/cases/snorm_tile_store.rs @@ -169,10 +169,6 @@ const PASS_NOTICES: &[Degradation] = &[ Degradation::SnormMinimumKept, // The same for an `RGB9E5Float` word Metal's store normalizes. Degradation::SharedExponentKept, - // A load pass's rewrite of the tiles no fragment reached, which only an extended-range, padded - // 10-bit or bfloat attachment takes (`render/unused_bits_load.rs`); none of this family's - // formats takes one. - Degradation::UnreachedTilesRewritten, ]; /// The bytes of a `SIDE` by `SIDE` target of `texel` bytes a texel whose every channel holds diff --git a/crates/metal2vulkan-runtime/examples/host_ab/runtime.rs b/crates/metal2vulkan-runtime/examples/host_ab/runtime.rs index c0bcffab1..e2b73bc3e 100644 --- a/crates/metal2vulkan-runtime/examples/host_ab/runtime.rs +++ b/crates/metal2vulkan-runtime/examples/host_ab/runtime.rs @@ -1414,7 +1414,6 @@ impl Gpu for Runtime { "replayed_cmd_set_color_write_mask", replayed.cmd_set_color_write_mask, ), - ("replayed_cmd_set_depth_bias2", replayed.cmd_set_depth_bias2), ( "replayed_cmd_bind_index_buffer2", replayed.cmd_bind_index_buffer2, @@ -1484,17 +1483,6 @@ impl Gpu for Runtime { ("color_resolve_passes_made", c.color_resolve_passes_made), ("color_resolve_passes_kept", c.color_resolve_passes_kept), ("ahead_nanos", c.ahead_nanos), - ("unused_bits_load_passes", c.unused_bits_load_passes), - ("unused_bits_load_texels", c.unused_bits_load_texels), - ("capture_reach_passes", c.capture_reach_passes), - ("capture_reach_primitives", c.capture_reach_primitives), - ("capture_reach_tiles_found", c.capture_reach_tiles_found), - ("capture_reach_tiles_bound", c.capture_reach_tiles_bound), - ("capture_reach_bound_passes", c.capture_reach_bound_passes), - ( - "capture_reach_narrower_passes", - c.capture_reach_narrower_passes, - ), ("driver_diagnostics_withheld", c.driver_diagnostics_withheld), ("memory_blocks_live", c.memory_blocks_live), ("empty_memory_blocks_live", c.empty_memory_blocks_live), diff --git a/crates/metal2vulkan-runtime/src/binding.rs b/crates/metal2vulkan-runtime/src/binding.rs index a866ca1f7..5c7a09891 100644 --- a/crates/metal2vulkan-runtime/src/binding.rs +++ b/crates/metal2vulkan-runtime/src/binding.rs @@ -134,10 +134,6 @@ pub(super) struct Tables<'a> { tile_memory: Option<&'a Buffer>, /// The address-mode maps the command's runtime samplers are bound with (`address_map.rs`). sampler_maps: SamplerMaps, - /// A capture draw's addresses (`render/capture.rs`): of its first capture record, and of its - /// first index where it is indexed. Its `PushHole::CaptureAddress` and - /// `PushHole::CaptureIndexAddress` take them. - capture: Option<(u64, Option)>, /// A de-indexed draw's first index's address (`VariantKey::primitive_id_indices`): its /// `PushHole::CaptureIndexAddress` takes it. indices: Option, @@ -180,7 +176,6 @@ impl<'a> Tables<'a> { control_point_indices: None, tile_memory: None, sampler_maps: SamplerMaps::default(), - capture: None, indices: None, snapshots: None, merged_header: None, @@ -206,15 +201,6 @@ impl<'a> Tables<'a> { .is_some_and(|s| s.slots.contains(&slot.index)) } - /// The tables, with a capture draw's addresses: of its first capture `records`, and of its - /// first index (`indices`) where it is indexed (`render/capture.rs`). - pub(super) fn with_capture(self, records: u64, indices: Option) -> Tables<'a> { - Tables { - capture: Some((records, indices)), - ..self - } - } - /// The tables, with a merged draw replay's header's address (`Tables::merged_header`). pub(super) fn with_merged_header(self, address: u64) -> Tables<'a> { Tables { @@ -725,24 +711,13 @@ pub(super) fn bind_into( PushHole::CommandRecordsAddress { .. } => { return Err(Error::NotImplemented(RuntimeGap::CommandReplay)); } - // A capture draw's first record, and its first index where it is indexed - // (`Tables::with_capture`). - PushHole::CaptureAddress { stages, offset } => Hole { - stages: stages.into(), - offset, - address: tables - .capture - .map(|(records, _)| records) - .ok_or_else(|| internal("a capture hole without capture records"))?, - }, + // A de-indexed draw's first index, or a private list's (`Tables::with_indices`). PushHole::CaptureIndexAddress { stages, offset } => Hole { stages: stages.into(), offset, address: tables - .capture - .and_then(|(_, indices)| indices) - .or(tables.indices) - .ok_or_else(|| internal("a capture index hole without capture indices"))?, + .indices + .ok_or_else(|| internal("an index hole without its indices"))?, }, // A merged draw replay's header, which its vertex function finds its command in. PushHole::MergedDrawAddress { stages, offset } => Hole { @@ -2289,24 +2264,6 @@ pub(super) struct CommandUses { } impl CommandUses { - /// Add `other`'s uses, as one command's: a key either names stays named, and the keys both - /// reach through the resident set alone stay so (`render/capture.rs`, whose draws record - /// as one command). - pub(super) fn merge(&mut self, other: CommandUses) { - let named = |uses: &CommandUses| -> BTreeSet { - uses.uses - .iter() - .map(|used| used.key) - .filter(|key| !uses.resident.contains(key)) - .collect() - }; - let (own, theirs) = (named(self), named(&other)); - self.resident.retain(|key| !theirs.contains(key)); - let reached = other.resident.into_iter().filter(|key| !own.contains(key)); - self.resident.extend(reached); - self.uses.extend(other.uses); - } - /// Add `used`, which names its key. pub(super) fn push(&mut self, used: Use) { self.resident.remove(&used.key); diff --git a/crates/metal2vulkan-runtime/src/clear_reach.rs b/crates/metal2vulkan-runtime/src/clear_reach.rs index c6118d1f0..1ed41b1ec 100644 --- a/crates/metal2vulkan-runtime/src/clear_reach.rs +++ b/crates/metal2vulkan-runtime/src/clear_reach.rs @@ -125,9 +125,8 @@ pub(super) fn stores(store: StoreAction) -> bool { } /// The tiles a render pass's draws reach, where Metal loads and stores its attachments, as far as -/// the host decides them: what a `DontCare` load clears (above), which tiles a rotated texture's -/// frame turns (`render/shadows.rs`), and which tiles the load pass of an extended-range or padded -/// attachment rewrites (`render/unused_bits_load.rs`). An execution of an indirect command buffer's +/// the host decides them: what a `DontCare` load clears (above) and which tiles a rotated +/// texture's frame turns (`render/shadows.rs`). An execution of an indirect command buffer's /// render commands, or a tile dispatch, counts as a draw call that draws (unmeasured). #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub(super) enum PassReach { @@ -142,7 +141,7 @@ pub(super) enum PassReach { /// and a pass of more layers are unmeasured: none of them decides it. Every, /// The tiles the draws' primitives reach, which the host does not know: each use of it - /// takes every tile and announces it (until the reach is captured). + /// takes every tile and announces it. Draws, } @@ -502,21 +501,11 @@ pub(super) struct DrawnTiles { } impl DrawnTiles { - /// A tile's width and height in pixels. - pub(super) fn tile(&self) -> [u32; 2] { - self.tile - } - /// Whether no tile is reached. pub(super) fn is_empty(&self) -> bool { self.words.iter().all(|&w| w == 0) } - /// The reached tiles' count. - pub(super) fn count(&self) -> u64 { - self.words.iter().map(|w| u64::from(w.count_ones())).sum() - } - /// Whether tile `(tx, ty)` is reached: none past the grid. pub(super) fn contains(&self, tx: u32, ty: u32) -> bool { let t = (ty as usize) * (self.per_row as usize) + tx as usize; diff --git a/crates/metal2vulkan-runtime/src/command_buffer/gate.rs b/crates/metal2vulkan-runtime/src/command_buffer/gate.rs index a916766b9..a4a9f8a06 100644 --- a/crates/metal2vulkan-runtime/src/command_buffer/gate.rs +++ b/crates/metal2vulkan-runtime/src/command_buffer/gate.rs @@ -11,7 +11,7 @@ //! - **And what fed its work** (`trails.rs`). A thread that made what the command buffer waited //! for, and holds what it made it with past its signal, holds the device without holding the //! command buffer: a pool piece between its making's settle and its give-back (a dispatch's or -//! a draw's pipeline, a capture's translation), the reaper with what such a piece gave back to a +//! a draw's pipeline), the reaper with what such a piece gave back to a //! released state, the twin-decode thread between a decode's end and its job's drop. Each opens //! a trail before its signal and closes it after its last let-go; the command buffer takes the //! device's trail mark as it completes, and `wait_until_completed` and its timed form, once the diff --git a/crates/metal2vulkan-runtime/src/command_buffer/mod.rs b/crates/metal2vulkan-runtime/src/command_buffer/mod.rs index b708b4b32..aa30032a0 100644 --- a/crates/metal2vulkan-runtime/src/command_buffer/mod.rs +++ b/crates/metal2vulkan-runtime/src/command_buffer/mod.rs @@ -630,8 +630,6 @@ pub(super) struct State { /// A direct mesh draw's object grid lay past what runs (`render/mesh_arguments.rs`): the /// command buffer fails as for `ExecutionStatus`'s `MESH_GRID_PAST_LIMITS`. mesh_grid_past: bool, - /// The captured passes' tile masks, which its completion counts (`render/capture.rs`). - pub(super) capture_tallies: Vec, /// The index pool of the commands' index bounds and rewrite passes (`index_bounds.rs`, /// `index_rewrite.rs`), once a draw needs it: its counter in the arena, starting at 0, and /// its lease of its queue's block, which its indices lie in (`gpu_pools.rs`). @@ -1821,7 +1819,6 @@ impl CommandBuffer { descriptors: DescriptorArena::default(), status_words: None, mesh_grid_past: false, - capture_tallies: Vec::new(), index_pool: None, mesh_pool: None, mesh_draws: 0, @@ -4260,9 +4257,6 @@ impl CommandBufferShared { /// waiters once the transition's [`Hold`] (and every other) is gone, and they wait for the /// trails below the mark. Waits from inside these steps answer as [`own`] says. fn complete(self: &Arc, result: Result<(), CommandBufferError>) { - // A capture replay found a primitive whose reach was not measured: its pass rewrote - // every tile, announced once the lock is let go (below). - let mut unmeasured_reach = false; // A thread sleeps on `changed`, as the state's lock below reads. let parked; // Its command pool, where it settled, whose primary the device's spares begin ahead once @@ -4385,12 +4379,7 @@ impl CommandBufferShared { state.status = CommandBufferStatus::Error; state.error = Some(CommandBufferError::CubicArgumentSampler); } - unmeasured_reach = report.captured_reach_unmeasured; state.report = Some(report); - let counts = &self.device.shared().counts; - for tally in &state.capture_tallies { - counts.capture_reach_tallied(tally.found(), tally.bound); - } } Err(error) => { state.status = CommandBufferStatus::Error; @@ -4410,7 +4399,6 @@ impl CommandBufferShared { // failure turns to `Error`. self.answer(&state); state.status_words = None; - state.capture_tallies.clear(); // Its heap versions, uploads, pools and descriptor pools go once its completed // handlers ran (below). released_versions = state.heaps.clear(); @@ -4452,18 +4440,6 @@ impl CommandBufferShared { // handler of its runs: a detach from one of them detaches (`detach.rs`). drop(submitted_holds); self.wake_parked(parked); - if unmeasured_reach { - self.device - .degrade(Degradation::UnreachedTilesRewritten, || { - ( - "a render pass whose draws' tile reach capture replay found".to_owned(), - "a primitive crossed the near or far plane, or lay past what Metal's tile \ - rule was measured over, so the pass rewrote every 32x32 tile of its \ - render area where Metal's rewrites only the tiles its primitives reach" - .to_owned(), - ) - }); - } let buffer = CommandBuffer(Arc::clone(self)); // Each handler leaves the queue under the lock and runs without it, in the order added // (a handler may query the command buffer). @@ -4569,37 +4545,6 @@ impl CommandBufferShared { } } -/// A captured pass's tile mask, copied where the host reads it once the command buffer completes -/// (`render/capture.rs`), and the tiles its draws' viewports and scissors reach: the counts -/// `WorkCounts::capture_reach_tiles_found` and its kin. -pub(super) struct CaptureTally { - /// The mask's copy: one bit a tile, tile `t` bit `t % 32` of word `t / 32`. - pub(super) mask: Upload, - /// The tiles of the pass's grid: the bits past them count nothing. - pub(super) grid: u64, - /// The tiles the draws' viewports and scissors reach. - pub(super) bound: u64, -} - -impl CaptureTally { - /// The tiles the mask names, once the command buffer completed. - fn found(&self) -> u64 { - let bytes = self.mask.read_bytes(); - let mut found = 0u64; - for (word, bits) in bytes.as_chunks::<4>().0.iter().enumerate() { - let first = word as u64 * 32; - let within = self.grid.saturating_sub(first).min(32); - let live = match within { - 32 => u32::MAX, - n => (1u32 << n) - 1, - }; - let bits = u32::from_le_bytes([bits[0], bits[1], bits[2], bits[3]]); - found += u64::from((bits & live).count_ones()); - } - found - } -} - /// A command buffer's transition, run in its queue's context. pub(crate) struct Transition { /// The command buffer, held until the transition ran. @@ -4619,14 +4564,9 @@ enum To { impl Transition { /// The transition of the command buffer `buffer` holds to `Completed` or `Error`, with - /// `result`: plain where it has no completed handler (none is added after the commit) and no - /// pass that captured its tiles' reach, the one notice it announces as it completes - /// (`render/capture.rs`). + /// `result`: plain where it has no completed handler (none is added after the commit). fn finished(buffer: Hold, result: Result<(), CommandBufferError>) -> Self { - let plain = { - let state = lock(&buffer.state); - state.completed.is_empty() && state.capture_tallies.is_empty() - }; + let plain = lock(&buffer.state).completed.is_empty(); Transition { buffer, to: To::Finished(result), diff --git a/crates/metal2vulkan-runtime/src/command_buffer/rebound_use.rs b/crates/metal2vulkan-runtime/src/command_buffer/rebound_use.rs index 9343832d5..903dcd2c1 100644 --- a/crates/metal2vulkan-runtime/src/command_buffer/rebound_use.rs +++ b/crates/metal2vulkan-runtime/src/command_buffer/rebound_use.rs @@ -9,9 +9,8 @@ use std::fmt; /// Why an ended encoder kept no log a rebind encodes it again from (`replay.rs`). #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub(crate) enum Unlogged { - /// It logged no calls: the device had no buffer over host pages as it opened, it is of a - /// kind that logs none (a resource state encoder's), or its pass captured its draws' tile - /// reach (`render/capture.rs`). + /// It logged no calls: the device had no buffer over host pages as it opened, or it is of a + /// kind that logs none (a resource state encoder's). NoCalls, /// It left work for later that an encoding again does not record at once: a host step's (a /// GPU-written indirect dispatch's), or a scrub's (`Segment::records_again`). @@ -66,8 +65,8 @@ impl fmt::Display for Unlogged { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(match self { Unlogged::NoCalls => { - "it logged no calls (no buffer over host pages as it opened, a kind that logs \ - none, or a pass that captured its draws' tile reach)" + "it logged no calls (no buffer over host pages as it opened, or a kind that \ + logs none)" } Unlogged::Segments => "it left work for later an encoding again does not record", Unlogged::Fails => "its command buffer fails it as it commits", diff --git a/crates/metal2vulkan-runtime/src/degradation.rs b/crates/metal2vulkan-runtime/src/degradation.rs index 3b97ede6a..781214df8 100644 --- a/crates/metal2vulkan-runtime/src/degradation.rs +++ b/crates/metal2vulkan-runtime/src/degradation.rs @@ -315,10 +315,12 @@ degradations! { /// A draw biases a `Depth16Unorm` depth by a constant, or by a slope alone, which brings /// Metal's constant unit, on a device whose driver is not measured to store Metal's codes /// so (`DriverDeviation::MetalDepth16BiasedStores`, `render_state.rs`): the device biases - /// and converts the depth. + /// by Metal's constant in its own unit and converts the depth. UnormDepthBias = "unorm-depth-bias", Precision, - "a biased depth can store a code next to Metal's: the device rounds the biased sum \ - its own way, and without depthBiasExact counts the bias in its own unit"; + "a biased depth can store another code than Metal's: the device biases by the \ + constant c in its own unit, up to twice 2^-16, where Metal biases by c + 1 units of \ + 1/65535 (c - 1 below 0, one unit for a slope alone), and rounds the biased sum its \ + own way"; /// A draw tests or writes a `Depth16Unorm` depth on a device whose driver is not measured /// to convert a depth to Metal's code (`DriverDeviation::MetalDepth16Stores`, /// `render_state.rs`), or a pass clears one to a depth that a device rounding to nearest @@ -1059,7 +1061,7 @@ degradations! { /// access (`texture/attached_reads.rs`): a texture reached through a handle or an /// argument buffer, a storage binding of a color attachment's texture, the depth or /// stencil attachment's texture, a texture buffer or a buffer over its bytes, a texture - /// whose copy is not served, or an execution's or a capture's command. Announced where the + /// whose copy is not served, or an execution's command. Announced where the /// draw records; the payload names its call. AttachmentReadInPlace = "attachment-read-in-place", Precision, "the access sees the attachment as the device holds it inside its render pass \ @@ -1219,32 +1221,33 @@ degradations! { Metal's blit reads from outside the texels: from outside the planes below a width \ of 4, and those an earlier blit left in a row's padding or past a plane, which \ Metal keeps"; - /// A draw in a render pass that loads a color attachment of an extended-range or padded - /// 10-bit format (`BGR10_XR`, `BGRA10_XR`, `RGB10A8_2P_XR10`, `R10Unorm_X6`, - /// `RG10Unorm_X12` and their sRGB twins, and `RGB10A2Unorm_sRGB`) and does not discard it - /// at the store, where the - /// pass's load pass (`render/unused_bits_load.rs`) does not take it (`render.rs`): a - /// multisampled attachment, a texture held as a shadow of another image or of a heap's - /// bytes, a sparse one, or one whose image the device does not copy both ways (a padded - /// format takes no multisample texture). Metal's pass, once it draws, writes each 32 x 32 tile a - /// draw reaches back with the bits its codes leave unused made canonical, the texels no - /// fragment writes and the channels a write mask leaves out too (on an Apple M4 and an - /// Apple M3 Max), where such an attachment keeps the bytes its draws do not write. - /// Announced at every draw, an indirect command buffer's executed commands' too, naming - /// every such attachment of the pass. Also a GPU blit into, out of or between textures of - /// which one is a `BGRA10_XR` or `BGRA10_XR_sRGB` texture Metal keeps losslessly - /// compressed (`compressed_blit.rs`): Metal's blit moves the texels through the - /// compression, which clears the same bits and clamps the same alpha, where the device's - /// copy keeps the bytes; once per device. + /// A draw in a render pass that loads a color attachment of an extended-range, padded + /// 10-bit or bfloat format (`BGR10_XR`, `BGRA10_XR`, `RGB10A8_2P_XR10`, `R10Unorm_X6`, + /// `RG10Unorm_X12` and their sRGB twins, `RGB10A2Unorm_sRGB`, `R16Bfloat`, `RG16Bfloat` + /// and `RGBA16Bfloat`) and does not discard it at the store (`render/tile_store.rs`). + /// Metal's pass, once it draws, writes each 32 x 32 tile a draw reaches back with the bits + /// its codes leave unused made canonical, a padded sRGB twin's codes through Metal's table + /// and a bfloat code through `half` (a NaN to `0x7fc0`), the texels no fragment writes and + /// the channels a write mask leaves out too (on an Apple M4 and an Apple M3 Max), where + /// the device's pass keeps the bytes its draws do not write, on every device. Announced at + /// every draw, an indirect command buffer's executed commands' too, naming every such + /// attachment of the pass. Also a GPU blit into, out of or between textures of which one + /// is a `BGRA10_XR` or `BGRA10_XR_sRGB` texture Metal keeps losslessly compressed + /// (`compressed_blit.rs`): Metal's blit moves the texels through the compression, which + /// clears the same bits and clamps the same alpha, where the device's copy keeps the + /// bytes; once per device. ExtendedRangeBitsKept = "extended-range-bits-kept", Precision, - "the texels the pass's draws do not write keep their bytes; Metal's pass keeps their \ - codes but rewrites the bits they leave unused in each tile a draw reaches \ - (BGR10_XR's bits 30 and 31 to ones, BGRA10_XR's low six bits of each field to \ - zeros, the two-plane color word's top two bits to zeros) and clamps BGRA10_XR's \ - alpha code to [384, 894]: a texel whose bytes no Metal write left (uploaded bytes, \ - or an alpha code past 894) keeps bytes Metal's pass would change, and a blit through \ - a BGRA10_XR texture Metal compresses keeps the bytes Metal's blit rewrites so; every \ - such texel reads the same value either way"; + "the texels the pass's draws do not write keep their bytes; Metal's pass rewrites, in \ + each tile a draw reaches, the bits their codes leave unused (BGR10_XR's bits 30 and \ + 31 to ones, BGRA10_XR's low six bits of each field, the two-plane color word's top \ + two bits and a padded word's low six bits to zeros), clamps BGRA10_XR's alpha code \ + to [384, 894], moves a padded sRGB twin's code through its table and a bfloat code \ + through half (out of half's range to an infinity or zero, a NaN to 0x7fc0): a texel \ + whose bytes no Metal write left (uploaded bytes, an alpha code past 894, a bfloat \ + code off half's grid) keeps bytes Metal's pass would change, and a blit through a \ + BGRA10_XR texture Metal compresses keeps the bytes Metal's blit rewrites so; an \ + extended-range texel reads the same value either way, a bfloat code off half's grid \ + reads its own value where Metal's reads the half it was moved to"; /// A draw in a render pass that loads a single-sampled color attachment of a signed /// normalized format (`R8Snorm`, `RG8Snorm`, `RGBA8Snorm`, `R16Snorm`, `RG16Snorm`, /// `RGBA16Snorm`) and does not discard it at the store (`render.rs`). Metal's pass, once @@ -1427,7 +1430,7 @@ degradations! { /// encoder the rebind could not encode again (a compute encoder its unit of command /// predication reaches past: one whose unit laid a step before it opened, or one of its /// own that the unit's later encoders read, or whose unit holds a loop or leaves work - /// out; a render pass a host step records, or whose end captured its draws' tile reach; work + /// out; a render pass a host step records; work /// recorded on the GPU alone that no longer runs there; a call that answers otherwise than /// at its encoding; `replay.rs`). Its reason names where the first such submission found /// the use (the encoder, and its own commands or work it left for later) and why no rebind @@ -1464,24 +1467,6 @@ degradations! { that does not name it reads what an earlier such write left in the stand-in's \ sink, where Metal drops those writes and reads zero; a sampled read, and a size \ query, are Metal's"; - /// A render pass that loads a color attachment of an extended-range, padded 10-bit or - /// bfloat format (`BGR10_XR`, `BGRA10_XR`, `RGB10A8_2P_XR10`, `R10Unorm_X6`, - /// `RG10Unorm_X12` and their sRGB twins, `RGB10A2Unorm_sRGB`, `R16Bfloat`, `RG16Bfloat` - /// and `RGBA16Bfloat`), stores it and draws, whose load pass - /// (`render/unused_bits_load.rs`) rewrites every 32 x 32 tile of its render area: Metal's - /// pass rewrites only the tiles a draw's primitives reach (on - /// an Apple M4 and an Apple M3 Max, alike), and every tile only where a color - /// attachment of the pass is cleared and stored (announced where none is, or where the - /// pass renders more than one layer). Announced at the pass's end, naming its - /// attachments the load pass took. - UnreachedTilesRewritten = "unreached-tiles-rewritten", Precision, - "in tiles no draw reaches the pass rewrites what Metal keeps: the unused bits made \ - canonical (BGR10_XR's bits 30 and 31 ones, BGRA10_XR's low six bits of each field \ - and the two-plane color word's top two bits zeros) and BGRA10_XR alpha codes \ - clamped to [384, 894], so an out-of-range raw alpha reads back changed, a padded \ - word's low six bits zeroed (an sRGB twin's code moved through Metal's table), a \ - bfloat code moved through half (out of half's range to an infinity or zero, a NaN \ - to 0x7fc0); the tiles a draw reaches are Metal's"; /// A draw in a render pass over a rasterization-rate map of no layers that was made after /// the device released a map of one or more layers, or reset from one of layers /// (`rate_mapped_pass.rs`). The draw diff --git a/crates/metal2vulkan-runtime/src/device/mod.rs b/crates/metal2vulkan-runtime/src/device/mod.rs index cecde9780..6fd831232 100644 --- a/crates/metal2vulkan-runtime/src/device/mod.rs +++ b/crates/metal2vulkan-runtime/src/device/mod.rs @@ -68,7 +68,7 @@ use super::mipmap_scratch::MipmapScratch; use super::owned_kernel::OwnedKernels; use super::recycle::{self, BufferMaking, Recycler}; use super::released_programs::Keepers; -use super::render_state::{depth_bias_command, DepthBiasCommand, DepthRanges}; +use super::render_state::DepthRanges; use super::render_target::KeptRenderPasses; use super::resource_ids::{ResourceIds, SamplerIdReads}; use super::sample_planes::PlanesObjects; @@ -320,9 +320,6 @@ pub(super) struct DeviceShared { /// The command that binds an index buffer range of a size, where the device enabled /// `maintenance5` (`draw_source.rs`). pub(super) sized_index_bind: Option, - /// The command that records a depth bias of a pinned unit, where the device enabled - /// `VK_EXT_depth_bias_control` (`render_state.rs`). - pub(super) depth_bias_command: Option, /// The mesh draw commands, where the device enabled `meshShader` (`render/mesh.rs`). pub(super) mesh_draws: Option, /// `vkCmdPushDescriptorSet`, from Vulkan 1.4 or `VK_KHR_push_descriptor` @@ -1408,15 +1405,6 @@ impl Device { } }); // SAFETY: as above; the loader serves `vkGetDeviceProcAddr` once the word is put back. - let depth_bias_command = unsafe { - loader_word.restore(); - depth_bias_command(&instance.raw, &raw, &enabled) - } - .map(|bias| { - // SAFETY: the device's own command of that name. - unsafe { crate::recorder::through(recording.as_ref(), Command::CmdSetDepthBias2, bias) } - }); - // SAFETY: as above; the loader serves `vkGetDeviceProcAddr` once the word is put back. let color_write_masks = unsafe { loader_word.restore(); ColorWriteMasks::load(&instance.raw, &raw, &enabled) @@ -1439,7 +1427,6 @@ impl Device { let drawn = prime::PrimedDraws { dynamic: extended_dynamic_state, color_write_masks, - depth_bias: depth_bias_command, sized_index_bind, }; // Before the exit hook is registered for this device (below): the first call of each @@ -1475,7 +1462,6 @@ impl Device { extended_dynamic_state: false, primitive_restart: false, color_write_masks: false, - depth_bias: false, sized_index_bind: false, ycbcr_conversion: ycbcr_formats.primer().is_some(), }), @@ -1773,7 +1759,6 @@ impl Device { shared_pointer_imports: OnceLock::new(), extended_dynamic_state, sized_index_bind, - depth_bias_command, mesh_draws, push_descriptor, pushes_after_pipeline_binds, diff --git a/crates/metal2vulkan-runtime/src/device/prime.rs b/crates/metal2vulkan-runtime/src/device/prime.rs index 4b85356b4..e953806ba 100644 --- a/crates/metal2vulkan-runtime/src/device/prime.rs +++ b/crates/metal2vulkan-runtime/src/device/prime.rs @@ -82,7 +82,6 @@ use crate::gpu_time::Calibration; use crate::loader_word::LoaderWord; use crate::memory; use crate::release::{self, Generated, Released}; -use crate::render_state::DepthBiasCommand; use crate::sharing::Sharing; use crate::tracker::Barrier; use ash::vk; @@ -174,10 +173,6 @@ pub(crate) const PRIMITIVE_RESTART_CALLS: [Call; 1] = [Call::CmdSetPrimitiveRest /// primes: a snapshot draw's masks (`dynamic_state.rs`, `render/snapshot.rs`). pub(crate) const COLOR_WRITE_MASK_CALLS: [Call; 1] = [Call::CmdSetColorWriteMask]; -/// The table's entry points a device without `VK_EXT_depth_bias_control` never calls, nor -/// primes: a depth bias in a unit of its own (`render_state.rs`). -pub(crate) const DEPTH_BIAS_CALLS: [Call; 1] = [Call::CmdSetDepthBias2]; - /// The table's entry points a device without `maintenance5` never calls, nor primes: an index /// buffer bound with its size (`draw_source.rs`). pub(crate) const SIZED_INDEX_BIND_CALLS: [Call; 1] = [Call::CmdBindIndexBuffer2]; @@ -379,7 +374,6 @@ pub(crate) struct Has { pub(crate) extended_dynamic_state: bool, pub(crate) primitive_restart: bool, pub(crate) color_write_masks: bool, - pub(crate) depth_bias: bool, pub(crate) sized_index_bind: bool, pub(crate) ycbcr_conversion: bool, } @@ -391,7 +385,6 @@ pub(crate) struct Has { pub(crate) struct PrimedDraws { pub(crate) dynamic: Option, pub(crate) color_write_masks: Option, - pub(crate) depth_bias: Option, pub(crate) sized_index_bind: Option, } @@ -404,7 +397,6 @@ impl PrimedDraws { .dynamic .is_some_and(|dynamic| dynamic.primitive_restart_enable.is_some()), color_write_masks: self.color_write_masks.is_some(), - depth_bias: self.depth_bias.is_some(), sized_index_bind: self.sized_index_bind.is_some(), ..has } @@ -491,7 +483,7 @@ pub(super) unsafe fn prime( /// has no push command, those of [`CALIBRATION_CALLS`] where it calibrates no timestamps, those /// of [`NAMING_CALLS`] where its instance reports no messages, and those of /// [`EXTENDED_DYNAMIC_STATE_CALLS`], [`PRIMITIVE_RESTART_CALLS`], -/// [`COLOR_WRITE_MASK_CALLS`], [`DEPTH_BIAS_CALLS`] and [`SIZED_INDEX_BIND_CALLS`] where it has +/// [`COLOR_WRITE_MASK_CALLS`] and [`SIZED_INDEX_BIND_CALLS`] where it has /// not their commands, and those of [`YCBCR_CONVERSION_CALLS`] where it converts no YCbCr format, /// that `calls` (one bit each) does not hold. pub(crate) fn missing(calls: u128, has: Has) -> Vec { @@ -513,7 +505,6 @@ pub(crate) fn missing(calls: u128, has: Has) -> Vec { && (has.extended_dynamic_state || !EXTENDED_DYNAMIC_STATE_CALLS.contains(&call)) && (has.primitive_restart || !PRIMITIVE_RESTART_CALLS.contains(&call)) && (has.color_write_masks || !COLOR_WRITE_MASK_CALLS.contains(&call)) - && (has.depth_bias || !DEPTH_BIAS_CALLS.contains(&call)) && (has.sized_index_bind || !SIZED_INDEX_BIND_CALLS.contains(&call)) && (has.ycbcr_conversion || !YCBCR_CONVERSION_CALLS.contains(&call)) }) @@ -1535,10 +1526,6 @@ impl Primer<'_> { masks(draws, 0, all.len() as u32, all.as_ptr()); self.made(Call::CmdSetColorWriteMask); } - if let Some(bias) = drawn.depth_bias { - bias(draws, &vk::DepthBiasInfoEXT::default()); - self.made(Call::CmdSetDepthBias2); - } // A clear of the attachment inside the pass, as a render encoder's clear of a stand-in // records it. let clear = [vk::ClearAttachment { diff --git a/crates/metal2vulkan-runtime/src/error.rs b/crates/metal2vulkan-runtime/src/error.rs index bca8e1d55..c6e6ed2a0 100644 --- a/crates/metal2vulkan-runtime/src/error.rs +++ b/crates/metal2vulkan-runtime/src/error.rs @@ -2040,7 +2040,7 @@ pub enum CommandBufferError { /// mapping update reads its buffer as it runs; a call refused at its encoding is refused /// again, and the calls after it run); this fails only an encoder that cannot be encoded /// again: one of a command buffer that used command predication; a render pass recorded later - /// (an indirect command buffer's execution) or whose end captured its draws' tile reach. Each + /// (an indirect command buffer's execution). Each /// of Metal's submissions holding such an encoder ran nothing (the command buffer's split), /// every other ran, the event signals fired and the handlers ran. What the command buffer's /// encoders made resident (`use_resource`, `use_heap`) and what its commands reach unnamed diff --git a/crates/metal2vulkan-runtime/src/exit_guard.rs b/crates/metal2vulkan-runtime/src/exit_guard.rs index e0efb3be1..5fc02a92c 100644 --- a/crates/metal2vulkan-runtime/src/exit_guard.rs +++ b/crates/metal2vulkan-runtime/src/exit_guard.rs @@ -482,11 +482,9 @@ calls! { CmdSetPrimitiveRestartEnable => c"vkCmdSetPrimitiveRestartEnable", // A render encoder's extension commands, each on a device that has it // ([`COLOR_WRITE_MASK_CALLS`](crate::device::prime::COLOR_WRITE_MASK_CALLS), - // [`DEPTH_BIAS_CALLS`](crate::device::prime::DEPTH_BIAS_CALLS), // [`SIZED_INDEX_BIND_CALLS`](crate::device::prime::SIZED_INDEX_BIND_CALLS)), through the // entry point the device gave (`vkCmdBindIndexBuffer2KHR` where it enables that form). CmdSetColorWriteMask => c"vkCmdSetColorWriteMaskEXT", - CmdSetDepthBias2 => c"vkCmdSetDepthBias2EXT", CmdBindIndexBuffer2 => c"vkCmdBindIndexBuffer2", // The objects a render encoder's lowering makes as it draws (its pass's render pass and // framebuffer, stand-in and scratch images, `creation.rs`), on the device's lowering thread diff --git a/crates/metal2vulkan-runtime/src/owned_kernel.rs b/crates/metal2vulkan-runtime/src/owned_kernel.rs index 0b9e98f94..09e5895bf 100644 --- a/crates/metal2vulkan-runtime/src/owned_kernel.rs +++ b/crates/metal2vulkan-runtime/src/owned_kernel.rs @@ -37,10 +37,9 @@ use crate::shader_cache::driver::Making; use ash::vk; use metal2vulkan::bind::{ MipmapFilterKernel, RewritePhase, RewriteProgram, ShadowMergeRead, ShadowTexelView, - TessellationScanKernel, TexelWords, YCbCrCodes, YCbCrConversion, + TessellationScanKernel, YCbCrCodes, YCbCrConversion, }; use metal2vulkan::metal::format::ExtendedRange; -use metal2vulkan::metal::PixelFormat; use std::collections::HashMap; /// A crate-owned module the runtime dispatches. @@ -163,22 +162,9 @@ pub(super) enum OwnedModule { /// `bind::ycbcr_write_module`: a 4:4:4 YCbCr texture's written texels encoded into its /// surface's two planes (`ycbcr.rs`), its write shadow bound as a storage image. YCbCrWrite, - /// `bind::unused_bits_module` of one format held as one kind of words: an extended-range, - /// padded 10-bit or bfloat texture's words in the tiles a mask names rewritten as Metal's tile - /// store leaves them, before a pass that loads it and draws (`render/unused_bits_load.rs`). - UnusedBits(PixelFormat, TexelWords), /// `bind::tiled_texels_module`: a heap texture's elements moved between its image's tight /// copy and Metal's tiles in the heap's bytes (`texture/heap_tiled.rs`). TiledTexels, - /// `bind::capture_assembly_module`: a pass's capture records assembled into its primitives - /// (`render/capture.rs`). - CaptureAssembly, - /// `bind::tile_reach_module`: a pass's primitives binned into the tiles they reach. Needs - /// `shaderInt64`: a device without it fails to build it with `Unsupported`. - TileReach, - /// `bind::capture_settle_module`: the mask made every tile where a primitive's reach was not - /// measured, reported in the status words. - CaptureSettle, /// `bind::extended_shadow_module` of one form: an extended-range attachment's `half` shadow /// set from its codes before the instance whose draws first hold it /// (`render/extended_shadow.rs`). Two storage images: the codes, then the shadow. @@ -454,27 +440,6 @@ impl OwnedModule { .map_err(Error::Compile)?; Ok((module.spirv.to_vec(), 3, 0)) } - OwnedModule::UnusedBits(format, words) => { - let device = device.compile_device(); - let module = metal2vulkan::bind::unused_bits_module(device, format, words) - .map_err(Error::Compile)?; - Ok((module.spirv.to_vec(), 3, 0)) - } - OwnedModule::CaptureAssembly => { - let module = metal2vulkan::bind::capture_assembly_module(device.compile_device()) - .map_err(Error::Compile)?; - Ok((module.spirv.to_vec(), 3, 0)) - } - OwnedModule::TileReach => { - let module = metal2vulkan::bind::tile_reach_module(device.compile_device()) - .map_err(Error::Compile)?; - Ok((module.spirv.to_vec(), 3, 0)) - } - OwnedModule::CaptureSettle => { - let module = metal2vulkan::bind::capture_settle_module(device.compile_device()) - .map_err(Error::Compile)?; - Ok((module.spirv.to_vec(), 3, 0)) - } OwnedModule::ExtendedShadowLoad(form) => { let device = device.compile_device(); let module = metal2vulkan::bind::extended_shadow_module(device, form) @@ -585,11 +550,7 @@ pub(super) struct OwnedKernels { two_plane_texels: Option, plane_bytes_copy: Option, ycbcr_write: Option, - unused_bits: HashMap<(PixelFormat, TexelWords), OwnedKernel>, tiled_texels: Option, - capture_assembly: Option, - tile_reach: Option, - capture_settle: Option, extended_shadow_loads: HashMap, predication_step: Option, twin_decodes: HashMap, @@ -628,9 +589,6 @@ impl OwnedKernels { self.plane_bytes_copy, self.ycbcr_write, self.tiled_texels, - self.capture_assembly, - self.tile_reach, - self.capture_settle, self.predication_step, ] .into_iter() @@ -644,7 +602,6 @@ impl OwnedKernels { .chain(self.index_rewrite_runs.values().copied()) .chain(self.ycbcr_converts.values().copied()) .chain(self.ycbcr_samples.values().copied()) - .chain(self.unused_bits.values().copied()) .chain(self.extended_shadow_loads.values().copied()) .chain(self.twin_decodes.values().copied()) .chain(self.tessellation_scans.values().copied()) @@ -695,9 +652,6 @@ impl OwnedKernels { OwnedModule::YCbCrSample(sampler, codes) => { self.ycbcr_samples.get(&(sampler, codes)).copied() } - OwnedModule::UnusedBits(format, words) => { - self.unused_bits.get(&(format, words)).copied() - } OwnedModule::ExtendedShadowLoad(form) => self.extended_shadow_loads.get(&form).copied(), OwnedModule::TwinDecode(decode) => self.twin_decodes.get(&decode).copied(), OwnedModule::TessellationScan(kernel) => self.tessellation_scans.get(&kernel).copied(), @@ -735,9 +689,6 @@ impl OwnedKernels { OwnedModule::YCbCrSample(sampler, codes) => { self.ycbcr_samples.insert((sampler, codes), kernel); } - OwnedModule::UnusedBits(format, words) => { - self.unused_bits.insert((format, words), kernel); - } OwnedModule::ExtendedShadowLoad(form) => { self.extended_shadow_loads.insert(form, kernel); } @@ -788,7 +739,6 @@ impl OwnedKernels { | OwnedModule::IndexRewriteRun(_) | OwnedModule::YCbCrConvert(..) | OwnedModule::YCbCrSample(..) - | OwnedModule::UnusedBits(..) | OwnedModule::ExtendedShadowLoad(_) | OwnedModule::TwinDecode(_) | OwnedModule::TessellationScan(_) => return None, @@ -813,9 +763,6 @@ impl OwnedKernels { OwnedModule::PlaneBytesCopy => &mut self.plane_bytes_copy, OwnedModule::YCbCrWrite => &mut self.ycbcr_write, OwnedModule::TiledTexels => &mut self.tiled_texels, - OwnedModule::CaptureAssembly => &mut self.capture_assembly, - OwnedModule::TileReach => &mut self.tile_reach, - OwnedModule::CaptureSettle => &mut self.capture_settle, OwnedModule::PredicationStep => &mut self.predication_step, }) } diff --git a/crates/metal2vulkan-runtime/src/pipeline/graphics.rs b/crates/metal2vulkan-runtime/src/pipeline/graphics.rs index 9e0617108..ab57509df 100644 --- a/crates/metal2vulkan-runtime/src/pipeline/graphics.rs +++ b/crates/metal2vulkan-runtime/src/pipeline/graphics.rs @@ -1001,7 +1001,6 @@ impl VariantObjects { 0.0, 0.0, 0.0, - None, self.device.compile_device().profile(), ) .map_err(|error| internal(&format!("a depth bias of no factors refused: {error:?}")))?; diff --git a/crates/metal2vulkan-runtime/src/pipeline/piece_holds.rs b/crates/metal2vulkan-runtime/src/pipeline/piece_holds.rs index 9d4b9e7f7..d6d79407e 100644 --- a/crates/metal2vulkan-runtime/src/pipeline/piece_holds.rs +++ b/crates/metal2vulkan-runtime/src/pipeline/piece_holds.rs @@ -2,8 +2,7 @@ //! holder of the device. //! //! A draw's making handed to the device's pool (`pool.rs`) needs its variant, its pass and its -//! making's ticket, and a capture form's translation its device and its descriptor: each holds -//! the device. Were the piece to hold them, the program could let go of the command buffer, the +//! making's ticket: each holds the device. Were the piece to hold them, the program could let go of the command buffer, the //! state and the device while the piece waits or runs, and the piece's release would then tear //! the device down on the pool's thread, perhaps while the process exits: after destructors the //! exit hook could not precede freed what that teardown calls into, RADV and ANV ended such diff --git a/crates/metal2vulkan-runtime/src/pipeline/render.rs b/crates/metal2vulkan-runtime/src/pipeline/render.rs index 9d8bc9877..6ecdfcf33 100644 --- a/crates/metal2vulkan-runtime/src/pipeline/render.rs +++ b/crates/metal2vulkan-runtime/src/pipeline/render.rs @@ -72,9 +72,9 @@ use metal2vulkan::cache::{Hash256, PipelineKey, SpecializationKey, VariantKey}; use metal2vulkan::library::{CompiledFunction, FunctionCompileKey}; use metal2vulkan::metal::{BindingAccess, PixelFormat, PrimitiveTopologyClass, RenderStages}; use metal2vulkan::pipeline::{ - CaptureForm, ColorAttachmentDescriptor, CommandWrites, MeshPipelineDescriptor, - PipelineInterface, RenderPipeline, RenderPipelineDescriptor, RuntimeFact, SpecKey, - StageEntries, StageModule, StageSource, TessellationDescriptor, + ColorAttachmentDescriptor, CommandWrites, MeshPipelineDescriptor, PipelineInterface, + RenderPipeline, RenderPipelineDescriptor, RuntimeFact, SpecKey, StageEntries, StageModule, + StageSource, TessellationDescriptor, }; use metal2vulkan::reflection::{LinkedUseAnswers, RenderPipelineReflection}; use std::any::Any; @@ -235,16 +235,8 @@ pub(crate) struct Program { /// alone (`drawn`), two descriptors the key tells apart, so it holds a key of each: a /// compile is keyed by the descriptor it compiles, a question by the descriptor it asks of. compiled_key: OnceLock, - /// The key of the descriptor its capture forms compile from - /// ([`GraphicsState::capture_key`]), built when the first form translates: one descriptor, - /// `descriptor` without its fragment stage or attachment formats ([`capture_descriptor`]), - /// for every form of every variant, so every form after the first builds none. - capture_key: OnceLock, /// Its part of the pipeline creation log, while the log is on (`creation_log.rs`). log: Option, - /// Its variants' capture forms (`VariantKey::captured_positions`), as capture replay asked for - /// them (`GraphicsState::capture_variant`): at most [`CAPTURES`]. - captures: Mutex>, /// What its last [`SETTLED`] settles of other shapes settled, in which buffer forms, the /// latest used first (`GraphicsState::settle_shape`). settled: Mutex>, @@ -253,8 +245,8 @@ pub(crate) struct Program { last_pipelines: Mutex>, /// Its routing into the pass colors it was last set in a pass of (`GraphicsState::routed`). routed: Mutex, u32>)>>, - /// What its pool pieces hold (`piece_holds.rs`): its draws' makings and its capture forms' - /// translations, kept here so a pool thread never holds the device's last reference. + /// What its pool pieces hold (`piece_holds.rs`): its draws' makings, kept here so a pool + /// thread never holds the device's last reference. pieces: Arc>, /// Its buffer slots whose bind offset class tells the device's view base alignment apart /// (`argument_table::AtBindViews`), of its base's interface. @@ -284,8 +276,6 @@ pub(crate) enum PieceHeld { _variant: Arc, _pass: Arc, }, - /// A capture form's translation: the state's device, which its sources read. - Capture(Device), } /// A pass's color formats, by index: what a state's routing is found for @@ -322,24 +312,6 @@ const SETTLED: usize = 4; /// shape, whose plan's specialization another draw of the pass does not share. const LAST_PIPELINES: usize = 4; -/// The most capture forms of its variants a state keeps (`GraphicsState::capture_variant`): a -/// settled key's and the key its plan asks for, of each form a pass draws. -const CAPTURES: usize = 8; - -/// A capture form of a state's variant: translated on the device's pool, its objects made on the -/// program's thread once it is, or refused. -#[derive(Clone)] -enum Capture { - /// Being translated on the pool: its outcome once the translation ends (a refusal as - /// `None`). - Translating(Arc>>>), - /// Its objects made. - Made(Arc), - /// Refused: by the compile (a device without the capture's stores, among others) or by its - /// objects. Never asked again while kept. - Refused, -} - impl std::fmt::Debug for RenderPipelineState { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match &self.0 { @@ -1790,8 +1762,6 @@ impl GraphicsState { texture_accesses: TextureAccessMemo::new(), descriptor_key: key.map_or_else(OnceLock::new, OnceLock::from), compiled_key: OnceLock::new(), - capture_key: OnceLock::new(), - captures: Mutex::new(Lru::counted(CAPTURES)), settled: Mutex::new(VecDeque::with_capacity(SETTLED)), last_pipelines: Mutex::new(VecDeque::with_capacity(LAST_PIPELINES)), routed: Mutex::new(None), @@ -1886,19 +1856,6 @@ impl GraphicsState { }) } - /// The key of `capture`, the descriptor the state's capture forms compile from - /// ([`capture_descriptor`] of its own), built once and held ([`Program::capture_key`]). - /// - /// Its own descriptor's key names another descriptor: a capture form compiles without the - /// fragment stage and the attachment formats, every field of which the key reads. `capture` - /// is fixed for the state's life -- the form a replay asks for is a fact of the variant's - /// key, not of the descriptor -- so the forms of every variant are keyed by this one key. - pub(crate) fn capture_key(&self, capture: &RenderPipelineDescriptor) -> &PipelineKey { - self.0 - .capture_key - .get_or_init(|| render_descriptor_key(&self.0.device, capture)) - } - /// The state a patch draw an indirect command scales runs on (`None` for a state that does /// not tessellate, whose draw refuses patches): its twin, of this state's descriptor with /// `tessellationFactorScaleEnabled` set and without `supportIndirectCommandBuffers`, made @@ -2236,117 +2193,6 @@ impl GraphicsState { (plan.variant == base.key && !self.0.stand_in).then_some((base, plan)) } - /// The capture form of the state's variant of `settled`, under `form`, and its plan for - /// `shape`, for capture replay (`render/capture.rs`), where it is ready: `None` while it is - /// not. It is the vertex stage alone, `settled` with `VariantKey::captured_positions`, of the - /// descriptor without its fragment function, color, depth or stencil formats (a pipeline that - /// rasterizes into a pass without attachments): every vertex function's position is - /// invariant, so the positions it writes are the ones the state's own draws rasterize. The - /// first ask hands its translation to the device's pool (bounded, `pool.rs`); the first ask - /// after the translation ended makes its objects here, on the program's thread, in the - /// program's order (the HITCH rule's, `kept.rs`). A form the compile or its objects refuse - /// stays `None` while kept, asked no more; so does one whose plan asks for another variant. - pub(crate) fn capture_variant( - &self, - settled: &VariantKey, - form: CaptureForm, - shape: &BindShape, - ) -> Option<(Arc, Arc)> { - let mut key = settled.clone(); - key.captured_positions = Some(form); - // The settled key holds facts of the fragment stage the capture form compiles without, - // so the capture's own plan may ask for its variant under another key, the facts of the - // vertex stage alone: that variant's plan asks for itself (as `settle`'s second - // variant's does). - for _ in 0..2 { - let variant = self.capture_form(&key)?; - let plan = variant.plan(&self.0.device, shape).ok()?; - if plan.variant == variant.key { - return Some((variant, plan)); - } - key = plan.variant.clone(); - } - None - } - - /// The capture form of `key` ([`capture_variant`](Self::capture_variant)'s), where it is - /// ready. - fn capture_form(&self, key: &VariantKey) -> Option> { - let found = lock(&self.0.captures).get(key).cloned(); - let entry = match found { - Some(Capture::Made(variant)) => return Some(variant), - Some(Capture::Refused) => return None, - Some(Capture::Translating(outcome)) => match outcome.get() { - None => return None, - Some(None) => Capture::Refused, - Some(Some(pipeline)) => { - let found = CompiledVariant::found(Remembered::Compiled(Arc::clone(pipeline))); - match RenderVariant::of(&self.0.device, key.clone(), found) { - Ok(variant) => Capture::Made(variant), - Err(_) => Capture::Refused, - } - } - }, - None => { - let StateDescriptor::Vertex(descriptor) = &self.0.descriptor else { - lock(&self.0.captures).insert(key.clone(), Capture::Refused, 1); - return None; - }; - let outcome = Arc::new(OnceLock::new()); - let translating = Capture::Translating(Arc::clone(&outcome)); - lock(&self.0.captures).insert(key.clone(), translating, 1); - let descriptor = capture_descriptor(descriptor); - // Built here, on the program's thread, where its one descriptor is: every later - // form's translation takes this key rather than building the same digest again. - let descriptor_key = *self.capture_key(&descriptor); - let key = key.clone(); - let keeping = self - .0 - .pieces - .keep(PieceHeld::Capture(self.0.device.clone())); - self.0.device.shared().pipeline_pool.run(Box::new(move || { - // Where the state let go meanwhile, the piece stops: no one asks again. - let Some((lease, held)) = keeping.start() else { - return; - }; - let device = match held { - PieceHeld::Capture(device) => device, - other => return lease.give_back(other, None), - }; - let translated = { - let sources = Sources::later(&device); - let entries = device.shared().shader_cache.memo.stage_entries(); - RenderVariant::compiled( - &sources, - &descriptor, - &key, - entries, - &descriptor_key, - ) - .ok() - .map(|found| match found.remembered { - Remembered::Live(variant) => Arc::clone(&variant.pipeline), - Remembered::Compiled(pipeline) => pipeline, - }) - }; - // Set once, by its one translation: a later draw may take it, and its command - // buffer complete, while this piece still holds the device, until it gave it - // back. A trail spans that (`trails.rs`). - let trail = device.shared().trails.open(); - let _set = outcome.set(translated); - lease.give_back(PieceHeld::Capture(device), Some(trail)); - })); - return None; - } - }; - let made = match &entry { - Capture::Made(variant) => Some(Arc::clone(variant)), - _ => None, - }; - lock(&self.0.captures).insert(key.clone(), entry, 1); - made - } - /// The variant of `key`: the large-buffer form's compiled at creation, or another compiled /// when first needed. fn variant(&self, key: &VariantKey) -> Result, Error> { @@ -2382,22 +2228,6 @@ impl GraphicsState { } } -/// The descriptor a state's capture forms compile from: `descriptor` without its fragment -/// function, color, depth or stencil formats, and without alpha-to-coverage or alpha-to-one -- a -/// pipeline of the vertex stage alone that rasterizes into a pass without attachments -/// (`GraphicsState::capture_variant`). It is the same descriptor for every form of every variant -/// of the state, so [`GraphicsState::capture_key`] keys all of them by its one key. -fn capture_descriptor(descriptor: &RenderPipelineDescriptor) -> RenderPipelineDescriptor { - let mut descriptor = descriptor.clone(); - descriptor.fragment = None; - descriptor.color_attachments = Default::default(); - descriptor.depth_format = None; - descriptor.stencil_format = None; - descriptor.alpha_to_coverage = false; - descriptor.alpha_to_one = false; - descriptor -} - /// The base variant of each color group of the state of `descriptor` whose creation compiled /// `base` (under stand-ins where `stand_in`), with whether it was compiled under stand-ins /// (`GraphicsState::color_group`): the first group's is `base`, each later one's compiled as the @@ -2527,8 +2357,7 @@ fn stage_name(source: &StageSource) -> String { /// /// The functions are what lets a creation name its stages' modules without hashing their words /// again ([`stage_words_digest`]). Empty for a pipeline the memo, a binary archive or the disk -/// cache gave whole, and for a mesh pipeline or a capture form, none of which link from compiled -/// functions here. +/// cache gave whole, and for a mesh pipeline, none of which link from compiled functions here. struct CompiledVariant { remembered: Remembered, functions: Vec, @@ -2572,7 +2401,7 @@ impl RenderVariant { /// built or holds: a creation compiles its base, its large-buffer form and each of its color /// groups' bases, all of one descriptor, so it builds that key once and every one of them /// looks its pipeline up under it; a state holds the key of each descriptor its later - /// compiles are of (`GraphicsState::compiled_key`, `capture_key`), so a draw builds none. + /// compiles are of (`GraphicsState::compiled_key`), so a draw builds none. fn compiled( sources: &Sources<'_>, descriptor: &RenderPipelineDescriptor, diff --git a/crates/metal2vulkan-runtime/src/recorder/log.rs b/crates/metal2vulkan-runtime/src/recorder/log.rs index ec1bfeba4..860679cc5 100644 --- a/crates/metal2vulkan-runtime/src/recorder/log.rs +++ b/crates/metal2vulkan-runtime/src/recorder/log.rs @@ -273,10 +273,6 @@ enum Logged { writes: Span, }, SetColorWriteMask(u32, Span), - SetDepthBias2 { - factors: [f32; 3], - representation: Option<(vk::DepthBiasRepresentationEXT, vk::Bool32)>, - }, BindIndexBuffer2(vk::Buffer, vk::DeviceSize, vk::DeviceSize, vk::IndexType), DrawMeshTasks(u32, u32, u32), DrawMeshTasksIndirect(vk::Buffer, vk::DeviceSize, u32, u32), @@ -1163,33 +1159,6 @@ impl Log { self.op(Logged::SetColorWriteMask(first, masks)); } - pub(super) unsafe fn cmd_set_depth_bias2(&mut self, info: *const vk::DepthBiasInfoEXT<'_>) { - // SAFETY: the caller's. - let info = unsafe { &*info }; - let representation = match info.p_next.is_null() { - true => None, - false => { - // SAFETY: the caller's: a chained structure starts with its type. - let chained = - unsafe { &*info.p_next.cast::>() }; - if chained.s_type != vk::StructureType::DEPTH_BIAS_REPRESENTATION_INFO_EXT - || !chained.p_next.is_null() - { - unchained("depth bias"); - } - Some((chained.depth_bias_representation, chained.depth_bias_exact)) - } - }; - self.op(Logged::SetDepthBias2 { - factors: [ - info.depth_bias_constant_factor, - info.depth_bias_clamp, - info.depth_bias_slope_factor, - ], - representation, - }); - } - pub(super) unsafe fn cmd_bind_index_buffer2( &mut self, buffer: vk::Buffer, @@ -1772,24 +1741,6 @@ impl Log { masks.len, self.masks.get_ptr(masks) ), - Logged::SetDepthBias2 { - factors, - representation, - } => { - let mut chained = representation.map(|(representation, exact)| { - vk::DepthBiasRepresentationInfoEXT::default() - .depth_bias_representation(representation) - .depth_bias_exact(exact != vk::FALSE) - }); - let mut info = vk::DepthBiasInfoEXT::default() - .depth_bias_constant_factor(factors[0]) - .depth_bias_clamp(factors[1]) - .depth_bias_slope_factor(factors[2]); - if let Some(chained) = &mut chained { - info = info.push_next(chained); - } - call!(CmdSetDepthBias2, vk::PFN_vkCmdSetDepthBias2EXT, &info) - } Logged::BindIndexBuffer2(buffer, offset, size, index_type) => call!( CmdBindIndexBuffer2, vk::PFN_vkCmdBindIndexBuffer2KHR, diff --git a/crates/metal2vulkan-runtime/src/recorder/thunks.rs b/crates/metal2vulkan-runtime/src/recorder/thunks.rs index 0690463b2..3733606ea 100644 --- a/crates/metal2vulkan-runtime/src/recorder/thunks.rs +++ b/crates/metal2vulkan-runtime/src/recorder/thunks.rs @@ -393,8 +393,6 @@ commands! { ); CmdSetColorWriteMask cmd_set_color_write_mask c"vkCmdSetColorWriteMaskEXT" (first: u32, count: u32, masks: *const vk::ColorComponentFlags); - CmdSetDepthBias2 cmd_set_depth_bias2 c"vkCmdSetDepthBias2EXT" - (info: *const vk::DepthBiasInfoEXT<'_>); CmdBindIndexBuffer2 cmd_bind_index_buffer2 c"vkCmdBindIndexBuffer2" ( buffer: vk::Buffer, diff --git a/crates/metal2vulkan-runtime/src/render.rs b/crates/metal2vulkan-runtime/src/render.rs index 24a90d82b..ce7d23b61 100644 --- a/crates/metal2vulkan-runtime/src/render.rs +++ b/crates/metal2vulkan-runtime/src/render.rs @@ -387,7 +387,6 @@ use tile_dispatch::{ScratchEdges, TileDispatch}; mod arguments; mod bound; mod call_checks; -mod capture; mod color_groups; mod deferral; mod draw_shape; @@ -414,8 +413,8 @@ mod table_facts; mod tessellation_scan; mod tile_dispatch; mod tile_memory; +mod tile_store; mod untouched; -mod unused_bits_load; mod vertex_reach; mod vertex_strides; @@ -748,10 +747,15 @@ enum NineFailure { /// `PushField::VerticesPerPrimitive`): such a draw runs the variant that draws its indices as /// vertices from 0 (`BindState::primitive_id_indices`). `None` for every other draw. fn primitive_id_indices(pipeline: &DrawingState, draw: &DrawCall) -> Option { - match draw { - DrawCall::Indexed { .. } if writes_primitive_ids(pipeline) => { - capture::form(draw)?.index_type() - } + let DrawCall::Indexed { index_type, .. } = *draw else { + return None; + }; + if !writes_primitive_ids(pipeline) { + return None; + } + match index_type { + t if t == metal2vulkan::vk::IndexType::UINT16 => Some(IndexType::UInt16), + t if t == metal2vulkan::vk::IndexType::UINT32 => Some(IndexType::UInt32), _ => None, } } @@ -1436,9 +1440,6 @@ pub(crate) struct RenderLowering { /// colors out of its subpass (`render/reroute.rs`): a draw that would record elsewhere, or /// whose variant the interlocked storage form refuses, fails the reroute. rerouting: bool, - /// The pass's draws kept for capture replay, or the capture draw being recorded - /// (`render/capture.rs`). - keeping: capture::Keeping, /// The buffer forms its draws' variants take (`BufferForms`): the large-buffer form where it /// records an execution's commands at its host step, or settles their variants at commit /// (`render/executions.rs`), so no buffer a command binds asks for another variant; the @@ -1514,15 +1515,11 @@ pub(crate) struct RenderLowering { /// form): its descriptor sets view the attachment's image, which then stays the pass's /// (`kept_bytes.rs`). inputs_read: BTreeSet, - /// The pass has a draw call, whether or not it draws anything, or an execution of render - /// commands: Metal's pass rewrites the unused bits of an extended-range or padded attachment - /// it loads in the tiles its draws reach (`render/unused_bits_load.rs`). - rewrites_unused_bits: bool, /// The kept-attachment notices of the layout as it stands (`degrade_kept_attachments`), /// decided at the first draw or execution under it; `None` until then, and again each time /// the encoder changes its layout: installs another, sets a color's store action or resolve, /// loads a memoryless color, or reroutes the pass. - kept_attachments: Option, + kept_attachments: Option, /// The pass's extended-range color attachments an earlier draw or execution of render /// commands may have written, or whose clear Metal's tile memory holds as values its codes /// do not read back (`cleared_off_codes`), by index (`degrade_extended_range_blends`). @@ -1932,7 +1929,6 @@ impl RenderLowering { log, grouped, } = opening; - let keeping = capture::Keeping::of(&layout); let rerecord = extended.keeps_draws(); // The bind state the device's last ended render encoder left (`live_bind.rs`). let live = core.device().shared().live_binds.take(); @@ -2011,7 +2007,6 @@ impl RenderLowering { tile_dispatch_calls: 0, replaying: false, rerouting: false, - keeping, forms: BufferForms::Bound, replayed: None, drawn_before: Vec::new(), @@ -2031,7 +2026,6 @@ impl RenderLowering { drawn: clear_reach::DrawnArea::default(), coverage: linear_attachment::Coverage::default(), inputs_read: BTreeSet::new(), - rewrites_unused_bits: false, kept_attachments: None, extended_written, extended, @@ -3943,10 +3937,8 @@ impl RenderLowering { } /// [`end_encoding`](Self::end_encoding)'s pass, all but its core's end and its later color - /// groups' passes: the core, what the encoder made resident, its log, whether a rebind may - /// encode it again from it (not where its end captured its draws' tile reach, whose tally - /// lies in the command buffer), and what its later color groups draw - /// (`render/color_groups.rs`). + /// groups' passes: the core, what the encoder made resident, its log, and what its later + /// color groups draw (`render/color_groups.rs`). fn end_pass(mut self: Box) -> Result { const CALL: &str = "end_encoding"; // Over a mutable rasterization-rate map: Metal's GPU hangs at a pass of no draw call until @@ -3979,10 +3971,6 @@ impl RenderLowering { // The last instance recorded inline after a split, its commands still kept: recorded // now, before the pass's plan of the instances after it (`render/inline_splits.rs`). self.flush_inline()?; - // The tiles the pass's draws reach, from the positions their own vertex functions - // compute, where capture replay finds them: recorded before the pass's other steps - // (`render/capture.rs`). - let captured = self.capture_reach(); // Whether a command of the pass may read an attachment's bytes it did not name. let unnamed_reads = self.barrier_inside || self.reaches_unnamed || !self.executions.is_empty(); @@ -4010,7 +3998,6 @@ impl RenderLowering { drawn, coverage, inputs_read, - rewrites_unused_bits, residency, extended, reload_at, @@ -4129,7 +4116,6 @@ impl RenderLowering { core, residency, log, - keeps_log: captured.is_none(), later: None, }); } @@ -4360,15 +4346,6 @@ impl RenderLowering { ) }); } - // An extended-range or padded 10-bit attachment the pass loads: the bits its codes leave - // unused made canonical, in the tiles the pass's draws reach, before the pass's other - // steps, as Metal's pass that draws rewrites them (`render/unused_bits_load.rs`). - // None where they reach no tile. The tiles capture replay binned, where it did. - let rewritten = unused_bits_load::TileReach::of(reach, tiles.as_ref(), captured.as_ref()) - .filter(|_| rewrites_unused_bits); - if let Some(rewritten) = rewritten { - unused_bits_load::record(&mut core, &layout, rewritten)?; - } // A color attachment the last instance leaves out does not resolve there: a pass that // resolves one runs one more instance, of no draws, after its sample planes are merged // back, which resolves the pass (`sample_planes.rs`). @@ -5048,11 +5025,6 @@ impl RenderLowering { if let Some(first) = &first_texel_copies { core.shadow_copies(first); } - // A rotated texture's frame the pass loads: its unused bits rewritten over the frame's - // tiles once its shadow's copy in filled it (`render/unused_bits_load.rs`). - if let Some(rewritten) = rewritten { - unused_bits_load::record_frames(&mut core, &layout, rewritten)?; - } if let Some(write) = nan_depth { write.record(&mut core); core.retain(write); @@ -5605,7 +5577,6 @@ impl RenderLowering { core, residency, log, - keeps_log: captured.is_none(), later, }) } @@ -6386,7 +6357,7 @@ impl RenderLowering { } /// Give up the draws recording of `instance`, one the pass replaced or gave up before running - /// it ([`install`](Self::install), `render/reroute.rs`, `render/capture.rs`): never submitted, + /// it ([`install`](Self::install), `render/reroute.rs`): never submitted, /// a deferred one is never replayed, and one of the pool's ends so the pool goes back to the /// device's spares unreset (`CommandBuffer::give_up_raw`). One with pieces (the secondaries /// of draws whose pipelines were being made) is left to the pool's reset; one whose secondary @@ -6403,7 +6374,7 @@ impl RenderLowering { // SAFETY: the secondary command buffer is recording, only this encoder records it, and // nothing executes it; no query is active in it: a query begins or continues only in an // instance none of whose draws record again (`rerecord` `None`, which `recorded` marks - // too), never one a pass replaces, a reroute leaves, or a capture's. + // too), never one a pass replaces or a reroute leaves. let ended = unsafe { self.core.command_buffer().give_up_raw(instance.draws) }; if ended.is_ok() { self.core.device().shared().counts.unrun_instance_ended(); @@ -6714,17 +6685,17 @@ impl RenderLowering { } /// Announce the kept-attachment notices at a draw, or an execution of render commands, of - /// each kind whose list of the pass's colors is not empty - /// (`unused_bits_load::KeptAttachments`): decided once for each layout the encoder records - /// under, as its calls change it ([`kept_attachments`](Self::kept_attachments)). + /// each kind whose list of the pass's colors is not empty (`tile_store::KeptAttachments`): + /// decided once for each layout the encoder records under, as its calls change it + /// ([`kept_attachments`](Self::kept_attachments)). fn degrade_kept_attachments(&mut self) { let device = self.core.device(); let layout = &self.layout; let kept = (self.kept_attachments) - .get_or_insert_with(|| unused_bits_load::KeptAttachments::of(layout, device)); + .get_or_insert_with(|| tile_store::KeptAttachments::of(layout, device)); debug_assert_eq!( *kept, - unused_bits_load::KeptAttachments::of(layout, device), + tile_store::KeptAttachments::of(layout, device), "the kept colors decided for a layout the encoder changed since" ); Self::degrade_unused_bits(device, &kept.unused_bits); @@ -6733,11 +6704,10 @@ impl RenderLowering { } /// Announce `extended-range-bits-kept` at a draw in a pass that loads a color attachment of - /// an extended-range or padded 10-bit format (and does not discard it at the store), whatever - /// the draw's state, naming every such attachment the load pass does not take, `kept` - /// (`render/unused_bits_load.rs`): Metal's pass, once it draws, rewrites the bits their codes - /// leave unused in each tile a draw reaches, the texels the draws do not write too, where such - /// an attachment keeps those. + /// an extended-range, padded 10-bit or bfloat format (and does not discard it at the store), + /// whatever the draw's state, naming every such attachment, `kept` + /// (`tile_store::bits_kept`): Metal's pass, once it draws, rewrites every texel of each tile a + /// draw reaches, the texels the draws do not write too, where the device's pass keeps those. fn degrade_unused_bits(device: &Device, kept: &[String]) { if kept.is_empty() { return; @@ -6745,9 +6715,11 @@ impl RenderLowering { device.degrade(Degradation::ExtendedRangeBitsKept, || { ( format!("a draw in a render pass that loads {}", kept.join(" and ")), - "the texels the pass's draws do not write keep the bits their codes leave \ - unused, and a BGRA10_XR alpha code past [384, 894], which Metal's pass \ - rewrites in each tile a draw reaches" + "the texels the pass's draws do not write keep their bytes: the bits their \ + codes leave unused, a BGRA10_XR alpha code past [384, 894], a padded word's \ + low six bits, a padded sRGB twin's code off Metal's table and a bfloat code \ + off half's grid (a NaN other than 0x7fc0), each of which Metal's pass rewrites \ + in each tile a draw reaches" .to_owned(), ) }); @@ -6756,7 +6728,7 @@ impl RenderLowering { /// Announce `snorm-minimum-kept` at a draw in a pass that loads a single-sampled color /// attachment of a signed normalized format (and does not discard it at the store), whatever /// the draw's state, naming every such attachment, `kept` - /// (`unused_bits_load::snorm_minimum_kept`): Metal's pass, once it draws, writes each tile a + /// (`tile_store::snorm_minimum_kept`): Metal's pass, once it draws, writes each tile a /// draw reaches back through the channels' values, so a minimum code (-128, or -32768) the /// draws do not write is stored as the code above it, where such an attachment keeps it. Not /// on a driver whose pass stores it so too (`DriverFact::TileStoreIsMetals`: MoltenVK's pass @@ -6778,7 +6750,7 @@ impl RenderLowering { /// Announce `shared-exponent-kept` at a draw in a pass that loads a single-sampled /// `RGB9E5Float` color attachment (and does not discard it at the store), whatever the draw's - /// state, naming every such attachment, `kept` (`unused_bits_load::shared_exponent_kept`): + /// state, naming every such attachment, `kept` (`tile_store::shared_exponent_kept`): /// Metal's pass, once it draws, writes each tile a draw reaches back through its texels' /// values, so a word the draws do not write whose largest mantissa is below 256 under an /// exponent above 0 is stored normalized, where such an attachment keeps it. Not on a driver @@ -7099,7 +7071,6 @@ impl RenderLowering { // execution (`executions.rs`). if !self.replaying { self.degrade_kept_attachments(); - self.rewrites_unused_bits = true; self.degrade_extended_range_blends(); self.degrade_ycbcr_blends(); } @@ -7292,28 +7263,16 @@ impl RenderLowering { // from a copy taken before the pass (`render/pass_start_reads.rs`). // The object and mesh tables' too, and an execution's commands', whose copies record // into the recording that replays them, before the pass (`render/executions.rs`). - // A capture draw (`render/capture.rs`) runs before the pass: it reads the bytes as they - // were then, in place, and announces nothing its first recording did not. - let capture = self.capture_addresses(); // The device's sampler states, less those at IDs no set-1 sampler array of the variant // holds (`heap_sets::fit_samplers`): taken where the draw needs them - // (`sampler::ArgumentSamplers`), and at once for a capture draw, whose capture form is - // another variant than the one settled. - let mut argument_samplers = match capture { - Some(_) => ArgumentSamplers::taken(self.core.device()), - None => ArgumentSamplers::untaken(), - }; - let pass_start = match capture { - Some(_) => PassStartTables::default(), - None => self.pass_start.tables( - &mut self.core, - [&self.vertex, &self.object, &self.mesh], - &pipeline.base().interface, - )?, - }; - if capture.is_none() { - self.degrade_kept_colors(&pipeline, &settings.routing); - } + // (`sampler::ArgumentSamplers`). + let mut argument_samplers = ArgumentSamplers::untaken(); + let pass_start = self.pass_start.tables( + &mut self.core, + [&self.vertex, &self.object, &self.mesh], + &pipeline.base().interface, + )?; + self.degrade_kept_colors(&pipeline, &settings.routing); // The pass colors the draw renders through views of other formats, in an instance of // its own (`next_instance`). Refused (`NotImplemented(IndirectRenderCommands)`) for an // execution's command, whose runs' framebuffers are the pass's. @@ -7329,7 +7288,7 @@ impl RenderLowering { // A draw that reads its pass's texture after a barrier inside its instance reads it // through a snapshot where it can (`render/snapshot.rs`): asked of the plan, kept where // the plan reads so, else `None` and the split. - let mut snapshot = self.snapshot_wanted(&pipeline, &reformats, capture.is_some()); + let mut snapshot = self.snapshot_wanted(&pipeline, &reformats); // Its runtime samplers' address modes as the textures they sample map them: what it // settles under, and binds with. let sampler_maps = self.sampler_maps(&pipeline, &pass_start)?; @@ -7367,28 +7326,12 @@ impl RenderLowering { } } self.give_up_extended_shadows(&pipeline, &live.state); - // The draw's primitive type: an indexed capture draw's layout says whether its strip - // restarts, and a vertex function that writes the primitive ID divides by its vertices per - // primitive (`PushField::VerticesPerPrimitive`). + // The draw's primitive type: a vertex function that writes the primitive ID divides by its + // vertices per primitive (`PushField::VerticesPerPrimitive`), and an indexed strip of it + // does not run de-indexed. if let Assembly::Primitives(primitive) = assembly { live.state.primitive_type = Some(primitive); } - // A capture draw runs its variant's capture form, where its objects are made: else it - // records nothing, and the capture neither. - let (variant, plan) = match capture { - None => (variant, plan), - Some(_) => { - let found = capture::form(&draw) - .and_then(|form| pipeline.capture_variant(variant.key(), form, &shape)); - match found { - Some(found) => found, - None => { - self.capture_missed(); - return Ok(()); - } - } - } - }; let device = self.core.device(); let stages = &variant.pipeline().stages; if device.argument_pixel_samplers_noted(stages).is_some() { @@ -7546,9 +7489,6 @@ impl RenderLowering { .flatten() .map(|buffer| buffer.identity().key), ) { - if self.capture_missed() { - return Ok(()); - } self.skipped_draw(); return Ok(()); } @@ -7912,17 +7852,14 @@ impl RenderLowering { // A draw that samples a color attachment's texture reads the texture's copy, taken before // its instance; after a memory barrier inside the current instance, which orders one // pixel alone, it records into a new instance, whose copy holds what the draws before the - // barrier wrote (`texture/attached_reads.rs`). An execution's command and a capture draw - // read the attachment in place: neither takes a copy. + // barrier wrote (`texture/attached_reads.rs`). An execution's command reads the + // attachment in place: it takes no copy. // A draw that reads through snapshots reads no attachment's texture otherwise // (`RenderCommandEncoder::snapshot_holds`), and stays in its instance: one recorded inline // has begun its render pass instance with no color in the feedback loop layout, so the // draw records into a new one (`render/snapshot.rs`). So does a draw that binds a texture // the current instance holds in that layout as a storage image. - let attached = capture.is_none() - && !self.replaying - && snapshot.is_none() - && self.samples_attachment(&plan); + let attached = !self.replaying && snapshot.is_none() && self.samples_attachment(&plan); let after_barrier = attached && (self.current.barriers || self.barrier); let snapshot_split = snapshot.as_ref().is_some_and(|w| self.snapshot_apart(w)); let storage_colors = self.storage_colors(&plan); @@ -7935,19 +7872,15 @@ impl RenderLowering { let unheld_writes = (self.current.inline || deciding) && self.writes_memoryless(&pipeline, routing, zeroes_colors); let first_write = self.current.inline && unheld_writes; - // A capture draw records into the capture's instance, the current one. - let (next, stood) = match capture { - Some(_) => (Next::Current, None), - None => self.next_instance( - (&fetched, Some(&pipeline)), - (stencil_use.is_some(), tests_use.is_some()), - views, - (ordered || after_barrier || apart || first_write) && !self.replaying, - hidden, - &routing.locations, - &reformats, - )?, - }; + let (next, stood) = self.next_instance( + (&fetched, Some(&pipeline)), + (stencil_use.is_some(), tests_use.is_some()), + views, + (ordered || after_barrier || apart || first_write) && !self.replaying, + hidden, + &routing.locations, + &reformats, + )?; if first_write && matches!(next, Next::New { split: true, .. }) { device.shared().counts.inline_memoryless_write_split(); } @@ -8175,15 +8108,12 @@ impl RenderLowering { .ok_or_else(|| internal("a heap's draw without its argument samplers"))?; tables = tables.with_heap(states, heap); } - if let Some((records, indices)) = capture { - tables = tables.with_capture(records, indices); - } if let Some(header) = self.replayed.as_ref().and_then(|r| r.merged_header()) { tables = tables.with_merged_header(header); } // A list in the private list form is read at its address, which the device gives the // list's memory where it has device addresses, as the form needs. - if capture.is_none() && variant.key().private_list { + if variant.key().private_list { let address = match (&listed, &rewrite) { (Some(list), _) => list.address(), (_, Some(pass)) => pass.address(), @@ -8194,7 +8124,7 @@ impl RenderLowering { tables = tables.with_indices(address); } // A de-indexed draw's vertex function reads its indices in place, at their address. - if capture.is_none() && variant.key().primitive_id_indices.is_some() { + if variant.key().primitive_id_indices.is_some() { let address = buffers .index .as_ref() @@ -8303,7 +8233,7 @@ impl RenderLowering { } // In a pass of several color groups, what the draw reads of what another group writes // (`render/color_groups.rs`): checked at its first recording. - if capture.is_none() && !self.rerouting { + if !self.rerouting { let roots = !commands.root_tables.is_empty(); self.check_group_reads(uses, roots, &plan)?; } @@ -8326,9 +8256,6 @@ impl RenderLowering { .map(|used| used.key) .filter(|key| !uses.resident().contains(key)); if self.core.skips(named) { - if self.capture_missed() { - return Ok(()); - } self.skipped_draw(); return Ok(()); } @@ -8354,11 +8281,6 @@ impl RenderLowering { if self.replaying && !self.gathered().covers(&draw_shadows) { return Err(Error::NotImplemented(RuntimeGap::IndirectRenderCommands)); } - // A shadowed texture's copies go around its instance, which a capture draw runs before. - if capture.is_some() && !draw_shadows.is_empty() { - self.capture_missed(); - return Ok(()); - } // Over the last draw's, in their storage (`LiveBind::vertex_buffers`). live.vertex_buffers.clear(); for bind in &plan.vertex_buffers { @@ -8473,8 +8395,8 @@ impl RenderLowering { }), }; // A draw that reaches no fragment runs its vertex function alone, through empty scissors, - // and so do unsized points, and a capture draw, which writes its records alone. - if failing == Some(FailingDraw::Untouched) || unsized_points || capture.is_some() { + // and so do unsized points. + if failing == Some(FailingDraw::Untouched) || unsized_points { for state in draw_states.iter_mut() { for scissor in state.scissors.iter_mut() { *scissor = vk::Rect2D::default(); @@ -8617,12 +8539,6 @@ impl RenderLowering { if reused_state && reused_pipeline { device.shared().counts.draw_shape_reused(); } - // A capture draw's pipeline is made on the pool: until it is, the capture records - // nothing. - if capture.is_some() && matches!(draw_pipeline, DrawPipeline::Making(_)) { - self.capture_missed(); - return Ok(()); - } // A pipeline made at the state's creation announces its notices at the first draw that // finds it made; a draw that began a making announced them as it began it. if let DrawPipeline::Made(made) = &draw_pipeline { @@ -8922,15 +8838,12 @@ impl RenderLowering { .fold(vk::PipelineStageFlags2::empty(), |all, used| { all | used.read.stages | used.write.stages }); - // A capture draw's uses are the capture's command's, before the pass (`capture_uses`). - if capture.is_none() { - let reaching = (&**uses, uses.resident()); - self.core - .note_reaching(stages, reaching, Some(&mut live.noted))?; - self.unordered.add(uses); - self.pass_start.announce(&device, uses, mesh_before); - self.pass_start.add(uses); - } + let reaching = (&**uses, uses.resident()); + self.core + .note_reaching(stages, reaching, Some(&mut live.noted))?; + self.unordered.add(uses); + self.pass_start.announce(&device, uses, mesh_before); + self.pass_start.add(uses); let heap_set = match heap { Some(_) => Some(heap_sets::bind( &device, @@ -9139,36 +9052,6 @@ impl RenderLowering { && tessellation_steps.is_none() && draw_shadows.is_empty() && snapshot.is_none(); - // Whether the draw can run again as a capture draw before the pass, where its pass keeps - // its draws for capture replay (`render/capture.rs`): its primitives' positions, viewport - // and scissor are the ones it rasterizes with, and its reads read what they read. - let capturable = !self.replaying - && self.layout.samples == 1 - && self.layout.sample_positions.is_empty() - && self.rate_map.is_none() - && !self.counts_visibility() - && !tessellated - && !meshes - && !graphics.vertex_writes_memory - && !graphics.writes_viewport_index - && !self.amplification.offsets_viewports() - && views == ViewSetup::default() - && pushes.len() == 1 - && buffers.indirect.is_none() - && buffers.patch_indices.is_none() - && buffers.control_point_indices.is_none() - && !before_instance - && bounds.is_none() - && rewrite.is_none() - && listed.is_none() - && mesh_steps.is_none() - && tessellation_steps.is_none() - && draw_shadows.is_empty() - && snapshot.is_none() - && capture::assembles(assembly) - && self.state.reach_state().is_some(); - // A draw that rasterizes nothing reaches no tile: it changes nothing the capture finds. - let rasterizes = !graphics.rasterizer_discard; // A draw whose pipeline is being made records between its instance's own draws, which // an instance recorded inline cannot run: it records into a new instance after it // (`render/inline_first.rs`). @@ -9207,23 +9090,14 @@ impl RenderLowering { let inline = self.inline_begin( &next, stood.as_deref(), - ( - !empty && !culled, - made_ahead, - capture.is_some(), - unheld_writes, - ), + (!empty && !culled, made_ahead, unheld_writes), feedback, )?; // And a later instance of such a pass after a split, where it can, the instance before's // copies planned (`render/inline_splits.rs`). let split_inline = match inline { Some(_) => None, - None => self.inline_split( - &next, - stood.as_deref(), - (!empty && !culled, made_ahead, capture.is_some()), - ), + None => self.inline_split(&next, stood.as_deref(), (!empty && !culled, made_ahead)), }; // A new instance that records inline takes no secondary; any other begins its own. if inline.is_none() && split_inline.is_none() { @@ -9615,9 +9489,6 @@ impl RenderLowering { } self.current.recorded = true; self.keep_draw(again, (call, assembly, draw), index); - if rasterizes { - self.keep_capture(capturable, (call, assembly, draw), index); - } if pushes.len() > 1 { let count = pushes.len(); device.degrade(Degradation::AmplificationDraws, || { @@ -9652,8 +9523,7 @@ impl RenderLowering { } // The draw binds the variant: the kinds its making announces at every occurrence, but // where the encoder records a draw again (`render/reroute.rs`), which announced them. - // Nor where it records a capture draw. - if let (Some(tested), false) = (&bound_each, self.rerouting || capture.is_some()) { + if let (Some(tested), false) = (&bound_each, self.rerouting) { let formats = |slot| tested.iter().find(|(s, _)| *s == slot)?.1; let compiled = variant.pipeline(); objects.announce_bound( @@ -9663,17 +9533,15 @@ impl RenderLowering { } // A pipeline being made: its creation times once made, and the pass holds it // (`render/pending.rs`). - // Built only where the device keeps records. A capture draw's runs for the pass's steps. - if capture.is_none() { - self.core.executed(|| { - let executed = ExecutedPipeline::Render(Arc::clone(variant.shared_pipeline())); - let execution = match later { - None => Execution::new(executed, shape, created), - Some(creation) => Execution::made_later(executed, shape, creation), - }; - execution.with_index_padding(padding) - }); - } + // Built only where the device keeps records. + self.core.executed(|| { + let executed = ExecutedPipeline::Render(Arc::clone(variant.shared_pipeline())); + let execution = match later { + None => Execution::new(executed, shape, created), + Some(creation) => Execution::made_later(executed, shape, creation), + }; + execution.with_index_padding(padding) + }); let made = match draw_pipeline { DrawPipeline::Made(made) => Some(made), DrawPipeline::Making(_) => None, @@ -9714,9 +9582,6 @@ impl RenderLowering { if heap.is_some() && !function_tables.is_empty() { self.core.retain(function_tables); } - if capture.is_some() { - self.capture_uses(uses.clone()); - } Ok(()) } diff --git a/crates/metal2vulkan-runtime/src/render/capture.rs b/crates/metal2vulkan-runtime/src/render/capture.rs deleted file mode 100644 index e7be57a3a..000000000 --- a/crates/metal2vulkan-runtime/src/render/capture.rs +++ /dev/null @@ -1,660 +0,0 @@ -//! Capture replay: the tiles a pass's draws reach, from the positions its own vertex functions -//! compute, before the pass. -//! -//! An Apple GPU loads and stores only the tiles a pass's primitives reach (`bind::tile_reach`), -//! which decides what the pass's extended-range load rewrites (`render/unused_bits_load.rs`). -//! The host decides that reach where the draws reach nothing or every tile, and bounds it by -//! their viewports and scissors (`clear_reach.rs`); elsewhere the runtime announces -//! `unreached-tiles-rewritten`. Capture replay finds the tiles themselves: -//! -//! - **Kept.** In a pass that consumes its reach (a color attachment the load pass takes, of one -//! sample, Metal's default 32 by 32 tiles, one layer, and no rotated texture's frame among -//! them: `unused_bits_load::consumes_capture`), each draw is kept with the encoder's -//! state at it (`reroute::Rerecord`) while every draw of the pass can run again before it: a -//! direct draw of a triangle list or strip, indexed or not, of any instance count, of one -//! amplification and no views, through a pipeline without tessellation or mesh stages whose -//! vertex function writes no memory and chooses no viewport, under solid fill, outside a -//! rasterization-rate map, a visibility query and custom sample positions, its indices read in -//! place; at most [`MAX_DRAWS`] draws of at most [`MAX_RECORDS`] vertices. Any other draw, a -//! tile dispatch or an execution of render commands ends the keeping for the pass. -//! - **Recorded again.** As the pass ends, before its steps, each kept draw records again with -//! its state, through the capture form of its variant (`GraphicsState::capture_variant`: the -//! vertex stage alone, writing each vertex's clip position to a record), into a pass of no -//! attachments under empty scissors, so no fragment runs. Every vertex function's position is -//! invariant, so the records hold the positions the pass's own draws rasterize. The capture form -//! is translated on the device's pool and its objects and pipeline made at a later pass (the -//! HITCH rule: nothing waits on the program's thread); until each of the pass's draws has both, -//! the pass stays on the host's reach and announces as before. -//! - **Binned.** Before the pass, the capture draws run, then `bind::capture_assembly_module` -//! assembles their records into primitives as Metal's input assembly does (a strip's restarts -//! and parity too), `bind::tile_reach_module` bins them by the measured rule into a tile mask, -//! and `bind::capture_settle_module` makes it every tile where a primitive crossed the near or -//! far plane or lay past what was measured, which it reports through the command buffer's -//! status words: the command buffer announces `unreached-tiles-rewritten` once it completes -//! (`StatusReport::captured_reach_unmeasured`). The load pass rewrites the tiles the mask -//! names. Exact otherwise: the rule is Metal's, measured, and its arithmetic integer. -//! - **Counted.** The mask is also copied where the host reads it once the command buffer -//! completes, which counts its tiles against those the draws' viewports and scissors reach -//! (`WorkCounts::capture_reach_tiles_found` and `capture_reach_tiles_bound`), and the pass as -//! one whose primitives reach every tile of that bound (`capture_reach_bound_passes`: a -//! full-screen draw's, the capture changing nothing rewritten) or fewer -//! (`capture_reach_narrower_passes`). - -use super::bound::Bound; -use super::reroute::Rerecord; -use super::shadows::InstanceShadows; -use super::{Assembly, Instance, InterlockedStorage, RenderLowering}; -use crate::attachmentless; -use crate::binding::CommandUses; -use crate::clear_reach::{DrawnArea, DrawnTiles, PassReach}; -use crate::command_buffer::CaptureTally; -use crate::draw_source::DrawSource; -use crate::owned_kernel::{OwnedKernel, OwnedModule, OwnedSet, OwnedSets}; -use crate::render_pass::PassLayout; -use crate::render_target::{self, Feedback}; -use crate::tracker::Barrier; -use crate::tracker::{GeometryWrites, IndirectReads}; -use crate::values::ResourceOptions; -use crate::versioned::Versioned; -use ash::vk; -use metal2vulkan::bind::{ - CaptureAssemblyModule, CaptureSettleModule, DrawCall, ExecutionStatus, TileReachModule, - ViewSetup, -}; -use metal2vulkan::metal::{CullMode, IndexType, PrimitiveType}; -use metal2vulkan::pipeline::CaptureForm; -use std::sync::Arc; - -/// The most draws a pass keeps for capture replay: past them its reach is the host's. -pub(super) const MAX_DRAWS: usize = 256; - -/// The most capture records a pass's kept draws write (their vertices or indices, each instance -/// counted): 8 MiB of records, and their primitives' 16 MiB. -pub(super) const MAX_RECORDS: u64 = 1 << 18; - -/// What a pass keeps for capture replay (the module docs). -pub(super) enum Keeping { - /// The draws kept so far, and the records they write. - Draws(Vec, u64), - /// None: the pass does not consume its reach, or one of its draws cannot run again before - /// it. - Stopped, - /// The kept draws record again as capture draws, the pass ending: the one recording now. - Recording(Capturing), -} - -impl Keeping { - /// What a pass of `layout` keeps from its start. - pub(super) fn of(layout: &PassLayout) -> Keeping { - match consumes(layout) { - true => Keeping::Draws(Vec::new(), 0), - false => Keeping::Stopped, - } - } -} - -/// A capture draw recording (`RenderCommandEncoder::draw_resident` in capture mode). -pub(super) struct Capturing { - /// The device address of the draw's first record. - pub(super) records: u64, - /// The device address of the draw's first index, where it is indexed. - pub(super) indices: Option, - /// What the capture draws use, as the one command they record in. - pub(super) uses: CommandUses, - /// A capture draw recorded nothing: its capture form's objects or pipeline were not made - /// yet, or it could not record. - pub(super) missed: bool, -} - -/// Whether a pass of `layout` consumes its draws' tile reach where capture replay can give it: -/// the load pass takes one of its color attachments and no rotated frame -/// (`unused_bits_load::consumes_capture`), at one sample and one layer, in Metal's default 32 by -/// 32 tiles, which the reach kernel bins (`bind::tile_reach`). -fn consumes(layout: &PassLayout) -> bool { - layout.samples == 1 - && layout.layers == 1 - && layout.tile.tile == Some([32, 32]) - && super::unused_bits_load::consumes_capture(layout, false) -} - -/// Whether capture replay assembles draws of `assembly`. -pub(super) fn assembles(assembly: Assembly) -> bool { - matches!( - assembly, - Assembly::Primitives(PrimitiveType::Triangle | PrimitiveType::TriangleStrip) - ) -} - -/// The capture form of a direct draw `draw`: of its vertices, or of its indices of their type. -pub(super) fn form(draw: &DrawCall) -> Option { - match *draw { - DrawCall::Primitives { .. } => Some(CaptureForm::Vertices), - DrawCall::Indexed { index_type, .. } => match index_type { - t if t == metal2vulkan::vk::IndexType::UINT16 => { - Some(CaptureForm::Indexed(IndexType::UInt16)) - } - t if t == metal2vulkan::vk::IndexType::UINT32 => { - Some(CaptureForm::Indexed(IndexType::UInt32)) - } - _ => None, - }, - _ => None, - } -} - -/// The vertices or indices of each instance of a direct draw `draw`, and its instances. -fn counts(draw: &DrawCall) -> Option<(u64, u64)> { - match *draw { - DrawCall::Primitives { - vertex_count, - instance_count, - .. - } => Some((u64::from(vertex_count), u64::from(instance_count))), - DrawCall::Indexed { - index_count, - instance_count, - .. - } => Some((u64::from(index_count), u64::from(instance_count))), - _ => None, - } -} - -/// The reach the pass's capture draws give (`RenderCommandEncoder::capture_reach`): the tile -/// mask, recorded before the pass's other steps, in the scratch the command buffer holds. -#[derive(Debug)] -pub(super) struct CapturedReach { - /// The mask's `VkBuffer`, its offset there, and its bytes: one bit a tile, as - /// `bind::TileReachModule` numbers them. - pub(super) mask: (vk::Buffer, u64, u64), -} - -/// One kept draw's place among the pass's capture records and tile reach states. -struct Placed { - /// Its first record: instance 0's vertex 0. - first: u64, - /// Its records an instance, and its instances. - count: u64, - instances: u64, - topology: PrimitiveType, - /// It restarts at flagged records: an indexed strip. - restarts: bool, - /// Its cull mode is front or back. - culls: bool, -} - -impl RenderLowering { - /// Keep the draw just recorded (`call` of `assembly` and `draw`, its indices from `index`) - /// for capture replay where the pass keeps its draws and `capturable` (the module docs); - /// otherwise the pass keeps none from here on. A draw recorded again (a reroute's, or a - /// capture draw) was kept at its first recording. - pub(super) fn keep_capture( - &mut self, - capturable: bool, - recorded: (&'static str, Assembly, DrawCall), - index: Option<&DrawSource<'_>>, - ) { - if self.rerouting { - return; - } - let Keeping::Draws(draws, records) = &self.keeping else { - return; - }; - let added = counts(&recorded.2).and_then(|(count, instances)| count.checked_mul(instances)); - let total = added.and_then(|added| added.checked_add(*records)); - let room = draws.len() < MAX_DRAWS && total.is_some_and(|total| total <= MAX_RECORDS); - let kept = match capturable && room { - true => self.kept_draw(recorded, index), - false => None, - }; - match (kept, total, &mut self.keeping) { - (Some(kept), Some(total), Keeping::Draws(draws, records)) => { - draws.push(kept); - *records = total; - } - _ => self.keeping = Keeping::Stopped, - } - } - - /// The capture draw recording now: its record and index addresses, where the encoder - /// records one (`draw_resident`). - pub(super) fn capture_addresses(&self) -> Option<(u64, Option)> { - match &self.keeping { - Keeping::Recording(capturing) => Some((capturing.records, capturing.indices)), - _ => None, - } - } - - /// Note that the capture draw recording now records nothing (its capture form's objects or - /// pipeline not made yet): whether one is recording. - pub(super) fn capture_missed(&mut self) -> bool { - match &mut self.keeping { - Keeping::Recording(capturing) => { - capturing.missed = true; - true - } - _ => false, - } - } - - /// Note `uses`, the capture draw's recording now, among the capture draws'. - pub(super) fn capture_uses(&mut self, uses: CommandUses) { - if let Keeping::Recording(capturing) = &mut self.keeping { - capturing.uses.merge(uses); - } - } - - /// As the pass ends, before its steps: record its kept draws again as capture draws and, - /// before the pass, the steps that bin their primitives into a tile mask (the module docs), - /// where the pass's draws reach some tiles and a load pass rewrites them. `None` where it - /// does not, where a kept draw's capture form or pipeline is not made yet, or where the - /// device cannot: the pass's reach is then the host's, announced as before. - pub(super) fn capture_reach(&mut self) -> Option { - let reach = PassReach::of(&self.layout, self.called, self.drew); - let drawn = self.drawn.tiles(&self.layout); - let reaches = drawn.as_ref().is_none_or(|tiles| !tiles.is_empty()); - let consumed = super::unused_bits_load::consumes_capture(&self.layout, true); - if !self.rewrites_unused_bits || reach != PassReach::Draws || !reaches || !consumed { - return None; - } - let Keeping::Draws(kept, records) = &self.keeping else { - return None; - }; - if kept.is_empty() { - return None; - } - let records = *records; - let mut placed = Vec::with_capacity(kept.len()); - let mut states = Vec::with_capacity(kept.len() * TileReachModule::STATE_WORDS as usize * 4); - let mut first = 0u64; - for draw in kept { - let (count, instances) = counts(&draw.draw())?; - let Assembly::Primitives(topology) = draw.assembly() else { - return None; - }; - let state = draw.state(); - states.extend(state.reach_state()?); - placed.push(Placed { - first, - count, - instances, - topology, - restarts: matches!(draw.draw(), DrawCall::Indexed { .. }) - && topology == PrimitiveType::TriangleStrip, - culls: state.cull_mode() != CullMode::None, - }); - first += count * instances; - } - if first != records { - return None; - } - // The entries, one an instance of each draw of some primitives, and the primitives'. - let mut entries = Vec::new(); - let mut total = 0u32; - let mut count = 0u32; - for (state, draw) in placed.iter().enumerate() { - let records = u32::try_from(draw.count).ok()?; - let primitives = CaptureAssemblyModule::primitives(draw.topology, records); - if primitives == 0 { - continue; - } - for n in 0..draw.instances { - let at = u32::try_from(draw.first + n * draw.count).ok()?; - entries.extend(CaptureAssemblyModule::draw( - total, - at, - records, - draw.topology, - draw.restarts, - draw.culls, - u32::try_from(state).ok()?, - )); - total = total.checked_add(primitives)?; - count += 1; - } - } - if total == 0 { - return None; - } - let steps = self.capture_steps(records, total)?; - let recorded = self.record_captures(&steps)?; - let mut draws = CaptureAssemblyModule::header(count, total).to_vec(); - draws.extend(entries); - let area = self.layout.extent; - let mut pass = TileReachModule::header(area, 1, 1, total).to_vec(); - pass.extend(states); - // The tiles the host's reach names, which the load pass would rewrite without the - // capture: counted against the mask's once the command buffer completes. - let grid = u64::from(area[0].div_ceil(32)) * u64::from(area[1].div_ceil(32)); - let bound = drawn.as_ref().map_or(grid, DrawnTiles::count); - self.record_capture_steps(steps, recorded, (&draws, &pass), (grid, bound)) - } - - /// The scratch and kernels of a pass's capture of `records` records and `total` - /// primitives: `None` where the device makes no kernel (the tile reach's `shaderInt64`, among - /// others) or gives no device address. - fn capture_steps(&mut self, records: u64, total: u32) -> Option { - let device = self.core.device().clone(); - let kernels = [ - OwnedModule::CaptureAssembly, - OwnedModule::TileReach, - OwnedModule::CaptureSettle, - ] - .map(|which| device.owned_kernel(which).ok()); - let [Some(assembly), Some(reach), Some(settle)] = kernels else { - return None; - }; - let limits = &device.properties().description.limits; - let align = limits.min_storage_buffer_offset_alignment.max(32); - let mask_words = TileReachModule::mask_words(self.layout.extent, 1, 1); - let groups = |n: u32, local: u32| n.div_ceil(local).max(1); - let most = limits.max_compute_work_group_count[0]; - if groups(total, CaptureAssemblyModule::LOCAL_SIZE) > most - || groups(total, TileReachModule::LOCAL_SIZE) > most - || groups(mask_words, CaptureSettleModule::LOCAL_SIZE) > most - { - return None; - } - let records_bytes = records * u64::from(CaptureAssemblyModule::RECORD_WORDS) * 4; - let primitives_bytes = u64::from(total) * u64::from(TileReachModule::PRIMITIVE_WORDS) * 4; - let mask_bytes = u64::from(mask_words) * 4; - let range = u64::from(limits.max_storage_buffer_range); - if records_bytes > range || primitives_bytes > range || mask_bytes > range { - return None; - } - let primitives_at = records_bytes.next_multiple_of(align); - let mask_at = (primitives_at + primitives_bytes).next_multiple_of(align); - let scratch = device - .own_buffer(mask_at + mask_bytes, ResourceOptions::private()) - .ok()?; - let (raw, at) = scratch.at(0); - let address = scratch.device_address()?; - if !at.is_multiple_of(align) || !address.is_multiple_of(32) { - return None; - } - Some(CaptureSteps { - scratch, - raw, - records: (at, records_bytes, address), - primitives: (at + primitives_at, primitives_bytes), - mask: (at + mask_at, mask_bytes), - kernels: [assembly, reach, settle], - total, - mask_words, - }) - } - - /// Record the pass's kept draws again as capture draws, each through its capture form into - /// its records in `steps`' scratch, into an instance of a pass without attachments: the - /// instance and the draws' uses, or `None` where a draw records nothing (its capture form's - /// objects or pipeline not made yet, or a refusal). The encoder's current instance stays - /// the pass's; the pass keeps no draw from here on. - fn record_captures(&mut self, steps: &CaptureSteps) -> Option<(Instance, CommandUses)> { - let device = self.core.device().clone(); - let shape = attachmentless::shape(1, 0); - let compatible = Arc::new(render_target::compatible_pass(&device, &shape).ok()?); - let draws = self.core.command_buffer().begin_draws(&compatible).ok()?; - let instance = Instance { - draws, - shape: Versioned::new(shape), - compatible, - recorded: false, - shadow: false, - shader_tests: false, - imageblock: false, - interlocked_writes: InterlockedStorage::NONE, - indirect_reads: IndirectReads::new(), - geometry_writes: GeometryWrites::new(), - tile_memory: false, - barriers: false, - views: ViewSetup::default(), - pieces: Vec::new(), - shadows: InstanceShadows::default(), - before: Vec::new(), - reformats: Vec::new(), - positioned: None, - rerecord: None, - bound: Bound::default(), - drawn: DrawnArea::default(), - inline: false, - continues: false, - kept: None, - planned: false, - feedback: Feedback::NONE, - storage_colors: 0, - }; - let (_, _, base) = steps.records; - let recording = Keeping::Recording(Capturing { - records: base, - indices: None, - uses: CommandUses::default(), - missed: false, - }); - // The kept draws leave the pass's keeping for the capture draws' recording, the pass's - // instance for the capture's: each a state the encoder moves on to, given back below. - let Keeping::Draws(mut kept, _) = std::mem::replace(&mut self.keeping, recording) else { - return None; - }; - let current = std::mem::replace(&mut self.current, instance); - let mut first = 0u64; - let mut recorded = true; - for draw in kept.iter_mut() { - let Some((count, instances)) = counts(&draw.draw()) else { - recorded = false; - break; - }; - let indices = match draw.index() { - None => Some(None), - Some(index) => index.address().map(Some), - }; - let (Some(indices), Keeping::Recording(capturing)) = (indices, &mut self.keeping) - else { - recorded = false; - break; - }; - capturing.records = base + first * u64::from(CaptureAssemblyModule::RECORD_WORDS) * 4; - capturing.indices = indices; - let again = self.record_again(draw); - let missed = matches!(&self.keeping, Keeping::Recording(c) if c.missed); - if again.is_err() || missed { - recorded = false; - break; - } - first += count * instances; - } - let instance = std::mem::replace(&mut self.current, current); - // The pass ends: it keeps no draw from here on. - let Keeping::Recording(capturing) = std::mem::replace(&mut self.keeping, Keeping::Stopped) - else { - self.end_unrun(instance); - return None; - }; - if !recorded { - // A capture that records nothing is never executed. - self.end_unrun(instance); - return None; - } - Some((instance, capturing.uses)) - } - - /// Record, into the encoder's command buffer before the pass, the capture draws' instance - /// `recorded` and the kernels over `steps`' scratch: the records the draws write, assembled - /// into the primitives (the draws' `draws` bytes), binned into the mask under the pass's - /// header and states (`pass`), and settled. - fn record_capture_steps( - &mut self, - steps: CaptureSteps, - (instance, uses): (Instance, CommandUses), - (draws, pass): (&[u8], &[u8]), - (grid, bound): (u64, u64), - ) -> Option { - let device = self.core.device().clone(); - // SAFETY: only this encoder records the secondary command buffer. - unsafe { self.core.command_buffer().end_raw(instance.draws) }.ok()?; - let framebuffer = render_target::attachmentless_framebuffer( - &device, - &instance.compatible, - self.layout.extent, - ) - .ok()?; - let (draws_upload, pass_upload, status, tally) = { - let mut state = self.core.command_buffer().state(); - let draws_upload = state - .uploads - .upload(&device, draws, draws.len() as u64) - .ok()?; - let pass_upload = state - .uploads - .upload(&device, pass, pass.len() as u64) - .ok()?; - let status = state.status_words(&device).ok()?; - let tally = state.uploads.upload(&device, &[], steps.mask.1).ok()?; - (draws_upload, pass_upload, status, tally) - }; - let region = |upload: &crate::upload::Upload| (upload.raw(), upload.offset(), upload.len()); - let (records_at, records_bytes, _) = steps.records; - let records = (steps.raw, records_at, records_bytes); - let primitives = (steps.raw, steps.primitives.0, steps.primitives.1); - let mask = (steps.raw, steps.mask.0, steps.mask.1); - let status = (status.raw(), status.offset(), ExecutionStatus::BYTES as u64); - let [assembly, reach, settle] = steps.kernels; - let sets = OwnedSets::write_each( - &device, - &[assembly, reach, settle], - &[ - buffers(vec![records, region(&draws_upload), primitives]), - buffers(vec![primitives, region(&pass_upload), mask]), - buffers(vec![status, region(&pass_upload), mask]), - ], - ) - .ok()?; - let descriptor_sets = sets.sets.clone(); - let groups = [ - steps - .total - .div_ceil(CaptureAssemblyModule::LOCAL_SIZE) - .max(1), - steps.total.div_ceil(TileReachModule::LOCAL_SIZE).max(1), - steps - .mask_words - .div_ceil(CaptureSettleModule::LOCAL_SIZE) - .max(1), - ]; - let [width, height] = self.layout.extent; - let render_area = vk::Rect2D { - offset: vk::Offset2D { x: 0, y: 0 }, - extent: vk::Extent2D { width, height }, - }; - let (pass_raw, framebuffer_raw, capture_draws) = - (instance.compatible.raw, framebuffer.raw, instance.draws); - let stages = uses.iter().fold(CAPTURE_STAGES, |all, used| { - all | used.read.stages | used.write.stages - }); - let (mask_raw, mask_at, mask_bytes) = mask; - let tally_copy = vk::BufferCopy { - src_offset: mask_at, - dst_offset: tally.offset(), - size: mask_bytes, - }; - let tally_raw = tally.raw(); - self.core - .command_reaching(stages, &uses, uses.resident(), |raw, command_buffer| { - // SAFETY: the encoder's command buffer is recording outside a render pass (the - // pass records after it), and only the encoder records it; the pass without - // attachments, its framebuffer, the capture draws' secondary command buffer - // (recorded against that pass), the scratch, the uploads, the status words and - // the sets are live until the command buffer completes (retained below, the - // uploads and status words with the command buffer); every binding lies inside - // its buffer, and each step reads what the one before it wrote past a barrier. - unsafe { - Barrier::everything().record(raw, command_buffer); - raw.cmd_fill_buffer(command_buffer, mask_raw, mask_at, mask_bytes, 0); - let begin = vk::RenderPassBeginInfo::default() - .render_pass(pass_raw) - .framebuffer(framebuffer_raw) - .render_area(render_area); - raw.cmd_begin_render_pass( - command_buffer, - &begin, - vk::SubpassContents::SECONDARY_COMMAND_BUFFERS, - ); - raw.cmd_execute_commands(command_buffer, &[capture_draws]); - raw.cmd_end_render_pass(command_buffer); - for ((kernel, set), groups) in - steps.kernels.iter().zip(&descriptor_sets).zip(groups) - { - Barrier::everything().record(raw, command_buffer); - raw.cmd_bind_pipeline( - command_buffer, - vk::PipelineBindPoint::COMPUTE, - kernel.pipeline, - ); - raw.cmd_bind_descriptor_sets( - command_buffer, - vk::PipelineBindPoint::COMPUTE, - kernel.layout, - 0, - std::slice::from_ref(set), - &[], - ); - raw.cmd_dispatch(command_buffer, groups, 1, 1); - } - Barrier::everything().record(raw, command_buffer); - // The mask where the host counts it once the command buffer completes. - raw.cmd_copy_buffer(command_buffer, mask_raw, tally_raw, &[tally_copy]); - } - }); - self.core.retain(steps.scratch); - self.core.retain(sets); - self.core.retain(framebuffer); - self.core.retain(instance.compatible); - device - .shared() - .counts - .capture_reach_recorded(u64::from(steps.total)); - let tally = CaptureTally { - mask: tally, - grid, - bound, - }; - self.core - .command_buffer() - .state() - .capture_tallies - .push(tally); - Some(CapturedReach { mask }) - } -} - -/// A set of storage buffers alone, `(buffer, offset, range)` in binding order. -fn buffers(buffers: Vec<(vk::Buffer, u64, u64)>) -> OwnedSet { - OwnedSet { - images: Vec::new(), - storage_images: Vec::new(), - buffers, - } -} - -/// The stages the capture steps run in besides their draws' uses'. -const CAPTURE_STAGES: vk::PipelineStageFlags2 = vk::PipelineStageFlags2::from_raw( - vk::PipelineStageFlags2::TRANSFER.as_raw() - | vk::PipelineStageFlags2::VERTEX_SHADER.as_raw() - | vk::PipelineStageFlags2::COMPUTE_SHADER.as_raw(), -); - -/// A pass's capture scratch and kernels (`RenderCommandEncoder::capture_steps`). -struct CaptureSteps { - scratch: crate::Buffer, - /// The scratch's `VkBuffer`. - raw: vk::Buffer, - /// The records' offset in `raw`, their bytes, and their device address. - records: (u64, u64, u64), - /// The primitives' offset in `raw` and bytes. - primitives: (u64, u64), - /// The mask's offset in `raw` and bytes. - mask: (u64, u64), - /// The assembly's, the tile reach's and the settle's kernels. - kernels: [OwnedKernel; 3], - /// The primitives, and the mask's words. - total: u32, - mask_words: u32, -} diff --git a/crates/metal2vulkan-runtime/src/render/color_groups.rs b/crates/metal2vulkan-runtime/src/render/color_groups.rs index ba2d23590..964ccc325 100644 --- a/crates/metal2vulkan-runtime/src/render/color_groups.rs +++ b/crates/metal2vulkan-runtime/src/render/color_groups.rs @@ -75,7 +75,6 @@ //! its texture. A draw that reads its own group's attachments where it runs in that group alone //! reads them as in any pass (`texture/attached_reads.rs`). -use super::capture; use super::extended_shadow::ExtendedShadows; use super::{ reads_handles, DrawingState, Opening, RenderLog, RenderLowering, RenderPipelineState, @@ -419,16 +418,13 @@ pub(super) struct Ended { pub(super) core: EncoderCore, pub(super) residency: Residency, pub(super) log: Option, - /// A rebind may encode the encoder again from its log: its end captured no draws' tile - /// reach, whose tally lies in the command buffer (`render/capture.rs`). - pub(super) keeps_log: bool, pub(super) later: Option>, } impl Ended { /// The pass's later color groups drawn (the module docs), each over the encoder's core from - /// its log: the core, what the first group's encoder made resident, and the log where a - /// rebind may encode the encoder again from it. + /// its log: the core, what the first group's encoder made resident, and the log, from which + /// a rebind may encode the encoder again. pub(super) fn with_later_groups( self, ) -> Result<(EncoderCore, Residency, Option), Error> { @@ -436,7 +432,6 @@ impl Ended { mut core, residency, log, - mut keeps_log, later, } = self; if let Some(later) = later { @@ -452,12 +447,11 @@ impl Ended { )); } let ended = encoder.end_pass()?; - keeps_log &= ended.keeps_log; core = ended.core; core.device().shared().counts.color_group_pass(); } } - Ok((core, residency, log.filter(|_| keeps_log))) + Ok((core, residency, log)) } } @@ -631,10 +625,8 @@ impl RenderLowering { !depth_stencil && !writes_colors(state, g.group.colors().len()) } - /// A later group skips the draw: the pass's draws are no longer kept for capture replay in - /// that group's pass, whose reach is then the host's (`render/capture.rs`). + /// A later group skips the draw, counted. pub(super) fn group_skipped(&mut self) { - self.keeping = capture::Keeping::Stopped; self.core .device() .shared() diff --git a/crates/metal2vulkan-runtime/src/render/draw_shape.rs b/crates/metal2vulkan-runtime/src/render/draw_shape.rs index 484bc5aeb..911df35f0 100644 --- a/crates/metal2vulkan-runtime/src/render/draw_shape.rs +++ b/crates/metal2vulkan-runtime/src/render/draw_shape.rs @@ -538,8 +538,8 @@ impl ShapeInputs<'_> { .as_ref() .and_then(|ds| ds.depth_format) .or(settings.hidden.then_some(HIDDEN_DEPTH_FORMAT)); - let bias = self.state.vk_depth_bias(topology, depth_format, profile)?; - let depth_bias = DepthBiasRecord::of(&bias, device.shared().depth_bias_command)?; + let bias = self.state.vk_depth_bias(topology, profile)?; + let depth_bias = DepthBiasRecord::of(&bias); // A 16-bit unorm depth, biased or not, stores Metal's codes where the driver is measured // to (`render_state::announce_unorm_depth`). render_state::announce_unorm_depth(device, depth_format, &fixed.depth_stencil, &bias); diff --git a/crates/metal2vulkan-runtime/src/render/executions.rs b/crates/metal2vulkan-runtime/src/render/executions.rs index 9f94509e5..243d781e8 100644 --- a/crates/metal2vulkan-runtime/src/render/executions.rs +++ b/crates/metal2vulkan-runtime/src/render/executions.rs @@ -545,11 +545,10 @@ impl RenderLowering { if !icb.descriptor().inherit_pipeline_state { self.writers.runs(icb.written().named().writes); } - // An execution rewrites an extended-range or padded attachment as a draw does, of reset - // commands too, and a signed normalized one's minimum codes, and an + // An execution keeps an extended-range, padded or bfloat attachment's texels as a draw + // does, of reset commands too, and a signed normalized one's minimum codes, and an // `RGB9E5Float` one's words. self.degrade_kept_attachments(); - self.rewrites_unused_bits = true; self.degrade_extended_range_execution(); // Its commands write the extended-range colors' codes alone: the shadows end. self.end_extended_shadows(); @@ -654,8 +653,6 @@ impl RenderLowering { // Its pixels are not bounded by a viewport the host knows of. self.drawn.everywhere(); self.coverage.everywhere(); - // Nor do its positions run again before the pass (`render/capture.rs`). - self.keeping = super::capture::Keeping::Stopped; let inherited = icb.descriptor().inherit_buffers; // An execution's commands take their flat inputs from the first vertex whatever the // encoder's provoking vertex mode (Metal probes on the M3 Max, macOS 27.0.1). @@ -2388,7 +2385,6 @@ impl RenderExecution { tile_dispatch_calls: 0, replaying: true, rerouting: false, - keeping: super::capture::Keeping::Stopped, forms, replayed: None, drawn_before: snapshot.drawn.clone(), @@ -2410,9 +2406,6 @@ impl RenderExecution { // A pass that executes render commands keeps its attachments over buffers in place // (`kept_bytes.rs`), whatever its draws read. inputs_read: BTreeSet::new(), - // The encoder that executes the commands records the pass's load pass - // (`defer_execution`); this one records only the commands' draws. - rewrites_unused_bits: false, kept_attachments: None, // The executing encoder announces for the execution (`defer_execution`). extended_written: BTreeSet::new(), diff --git a/crates/metal2vulkan-runtime/src/render/extended_shadow.rs b/crates/metal2vulkan-runtime/src/render/extended_shadow.rs index 900aa9529..caee647f0 100644 --- a/crates/metal2vulkan-runtime/src/render/extended_shadow.rs +++ b/crates/metal2vulkan-runtime/src/render/extended_shadow.rs @@ -33,7 +33,7 @@ //! commands or a tile dispatch, whose commands write the codes alone, gives up every shadow: //! the codes hold the encode of the last `half` written, and the draws after it see them, as //! before the shadow. None starts again in the pass. Not while the encoder records an -//! execution's commands or a capture draw (`render/capture.rs`), which bind no shadow. +//! execution's commands, which bind no shadow. //! - **The announcement**. A draw that held a color's shadow read what Metal's tile memory holds, //! so `extended-range-blends-stored-codes` names only the colors a draw read from the codes //! (`degrade_extended_range_blends`, `ExtendedShadows::held`). @@ -413,10 +413,10 @@ fn color( impl RenderLowering { /// The shadows a draw binds: the held ones, none while the encoder records an execution's - /// commands or a capture draw. + /// commands. pub(super) fn extended_shadows_bound(&self) -> &BTreeSet { static NONE: BTreeSet = BTreeSet::new(); - match self.replaying || self.capture_addresses().is_some() { + match self.replaying { true => &NONE, false => &self.extended.live, } @@ -430,7 +430,6 @@ impl RenderLowering { if !self.extended.holds || self.replaying || self.rerouting - || self.capture_addresses().is_some() || pipeline.descriptor().vertex().is_none() { return Ok(()); @@ -540,7 +539,7 @@ impl RenderLowering { /// Once a draw of `pipeline` installed its instance: the shadows that instance first holds /// are set before it, and what it may write is noted. pub(super) fn installed_extended_draw(&mut self, pipeline: &DrawingState) { - if self.replaying || self.capture_addresses().is_some() { + if self.replaying { return; } let at = self.earlier.len(); diff --git a/crates/metal2vulkan-runtime/src/render/inline_first.rs b/crates/metal2vulkan-runtime/src/render/inline_first.rs index 0b4906278..7dad3828b 100644 --- a/crates/metal2vulkan-runtime/src/render/inline_first.rs +++ b/crates/metal2vulkan-runtime/src/render/inline_first.rs @@ -306,8 +306,8 @@ impl RenderLowering { /// Where the pass's first instance may record inline (`Inline::Open`) and the draw about to /// record into `next` is its first that records (`records`), decide: where the instance - /// allows it (the module docs; `made` its pipeline, `capture` a capture draw, `writes` that - /// the draw writes a memoryless color, `stood` a stand-in arriving with it), its render pass + /// allows it (the module docs; `made` its pipeline, `writes` that the draw writes a + /// memoryless color, `stood` a stand-in arriving with it), its render pass /// and framebuffer, and the command buffer the /// encoder holds for it, for [`begin_inline`](Self::begin_inline) once the draw installed /// its instance; else `None`, and the pass records as before: so for a draw whose `feedback` @@ -321,14 +321,14 @@ impl RenderLowering { &mut self, next: &Next, stood: Option<&PassLayout>, - (records, made, capture, writes): (bool, bool, bool, bool), + (records, made, writes): (bool, bool, bool), feedback: Feedback, ) -> Result, Error> { let begin = match feedback == Feedback::NONE { - true => self.decide_inline(next, stood, (records, made, capture, writes))?, + true => self.decide_inline(next, stood, (records, made, writes))?, false => { // Decided at this draw: the pass records its first instance in a secondary. - if matches!(self.inline, Inline::Open { .. }) && records && !capture { + if matches!(self.inline, Inline::Open { .. }) && records { self.inline = Inline::Never; (self.core.device().shared().counts).pass_not_inline(NotInline::Draws); } @@ -350,12 +350,12 @@ impl RenderLowering { &mut self, next: &Next, stood: Option<&PassLayout>, - (records, made, capture, writes): (bool, bool, bool, bool), + (records, made, writes): (bool, bool, bool), ) -> Result, Error> { let Inline::Open { splits } = self.inline else { return Ok(None); }; - if !records || capture { + if !records { return Ok(None); } // Decided at this draw, either way. diff --git a/crates/metal2vulkan-runtime/src/render/inline_splits.rs b/crates/metal2vulkan-runtime/src/render/inline_splits.rs index c7c9e6420..cd18501fc 100644 --- a/crates/metal2vulkan-runtime/src/render/inline_splits.rs +++ b/crates/metal2vulkan-runtime/src/render/inline_splits.rs @@ -243,14 +243,14 @@ pub(super) struct SplitBegin { impl RenderLowering { /// Whether the draw about to record into `next` begins a new instance that records inline /// after the current one (the module docs; `records`: the draw records, `made` its pipeline, - /// `capture` a capture draw, `stood` a stand-in arriving with it); where it does, the current + /// `stood` a stand-in arriving with it); where it does, the current /// instance's copies planned, which the draw records once installed. `None` where it does /// not, or where the plan is refused (the pass's end plans it again, and refuses it there). pub(super) fn inline_split( &mut self, next: &Next, stood: Option<&PassLayout>, - (records, made, capture): (bool, bool, bool), + (records, made): (bool, bool), ) -> Option { let inline_first::Inline::Begun(begun) = &self.inline else { return None; @@ -271,7 +271,6 @@ impl RenderLowering { let admitted = begun.splits && records && made - && !capture && self.current.inline && !self.current.continues && !self.replaying diff --git a/crates/metal2vulkan-runtime/src/render/replay.rs b/crates/metal2vulkan-runtime/src/render/replay.rs index 667d0daf1..a31373ce5 100644 --- a/crates/metal2vulkan-runtime/src/render/replay.rs +++ b/crates/metal2vulkan-runtime/src/render/replay.rs @@ -12,9 +12,7 @@ //! - **Kept** as the compute encoder's log is (`EncoderCore::end_with_replay`): where a command //! named a buffer over host pages, and the pass left no segment for later but its executions of //! indirect command buffers, which the encoding again records at once on the GPU alone, as its -//! commit did (no draw whose pipeline was still being made). A pass whose draws' tile -//! reach its end captures (`capture.rs`) keeps none: the capture's tally lies in the command -//! buffer, where an encoding again would leave the first one's beside its own. +//! commit did (no draw whose pipeline was still being made). //! - **Per-stage calls** share a variant, with the [`Table`] they set. use super::RenderLowering; diff --git a/crates/metal2vulkan-runtime/src/render/reroute.rs b/crates/metal2vulkan-runtime/src/render/reroute.rs index fdd08ed7a..f52252a1b 100644 --- a/crates/metal2vulkan-runtime/src/render/reroute.rs +++ b/crates/metal2vulkan-runtime/src/render/reroute.rs @@ -62,28 +62,6 @@ pub(super) struct Rerecord { held: Held, } -impl Rerecord { - /// The draw. - pub(super) fn draw(&self) -> DrawCall { - self.draw - } - - /// What the draw assembles. - pub(super) fn assembly(&self) -> Assembly { - self.assembly - } - - /// The encoder's state at the draw. - pub(super) fn state(&self) -> &EncoderState { - &self.held.state - } - - /// The draw's indices, read in place. - pub(super) fn index(&self) -> Option<&KeptSource> { - self.index.as_ref() - } -} - /// The encoder's state a draw reads, as it stood at the draw. struct Held { pipeline: Option, @@ -151,7 +129,6 @@ impl RenderLowering { .is_some_and(|draws| !draws.is_empty()); if self.replaying || self.rerouting - || self.capture_addresses().is_some() || !current.recorded || !kept || self.layout.fetch_inputs @@ -267,27 +244,6 @@ impl RenderLowering { } } - /// The draw just recorded (`call` of `assembly` and `draw`, its indices from `index`) with - /// the encoder's state at it, kept for recording again elsewhere (`render/capture.rs`); - /// `None` where its indices cannot be kept. - pub(super) fn kept_draw( - &self, - (call, assembly, draw): (&'static str, Assembly, DrawCall), - index: Option<&DrawSource<'_>>, - ) -> Option { - let index = match index { - Some(source) => Some(source.kept()?), - None => None, - }; - Some(Rerecord { - call, - assembly, - draw, - index, - held: self.held(), - }) - } - /// Exchange the encoder's state a draw reads with `held`. fn swap_held(&mut self, held: &mut Held) { std::mem::swap(&mut self.pipeline, &mut held.pipeline); diff --git a/crates/metal2vulkan-runtime/src/render/shadows.rs b/crates/metal2vulkan-runtime/src/render/shadows.rs index 5c9e96c37..18e13360c 100644 --- a/crates/metal2vulkan-runtime/src/render/shadows.rs +++ b/crates/metal2vulkan-runtime/src/render/shadows.rs @@ -20,9 +20,8 @@ //! back. A pass whose draws do reach tiles, some or (where it clears and stores an attachment) //! every one, changes a color attachment it loads (as the encoder set its load, so no clear //! before the pass reaches it: a clear past the render area clears attachments loaded `Clear` -//! alone, `clear_reach.rs`) only inside its draws' scissors (`clear_reach::DrawnArea`), the -//! load pass of a format whose tiles Metal stores otherwise rewriting the buffer's bytes before -//! it (`render/unused_bits_load.rs`): only those texels are copied back, and, where the pass +//! alone, `clear_reach.rs`) only inside its draws' scissors (`clear_reach::DrawnArea`): only +//! those texels are copied back, and, where the pass //! takes the texture in no other way, only those are copied in, as nothing the pass reads //! outside them reaches anything but the image (its load is stored back unchanged, and a //! fragment reads the attachment at its own pixel alone). A texture over a buffer with an diff --git a/crates/metal2vulkan-runtime/src/render/snapshot.rs b/crates/metal2vulkan-runtime/src/render/snapshot.rs index c140aec9b..d6ee25233 100644 --- a/crates/metal2vulkan-runtime/src/render/snapshot.rs +++ b/crates/metal2vulkan-runtime/src/render/snapshot.rs @@ -70,7 +70,7 @@ //! - **Where it runs** (each check else the split, as before): the device enabled //! `attachmentFeedbackLoopLayout`, `extendedDynamicState3ColorWriteMask` and //! `fragmentShaderPixelInterlock` (`dynamic_state::ColorWriteMasks`); the draw follows a barrier -//! inside its instance, records no execution's command, capture or reroute, and runs in a pass +//! inside its instance, records no execution's command or reroute, and runs in a pass //! with no visibility query active, no input attachment fetch, rasterization-rate map, views or //! more than one sample or layer; every slot of the draw that reads a color attachment's texture //! is a fragment slot its function can read through a snapshot (`StageModule::snapshot_textures`) @@ -256,9 +256,8 @@ impl RenderLowering { &self, pipeline: &DrawingState, reformats: &[Reformat], - capture: bool, ) -> Option { - if capture || self.replaying || self.rerouting || !(self.current.barriers || self.barrier) { + if self.replaying || self.rerouting || !(self.current.barriers || self.barrier) { return None; } let base = pipeline.base(); diff --git a/crates/metal2vulkan-runtime/src/render/tile_dispatch.rs b/crates/metal2vulkan-runtime/src/render/tile_dispatch.rs index 5bb661dc7..2bf317a3b 100644 --- a/crates/metal2vulkan-runtime/src/render/tile_dispatch.rs +++ b/crates/metal2vulkan-runtime/src/render/tile_dispatch.rs @@ -1237,8 +1237,6 @@ impl RenderLowering { // Its pixels are not bounded by a viewport the host knows of. self.drawn.everywhere(); self.coverage.everywhere(); - // Nor do its positions run again before the pass (`render/capture.rs`). - self.keeping = super::capture::Keeping::Stopped; let executed = || ExecutedPipeline::Compute(Arc::clone(variant.shared_pipeline())); match (&made_pipelines, creation) { (Some(made), _) => self.core.executed(|| { diff --git a/crates/metal2vulkan-runtime/src/render/tile_store.rs b/crates/metal2vulkan-runtime/src/render/tile_store.rs new file mode 100644 index 000000000..143eb3e39 --- /dev/null +++ b/crates/metal2vulkan-runtime/src/render/tile_store.rs @@ -0,0 +1,150 @@ +//! What a render pass's store keeps of the texels its draws do not write, where Metal's tile store +//! rewrites them: the kept-attachment notices a draw announces. +//! +//! - **Metal's answer** (an Apple M3 Max under macOS 27.0.1, and an Apple M4). An Apple GPU stores +//! a render pass's attachments a 32 x 32 tile at a time, and a pass that loads a color attachment +//! and records a draw writes every texel of each tile a draw's primitives reach back, through its +//! tile memory: the texels no fragment covers, fragments that discard or fail a test, and +//! channels a write mask leaves out among them. A tile no draw reaches keeps its bytes, and a +//! pass that draws nothing keeps every texel. +//! - An extended-range or padded 10-bit attachment (`BGR10_XR`, `BGRA10_XR`, `RGB10A8_2P_XR10`, +//! `R10Unorm_X6`, `RG10Unorm_X12` or one of their `_sRGB` twins) keeps each texel's codes with +//! the bits they leave unused made canonical: `BGR10_XR`'s bits 30 and 31 ones, +//! `BGRA10_XR`'s low six bits of each field zeros and its alpha code clamped to `[384, 894]`, +//! the two-plane color word's top two bits zeros, a padded word's low six bits zeros, a padded +//! `_sRGB` twin's codes through Metal's table. +//! - A bfloat attachment (`R16Bfloat`, `RG16Bfloat`, `RGBA16Bfloat`) holds `half` values in its +//! tiles: every code of each tile it stores back goes through `half` to nearest even and back +//! to the nearest bfloat code, a NaN to `0x7fc0` (on the M4, every code of each format: 56,829 +//! move; on the M3 Max our probe `bfl`, every code of the tile a small triangle reached). +//! - A single-sampled signed normalized attachment stores a channel's minimum code (-128, or +//! -32768) as the code above it, and an `RGB9E5Float` one normalizes a word whose largest +//! mantissa is below 256 under an exponent above 0 (the M3 Max). +//! - **The runtime's answer: the device's load and store.** The device's pass keeps every byte its +//! draws do not write (`VK_ATTACHMENT_STORE_OP_STORE` of a loaded attachment), on every device: +//! no code is rewritten before or after the pass. A draw announces what differs, naming the +//! attachments of its pass: `extended-range-bits-kept` for an extended-range, padded or bfloat +//! one ([`bits_kept`]), `snorm-minimum-kept` ([`snorm_minimum_kept`]) and +//! `shared-exponent-kept` ([`shared_exponent_kept`]), the last two but on a driver whose pass +//! stores them as Metal's (`DriverFact::TileStoreIsMetals`: MoltenVK's pass is a Metal pass). A +//! pass whose store discards the attachment (`DontCare`) keeps nothing either way. The first +//! notice holds on MoltenVK too: an extended-range, padded or bfloat attachment is an image of +//! an unsigned integer format on every device (`metal::format::ExtendedRange`), whose codes a +//! Metal pass stores as they are. + +use crate::device::Device; +use crate::render_pass::{ColorTarget, PassLayout, Target}; +use crate::render_values::{LoadAction, StoreAction}; +use metal2vulkan::device::DriverFact; +use metal2vulkan::metal::format::ExtendedRange; +use metal2vulkan::metal::PixelFormat; + +/// The texture's own target of `color`: a stand-in's (`attachment_stand_in.rs`) is the one it +/// stands in for. +fn own(color: &ColorTarget) -> &Target { + color.stand_in.as_ref().map_or(&color.target, |s| &s.own) +} + +/// Whether `device`'s render pass stores a signed normalized minimum code and an `RGB9E5Float` +/// word as Metal's tile store does (`DriverFact::TileStoreIsMetals`: MoltenVK's pass is a Metal +/// pass). +pub(super) fn metals_store(device: &Device) -> bool { + device + .properties() + .driver_facts + .contains(&DriverFact::TileStoreIsMetals) +} + +/// Whether `color` is an attachment of an extended-range, padded 10-bit or bfloat format, loaded +/// and not discarded at the store (a store action the encoder decides later counts as storing): +/// Metal's pass, once it draws, rewrites the texels its draws do not write, where the device's +/// pass keeps their bytes (the module docs). +pub(super) fn bits_kept(color: &ColorTarget) -> bool { + let discarded = color.store == StoreAction::DontCare && !color.late_store; + ExtendedRange::of(own(color).texture.pixel_format()).is_some() + && color.load == LoadAction::Load + && !color.memoryless + && !discarded +} + +/// The signed normalized color formats whose minimum code Metal's tile store rewrites, as +/// measured on an Apple M3 Max (`snorm-minimum-kept`). +const SNORM_MINIMUM: [PixelFormat; 6] = [ + PixelFormat::R8Snorm, + PixelFormat::RG8Snorm, + PixelFormat::RGBA8Snorm, + PixelFormat::R16Snorm, + PixelFormat::RG16Snorm, + PixelFormat::RGBA16Snorm, +]; + +/// Whether `color` is a single-sampled attachment of a signed normalized format +/// ([`SNORM_MINIMUM`]), loaded and not discarded at the store: Metal's pass, once it draws, writes +/// each tile a draw reaches back through the channels' values, so a minimum code (-128, or -32768) +/// is stored as the code above it, where the device's pass keeps the bytes its draws do not write +/// (`degrade_snorm_minimum`, which reads `DriverFact::TileStoreIsMetals`: a driver whose pass +/// stores them as Metal's). +pub(super) fn snorm_minimum_kept(color: &ColorTarget) -> bool { + kept_through_store(color, |format| SNORM_MINIMUM.contains(&format)) +} + +/// Whether `color` is a single-sampled `RGB9E5Float` attachment, loaded and not discarded at the +/// store: Metal's pass, once it draws, writes each tile a draw reaches back through its texels' +/// values, so a word whose largest mantissa is below 256 under an exponent above 0 (one no Metal +/// write leaves) is stored normalized, its mantissas shifted up as its exponent steps down, where +/// the device's pass keeps the bytes its draws do not write (`degrade_shared_exponent`, which reads +/// `DriverFact::TileStoreIsMetals`). +pub(super) fn shared_exponent_kept(color: &ColorTarget) -> bool { + kept_through_store(color, |format| format == PixelFormat::RGB9E5Float) +} + +/// Whether `color` is a single-sampled attachment of a format `of` takes, loaded and not +/// discarded at the store. +fn kept_through_store(color: &ColorTarget, of: impl Fn(PixelFormat) -> bool) -> bool { + let target = own(color); + let discarded = color.store == StoreAction::DontCare && !color.late_store; + of(target.texture.pixel_format()) + && target.samples == 1 + && color.load == LoadAction::Load + && !color.memoryless + && !discarded +} + +/// The color attachments of a pass's layout that each of a draw's kept-attachment notices names, as +/// `color {index}, {format:?}`: the extended-range, padded and bfloat ones ([`bits_kept`], +/// `degrade_unused_bits`) and, on a driver whose pass does not store as Metal's +/// ([`metals_store`]), the signed normalized ones ([`snorm_minimum_kept`], +/// `degrade_snorm_minimum`) and the `RGB9E5Float` ones ([`shared_exponent_kept`], +/// `degrade_shared_exponent`). They read the layout's colors, their textures' formats and samples, +/// and the device's driver facts; all but the layout are fixed at creation, so an encoder decides +/// them once for each layout it records under. +#[derive(Debug, Default, PartialEq)] +pub(super) struct KeptAttachments { + pub(super) unused_bits: Vec, + pub(super) snorm_minimum: Vec, + pub(super) shared_exponent: Vec, +} + +impl KeptAttachments { + /// The kept attachments of `layout`, a pass of `device`'s. + pub(super) fn of(layout: &PassLayout, device: &Device) -> Self { + let metals = metals_store(device); + let mut kept = Self::default(); + for (index, color) in layout.colors.iter().enumerate() { + let Some(color) = color else { + continue; + }; + let name = || format!("color {index}, {:?}", color.target.texture.pixel_format()); + if bits_kept(color) { + kept.unused_bits.push(name()); + } + if !metals && snorm_minimum_kept(color) { + kept.snorm_minimum.push(name()); + } + if !metals && shared_exponent_kept(color) { + kept.shared_exponent.push(name()); + } + } + kept + } +} diff --git a/crates/metal2vulkan-runtime/src/render/unused_bits_load.rs b/crates/metal2vulkan-runtime/src/render/unused_bits_load.rs deleted file mode 100644 index b39ec934c..000000000 --- a/crates/metal2vulkan-runtime/src/render/unused_bits_load.rs +++ /dev/null @@ -1,877 +0,0 @@ -//! The load pass of an extended-range, padded 10-bit or bfloat color attachment. -//! -//! - **Metal's answer** (on an Apple M4 under macOS 27.0.1 and on the consumer's Apple M3 Max under -//! macOS 26.7, alike; on both). An Apple GPU stores a render pass's attachments a 32 x 32 tile at -//! a time. A pass that loads a color attachment of `BGR10_XR`, `BGRA10_XR`, `RGB10A8_2P_XR10`, -//! `R10Unorm_X6`, `RG10Unorm_X12` or one of their `_sRGB` twins and records a draw writes every -//! texel of each tile it stores back: a channel a fragment writes takes the write, and every -//! other texel keeps its codes with the bits they leave unused made canonical -//! (`bind::unused_bits_module`: `BGR10_XR`'s bits 30 and 31 ones, `BGRA10_XR`'s low six bits of -//! each field zeros and its alpha code clamped to `[384, 894]`, the two-plane color word's top -//! two bits zeros, a padded word's low six bits zeros, the padded `_sRGB` twins' codes through -//! Metal's table). That includes the texels no fragment covers, fragments that discard or fail a -//! test, and channels a write mask leaves out. A pass that loads a bfloat color attachment -//! (`R16Bfloat`, `RG16Bfloat`, `RGBA16Bfloat`) and draws does so too, its tiles holding `half` -//! values: every code of each tile it stores back goes through `half` to nearest even and back to -//! the nearest bfloat code, a NaN to `0x7fc0` (`ExtendedRange::load_code`; on an Apple M4 -//! under macOS 27.0.1, every code of each format: 56,829 move, and only in the tiles the draws' -//! primitives reach; the M3 Max under macOS 27.0.1 alike, our probe `bfl`: every code of the -//! tile a small triangle reached, of each format, and none elsewhere). The tiles it stores are those a draw's primitives reach (the half of a rect -//! whose edge lies on x = 32 reaches the tiles right of it; a zero-area rect or one off the -//! target reaches none), within the render area rounded up to 32 texels a side from the origin -//! and kept within the texture; every tile of it where a color attachment of the pass is cleared -//! and stored, a draw of nothing (of no vertices, say) too. A pass that draws nothing keeps every -//! texel. -//! - **The runtime's answer.** Before a pass that loads such an attachment, stores it and records -//! a draw call or an execution of render commands, ahead of the pass's other steps (a shadow's -//! or a stand-in's copy in among them), the encoder copies the region's texels into a scratch -//! buffer, rewrites the words of each tile a [`TileReach`] names there (one dispatch of -//! `bind::unused_bits_module` of the attachment's form a band of rows), and copies them back. -//! The texels come from the buffer's bytes of a texture over a buffer, a surface's plane, or a -//! texture buffer's attachment twin (`Texture::attachment_twin`), a 2D texture or a 2D array -//! view of one layer (a two-plane format's plane 0 color words alone, `TexelWords::ColorPlane`), -//! and from the image of any other single-sampled texture the runtime holds as an image of its -//! own (`TexelWords::Raw`), every layer the pass renders of its level. The pass then loads -//! Metal's texels, and a write mask, a discard, a test and a texel no draw covers keep them as -//! Metal's pass does. A pass whose store discards the attachment (`DontCare`, which leaves the -//! bytes as they were) is left alone. -//! - **A rotated texture's frame**. A rotated texture renders through its twin of the pass's frame -//! (`rotated.rs`), an image the shadow's copy in fills from the plane's bytes by Metal's load map -//! (`Turn::Load`, in a pass that draws). Its tiles are the frame's, so the load pass rewrites -//! that image instead, right after the pass's shadows' copies in ([`record_frames`]) and before -//! its stand-ins' copies and clears: the frame's texels of each tile, mapped back through the -//! rotation by the copy out (`Turn::Store`) as the pass's own writes are, which leaves the -//! plane's words as Metal's pass leaves them, by Metal's tile rule and rotation maps (each -//! measured on its own). -//! - **The reach** ([`TileReach`], from the pass's `clear_reach::PassReach`). None in a pass whose -//! draws reach no tile (each draws nothing, of no vertex or instance or through a pipeline that -//! rasterizes nothing, and no attachment is cleared and stored): the pass keeps every texel, as -//! Metal's does. Every tile of the region, exact, where an attachment of a pass of one layer is -//! cleared and stored. Elsewhere the tiles the draws' viewports and scissors reach -//! (`clear_reach::DrawnArea`; every tile through a rasterization-rate map, an execution of render -//! commands or a tile dispatch), and `unreached-tiles-rewritten` names the attachments, whose -//! tiles there no draw reaches are rewritten here where Metal keeps them; but where capture -//! replay found the tiles the draws' primitives reach (`render/capture.rs`, Metal's, announced by -//! the command buffer where a primitive's reach was not measured). -//! - **A signed normalized or `RGB9E5Float` attachment** keeps the device's load and store. The -//! same pass, once it draws, writes a single-sampled such attachment's tiles back through their -//! values (an Apple M3 Max under macOS 27.0.1): a channel's minimum code (-128, or -32768) is -//! stored as the code above it, and a word whose largest mantissa is below 256 under an exponent -//! above 0 normalized. The device's pass keeps such a code or word, and a draw announces -//! `snorm-minimum-kept` or `shared-exponent-kept` ([`snorm_minimum_kept`], -//! [`shared_exponent_kept`]), but on a driver whose pass stores them as Metal's -//! (`DriverFact::TileStoreIsMetals`: MoltenVK's pass is a Metal pass). -//! - **Not here** (`degrade_unused_bits` announces `extended-range-bits-kept` at each draw): a -//! multisampled attachment (no copy reaches its samples), a texture held as a shadow of another -//! image or of a heap's bytes, a sparse one, and one whose image the device does not copy both -//! ways. A padded format takes no multisample texture, Metal's validation stopping one, and -//! reaches the rest through a heap or a sparse heap, which make one of it as the device does -//! (`metal::format::padded_words`). - -use super::capture::CapturedReach; -use crate::buffer_texture::Texels; -use crate::clear_reach::{DrawnTiles, PassReach}; -use crate::degradation::Degradation; -use crate::device::functions::Vk; -use crate::device::Device; -use crate::encoder::EncoderCore; -use crate::error::{internal, Error}; -use crate::owned_kernel::{OwnedModule, OwnedSets}; -use crate::render_pass::{ColorTarget, PassLayout, Target}; -use crate::render_values::{LoadAction, StoreAction}; -use crate::shadow::ShadowTarget; -use crate::texture::Texture; -use crate::tracker::{Access, Barrier, Use, UseRange}; -use crate::values::ResourceOptions; -use ash::vk; -use metal2vulkan::bind::{TexelWords, UnusedBitsModule}; -use metal2vulkan::device::DriverFact; -use metal2vulkan::metal::format::ExtendedRange; -use metal2vulkan::metal::{PixelFormat, TextureType}; -use metal2vulkan::vk::{ImageType, ImageUsageFlags}; - -/// The side, in texels, of the tiles Metal stores. -const TILE: u32 = UnusedBitsModule::TILE; - -/// The scratch's largest band of rows: 32 MiB. -const MAX_SCRATCH: u64 = 32 << 20; - -/// The tiles of a pass's region whose texels the load pass rewrites: those Metal's tile store -/// writes back, the tiles its draws reach (the module docs). -#[derive(Clone, Copy, Debug)] -pub(super) enum TileReach<'a> { - /// Every tile: Metal's answer where `exact`, else where Metal's are the tiles the draws' - /// primitives reach, until those are captured. - Every { exact: bool }, - /// The tiles the draws' viewports and scissors reach (`clear_reach::DrawnTiles`, 32 by 32): - /// Metal's answer in each tile outside them, every tile inside rewritten. - Within(&'a DrawnTiles), - /// The tiles the draws' primitives reach, as capture replay binned them before the pass - /// (`render/capture.rs`): Metal's answer, but where a primitive's reach was not measured, - /// where the mask holds every tile and the command buffer announces it as it completes. - Captured(&'a CapturedReach), -} - -/// What fills a load pass's tile mask ([`TileReach::mask`]). -enum Mask { - /// Every tile. - Every, - /// These words. - Words(Vec), - /// The words of capture replay's mask: its `VkBuffer`, offset and bytes. - Captured((vk::Buffer, u64, u64)), -} - -impl<'a> TileReach<'a> { - /// The tiles the load pass rewrites in a pass whose draws reach `reach`: those `captured` - /// names where capture replay binned them, else within `tiles` where those bound them; none - /// where they reach none (`clear_reach.rs`). - pub(super) fn of( - reach: PassReach, - tiles: Option<&'a DrawnTiles>, - captured: Option<&'a CapturedReach>, - ) -> Option> { - match (reach, captured, tiles) { - (PassReach::Nothing, ..) => None, - (PassReach::Every, ..) => Some(TileReach::Every { exact: true }), - (PassReach::Draws, Some(captured), _) => Some(TileReach::Captured(captured)), - (PassReach::Draws, None, None) => Some(TileReach::Every { exact: false }), - (PassReach::Draws, None, Some(tiles)) => Some(TileReach::Within(tiles)), - } - } - - /// Whether the reach is Metal's (a captured one's where its primitives' reach was measured, - /// which the command buffer announces otherwise). - fn exact(self) -> bool { - match self { - TileReach::Every { exact } => exact, - TileReach::Within(_) => false, - TileReach::Captured(_) => true, - } - } - - /// The mask (one bit a tile, `bind::UnusedBitsModule`'s order) of `layers` layers of - /// `tile_rows` rows of `tiles_per_row` tiles, of `bytes` bytes. A captured mask is binned in - /// the same order over the render area (`bind::TileReachModule`, of one layer), whose tiles - /// are the region's: its bytes are the mask's, else the load pass is refused. - fn mask( - self, - tiles_per_row: u64, - tile_rows: u64, - (layers, bytes): (u64, u64), - ) -> Result { - // A pass's tiles are 32 by 32 at one sample, the only count the load pass takes. - let tiles = match self { - TileReach::Within(tiles) if tiles.tile() == [TILE, TILE] => tiles, - TileReach::Captured(captured) => { - let (_, _, captured_bytes) = captured.mask; - return match layers == 1 && captured_bytes == bytes { - true => Ok(Mask::Captured(captured.mask)), - false => Err(internal("a captured tile mask of another grid")), - }; - } - _ => return Ok(Mask::Every), - }; - let per_layer = tiles_per_row * tile_rows; - let mut words = vec![0u32; (layers * per_layer).div_ceil(32) as usize]; - for layer in 0..layers { - for ty in 0..tile_rows { - for tx in 0..tiles_per_row { - let reached = match (u32::try_from(tx), u32::try_from(ty)) { - (Ok(tx), Ok(ty)) => tiles.contains(tx, ty), - _ => true, - }; - if reached { - let t = (layer * per_layer + ty * tiles_per_row + tx) as usize; - words[t / 32] |= 1 << (t % 32); - } - } - } - } - Ok(Mask::Words(words)) - } -} - -/// Record `mask` (of `bytes`) into `buffer` at `offset`. -/// -/// # Safety -/// -/// `command_buffer` is recording, outside a render pass, and `offset..offset + bytes` lies in -/// `buffer`, a multiple of 4 from a multiple of 4, and is not in use; a mask's words are -/// `bytes / 4` words, and a captured mask's bytes are `bytes` of a live buffer, written before a -/// barrier the command buffer recorded already. -unsafe fn record_mask( - raw: &Vk, - command_buffer: vk::CommandBuffer, - (buffer, offset, bytes): (vk::Buffer, u64, u64), - mask: &Mask, -) { - match mask { - // SAFETY: the caller's contract. - Mask::Every => unsafe { - raw.cmd_fill_buffer(command_buffer, buffer, offset, bytes, u32::MAX) - }, - Mask::Captured((from, at, _)) => { - let region = vk::BufferCopy { - src_offset: *at, - dst_offset: offset, - size: bytes, - }; - // SAFETY: the caller's contract. - unsafe { raw.cmd_copy_buffer(command_buffer, *from, buffer, &[region]) }; - } - // At most 65536 bytes an update, as `vkCmdUpdateBuffer` takes. - Mask::Words(words) => { - for (i, chunk) in words.chunks(1 << 14).enumerate() { - let bytes: Vec = chunk.iter().flat_map(|w| w.to_le_bytes()).collect(); - let at = offset + (i as u64) * (4 << 14); - // SAFETY: the caller's contract; the chunk lies in the mask's bytes. - unsafe { raw.cmd_update_buffer(command_buffer, buffer, at, &bytes) }; - } - } - } -} - -/// Where the load pass finds a taken attachment's texels. -enum Source<'a> { - /// The rows of a buffer's bytes, held as the words named. - Bytes(&'a Texels, TexelWords), - /// The texture's own image, its raw texels. - Image, - /// A rotated texture's image of the pass's frame, its raw texels, rewritten after the pass's - /// shadows' copies in ([`record_frames`]). - Frame, -} - -/// A color attachment the load pass takes: its format, the target whose texels it rewrites (the -/// texture's own, where a stand-in renders for it), and where it finds them. -struct Taken<'a> { - format: PixelFormat, - target: &'a Target, - source: Source<'a>, -} - -/// The texture's own target of `color`: a stand-in's (`attachment_stand_in.rs`) is the one it -/// stands in for. -fn own(color: &ColorTarget) -> &Target { - color.stand_in.as_ref().map_or(&color.target, |s| &s.own) -} - -/// Whether the load pass rewrites a texture of `texture`'s format: an extended-range, padded or -/// bfloat one's. -fn rewrites(texture: &Texture) -> bool { - ExtendedRange::of(texture.pixel_format()).is_some() -} - -/// Whether `device`'s render pass stores a signed normalized minimum code and an `RGB9E5Float` -/// word as Metal's tile store does (`DriverFact::TileStoreIsMetals`: MoltenVK's pass is a Metal -/// pass). -pub(super) fn metals_store(device: &Device) -> bool { - device - .properties() - .driver_facts - .contains(&DriverFact::TileStoreIsMetals) -} - -/// Whether `color` is of a format the load pass rewrites ([`rewrites`]), loaded and not -/// discarded at the store; `late` counts a store action the encoder decides later as storing. -fn loaded(color: &ColorTarget, late: bool) -> bool { - let discarded = color.store == StoreAction::DontCare && !(late && color.late_store); - rewrites(&own(color).texture) - && color.load == LoadAction::Load - && !color.memoryless - && !discarded -} - -/// The color attachment `color` as the load pass takes it (the module docs), or `None` where it -/// does not. -fn takes(color: &ColorTarget, late: bool) -> Option> { - if !loaded(color, late) { - return None; - } - let target = own(color); - let texture = &target.texture; - let format = texture.pixel_format(); - let turned = texture - .shadow() - .is_some_and(|copies| matches!(copies.target(), Some(ShadowTarget::Rotated { .. }))); - if target.samples != 1 { - return None; - } - let copied = ImageUsageFlags::TRANSFER_SRC | ImageUsageFlags::TRANSFER_DST; - let copies_both_ways = || { - texture - .image_plan() - .is_ok_and(|plan| plan.usage.contains(copied)) - }; - // A rotated texture's frame, which its shadow's copy in fills. - if turned { - return copies_both_ways().then_some(Taken { - format, - target, - source: Source::Frame, - }); - } - if let Some(texels) = texture.buffer_texels() { - let words = match ExtendedRange::of(format) { - Some(ExtendedRange::Planes { .. }) => TexelWords::ColorPlane, - _ => TexelWords::Raw, - }; - let flat = matches!( - texture.texture_type(), - TextureType::Type2D | TextureType::Type2DArray - ) && target.layers == 1; - let texel = u64::from(UnusedBitsModule::texel_bytes(format, words)?); - let rows_of_texels = texels.layout.row_bytes == u64::from(target.extent[0]) * texel; - return (flat && rows_of_texels).then_some(Taken { - format, - target, - source: Source::Bytes(texels, words), - }); - } - let image = texture.shadow().is_none() && !texture.is_sparse() && copies_both_ways(); - image.then_some(Taken { - format, - target, - source: Source::Image, - }) -} - -/// Whether capture replay's reach has a consumer in a pass of `layout` (`render/capture.rs`): the -/// load pass takes one of its color attachments, as the pass begins (`ended` false) or as it ends -/// (`ended`: its store actions set, one still `Unknown` discarding), and no rotated texture's -/// frame among them. A frame's twin is copied out whole (`rotated.rs`), so a tile no primitive -/// reaches would store the texels its copy in loaded where Metal's pass keeps the plane's (a -/// mirror at rotation 4): such a pass keeps the host's reach, announced. -pub(super) fn consumes_capture(layout: &PassLayout, ended: bool) -> bool { - let mut taken = layout - .colors - .iter() - .flatten() - .filter(|color| !ended || color.store != StoreAction::Unknown) - .filter_map(|color| takes(color, !ended)) - .peekable(); - taken.peek().is_some() && taken.all(|taken| !matches!(taken.source, Source::Frame)) -} - -/// Whether `color` is of an extended-range, padded or bfloat format, loaded and not discarded at -/// the store, where the load pass does not take it (`degrade_unused_bits`). -pub(super) fn untaken(color: &ColorTarget) -> bool { - ExtendedRange::of(own(color).texture.pixel_format()).is_some() - && loaded(color, true) - && takes(color, true).is_none() -} - -/// The signed normalized color formats whose minimum code Metal's tile store rewrites, as -/// measured on an Apple M3 Max (`snorm-minimum-kept`). -const SNORM_MINIMUM: [PixelFormat; 6] = [ - PixelFormat::R8Snorm, - PixelFormat::RG8Snorm, - PixelFormat::RGBA8Snorm, - PixelFormat::R16Snorm, - PixelFormat::RG16Snorm, - PixelFormat::RGBA16Snorm, -]; - -/// Whether `color` is a single-sampled attachment of a signed normalized format -/// ([`SNORM_MINIMUM`]), loaded and not discarded at the store: Metal's pass, once it draws, writes -/// each tile a draw reaches back through the channels' values, so a minimum code (-128, or -32768) -/// is stored as the code above it, where the device's pass keeps the bytes its draws do not write -/// (`degrade_snorm_minimum`, which reads `DriverFact::TileStoreIsMetals`: a driver whose pass -/// stores them as Metal's). -pub(super) fn snorm_minimum_kept(color: &ColorTarget) -> bool { - kept_through_store(color, |format| SNORM_MINIMUM.contains(&format)) -} - -/// Whether `color` is a single-sampled `RGB9E5Float` attachment, loaded and not discarded at the -/// store: Metal's pass, once it draws, writes each tile a draw reaches back through its texels' -/// values, so a word whose largest mantissa is below 256 under an exponent above 0 (one no Metal -/// write leaves) is stored normalized, its mantissas shifted up as its exponent steps down, where -/// the device's pass keeps the bytes its draws do not write (`degrade_shared_exponent`, which reads -/// `DriverFact::TileStoreIsMetals`). -pub(super) fn shared_exponent_kept(color: &ColorTarget) -> bool { - kept_through_store(color, |format| format == PixelFormat::RGB9E5Float) -} - -/// Whether `color` is a single-sampled attachment of a format `of` takes, loaded and not -/// discarded at the store. -fn kept_through_store(color: &ColorTarget, of: impl Fn(PixelFormat) -> bool) -> bool { - let target = own(color); - let discarded = color.store == StoreAction::DontCare && !color.late_store; - of(target.texture.pixel_format()) - && target.samples == 1 - && color.load == LoadAction::Load - && !color.memoryless - && !discarded -} - -/// The color attachments of a pass's layout that each of a draw's kept-attachment notices names, as -/// `color {index}, {format:?}`: the extended-range or padded ones the load pass does not take -/// ([`untaken`], `degrade_unused_bits`) and, on a driver whose pass does not store as Metal's -/// ([`metals_store`]), the signed normalized ones ([`snorm_minimum_kept`], -/// `degrade_snorm_minimum`) and the `RGB9E5Float` ones ([`shared_exponent_kept`], -/// `degrade_shared_exponent`). They read the layout's colors, their textures' formats, samples, -/// shadows and image plans, and the device's driver facts; all but the -/// layout are fixed at creation, so an encoder decides them once for each layout it records -/// under. -#[derive(Debug, Default, PartialEq)] -pub(super) struct KeptAttachments { - pub(super) unused_bits: Vec, - pub(super) snorm_minimum: Vec, - pub(super) shared_exponent: Vec, -} - -impl KeptAttachments { - /// The kept attachments of `layout`, a pass of `device`'s. - pub(super) fn of(layout: &PassLayout, device: &Device) -> Self { - let metals = metals_store(device); - let mut kept = Self::default(); - for (index, color) in layout.colors.iter().enumerate() { - let Some(color) = color else { - continue; - }; - let name = || format!("color {index}, {:?}", color.target.texture.pixel_format()); - if untaken(color) { - kept.unused_bits.push(name()); - } - if !metals && snorm_minimum_kept(color) { - kept.snorm_minimum.push(name()); - } - if !metals && shared_exponent_kept(color) { - kept.shared_exponent.push(name()); - } - } - kept - } -} - -/// The texels of one attachment's region: its columns, the rows of each layer, its layers, and -/// the bytes of a texel and of each row in the scratch (the texels', then any padding to a -/// word). -#[derive(Clone, Copy)] -struct Region { - columns: u64, - rows: u64, - layers: u64, - texel: u64, - stride: u64, -} - -impl Region { - /// The bytes of each row's texels. - fn row_bytes(&self) -> u64 { - self.columns * self.texel - } -} - -/// One band of a region's rows: its first row (counted across the layers) and its rows. -#[derive(Clone, Copy)] -struct Band { - first_row: u64, - rows: u64, -} - -/// Record, into `core` before the pass of `layout` whose store actions are settled, the load -/// pass of each color attachment it takes over the tiles of `reach` (the module docs), but for a -/// rotated texture's frame ([`record_frames`]), and announce `unreached-tiles-rewritten` where -/// `reach` is not Metal's, naming every attachment either rewrites. The caller calls it only for -/// a pass that recorded a draw call or an execution of render commands, whose draws reach a -/// tile. -pub(super) fn record( - core: &mut EncoderCore, - layout: &PassLayout, - reach: TileReach<'_>, -) -> Result<(), Error> { - let rewritten: Vec = layout - .colors - .iter() - .enumerate() - .filter_map(|(index, color)| { - let taken = takes(color.as_ref()?, false)?; - let format = taken.target.texture.pixel_format(); - Some(format!("color {index}, {format:?}")) - }) - .collect(); - record_taken(core, layout, reach, false)?; - if !rewritten.is_empty() && !reach.exact() { - core.device() - .degrade(Degradation::UnreachedTilesRewritten, || { - ( - format!( - "a render pass that loads {} and draws", - rewritten.join(" and ") - ), - "the pass rewrites every 32x32 tile of its render area, where Metal's \ - rewrites only the tiles a draw's primitives reach (or every tile where a \ - color attachment is cleared): in tiles no draw reaches the unused bits are \ - made canonical and BGRA10_XR alpha codes clamped to [384, 894], a padded \ - word's low six bits zeroed (an _sRGB twin's code through Metal's table) and \ - a bfloat code moved through half, where Metal keeps those texels' bytes" - .to_owned(), - ) - }); - } - Ok(()) -} - -/// Record, into `core` right after the shadows' copies in of the pass of `layout` (and before -/// its stand-ins' copies and clears), the load pass of each rotated texture's frame it takes over -/// the tiles of `reach` (the module docs). [`record`] announces them. The caller calls it only -/// for a pass that recorded a draw call or an execution of render commands, whose draws reach a -/// tile. -pub(super) fn record_frames( - core: &mut EncoderCore, - layout: &PassLayout, - reach: TileReach<'_>, -) -> Result<(), Error> { - record_taken(core, layout, reach, true) -} - -/// Record the load pass of each color attachment of `layout` taken from a rotated texture's -/// frame (`frames`), or of each other one taken. -fn record_taken( - core: &mut EncoderCore, - layout: &PassLayout, - reach: TileReach<'_>, - frames: bool, -) -> Result<(), Error> { - for color in layout.colors.iter().flatten() { - let Some(taken) = takes(color, false) else { - continue; - }; - if matches!(taken.source, Source::Frame) != frames { - continue; - } - let target = taken.target; - let [width, height] = target.extent; - let words = match taken.source { - Source::Bytes(_, words) => words, - Source::Image | Source::Frame => TexelWords::Raw, - }; - let texel = UnusedBitsModule::texel_bytes(taken.format, words) - .ok_or_else(|| internal("an unused bits attachment without its words"))?; - let columns = u64::from(layout.extent[0].next_multiple_of(TILE).min(width)); - let rows = u64::from(layout.extent[1].next_multiple_of(TILE).min(height)); - let texel = u64::from(texel); - let region = Region { - columns, - rows, - layers: u64::from(target.layers), - texel, - stride: (columns * texel).next_multiple_of(4), - }; - if columns == 0 || rows == 0 || region.layers == 0 { - continue; - } - rewrite(core, &taken, words, region, reach)?; - core.device() - .shared() - .counts - .unused_bits_load_recorded(columns * rows * region.layers); - } - Ok(()) -} - -/// Rewrite the words of `taken`'s `region`, held as `words`, in the tiles of `reach`, as Metal's -/// tile store leaves them. -fn rewrite( - core: &mut EncoderCore, - taken: &Taken<'_>, - words: TexelWords, - region: Region, - reach: TileReach<'_>, -) -> Result<(), Error> { - let device = core.device().clone(); - let limits = &device.properties().description.limits; - // A storage buffer's binding offset, and an image copy's buffer offset (a texel's bytes). - let align = limits.min_storage_buffer_offset_alignment.max(8); - let per_dispatch = - u64::from(UnusedBitsModule::LOCAL_SIZE) * u64::from(limits.max_compute_work_group_count[0]); - let most = MAX_SCRATCH - .min(u64::from(limits.max_storage_buffer_range)) - .min(4 * per_dispatch); - let all_rows = region.rows * region.layers; - let band_rows = (most / region.stride).min(all_rows); - if band_rows == 0 { - return Err(internal("an unused bits row past a storage buffer's range")); - } - let bands: Vec = (0..all_rows) - .step_by(band_rows as usize) - .map(|first_row| Band { - first_row, - rows: band_rows.min(all_rows - first_row), - }) - .collect(); - let tiles_per_row = region.columns.div_ceil(u64::from(TILE)); - let tiles = region.layers * region.rows.div_ceil(u64::from(TILE)) * tiles_per_row; - let mask_bytes = 4 * tiles.div_ceil(32); - let tile_rows = region.rows.div_ceil(u64::from(TILE)); - let mask = reach.mask(tiles_per_row, tile_rows, (region.layers, mask_bytes))?; - let narrow = |v: u64| u32::try_from(v).map_err(|_| internal("an unused bits region past u32")); - let shapes: Vec<[u8; 16]> = bands - .iter() - .map(|band| { - Ok(UnusedBitsModule::shape( - narrow(region.stride / 4)?, - narrow(band.first_row)?, - narrow(region.rows)?, - narrow(tiles_per_row)?, - )) - }) - .collect::>()?; - // The scratch: a band's rows, the mask, then each band's shape. - let words_bytes = (band_rows * region.stride).next_multiple_of(align); - let mask_at = words_bytes; - let shapes_at = mask_at + mask_bytes.next_multiple_of(align); - let slot = 16u64.next_multiple_of(align); - let scratch_bytes = shapes_at + slot * bands.len() as u64; - let scratch = device.own_buffer(scratch_bytes, ResourceOptions::private())?; - let (raw_scratch, at) = scratch.at(0); - if !at.is_multiple_of(align) { - return Err(internal("an unused bits scratch off its alignment")); - } - let kernel = device.owned_kernel(OwnedModule::UnusedBits(taken.format, words))?; - let ranges: Vec<_> = bands - .iter() - .enumerate() - .map(|(b, band)| { - vec![ - (raw_scratch, at, band.rows * region.stride), - (raw_scratch, at + mask_at, mask_bytes), - (raw_scratch, at + shapes_at + slot * b as u64, 16), - ] - }) - .collect(); - let sets = OwnedSets::write(&device, &kernel, &ranges)?; - let groups: Vec = bands - .iter() - .map(|band| { - narrow( - (band.rows * region.stride / 4).div_ceil(u64::from(UnusedBitsModule::LOCAL_SIZE)), - ) - }) - .collect::>()?; - let access = Access::new( - vk::PipelineStageFlags2::TRANSFER, - vk::AccessFlags2::TRANSFER_READ | vk::AccessFlags2::TRANSFER_WRITE, - ); - let target = taken.target; - let (copies, uses) = match taken.source { - Source::Bytes(texels, _) => { - let layout = &texels.layout; - let (raw_buffer, base) = texels.buffer.at(layout.offset); - let row_bytes = region.row_bytes(); - let copies: Vec> = bands - .iter() - .map(|band| { - (0..band.rows) - .map(|row| vk::BufferCopy { - src_offset: base + (band.first_row + row) * layout.row_pitch, - dst_offset: at + row * region.stride, - size: row_bytes, - }) - .collect() - }) - .collect(); - let span = - layout.offset..layout.offset + (region.rows - 1) * layout.row_pitch + row_bytes; - let (identity, range) = texels.buffer.tracked(span); - let uses = vec![Use::writes( - identity.key, - identity.tracked, - UseRange::Bytes(range), - access, - )]; - core.retain(texels.buffer.clone()); - (Copies::Bytes(raw_buffer, copies), uses) - } - Source::Image | Source::Frame => { - let texture = &target.texture; - let image = texture.raw_image()?; - let deep = texture.image_plan()?.image_type == ImageType::TYPE_3D; - let regions: Vec> = bands - .iter() - .map(|band| image_regions(target, region, *band, at, deep)) - .collect(); - let level = target.level..target.level + 1; - let layers = target.layer..target.layer + target.layers; - let uses = vec![texture.image_use(level, layers, access, true)?]; - core.retain(texture.clone()); - (Copies::Image(image, regions), uses) - } - }; - let descriptor_sets = sets.sets.clone(); - let stages = vk::PipelineStageFlags2::TRANSFER | vk::PipelineStageFlags2::COMPUTE_SHADER; - core.command(stages, &uses, |raw, command_buffer| { - // SAFETY: the command buffer is recording outside a render pass (the pass records after - // it), and only the encoder records it; the texels' buffer or image, the scratch and the - // sets are retained until it completes; every copy lies inside the texels (the target's - // rows, its level and layers) and the scratch (a band's rows), and every binding inside - // the scratch; each step reads what the one before it wrote past a barrier, and the - // scratch's rows are written again only past a barrier after the band before is done - // with them. The image rests in `GENERAL`. - unsafe { - Barrier::everything().record(raw, command_buffer); - record_mask( - raw, - command_buffer, - (raw_scratch, at + mask_at, mask_bytes), - &mask, - ); - for (b, shape) in shapes.iter().enumerate() { - let offset = at + shapes_at + slot * b as u64; - raw.cmd_update_buffer(command_buffer, raw_scratch, offset, shape); - } - raw.cmd_bind_pipeline( - command_buffer, - vk::PipelineBindPoint::COMPUTE, - kernel.pipeline, - ); - for (b, (set, groups)) in descriptor_sets.iter().zip(&groups).enumerate() { - Barrier::everything().record(raw, command_buffer); - copies.to_scratch(raw, command_buffer, raw_scratch, b); - Barrier::everything().record(raw, command_buffer); - raw.cmd_bind_descriptor_sets( - command_buffer, - vk::PipelineBindPoint::COMPUTE, - kernel.layout, - 0, - std::slice::from_ref(set), - &[], - ); - raw.cmd_dispatch(command_buffer, *groups, 1, 1); - Barrier::everything().record(raw, command_buffer); - copies.back(raw, command_buffer, raw_scratch, b); - } - Barrier::everything().record(raw, command_buffer); - } - }); - core.retain(scratch); - core.retain(sets); - Ok(()) -} - -/// Each band's copies between the texels and the scratch, into it (and back, swapped). -enum Copies { - /// Each row of a buffer's bytes. - Bytes(vk::Buffer, Vec>), - /// Each layer's rows of an image's level. - Image(vk::Image, Vec>), -} - -impl Copies { - /// Record band `b`'s copy into `scratch`. - /// - /// # Safety - /// - /// `command_buffer` is recording, outside a render pass; the copies lie in their resources, - /// which are live until it completes, and an image rests in `GENERAL`. - unsafe fn to_scratch( - &self, - raw: &Vk, - command_buffer: vk::CommandBuffer, - scratch: vk::Buffer, - b: usize, - ) { - // SAFETY: the caller's contract. - unsafe { - match self { - Copies::Bytes(buffer, copies) => { - raw.cmd_copy_buffer(command_buffer, *buffer, scratch, &copies[b]) - } - Copies::Image(image, regions) => raw.cmd_copy_image_to_buffer( - command_buffer, - *image, - vk::ImageLayout::GENERAL, - scratch, - ®ions[b], - ), - } - } - } - - /// Record band `b`'s copy back from `scratch`. - /// - /// # Safety - /// - /// As [`to_scratch`](Self::to_scratch). - unsafe fn back( - &self, - raw: &Vk, - command_buffer: vk::CommandBuffer, - scratch: vk::Buffer, - b: usize, - ) { - // SAFETY: the caller's contract. - unsafe { - match self { - Copies::Bytes(buffer, copies) => { - let back: Vec = copies[b] - .iter() - .map(|c| vk::BufferCopy { - src_offset: c.dst_offset, - dst_offset: c.src_offset, - size: c.size, - }) - .collect(); - raw.cmd_copy_buffer(command_buffer, scratch, *buffer, &back) - } - Copies::Image(image, regions) => raw.cmd_copy_buffer_to_image( - command_buffer, - scratch, - *image, - vk::ImageLayout::GENERAL, - ®ions[b], - ), - } - } - } -} - -/// The copies between `target`'s level and the scratch at `at` of `band`'s rows of `region`: -/// one per layer the band meets, a 3D image's depth planes (`deep`) by its z offset, another's -/// array layers by its layer. -fn image_regions( - target: &Target, - region: Region, - band: Band, - at: u64, - deep: bool, -) -> Vec { - let mut regions = Vec::new(); - let mut row = band.first_row; - let end = band.first_row + band.rows; - while row < end { - let layer = row / region.rows; - let y = row % region.rows; - let rows = (region.rows - y).min(end - row); - let layer = target.layer + layer as u32; - let (base_array_layer, z) = match deep { - true => (0, layer as i32), - false => (layer, 0), - }; - regions.push(vk::BufferImageCopy { - buffer_offset: at + (row - band.first_row) * region.stride, - buffer_row_length: 0, - buffer_image_height: 0, - image_subresource: vk::ImageSubresourceLayers { - aspect_mask: vk::ImageAspectFlags::COLOR, - mip_level: target.level, - base_array_layer, - layer_count: 1, - }, - image_offset: vk::Offset3D { - x: 0, - y: y as i32, - z, - }, - image_extent: vk::Extent3D { - width: region.columns as u32, - height: rows as u32, - depth: 1, - }, - }); - row += rows; - } - regions -} diff --git a/crates/metal2vulkan-runtime/src/render_state.rs b/crates/metal2vulkan-runtime/src/render_state.rs index cffca427c..a5efa4e40 100644 --- a/crates/metal2vulkan-runtime/src/render_state.rs +++ b/crates/metal2vulkan-runtime/src/render_state.rs @@ -106,7 +106,7 @@ use super::render_values::{ScissorRect, Viewport}; use super::Device; use ash::vk; use metal2vulkan::bind::{CompensatedViewport, RegionLimits}; -use metal2vulkan::device::{DeviceProfile, EnableSet, VkExtension, VkFeature}; +use metal2vulkan::device::{DeviceProfile, VkExtension, VkFeature}; use metal2vulkan::error::{Capability, Feature, RuntimeDriverDefect, Unsupported}; use metal2vulkan::metal::{ CullMode, DepthClipMode, PixelFormat, StencilOperation, TriangleFillMode, Winding, @@ -786,7 +786,7 @@ impl EncoderState { topology: metal2vulkan::vk::PrimitiveTopology, profile: &DeviceProfile, ) -> Result, Error> { - let biased = metal2vulkan::metal::state::depth_bias(topology, 0.0, 0.0, 0.0, None, profile) + let biased = metal2vulkan::metal::state::depth_bias(topology, 0.0, 0.0, 0.0, profile) .map_err(device_error)? .enable; Ok(biased.then_some(self.depth_bias)) @@ -797,32 +797,6 @@ impl EncoderState { &self.scissors[0] } - /// The cull mode. - pub(super) fn cull_mode(&self) -> CullMode { - self.cull_mode - } - - /// The state the tile reach rule bins a draw's primitives under - /// (`bind::TileReachModule::state`), for a draw of a pipeline that selects no viewport: the - /// first viewport as the rasterizer takes it (in `f32`), the first scissor rectangle, the - /// cull mode, the winding and the depth clip mode. `None` under a fill mode other than - /// `Fill`, whose triangles draw as lines, and for a rectangle past `u32`. - pub(super) fn reach_state(&self) -> Option<[u8; 48]> { - if self.fill_mode != TriangleFillMode::Fill { - return None; - } - let v = self.viewports.first()?; - let s = self.scissors.first()?; - let side = |x: u64| u32::try_from(x).ok(); - Some(metal2vulkan::bind::TileReachModule::state( - [v.origin_x, v.origin_y, v.width, v.height].map(|f| f as f32), - [side(s.x)?, side(s.y)?, side(s.width)?, side(s.height)?], - self.cull_mode.as_raw(), - self.winding.as_raw(), - self.clip_mode.as_raw(), - )) - } - /// The powers of two `[sx, sy]` a draw of points widens the Vulkan viewports it uses by, /// about their centers ([`EncoderState::vk_viewports`]), its vertex stage scaling the /// position by their inverses and culling at Metal's guard band ([`guard_points`]): on each @@ -1082,15 +1056,12 @@ impl EncoderState { Ok([first.znear as f32, first.zfar as f32]) } - /// The draw's depth bias for `topology` in a pass whose depth attachment's texture is of - /// `depth_format` (`metal::state::depth_bias`): a clamp needs `depthBiasClamp`, and a - /// `Depth16Unorm` depth's constant counts Metal's unit where the device pins Vulkan's. A - /// saturated bias or an offset biases nothing here: the draw's viewports take it - /// ([`EncoderState::draw_viewports`]). + /// The draw's depth bias for `topology` (`metal::state::depth_bias`): a clamp needs + /// `depthBiasClamp`, and the constant counts the device's unit. A saturated bias or an offset + /// biases nothing here: the draw's viewports take it ([`EncoderState::draw_viewports`]). pub(super) fn vk_depth_bias( &self, topology: metal2vulkan::vk::PrimitiveTopology, - depth_format: Option, profile: &DeviceProfile, ) -> Result { let [bias, slope, clamp] = match self.depth_bias { @@ -1101,7 +1072,7 @@ impl EncoderState { } => [constant, slope, clamp], DepthBiasEffect::Saturated { .. } | DepthBiasEffect::Offset(_) => [0.0; 3], }; - metal2vulkan::metal::state::depth_bias(topology, bias, slope, clamp, depth_format, profile) + metal2vulkan::metal::state::depth_bias(topology, bias, slope, clamp, profile) .map_err(device_error) } @@ -1874,7 +1845,7 @@ pub(super) fn written_depth_clamp( ); } let profile = device.compile_device().profile(); - let biased = metal2vulkan::metal::state::depth_bias(topology, 0.0, 0.0, 0.0, None, profile) + let biased = metal2vulkan::metal::state::depth_bias(topology, 0.0, 0.0, 0.0, profile) .map_err(device_error)? .enable; if biased && !matches!(state.depth_bias, DepthBiasEffect::Factors { .. }) { @@ -1950,20 +1921,19 @@ fn clamp_range(viewport: &Viewport) -> [f32; 2] { } /// Announce once what a draw of `depth_stencil` stores in a `Depth16Unorm` depth -/// (`depth_format`) under the Vulkan bias `bias`: the device converts the depth, so a constant -/// bias, or a slope alone, which brings Metal's constant unit, stores Metal's codes only where the -/// profile takes `DriverDeviation::MetalDepth16BiasedStores` (`unorm-depth-bias`), and any depth it -/// tests or writes only where the profile takes `DriverDeviation::MetalDepth16Stores` -/// (`unorm-depth-rounding`). Metal biases by `c ± 1` units of 1/65535 as `float` -/// (`metal::state::depth_bias`), adds the bias to the depth rounded toward zero, and stores the sum -/// rounded to nearest, a tie up (probes). +/// (`depth_format`) under the Vulkan bias `bias`: the device biases and converts the depth, so a +/// constant bias, or a slope alone, which brings Metal's constant unit, stores Metal's codes only +/// where the profile takes `DriverDeviation::MetalDepth16BiasedStores` (`unorm-depth-bias`), and +/// any depth it tests or writes only where the profile takes `DriverDeviation::MetalDepth16Stores` +/// (`unorm-depth-rounding`). Metal biases by `c ± 1` units of 1/65535 as `float`, adds the bias to +/// the depth rounded toward zero, and stores the sum rounded to nearest, a tie up (probes); the +/// device biases by `c` of its own unit (`metal::state::depth_bias`). pub(super) fn announce_unorm_depth( device: &Device, depth_format: Option, depth_stencil: &metal2vulkan::metal::state::DepthStencilState, bias: &metal2vulkan::metal::state::DepthBias, ) { - use metal2vulkan::metal::state::DepthBiasUnit; if depth_format != Some(PixelFormat::Depth16Unorm) { return; } @@ -1991,107 +1961,43 @@ pub(super) fn announce_unorm_depth( let object = "a draw biasing a Depth16Unorm depth by a constant, or by a slope that \ brings Metal's constant unit" .to_owned(); - let reason = match bias.unit { - DepthBiasUnit::Device => "the device lacks VK_EXT_depth_bias_control's \ - depthBiasExact, so the bias counts its own unit, up to \ - twice 2^-16, where Metal's is c + 1 units of 1/65535 for c \ - of 0 or more (a slope alone brings one) and c - 1 below" - .to_owned(), - _ => "the device adds Metal's bias to the depth and converts the sum in its own \ - rounding, where Metal adds it rounding toward zero: a biased depth near a \ - code's midpoint can store the code next to Metal's" - .to_owned(), - }; + let reason = "the device biases by the constant c in its own unit, up to twice 2^-16 \ + (none for a slope alone), and converts the sum in its own rounding, where \ + Metal biases by c + 1 units of 1/65535 for c of 0 or more (a slope alone \ + brings one) and c - 1 below, adding them rounding toward zero: a biased \ + depth can store another code than Metal's" + .to_owned(); (object, reason) }); } -/// `vkCmdSetDepthBias2EXT` (`VK_EXT_depth_bias_control`): records a depth bias whose constant -/// factor counts the unit a chained `VkDepthBiasRepresentationInfoEXT` names. -pub(super) type DepthBiasCommand = vk::PFN_vkCmdSetDepthBias2EXT; - -/// The device's [`DepthBiasCommand`], where it enabled `VK_EXT_depth_bias_control`. -/// -/// # Safety -/// -/// `device` was made from `instance` with `enabled` enabled, and the loader serves -/// `vkGetDeviceProcAddr` for it (its loader word is in place). -pub(super) unsafe fn depth_bias_command( - instance: &ash::Instance, - device: &ash::Device, - enabled: &EnableSet, -) -> Option { - if !enabled - .extensions - .contains(&VkExtension::ExtDepthBiasControl) - { - return None; - } - // SAFETY: the caller's; a command the device does not have is null. - let command = unsafe { - instance.get_device_proc_addr(device.handle(), c"vkCmdSetDepthBias2EXT".as_ptr()) - }?; - // SAFETY: the device gave the command of this name. - Some(unsafe { std::mem::transmute::(command) }) -} - -/// What a depth bias command sets, as the command carries it: the factors' bits and a pinned -/// unit's representation. Two records set the same state where theirs are equal. It keeps no -/// command, so what keeps it keeps none of the device's functions. +/// What a depth bias command sets: the factors' bits. Two records set the same state where +/// theirs are equal. #[derive(Clone, Copy, PartialEq, Eq)] pub(super) struct DepthBiasSetting { factors: [u32; 3], - representation: Option, } -/// How a draw records its depth bias ([`metal2vulkan::metal::state::DepthBias`]). +/// How a draw records its depth bias ([`metal2vulkan::metal::state::DepthBias`]): +/// `vkCmdSetDepthBias` of its factors. #[derive(Clone, Copy, PartialEq)] pub(super) struct DepthBiasRecord { /// Constant factor, clamp, slope factor. factors: [f32; 3], - /// The command and the representation of a pinned unit (`DepthBiasUnit::Depth` or - /// `ExactFormatUnit`); `None`: `vkCmdSetDepthBias`, the device's unit. - pinned: Option<(DepthBiasCommand, vk::DepthBiasRepresentationEXT)>, } impl DepthBiasRecord { - /// How `bias` records on a device whose depth bias command is `command`: a pinned unit on a - /// device without the command is an internal error, since `metal::state::depth_bias` pins - /// one only where the device enabled the extension's `depthBiasExact`. - pub(super) fn of( - bias: &metal2vulkan::metal::state::DepthBias, - command: Option, - ) -> Result { - use metal2vulkan::metal::state::DepthBiasUnit; - let representation = match bias.unit { - DepthBiasUnit::Device => None, - DepthBiasUnit::Depth => Some(vk::DepthBiasRepresentationEXT::FLOAT), - DepthBiasUnit::ExactFormatUnit => { - Some(vk::DepthBiasRepresentationEXT::LEAST_REPRESENTABLE_VALUE_FORMAT) - } - unit => return Err(internal(&format!("a depth bias unit of {unit:?}"))), - }; - let pinned = match (representation, command) { - (None, _) => None, - (Some(representation), Some(command)) => Some((command, representation)), - (Some(_), None) => { - return Err(internal( - "a pinned depth bias unit on a device without vkCmdSetDepthBias2EXT", - )) - } - }; - Ok(DepthBiasRecord { + /// How `bias` records. + pub(super) fn of(bias: &metal2vulkan::metal::state::DepthBias) -> DepthBiasRecord { + DepthBiasRecord { factors: [bias.constant_factor, bias.clamp, bias.slope_factor], - pinned, - }) + } } - /// What recording it sets: its factors, bit for bit, in its representation, without the - /// command (the device's, the same for every record of the device). + /// What recording it sets: its factors, bit for bit. pub(super) fn setting(&self) -> DepthBiasSetting { DepthBiasSetting { factors: self.factors.map(f32::to_bits), - representation: self.pinned.map(|(_, representation)| representation), } } @@ -2103,26 +2009,8 @@ impl DepthBiasRecord { /// dynamic state. pub(super) unsafe fn record(&self, raw: &ash::Device, command_buffer: vk::CommandBuffer) { let [constant, clamp, slope] = self.factors; - match self.pinned { - None => { - // SAFETY: the caller's. - unsafe { raw.cmd_set_depth_bias(command_buffer, constant, clamp, slope) } - } - Some((command, representation)) => { - let mut exact = vk::DepthBiasRepresentationInfoEXT::default() - .depth_bias_representation(representation) - .depth_bias_exact(true); - let info = vk::DepthBiasInfoEXT::default() - .depth_bias_constant_factor(constant) - .depth_bias_clamp(clamp) - .depth_bias_slope_factor(slope) - .push_next(&mut exact); - // SAFETY: the caller's; the device enabled the extension the command is of, - // and `depthBiasExact` and, for the float representation, `floatRepresentation`, - // which `metal::state::depth_bias` pinned the unit for. - unsafe { command(command_buffer, &info) } - } - } + // SAFETY: the caller's. + unsafe { raw.cmd_set_depth_bias(command_buffer, constant, clamp, slope) } } } @@ -3303,9 +3191,7 @@ mod tests { gap, "an offset in clamp mode" ); - let bias = state - .vk_depth_bias(T::TRIANGLE_LIST, Some(PixelFormat::Depth16Unorm), profile) - .unwrap(); + let bias = state.vk_depth_bias(T::TRIANGLE_LIST, profile).unwrap(); assert_eq!( [bias.constant_factor, bias.slope_factor, bias.clamp], [0.0; 3], diff --git a/crates/metal2vulkan-runtime/src/render_target.rs b/crates/metal2vulkan-runtime/src/render_target.rs index c37092ebe..9d0706db9 100644 --- a/crates/metal2vulkan-runtime/src/render_target.rs +++ b/crates/metal2vulkan-runtime/src/render_target.rs @@ -2047,16 +2047,6 @@ pub(super) fn framebuffer_over( Ok(made) } -/// The framebuffer of `pass`, a pass without attachments (`attachmentless.rs`), over `extent` -/// and one layer: capture replay's (`render/capture.rs`). -pub(super) fn attachmentless_framebuffer( - device: &Device, - pass: &RenderPassObject, - extent: [u32; 2], -) -> Result { - made_framebuffer(device, pass, &[], extent, 1) -} - /// The framebuffer of `pass` with `attachments`, over `extent` and `layers`: each view of one /// level and of those layers, or of the views of a multiview pass's one layer, at least `extent` /// large. diff --git a/crates/metal2vulkan-runtime/src/tests/descriptor_key_at_draw.rs b/crates/metal2vulkan-runtime/src/tests/descriptor_key_at_draw.rs index 03750c455..8c99f898a 100644 --- a/crates/metal2vulkan-runtime/src/tests/descriptor_key_at_draw.rs +++ b/crates/metal2vulkan-runtime/src/tests/descriptor_key_at_draw.rs @@ -1,12 +1,11 @@ -//! A state's draws build **no** descriptor key, and its capture forms build one between them -//! (`descriptor_keys_built`): the key of the descriptor a compile is keyed by belongs to that -//! descriptor, and the state holds one per descriptor it compiles as. +//! A state's draws build **no** descriptor key (`descriptor_keys_built`): the key of the +//! descriptor a compile is keyed by belongs to that descriptor, and the state holds one per +//! descriptor it compiles as. //! //! The creation's half of this is `descriptor_key_once.rs`, which this continues: a creation //! builds the key of its descriptor once and the state keeps it. What was left there is the -//! draw's half -- a variant a draw of another bind shape needs, and a capture form a replay -//! needs, each compiled under a key built at the draw: the same digest of the same fixed -//! descriptor, built again for every variant and every form. +//! draw's half -- a variant a draw of another bind shape needs, compiled under a key built at the +//! draw: the same digest of the same fixed descriptor, built again for every variant. //! //! # Which descriptor keys which compile //! @@ -17,9 +16,7 @@ //! * the descriptor it draws as (`GraphicsState::descriptor_key`), which for a twin of a color //! group holds its group's color attachments alone and clears //! `supportIndirectCommandBuffers` -- fields the key reads, so the twin's two descriptors are -//! two keys; -//! * the descriptor its capture forms compile from: the vertex stage alone, without the fragment -//! function or any attachment format. +//! two keys. //! //! Each key stays with its own descriptor. Keying a compile by a descriptor it does not compile //! would look its pipeline up among another descriptor's entries in the shader cache, which @@ -43,9 +40,8 @@ use super::descriptor_key_once::{built, descriptor}; use crate::pipeline::{BufferForms, GraphicsState, RenderStateKind}; use crate::{PipelineOptions, RenderPipelineState}; use metal2vulkan::bind::BindShape; -use metal2vulkan::cache::VariantKey; -use metal2vulkan::metal::{IndexType, PixelFormat}; -use metal2vulkan::pipeline::{CaptureForm, ColorAttachmentDescriptor, RenderPipelineDescriptor}; +use metal2vulkan::metal::PixelFormat; +use metal2vulkan::pipeline::ColorAttachmentDescriptor; use std::collections::BTreeSet; use std::sync::Arc; @@ -57,21 +53,6 @@ fn graphics(state: &RenderPipelineState) -> &GraphicsState { } } -/// `descriptor` as a state's capture forms compile it, as `pipeline::render`'s own -/// `capture_descriptor` makes it: the vertex stage alone, rasterizing into a pass without -/// attachments. Written here from the descriptor, so the key the state holds is held to the key -/// of a descriptor this test built, not to one the product handed it. -fn captured(descriptor: &RenderPipelineDescriptor) -> RenderPipelineDescriptor { - let mut descriptor = descriptor.clone(); - descriptor.fragment = None; - descriptor.color_attachments = Default::default(); - descriptor.depth_format = None; - descriptor.stencil_format = None; - descriptor.alpha_to_coverage = false; - descriptor.alpha_to_one = false; - descriptor -} - /// The variant a draw of another bind shape needs is compiled under the key the state's creation /// built: the draw builds none, and a later draw of the shape finds the variant and builds none /// either. A pass without the pipeline's color attachment, whose writes Metal drops @@ -154,55 +135,6 @@ fn a_states_compile_key_is_its_descriptors() { ); } -/// Every capture form of every variant of one state compiles from one descriptor, so the forms -/// build one key between them: the first builds it, each later one takes it. The key is the key -/// of that descriptor, which is not the state's own. -#[test] -fn capture_forms_of_one_state_build_one_descriptor_key() { - let scratch = Scratch::new("descriptor-key-capture"); - let device = device(&scratch.0); - let descriptor = descriptor(&device); - let state = device - .new_render_pipeline_state(&descriptor, &PipelineOptions::default()) - .unwrap(); - let state = graphics(&state); - let shape = BindShape::default(); - let settled = VariantKey::default(); - let before = built(&device); - // Three forms of the one variant: a replay of a draw of primitives, and of an indexed draw - // of each index type (`render/capture.rs`). Each asks for a compile of its own; a form is - // `None` while its translation runs, which is what every first ask answers. - for form in [ - CaptureForm::Vertices, - CaptureForm::Indexed(IndexType::UInt16), - CaptureForm::Indexed(IndexType::UInt32), - ] { - let _ = state.capture_variant(&settled, form, &shape); - } - assert_eq!( - built(&device)[0] - before[0], - 1, - "descriptor keys three capture forms of one state built" - ); - let capture = captured(&descriptor); - let held = *state.capture_key(&capture); - assert_eq!( - built(&device)[0] - before[0], - 1, - "descriptor keys a read of the held capture key built" - ); - assert_eq!( - held, - device.compile_device().render_descriptor_key(&capture), - "the key the forms were compiled under is the key of the descriptor they compile from" - ); - assert_ne!( - held, - *state.descriptor_key(), - "a capture form's descriptor is not the state's: its key may not be the state's" - ); -} - /// The two descriptors a twin of a color group holds are keyed apart: the descriptor it was made /// from, which its variants compile from, and the group's color attachments alone, which it draws /// as and answers questions of. A compile keyed by the second would be looked up among the diff --git a/crates/metal2vulkan-runtime/src/tests/exit_guard.rs b/crates/metal2vulkan-runtime/src/tests/exit_guard.rs index d18676213..5af2d543a 100644 --- a/crates/metal2vulkan-runtime/src/tests/exit_guard.rs +++ b/crates/metal2vulkan-runtime/src/tests/exit_guard.rs @@ -1649,7 +1649,7 @@ fn the_device_s_functions_are_reached_through_checked_accessors() { /// tuple field, a type argument or a by-value parameter) fails /// `only_the_listed_modules_keep_the_device_s_functions`; so does a listed module that keeps none /// any more. -const KEEPERS: [(&str, &str); 24] = [ +const KEEPERS: [(&str, &str); 23] = [ ( "binding.rs", "the push command (vkCmdPushDescriptorSet), a call's parameter (`push_set`) and the \ @@ -1738,10 +1738,6 @@ const KEEPERS: [(&str, &str); 24] = [ "render/pending.rs", "a pending draw's recording, held by its command buffer", ), - ( - "render_state.rs", - "a draw's recording (vkCmd*), held by what holds its command buffer", - ), ( "scheduler/mod.rs", "the scheduler's nudge, signalled and waited for only while its thread waits on the \ @@ -2084,10 +2080,10 @@ fn the_table_names_each_entry_point_once() { #[test] fn the_priming_check_names_what_was_not_made() { use crate::device::prime::{ - missing, Has, CALIBRATION_CALLS, COLOR_WRITE_MASK_CALLS, DEPTH_BIAS_CALLS, - DEVICE_ADDRESS_CALLS, EXTENDED_DYNAMIC_STATE_CALLS, GENERATED_COMMANDS_CALLS, - HOST_QUERY_RESET_CALLS, NAMING_CALLS, PRIMITIVE_RESTART_CALLS, PUSH_DESCRIPTOR_CALLS, - SIZED_INDEX_BIND_CALLS, SPARSE_CALLS, TIMESTAMP_CALLS, UNPRIMED, YCBCR_CONVERSION_CALLS, + missing, Has, CALIBRATION_CALLS, COLOR_WRITE_MASK_CALLS, DEVICE_ADDRESS_CALLS, + EXTENDED_DYNAMIC_STATE_CALLS, GENERATED_COMMANDS_CALLS, HOST_QUERY_RESET_CALLS, + NAMING_CALLS, PRIMITIVE_RESTART_CALLS, PUSH_DESCRIPTOR_CALLS, SIZED_INDEX_BIND_CALLS, + SPARSE_CALLS, TIMESTAMP_CALLS, UNPRIMED, YCBCR_CONVERSION_CALLS, }; let has = |timestamps, device_addresses| Has { timestamps, @@ -2101,7 +2097,6 @@ fn the_priming_check_names_what_was_not_made() { extended_dynamic_state: true, primitive_restart: true, color_write_masks: true, - depth_bias: true, sized_index_bind: true, ycbcr_conversion: true, }; @@ -2200,7 +2195,7 @@ fn the_priming_check_names_what_was_not_made() { assert!(missing(unnamed, without).is_empty()); assert_eq!(missing(unnamed, has(true, true)), NAMING_CALLS); // Without a render encoder's command of an extension or of Vulkan 1.3, nor is that command. - let groups: [(&[Call], fn(Has) -> Has); 6] = [ + let groups: [(&[Call], fn(Has) -> Has); 5] = [ (&EXTENDED_DYNAMIC_STATE_CALLS, |has| Has { extended_dynamic_state: false, ..has @@ -2213,10 +2208,6 @@ fn the_priming_check_names_what_was_not_made() { color_write_masks: false, ..has }), - (&DEPTH_BIAS_CALLS, |has| Has { - depth_bias: false, - ..has - }), (&SIZED_INDEX_BIND_CALLS, |has| Has { sized_index_bind: false, ..has diff --git a/crates/metal2vulkan-runtime/src/tests/upload_chunk_zeros.rs b/crates/metal2vulkan-runtime/src/tests/upload_chunk_zeros.rs index 70fa708b3..b5d8785cb 100644 --- a/crates/metal2vulkan-runtime/src/tests/upload_chunk_zeros.rs +++ b/crates/metal2vulkan-runtime/src/tests/upload_chunk_zeros.rs @@ -92,7 +92,8 @@ fn a_regions_tail_reads_zero_over_a_dirty_chunk() { FIRST_CHUNK_BYTES, "the region is the whole chunk" ); - assert_eq!(region.read_bytes(), poison, "the poison was written"); + let whole = region.read::<{ FIRST_CHUNK_BYTES as usize }>(); + assert_eq!(whole.as_slice(), poison, "the poison was written"); } until("the chunk was parked", || parked() > before_parked); // The chunk comes back for the next arena of the same making, holding the poison. @@ -103,7 +104,7 @@ fn a_regions_tail_reads_zero_over_a_dirty_chunk() { .upload(&device, &data, 64) .expect("a short region of a recycled chunk"); let cleared = device.work_counts().new_buffer_bytes_cleared - before; - let bytes = region.read_bytes(); + let bytes = region.read::<64>(); assert_eq!(&bytes[..8], &data, "the region holds its data"); assert_eq!( &bytes[8..], diff --git a/crates/metal2vulkan-runtime/src/upload.rs b/crates/metal2vulkan-runtime/src/upload.rs index 77c007490..7133964e9 100644 --- a/crates/metal2vulkan-runtime/src/upload.rs +++ b/crates/metal2vulkan-runtime/src/upload.rs @@ -358,22 +358,4 @@ impl Upload { } bytes } - - /// The region's bytes as the device left them, under [`read`](Self::read)'s contract. - pub(super) fn read_bytes(&self) -> Vec { - let Some(mapped) = self.buffer.contents() else { - unreachable!("upload chunks are Shared buffers") - }; - let mut bytes = vec![0; self.len as usize]; - // SAFETY: the region lies inside the mapping, and no command writes it any more (the - // caller's contract); the memory is host-coherent. - unsafe { - std::ptr::copy_nonoverlapping( - mapped.as_ptr().add(self.offset as usize), - bytes.as_mut_ptr(), - bytes.len(), - ); - } - bytes - } } diff --git a/crates/metal2vulkan-runtime/src/work_counts.rs b/crates/metal2vulkan-runtime/src/work_counts.rs index 8ddc1b9b2..a772bf654 100644 --- a/crates/metal2vulkan-runtime/src/work_counts.rs +++ b/crates/metal2vulkan-runtime/src/work_counts.rs @@ -103,14 +103,6 @@ pub(crate) struct Counters { color_resolve_passes_made: AtomicU64, color_resolve_passes_kept: AtomicU64, ahead_nanos: AtomicU64, - unused_bits_load_passes: AtomicU64, - unused_bits_load_texels: AtomicU64, - capture_reach_passes: AtomicU64, - capture_reach_primitives: AtomicU64, - capture_reach_tiles_found: AtomicU64, - capture_reach_tiles_bound: AtomicU64, - capture_reach_bound_passes: AtomicU64, - capture_reach_narrower_passes: AtomicU64, driver_diagnostics_withheld: AtomicU64, stand_ins_made: AtomicU64, stand_in_bytes: AtomicU64, @@ -1128,36 +1120,6 @@ impl Counters { .fetch_add(1, Ordering::Relaxed); } - /// An encoder recorded the load pass of an extended-range or padded color attachment over a - /// region of `texels` texels (`render/unused_bits_load.rs`). - pub(crate) fn unused_bits_load_recorded(&self, texels: u64) { - self.unused_bits_load_passes.fetch_add(1, Ordering::Relaxed); - self.unused_bits_load_texels - .fetch_add(texels, Ordering::Relaxed); - } - - /// An encoder recorded a pass's capture replay over `primitives` primitives - /// (`render/capture.rs`). - pub(crate) fn capture_reach_recorded(&self, primitives: u64) { - self.capture_reach_passes.fetch_add(1, Ordering::Relaxed); - self.capture_reach_primitives - .fetch_add(primitives, Ordering::Relaxed); - } - - /// A captured pass's command buffer completed: its primitives reach `found` tiles, of the - /// `bound` its draws' viewports and scissors reach. - pub(crate) fn capture_reach_tallied(&self, found: u64, bound: u64) { - self.capture_reach_tiles_found - .fetch_add(found, Ordering::Relaxed); - self.capture_reach_tiles_bound - .fetch_add(bound, Ordering::Relaxed); - match found >= bound { - true => &self.capture_reach_bound_passes, - false => &self.capture_reach_narrower_passes, - } - .fetch_add(1, Ordering::Relaxed); - } - /// A driver call reported `withheld` diagnostics its driver facts measure it to report, which /// the device's sink was not handed (`driver_facts.rs`). pub(crate) fn driver_diagnostics_withheld(&self, withheld: u64) { @@ -2830,8 +2792,8 @@ pub struct WorkCounts { /// runtime thread held to make what the command buffer's work waited for had not gone yet. pub trail_waits_blocked: u64, /// Command buffers whose transition to `Completed` or `Error` ran on the queue waiter that - /// saw their work complete, with no handler thread woken: those with no completed handler, no - /// pass that captured its tiles' reach, and no earlier transition of their queue that runs + /// saw their work complete, with no handler thread woken: those with no completed handler and + /// no earlier transition of their queue that runs /// the program's code or runs on a handler thread then, while the runtime held none of the /// program's objects a release drops or runs (`command_buffer/completion.rs`). pub completed_where_seen: u64, @@ -3111,34 +3073,6 @@ pub struct WorkCounts { /// Nanoseconds commits spent making ahead for their render passes' host steps, kept /// backings included. pub ahead_nanos: u64, - /// Load passes render encoders recorded: one per extended-range, padded 10-bit or bfloat - /// color attachment that a pass which draws loads and stores, whose words a dispatch rewrote in - /// the tiles the pass's draws reach before the pass, as Metal's tile store leaves them - /// (`render/unused_bits_load.rs`). - pub unused_bits_load_passes: u64, - /// The texels of those passes' regions (the render area rounded up to 32 texels a side, - /// within the texture, of every layer the pass renders). - pub unused_bits_load_texels: u64, - /// Passes whose draws' tile reach capture replay found before the pass, from the positions - /// their own vertex functions compute (`render/capture.rs`): the load pass rewrites the tiles - /// those reach, as Metal's pass does. - pub capture_reach_passes: u64, - /// The primitives those passes' capture draws assembled and binned. - pub capture_reach_primitives: u64, - /// The tiles those passes' primitives reach, as their masks held them once their command - /// buffers completed (every tile of the pass where its capture fell back, a primitive's - /// reach not measured): those the load passes rewrote. - pub capture_reach_tiles_found: u64, - /// The tiles their draws' viewports and scissors reach (`clear_reach::DrawnArea`): those the - /// load passes would rewrite without the capture. - pub capture_reach_tiles_bound: u64, - /// Those passes whose primitives reach every tile their viewports and scissors reach (a - /// full-screen draw's, say): the capture changed nothing the load pass rewrote, but for the - /// announcement. - pub capture_reach_bound_passes: u64, - /// Those passes whose primitives reach fewer: the tiles between were kept, as Metal keeps - /// them, where the load pass would have rewritten them. - pub capture_reach_narrower_passes: u64, /// Driver diagnostics withheld from the device's message sink: messages a driver diagnostic /// fact (`DriverFact::pipeline_creation_diagnostics`) measures the driver to report inside a /// call the runtime made, reported there (`driver_facts.rs`). MoltenVK 1.4.1's warning of a @@ -3648,8 +3582,8 @@ pub struct WorkCounts { /// **Inside an encoder**, orders a blit's untracked uses by key and range). pub command_barriers: u64, /// Render pass instances a pass replaced or gave up before running them (a draw that needed - /// another shape before any draw recorded, a reroute's instance left behind, a capture that - /// recorded nothing, a first instance whose draws record inline instead), whose draws + /// another shape before any draw recorded, a reroute's instance left behind, a first instance + /// whose draws record inline instead), whose draws /// recording the runtime gave up: never replayed where deferred (`recorder`), else ended, so /// their command pool goes back to the device's spares unreset /// (`WorkCounts::spare_command_pools_reset` counts the others). A pass's first instance that @@ -4850,16 +4784,6 @@ impl Device { color_resolve_passes_made: counters.color_resolve_passes_made.load(Ordering::Relaxed), color_resolve_passes_kept: counters.color_resolve_passes_kept.load(Ordering::Relaxed), ahead_nanos: counters.ahead_nanos.load(Ordering::Relaxed), - unused_bits_load_passes: counters.unused_bits_load_passes.load(Ordering::Relaxed), - unused_bits_load_texels: counters.unused_bits_load_texels.load(Ordering::Relaxed), - capture_reach_passes: counters.capture_reach_passes.load(Ordering::Relaxed), - capture_reach_primitives: counters.capture_reach_primitives.load(Ordering::Relaxed), - capture_reach_tiles_found: counters.capture_reach_tiles_found.load(Ordering::Relaxed), - capture_reach_tiles_bound: counters.capture_reach_tiles_bound.load(Ordering::Relaxed), - capture_reach_bound_passes: counters.capture_reach_bound_passes.load(Ordering::Relaxed), - capture_reach_narrower_passes: counters - .capture_reach_narrower_passes - .load(Ordering::Relaxed), driver_diagnostics_withheld: counters .driver_diagnostics_withheld .load(Ordering::Relaxed), diff --git a/crates/metal2vulkan-runtime/src/ycbcr.rs b/crates/metal2vulkan-runtime/src/ycbcr.rs index 4b1ed86cd..888e32ad1 100644 --- a/crates/metal2vulkan-runtime/src/ycbcr.rs +++ b/crates/metal2vulkan-runtime/src/ycbcr.rs @@ -994,8 +994,8 @@ struct YCbCrLoad { groups: [u32; 2], } -/// The side of the tiles Metal loads and stores a render pass's attachment by -/// (`bind::tile_reach`): a pass that loads a two-plane YCbCr attachment stores every texel of +/// The side of the tiles Metal loads and stores a render pass's attachment by (32 x 32 on Apple's +/// GPUs): a pass that loads a two-plane YCbCr attachment stores every texel of /// each tile it reaches, its codes re-encoded from what the tile loaded. const TILE: u32 = 32; diff --git a/crates/metal2vulkan-validation/fixtures/public/tile_reach/device_passes.txt b/crates/metal2vulkan-validation/fixtures/public/tile_reach/device_passes.txt deleted file mode 100644 index 59dd1c3ef..000000000 --- a/crates/metal2vulkan-validation/fixtures/public/tile_reach/device_passes.txt +++ /dev/null @@ -1,1797 +0,0 @@ -# The tile reach kernel on a device: passes and the -# rule's answers, generated by bind::tile_reach::tests::device from the measured cases -# and seeded random passes. Our own synthetic data. Print it again with -# cargo nextest run -p metal2vulkan --all-features --lib --run-ignored ignored-only --no-capture -E 'test(/print_the_device_passes/)' -# Per pass: `pass `; each state, `state` and its 12 -# words (TileReachModule::state); each primitive, `primitive` and its 16 words -# (TileReachModule::primitive), words in hex; `expect `, the -# header's two counts; and the tile mask's set bits, `bits` and up to 16 indices a line. -pass 40 40 1 3 -state 00000000 00000000 42200000 42200000 00000000 00000000 00000028 00000028 00000000 00000000 00000000 00000000 -state 00000000 00000000 42200000 42200000 00000000 00000000 00000028 00000028 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 00000001 3f800000 c0400000 40400000 3f000000 3f800000 40a00000 40400000 3f000000 3f800000 c0400000 c0a00000 3f000000 3f800000 -primitive 00000002 00000001 00000002 3f800000 bd800000 3d800000 3f000000 3f800000 3dc00000 3d800000 3f000000 3f800000 bd800000 bdc00000 3f000000 3f800000 -primitive 00000002 00000001 00000002 3f800000 3dc00000 3d800000 3f000000 3f800000 3dc00000 bdc00000 3f000000 3f800000 bd800000 bdc00000 3f000000 3f800000 -expect 0 0 -bits 4 5 6 7 8 -pass 128 128 1 213 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000002 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000002 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000028 00000028 0000000a 0000000a 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000028 00000028 0000000a 0000000a 00000000 00000000 00000000 00000000 -state 42000000 42000000 42000000 42000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000001 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 42010000 42010000 41fc0000 41fc0000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 41a00000 41a00000 41a00000 41a00000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000032 00000032 00000004 00000004 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 42400000 42400000 41800000 41800000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 42000000 42000000 42000000 42000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 3e800000 3e800000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 42800000 42800000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 00000001 3f800000 c0400000 40400000 3f000000 3f800000 40a00000 40400000 3f000000 3f800000 c0400000 c0a00000 3f000000 3f800000 -primitive 00000002 00000001 00000002 3f800000 bec00000 3ec00000 3f000000 3f800000 be600000 3ec00000 3f000000 3f800000 bec00000 3e600000 3f000000 3f800000 -primitive 00000002 00000001 00000002 3f800000 be600000 3ec00000 3f000000 3f800000 be600000 3e600000 3f000000 3f800000 bec00000 3e600000 3f000000 3f800000 -primitive 00000002 00000002 00000003 3f800000 bebf3333 3ebf3333 3f000000 3f800000 bebccccd 3ebf3333 3f000000 3f800000 bebf3333 3ebccccd 3f000000 3f800000 -primitive 00000002 00000003 00000004 3f800000 bebd999a 3ebd999a 3f000000 3f800000 beb9999a 3ebd999a 3f000000 3f800000 bebd999a 3eb9999a 3f000000 3f800000 -primitive 00000002 00000004 00000005 3f800000 bf800000 3f800000 3f000000 3f800000 3ef80000 3f800000 3f000000 3f800000 bf800000 bef80000 3f000000 3f800000 -primitive 00000002 00000005 00000006 3f800000 bf800000 3f800000 3f000000 3f800000 3f800000 3f800000 3f000000 3f800000 3f800000 bf800000 3f000000 3f800000 -primitive 00000002 00000006 00000007 3f800000 bf780000 3f780000 3f000000 3f800000 3f780000 bf780000 3f000000 3f800000 bf733333 3f780000 3f000000 3f800000 -primitive 00000002 00000007 00000008 3f800000 bf75999a 3f75999a 3f000000 3f800000 3f766666 bf766666 3f000000 3f800000 bf75851f 3f75ae14 3f000000 3f800000 -primitive 00000002 00000008 00000009 3f800000 bf01999a 3f580000 3f000000 3f800000 befccccd 3f580000 3f000000 3f800000 bf01999a 3f300000 3f000000 3f800000 -primitive 00000002 00000008 00000009 3f800000 befccccd 3f580000 3f000000 3f800000 befccccd 3f300000 3f000000 3f800000 bf01999a 3f300000 3f000000 3f800000 -primitive 00000002 00000009 0000000a 3f800000 bf300000 3f300000 3f000000 3f800000 bf000000 3f300000 3f000000 3f800000 bf300000 3f080000 3f000000 3f800000 -primitive 00000002 00000009 0000000a 3f800000 bf000000 3f300000 3f000000 3f800000 bf000000 3f080000 3f000000 3f800000 bf300000 3f080000 3f000000 3f800000 -primitive 00000002 0000000a 0000000b 3f800000 bf300000 3f300000 3f000000 3f800000 befd999a 3f300000 3f000000 3f800000 bf300000 3f080000 3f000000 3f800000 -primitive 00000002 0000000a 0000000b 3f800000 befd999a 3f300000 3f000000 3f800000 befd999a 3f080000 3f000000 3f800000 bf300000 3f080000 3f000000 3f800000 -primitive 00000002 0000000b 0000000c 3f800000 bf300000 3f300000 3f000000 3f800000 befb3333 3f300000 3f000000 3f800000 bf300000 3f080000 3f000000 3f800000 -primitive 00000002 0000000b 0000000c 3f800000 befb3333 3f300000 3f000000 3f800000 befb3333 3f080000 3f000000 3f800000 bf300000 3f080000 3f000000 3f800000 -primitive 00000002 0000000c 0000000d 3f800000 bec00000 3ec00000 3f000000 3f800000 bec00000 3e600000 3f000000 3f800000 be600000 3ec00000 3f000000 3f800000 -primitive 00000002 0000000d 0000000e 3f800000 bec00000 3ec00000 3f000000 3f800000 be600000 3ec00000 3f000000 3f800000 bec00000 3e600000 3f000000 3f800000 -primitive 00000002 0000000e 0000000f 3f800000 bf780000 3f580000 3f000000 3f800000 00000000 3f580000 3f000000 3f800000 3f780000 3f580000 3f000000 3f800000 -primitive 00000002 0000000f 00000010 3f800000 bec00000 3ec00000 3f000000 3f800000 be600000 3ec00000 3f000000 3f800000 bec00000 3e600000 3f000000 3f800000 -primitive 00000002 0000000f 00000010 3f800000 be600000 3ec00000 3f000000 3f800000 be600000 3e600000 3f000000 3f800000 bec00000 3e600000 3f000000 3f800000 -primitive 00000002 00000010 00000011 3f800000 c0400000 40400000 3f000000 3f800000 40a00000 40400000 3f000000 3f800000 c0400000 c0a00000 3f000000 3f800000 -primitive 00000002 00000011 00000012 3f800000 bf780000 3f780000 3f000000 3f800000 bf580000 3f780000 3f000000 3f800000 bf780000 3f580000 3f000000 3f800000 -primitive 00000002 00000011 00000012 3f800000 bf580000 3f780000 3f000000 3f800000 bf580000 3f580000 3f000000 3f800000 bf780000 3f580000 3f000000 3f800000 -primitive 00000002 00000012 00000013 3f800000 c0400000 40400000 3f000000 3f800000 40a00000 40400000 3f000000 3f800000 c0400000 c0a00000 3f000000 3f800000 -primitive 00000002 00000013 00000014 3f800000 3f100000 bf100000 3f000000 3f800000 406c0000 bf100000 3f000000 3f800000 3f100000 c06c0000 3f000000 3f800000 -primitive 00000002 00000014 00000015 3f800000 40080000 c0080000 3f000000 3f800000 406c0000 c0080000 3f000000 3f800000 40080000 c06c0000 3f000000 3f800000 -primitive 00000002 00000015 00000016 3f800000 bec00000 3ec00000 bf000000 3f800000 be600000 3ec00000 bf000000 3f800000 bec00000 3e600000 bf000000 3f800000 -primitive 00000000 00000016 00000017 3f800000 bebc0000 3ebc0000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000017 00000018 42200000 00000000 00000000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000001 00000018 00000019 3f800000 bf780000 3ebc0000 3f000000 3f800000 3f780000 3ebc0000 3f000000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000001 00000019 0000001a 3f800000 bf780000 3f780000 3f000000 3f800000 3f780000 bf780000 3f000000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000002 0000001a 0000001b 3f800000 bec00000 3ec00000 3f000000 3f800000 beb86666 3ec00000 3f000000 3f800000 bec00000 3eb86666 3f000000 3f800000 -primitive 00000002 0000001b 0000001c 3f800000 bf040000 3ec00000 3f000000 3f800000 befb3333 3ec00000 3f000000 3f800000 bf040000 3ebb3333 3f000000 3f800000 -primitive 00000002 0000001c 0000001d 3f800000 bf040000 3ec00000 3f000000 3f800000 befb3333 3ec00000 3f000000 3f800000 bf040000 3eb66666 3f000000 3f800000 -primitive 00000002 0000001d 0000001e 3f800000 bf200000 3f600000 3f000000 3f800000 bf004000 3f600000 3f000000 3f800000 bf200000 3f400000 3f000000 3f800000 -primitive 00000002 0000001d 0000001e 3f800000 bf004000 3f600000 3f000000 3f800000 bf004000 3f400000 3f000000 3f800000 bf200000 3f400000 3f000000 3f800000 -primitive 00000002 0000001e 0000001f 3f800000 bf200000 3f600000 3f000000 3f800000 bf001000 3f600000 3f000000 3f800000 bf200000 3f400000 3f000000 3f800000 -primitive 00000002 0000001e 0000001f 3f800000 bf001000 3f600000 3f000000 3f800000 bf001000 3f400000 3f000000 3f800000 bf200000 3f400000 3f000000 3f800000 -primitive 00000002 0000001f 00000020 3f800000 bf200000 3f600000 3f000000 3f800000 bf000400 3f600000 3f000000 3f800000 bf200000 3f400000 3f000000 3f800000 -primitive 00000002 0000001f 00000020 3f800000 bf000400 3f600000 3f000000 3f800000 bf000400 3f400000 3f000000 3f800000 bf200000 3f400000 3f000000 3f800000 -primitive 00000002 00000020 00000021 3f800000 bf200000 3f600000 3f000000 3f800000 bf000200 3f600000 3f000000 3f800000 bf200000 3f400000 3f000000 3f800000 -primitive 00000002 00000020 00000021 3f800000 bf000200 3f600000 3f000000 3f800000 bf000200 3f400000 3f000000 3f800000 bf200000 3f400000 3f000000 3f800000 -primitive 00000002 00000021 00000022 3f800000 bf200000 3f600000 3f000000 3f800000 bf000040 3f600000 3f000000 3f800000 bf200000 3f400000 3f000000 3f800000 -primitive 00000002 00000021 00000022 3f800000 bf000040 3f600000 3f000000 3f800000 bf000040 3f400000 3f000000 3f800000 bf200000 3f400000 3f000000 3f800000 -primitive 00000002 00000022 00000023 3f800000 bf200000 3f600000 3f000000 3f800000 bf000000 3f600000 3f000000 3f800000 bf200000 3f400000 3f000000 3f800000 -primitive 00000002 00000022 00000023 3f800000 bf000000 3f600000 3f000000 3f800000 bf000000 3f400000 3f000000 3f800000 bf200000 3f400000 3f000000 3f800000 -primitive 00000002 00000023 00000024 3f800000 bf000000 3f600000 3f000000 3f800000 bec00000 3f600000 3f000000 3f800000 bf000000 3f400000 3f000000 3f800000 -primitive 00000002 00000023 00000024 3f800000 bec00000 3f600000 3f000000 3f800000 bec00000 3f400000 3f000000 3f800000 bf000000 3f400000 3f000000 3f800000 -primitive 00000002 00000024 00000025 3f800000 bf600000 3f200000 3f000000 3f800000 bf400000 3f200000 3f000000 3f800000 bf600000 3f004000 3f000000 3f800000 -primitive 00000002 00000024 00000025 3f800000 bf400000 3f200000 3f000000 3f800000 bf400000 3f004000 3f000000 3f800000 bf600000 3f004000 3f000000 3f800000 -primitive 00000002 00000025 00000026 3f800000 bf600000 3f200000 3f000000 3f800000 bf400000 3f200000 3f000000 3f800000 bf600000 3f000200 3f000000 3f800000 -primitive 00000002 00000025 00000026 3f800000 bf400000 3f200000 3f000000 3f800000 bf400000 3f000200 3f000000 3f800000 bf600000 3f000200 3f000000 3f800000 -primitive 00000002 00000026 00000027 3f800000 bf600000 3f200000 3f000000 3f800000 bf400000 3f200000 3f000000 3f800000 bf600000 3f000000 3f000000 3f800000 -primitive 00000002 00000026 00000027 3f800000 bf400000 3f200000 3f000000 3f800000 bf400000 3f000000 3f000000 3f800000 bf600000 3f000000 3f000000 3f800000 -primitive 00000002 00000027 00000028 3f800000 bf800000 3f800000 3f000000 3f800000 3f000000 3f800000 3f000000 3f800000 bf800000 bf000000 3f000000 3f800000 -primitive 00000002 00000028 00000029 3f800000 bf800000 3f800000 3f000000 3f800000 bf000000 3f800000 3f000000 3f800000 bf800000 3f000000 3f000000 3f800000 -primitive 00000002 00000029 0000002a 3f800000 bec00000 3ec00000 3f000000 3f800000 00000000 3ec00000 3f000000 3f800000 bec00000 00000000 3f000000 3f800000 -primitive 00000000 0000002a 0000002b 3f800000 bf010000 3f560000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000002b 0000002c 3f800000 bf000000 3f560000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000002c 0000002d 40000000 bef80000 3f560000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000002d 0000002e 3f000000 bec00000 3ec00000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000002e 0000002f 42200000 3f840000 00000000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000001 0000002f 00000030 3f800000 bf780000 3f006666 3f000000 3f800000 bf300000 3f006666 3f000000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000001 00000030 00000031 3f800000 bf780000 3f000000 3f000000 3f800000 bf300000 3f000000 3f000000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000001 00000031 00000032 3f800000 bf780000 3f020000 3f000000 3f800000 bf300000 3f020000 3f000000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000001 00000032 00000033 3f800000 bebf3333 3ebf3333 3f000000 3f800000 bebccccd 3ebf3333 3f000000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000001 00000033 00000034 3f800000 bf580000 3f560000 3f000000 3f800000 bf000000 3f560000 3f000000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000002 00000034 00000035 3f800000 bec00000 3ec00000 3fc00000 3f800000 be600000 3ec00000 3fc00000 3f800000 bec00000 3e600000 3fc00000 3f800000 -primitive 00000002 00000034 00000035 3f800000 be600000 3ec00000 3fc00000 3f800000 be600000 3e600000 3fc00000 3f800000 bec00000 3e600000 3fc00000 3f800000 -primitive 00000002 00000035 00000036 3f800000 bec00000 3ec00000 3fc00000 3f800000 be600000 3ec00000 3fc00000 3f800000 bec00000 3e600000 3fc00000 3f800000 -primitive 00000002 00000035 00000036 3f800000 be600000 3ec00000 3fc00000 3f800000 be600000 3e600000 3fc00000 3f800000 bec00000 3e600000 3fc00000 3f800000 -primitive 00000002 00000036 00000037 3f800000 bec00000 3ec00000 3f000000 3f800000 be600000 3ec00000 3f000000 3f800000 bec00000 3e600000 3f000000 3f800000 -primitive 00000002 00000036 00000037 3f800000 be600000 3ec00000 3f000000 3f800000 be600000 3e600000 3f000000 3f800000 bec00000 3e600000 3f000000 3f800000 -primitive 00000002 00000037 00000038 3f800000 c4c37000 3ec00000 3f000000 3f800000 44c33000 3ec00000 3f000000 3f800000 bf800000 c4c33000 3f000000 3f800000 -primitive 00000002 00000038 00000039 3f800000 c4c37000 3f000000 3f000000 3f800000 44c33000 3f000000 3f000000 3f800000 bf800000 c4c33000 3f000000 3f800000 -primitive 00000002 00000039 0000003a 3f800000 c0400000 40400000 3f000000 3f800000 40a00000 40400000 3f000000 3f800000 c0400000 c0a00000 3f000000 3f800000 -primitive 00000002 0000003a 0000003b 3f800000 c0400000 40400000 3f000000 3f800000 40a00000 40400000 3f000000 3f800000 c0400000 c0a00000 3f000000 3f800000 -primitive 00000002 0000003b 0000003c 3f800000 bf780000 3f780000 3f000000 3f800000 bf680000 3f780000 3f000000 3f800000 bf780000 3f680000 3f000000 3f800000 -primitive 00000002 0000003b 0000003c 3f800000 bf680000 3f780000 3f000000 3f800000 bf680000 3f680000 3f000000 3f800000 bf780000 3f680000 3f000000 3f800000 -primitive 00000002 0000003c 0000003d 3f800000 bf780000 3f780000 3f000000 3f800000 bf680000 3f780000 3f000000 3f800000 bf780000 3f680000 3f000000 3f800000 -primitive 00000002 0000003c 0000003d 3f800000 bf680000 3f780000 3f000000 3f800000 bf680000 3f680000 3f000000 3f800000 bf780000 3f680000 3f000000 3f800000 -primitive 00000002 0000003d 0000003e 3f800000 bf780000 3f780000 3f000000 3f800000 bf680000 3f780000 3f000000 3f800000 bf780000 3f680000 3f000000 3f800000 -primitive 00000002 0000003d 0000003e 3f800000 bf680000 3f780000 3f000000 3f800000 bf680000 3f680000 3f000000 3f800000 bf780000 3f680000 3f000000 3f800000 -primitive 00000002 0000003e 0000003f 3f800000 bf780000 3f780000 3f000000 3f800000 bf680000 3f780000 3f000000 3f800000 bf780000 3f680000 3f000000 3f800000 -primitive 00000002 0000003e 0000003f 3f800000 bf680000 3f780000 3f000000 3f800000 bf680000 3f680000 3f000000 3f800000 bf780000 3f680000 3f000000 3f800000 -primitive 00000002 0000003f 00000040 3f800000 bf780000 3f780000 3f000000 3f800000 bf680000 3f780000 3f000000 3f800000 bf780000 3f680000 3f000000 3f800000 -primitive 00000002 0000003f 00000040 3f800000 bf680000 3f780000 3f000000 3f800000 bf680000 3f680000 3f000000 3f800000 bf780000 3f680000 3f000000 3f800000 -primitive 00000002 00000040 00000041 3f800000 bf780000 3f780000 3f000000 3f800000 bf680000 3f780000 3f000000 3f800000 bf780000 3f680000 3f000000 3f800000 -primitive 00000002 00000040 00000041 3f800000 bf680000 3f780000 3f000000 3f800000 bf680000 3f680000 3f000000 3f800000 bf780000 3f680000 3f000000 3f800000 -primitive 00000002 00000041 00000042 3f800000 bebc0000 3ec00000 3f000000 3f800000 beb8cccd 3ebc0000 3f000000 3f800000 bebc0000 3eb80000 3f000000 3f800000 -primitive 00000002 00000042 00000043 3f800000 bebc0000 3ec00000 3f000000 3f800000 bebc0000 3eb80000 3f000000 3f800000 bebf3333 3ebc0000 3f000000 3f800000 -primitive 00000002 00000043 00000044 3f800000 bec00000 3ebc0000 3f000000 3f800000 beb80000 3ebc0000 3f000000 3f800000 bebc0000 3eb8cccd 3f000000 3f800000 -primitive 00000002 00000044 00000045 3f800000 bec00000 3ebc0000 3f000000 3f800000 bebc0000 3ebf3333 3f000000 3f800000 beb80000 3ebc0000 3f000000 3f800000 -primitive 00000002 00000045 00000046 3f800000 bebc0000 3ebc0000 3f000000 3f800000 beb8cccd 3ebb3333 3f000000 3f800000 bebb3333 3eb8cccd 3f000000 3f800000 -primitive 00000001 00000046 00000047 3f800000 bf580000 3f560000 3f000000 3f800000 bf01999a 3f560000 3f000000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000001 00000047 00000048 3f800000 bf580000 3f560000 3f000000 3f800000 bf006666 3f560000 3f000000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000001 00000048 00000049 3f800000 bf780000 3f026666 3f000000 3f800000 bf300000 3f026666 3f000000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000001 00000049 0000004a 3f800000 bf780000 3f023333 3f000000 3f800000 bf300000 3f023333 3f000000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000001 0000004a 0000004b 3f800000 bf01999a 3f780000 3f000000 3f800000 bf01999a 3f300000 3f000000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000001 0000004b 0000004c 3f800000 bf780000 3f040000 3f000000 3f800000 bd800000 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000002 0000004c 0000004d 3f800000 bec00000 3ec00000 3f000000 3f800000 bec00000 3d800000 3f000000 3f800000 3e800000 3e600000 bf000000 3f800000 -primitive 00000002 0000004d 0000004e 3f800000 bf780000 3f780000 3f000000 3f800000 bf700000 3f780000 3f000000 3f800000 be3ccccd 3e400000 3f000000 3f800000 -primitive 00000002 0000004e 0000004f 3f800000 bf780000 3f780000 3f000000 3f800000 bf700000 3f780000 3f000000 3f800000 be3ccccd 3e400000 3f000000 3f800000 -primitive 00000002 0000004f 00000050 3f800000 bebd999a 3ebf999a 3f000000 3f800000 bebc6666 3ebf999a 3f000000 3f800000 bebd999a 3ebe6666 3f000000 3f800000 -primitive 00000002 00000050 00000051 3f800000 bec00000 3ec00000 3f000000 3f800000 be600000 3ec00000 3f000000 3f800000 bec00000 3e600000 3f000000 3f800000 -primitive 00000002 00000050 00000051 3f800000 be600000 3ec00000 3f000000 3f800000 be600000 3e600000 3f000000 3f800000 bec00000 3e600000 3f000000 3f800000 -primitive 00000002 00000051 00000052 3f800000 bec00000 3ec00000 3f000000 3f800000 be600000 3ec00000 3f000000 3f800000 bec00000 3e600000 3f000000 3f800000 -primitive 00000002 00000051 00000052 3f800000 be600000 3ec00000 3f000000 3f800000 be600000 3e600000 3f000000 3f800000 bec00000 3e600000 3f000000 3f800000 -primitive 00000002 00000052 00000053 3f800000 bec00000 3ec00000 3f000000 3f800000 be600000 3ec00000 3f000000 3f800000 bec00000 3e600000 3f000000 3f800000 -primitive 00000002 00000052 00000053 3f800000 be600000 3ec00000 3f000000 3f800000 be600000 3e600000 3f000000 3f800000 bec00000 3e600000 3f000000 3f800000 -primitive 00000002 00000053 00000054 3f800000 bec00000 3ec00000 3f000000 3f800000 be600000 3ec00000 3f000000 3f800000 bec00000 3e600000 3f000000 3f800000 -primitive 00000002 00000053 00000054 3f800000 be600000 3ec00000 3f000000 3f800000 be600000 3e600000 3f000000 3f800000 bec00000 3e600000 3f000000 3f800000 -primitive 00000001 00000054 00000055 3f800000 bec00000 3f040000 3f000000 3f800000 bd800000 3f540000 3f000000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000001 00000055 00000056 3f800000 bec00000 3f02cccd 3f000000 3f800000 bd800000 3f52cccd 3f000000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000001 00000056 00000057 3f800000 bec00000 3f04cccd 3f000000 3f800000 bd800000 3f54cccd 3f000000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000001 00000057 00000058 3f800000 bf580000 3f300000 3f000000 3f800000 bf040000 3f2c0000 3f000000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000001 00000058 00000059 3f800000 bf580000 3f300000 3f000000 3f800000 bf026666 3f2c0000 3f000000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000002 00000059 0000005a 3f800000 bf780000 3f560000 3f000000 3f800000 00000000 3f560000 3f000000 3f800000 3f780000 3f560000 3f000000 3f800000 -primitive 00000002 0000005a 0000005b 3f800000 bebc0000 3f780000 3f000000 3f800000 bebc0000 00000000 3f000000 3f800000 bebc0000 bf780000 3f000000 3f800000 -primitive 00000002 0000005b 0000005c 3f800000 bebc0000 3ebc0000 3f000000 3f800000 bebc0000 3ebc0000 3f000000 3f800000 bebc0000 3ebc0000 3f000000 3f800000 -primitive 00000002 0000005c 0000005d 3f800000 bf780000 3f780000 3f000000 3f800000 bf700000 3f780000 3f000000 3f800000 be3ccccd 3e400000 3f000000 3f800000 -primitive 00000002 0000005d 0000005e 3f800000 bec00000 3ec00000 3f000000 3f800000 be600000 3ec00000 3f000000 3f800000 bec00000 3e600000 3f000000 3f800000 -primitive 00000002 0000005d 0000005e 3f800000 be600000 3ec00000 3f000000 3f800000 be600000 3e600000 3f000000 3f800000 bec00000 3e600000 3f000000 3f800000 -primitive 00000002 0000005e 0000005f 3f800000 bec00000 3ec00000 3f000000 3f800000 be600000 3ec00000 3f000000 3f800000 bec00000 3e600000 3f000000 3f800000 -primitive 00000002 0000005e 0000005f 3f800000 be600000 3ec00000 3f000000 3f800000 be600000 3e600000 3f000000 3f800000 bec00000 3e600000 3f000000 3f800000 -primitive 00000000 0000005f 00000060 00000000 bebc0000 3ebc0000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000060 00000061 3e800000 bf000000 3ebc0000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000061 00000062 3f800000 beb9999a 3eb9999a 3f000000 3f800000 beb66666 3eb9999a 3f000000 3f800000 beb9999a 3eb66666 3f000000 3f800000 -primitive 00000002 00000062 00000063 3f800000 bebacccd 3ebacccd 3f000000 3f800000 beb7999a 3ebacccd 3f000000 3f800000 bebacccd 3eb7999a 3f000000 3f800000 -primitive 00000002 00000063 00000064 3f800000 bebb6666 3ebb6666 3f000000 3f800000 beb83333 3ebb6666 3f000000 3f800000 bebb6666 3eb83333 3f000000 3f800000 -primitive 00000002 00000064 00000065 3f800000 bebbb333 3ebbb333 3f000000 3f800000 beb88000 3ebbb333 3f000000 3f800000 bebbb333 3eb88000 3f000000 3f800000 -primitive 00000002 00000065 00000066 3f800000 bebbd99a 3ebbd99a 3f000000 3f800000 beb8a666 3ebbd99a 3f000000 3f800000 bebbd99a 3eb8a666 3f000000 3f800000 -primitive 00000002 00000066 00000067 3f800000 bebbeccd 3ebbeccd 3f000000 3f800000 beb8b99a 3ebbeccd 3f000000 3f800000 bebbeccd 3eb8b99a 3f000000 3f800000 -primitive 00000002 00000067 00000068 3f800000 bebbf666 3ebbf666 3f000000 3f800000 beb8c333 3ebbf666 3f000000 3f800000 bebbf666 3eb8c333 3f000000 3f800000 -primitive 00000002 00000068 00000069 3f800000 bebbfb33 3ebbfb33 3f000000 3f800000 beb8c800 3ebbfb33 3f000000 3f800000 bebbfb33 3eb8c800 3f000000 3f800000 -primitive 00000002 00000069 0000006a 3f800000 bebbfd9a 3ebbfd9a 3f000000 3f800000 beb8ca66 3ebbfd9a 3f000000 3f800000 bebbfd9a 3eb8ca66 3f000000 3f800000 -primitive 00000002 0000006a 0000006b 3f800000 bebbfecd 3ebbfecd 3f000000 3f800000 beb8cb9a 3ebbfecd 3f000000 3f800000 bebbfecd 3eb8cb9a 3f000000 3f800000 -primitive 00000002 0000006b 0000006c 3f800000 bebacccd 3ebc0000 3f000000 3f800000 beb7999a 3ebc0000 3f000000 3f800000 bebacccd 3eb8cccd 3f000000 3f800000 -primitive 00000002 0000006c 0000006d 3f800000 bebc0000 3ebacccd 3f000000 3f800000 beb8cccd 3ebacccd 3f000000 3f800000 bebc0000 3eb7999a 3f000000 3f800000 -primitive 00000002 0000006d 0000006e 3f800000 bebbb333 3ebc0000 3f000000 3f800000 beb88000 3ebc0000 3f000000 3f800000 bebbb333 3eb8cccd 3f000000 3f800000 -primitive 00000002 0000006e 0000006f 3f800000 bebc0000 3ebbb333 3f000000 3f800000 beb8cccd 3ebbb333 3f000000 3f800000 bebc0000 3eb88000 3f000000 3f800000 -primitive 00000002 0000006f 00000070 3f800000 bebbd99a 3ebc0000 3f000000 3f800000 beb8a666 3ebc0000 3f000000 3f800000 bebbd99a 3eb8cccd 3f000000 3f800000 -primitive 00000002 00000070 00000071 3f800000 bebc0000 3ebbd99a 3f000000 3f800000 beb8cccd 3ebbd99a 3f000000 3f800000 bebc0000 3eb8a666 3f000000 3f800000 -primitive 00000002 00000071 00000072 3f800000 bebbfb33 3ebc0000 3f000000 3f800000 beb8c800 3ebc0000 3f000000 3f800000 bebbfb33 3eb8cccd 3f000000 3f800000 -primitive 00000002 00000072 00000073 3f800000 bebc0000 3ebbfb33 3f000000 3f800000 beb8cccd 3ebbfb33 3f000000 3f800000 bebc0000 3eb8c800 3f000000 3f800000 -primitive 00000002 00000073 00000074 3f800000 bebbfd9a 3ebc0000 3f000000 3f800000 beb8ca66 3ebc0000 3f000000 3f800000 bebbfd9a 3eb8cccd 3f000000 3f800000 -primitive 00000002 00000074 00000075 3f800000 bebc0000 3ebbfd9a 3f000000 3f800000 beb8cccd 3ebbfd9a 3f000000 3f800000 bebc0000 3eb8ca66 3f000000 3f800000 -primitive 00000002 00000075 00000076 3f800000 bebc147b 3ebc147b 3f000000 3f800000 beb8e148 3ebc147b 3f000000 3f800000 bebc147b 3eb8e148 3f000000 3f800000 -primitive 00000002 00000076 00000077 3f800000 bf766666 3f766666 3f000000 3f800000 bf71999a 3f766666 3f000000 3f800000 bf766666 3f71999a 3f000000 3f800000 -primitive 00000002 00000077 00000078 3f800000 bf766666 3f766666 3f000000 3f800000 bf71999a 3f766666 3f000000 3f800000 bf766666 3f71999a 3f000000 3f800000 -primitive 00000002 00000078 00000079 3f800000 bebf3333 3ebf3333 3f000000 3f800000 bebccccd 3ebf3333 3f000000 3f800000 bebf3333 3ebccccd 3f000000 3f800000 -primitive 00000002 00000079 0000007a 3f800000 bebf3333 3ebf3333 3f000000 3f800000 bebccccd 3ebf3333 3f000000 3f800000 bebf3333 3ebccccd 3f000000 3f800000 -primitive 00000002 0000007a 0000007b 3f800000 bebd999a 3ebd999a 3f000000 3f800000 beb9999a 3ebd999a 3f000000 3f800000 bebd999a 3eb9999a 3f000000 3f800000 -primitive 00000002 0000007b 0000007c 3f800000 bebd3d71 3ebf3d71 3f000000 3f800000 bebc70a4 3ebf3d71 3f000000 3f800000 bebd3d71 3ebe70a4 3f000000 3f800000 -primitive 00000002 0000007c 0000007d 3f800000 beb93d71 3ebd3d71 3f000000 3f800000 beb870a4 3ebd3d71 3f000000 3f800000 beb93d71 3ebc70a4 3f000000 3f800000 -primitive 00000002 0000007d 0000007e 3f800000 bebf3d71 3ebb3d71 3f000000 3f800000 bebe70a4 3ebb3d71 3f000000 3f800000 bebf3d71 3eba70a4 3f000000 3f800000 -primitive 00000002 0000007e 0000007f 3f800000 bebb3d71 3eb93d71 3f000000 3f800000 beba70a4 3eb93d71 3f000000 3f800000 bebb3d71 3eb870a4 3f000000 3f800000 -primitive 00000002 0000007f 00000080 3f800000 bec00000 3ebe0000 3f000000 3f800000 bebc0000 3eba0000 3f000000 3f800000 bec00000 3ebd3333 3f000000 3f800000 -primitive 00000002 00000080 00000081 3f800000 bec00000 3ebe0000 3f000000 3f800000 beb80000 3eb60000 3f000000 3f800000 bec00000 3ebd3333 3f000000 3f800000 -primitive 00000002 00000081 00000082 3f800000 bec00000 3ebe0000 3f000000 3f800000 beb40000 3eb20000 3f000000 3f800000 bec00000 3ebd3333 3f000000 3f800000 -primitive 00000002 00000082 00000083 3f800000 bec00000 3ebe0000 3f000000 3f800000 beb00000 3eae0000 3f000000 3f800000 bec00000 3ebd3333 3f000000 3f800000 -primitive 00000002 00000083 00000084 3f800000 bec00000 3ebe0000 3f000000 3f800000 beac0000 3eaa0000 3f000000 3f800000 bec00000 3ebd3333 3f000000 3f800000 -primitive 00000002 00000084 00000085 3f800000 bec00000 3ebe0000 3f000000 3f800000 bea80000 3ea60000 3f000000 3f800000 bec00000 3ebd3333 3f000000 3f800000 -primitive 00000002 00000085 00000086 3f800000 bec00000 3ebe0000 3f000000 3f800000 bea40000 3ea20000 3f000000 3f800000 bec00000 3ebd3333 3f000000 3f800000 -primitive 00000002 00000086 00000087 3f800000 bec00000 3ebe0000 3f000000 3f800000 bea00000 3e9e0000 3f000000 3f800000 bec00000 3ebd3333 3f000000 3f800000 -primitive 00000002 00000087 00000088 3f800000 bec00000 3ebe0000 3f000000 3f800000 be980000 3e960000 3f000000 3f800000 bec00000 3ebd3333 3f000000 3f800000 -primitive 00000002 00000088 00000089 3f800000 bec00000 3ebe0000 3f000000 3f800000 be900000 3e8e0000 3f000000 3f800000 bec00000 3ebd3333 3f000000 3f800000 -primitive 00000002 00000089 0000008a 3f800000 bec00000 3ebe0000 3f000000 3f800000 be880000 3e860000 3f000000 3f800000 bec00000 3ebd3333 3f000000 3f800000 -primitive 00000002 0000008a 0000008b 3f800000 bec00000 3ebe0000 3f000000 3f800000 be800000 3e7c0000 3f000000 3f800000 bec00000 3ebd3333 3f000000 3f800000 -primitive 00000002 0000008b 0000008c 3f800000 bec00000 3ebe0000 3f000000 3f800000 be600000 3e5c0000 3f000000 3f800000 bec00000 3ebd3333 3f000000 3f800000 -primitive 00000002 0000008c 0000008d 3f800000 bec00000 3ebe0000 3f000000 3f800000 be400000 3e3c0000 3f000000 3f800000 bec00000 3ebd3333 3f000000 3f800000 -primitive 00000002 0000008d 0000008e 3f800000 bec00000 3ebe0000 3f000000 3f800000 be000000 3df80000 3f000000 3f800000 bec00000 3ebd3333 3f000000 3f800000 -primitive 00000002 0000008e 0000008f 3f800000 bec00000 3ebe0000 3f000000 3f800000 00000000 bb800000 3f000000 3f800000 bec00000 3ebd3333 3f000000 3f800000 -primitive 00000002 0000008f 00000090 3f800000 bec00000 3ebe0000 3f000000 3f800000 3e000000 be040000 3f000000 3f800000 bec00000 3ebd3333 3f000000 3f800000 -primitive 00000002 00000090 00000091 3f800000 bec00000 3ebe0000 3f000000 3f800000 3ec00000 bec20000 3f000000 3f800000 bec00000 3ebd3333 3f000000 3f800000 -primitive 00000002 00000091 00000092 3f800000 bec00000 3ebe0000 3f000000 3f800000 3f200000 bf210000 3f000000 3f800000 bec00000 3ebd3333 3f000000 3f800000 -primitive 00000002 00000092 00000093 3f800000 bec00000 3ebe0000 3f000000 3f800000 3f600000 bf610000 3f000000 3f800000 bec00000 3ebd3333 3f000000 3f800000 -primitive 00000002 00000093 00000094 3f800000 beb80000 3eb60000 3f000000 3f800000 beac0000 3eaa0000 3f000000 3f800000 beb80000 3eb53333 3f000000 3f800000 -primitive 00000002 00000094 00000095 3f800000 bef80000 3ef60000 3f000000 3f800000 beec0000 3eea0000 3f000000 3f800000 bef80000 3ef53333 3f000000 3f800000 -primitive 00000002 00000095 00000096 3f800000 beb80000 3eb60000 3f000000 3f800000 bea80000 3ea60000 3f000000 3f800000 beb80000 3eb53333 3f000000 3f800000 -primitive 00000002 00000096 00000097 3f800000 bef80000 3ef60000 3f000000 3f800000 bee80000 3ee60000 3f000000 3f800000 bef80000 3ef53333 3f000000 3f800000 -primitive 00000002 00000097 00000098 3f800000 beb80000 3eb60000 3f000000 3f800000 bea00000 3e9e0000 3f000000 3f800000 beb80000 3eb53333 3f000000 3f800000 -primitive 00000002 00000098 00000099 3f800000 bef80000 3ef60000 3f000000 3f800000 bee00000 3ede0000 3f000000 3f800000 bef80000 3ef53333 3f000000 3f800000 -primitive 00000002 00000099 0000009a 3f800000 beb80000 3eb60000 3f000000 3f800000 be980000 3e960000 3f000000 3f800000 beb80000 3eb53333 3f000000 3f800000 -primitive 00000002 0000009a 0000009b 3f800000 bef80000 3ef60000 3f000000 3f800000 bed80000 3ed60000 3f000000 3f800000 bef80000 3ef53333 3f000000 3f800000 -primitive 00000002 0000009b 0000009c 3f800000 beb80000 3eb60000 3f000000 3f800000 be880000 3e860000 3f000000 3f800000 beb80000 3eb53333 3f000000 3f800000 -primitive 00000002 0000009c 0000009d 3f800000 bef80000 3ef60000 3f000000 3f800000 bec80000 3ec60000 3f000000 3f800000 bef80000 3ef53333 3f000000 3f800000 -primitive 00000002 0000009d 0000009e 3f800000 bec00000 3ebe0000 3f000000 3f800000 bec00000 3ebd3333 3f000000 3f800000 beb00000 3eae0000 3f000000 3f800000 -primitive 00000002 0000009e 0000009f 3f800000 bec00000 3ebe0000 3f000000 3f800000 bec00000 3ebd3333 3f000000 3f800000 bea00000 3e9e0000 3f000000 3f800000 -primitive 00000002 0000009f 000000a0 3f800000 bec00000 3ebe0000 3f000000 3f800000 bec00000 3ebd3333 3f000000 3f800000 be800000 3e7c0000 3f000000 3f800000 -primitive 00000002 000000a0 000000a1 3f800000 bebb3333 3eb93333 3f000000 3f800000 bea1999a 3e9f999a 3f000000 3f800000 bebb3333 3eb86666 3f000000 3f800000 -primitive 00000002 000000a1 000000a2 3f800000 bebc0000 3eba0000 3f000000 3f800000 bea40000 3ea20000 3f000000 3f800000 bebc0000 3eb93333 3f000000 3f800000 -primitive 00000002 000000a2 000000a3 3f800000 bebccccd 3ebacccd 3f000000 3f800000 bea4cccd 3ea2cccd 3f000000 3f800000 bebccccd 3eba0000 3f000000 3f800000 -primitive 00000002 000000a3 000000a4 3f800000 bec00000 3ebe0000 3f000000 3f800000 bea73333 3ea53333 3f000000 3f800000 bec00000 3ebd3333 3f000000 3f800000 -primitive 00000002 000000a4 000000a5 3f800000 bec00000 3ebe0000 3f000000 3f800000 bea66666 3ea46666 3f000000 3f800000 bec00000 3ebd3333 3f000000 3f800000 -primitive 00000002 000000a5 000000a6 3f800000 bec00000 3ebe0000 3f000000 3f800000 bea5999a 3ea3999a 3f000000 3f800000 bec00000 3ebd3333 3f000000 3f800000 -primitive 00000002 000000a6 000000a7 3f800000 bec00000 3ebe0000 3f000000 3f800000 bea4cccd 3ea2cccd 3f000000 3f800000 bec00000 3ebd3333 3f000000 3f800000 -primitive 00000002 000000a7 000000a8 3f800000 bec00000 3ebe0000 3f000000 3f800000 bea4147b 3ea2147b 3f000000 3f800000 bec00000 3ebd3333 3f000000 3f800000 -primitive 00000002 000000a8 000000a9 3f800000 bec00000 3ebe0000 3f000000 3f800000 bea80000 3ea60000 3f000000 3f800000 bec00000 3ebd3333 3f000000 3f800000 -primitive 00000002 000000a9 000000aa 3f800000 bec00000 3ebe0000 3f000000 3f800000 bea40000 3ea20000 3f000000 3f800000 bec00000 3ebd3333 3f000000 3f800000 -primitive 00000002 000000aa 000000ab 3f800000 bec00000 be80cccd 3f000000 3f800000 beb80000 be90cccd 3f000000 3f800000 bec00000 be826666 3f000000 3f800000 -primitive 00000002 000000ab 000000ac 3f800000 bec00000 3f2e999a 3f000000 3f800000 beb00000 3f2a999a 3f000000 3f800000 bec00000 3f2d6666 3f000000 3f800000 -primitive 00000002 000000ac 000000ad 3f800000 bec00000 be80cccd 3f000000 3f800000 beb4cccd be973333 3f000000 3f800000 bec00000 be826666 3f000000 3f800000 -primitive 00000002 000000ad 000000ae 3f800000 bec00000 3f2e999a 3f000000 3f800000 bea9999a 3f290000 3f000000 3f800000 bec00000 3f2d6666 3f000000 3f800000 -primitive 00000002 000000ae 000000af 3f800000 bec00000 be80cccd 3f000000 3f800000 beb40000 be98cccd 3f000000 3f800000 bec00000 be826666 3f000000 3f800000 -primitive 00000002 000000af 000000b0 3f800000 bec00000 3f2e999a 3f000000 3f800000 bea80000 3f28999a 3f000000 3f800000 bec00000 3f2d6666 3f000000 3f800000 -primitive 00000002 000000b0 000000b1 3f800000 bec00000 be80cccd 3f000000 3f800000 beb33333 be9a6666 3f000000 3f800000 bec00000 be826666 3f000000 3f800000 -primitive 00000002 000000b1 000000b2 3f800000 bec00000 3f2e999a 3f000000 3f800000 bea66666 3f283333 3f000000 3f800000 bec00000 3f2d6666 3f000000 3f800000 -primitive 00000002 000000b2 000000b3 3f800000 bec00000 be80cccd 3f000000 3f800000 beb20000 be9ccccd 3f000000 3f800000 bec00000 be826666 3f000000 3f800000 -primitive 00000002 000000b3 000000b4 3f800000 bec00000 3f2e999a 3f000000 3f800000 bea40000 3f27999a 3f000000 3f800000 bec00000 3f2d6666 3f000000 3f800000 -primitive 00000002 000000b4 000000b5 3f800000 bec00000 be80cccd 3f000000 3f800000 beb00000 bea0cccd 3f000000 3f800000 bec00000 be826666 3f000000 3f800000 -primitive 00000002 000000b5 000000b6 3f800000 bec00000 3f2e999a 3f000000 3f800000 bea00000 3f26999a 3f000000 3f800000 bec00000 3f2d6666 3f000000 3f800000 -primitive 00000002 000000b6 000000b7 3f800000 bec00000 be80cccd 3f000000 3f800000 bea80000 beb0cccd 3f000000 3f800000 bec00000 be826666 3f000000 3f800000 -primitive 00000002 000000b7 000000b8 3f800000 bec00000 3f2e999a 3f000000 3f800000 be900000 3f22999a 3f000000 3f800000 bec00000 3f2d6666 3f000000 3f800000 -primitive 00000002 000000b8 000000b9 3f800000 bec00000 3ebf2666 3f000000 3f800000 be800000 3eb72666 3f000000 3f800000 bec00000 3ebed99a 3f000000 3f800000 -primitive 00000002 000000b9 000000ba 3f800000 bec00000 3eb93333 3f000000 3f800000 beb80000 3e726666 3f000000 3f800000 bec00000 3eb6cccd 3f000000 3f800000 -primitive 00000002 000000ba 000000bb 3f800000 bec00000 3ebf70a4 3f000000 3f800000 be900000 3eb5d70a 3f000000 3f800000 bec00000 3ebef5c3 3f000000 3f800000 -primitive 00000002 000000bb 000000bc 3f800000 bec00000 3ebf51ec 3f000000 3f800000 be980000 3eb351ec 3f000000 3f800000 bec00000 3ebf147b 3f000000 3f800000 -primitive 00000002 000000bc 000000bd 3f800000 bec00000 3ebf70a4 3f000000 3f800000 be9c0000 3ea9d70a 3f000000 3f800000 bec00000 3ebef5c3 3f000000 3f800000 -primitive 00000002 000000bd 000000be 3f800000 bec00000 3ebf70a4 3f000000 3f800000 beb00000 3e95d70a 3f000000 3f800000 bec00000 3ebef5c3 3f000000 3f800000 -primitive 00000002 000000be 000000bf 3f800000 bec00000 3ebf51ec 3f000000 3f800000 beb00000 3e9a851f 3f000000 3f800000 bec00000 3ebf147b 3f000000 3f800000 -primitive 00000002 000000bf 000000c0 3f800000 bec00000 3ebc999a 3f000000 3f800000 beb1999a 3e98999a 3f000000 3f800000 bec00000 3ebb6666 3f000000 3f800000 -primitive 00000002 000000c0 000000c1 3f800000 bec00000 3ebd3333 3f000000 3f800000 bea4cccd 3ea20000 3f000000 3f800000 bec00000 3ebacccd 3f000000 3f800000 -primitive 00000002 000000c1 000000c2 3f800000 bec00000 3ebd3333 3f000000 3f800000 bea33333 3ea06666 3f000000 3f800000 bec00000 3ebacccd 3f000000 3f800000 -primitive 00000002 000000c2 000000c3 3f800000 bec00000 3ebd3333 3f000000 3f800000 beb5999a 3e3f3333 3f000000 3f800000 bec00000 3ebacccd 3f000000 3f800000 -primitive 00000002 000000c3 000000c4 3f800000 bec00000 3ebd3333 3f000000 3f800000 beb1999a 3e920000 3f000000 3f800000 bec00000 3ebacccd 3f000000 3f800000 -primitive 00000002 000000c4 000000c5 3f800000 bec00000 3ebd3333 3f000000 3f800000 bea66666 3ea3999a 3f000000 3f800000 bec00000 3ebacccd 3f000000 3f800000 -primitive 00000002 000000c5 000000c6 3f800000 bec00000 3ebc999a 3f000000 3f800000 be9d999a 3eab6666 3f000000 3f800000 bec00000 3ebb6666 3f000000 3f800000 -primitive 00000002 000000c6 000000c7 3f800000 bec00000 3ebf1111 3f000000 3f800000 be933333 3eb02222 3f000000 3f800000 bec00000 3ebe4444 3f000000 3f800000 -primitive 00000002 000000c7 000000c8 3f800000 bec00000 3ebfb05b 3f000000 3f800000 be466666 3eb560b6 3f000000 3f800000 bec00000 3ebf6c17 3f000000 3f800000 -primitive 00000002 000000c8 000000c9 3f800000 bec00000 3ebd3333 3f000000 3f800000 beb4cccd 3e30cccd 3f000000 3f800000 bec00000 3ebacccd 3f000000 3f800000 -primitive 00000002 000000c9 000000ca 3f800000 bec00000 3ebfb05b 3f000000 3f800000 be366666 3eb47d28 3f000000 3f800000 bec00000 3ebf6c17 3f000000 3f800000 -primitive 00000002 000000ca 000000cb 3f800000 bec00000 3ebd3333 3f000000 3f800000 beaf3333 3e8acccd 3f000000 3f800000 bec00000 3ebacccd 3f000000 3f800000 -primitive 00000002 000000cb 000000cc 3f800000 bec00000 3ebf1111 3f000000 3f800000 be8b3333 3ead7777 3f000000 3f800000 bec00000 3ebe4444 3f000000 3f800000 -primitive 00000002 000000cc 000000cd 3f800000 bec00000 3eb93333 3f000000 3f800000 beb4cccd 3e126666 3f000000 3f800000 bec00000 3eb6cccd 3f000000 3f800000 -primitive 00000002 000000cd 000000ce 3f800000 bec00000 3ebf51ec 3f000000 3f800000 be266666 3eb470a4 3f000000 3f800000 bec00000 3ebf147b 3f000000 3f800000 -primitive 00000002 000000ce 000000cf 3f800000 bec00000 3eb93333 3f000000 3f800000 beab3333 3e8f999a 3f000000 3f800000 bec00000 3eb6cccd 3f000000 3f800000 -primitive 00000002 000000cf 000000d0 3f800000 bec00000 3ebc999a 3f000000 3f800000 be9b3333 3eaa3333 3f000000 3f800000 bec00000 3ebb6666 3f000000 3f800000 -primitive 00000002 000000d0 000000d1 3f800000 bec00000 3ebd3333 3f000000 3f800000 beb5999a 3e15999a 3f000000 3f800000 bec00000 3ebacccd 3f000000 3f800000 -primitive 00000002 000000d1 000000d2 3f800000 bec00000 3ebd3333 3f000000 3f800000 beaccccd 3e83999a 3f000000 3f800000 bec00000 3ebacccd 3f000000 3f800000 -primitive 00000002 000000d2 000000d3 3f800000 bec00000 3ebe4ccd 3f000000 3f800000 be833333 3eaf199a 3f000000 3f800000 bec00000 3ebdb333 3f000000 3f800000 -primitive 00000002 000000d3 000000d4 3f800000 bec00000 3ebd3333 3f000000 3f800000 beb4cccd 3e040000 3f000000 3f800000 bec00000 3ebacccd 3f000000 3f800000 -expect 1 0 -bits 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 -bits 37 69 80 81 82 84 85 88 96 97 98 99 101 102 103 106 -bits 107 111 112 113 117 118 122 123 127 128 129 133 134 138 139 143 -bits 160 161 176 177 192 193 229 261 277 309 335 373 389 390 393 394 -bits 404 405 406 407 416 417 420 421 422 425 426 427 430 431 468 469 -bits 480 496 512 528 529 544 545 560 561 577 592 608 612 624 628 640 -bits 641 642 643 644 645 646 648 649 652 656 657 660 677 678 681 688 -bits 689 704 705 721 741 759 763 768 772 784 788 800 804 821 832 833 -bits 869 885 900 901 902 903 904 905 906 907 908 909 910 911 916 917 -bits 918 919 920 921 922 923 924 925 926 927 933 944 945 948 949 960 -bits 976 992 1008 1024 1040 1061 1077 1093 1109 1125 1136 1137 1152 1153 1168 1184 -bits 1200 1201 1216 1217 1220 1221 1237 1253 1264 1265 1269 1301 1317 1333 1349 1361 -bits 1377 1393 1408 1424 1493 1509 1525 1541 1556 1557 1701 1717 1861 1877 1893 1920 -bits 1941 2149 2165 2181 2197 2213 2229 2245 2261 2277 2293 2297 2298 2309 2313 2314 -bits 2325 2329 2330 2341 2345 2346 2350 2351 2357 2361 2362 2366 2367 2469 2485 2501 -bits 2517 2549 2565 2725 2937 2945 3029 3109 3221 3237 3253 3269 3285 3301 3317 3333 -bits 3349 3365 3381 3397 -pass 128 128 2 27 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 00000001 3f800000 bf780000 3f780000 3f000000 3f800000 bf680000 3f780000 3f000000 3f800000 bf780000 3f680000 3f000000 3f800000 -primitive 00000002 00000000 00000001 3f800000 bf680000 3f780000 3f000000 3f800000 bf680000 3f680000 3f000000 3f800000 bf780000 3f680000 3f000000 3f800000 -primitive 00000002 00000001 00000002 3f800000 bf780000 3f600000 3f000000 3f800000 bf680000 3f600000 3f000000 3f800000 bf780000 3f400000 3f000000 3f800000 -primitive 00000002 00000001 00000002 3f800000 bf680000 3f600000 3f000000 3f800000 bf680000 3f400000 3f000000 3f800000 bf780000 3f400000 3f000000 3f800000 -primitive 00000002 00000002 00000003 3f800000 beba3d71 3eba3d71 3f000000 3f800000 beb970a4 3eba3d71 3f000000 3f800000 beba3d71 3eb970a4 3f000000 3f800000 -primitive 00000002 00000003 00000004 3f800000 bebe3d71 3ebe3d71 3f000000 3f800000 bebd70a4 3ebe3d71 3f000000 3f800000 bebe3d71 3ebd70a4 3f000000 3f800000 -primitive 00000002 00000004 00000005 3f800000 bec00000 3ebe0000 3f000000 3f800000 beb40000 3eb20000 3f000000 3f800000 bec00000 3ebd3333 3f000000 3f800000 -primitive 00000002 00000005 00000006 3f800000 bec00000 3ebe0000 3f000000 3f800000 beb00000 3eae0000 3f000000 3f800000 bec00000 3ebd3333 3f000000 3f800000 -primitive 00000002 00000006 00000007 3f800000 bec00000 3ebe0000 3f000000 3f800000 beac0000 3eaa0000 3f000000 3f800000 bec00000 3ebd3333 3f000000 3f800000 -primitive 00000002 00000007 00000008 3f800000 bec00000 3ebe0000 3f000000 3f800000 bea80000 3ea60000 3f000000 3f800000 bec00000 3ebd3333 3f000000 3f800000 -primitive 00000002 00000008 00000009 3f800000 bec00000 3ebe0000 3f000000 3f800000 bea40000 3ea20000 3f000000 3f800000 bec00000 3ebd3333 3f000000 3f800000 -primitive 00000002 00000009 0000000a 3f800000 bec00000 3ebe0000 3f000000 3f800000 bea00000 3e9e0000 3f000000 3f800000 bec00000 3ebd3333 3f000000 3f800000 -primitive 00000002 0000000a 0000000b 3f800000 bebc8000 3ebd999a 3f000000 3f800000 beae8000 3ea1999a 3f000000 3f800000 bebc8000 3ebc6666 3f000000 3f800000 -primitive 00000002 0000000b 0000000c 3f800000 bebd8000 3ebd0ccd 3f000000 3f800000 bea1c000 3eaf2ccd 3f000000 3f800000 bebd8000 3ebc7333 3f000000 3f800000 -primitive 00000002 0000000c 0000000d 3f800000 bec00000 3eb93333 3f000000 3f800000 beb5c000 3e9a7333 3f000000 3f800000 bec00000 3eb6cccd 3f000000 3f800000 -primitive 00000002 0000000d 0000000e 3f800000 beb98000 3ebe3bbc 3f000000 3f800000 be9dc000 3eb4fbbc 3f000000 3f800000 beb98000 3ebd6eef 3f000000 3f800000 -primitive 00000002 0000000e 0000000f 3f800000 bec00000 3ebd3333 3f000000 3f800000 beaca000 3ea9d333 3f000000 3f800000 bec00000 3ebacccd 3f000000 3f800000 -primitive 00000002 0000000f 00000010 3f800000 bebe8000 3eb9999a 3f000000 3f800000 beb1c000 3ea0199a 3f000000 3f800000 bebe8000 3eb86666 3f000000 3f800000 -primitive 00000002 00000010 00000011 3f800000 bec00000 3ebe4ccd 3f000000 3f800000 bea70000 3eb1cccd 3f000000 3f800000 bec00000 3ebdb333 3f000000 3f800000 -primitive 00000002 00000011 00000012 3f800000 bec00000 3eb93333 3f000000 3f800000 beb58000 3e99b333 3f000000 3f800000 bec00000 3eb6cccd 3f000000 3f800000 -primitive 00000002 00000012 00000013 3f800000 bebe8000 3ebfe666 3f000000 3f800000 bea04000 3eb5d111 3f000000 3f800000 bebe8000 3ebf199a 3f000000 3f800000 -primitive 00000002 00000013 00000014 3f800000 bebd8000 3ebab333 3f000000 3f800000 bea9c000 3ea6f333 3f000000 3f800000 bebd8000 3eb84ccd 3f000000 3f800000 -primitive 00000002 00000014 00000015 3f800000 bebe8000 3ebcb333 3f000000 3f800000 beb2e000 3e99d333 3f000000 3f800000 bebe8000 3eba4ccd 3f000000 3f800000 -primitive 00000002 00000015 00000016 3f800000 bec00000 3ebdbbbc 3f000000 3f800000 be9c4000 3eb1d111 3f000000 3f800000 bec00000 3ebceeef 3f000000 3f800000 -primitive 00000002 00000016 00000017 3f800000 bec00000 3ebc999a 3f000000 3f800000 beb1c000 3ea0199a 3f000000 3f800000 bec00000 3ebb6666 3f000000 3f800000 -primitive 00000002 00000017 00000018 3f800000 bec00000 3ebe4ccd 3f000000 3f800000 bea5c000 3eb12ccd 3f000000 3f800000 bec00000 3ebdb333 3f000000 3f800000 -primitive 00000002 00000018 00000019 3f800000 bec00000 3eb93333 3f000000 3f800000 beb42000 3e959333 3f000000 3f800000 bec00000 3eb6cccd 3f000000 3f800000 -primitive 00000002 00000019 0000001a 3f800000 bebe8000 3ebfe666 3f000000 3f800000 be9dc000 3eb4fbbc 3f000000 3f800000 bebe8000 3ebf199a 3f000000 3f800000 -expect 0 0 -bits 16 32 53 69 117 133 149 165 325 341 357 373 389 405 421 -pass 128 128 4 34 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 00000001 3f800000 bf780000 3f780000 3f000000 3f800000 bf680000 3f780000 3f000000 3f800000 bf780000 3f680000 3f000000 3f800000 -primitive 00000002 00000000 00000001 3f800000 bf680000 3f780000 3f000000 3f800000 bf680000 3f680000 3f000000 3f800000 bf780000 3f680000 3f000000 3f800000 -primitive 00000002 00000001 00000002 3f800000 bf780000 3f600000 3f000000 3f800000 bf680000 3f600000 3f000000 3f800000 bf780000 3f400000 3f000000 3f800000 -primitive 00000002 00000001 00000002 3f800000 bf680000 3f600000 3f000000 3f800000 bf680000 3f400000 3f000000 3f800000 bf780000 3f400000 3f000000 3f800000 -primitive 00000002 00000002 00000003 3f800000 bf780000 3f600000 3f000000 3f800000 bf680000 3f600000 3f000000 3f800000 bf780000 3f406666 3f000000 3f800000 -primitive 00000002 00000002 00000003 3f800000 bf680000 3f600000 3f000000 3f800000 bf680000 3f406666 3f000000 3f800000 bf780000 3f406666 3f000000 3f800000 -primitive 00000002 00000003 00000004 3f800000 bebd999a 3ebf999a 3f000000 3f800000 bebc6666 3ebf999a 3f000000 3f800000 bebd999a 3ebe6666 3f000000 3f800000 -primitive 00000002 00000004 00000005 3f800000 bebd3d71 3ebf3d71 3f000000 3f800000 bebc70a4 3ebf3d71 3f000000 3f800000 bebd3d71 3ebe70a4 3f000000 3f800000 -primitive 00000002 00000005 00000006 3f800000 beb93d71 3ebd3d71 3f000000 3f800000 beb870a4 3ebd3d71 3f000000 3f800000 beb93d71 3ebc70a4 3f000000 3f800000 -primitive 00000002 00000006 00000007 3f800000 bebf3d71 3ebb3d71 3f000000 3f800000 bebe70a4 3ebb3d71 3f000000 3f800000 bebf3d71 3eba70a4 3f000000 3f800000 -primitive 00000002 00000007 00000008 3f800000 bebb3d71 3eb93d71 3f000000 3f800000 beba70a4 3eb93d71 3f000000 3f800000 bebb3d71 3eb870a4 3f000000 3f800000 -primitive 00000002 00000008 00000009 3f800000 bebc3d71 3ebc3d71 3f000000 3f800000 bebb70a4 3ebc3d71 3f000000 3f800000 bebc3d71 3ebb70a4 3f000000 3f800000 -primitive 00000002 00000009 0000000a 3f800000 bebe3d71 3ebe3d71 3f000000 3f800000 bebd70a4 3ebe3d71 3f000000 3f800000 bebe3d71 3ebd70a4 3f000000 3f800000 -primitive 00000002 0000000a 0000000b 3f800000 bec00000 3ebf999a 3f000000 3f800000 beb80000 3eb7999a 3f000000 3f800000 bec00000 3ebecccd 3f000000 3f800000 -primitive 00000002 0000000b 0000000c 3f800000 bec00000 3ebf999a 3f000000 3f800000 beb60000 3eb5999a 3f000000 3f800000 bec00000 3ebecccd 3f000000 3f800000 -primitive 00000002 0000000c 0000000d 3f800000 bec00000 3ebf999a 3f000000 3f800000 beb40000 3eb3999a 3f000000 3f800000 bec00000 3ebecccd 3f000000 3f800000 -primitive 00000002 0000000d 0000000e 3f800000 bec00000 3ebf999a 3f000000 3f800000 beb20000 3eb1999a 3f000000 3f800000 bec00000 3ebecccd 3f000000 3f800000 -primitive 00000002 0000000e 0000000f 3f800000 bec00000 3ebf999a 3f000000 3f800000 beb00000 3eaf999a 3f000000 3f800000 bec00000 3ebecccd 3f000000 3f800000 -primitive 00000002 0000000f 00000010 3f800000 bec00000 3ebf999a 3f000000 3f800000 beae0000 3ead999a 3f000000 3f800000 bec00000 3ebecccd 3f000000 3f800000 -primitive 00000002 00000010 00000011 3f800000 bec00000 3ebf999a 3f000000 3f800000 beac0000 3eab999a 3f000000 3f800000 bec00000 3ebecccd 3f000000 3f800000 -primitive 00000002 00000011 00000012 3f800000 bec00000 3ebf999a 3f000000 3f800000 bea80000 3ea7999a 3f000000 3f800000 bec00000 3ebecccd 3f000000 3f800000 -primitive 00000002 00000012 00000013 3f800000 bec00000 3ebf999a 3f000000 3f800000 bea40000 3ea3999a 3f000000 3f800000 bec00000 3ebecccd 3f000000 3f800000 -primitive 00000002 00000013 00000014 3f800000 bec00000 3ebf999a 3f000000 3f800000 bea00000 3e9f999a 3f000000 3f800000 bec00000 3ebecccd 3f000000 3f800000 -primitive 00000002 00000014 00000015 3f800000 beba8000 3ebc199a 3f000000 3f800000 beaf6000 3e9ab99a 3f000000 3f800000 beba8000 3ebae666 3f000000 3f800000 -primitive 00000002 00000015 00000016 3f800000 bebf8000 3ebeb333 3f000000 3f800000 be9ec000 3eb3c889 3f000000 3f800000 bebf8000 3ebe4ccd 3f000000 3f800000 -primitive 00000002 00000016 00000017 3f800000 bebe0000 3ebe999a 3f000000 3f800000 beaac000 3eab599a 3f000000 3f800000 bebe0000 3ebd6666 3f000000 3f800000 -primitive 00000002 00000017 00000018 3f800000 bebd8000 3ebbe666 3f000000 3f800000 beb0c000 3ea26666 3f000000 3f800000 bebd8000 3eba199a 3f000000 3f800000 -primitive 00000002 00000018 00000019 3f800000 bebe8000 3ebdb333 3f000000 3f800000 bea4c000 3eb0d333 3f000000 3f800000 bebe8000 3ebccccd 3f000000 3f800000 -primitive 00000002 00000019 0000001a 3f800000 bebe8000 3eb8199a 3f000000 3f800000 beb36000 3e96b99a 3f000000 3f800000 bebe8000 3eb6e666 3f000000 3f800000 -primitive 00000002 0000001a 0000001b 3f800000 bec00000 3eb8999a 3f000000 3f800000 beacc000 3ea5599a 3f000000 3f800000 bec00000 3eb76666 3f000000 3f800000 -primitive 00000002 0000001b 0000001c 3f800000 bebf8000 3ebfe666 3f000000 3f800000 beb2c000 3ea66666 3f000000 3f800000 bebf8000 3ebe199a 3f000000 3f800000 -primitive 00000002 0000001c 0000001d 3f800000 beba8000 3ebfb333 3f000000 3f800000 bea0c000 3eb2d333 3f000000 3f800000 beba8000 3ebecccd 3f000000 3f800000 -primitive 00000002 0000001d 0000001e 3f800000 bebe0000 3ebe999a 3f000000 3f800000 beaa2000 3eaab99a 3f000000 3f800000 bebe0000 3ebd6666 3f000000 3f800000 -primitive 00000002 0000001e 0000001f 3f800000 bebf8000 3ebfe666 3f000000 3f800000 beb1e000 3ea4a666 3f000000 3f800000 bebf8000 3ebe199a 3f000000 3f800000 -primitive 00000002 0000001f 00000020 3f800000 bec00000 3ebe7333 3f000000 3f800000 bea4c000 3eb0d333 3f000000 3f800000 bec00000 3ebd8ccd 3f000000 3f800000 -primitive 00000002 00000020 00000021 3f800000 bebc8000 3ebdb333 3f000000 3f800000 be9be000 3eb2d333 3f000000 3f800000 bebc8000 3ebd4ccd 3f000000 3f800000 -expect 0 0 -bits 32 64 68 96 137 169 201 233 265 553 585 617 649 -pass 2048 64 1 248 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -state 00000000 00000000 45000000 42800000 00000000 00000000 00000800 00000040 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000001 3fa64000 bf702980 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000001 00000002 3fa64000 bf6fd680 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000002 00000003 3fa64000 bf7029c0 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000003 00000004 3fa64000 bf6fd640 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000004 00000005 3fa68000 bf702980 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000005 00000006 3fa68000 bf6fd680 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000006 00000007 3fa68000 bf7029c0 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000007 00000008 3fa68000 bf6fd640 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000008 00000009 3fa6c000 bf702980 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000009 0000000a 3fa6c000 bf6fd680 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000000a 0000000b 3fa6c000 bf7029c0 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000000b 0000000c 3fa6c000 bf6fd640 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000000c 0000000d 3fa64000 bf70299a 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000000d 0000000e 3fa64000 bf6fd666 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000000e 0000000f 3fa64000 bf7029a6 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000000f 00000010 3fa64000 bf6fd65a 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000010 00000011 42200000 39800000 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000011 00000012 43ff8000 39800000 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000012 00000013 44000000 39800000 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000013 00000014 44004000 39800000 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000014 00000015 447a0000 39800000 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000015 00000016 44fa0000 39800000 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000016 00000017 46000000 39800000 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000017 00000018 42800000 bf83c000 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000018 00000019 43480000 bf8c4000 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000019 0000001a 447a0000 bfbe4000 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000001a 0000001b 3fa64000 bf702a00 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000001b 0000001c 3fa62000 bf7029c0 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000001c 0000001d 3fa61000 bf7029c0 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000001d 0000001e 3fa60800 bf7029c0 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000001e 0000001f 3fa60000 bf7029c0 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000001f 00000020 3fa5e000 bf7029c0 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000020 00000021 3fa64000 bf7029c0 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000021 00000022 3fa68000 bf6fd680 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000022 00000023 3fa68800 bf6fd680 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000023 00000024 3fa69000 bf6fd680 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000024 00000025 3fa6a000 bf6fd680 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000025 00000026 3fa6b000 bf6fd680 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000026 00000027 3fa6c000 bf6fd680 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000027 00000028 3fa64000 bf7c0000 bca60000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000028 00000029 3fa64000 bf7c0000 3ca60000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000029 0000002a 3fa64000 bf7c0000 bca70000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000002a 0000002b 3fa64000 bf7c0000 3ca70000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000002b 0000002c 3fa68000 bf7c0000 bca60000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000002c 0000002d 3fa68000 bf7c0000 3ca60000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000002d 0000002e 3fa68000 bf7c0000 bca70000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000002e 0000002f 3fa68000 bf7c0000 3ca70000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000002f 00000030 3fa6c000 bf7c0000 bca60000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000030 00000031 3fa6c000 bf7c0000 3ca60000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000031 00000032 3fa6c000 bf7c0000 bca70000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000032 00000033 3fa6c000 bf7c0000 3ca70000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000033 00000034 43ff4000 3a000000 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000034 00000035 43ff8000 3a000000 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000035 00000036 43ffa000 3a000000 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000036 00000037 44160000 3a000000 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000037 00000038 00000000 bf700040 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000038 00000039 00000000 bf700080 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000039 0000003a 00000000 bf7000c0 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000003a 0000003b 00000000 bf700100 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000003b 0000003c 00000000 bf700140 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000003c 0000003d 00000000 bf7001c0 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000003d 0000003e 00000000 bf700240 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000003e 0000003f 00000000 bf700340 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000003f 00000040 00000000 bf700440 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000040 00000041 00000000 bf700640 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000041 00000042 00000000 bf700840 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000042 00000043 00000000 bf700c40 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000043 00000044 00000000 bf701000 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000044 00000045 3d800000 bf700240 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000045 00000046 3d800000 bf700280 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000046 00000047 3d800000 bf7002c0 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000047 00000048 3d800000 bf700300 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000048 00000049 3d800000 bf700340 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000049 0000004a 3d800000 bf7003c0 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000004a 0000004b 3d800000 bf700440 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000004b 0000004c 3d800000 bf700540 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000004c 0000004d 3d800000 bf700640 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000004d 0000004e 3d800000 bf700840 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000004e 0000004f 3d800000 bf700a40 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000004f 00000050 3d800000 bf700e40 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000050 00000051 3d800000 bf701200 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000051 00000052 3e800000 bf700840 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000052 00000053 3e800000 bf700880 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000053 00000054 3e800000 bf7008c0 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000054 00000055 3e800000 bf700900 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000055 00000056 3e800000 bf700940 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000056 00000057 3e800000 bf7009c0 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000057 00000058 3e800000 bf700a40 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000058 00000059 3e800000 bf700b40 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000059 0000005a 3e800000 bf700c40 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000005a 0000005b 3e800000 bf700e40 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000005b 0000005c 3e800000 bf701040 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000005c 0000005d 3e800000 bf701440 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000005d 0000005e 3e800000 bf701800 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000005e 0000005f 3fa60000 bf7029c0 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000005f 00000060 3fa60000 bf702a00 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000060 00000061 3fa60000 bf702a40 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000061 00000062 3fa60000 bf702a80 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000062 00000063 3fa60000 bf702ac0 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000063 00000064 3fa60000 bf702b40 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000064 00000065 3fa60000 bf702bc0 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000065 00000066 3fa60000 bf702cc0 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000066 00000067 3fa60000 bf702dc0 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000067 00000068 3fa60000 bf702fc0 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000068 00000069 3fa60000 bf7031c0 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000069 0000006a 3fa60000 bf7035c0 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000006a 0000006b 3fa60000 bf703980 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000006b 0000006c 3fa64000 bf7029c0 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000006c 0000006d 3fa64000 bf702a00 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000006d 0000006e 3fa64000 bf702a40 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000006e 0000006f 3fa64000 bf702a80 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000006f 00000070 3fa64000 bf702ac0 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000070 00000071 3fa64000 bf702b40 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000071 00000072 3fa64000 bf702bc0 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000072 00000073 3fa64000 bf702cc0 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000073 00000074 3fa64000 bf702dc0 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000074 00000075 3fa64000 bf702fc0 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000075 00000076 3fa64000 bf7031c0 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000076 00000077 3fa64000 bf7035c0 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000077 00000078 3fa64000 bf703980 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000078 00000079 3fa68000 bf7029c0 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000079 0000007a 3fa68000 bf702a00 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000007a 0000007b 3fa68000 bf702a40 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000007b 0000007c 3fa68000 bf702a80 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000007c 0000007d 3fa68000 bf702ac0 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000007d 0000007e 3fa68000 bf702b40 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000007e 0000007f 3fa68000 bf702bc0 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000007f 00000080 3fa68000 bf702cc0 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000080 00000081 3fa68000 bf702dc0 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000081 00000082 3fa68000 bf702fc0 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000082 00000083 3fa68000 bf7031c0 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000083 00000084 3fa68000 bf7035c0 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000084 00000085 3fa68000 bf703980 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000085 00000086 3fa6c000 bf7029c0 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000086 00000087 3fa6c000 bf702a00 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000087 00000088 3fa6c000 bf702a40 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000088 00000089 3fa6c000 bf702a80 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000089 0000008a 3fa6c000 bf702ac0 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000008a 0000008b 3fa6c000 bf702b40 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000008b 0000008c 3fa6c000 bf702bc0 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000008c 0000008d 3fa6c000 bf702cc0 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000008d 0000008e 3fa6c000 bf702dc0 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000008e 0000008f 3fa6c000 bf702fc0 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000008f 00000090 3fa6c000 bf7031c0 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000090 00000091 3fa6c000 bf7035c0 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000091 00000092 3fa6c000 bf703980 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000092 00000093 3fa64000 ba270000 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000093 00000094 3fa64000 ba280000 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000094 00000095 3fa64000 ba290000 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000095 00000096 3fa64000 ba2a0000 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000096 00000097 3fa64000 ba2b0000 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000097 00000098 3fa64000 ba2d0000 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000098 00000099 3fa64000 ba2f0000 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000099 0000009a 3fa64000 ba330000 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000009a 0000009b 3fa64000 ba370000 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000009b 0000009c 3fa64000 ba3f0000 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000009c 0000009d 3fa64000 ba470000 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000009d 0000009e 3fa64000 ba570000 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000009e 0000009f 3fa64000 ba660000 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 0000009f 000000a0 42000000 bc800800 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000a0 000000a1 42000000 bc801000 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000a1 000000a2 42000000 bc801800 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000a2 000000a3 42000000 bc802000 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000a3 000000a4 42000000 bc802800 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000a4 000000a5 42000000 bc803800 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000a5 000000a6 42000000 bc804800 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000a6 000000a7 42000000 bc806800 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000a7 000000a8 42000000 bc808800 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000a8 000000a9 42000000 bc80c800 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000a9 000000aa 42000000 bc810800 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000aa 000000ab 42000000 bc818800 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000ab 000000ac 42000000 bc820000 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000ac 000000ad 436a6100 bdea6200 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000ad 000000ae 436a6100 bdea6400 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000ae 000000af 436a6100 bdea6600 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000af 000000b0 436a6100 bdea6800 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000b0 000000b1 436a6100 bdea6a00 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000b1 000000b2 436a6100 bdea6e00 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000b2 000000b3 436a6100 bdea7200 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000b3 000000b4 436a6100 bdea7a00 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000b4 000000b5 436a6100 bdea8200 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000b5 000000b6 436a6100 bdea9200 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000b6 000000b7 436a6100 bdeaa200 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000b7 000000b8 436a6100 bdeac200 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000b8 000000b9 436a6100 bdeae000 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000b9 000000ba 3b800000 bf700000 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000ba 000000bb 3b880000 bf700000 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000bb 000000bc 3d880000 bf6ffe00 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000bc 000000bd 3d888000 bf6ffe00 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000bd 000000be 3fa68000 3a260000 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000be 000000bf 3fa68800 3a260000 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000bf 000000c0 42000400 3c800000 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000c0 000000c1 42000440 3c800000 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000c1 000000c2 436a6100 3dea6000 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000c2 000000c3 436a6110 3dea6000 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000c3 000000c4 3fa64000 bf7c0000 3ca80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000c4 000000c5 3fa64000 bf7c0000 3caa0000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000c5 000000c6 3fa64000 bf7c0000 3cae0000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000c6 000000c7 3fa64000 bf7c0000 3cb60000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000c7 000000c8 3fa64000 bf7c0000 3cc60000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000c8 000000c9 3fa64000 bf7c0000 3ce60000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000c9 000000ca 3d880000 bf7c0000 ba800000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000ca 000000cb 3d888000 bf7c0000 ba800000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000cb 000000cc 43ff8000 ba010000 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000cc 000000cd 43ff8000 ba000000 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000cd 000000ce 43ff8000 b9fe0000 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000ce 000000cf 43ff8100 ba010000 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000cf 000000d0 43ff8100 ba000000 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000d0 000000d1 43ff8100 b9fe0000 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000d1 000000d2 44160000 ba010000 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000d2 000000d3 44160000 ba000000 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000d3 000000d4 44160000 b9fe0000 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000d4 000000d5 3d000000 bf700040 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000d5 000000d6 3d000000 bf700300 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000d6 000000d7 3d000000 bf700340 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000d7 000000d8 3dc00000 bf700100 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000d8 000000d9 3dc00000 bf700140 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000d9 000000da 3dc00000 bf700500 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000da 000000db 3dc00000 bf700540 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000db 000000dc 3fa40000 bf702700 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000dc 000000dd 3fa40000 bf702740 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000dd 000000de 3fa40000 bf702b00 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000de 000000df 3fa40000 bf702b40 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000df 000000e0 3fac0000 bf702900 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000e0 000000e1 3fac0000 bf702940 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000e1 000000e2 3fac0000 bf702d00 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000e2 000000e3 3fac0000 bf702d40 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000e3 000000e4 43800400 bdfff800 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000e4 000000e5 43800400 bdfffa00 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000e5 000000e6 43800400 be000c00 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000e6 000000e7 43800400 be000d00 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000e7 000000e8 407a2000 bf707f00 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000e8 000000e9 407a2000 bf707f40 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000e9 000000ea 407a4000 bf707f00 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000ea 000000eb 407a4000 bf707f40 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000eb 000000ec 407a6000 bf707ec0 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000ec 000000ed 407a6000 bf707f00 3ef80000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000ed 000000ee 3dc00000 bf7c0000 3a000000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000ee 000000ef 3dc00000 bf7c0000 3a200000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000ef 000000f0 3dc00000 bf7c0000 3b200000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000f0 000000f1 3dc00000 bf7c0000 3b280000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000f1 000000f2 3fa40000 bf7c0000 3c9c0000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000f2 000000f3 3fa40000 bf7c0000 3c9d0000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000f3 000000f4 3fa40000 bf7c0000 3cac0000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000f4 000000f5 3fa40000 bf7c0000 3cad0000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000f5 000000f6 407a6000 bf7c0000 3d7d8000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 000000f6 000000f7 407a6000 bf7c0000 3d7e0000 3f000000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -expect 0 0 -bits 129 130 258 385 386 514 641 642 770 897 898 1026 1153 1154 1281 1282 -bits 1409 1410 1538 1665 1666 1794 1921 1922 2050 2207 2208 2271 2272 2328 2329 2330 -bits 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2392 2393 2394 -bits 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2456 2457 2458 -bits 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2520 2521 2522 -bits 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2584 2585 2586 -bits 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2648 2649 2650 -bits 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2712 2713 2714 -bits 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2776 2777 2778 -bits 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2840 2841 2842 -bits 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2904 2905 2906 -bits 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2968 2969 2970 -bits 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 3032 3033 3034 -bits 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3072 3136 3200 -bits 3264 3457 3458 3585 3586 3713 3714 3841 3842 3969 3970 4097 4098 4225 4226 4354 -bits 4481 4482 4609 4610 4737 4738 4865 4866 4993 4994 5184 5248 5312 5440 5504 5568 -bits 5696 5760 5824 5952 6016 6080 6144 6208 6272 6336 6464 6528 6592 6680 6681 6682 -bits 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6744 6745 6746 -bits 6747 6748 6749 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6808 6809 6810 -bits 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6872 6873 -bits 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6936 -bits 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 -bits 7000 7001 7002 7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 7013 7014 7015 -bits 7016 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 -bits 7079 7080 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 7140 7141 -bits 7142 7143 7144 7169 7297 7425 7553 7681 7809 7937 8065 8193 8321 8449 8577 8705 -bits 8833 8961 9089 9217 9345 9473 9601 9729 9857 9985 10113 10241 10369 10497 10625 10753 -bits 10881 11009 11137 11265 11393 11521 11649 11777 11905 12033 12161 12162 12289 12290 12417 12418 -bits 12545 12546 12673 12801 12929 13057 13185 13313 13441 13569 13697 13825 13826 13953 13954 14081 -bits 14082 14209 14210 14337 14465 14593 14721 14849 14977 15105 15233 15361 15489 15490 15617 15618 -bits 15745 15746 15873 15874 16001 16129 16257 16385 16513 16641 16769 16897 17025 17153 17154 17281 -bits 17282 17409 17410 17537 17665 17793 17921 18049 18177 18305 18433 18561 18689 18847 18848 18975 -bits 18976 19103 19104 19231 19232 19359 19487 19615 19743 19871 19999 20127 20255 20383 20510 20511 -bits 20574 20575 20638 20639 20702 20703 20766 20767 20830 20831 20894 20895 20958 20959 21022 21023 -bits 21086 21087 21150 21151 21214 21215 21278 21279 21342 21343 21406 21407 21470 21471 21534 21535 -bits 21598 21599 21662 21663 21726 21727 21790 21791 21854 21855 21918 21919 21982 21983 22046 22047 -bits 22110 22111 22168 22169 22170 22171 22172 22173 22174 22175 22232 22233 22234 22235 22236 22237 -bits 22238 22239 22296 22297 22298 22299 22300 22301 22302 22303 22360 22361 22362 22363 22364 22365 -bits 22366 22367 22424 22425 22426 22427 22428 22429 22430 22431 22488 22489 22490 22491 22492 22493 -bits 22494 22495 22552 22553 22554 22555 22556 22557 22558 22559 22616 22617 22618 22619 22620 22621 -bits 22622 22623 22680 22681 22682 22683 22684 22685 22686 22687 22744 22745 22746 22747 22748 22749 -bits 22750 22751 22808 22809 22810 22811 22812 22813 22814 22815 22872 22873 22874 22875 22876 22877 -bits 22878 22879 22936 22937 22938 22939 22940 22941 22942 22943 23000 23001 23002 23003 23004 23005 -bits 23006 23007 23064 23065 23066 23067 23068 23069 23070 23071 23128 23129 23130 23131 23132 23133 -bits 23134 23135 23192 23193 23194 23195 23196 23197 23198 23199 23256 23257 23258 23259 23260 23261 -bits 23262 23263 23320 23321 23322 23323 23324 23325 23326 23327 23384 23385 23386 23387 23388 23389 -bits 23390 23391 23448 23449 23450 23451 23452 23453 23454 23455 23512 23513 23514 23515 23516 23517 -bits 23518 23519 23576 23577 23578 23579 23580 23581 23582 23583 23640 23641 23642 23643 23644 23645 -bits 23646 23647 23704 23705 23706 23707 23708 23709 23710 23711 23768 23769 23770 23771 23772 23773 -bits 23774 23775 23810 23937 24066 24193 24194 24352 24479 24480 24608 24609 24672 24673 24735 24736 -bits 24799 24800 24864 24865 24866 24867 24868 24869 24870 24871 24928 24929 24930 24931 24932 24933 -bits 24934 24935 24991 24992 24993 24994 24995 24996 24997 24998 24999 25055 25056 25057 25058 25059 -bits 25060 25061 25062 25063 25088 25152 25216 25280 25344 25472 25600 25728 25920 25984 26048 26135 -bits 26136 26137 26138 26139 26140 26141 26142 26143 26144 26145 26146 26147 26148 26149 26150 26151 -bits 26199 26200 26201 26202 26203 26204 26205 26206 26207 26208 26209 26210 26211 26212 26213 26214 -bits 26215 26264 26265 26266 26267 26268 26269 26270 26271 26272 26273 26274 26275 26276 26277 26278 -bits 26279 26328 26329 26330 26331 26332 26333 26334 26335 26336 26337 26338 26339 26340 26341 26342 -bits 26343 26392 26393 26394 26395 26396 26397 26398 26399 26400 26401 26402 26403 26404 26405 26406 -bits 26407 26456 26457 26458 26459 26460 26461 26462 26463 26464 26465 26466 26467 26468 26469 26470 -bits 26471 26519 26520 26521 26522 26523 26524 26525 26526 26527 26528 26529 26530 26531 26532 26533 -bits 26534 26535 26583 26584 26585 26586 26587 26588 26589 26590 26591 26592 26593 26594 26595 26596 -bits 26597 26598 26599 26648 26649 26650 26651 26652 26653 26654 26655 26656 26657 26658 26659 26660 -bits 26661 26662 26663 26712 26713 26714 26715 26716 26717 26718 26719 26720 26721 26722 26723 26724 -bits 26725 26726 26727 26776 26777 26778 26779 26780 26781 26782 26783 26784 26785 26786 26787 26788 -bits 26789 26790 26791 26840 26841 26842 26843 26844 26845 26846 26847 26848 26849 26850 26851 26852 -bits 26853 26854 26855 26903 26904 26905 26906 26907 26908 26909 26910 26911 26912 26913 26914 26915 -bits 26916 26917 26918 26919 26967 26968 26969 26970 26971 26972 26973 26974 26975 26976 26977 26978 -bits 26979 26980 26981 26982 26983 27032 27033 27034 27035 27036 27037 27038 27039 27040 27041 27042 -bits 27043 27044 27045 27046 27047 27096 27097 27098 27099 27100 27101 27102 27103 27104 27105 27106 -bits 27107 27108 27109 27110 27111 27160 27161 27162 27163 27164 27165 27166 27167 27168 27169 27170 -bits 27171 27172 27173 27174 27175 27224 27225 27226 27227 27228 27229 27230 27231 27232 27233 27234 -bits 27235 27236 27237 27238 27239 27265 27266 27393 27394 27521 27649 27650 27777 27778 27905 27906 -bits 28033 28161 28162 28289 28290 28417 28418 28545 28673 28674 28801 28802 28929 28930 29057 29208 -bits 29209 29210 29211 29212 29213 29214 29215 29216 29272 29273 29274 29275 29276 29277 29278 29279 -bits 29280 29335 29336 29337 29338 29339 29340 29341 29342 29343 29344 29399 29400 29401 29402 29403 -bits 29404 29405 29406 29407 29408 29463 29464 29465 29466 29467 29468 29469 29470 29471 29472 29527 -bits 29528 29529 29530 29531 29532 29533 29534 29535 29536 29591 29592 29593 29594 29595 29596 29597 -bits 29598 29599 29655 29656 29657 29658 29659 29660 29661 29662 29663 29697 29698 29825 29953 29954 -bits 30081 30209 30210 30337 30464 30528 30592 30656 30720 30784 30848 30976 31040 31104 31168 31232 -bits 31296 31360 31488 31552 31616 -pass 200 72 2 33 -state 00000000 00000000 43480000 42900000 00000004 00000014 0000003a 00000043 00000000 00000001 00000000 00000000 -primitive 00000002 00000000 00000001 3f800000 3e06051f bf823e39 3e580000 3f800000 3f99f948 bfa15e39 3e580000 3f800000 3f82e1ec bd3e5555 3e580000 3f800000 -primitive 00000002 00000000 00000002 3f800000 3ed3ee97 bf400b33 3e853333 3ee66666 3f747ae1 bfdd28e4 3f0e0000 3f800000 408b1f57 c1067aad 4050d100 409a8000 -primitive 00000001 00000000 00000003 3f800000 3db33ccd bf054fc7 3e78c000 3ea00000 be599e66 be78c8e3 3e78c000 3ea00000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 00000004 3f800000 43ebde9c 3da05eb8 3dee299a 3ed0cccd 3f043a22 3ea0dd73 3dee299a 3ed0cccd 3e5dd24b 3f12bf53 3dee299a 3ed0cccd -primitive ffffffff 00000000 00000005 3f800000 bf5b51ec c00358e4 3f6d0000 3f800000 3e948f5c bfaab9c7 bf380000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000006 4171a000 c03a1e5a c4bf26e4 3d600000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 00000007 3f800000 c3b4de66 c5137d39 3fda0000 3f800000 c3b5082f c5136eb7 3fda0000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000024 42664000 c09481b0 c02f1900 4012c700 40610000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000009 42026000 3f9ebae1 bfd561c7 3fb10000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 0000000a 3f800000 3f19a000 3de38e39 bf1b0000 3f800000 3f19a000 3de38e39 bf1b0000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 0000000b 3f800000 beda654f bf36091a 3c75b333 3eda6666 3f187de8 3cb2c6ef 3c75b333 3eda6666 3d5b4de7 bf166008 3c75b333 3eda6666 -primitive 00000000 00000000 0000000c 41c4e400 bd246666 3ff1c38e 3dd80000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 0000000d 3f800000 3e99ce14 bf33071c 3eea0000 3f800000 404f13ec 3ec5be00 00000000 401c0000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 00000024 3f800000 be8e8dbd be280900 3e313000 3e580000 bfa5699a bf5a271c 3f640000 3f800000 be8e489f be141100 3e313000 3e580000 -primitive 00000000 00000000 0000000f 424b8400 c28a6148 40d1b37c 3e3c0000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 00000010 3f800000 bef57c29 3eba4aab 3c800000 3f800000 be67ca3d 3f25fe39 3c800000 3f800000 00000000 00000000 00000000 00000000 -primitive ffffffff 00000000 00000011 3f800000 c0dd27bd 40dd10a5 3fa5d800 40dd2000 c0da8785 40eeb96c 3fa5d800 40dd2000 c0daf1a9 40cbca25 3fa5d800 40dd2000 -primitive 00000002 00000000 00000012 3f800000 3e8a599a bf7b48e4 3e380000 3f800000 3e19d648 bf14a119 3ef1d800 3f0e0000 3e853ae1 bf86b2ab 3e380000 3f800000 -primitive 00000000 00000002 00000013 429e3f00 3eb928f6 bfc85800 3eb60000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000014 419fc000 c4e377ae bf9a6cc6 3f750000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000015 41f2ec00 bf9a7ccd c005d239 3f7e0000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 00000016 3f800000 3e8f6148 3f800000 3f4c0000 3f800000 3ea2e666 3f6baaab 3f4c0000 3f800000 3e86570a 3f89d555 3f670000 3f800000 -primitive 00000002 00000000 00000017 3f800000 3f4e3d71 3d555555 3da80000 3f800000 be5b970a 3f93ed55 3f700000 3f800000 3e8f4ccd 3ff1d555 3da80000 3f800000 -primitive 00000002 00000000 00000018 3f800000 beb8570a 3ff1d1c7 3f460000 3f800000 bf6d49cf 407d0a03 3e840000 3f800000 3f5f0a3d 3ffea2ab 3e840000 3f800000 -primitive 00000000 00000000 00000019 41f84000 3f9606b8 3ee00aab 3eb20000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 0000001a 43ff8000 3f19a148 bf473555 3ca00000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 0000001b 3f800000 bfa8f852 bfd5571c 3f610000 3f800000 bf2e0e14 3de3e38e 3f610000 3f800000 bf9d2571 bcea0000 3ec40000 3f800000 -primitive 00000001 00000000 0000001c 3f800000 3f19947b 3f7fe71c 3e080000 3f800000 bf341fae 41085980 3ff54000 40900000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 0000001d 3f800000 bf2e15c3 3f800e39 3f730000 3f800000 bf70ca3d c0035f1c 3f780000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 0000001e 3f800000 3e25ee14 bdf69c72 be400000 3f800000 3fda439a bf88dc39 3f5c0000 3fb00000 3f2b9490 c51e9700 3e418000 3f900000 -primitive 00000000 00000000 0000001f 42518e00 3f4367ae bf61038e 3f2f0000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000022 41f64000 bfa8f666 bf470aab 3f240000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -expect 1 4 -bits 70 71 77 78 337 546 547 553 554 560 561 567 568 574 609 616 -bits 623 -pass 160 96 3 33 -state 42ada000 c1376000 435ad200 43045a00 00000000 00000000 000000a0 00000060 00000000 00000001 00000000 00000000 -primitive 00000000 00000000 00000021 42187e00 bfa91d60 c028be38 3c2e0000 402e0000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 00000002 3f800000 be4d0000 bfd55955 3f1d0000 3f800000 bf253000 c01a2600 3f1d0000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 00000003 3f800000 3f3a68cd 3eb1caab 3e440000 3f800000 3f3a68cd 3eb1caab 3e440000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 00000004 3f800000 41628bc0 4096fc82 40ed2ec0 41629000 3f4c2400 3e8cc2ab 3ec60000 3f800000 3f800266 3fd54aab 3f838000 3f800000 -primitive 00000002 00000000 00000005 3f800000 bf9c94b4 41231efb 3ef4b000 40c3c000 408ea837 418798ac 3ef4b000 40c3c000 40c3b770 c0c3bbec 3ef4b000 40c3c000 -primitive 00000000 00000000 00000006 42480a00 bf3405a0 c0610000 3f972c00 40610000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 00000007 3f800000 be7df000 3f045555 3f030000 3f800000 3fb330cd bfd55000 3f030000 3f800000 3f231b33 3f0946ab 3f030000 3f800000 -primitive 00000001 00000000 00000008 3f800000 3f70719a bfb902ab 3da00000 3f800000 3e4cf333 3f7ffaab 3da00000 3f800000 00000000 00000000 00000000 00000000 -primitive ffffffff 00000000 00000009 3f800000 bfb32f33 beaa8000 3edc0000 3f800000 be968333 3f797aab 3edc0000 3f800000 be08f99a 3e2f1555 3edc0000 3f800000 -primitive 00000001 00000000 0000000a 3f800000 be8cdccd 3e0d3555 3e540000 3f800000 3f60f8cd bfd92aab 3e540000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 0000000b 3f800000 3ffe5b90 c0fe218c 3ff25800 408d0000 3ef0019a bfeede00 3f790000 3f800000 3efa1b33 bfe988ab 3f3c0000 3f800000 -primitive 00000002 00000000 0000000c 3f800000 3f199ccd 3f800aab 3f180000 3f800000 bd95a67b bf1c07cd 3ea774cd 3ebb3333 be4cf99a bf800400 3e340000 3f800000 -primitive 00000000 00000000 0000000d 41ea9000 448410da c51bad84 428e5580 44cf0800 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 0000000e 3f800000 3f2a78cd bf9ef355 3f5d0000 3f800000 bf67c666 3d4c4000 3f640000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 0000000f 3f800000 3f445ec7 c10d4cdb 40be8a00 41524000 bf5a97c0 3dc8b500 800116c2 3f840000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 00000010 3f800000 3f3d38cd bf0662ab 3e9c0000 3f800000 bf1994cd bf800400 3f080000 3f800000 bf1a9e66 3fcc2955 3f080000 3f800000 -primitive 00000002 00000000 00000011 3f800000 4463786c c3cecb74 439d7880 441c4000 bf851ecd bfbfa600 3e8c0000 3f800000 bf199800 beaac000 3f250000 3f800000 -primitive 00000002 00000000 00000012 3f800000 3f3de266 3f04ceab 3f3e0000 3f800000 3f44a266 3f04f955 3f3e0000 3f800000 3f386f33 3eeb9d55 3e8a0000 3f800000 -primitive 00000001 00000000 00000013 3f800000 c15ee63f 4094b739 41b0c850 415ef000 3e4cf99a 3fd55c00 3f2c0000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000014 7fc00000 3f7ff333 3eaacaab 3f120000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000015 40be9000 7fc00000 bfc7e155 3efa0000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000016 42849000 bfb8d600 bf2efd55 3eca0000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000017 000116c2 c18b67f8 41b5ac81 411e8240 41524000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000018 43ffc000 3f199333 3f7ff555 3f908000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 00000019 3f800000 3f7ff800 bfd55000 3ebc0000 3f800000 3f78ab33 bfce5000 3ebc0000 3f800000 3f846f33 bfd4b000 3ebc0000 3f800000 -primitive 00000002 00000000 0000001a 3f800000 be5cd333 bc1daaab 3ed40000 3f800000 c11d58d2 c13b4854 40d394c0 40e0c000 444c465f 43aa30ba 44854d00 44185800 -primitive 00000000 00000000 0000001b 4282eb00 3f2b7000 bf125155 3f840000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 0000001c 41d7dc00 3f7ff333 beaa8000 3f410000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 0000001d 3f800000 bdf1f333 3f613155 3f500000 3f800000 bfb3359a 3fd54d55 3f500000 3f800000 3f5ff666 bf4c5c00 3f500000 3f800000 -primitive 00000001 00000000 0000001e 3f800000 bf7ffccd bfd552ab 3f250000 3f800000 3e48aa33 3ee8719a 3d23cccd 3e866666 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 0000001f 3f800000 44b8679b 40bebcd9 3e0f6000 3f940000 44b86956 40bd00d9 3e0f6000 3f940000 44b86886 40be03d9 3e0f6000 3f940000 -primitive 00000002 00000000 00000020 3f800000 c03943a3 c4bf4300 3f590000 3f800000 c03686d6 c4bf4088 bf310000 3f800000 c039206f c4bf40e8 3f590000 3f800000 -expect 5 8 -bits 104 218 223 224 233 234 239 244 249 254 268 269 403 404 438 439 -bits 464 -pass 200 72 4 33 -state 00000000 00000000 43480000 42900000 00000056 0000001c 00000004 0000000a 00000002 00000000 00000000 00000000 -primitive 00000001 00000000 00000001 3f800000 406d6d5a 41540a1c 3ff53280 41541000 3f26799a 4001d71c 3e0c0000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000002 42680e00 c47df88d c4a1c8e5 42d0bd80 44b98c00 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 00000003 3f800000 40bd4637 3f8c8245 40bdb7c0 411db000 c1aaa128 46a86ace 40bdb7c0 411db000 00000000 00000000 00000000 00000000 -primitive 00000000 00000001 00000022 00000000 be9fcbf1 3dc59f55 3f9c1800 3f5e0000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000005 7fc00000 bfade800 3fe3f0e4 3f5a0000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000006 423d9400 3f6b87ae bf9c6e39 3fc00000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000007 44160000 bd23d70a 3fb8e000 3e740000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000022 428a3200 3f8a1e14 3f31a71c 3e240000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 00000009 3f800000 bf4b7ae1 bfd802ab 3f020000 3f800000 bf7baa3d 3ea73555 3f020000 3f800000 3fa8851f 3dad1c72 3f020000 3f800000 -primitive 00000001 00000000 0000000a 3f800000 3e9e1523 40584f4e 3f2f0000 3f800000 3e1422a7 40cdce6a 3ff9d200 40190000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 0000000b 3f800000 c17a208b c1b689a6 4097a7c0 413e5000 c19c56b8 c13f5309 4097a7c0 413e5000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 0000000c 42399c00 c42ba2b8 4578f239 3eb80000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000003 00000000 0000000d 3f800000 bf55a5c3 bf7f6000 3f080000 3f800000 bf2e1333 bf47038e 3efe0000 3f800000 beb85eb8 3f0e3c72 3c800000 3f800000 -primitive 00000001 00000000 0000000e 3f800000 bf73f07b c04f8d80 f149f2ca 40990000 4465d61a 459072da 3da50000 3ff00000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 0000000f 42938800 bd2451ec bf9c6aab 3f040000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 00000021 3f800000 447d5bad 422f02aa 3f0cc800 3f540000 bf994c7b beac0e39 3f720000 3f800000 3f464ade bf8ad080 3f0cc800 3f540000 -primitive 00000002 00000000 00000011 3f800000 c2ec6320 c68bedf7 4049e400 406c0000 c31c08eb c6b8d732 403cc140 409be000 c1ce5f46 c5744987 3eeaf800 3f4e0000 -primitive 00000001 00000000 00000012 3f800000 bf2e25c3 3fb74555 3f180000 3f800000 bf2be5c3 3fba6555 3f180000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 00000013 3f800000 bd23851f bf47071c 3d900000 3f800000 bf2e11ec bf47071c 3f6b0000 3f800000 bf2e0b85 bf472e39 3d900000 3f800000 -primitive 00000001 00000000 00000014 3f800000 bfebcf18 40446f81 3edc0000 3f800000 bf57a14d 40b3fe02 3f2c0000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000002 00000001 00000015 3f800000 3f776a3d bf0b438e 3f530000 3f800000 becee571 c054418e 3ff78000 40300000 3e8f47ae bf9c671c 3f530000 3f800000 -primitive 00000002 00000000 00000016 3f800000 bfa8f8f6 3f0e4e39 3dd00000 3f800000 bf43899a bf4721c7 3dd00000 3f800000 3f4f651f bf3b1e39 3dd00000 3f800000 -primitive 00000002 00000000 00000017 3f800000 3e8f5eb8 3f0e4e39 3e860000 3f800000 3e8f599a bf471555 3e860000 3f800000 bf800148 3fb8daab 3e860000 3f800000 -primitive 00000001 00000000 00000018 3f800000 3f5fc333 3fafd1c7 3f370000 3f800000 3f42670a 3fd898e4 3e440000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 00000019 3f800000 bf04b99a bfb7e472 3f4d0000 3f800000 be9d91ec bf59f38e 3f4d0000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 0000001a 3f800000 bf8e9e14 3f31b38e 3f0a0000 3f800000 bf4e67ae 3fc65639 3f0a0000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 0000001b 3f800000 3f26762c bf6e7c19 3d7c7333 3ef4cccd 3e091415 3d58db33 3d7c7333 3ef4cccd 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 00000024 3f800000 c4839e63 c3964b35 4450bd80 44b98c00 c4c696ea 449474e5 4450bd80 44b98c00 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 0000001d 3f800000 3f9eb47b bf4711c7 3f510000 3f800000 3e8f68f6 3de471c7 3f510000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 0000001e 3f800000 bf96c8f6 bd9371c7 3f340000 3f800000 beb85c29 bf9c68e4 3f340000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 0000001f 42747400 3f6b8b85 bf47271c bee40000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000020 41eb8400 bfa8f7ae bf470aab 3f530000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -expect 1 7 -bits 254 261 324 331 814 821 -pass 96 64 3 33 -state 00000000 00000000 42c00000 42800000 00000000 00000000 00000060 00000040 00000002 00000000 00000001 00000000 -primitive 00000001 00000000 00000001 3f800000 c39a38ab c0a10408 3f4d0000 3f800000 c1ba973c 422ddc8a 40c65b00 413ab000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 00000002 3f800000 bfd55400 3f7ffc00 3ffe0000 3f800000 bfd67eab 3f693c00 3f930000 3f800000 bfd6f400 3f76fc00 3ffe0000 3f800000 -primitive 00000001 00000000 00000003 3f800000 3f99b8ab bd8a0000 3e380000 3f800000 bfd55c00 bffff200 3e380000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 00000024 3f800000 c0aba2fc c0659fec 4097a100 40ab0000 c13b7e7e c0e5dbaa 413bb160 41476000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 00000005 3f800000 bfd55155 bf800a00 3eb20000 3f800000 bfd13c00 bf83ea00 3eb20000 3f800000 bfce1155 bf898a00 3eb20000 3f800000 -primitive 00000002 00000000 00000006 3f800000 3e0deaab c0042d00 3f270000 3f800000 3dc88000 c003ed00 3f270000 3f800000 3e059555 c0000d00 3f270000 3f800000 -primitive 00000001 00000000 00000007 3f800000 c0eba8d6 c10d66a0 40352300 408d6000 408d58a3 c08d6000 40352300 408d6000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000008 4289f900 404b32c0 3ae46000 3f34cc00 41184000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 00000009 3f800000 3f6bfeab bfb1b500 3e8e0000 3f800000 bf915a00 bef45c00 3e8e0000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 0000000a 42327400 409f2103 c1394a29 40df2660 40b8e000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 0000000b 3f800000 c1354d37 41352c2d 41326b00 41354000 c129f938 4124ccc5 41326b00 41354000 c139ba07 413fe195 41326b00 41354000 -primitive 00000000 00000000 0000000c 422a1c00 c0189ad4 c0bb1c6d c03fe800 40858000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 0000000d 3f800000 c4c009de c4665ecb 44418ec8 44667800 bfc880ab 3fc80000 3fb48000 3f800000 bfd552ab 3ffffa00 3fb48000 3f800000 -primitive 00000001 00000000 0000000e 3f800000 452d5eeb c4cdaac0 3e8a0000 3f800000 c15e7e9f c609665b 40b78400 40580000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 0000000f 3f800000 bebfb555 bf92ef00 3f440000 3f800000 bea80aab bf893f00 3f440000 3f800000 beca8aab bf9fff00 3f440000 800116c2 -primitive 00000000 00000000 00000010 41e02800 3fd55d55 40000600 3f540000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000011 425b6400 4173ae28 c1bf26c9 4062ec00 409a8000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000012 425b8600 3ec9822d 3f46dd75 be39499a 3f126666 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 00000013 3f800000 3e281500 bf7c0fc0 3e9f7800 3efc0000 c084d1bf 41c76ae7 40dd2e80 41476000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 00000014 3f800000 bec2faab 3fba6c00 3f000000 3f800000 bed92555 3fb03c00 3f000000 3f800000 becd7aab 3fac3c00 3efe0000 3f800000 -primitive 00000002 00000000 00000015 3f800000 bfd54aab b9400000 3e400000 3f800000 c46c57e8 4162de20 4383d600 440ca000 bfd5eaab 3d674000 3e400000 3f800000 -primitive 00000001 00000000 00000016 3f800000 3fd54eab 3f800e00 3f130000 3f800000 3fab66ab 3f026400 3efe0000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 00000017 3f800000 3e5a2000 3faa6b00 3f4b0000 3f800000 beaa8aab 39000000 3f4b0000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 00000018 3f800000 3e9bfe0d 3e3b44c0 3e8bab33 3e3b3333 3fd55800 3ffffc00 be8a0000 3f800000 3fc78cab 3f3ede00 be8a0000 3f800000 -primitive 00000002 00000000 00000019 3f800000 bd720000 bf6aa800 3f030000 3f800000 3fd55d55 bffff000 3f030000 3f800000 ff800000 c002dd00 3f030000 3f800000 -primitive 00000000 00000000 0000001a 42268c00 c435c860 3fa3d979 3e828000 3e900000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 0000001b 3f800000 3e97ff0d 3eb664fa 3b88cccd 3e366666 3e9794a7 3eb262fa 3b88cccd 3e366666 3fd68955 4005b700 3f330000 3f800000 -primitive ffffffff 00000000 0000001c 3f800000 4577bf95 45ad9110 3fec0000 3f800000 bee48800 40066800 3f530000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 0000001d 40cd6000 3f7ff800 bf7ff400 3eee0000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 0000001e 3f800000 c4ce5ad0 3fcc1ae1 3eef4000 3f040000 be300000 3f040e70 3eef4000 3f040000 3ca24000 bf412fa8 3eef4000 3f040000 -primitive 00000000 00000000 0000001f 4139c800 bf7ff555 bffffa00 3f4b0000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 00000020 3f800000 3f55faa6 bf806e6d 3e50a666 3f006666 3f006fc3 bf805e60 3e50a666 3f006666 00000000 00000000 00000000 00000000 -expect 0 3 -bits 3 22 23 47 48 49 50 51 52 53 57 58 75 76 109 110 -bits 115 118 138 139 141 142 179 180 181 183 184 -pass 256 40 1 33 -state 00000000 00000000 43800000 42200000 000000a6 00000022 00000073 0000001e 00000002 00000001 00000000 00000000 -primitive 00000001 00000000 00000001 3f800000 bea73300 3f1bf000 3f070000 3f800000 3f022e00 3f554666 3e400000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 00000002 3f800000 40520690 c0e71501 3ffff000 40520000 3f816000 c00c4ccd 3fa68000 3f800000 3f80b800 c010c000 3fa68000 3f800000 -primitive 00000001 00000000 00000003 3f800000 bf373d00 c0387000 3e9c0000 3f800000 3f9fff80 bf198ccd 3ef20000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000023 bf800000 beb98200 bf795ccd 3f3f0000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 00000005 3f800000 3e7ff800 c00cd333 3efa0000 3f800000 3e763800 c0052000 3f0d0000 3f800000 3e6c1800 c0050666 3efa0000 3f800000 -primitive 00000001 00000000 00000006 3f800000 c06a8100 beb82000 3ff48000 40400000 c06fd900 3e32f334 3ff48000 40400000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 00000024 3f800000 3e7a9c00 c0b5d99a 3fbb0000 40000000 be2d7000 c08d0400 3fbb0000 40000000 40200300 40a66b33 3fbb0000 40000000 -primitive 00000000 00000000 00000008 00000000 bf6e8000 bf76fccd 3f0a0000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 00000009 3f800000 3f11b7d4 c0374ead 3f6eb000 3fe40000 3f795080 3eb42000 3f650000 3f800000 bed96c00 3f9ea19a 3f110000 3f800000 -primitive 00000000 00000000 0000000a 3e800000 38800000 4026599a 3e940000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 0000000b 3f800000 3fa5e800 c03db666 00000000 3f800000 b8c00000 bf19b333 3e920000 3f800000 3e800800 40266e66 3e920000 3f800000 -primitive 00000002 00000000 0000000c 3f800000 bf9ffe80 bf199333 3f010000 3f800000 3ea07d00 3f897e66 3f010000 3f800000 bf8a96c0 bf9d3333 3d500000 3f800000 -primitive 00000002 00000000 0000000d 3f800000 be493e00 4000fa66 3f670000 3f800000 be625e00 400760cd 3f670000 3f800000 be301e00 3fee5b33 3f670000 3f800000 -primitive 00000001 00000000 0000000e 3f800000 c3aac880 c0f09bc0 3f380000 3f800000 c316de80 c10fb98c bf520000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 0000000f 3f800000 3ebfa900 3fff7666 3e9e0000 3f800000 3ecd6900 400b3b33 3fe58000 3f800000 3ebe4900 3ff91000 3ef20000 3f800000 -primitive 00000002 00000000 00000010 3f800000 be800e00 40265e66 3f310000 3f800000 be81be00 4028519a 3f110000 3f800000 be86de00 4022c4cd 3e9e0000 3f800000 -primitive ffffffff 00000000 00000011 3f800000 3e7b7800 c02a519a 3f720000 3f800000 be90d200 be84b99a 3e240000 3f800000 3e8a2800 3e9d5333 3e240000 3f800000 -primitive 00000002 00000000 00000012 3f800000 bf800180 c00cc99a 3e900000 3f800000 bf810180 c011099a 3f390000 3f800000 bf7a8b00 c015f000 3f390000 3f800000 -primitive 00000001 00000000 00000013 3f800000 bd9b7000 bfea219a 3e100000 3f800000 bd9b7000 bfea219a 3eea0000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 00000014 3f800000 c540a04c 3f951660 4068ce00 40670000 c5409f99 3fd6c72d 4068ce00 40670000 c540a082 3f87bb93 4068ce00 40670000 -primitive 00000000 00000000 00000015 424a7200 bf81f8e4 bf9bec80 3d430000 40020000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 00000016 3f800000 bf90e800 c030bccd bd400000 3f800000 bf802b00 c0664ccd bd400000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000017 42273800 3f2d2a80 401c4666 3f1f0000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 00000018 3f800000 be5c0dc0 bff1ef80 3e9fd800 3f5c0000 bf5bfad8 3f5c0aff 3e9fd800 3f5c0000 3f8f1cc0 3fdaa4cd 3f550000 3f800000 -primitive 00000003 00000000 00000019 3f800000 becacb00 3fc4a333 3f170000 3f800000 bf9ffe80 4026619a be180000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 0000001a 3f800000 bd29c800 bf05fccd 3e0c0000 3f800000 bdc9a400 be22599a 3e0c0000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 0000001b 3f800000 448cda4a c50f90bc 43e50100 445ac000 bfab5efa 455e6f9a 3dc00000 3f800000 be2a9b80 3ee018d9 3ea79400 3e840000 -primitive 00000001 00000000 0000001c 3f800000 bf800300 bf199333 3f5a0000 3f800000 bd05a800 bea1999a 3f5a0000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 0000001d 3f800000 c4e901ea c5834bcb 441da760 44f03c00 c4e540fa c5852040 441da760 44f03c00 bf7ac480 c00a0333 3f590000 3f800000 -primitive 00000002 00000000 0000001e 3f800000 3e8cf600 4015ec00 3f640000 3f800000 be8663c6 3e86707b 3dcdcccd 3e866666 bfa00400 bf19b99a 3e8e0000 3f800000 -primitive 00000000 00000000 0000001f 41884000 40df24e2 c144604c 3ffb0400 40b28000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 00000024 3f800000 bf9ce400 3fc26000 3f010000 3f800000 bfa00000 40266000 3f010000 3f800000 be5cbf00 be84543e 3eb0d000 3edccccd -expect 4 4 -bits 63 157 158 445 446 447 -pass 160 96 3 33 -state 42f7fb00 4143a000 421dd400 c2f10100 00000029 00000000 00000003 00000009 00000001 00000001 00000000 00000000 -primitive 00000001 00000000 00000001 3f800000 bf9ee466 bf52ceab 3ed60000 3f800000 3fb33666 3f7ffd55 3f1f0000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 00000002 3f800000 3f19a666 beaa9aab 3ea80000 3f800000 3f138ccd be9a1aab 3ea80000 3f800000 3f1d4000 bec61aab 3ea80000 3f800000 -primitive 00000002 00000000 00000003 3f800000 beff60b8 bdf32400 3e77f333 3eb66666 be9f0bac bf04fd27 3e77f333 3eb66666 3e5aecaf bdf314cc 3e77f333 3eb66666 -primitive 00000000 00000000 00000022 3e800000 bfb3359a beaaa555 3eec0000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 00000005 3f800000 3f956ccd bfe5c0ab 3f510000 3f800000 bf7ff333 bf800555 3f510000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000006 41b71400 bf7b2333 bfb7e000 bf4c0000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 00000007 3f800000 bf80059a 3fd54c00 bf790000 3f800000 bfbfd8cd 3fcf8c00 3efa0000 3f800000 3f8000cd 3f7ff800 3efa0000 3f800000 -primitive 00000000 00000000 00000008 42bc5000 bf800666 bf7ff800 3e340000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000009 bf800000 3e4caccd bfd55eab 3e640000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 0000000a 3f800000 3fb32ccd 3fd54c00 3fc68000 3f800000 bf646a66 bf836555 3fc68000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 0000000b 3f800000 bfb33666 3eaab555 3e400000 3f800000 bf342b5a 3e57ffb3 3dbc0666 3f02cccd bfb31000 3e9a6000 3f360000 3f800000 -primitive 00000002 00000000 0000000c 3f800000 3f8004cd bfd55955 3ee60000 3f800000 bf199e66 3f7feaab 3ee60000 3f800000 bf199333 beaa9000 3ee60000 3f800000 -primitive 00000002 00000000 0000000d 3f800000 bebe6074 3ee2b496 3e56a000 3e880000 bfb1e733 3fdce955 3f310000 3f800000 c176854a 41931a83 40c71040 41337000 -primitive 00000001 00000000 0000000e 3f800000 3eee5b33 bf8dc8ab 3f350000 3f800000 3eee5b33 bf8dc8ab 3f350000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 0000000f 3f800000 bf630c00 bf9b8200 3f878000 3f800000 bf5bcc00 bf9c6cab 3f878000 3f800000 bf627f33 bf9ca200 3f878000 3f800000 -primitive 00000000 00000000 00000010 4226c000 3f199333 beaa9000 3f790000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 00000011 3f800000 3f7ff4cd 3fd55155 3ed20000 3f800000 3d942666 3eff92ab 3ed20000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 00000012 3f800000 3ea68666 3fb0b800 3f470000 3f800000 3e8f2000 3fb802ab 3e5c0000 3f800000 3ebb5333 3fa9ad55 3f470000 3f800000 -primitive 00000001 00000000 00000013 3f800000 c039fc83 bf77e8c0 402da600 403a0000 c03ed3bc bf8c1720 402da600 403a0000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 00000014 3f800000 3f83accd 3fe45000 3e8a0000 3f800000 be4ca666 3fd55155 3e8a0000 3f800000 bfb90800 bfa69f55 3e8a0000 3f800000 -primitive 00000002 00000000 00000015 3f800000 bf26fc00 bfc28200 3f190000 3f800000 bec09e1b 44ee4c55 3f190000 3f800000 3d3cf333 bd01aaab 3f190000 3f800000 -primitive 00000002 00000000 00000016 3f800000 bfb32d9a bfd54d55 3f240000 3f800000 bf9bc2cd bfd300ab 3f240000 3f800000 44a07e1a c57d4ac0 3f240000 3f800000 -primitive 00000001 00000000 00000017 3f800000 be232d14 be233f19 3db50ccd 3e233333 c4494a66 c5296255 3f7a0000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 00000018 3f800000 3e707000 3fa99955 3f6a0000 3f800000 be8ce99a 3fde6155 3f330000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 00000019 3f800000 c048f98c c3969d55 3fb48000 bf800000 bf7da0f9 c301bc00 3ff60000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 0000001a 3f800000 3e8a319a 3f45fc00 3ef40000 3f800000 3f622266 3f676400 3eb00000 3f800000 c0b5e564 c0a486c3 40893640 4138e000 -primitive 00000000 00000000 0000001b 3ea80000 3f6bca66 3f8cccab be040000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 0000001c 3f800000 c0e02c80 40561ce0 3fd8f000 409c0000 c4984a92 43ff4f55 439191a0 444f0800 c0e17be6 406eb0e0 3fd8f000 409c0000 -primitive 00000001 00000000 0000001d 3f800000 be4ca666 3fd54c00 3f690000 3f800000 3f871f33 be07aaab 3f6d0000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 0000001e 3f800000 c4ca8433 44a98f00 3ee60000 3f800000 c4ca84c5 44a98d05 3ee60000 3f800000 c4ca8452 44a99105 3ee60000 3f800000 -primitive 00000002 00000000 0000001f 3f800000 3f503400 3fa29400 3e2c0000 3f800000 3e667999 3e002000 3efcc000 3ec00000 bed34499 bea5fe00 3efcc000 3ec00000 -primitive 00000001 00000000 00000020 3f800000 3eee8d3b 3f0e0470 3e8e719a 3eaa6666 3f0414af 3f235be3 3e8e719a 3eaa6666 00000000 00000000 00000000 00000000 -expect 2 4 -pass 96 64 2 33 -state 00000000 00000000 42c00000 42800000 00000000 00000000 00000060 00000040 00000000 00000001 00000001 00000000 -state 00000000 00000000 42c00000 42800000 00000000 00000000 00000060 00000040 00000001 00000001 00000000 00000000 -state 00000000 00000000 42c00000 42800000 00000000 00000000 00000060 00000040 00000001 00000000 00000000 00000000 -primitive 00000000 00000001 00000001 429eda00 bfd55aab bffff800 3f0c0000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 00000002 3f800000 bd51eaab 3fac6800 3ce00000 3f800000 bf6ef555 bfc60700 3ce00000 3f800000 beaa9aab bf7ff000 3ce00000 3f800000 -primitive 00000000 00000001 00000003 420f0c00 bf7ffaab b9a00000 3d400000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000001 00000004 3f800000 bf9a2e00 bf69a000 3ed00000 3f800000 bfa178ab bf4bc000 3ed00000 3f800000 bf9d0355 bf680000 3ed00000 3f800000 -primitive 00000000 00000002 00000005 7f800000 be835555 3fe04b00 bea40000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000006 42373c00 443dcfcc c2a43616 43b313c0 440ca000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 00000007 3f800000 bfa430ab bfe49600 3e180000 3f800000 bfa16600 bfed6600 3e180000 3f800000 bfa98600 bfdaf600 3e180000 3f800000 -primitive 00000000 00000002 00000008 420f4200 3ec8dbd2 42b00c00 3ee60000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000001 00000002 00000009 3f800000 bf0e7aab bf613600 3df80000 3f800000 bf0e7aab bf613600 3f400000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000000 00000001 0000000a 425c5400 44c264e4 44b6014b 42b00680 44c92c00 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000001 00000001 0000000b 3f800000 3f7fed55 3f800a00 3f700000 3f800000 44c1fa80 c50f0a00 3ee00000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000000 00000002 0000000c 42499e00 3f724048 bf4f0722 3e750666 3f113333 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000002 0000000d 3f800000 3fde9eab bf2fce00 3f760000 3f800000 beaabaab 3ffff000 3f760000 3f800000 bfd55555 bffffc00 3f760000 3f800000 -primitive 00000000 00000002 0000000e 42160c00 beaa8aab b8800000 3ed20000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 0000000f 3f800000 44e7de55 405d4f3b 3f620000 3f800000 44e7de55 405d4f3b 3f620000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000001 00000002 00000010 3f800000 bfa44aab 3f463800 3f2a0000 3f800000 c00c29c8 40706918 3f15a000 3ffc0000 00000000 00000000 00000000 00000000 -primitive 00000001 00000001 00000011 3f800000 c19b9880 413ab8c0 419e3f30 413ab000 c19b9880 413ab8c0 419e3f30 413ab000 00000000 00000000 00000000 00000000 -primitive 00000001 00000001 00000023 3f800000 be8bfd60 bea80690 3e088000 3e280000 400d9f6e c4e27a99 3f707e00 3f3a0000 00000000 00000000 00000000 00000000 -primitive 00000000 00000001 00000013 43ffc000 3eaab555 bf800c00 3f010000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000002 00000014 3f800000 434c14ca c4bb982c 439d3a00 445ac000 3e622aab bfe26a00 3d800000 3f800000 3e5a2aab bfdc9a00 3ec80000 3f800000 -primitive 00000002 00000002 00000015 3f800000 bfda5b55 3f3dc600 3f5b0000 3f800000 bfd54600 3f202600 3f5b0000 3f800000 bfd210ab 3f394600 3f5b0000 3f800000 -primitive 00000001 00000000 00000016 3f800000 3f974555 40082a00 3ed80000 3f800000 3f80faab 3feee400 3ed80000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000002 00000001 00000017 3f800000 3f8a7ecb bdd66640 3e98e400 3f3e0000 3fad0980 be2df180 3f14a000 3f680000 3fb03000 f149f2ca 3e8a0000 3f800000 -primitive 00000001 00000000 00000018 3f800000 800116c2 c0000000 3d800000 3f800000 3e42a495 bf91f928 3ecb0800 3f120000 00000000 00000000 00000000 00000000 -primitive 00000000 00000001 00000019 429a2a00 3fc17c00 bed00c00 3f090000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000001 00000002 0000001a 3f800000 3eaab555 3f800400 7149f2ca 3f800000 bf2712ab bf469200 3ef20000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000001 00000001 0000001b 3f800000 3fa20510 c0730f30 400a9600 40730000 c0da8686 c074c5ba 400a9600 40730000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 0000001c 420b4600 40f273e0 b9918000 3f55b400 40918000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000002 0000001d 3f800000 c0dc6e34 bebf2980 4058a680 40a32000 3fd9a1fc c0a315ce 4058a680 40a32000 c0960690 c03410e0 4031e400 40340000 -primitive 00000001 00000002 0000001e 3f800000 449a4a64 bee77200 43ff8de0 449a4c00 3eaaa555 bffff600 3e0c0000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 0000001f 41997800 3f3b7555 bf54f000 bf520000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000002 00000020 3f800000 bf3f92ab 3fb80000 bf260000 3f800000 bf30fd55 3fb65000 bf260000 3f800000 bf2b2800 3faa5000 bf260000 3f800000 -expect 2 6 -bits 9 12 13 15 16 18 21 38 41 57 62 68 78 79 80 81 -bits 82 83 84 85 87 88 114 115 116 117 118 119 152 155 159 165 -bits 166 167 182 185 191 -pass 256 40 4 33 -state c14c2800 41d0d400 42af3100 423faa00 000000c4 0000000b 00000102 00000011 00000002 00000001 00000001 00000000 -state 00000000 00000000 43800000 42200000 00000000 00000000 00000100 00000028 00000000 00000001 00000001 00000000 -primitive 00000002 00000000 00000001 3f800000 38c00000 bfb34ccd 3f430000 3f800000 c48d34b0 40fa7f7d 3f430000 3f800000 3f400500 3f7ff99a 3ee20000 3f800000 -primitive 00000001 00000001 00000002 3f800000 c160c625 4034103a 3e289000 4160c000 bf878b80 be348000 3fea8000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000002 00000001 00000003 3f800000 3f95ff00 4004e733 3c000000 3f800000 3ed00340 3ed00a66 be4cc000 3ed00000 3f800100 bfb32333 3f120000 3f800000 -primitive 00000000 00000000 00000004 41a3b800 3e079000 bf89a99a 3c800000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 00000005 3f800000 3ef3f490 bf1278b3 3ecbf800 3f740000 3ef9cb10 bf0bfd80 3ecbf800 3f740000 3ef6f400 bf35accd 3e300000 3f800000 -primitive 00000001 00000001 00000006 3f800000 bf305a80 3fae6000 3f7c0000 3f800000 3f306d00 3c00cccd 3f7c0000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000007 43ffc000 3ecdcb70 3ed39400 3d4d0000 3ea00000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000001 00000001 00000008 3f800000 3f8ba500 3fefc333 bf120000 3f800000 40df1d36 c056450c 3eea4800 40b28000 00000000 00000000 00000000 00000000 -primitive 00000002 00000001 00000009 3f800000 3f45bf80 c016c333 be980000 3f800000 40499c3e c11ad41d bfc3c000 40828000 3e998843 bf6c2e2e 3e8d9e66 3ec73333 -primitive 00000002 00000001 0000000a 3f800000 bf324900 40278f33 3ea40000 3f800000 bf366100 4032b59a bf790000 3f800000 bf399900 40284f33 3ea40000 3f800000 -primitive 00000000 00000001 0000000b 42146400 3f400700 3e4d999a 3f1a0000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000001 0000000c 3fc2c000 3f7ffb00 3e4d0000 3e580000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000001 0000000d 3f800000 4129f14f c10817a6 41b2c5a0 41629000 c1fbe772 478c27b7 41b2c5a0 41629000 c0bb4967 40f47091 41b2c5a0 41629000 -primitive 00000002 00000001 0000000e 3f800000 bf4e2000 bfe554cd 3f7f0000 3f800000 3eba88f6 c0bbfefa 3f7f0000 3f800000 c01f9fde bd108667 401d9800 40240000 -primitive 00000002 00000001 0000000f 3f800000 3f935d80 bf7a0000 3e900000 3f800000 40c5ab5f c08f9eed 40de4940 40aa6000 3f92bd80 bf73cccd 3d800000 3f800000 -primitive ffffffff 00000000 00000010 3f800000 bf133c00 c008f733 3f1a0000 3f800000 bfd862b8 c0cbdccf 3e607000 403d0000 bfe2d058 c0c1ac9b 3e607000 403d0000 -primitive 00000003 00000001 00000011 3f800000 3f1e8780 c01c04cd 3f5c0000 3f800000 3f1e8780 c01c04cd 3ec20000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 00000012 3f800000 3f570e00 3f99399a 3eae0000 3f800000 3f570e00 3f99399a 3e960000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 00000013 3f800000 bf3a6080 bf33799a 3f3c0000 3f800000 bf3a6080 bf33799a 3f3c0000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000001 00000002 00000014 3f800000 be19e37a 3e3d50a4 3e2e099a 3e49999a 3f3ffa00 bfb34333 3f150000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000015 3f800000 3e801000 bf196ccd 3fd68000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000002 00000016 3f800000 be7fe400 3fe66666 3f740000 3f800000 3fa00300 bf19c666 3f740000 3f800000 3f400100 bfb3399a 3f740000 3f800000 -primitive 00000000 00000000 00000017 3f1b0000 bfa55aa0 c5ebdf80 3d100000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000001 00000001 00000018 3f800000 bf7ff800 bfb3399a 3ea00000 3f800000 3dcf5800 c0190a66 3f710000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000002 00000001 00000022 3f800000 be61f568 3e342e9a 3f243400 3f620000 be723400 3d6d3333 3faf0000 3f800000 be57eaa8 3e659e9a 3f243400 3f620000 -primitive 00000000 00000001 0000001a 80000000 c7f9dfb6 45a961b9 43ffe3d0 44185800 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 0000001b 3f800000 3e29e681 3fba98c3 3d961333 3ed0cccd c36eb71c 3f7b62d5 3d961333 3ed0cccd bdedfa4b beb54869 3d961333 3ed0cccd -primitive 00000002 00000001 0000001c 3f800000 be3dac00 bfe02e66 3e100000 3f800000 be5acc00 bfde2e66 3f420000 3f800000 be426c00 bfd7e19a 3f420000 3f800000 -primitive 00000002 00000000 0000001d 3f800000 bf9b0080 c0034733 3f370000 3f800000 bf8154da bfe0e1ec bf800000 3f540000 bef21584 bf49536c 3e09d000 3ec40000 -primitive 00000002 00000000 0000001e 3f800000 3f3ffd00 3e4ccccd 3d700000 3f800000 3f400800 3fe65ccd 3d700000 3f800000 3f635f80 bf2f199a 3d700000 3f800000 -primitive 00000002 00000001 00000024 3f800000 3e800200 bf19c666 3f690000 3f800000 3efff000 3e4c8000 3f590000 3f800000 bf420a80 c01d0f33 3f690000 3f800000 -primitive 00000001 00000001 00000020 3f800000 40146438 4029faa0 3ce70000 40670000 c0be57ee 3fcb0000 402e7400 40fdc000 00000000 00000000 00000000 00000000 -expect 0 6 -bits 3 11 12 13 19 20 21 48 56 146 147 148 149 150 157 158 -bits 270 271 278 279 286 287 295 303 314 315 316 317 318 323 324 325 -bits 326 327 334 335 344 352 353 768 769 770 771 772 773 774 776 777 -pass 96 64 4 33 -state 00000000 00000000 42c00000 42800000 00000000 00000000 00000060 00000040 00000001 00000001 00000000 00000000 -state 42882c00 42560000 42312200 421d1c00 00000000 00000000 00000060 00000040 00000002 00000001 00000001 00000000 -state 41854800 4092e000 423a9000 420a7200 00000064 00000035 00000051 00000007 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000001 41397000 bfdc0420 bf841080 3f389800 3f840000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 00000002 3f800000 bf8111e0 bf308c80 3f7a2000 402e0000 be1b8aab bf625400 3ef40000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000003 42962400 bf800000 bfbff600 3efe0000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000002 00000004 43ff8000 bf7ff800 bf800c00 3f610000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000005 4053e000 c4823897 c41c33cb 440e3640 441c4000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000001 00000006 3f800000 3f3cb7a5 befc46d2 3ec7d400 3ed0cccd bf5f7000 be80c000 3f620000 3f800000 bf438d55 3f9ab300 3f060000 3f800000 -primitive 00000000 00000000 00000007 417fb000 3f21b455 bf56b0c0 3ee86000 3f500000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000002 00000008 3f800000 3f800aab 3f000c00 3ed60000 3f800000 3eaa9000 3f800200 3ed60000 3f800000 3eaabaab beffe000 3ed60000 3f800000 -primitive 00000002 00000002 00000009 3f800000 c018e4a0 bf1b5be0 3fbab800 3fc80000 c026abb6 bfc7f380 3fbab800 3fc80000 bfad8d2a 3f784da0 3fbab800 3fc80000 -primitive 00000001 00000002 0000000a 3f800000 be64e000 3f947300 3eb60000 3f800000 bf7ffd55 bfbffa00 3eb60000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000002 00000001 0000000b 3f800000 bf7ff555 3effe800 3e900000 3f800000 bf6f7555 3edf2800 3e900000 3f800000 bf87baab 3f165400 3e900000 3f800000 -primitive 00000002 00000000 0000000c 3f800000 bf69ec80 3eea1d40 3e491800 3f6a0000 ff800000 3f10d260 3e491800 3f6a0000 bf6d6d80 3ec1aac0 3e491800 3f6a0000 -primitive 00000002 00000001 0000000d 3f800000 bfbff200 bfc00300 3f610000 3fc00000 bfbcc200 bfc40b00 3f610000 3fc00000 bfbb1200 bfce4300 3f610000 3fc00000 -primitive 00000002 00000000 0000000e 3f800000 c0c14f4b c067ea40 40110000 40680000 bf9ac7ab 406815c0 40110000 40680000 bed5a600 40bcb660 40110000 40680000 -primitive 00000001 00000000 0000000f 3f800000 c04017f5 c07425b0 3fe53000 40180000 3ea97aab 3d28c000 3f430000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000000 00000001 00000010 43ffc000 3f800800 beffe800 3f370000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 00000011 3f800000 c0287870 c0bd3288 40b0b800 41110000 c03127c6 c0a7f508 40b0b800 41110000 c02029c6 c0d20348 40b0b800 41110000 -primitive 00000000 00000001 00000012 42466000 bfe6a755 bff9ef00 3ff40000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000002 00000013 3f800000 be833000 c0078d00 3f0a0000 3f800000 3ebb2c60 c088a656 3f0a0000 3f800000 3eaa9555 bfc00800 3f0a0000 3f800000 -primitive 00000001 00000001 00000014 3f800000 3ef0ca80 bf7d4580 3e4a8000 3ef00000 c549cb19 44723792 43ae1280 44f23000 00000000 00000000 00000000 00000000 -primitive 00000001 00000001 00000015 3f800000 3eaa8aab bf7fec00 3d200000 3f800000 beb06000 bf625a00 3f5f0000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000002 00000002 00000016 3f800000 bfb0c355 bfd5db00 3e6c0000 3f800000 bfb14e00 bfddbb00 3f670000 3f800000 bfac8e00 bfe16b00 3e6c0000 3f800000 -primitive 00000001 00000002 00000017 3f800000 3db9ab00 3e0b21cd 3db02ccd 3e8b3333 436fabcc 43b3998a 43287500 4433b000 00000000 00000000 00000000 00000000 -primitive 00000000 00000002 00000018 000116c2 c116aa00 c014a658 408ebc00 40ae0000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 00000019 3f800000 3f90c4ab 3f311200 3ed40000 3f800000 3fb750ab 3fede800 3ed40000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000002 00000004 0000001a 3f800000 c03a0ba0 403a0ba0 40109600 403a0000 bf7a1000 3f68b000 3eee0000 3f800000 c02cf7a0 4043ac20 40109600 403a0000 -primitive 00000002 00000000 0000001b 3f800000 3f0fad40 bf22e8b0 3e214000 3ef00000 3f093b40 bf1541b0 3e214000 3ef00000 3f9ae155 bfb81500 3fa28000 3f800000 -primitive 00000002 00000002 0000001c 3f800000 c52c8483 451b4fb4 441e8220 44cf0800 4449d114 c53222ad 441e8220 44cf0800 7149f2ca 45142540 3d700000 3f800000 -primitive 00000001 00000000 0000001d 3f800000 3fb720ab 3de40000 3eee0000 3f800000 3fb720ab 3de40000 3eee0000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 00000022 3f800000 c54b2f00 45bd3ea0 3fe40000 3f800000 c54b2f00 45bd3ea0 3f000000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000000 00000001 0000001f 41a25c00 3f2ac150 3f7fbb98 3e78a000 3f1c0000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 00000020 3f800000 c5279f6e c4494526 4535eb4a 44c92c00 ca7214ba c9147f33 4535eb4a 44c92c00 45285f2c 4541a527 4535eb4a 44c92c00 -expect 2 7 -bits 30 31 34 42 43 45 46 95 143 184 185 187 189 190 203 -pass 96 64 4 33 -state 00000000 00000000 42c00000 42800000 00000000 00000000 00000060 00000040 00000002 00000000 00000001 00000000 -primitive 00000001 00000000 00000001 3f800000 bf8b2d55 3f132200 3f480000 3f800000 be9c9300 3e258640 3e1fc000 3e900000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000002 3e800000 bfd54c00 bfc00c00 3fec0000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 00000003 3f800000 3fcbee14 c5713840 bed00000 3f800000 3fdeee14 c5713bd0 bed00000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000004 42936700 3e9e8555 3de8b000 3e960000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 00000005 3f800000 4089d9d4 c14e998b 413e7b80 414ea000 3fa24040 c07954f0 3f4ab000 408d0000 3ecc4aab bf60b800 3f7b0000 3f800000 -primitive 00000002 00000000 00000023 3f800000 bfadd9f0 c0c3cc3c 40048a00 40828000 beaad555 bfbffa00 3f180000 3f800000 bfd54aab 3f7ff000 00000000 3f800000 -primitive 00000001 00000000 00000007 3f800000 bf8e0000 c09fbe56 409b9700 40550000 c0887b36 c02ff2d8 409b9700 40550000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 00000008 3f800000 3fd54eab 39400000 3f6b0000 3f800000 3fcaf955 3d886000 3f6c0000 3f800000 3fdd2eab bd334000 3f6b0000 3f800000 -primitive 00000002 00000000 00000009 3f800000 3f308000 bf70b000 3f780000 3f800000 3eaa9aab 39400000 3f780000 3f800000 3f114400 bd2cc000 3f780000 3f800000 -primitive 00000000 00000000 0000000a 411cd000 3f800aab 3f001400 3f760000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 0000000b 3f800000 c081c9f8 406f5950 4089dc00 404c0000 bf5abe00 bf8f19f0 4089dc00 404c0000 bfb259cb bed5ebf0 3b560000 3f560000 -primitive 00000002 00000000 0000000c 3f800000 bfd34b55 bd112000 3f270000 3f800000 bfd72b55 be004800 3f270000 3f800000 bfddeb55 bdcb9000 bf570000 3f800000 -primitive 00000002 00000000 0000000d 3f800000 bf98b2ab 3f065400 3f7f0000 3f800000 bf908800 3f115400 3ca00000 3f800000 bf8e92ab 3f177400 3ca00000 3f800000 -primitive 00000000 00000000 0000000e 428ec500 bf7fed55 bf800600 3ec20000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 0000000f 43ffc000 3f4fb800 bffdbe00 3fc08000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000010 41cb0800 3fc34cab 3fd18900 3f6f0000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000011 41160800 3fc61736 457aaa60 3f030000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 00000012 3f800000 3eff4000 3f91e300 3f470000 3f800000 3da18000 bff11800 3f470000 3f800000 3f9fcda7 c0932d60 3f470000 3f800000 -primitive 00000002 00000000 00000013 3f800000 4603e860 458acbdc bf9fec00 40320000 bf6d3f16 3fb1d380 bf9fec00 40320000 bdfcbf00 c082ad92 bf9fec00 40320000 -primitive 00000000 00000000 00000014 42e03000 c0d03779 c0dab82d 40ae9100 40f2e000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 00000015 3f800000 c0734dbb c05af250 3f343800 40120000 bf8002ab 3f800600 3f080000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 00000016 3f800000 3fd556ab 3fbffc00 3f510000 3f800000 3fd50c00 3fb6cc00 3f510000 3f800000 3fcc4c00 3fb7bc00 3f510000 3f800000 -primitive 00000001 00000000 00000017 3f800000 bf54f2ab 3fc43900 3f4b0000 3f800000 3f352955 bf257000 3e000000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000018 42831800 3fd55155 bfc00600 3f340000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000019 4275cc00 3fd54c00 3f7fec00 3f150000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 0000001a 3f800000 bd2e6f4d bf91b8d8 3efcdf33 3f053333 bf5e0b1a 3de09473 3efcdf33 3f053333 3f354400 3e265000 3f000000 3f800000 -primitive 00000002 00000000 0000001b 3f800000 beaa9555 3f800c00 3ef40000 3f800000 be106aab 40029d00 3ef40000 3f800000 be157000 3fc36600 3ef40000 3f800000 -primitive 00000000 00000002 0000001c 416fd800 3eaacaab bfc00400 3fd90000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 0000001d 3f800000 bfbbc000 3f1a6800 3e960000 3f800000 c4014cc8 cac7dafd 4366b680 44afc800 3f7ffd55 beffd000 3f230000 3f800000 -primitive 00000000 00000000 0000001e 41884400 3eaad000 39c00000 3f6c0000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 0000001f 3f800000 beba0555 bfa16200 3f780000 3f800000 be9e0555 bfa46200 3f780000 3f800000 becd3000 bf988200 3f780000 3f800000 -primitive 00000002 00000000 00000020 3f800000 3eaa8aab bf000000 3ff40000 3f800000 be48baab bfcaa300 3ff40000 3f800000 3fcec0ab bf842800 3f5e0000 3f800000 -expect 0 2 -bits 6 9 48 49 50 51 52 53 54 55 56 57 58 59 70 71 -bits 112 113 115 116 119 122 125 132 135 138 139 171 172 174 175 177 -bits 178 180 181 182 183 184 185 186 187 188 189 190 191 240 241 243 -bits 244 246 247 249 250 252 276 277 280 283 284 287 296 299 315 316 -bits 317 318 319 320 321 322 323 364 365 367 368 -pass 256 40 3 33 -state 437ead00 4134a800 43affa40 40b1e000 00000000 00000000 00000100 00000028 00000001 00000000 00000001 00000000 -state 431b7c80 40b98000 43a03c00 bfe40000 000000b4 00000025 0000006e 00000022 00000002 00000001 00000001 00000000 -primitive 00000000 00000000 00000001 424daa00 be1a8600 bfd59b33 3eec0000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000001 00000002 000116c2 3f3ffe00 40267000 3f6d0000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000001 00000003 4285b000 7f800000 c00cc666 3f2c0000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000004 00000001 00000004 4204fc00 7149f2ca c00cc4cd 3f3d0000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000001 00000001 00000005 3f800000 3fa60400 3f49bccd 3f610000 3f800000 44415d02 c50dbf1c 43496a80 4480e800 00000000 00000000 00000000 00000000 -primitive 00000000 00000001 00000006 42aff000 be800e00 c00cc4cd 3f8a8000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 00000007 3f800000 bf321a00 3d26cccd 3c400000 3f800000 3f7ffc00 40266333 3c400000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000008 42709400 3f424100 bffd4b33 3fd68000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 00000022 3f800000 3e837300 3fad2e66 3ec00000 3f800000 3e648568 bedc18f4 3de58000 3e580000 00000000 00000000 00000000 00000000 -primitive 00000000 00000001 0000000a 42023600 3dfecc00 c01e4f33 3f180000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 0000000b 3f800000 c4475619 44b5d72b 44a45268 44add400 44882281 43ae339a 44a45268 44add400 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 0000000c 3f800000 bf94c7c0 3e10c000 3f220000 3f800000 c07b1114 3ef44400 3ea8c000 40580000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 0000000d 3f800000 c0958d74 41819cfc 3e604c00 40c76000 be4e5ce0 bf951188 3e3b7b33 3eed999a beed97be 3f9a64c3 3e3b7b33 3eed999a -primitive 00000001 00000001 00000023 3f800000 c0060189 be850b0f 3fb60000 3f800000 be7ff000 bf196666 3f640000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000000 00000001 0000000f 43ff8000 3f647600 403e48cd 3f580000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000001 00000010 42016000 4587d356 41de7faf 3f5af000 40620000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000001 00000001 00000011 3f800000 3f400200 bf19cccd be440000 3f800000 3db7ec00 c0083ccd 3f1e0000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000002 00000001 00000012 3f800000 c4282a01 c4fb5c25 44170fe0 44435000 c3d3e685 c484dc74 44170fe0 44435000 c4127e4a 44fde0ae 44170fe0 44435000 -primitive 00000002 00000001 00000013 3f800000 403afeb4 41022643 40058000 40858000 403f330c 410915d0 40058000 40858000 40393c24 41001043 f149f2ca 40858000 -primitive 00000000 00000000 00000014 40990000 bf8d6740 3f3eb99a 3ec60000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 00000015 3f800000 3f7fff00 40266666 3e8c0000 3f800000 3db11000 bda4999a 3e8c0000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000002 00000001 00000022 3f800000 3f55b100 bf941800 3ea80000 3f800000 3f55d900 bf884b33 3ea80000 3f800000 3eb6ac9c bee90d40 3e974000 3edc0000 -primitive 00000002 00000001 00000017 3f800000 3f400600 c00cd666 3c800000 3f800000 3f3eb600 c00b3ccd 3f560000 3f800000 3f437600 c00fd666 3f3a0000 3f800000 -primitive 00000001 00000000 00000018 3f800000 3df6c400 bebf999a 3f0c0000 3f800000 3df6c400 bebf999a 3f0c0000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000019 7fc00000 4460a4c6 4592049e 43e7a0e0 44e09c00 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000001 0000001a 41501000 3f000300 c00cc000 3f4f0000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000001 0000001b 3f800000 42023400 44a9a466 3f030000 3f800000 bf544580 c0263333 3f030000 3f800000 b8000000 c00cc800 3f030000 3f800000 -primitive 00000002 00000000 0000001c 3f800000 b9cc0000 c0e05719 3ebf4000 404c0000 3dbf7000 bfae3666 3f040000 3f800000 3e7fe800 bf19b99a 3f5d0000 3f800000 -primitive 00000001 00000001 00000022 3f800000 3f000700 bf198000 be340000 3f800000 be800200 4026699a be340000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 0000001e 3f800000 c0178000 bff26667 40c73d00 404a0000 c0bb7678 c0b5fc80 3f963600 40f68000 bf398800 bf36999a 3efa0000 3f800000 -primitive 00000001 00000001 0000001f 3f800000 c005279e 45c4b8cd 3e380000 3f800000 bf9fff80 bf197333 3f720000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 00000020 3f800000 3f102c00 bf6cfccd 3f1a0000 3f800000 3f997400 3fcba4cd 3f9c0000 3f800000 bfa00100 3f7feccd 3f1a0000 3f800000 -expect 0 6 -bits 519 -pass 128 128 1 33 -state 00000000 00000000 43000000 43000000 00000000 00000000 00000080 00000080 00000001 00000000 00000000 00000000 -primitive 00000002 00000000 00000001 3f800000 bf800700 39000000 3f600000 3f800000 be84d2ca bc7ea4cd 3d89b333 00000000 be83f816 bbfc1ccd 3d89b333 3e81999a -primitive 00000002 00000000 00000002 3f800000 3f360ca0 bfadcdd8 4002ec00 40640000 44ae9980 c48b4460 3f720000 3f800000 bf800100 bfc00000 3f720000 3f800000 -primitive 00000002 00000000 00000003 3f800000 3f7ffa00 bf800100 3eae0000 3f800000 409e366d c0a41c21 3f349000 40a08000 3f808500 bf7a2200 3eae0000 3f800000 -primitive 00000000 00000000 00000004 428d8b00 bf7ffe00 b9400000 3fd48000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 00000005 3f800000 bf800600 bfbffc00 3eca0000 3f800000 3f800200 3f001000 3eca0000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 00000006 3f800000 3fbffe00 00000000 3e040000 3f800000 c00d092a 3f77344c c04d8300 40550000 3f726700 3f6e2c00 3e040000 3f800000 -primitive 00000002 00000000 00000007 3f800000 3e747400 3fc53b00 3edc0000 3f800000 3e845a00 3fc13300 3edc0000 3f800000 3e8a7a00 3fbf8b00 3edc0000 3f800000 -primitive 00000001 00000000 00000008 3f800000 c07d7b12 44791d00 3ed80000 3f800000 c07d7b12 44791d00 3ed80000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 00000009 3f800000 bfbffe00 3f800600 3e4c0000 3f800000 bf549070 3f0b9ef0 3ef6b19a 3f0d999a bf56d88a 3f144370 3ef6b19a 3f0d999a -primitive 00000002 00000000 0000000a 3f800000 bf2a8900 3e5ee400 3ec00000 3f800000 3f000600 bf7ff200 3ec00000 3f800000 bf0db1ec ff800000 3ec00000 3f800000 -primitive 00000000 00000000 0000000b 4261f200 bf992f00 bf057300 3f310000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 0000000c 3f800000 beced030 405c6e7b bf84f600 40370000 3ed41400 3ddbd800 3f4e0000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 00000023 3f800000 bfbc2f80 3eb57800 3eaa0000 3f800000 bfbc2f80 3eb57800 3f170000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 0000000e 3f800000 4171fbc8 c121564d 40e195e0 41215000 3fba9900 bf856f00 3d500000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 0000000f 4269bc00 bef4d846 3e74d0a0 3e96219a 3ef4cccd 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000010 43ffc000 3ef2cc00 bfbeb400 3d880000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000011 3fd40000 4021f724 4021f724 3ffd2000 40220000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 00000012 3f800000 3f680740 3ee803a0 3ea15000 3f680000 c02a4e32 4528c05f 3ea15000 3f680000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 00000013 3f800000 b82f0000 3ed1fcb8 be7dc000 3e8c0000 bed207a8 3e8c0230 be7dc000 3e8c0000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 00000014 3f800000 bf000e00 bf000a00 3f8f0000 3f800000 bf000e00 bf000a00 3f8f0000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000015 41a17000 4027f6d0 407c0a80 3fd35000 40280000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000016 44160000 bf476d00 bfaaba80 3f130000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000017 415a5800 3fb36700 bfc50580 3ff68000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000018 bf800000 39600000 39400000 3f130000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000019 41960000 beccce5d bf02659b 3e3f44cd 3ef26666 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 0000001a 3f800000 b8800000 3fbffd00 3f590000 3f800000 bf800700 beffec00 3f590000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 0000001b 3f800000 3fbff800 39800000 3df80000 3f800000 c40ec4c0 453b4fb0 3f0c0000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 0000001c bf800000 bf800300 39800000 3f870000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 0000001d 43ffc000 bf7ffc00 3effe000 3f5c0000 800116c2 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 0000001e 43ffc000 c000674c 42b45800 3f7d0000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 0000001f 3f800000 c0a5e358 bf66f538 3f506800 406a0000 3fc93e64 c09ced81 3f506800 406a0000 40b9b1a6 3f9fa764 3f506800 406a0000 -primitive 00000000 00000000 00000020 42085400 3f3a1300 3f779900 3ff88000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -expect 3 9 -bits 83 86 87 89 90 91 92 93 94 184 188 194 198 240 244 256 -bits 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 275 -bits 291 295 352 353 354 355 356 357 358 359 360 361 362 363 364 365 -bits 366 367 390 412 416 417 420 421 424 428 501 502 503 504 505 506 -bits 507 508 509 510 511 -pass 96 64 4 33 -state 00000000 00000000 42c00000 42800000 00000000 00000000 00000060 00000040 00000000 00000001 00000000 00000000 -primitive 00000002 00000000 00000001 3f800000 3f800aab 3fc00400 3f590000 3f800000 3f7eeaab 3fb54400 3f590000 3f800000 3f87aaab 3fb95400 3f590000 3f800000 -primitive 00000000 00000001 00000002 43ff8000 c2f1bad0 4400f0ca 431b4600 443b8000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000003 7fc00000 3fd556ab bf800800 3f520000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 00000004 3f800000 bf527c00 bfeb3300 3ece0000 3f800000 bf5fa6ab bfeab300 3ece0000 3f800000 bf407c00 bfecb300 3ece0000 3f800000 -primitive 00000002 00000000 00000005 3f800000 4177bd13 3adef000 c07f7300 4114a000 45124494 c2b61d18 4442b3c0 44abe000 450cd018 431d5b34 4442b3c0 44abe000 -primitive 00000001 00000000 00000006 3f800000 bf7ff555 bfc00400 3ed40000 3f800000 bfb34f55 3fde2b00 3ed40000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 00000007 3f800000 44f57dd4 c4019538 43940a70 44c15c00 3f7d1555 3db10000 3cc00000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 00000008 3f800000 bf800d55 bf652a00 3f640000 3f800000 bf800d55 bf652a00 3f640000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000004 00000000 00000009 3f800000 4151ca36 47394aff 411268b0 414cd000 c1983483 c1a6e102 411268b0 414cd000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 0000000a 3f800000 bf8810ab bfa1bf00 3f7c0000 3f800000 bfb276ab 3f776600 3f7c0000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 0000000b 3f800000 bf800555 3fc00800 3fee0000 3f800000 3fb87a00 bf65c800 3fee0000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 0000000c 42d6d000 3e9a8400 3f681d00 3f3b9800 3f680000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 0000000d 3f800000 3f30abc6 bed3ec20 3e5c4800 3ed40000 3f317fc6 bee77ca0 3e5c4800 3ed40000 449db7fa c43173bc 43648400 443b8000 -primitive 00000002 00000000 0000000e 3f800000 bed97780 c078eee4 3fc88800 400a0000 bf37eec0 4009f0e8 3fc88800 400a0000 bf393960 bfaa01c0 3fc88800 400a0000 -primitive 00000000 00000000 0000000f 42866400 bfa71bd2 40e3d958 be740000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 00000010 3f800000 44d1ad80 45997260 3f200000 3f800000 bf8006ab bf7ff800 3f200000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 00000011 3f800000 beaaaaab bf800a00 3f410000 3f800000 c4a4ac2b 408dfd91 3ee80000 3f800000 3f8006ab 3effc800 3c800000 3f800000 -primitive 00000000 00000000 00000012 80000000 beaabaab bf800e00 3ee20000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000002 00000013 3f800000 bfd54d55 b9a00000 3f730000 3f800000 bfcd3800 3dc36000 3ef60000 3f800000 bfd622ab bd314000 3f730000 3f800000 -primitive 00000002 00000000 00000014 3f800000 3fd8e755 bfa6cc00 3f050000 3f800000 3fd11cab 000116c2 3f050000 3f800000 3fd5fcab bfa7ac00 3f050000 3f800000 -primitive 00000001 00000000 00000015 3f800000 bfd556ab 39e00000 3e280000 3f800000 3f1b5555 400d9980 3f170000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000016 44160000 bea2a555 bfc1b900 3ffd0000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000017 42ae9000 bfa91f55 3f403400 3e3c0000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 00000018 3f800000 bf7ffd55 3efff000 3efa0000 3f800000 bf74fd55 3f07d800 3efa0000 3f800000 bf7c12ab 3ec5b000 3eca0000 3f800000 -primitive 00000002 00000000 00000019 3f800000 beaa8555 beffe000 3e780000 3f800000 3f8006ab 3f800e00 bf100000 3f800000 3f7ff2ab bfbffe00 ff800000 3f800000 -primitive 00000002 00000000 0000001a 3f800000 3f9be81b c53723e0 3f180000 3f800000 3f993d71 c5372228 3f180000 3f800000 3f93681b c537247c 3f180000 3f800000 -primitive 00000002 00000000 0000001b 3f800000 3f7ffd55 bfc00800 3f350000 3f800000 c0010705 c50feee4 3eef799a 3f14cccd bfd55c00 3f001800 3f350000 3f800000 -primitive 00000001 00000000 0000001c 3f800000 bfcc8800 bf1d2400 3fee0000 3f800000 3eaa9aab bf800c00 3fee0000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 0000001d 3f800000 3eaac000 beffd000 3e840000 3f800000 3ec06aab bf0fc800 3f3b0000 3f800000 3e9c6aab bf12e800 3f040000 3f800000 -primitive 00000002 00000000 0000001e 3f800000 c601290f c199cd08 40a66900 40bc8000 c42cac1c bfcb1ec0 3ecac800 3efc0000 c6012874 c1967100 40a66900 40bc8000 -primitive 00000001 00000000 0000001f 3f800000 3f6a2400 3ffa6c00 3d800000 3f800000 beaad555 3fbff600 3d800000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000020 000116c2 3fd54aab bfbff600 3fae8000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -expect 1 10 -bits 89 105 144 145 146 147 148 149 150 151 152 153 154 155 168 169 -bits 171 172 174 175 177 178 192 193 195 198 201 204 205 206 207 208 -bits 209 210 211 212 213 214 252 276 279 282 285 288 291 327 330 333 -bits 334 356 358 359 -pass 256 40 4 33 -state 00000000 00000000 43800000 42200000 00000048 0000002c 000000e3 00000011 00000001 00000000 00000001 00000000 -state c13a4800 421b4600 4317f480 41852800 00000041 00000022 0000006d 00000015 00000000 00000000 00000000 00000000 -primitive 00000001 00000001 00000001 3f800000 43e22cdd c4748913 435eb7a0 44202800 3f701d80 bd306666 3f250000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000002 00000001 00000002 3f800000 beb3bf69 bf80b889 3ee0fd9a 3ef73333 bf384580 bff94e66 3f430000 3f800000 beba5376 bf83790d 3ee0fd9a 3ef73333 -primitive 00000000 00000000 00000003 42066600 41671972 413904fa 3fa78b00 4138e000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000004 7f800000 3ee1d000 c033ce66 3f0a0000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 00000005 3f800000 3f3ff900 3fe65666 3f320000 3f800000 3fa00080 3f7fe666 3f320000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 00000022 3f800000 3f000500 bf198ccd 3e8c0000 7149f2ca 3eca7600 bfa28000 3f9f8000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000007 41165000 becfcf00 4015559a 3ece0000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000001 00000001 00000008 3f800000 4045fc22 c08aa107 3f8e5000 40460000 bf800000 c1115eb8 3f8e5000 40460000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 00000009 3f800000 3f86e140 c016919a 3f290000 3f800000 3f2e2d80 3dda3333 3f290000 3f800000 3f01b000 3f3af333 3f290000 3f800000 -primitive 00000001 00000000 0000000a 3f800000 3e02d2ee 3dd0c4e1 3e9c58cd 3f02cccd 3ee10200 bf81a333 3e900000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 0000000b 41f2e800 3ebed700 c039e666 3fa08000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 0000000c 3f800000 430c9736 c444f194 c3e48400 f149f2ca 43053e5a c43d9534 c3e48400 440ca000 4305b966 c45ff854 c3e48400 440ca000 -primitive 00000001 00000001 0000000d 3f800000 c3bf6dfb 44bf897e 4525fc30 44bf6800 3f8342c0 40025b33 3f430000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000000 00000001 0000000e 00000000 be08d400 3fc5e4cd 3f520000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000001 0000000f 3f800000 449499f0 4071b67a 3db80000 3f800000 bf45e080 3f92b800 3ea20000 3f800000 bf10ad80 c00afc00 3ea20000 3f800000 -primitive 00000002 00000001 00000010 3f800000 3ec3d600 bfd0699a 3f190000 3f800000 38a00000 3f801000 3f1b0000 3f800000 3f578d00 bf493666 3f1b0000 3f800000 -primitive 00000002 00000000 00000011 3f800000 bf400100 bf19c666 3f300000 3f800000 3e5a3c00 3fe95ccd 3f300000 3f800000 3f9ffe00 3e4d199a 3f300000 3f800000 -primitive 00000002 00000001 00000012 3f800000 3f2da580 3f0d199a 3f730000 3f800000 3f066e00 be65cccd 3fba0000 3f800000 3f15eb80 3f2cb666 3f3a0000 3f800000 -primitive 00000000 00000001 00000013 7f800000 443965a0 c0bb1014 000116c2 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000014 41635000 48cc9bd7 44baf8e9 4292f900 4427f800 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 00000015 3f800000 479083ba c9f8ca7b 43c19a80 444b2000 3f000700 3fe66000 3d500000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000000 00000001 00000016 43ff8000 3f39fa30 c08222ed c0043c00 403a0000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000017 42071600 446a59e6 c4dab830 436f4200 449c4000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 00000018 3f800000 bfd310dc 409b7fc9 3e316000 40010000 bf516e00 401a4b33 3e380000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000002 00000001 00000019 3f800000 bf919980 3f9a4333 3f3a0000 3f800000 be84da28 3ea4af00 3d430000 3e700000 bf94a180 3f8a7666 3f3a0000 3f800000 -primitive 00000002 00000001 0000001a 3f800000 392a6000 3f88a1fd 41156930 40aa6000 bf9ffd00 3f801000 3d600000 3f800000 c0d8e846 3fc5ed86 41156930 40aa6000 -primitive 00000002 00000001 0000001b 3f800000 440c3a80 c6086aa6 3f390000 3f800000 40458503 bfdc969d 3fecc200 4089c000 4089c08a c02553b0 3fecc200 4089c000 -primitive 00000001 00000001 0000001c 3f800000 3fa49f00 bfc07000 3ff18000 3f800000 3fa49f00 bfc07000 3fe68000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 0000001d 3f800000 c3b1f924 44837b4d c4502140 4456d800 c3a7f472 448bca42 c4502140 4456d800 c3be31ce 44969dbd c4502140 4456d800 -primitive 00000002 00000001 0000001e 3f800000 405600d6 c0005100 3e3b4000 40560000 40208358 c095d227 3e3b4000 40560000 c37ffc7c 46a28019 3e3b4000 40560000 -primitive 00000002 00000001 0000001f 3f800000 3efffa00 3fe67ccd bf000000 3f800000 bf3fff00 bfb32666 3d900000 3f800000 bf52d280 bf1f799a 3d900000 3f800000 -primitive 00000002 00000001 00000020 3f800000 bf7ffc00 3e4d4ccd 3e640000 3f800000 bf7d0c00 3ec50ccd 3e640000 3f800000 bf79dc00 3ea4a666 3e640000 3f800000 -expect 4 4 -bits 378 379 380 402 739 740 -pass 33 31 4 33 -state 00000000 00000000 42040000 41f80000 0000001c 0000000e 00000026 00000014 00000000 00000001 00000000 00000000 -state 00000000 00000000 42040000 41f80000 00000024 0000000d 00000006 00000012 00000001 00000001 00000001 00000000 -primitive 00000001 00000002 00000001 3f800000 c01f6aab bfac8e74 3f2c0000 3f800000 bf801365 3f801ce7 3e280000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000000 00000001 00000002 80000000 3f705555 3f800842 3eca0000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000003 420e9e00 c03c2c9b bf883def 3f7b0000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000004 42827d00 3f706c9b bd018c63 3f460000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000005 3f800000 c03c1174 bf884632 3f290000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000001 00000006 3f800000 bf2fdc01 bffd59ae 3e8b6000 3ea00000 3f45668c 3f52f529 3e8b6000 3ea00000 bf6b2936 3f22973a 3e8b6000 3ea00000 -primitive 00000000 00000001 00000007 40aed000 3fa85b27 bf5f77be 3f240000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000003 00000008 3f800000 c073a02e 000116c2 bf570000 3f800000 c06ac6f7 402435c7 ff800000 3f800000 c0773393 40394e8d bf570000 3f800000 -primitive 00000001 00000001 00000009 3f800000 c032e7c2 c002b6b6 3d800000 3f800000 c032e7c2 c002b6b6 3d800000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000001 00000001 0000000a 3f800000 bdb9f07c 4011873a 3f5b0000 3f800000 bf7fc9b2 405cdbdf 3f5b0000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 0000000b 3f800000 bffc262f 3ffc0000 3fa07400 3ffc0000 bf8f8e00 40bed880 3fa07400 3ffc0000 00000000 00000000 00000000 00000000 -primitive 00000002 00000001 0000000c 3f800000 4095a018 c0be704d 3f374800 407f0000 40493e10 bfa0bdef 3f4b0000 3f800000 bf7fe8ba 3f7fdef8 3f4b0000 3f800000 -primitive 00000001 00000001 0000000d 3f800000 403843e1 400214a5 3e180000 3f800000 4018a4d9 3fc0d6b6 3f420000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000002 00000002 0000000e 3f800000 c0f33ffc 43b60421 3ee80000 3f800000 c03c1365 bd084211 3ee80000 3f800000 3dce6c9b c0518108 3ee80000 3f800000 -primitive 00000002 00000000 00000024 3f800000 c63a2410 41517ad0 3da80000 3f800000 c63a2326 41514d65 3e960000 3f800000 c63a2431 4150e20a 3f3b0000 3f800000 -primitive 00000002 00000000 00000010 3f800000 bf800000 bd06b5ad 3f790000 3f800000 3f830d93 bed80000 3f790000 3f800000 c0361b27 bf858000 3f790000 3f800000 -primitive 00000000 00000001 00000011 42436c00 3f605555 bfa8e319 3f490000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 00000012 3f800000 403b8aab 406214a5 3e580000 3f800000 3f705d17 bf883def 3f1f0000 3f800000 c034f07c 3f8e4842 3e580000 3f800000 -primitive 00000000 00000000 00000021 423bfe00 40382e8c 800116c2 3f1c0000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000001 00000001 00000024 3f800000 3f82c7c2 c058d8c6 3f6a0000 3f800000 4437005e c529d8a9 438f6ec0 44435000 00000000 00000000 00000000 00000000 -primitive 00000000 00000001 00000015 417a8000 3e3e7000 3bd25930 3bd33333 3e533333 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 00000016 3f800000 3f32c9b2 40608e74 3f2f0000 3f800000 4429b67f 458ec08f c379e0c0 44add400 4488df89 459cc545 c379e0c0 44add400 -primitive 00000000 00000000 00000017 422aaa00 403849b2 bf884211 3df00000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000001 00000018 3f800000 c5083ed1 442b30fa 43d59f80 4488b800 c98a70b6 caee5841 43d59f80 4488b800 404140f8 be64f7be 3f630000 3f800000 -primitive ffffffff 00000001 00000019 3f800000 bf8128ba bf0e0000 3f2e0000 3f800000 bf81e2e9 bf3094a5 3f2e0000 3f800000 bf4768ba bf236b5b 3f550000 3f800000 -primitive 00000001 00000001 0000001a 3f800000 c03c1d17 3f7ff7be 3dc00000 bf800000 c03c1d17 3f7ff7be 3dc00000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 0000001b 419f4c00 3f1da8ba bca95ad7 3ee1c000 3f280000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000001 0000001c 3f800000 3fe03597 3fecea3a 3ec10800 3f2e0000 c109a523 c126158d 3f9a9800 404c0000 c04c18ba c0594a32 3f9a9800 404c0000 -primitive 00000002 00000000 00000023 3f800000 4038326d 3f7fef7c 3e1c0000 3f800000 bf935174 3fe9c421 3e1c0000 3f800000 3f707c1f 40022108 3e1c0000 3f800000 -primitive 00000001 00000001 0000001e 3f800000 4016c7c2 3eec6319 3e000000 3f800000 4016c7c2 3eec6319 3f080000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000000 00000002 0000001f 42ced000 c20d3a6f 413ff49e 40991980 41402000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 00000020 3f800000 400d926d 40578211 3e980000 3f800000 3f66a6ca 3ffc5ef8 3e980000 3f800000 00000000 00000000 00000000 00000000 -expect 1 9 -bits 16 17 18 19 66 67 72 73 74 75 108 109 110 111 -pass 33 31 3 33 -state 00000000 00000000 42040000 41f80000 00000018 00000011 00000002 0000001f 00000001 00000001 00000000 00000000 -primitive 00000002 00000000 00000001 3f800000 c30acd93 c61984a5 3f070000 3f800000 bcfc1f08 c043f9ce beb60000 bf800000 3f705d17 40441084 3f070000 3f800000 -primitive 00000001 00000000 00000002 3f800000 bff33a2f 3f815295 3e100000 3f800000 c0c7dca0 c11e9706 3e100000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000003 41286800 3fb84d93 3fc41ef8 3e100000 3f000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000004 423a4000 4456a4af c376c9ec 43c8c670 4427f800 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 00000005 3f800000 c08bc805 c617bf5b beb60000 3f800000 c08689f6 c617be99 beb60000 3f800000 c0872cdf c617c007 3dc80000 3f800000 -primitive 00000000 00000000 00000006 4255ba00 3ffb2c9b 3f8df9ce 3f2b0000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 00000007 3f800000 c03c1d17 3f800421 3e5c0000 3f800000 c099126d bf768c63 3e5c0000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000008 4291f000 40384ba3 40441084 3f280000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 00000009 403fc000 c5221e71 45a6de37 44458e38 44ec5400 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 0000000a 3f800000 403cde10 3f42d6b6 3f310000 3f800000 3f7064d9 bf885ad7 3f310000 3f800000 3f9422e9 400c894a 3f220000 3f800000 -primitive 00000000 00000000 0000000b 42711000 bf7fc9b2 404418c6 3f340000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 0000000c 3f800000 caadd6aa caa63faa 43975e00 43fa0000 c4308b13 440fd695 43975e00 43fa0000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 0000000d 3f800000 3d0e4d93 3fc19084 3e8a0000 3f800000 40c9f88c 44e97a5a 44879ccc 44927c00 3e3cc9b2 3fd6dad7 bd980000 3f800000 -primitive 00000001 00000000 0000000e 3f800000 c02502e9 bdd6b5ad 3f070000 3f800000 c091e75d c0a3e094 3fe38000 400c0000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 0000000f 3f800000 c59d1328 c51d1c74 42575500 44f61800 c11f5955 41f467bc 40869400 411f8000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 00000010 3f800000 3f703e10 bf886319 3f6c0000 3f800000 406762b2 c0834b78 bf6af200 40768000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 00000011 3f800000 c05a8000 c0508319 3ef80000 3f800000 bf807a2f c00c1def 3f530000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 00000012 3f800000 bf3c49b2 3f82d4a5 3f940000 3f800000 bf3c49b2 3f82d4a5 3f940000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 00000013 3f800000 410b950d 4114bcc4 410a2cc0 4114a000 418bd53c c14bf9b7 410a2cc0 4114a000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 00000014 3f800000 3f5fba2f 4064c73a bf680000 3f800000 be740000 409846b6 bf680000 3f800000 00000000 00000000 00000000 00000000 -primitive 00000001 00000000 00000015 3f800000 c4b174fa 45830aa0 447ee200 44bb8000 c59912ca 45248a7b 447ee200 44bb8000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 00000016 3f800000 c5950470 c51cf9dd 432008c0 44dea800 bfa407c2 bf168842 3f460000 3f800000 3f89b64e 3faf54a5 3e440000 3f800000 -primitive 00000003 00000000 00000017 41882400 bd68ba2f 403b539d 3f160000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 00000022 3f800000 c02407c2 3ec2def8 3ee00000 3f800000 4038345d 3f8018c6 3ee00000 3f800000 c00c326d c0023ad7 3ee00000 3f800000 -primitive 00000000 00000000 00000019 41f72000 bf086991 3f367442 3d13999a 3ec4cccd 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 0000001a 41ff9800 400300f8 402256b6 3f540000 3f800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000000 00000000 0000001b 4202a000 c0db963e bfa53a10 3f96f000 400c0000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -primitive 00000002 00000000 0000001c 3f800000 c02505d1 bff6af7c 3fc30000 3f800000 c1175900 c0da309d 40381400 407c0000 c59a1edb c57d49f8 c3a16850 44f03c00 -primitive 00000002 00000000 0000001d 3f800000 c5b4d3a3 c645b719 3f150000 3f800000 c02b65d1 40382421 3f150000 3f800000 403849b2 3f802108 3ef80000 3f800000 -primitive 00000002 00000000 0000001e 3f800000 3e0b41f0 bffe2fb1 3f37da00 3f4a0000 3c8f2095 bebda4bf 3d94cccd 3e19999a 3e507c1f c014094a 3f490000 3f800000 -primitive 00000002 00000000 00000024 3f800000 c05182e9 40115084 3efa0000 3f800000 c0ab40a3 4087053a bfab4800 3fd80000 c0b290a2 407051ad bfab4800 3fd80000 -primitive 00000002 00000000 00000020 3f800000 3f705d17 bf885ef8 3f260000 3f800000 c0d993c6 c0e7964b 3f8b5600 40d98000 c03c1746 bf88318c 3f200000 3f800000 -expect 6 1 -bits 0 8 12 58 diff --git a/crates/metal2vulkan-validation/runtime-sources.sha256 b/crates/metal2vulkan-validation/runtime-sources.sha256 index 8b4337fd9..0dcd73c0c 100644 --- a/crates/metal2vulkan-validation/runtime-sources.sha256 +++ b/crates/metal2vulkan-validation/runtime-sources.sha256 @@ -1 +1 @@ -5444426c46744d1bdcdb9fa83307a75b6b7d8d8775c91df28b9b53b4b8668816 +3e69f4be31b028e09fc942e6bd99f1344af32d5748d3c0a31af90f77eb90fe71 diff --git a/crates/metal2vulkan-validation/src/candidate/platform/runtime_probe/depth_source.rs b/crates/metal2vulkan-validation/src/candidate/platform/runtime_probe/depth_source.rs index c03329f47..df3941016 100644 --- a/crates/metal2vulkan-validation/src/candidate/platform/runtime_probe/depth_source.rs +++ b/crates/metal2vulkan-validation/src/candidate/platform/runtime_probe/depth_source.rs @@ -1491,16 +1491,9 @@ fn pipeline( constant, slope, clamp, - Some(metal2vulkan::metal::PixelFormat::Depth32Float), profile, ) .map_err(|error| format!("the product's depth bias: {error}"))?; - if bias.unit != metal2vulkan::metal::state::DepthBiasUnit::Device { - return Err(format!( - "a depth bias in {:?}, not the device's unit", - bias.unit - )); - } // The viewport's depth range, near and far, as specialization constants 0 and 1. let range_entries = [ vk::SpecializationMapEntry { diff --git a/crates/metal2vulkan-validation/src/runtime_lane.rs b/crates/metal2vulkan-validation/src/runtime_lane.rs index 19dc21b3b..e44341862 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane.rs @@ -281,10 +281,6 @@ mod cache; #[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))] mod capabilities; #[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))] -mod capture_costs; -#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))] -mod capture_reach; -#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))] mod chosen_pointers; #[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))] mod chroma_pairs; @@ -822,8 +818,6 @@ mod tile_normalized; #[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))] mod tile_path_costs; #[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))] -mod tile_reach_kernel; -#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))] mod tile_shadows; #[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))] mod tile_states; diff --git a/crates/metal2vulkan-validation/src/runtime_lane/bfloat_targets.rs b/crates/metal2vulkan-validation/src/runtime_lane/bfloat_targets.rs index 1fdd33c9e..875976a7d 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/bfloat_targets.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/bfloat_targets.rs @@ -19,10 +19,10 @@ //! - **Loads.** A 256-texel-wide target holding every bfloat code once (each channel of each //! texel the next code), through one pass that stores it: loaded with no draw, which keeps //! every code; loaded under a full-screen draw that writes another attachment alone, which -//! rewrites every code through `half` (`ExtendedRange::load_code`: 56,829 codes move); with a -//! `DontCare` load under that draw, which stores zeros, or with no draw, which keeps every code; -//! and cleared to `(0.5, -2, 3e38, 1e-30)` under that draw. Metal's answer is the SHA-256 of -//! the target's bytes after the pass. The probe's bfloat target was its pass's color +//! rewrites every code through `half` (56,829 codes move), where the device's store keeps every +//! code (`extended-range-bits-kept`); with a `DontCare` load under that draw, which stores +//! zeros, or with no draw, which keeps every code; and cleared to `(0.5, -2, 3e38, 1e-30)` under +//! that draw. Metal's answer is the SHA-256 of the target's bytes after the pass. The probe's bfloat target was its pass's color //! attachment 0 and the drawn one attachment 1; here they are swapped, since the owned fixture //! `rt6_samples`'s fill writes color 0 (Metal's pass rewrites each loaded attachment of every //! tile a draw reaches, whichever it writes). @@ -610,11 +610,12 @@ fn load_case(lane: &Lane, pf: PixelFormat, channels: u64, case: Case) -> Vec read_buffer(&back, 0, length).unwrap() } -/// A pass over a bfloat target that holds every code leaves Metal's codes: a load keeps them -/// where nothing draws and takes them through `half` where a draw reaches their tiles, a -/// `DontCare` load under a draw stores zeros, and a clear under a draw stores the clear's. +/// A pass over a bfloat target that holds every code leaves the device's codes: a load keeps them +/// where nothing draws and where a draw reaches their tiles (the device's store, where Metal's +/// takes them through `half`: its digest is printed), a `DontCare` load under a draw stores +/// zeros, and a clear under a draw stores the clear's, Metal's codes. #[test] -fn bfloat_load_passes_leave_metal_s_codes() { +fn bfloat_load_passes_leave_the_devices_codes() { let (messages, _cache, lane) = lane(); let mut wrong = Vec::new(); for (pf, channels, _, cleared) in FORMATS { @@ -626,14 +627,14 @@ fn bfloat_load_passes_leave_metal_s_codes() { Case::DontCareKept, Case::Cleared, ] { + // Metal's, but for a loaded target under a draw, whose codes the device's store keeps. let metal = match case { - Case::Kept | Case::DontCareKept => EVERY_CODE, - Case::Loaded => LOADED, + Case::Kept | Case::DontCareKept | Case::Loaded => EVERY_CODE, Case::DontCare => DONT_CARE, Case::Cleared => cleared, }; let got = load_case(&lane, pf, channels, case); - // The model's bytes: every code, its load code, zeros, or the clear's texel. + // The model's bytes: every code, zeros, or the clear's texel. let model: Vec = got .chunks(2) .enumerate() @@ -641,8 +642,7 @@ fn bfloat_load_passes_leave_metal_s_codes() { let code = i as u32 & 0xffff; let texel = form.clear_texel([0.5, -2.0, 3e38, 1e-30], ClearRoute::ThroughHalf); let stored = match case { - Case::Kept | Case::DontCareKept => code, - Case::Loaded => form.load_code(code).expect("a bfloat code"), + Case::Kept | Case::DontCareKept | Case::Loaded => code, Case::DontCare => 0, Case::Cleared => texel[i % channels as usize], }; @@ -650,6 +650,9 @@ fn bfloat_load_passes_leave_metal_s_codes() { }) .collect(); assert_eq!(digest(&model), metal, "{pf:?} {case:?}: the model's"); + if case == Case::Loaded { + println!("BFLOAT-TARGETS-KEPT {pf:?}: every code kept, Metal's {LOADED}"); + } if digest(&got) != metal { let first = got .chunks(2) diff --git a/crates/metal2vulkan-validation/src/runtime_lane/capture_costs.rs b/crates/metal2vulkan-validation/src/runtime_lane/capture_costs.rs deleted file mode 100644 index b4849b2bf..000000000 --- a/crates/metal2vulkan-validation/src/runtime_lane/capture_costs.rs +++ /dev/null @@ -1,342 +0,0 @@ -//! What capture replay (`render/capture.rs`) costs a pass, on the device the cfg selects, without -//! the validation layer. -//! -//! Each shape is a pass that loads and stores a `BGR10_XR` color attachment, under a pipeline of -//! the owned fixture `rch_vertex_math` (identity matrices: each position is the buffer's) whose -//! color's write mask is none of its channels, in two modes: -//! -//! - **exact**: the shape's draws, then a triangle off the target. Its capture replay is ready -//! (the shape runs until a pass announces nothing), so each pass draws its captures and bins -//! their primitives before it, and its load rewrites the tiles they reach. -//! - **every tile**: the shape's draws, then a line off the target, which no capture replays: the -//! pass rewrites every tile its scissors reach and announces `unreached-tiles-rewritten`. -//! -//! The shapes: -//! -//! - `cells`: a 384x256 target and two scissored cells (0, 0, 166, 166 and 166, 0, 166, 166) of -//! four small rects each, each rect an indexed (`uint16`) triangle list of 6 indices over its 4 -//! vertices: an atlas pass of eight draws. -//! - `heavy`: a 1024x1024 target and four draws of 3 x 2^14 vertices (3 x 2^10 on a CPU ICD) of -//! zero-area triangles, as the `vertex_cost` lane spreads them: the capture shades each vertex -//! again. -//! -//! Each sample is one command buffer of [`PASSES`] passes of one mode, the modes alternating, 20 -//! samples a mode after 3 warm ones (`CAPTURE-COST`, a pass's share of each): the host's time to -//! encode it, the command buffer's GPU time (MoltenVK's GPU times of a render pass are not the -//! pass's), and the host's time from the commit to the completion; medians and -//! fastest. Measures; asserts only that each mode took its path. - -use super::degrade_notices::counts; -use super::{buffer_with, validated_device_with, Messages, ScratchCache, WAIT}; -use crate::air_library::AirLibrary; -use crate::gpu::TEST_DEVICE; -use metal2vulkan::metal::{ColorWriteMask, IndexType, PixelFormat, PrimitiveType, TextureUsage}; -use metal2vulkan::pipeline::{ColorAttachmentDescriptor, RenderPipelineDescriptor, StageSource}; -use metal2vulkan_devtools::{engine_dir, llvm_assemble}; -use metal2vulkan_runtime::{ - Buffer, CommandQueue, Degradation, Device, LoadAction, PipelineOptions, RenderCommandEncoder, - RenderPassDescriptor, RenderPipelineState, ResourceOptions, ScissorRect, StoreAction, - TextureDescriptor, -}; -use std::time::{Duration, Instant}; - -/// The passes of each sample's command buffer. -const PASSES: usize = 16; - -/// The kind a pass announces where its draws' tile reach is not captured. -const UNREACHED_TILES: Degradation = Degradation::UnreachedTilesRewritten; - -/// The vertices of each `heavy` draw: 2^14 triangles on a GPU. -#[cfg(m2v_gpu)] -const HEAVY_VERTICES: u32 = 3 << 14; - -/// The vertices of each `heavy` draw on a CPU ICD, which shades them on the CPU: 2^10 triangles. -#[cfg(not(m2v_gpu))] -const HEAVY_VERTICES: u32 = 3 << 10; - -/// The `cells` shape's scissored cells. -const CELLS: [ScissorRect; 2] = [ - ScissorRect { - x: 0, - y: 0, - width: 166, - height: 166, - }, - ScissorRect { - x: 166, - y: 0, - width: 166, - height: 166, - }, -]; - -/// A pass's tail draw: a triangle off the target (exact), or a line off it (every tile). -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -enum Mode { - Exact, - EveryTile, -} - -/// One shape's target side, positions, indices, and draws. -struct Shape { - name: &'static str, - extent: [u64; 2], - positions: Vec<[f32; 4]>, - /// The `cells` rects' indices (a list of two triangles over 4 vertices), where it draws them. - indices: Option>, -} - -/// The off-target vertices each shape's positions end in: a triangle's three, then a line's two. -const OFF: [[f32; 4]; 5] = [[-2.0, -2.0, 0.5, 1.0]; 5]; - -/// The clip-space position of window pixel `(x, y)` of a target of `extent` under Metal's default -/// viewport. -fn clip([w, h]: [u64; 2], x: f32, y: f32) -> [f32; 4] { - [2.0 * x / w as f32 - 1.0, 1.0 - 2.0 * y / h as f32, 0.5, 1.0] -} - -/// The `cells` shape: four 24x24 rects in each cell, each from its own 4 vertices. -fn cells() -> Shape { - let extent = [384, 256]; - let mut positions = Vec::new(); - for cell in CELLS { - for r in 0..4u64 { - let x = (cell.x + 12 + 70 * (r % 2)) as f32; - let y = (cell.y + 12 + 70 * (r / 2)) as f32; - for (dx, dy) in [(0.0, 0.0), (24.0, 0.0), (0.0, 24.0), (24.0, 24.0)] { - positions.push(clip(extent, x + dx, y + dy)); - } - } - } - positions.extend(OFF); - Shape { - name: "cells", - extent, - positions, - indices: Some(vec![0, 1, 2, 2, 1, 3]), - } -} - -/// The `heavy` shape: triangle `k`'s three vertices at one point of the target, spread by a -/// multiplicative hash of `k`. -fn heavy() -> Shape { - let mut positions = Vec::with_capacity(HEAVY_VERTICES as usize + OFF.len()); - for k in 0..HEAVY_VERTICES / 3 { - let h = k.wrapping_mul(2654435761); - let x = f32::from(h as u16) / 32767.5 - 1.0; - let y = f32::from((h >> 16) as u16) / 32767.5 - 1.0; - positions.extend([[x, y, 0.5, 1.0]; 3]); - } - positions.extend(OFF); - Shape { - name: "heavy", - extent: [1024, 1024], - positions, - indices: None, - } -} - -/// The fixture's uniforms: identity model, view and projection matrices. -fn identity() -> Vec { - let one = |i: usize| (0..4).map(move |j| if i == j { 1.0f32 } else { 0.0 }); - (0..3) - .flat_map(|_| (0..4).flat_map(one)) - .flat_map(f32::to_le_bytes) - .collect() -} - -/// A shape's objects on one device. -struct Bench { - queue: CommandQueue, - state: RenderPipelineState, - positions: Buffer, - uniforms: Buffer, - indices: Option, - pass: RenderPassDescriptor, - shape: Shape, -} - -impl Bench { - fn new(device: &Device, state: &RenderPipelineState, shape: Shape) -> Bench { - let bytes: Vec = shape - .positions - .iter() - .flatten() - .flat_map(|v| v.to_le_bytes()) - .collect(); - let indices = shape.indices.as_ref().map(|indices| { - let bytes: Vec = indices.iter().flat_map(|i| i.to_le_bytes()).collect(); - buffer_with(device, &bytes).unwrap() - }); - let [w, h] = shape.extent; - let mut descriptor = TextureDescriptor::texture_2d(PixelFormat::BGR10XR, w, h, false); - descriptor.usage = TextureUsage::RENDER_TARGET; - descriptor.resource_options = ResourceOptions::private(); - let target = device.new_texture(&descriptor).unwrap(); - let mut pass = RenderPassDescriptor::new(); - let color = &mut pass.color_attachments[0]; - color.texture = Some(target); - color.load_action = LoadAction::Load; - color.store_action = StoreAction::Store; - Bench { - queue: device.new_command_queue().unwrap(), - state: state.clone(), - positions: buffer_with(device, &bytes).unwrap(), - uniforms: buffer_with(device, &identity()).unwrap(), - indices, - pass, - shape, - } - } - - /// The draws of one pass in `mode`. - fn draws(&self, e: &mut RenderCommandEncoder, mode: Mode) { - e.set_render_pipeline_state(&self.state).unwrap(); - e.set_vertex_buffer(Some(&self.positions), 0, 0).unwrap(); - e.set_vertex_buffer(Some(&self.uniforms), 0, 1).unwrap(); - match &self.indices { - Some(indices) => { - for (c, cell) in CELLS.into_iter().enumerate() { - e.set_scissor_rect(cell).unwrap(); - for r in 0..4 { - let base = 4 * (4 * c + r) as i32; - e.draw_indexed_primitives( - PrimitiveType::Triangle, - 6, - IndexType::UInt16, - indices, - 0, - 1, - base, - 0, - ) - .unwrap(); - } - } - } - None => { - for _ in 0..4 { - e.draw_primitives(PrimitiveType::Triangle, 0, HEAVY_VERTICES, 1, 0) - .unwrap(); - } - } - } - let off = (self.shape.positions.len() - OFF.len()) as u32; - match mode { - Mode::Exact => e.draw_primitives(PrimitiveType::Triangle, off, 3, 1, 0), - Mode::EveryTile => e.draw_primitives(PrimitiveType::Line, off + 3, 2, 1, 0), - } - .unwrap(); - } - - /// One command buffer of `passes` passes in `mode`: the host's encode time, the GPU time and - /// the host's time from commit to completion, in milliseconds a pass. - fn sample(&self, mode: Mode, passes: usize) -> [f64; 3] { - let began = Instant::now(); - let command_buffer = self.queue.command_buffer().unwrap(); - for _ in 0..passes { - let mut e = command_buffer.render_command_encoder(&self.pass).unwrap(); - self.draws(&mut e, mode); - e.end_encoding().unwrap(); - } - let encoded = began.elapsed().as_secs_f64(); - let committed = Instant::now(); - command_buffer.commit().unwrap(); - command_buffer.wait_until_completed_for(WAIT).unwrap(); - let wall = committed.elapsed().as_secs_f64(); - assert_eq!(command_buffer.error(), None, "{} {mode:?}", self.shape.name); - let gpu = command_buffer.gpu_end_time().unwrap() - command_buffer.gpu_start_time().unwrap(); - let per = |s: f64| s * 1e3 / passes as f64; - [per(encoded), per(gpu), per(wall)] - } -} - -/// Each shape's passes in both modes (the module docs). -#[test] -fn capture_replay_costs() { - let cache = ScratchCache::new().unwrap(); - let messages = Messages::default(); - let device = validated_device_with(TEST_DEVICE, &messages, cache.path(), |options| { - options.layers.clear(); - options.announce_each = [UNREACHED_TILES].into_iter().collect(); - }) - .unwrap(); - let bitcode = llvm_assemble(&engine_dir().join("rch_vertex_math.ll")).unwrap(); - let library = device.new_library_with_air(&bitcode).unwrap(); - let function = |name: &str| { - StageSource::Function( - library - .new_function_with_name(name) - .unwrap() - .function_descriptor(), - ) - }; - let mut state = RenderPipelineDescriptor::new(function("rch_vertex_math")); - state.fragment = Some(function("rch_vertex_math_color")); - let mut none = ColorAttachmentDescriptor::new(PixelFormat::BGR10XR); - none.write_mask = ColorWriteMask::NONE; - state.color_attachments[0] = Some(none); - let state = device - .new_render_pipeline_state(&state, &PipelineOptions::default()) - .unwrap(); - let announced = || counts(&messages.take_notices()).contains_key(&UNREACHED_TILES); - for shape in [cells(), heavy()] { - let bench = Bench::new(&device, &state, shape); - let name = bench.shape.name; - // Until the shape's capture forms and pipelines are made. - announced(); - let began = Instant::now(); - loop { - bench.sample(Mode::Exact, 1); - if !announced() { - break; - } - assert!(began.elapsed() < WAIT, "{name}: no capture within {WAIT:?}"); - std::thread::sleep(Duration::from_millis(20)); - } - let mut times = [Vec::new(), Vec::new()]; - let tallied = device.work_counts(); - for k in 0..23 { - for (m, mode) in [Mode::Exact, Mode::EveryTile].into_iter().enumerate() { - let before = device.work_counts().capture_reach_passes; - let sample = bench.sample(mode, PASSES); - let captured = device.work_counts().capture_reach_passes - before; - let every = announced(); - match mode { - Mode::Exact => assert!(captured == PASSES as u64 && !every, "{name} {k}"), - Mode::EveryTile => assert!(captured == 0 && every, "{name} {k}"), - } - if k >= 3 { - times[m].push(sample); - } - } - } - let after = device.work_counts(); - let passes = after.capture_reach_passes - tallied.capture_reach_passes; - eprintln!( - "CAPTURE-TALLY {name}: {passes} captured passes found {} of the {} tiles their \ - scissors bound; {} at their bound, {} narrower", - after.capture_reach_tiles_found - tallied.capture_reach_tiles_found, - after.capture_reach_tiles_bound - tallied.capture_reach_tiles_bound, - after.capture_reach_bound_passes - tallied.capture_reach_bound_passes, - after.capture_reach_narrower_passes - tallied.capture_reach_narrower_passes, - ); - let stat = |samples: &[[f64; 3]], i: usize| { - let mut v: Vec = samples.iter().map(|s| s[i]).collect(); - v.sort_by(f64::total_cmp); - (v[v.len() / 2], v[0]) - }; - for (m, mode) in ["exact", "every-tile"].into_iter().enumerate() { - let (encode, encode_fast) = stat(×[m], 0); - let (gpu, gpu_fast) = stat(×[m], 1); - let (wall, wall_fast) = stat(×[m], 2); - eprintln!( - "CAPTURE-COST {name} {mode} a pass ({PASSES} passes a command buffer): encode \ - median {encode:.4} ms, fastest {encode_fast:.4} ms; GPU median {gpu:.4} ms, \ - fastest {gpu_fast:.4} ms; commit to completion median {wall:.4} ms, fastest \ - {wall_fast:.4} ms" - ); - } - } - messages.take_notices(); -} diff --git a/crates/metal2vulkan-validation/src/runtime_lane/capture_reach.rs b/crates/metal2vulkan-validation/src/runtime_lane/capture_reach.rs deleted file mode 100644 index 45fe98d62..000000000 --- a/crates/metal2vulkan-validation/src/runtime_lane/capture_reach.rs +++ /dev/null @@ -1,448 +0,0 @@ -//! Capture replay (`render/capture.rs`) on the device the cfg selects, under the validation layer: -//! a pass's load of an extended-range color rewrites the tiles its draws' primitives reach, as the -//! capture of their own positions bins them. -//! -//! A 128x128 `BGR10_XR` target of zero words, loaded and stored, under a pipeline of the owned -//! fixture `rch_vertex_math` (identity matrices: each position is the buffer's) whose color's -//! write mask is none of its channels, draws a triangle list's triangle in tile (1, 2), and an -//! indexed (`uint16`) triangle strip of two instances whose all-ones index restarts it: its first -//! piece's two triangles over tiles (2, 0) and (3, 0), its second's one in tile (0, 3). Metal's -//! pass rewrites the words of each tile a primitive reaches (bits 30 and 31 ones), and keeps the -//! others. The pass's first run asks for its draws' capture forms, which the device translates on -//! its pool and makes at later passes: it rewrites every tile and announces -//! `unreached-tiles-rewritten` (the device announces the kind at every occurrence). A later run, -//! once every capture form and pipeline is made, rewrites the four tiles alone, Metal's answer, and -//! announces nothing; so does the run after it. The same draws in a pass that loads the color -//! `DontCare` or `Clear` run no capture: no load pass takes the color. -//! -//! An atlas pass as the consumer's draw them does the same over its scissored cells' small rects -//! (an `RGB10A8_2P_XR10` target beside memoryless colors and depth): its first run rewrites every -//! tile the scissors reach, a later run the tiles the rects reach alone. - -use super::degrade_notices::counts; -use super::resolves::{lane_with, quiet}; -use super::{buffer_with, WAIT}; -use crate::air_library::AirLibrary; -use metal2vulkan::metal::{ColorWriteMask, IndexType, PixelFormat, PrimitiveType, TextureUsage}; -use metal2vulkan::pipeline::{ColorAttachmentDescriptor, RenderPipelineDescriptor, StageSource}; -use metal2vulkan_devtools::{engine_dir, llvm_assemble}; -use metal2vulkan_runtime::{ - BlitOption, Degradation, LoadAction, PipelineOptions, Region, RenderCommandEncoder, - RenderPassDescriptor, ResourceOptions, ScissorRect, StoreAction, TextureDescriptor, WorkCounts, -}; -use std::time::{Duration, Instant}; - -/// The target's side, in pixels: four 32x32 tiles a side. -const SIDE: u64 = 128; - -/// The kind the pass announces until its draws' tile reach is captured. -const UNREACHED_TILES: Degradation = Degradation::UnreachedTilesRewritten; - -/// The tiles the draws' primitives reach, `(x, y)`. -const REACHED: [(u64, u64); 4] = [(1, 2), (2, 0), (3, 0), (0, 3)]; - -/// The strip's indices: its first piece (vertices 3 to 6), the restart, its second (7 to 9). -const STRIP: [u16; 8] = [3, 4, 5, 6, 0xffff, 7, 8, 9]; - -/// The clip-space position of window pixel `(x, y)` of the target under Metal's default -/// viewport. -fn clip(x: f32, y: f32) -> [f32; 4] { - [x / 64.0 - 1.0, 1.0 - y / 64.0, 0.5, 1.0] -} - -/// The positions: the list's triangle in tile (1, 2), the strip's first piece's four vertices -/// over tiles (2, 0) and (3, 0), and its second piece's triangle in tile (0, 3). -fn positions() -> Vec { - [ - clip(40.0, 70.0), - clip(50.0, 70.0), - clip(40.0, 80.0), - clip(70.0, 8.0), - clip(70.0, 20.0), - clip(120.0, 8.0), - clip(120.0, 20.0), - clip(5.0, 100.0), - clip(20.0, 100.0), - clip(5.0, 115.0), - ] - .iter() - .flatten() - .flat_map(|v| v.to_le_bytes()) - .collect() -} - -/// The fixture's uniforms: identity model, view and projection matrices. -fn identity() -> Vec { - let one = |i: usize| (0..4).map(move |j| if i == j { 1.0f32 } else { 0.0 }); - (0..3) - .flat_map(|_| (0..4).flat_map(one)) - .flat_map(f32::to_le_bytes) - .collect() -} - -/// The target's words once a pass rewrote the tiles `tiles` and kept every other. -fn rewritten(tiles: &[(u64, u64)]) -> Vec { - (0..SIDE) - .flat_map(|y| (0..SIDE).map(move |x| (x, y))) - .flat_map(|(x, y)| match tiles.contains(&(x / 32, y / 32)) { - true => 0xc000_0000u32.to_le_bytes(), - false => [0; 4], - }) - .collect() -} - -/// The capture tally between `before` and `after` (`WorkCounts`): the tiles found and bound, and -/// the passes found at their bound and narrower. -fn tally(before: &WorkCounts, after: &WorkCounts) -> (u64, u64, u64, u64) { - ( - after.capture_reach_tiles_found - before.capture_reach_tiles_found, - after.capture_reach_tiles_bound - before.capture_reach_tiles_bound, - after.capture_reach_bound_passes - before.capture_reach_bound_passes, - after.capture_reach_narrower_passes - before.capture_reach_narrower_passes, - ) -} - -/// Every tile of the target. -fn every_tile() -> Vec<(u64, u64)> { - (0..4).flat_map(|y| (0..4).map(move |x| (x, y))).collect() -} - -/// The pass's first run rewrites every tile and announces `unreached-tiles-rewritten`; a later -/// run, once its draws' capture forms and pipelines are made, rewrites only the tiles their -/// primitives reach and announces nothing (the module docs). -#[test] -fn a_load_pass_rewrites_the_tiles_its_captured_primitives_reach() { - let (messages, _cache, lane) = lane_with(|options| { - options.announce_each = [UNREACHED_TILES].into_iter().collect(); - }); - let bitcode = llvm_assemble(&engine_dir().join("rch_vertex_math.ll")).unwrap(); - let library = lane.device.new_library_with_air(&bitcode).unwrap(); - let function = |name: &str| { - StageSource::Function( - library - .new_function_with_name(name) - .unwrap() - .function_descriptor(), - ) - }; - let pf = PixelFormat::BGR10XR; - let mut state = RenderPipelineDescriptor::new(function("rch_vertex_math")); - state.fragment = Some(function("rch_vertex_math_color")); - let mut none = ColorAttachmentDescriptor::new(pf); - none.write_mask = ColorWriteMask::NONE; - state.color_attachments[0] = Some(none); - let state = lane - .device - .new_render_pipeline_state(&state, &PipelineOptions::default()) - .unwrap(); - let positions = buffer_with(&lane.device, &positions()).unwrap(); - let uniforms = buffer_with(&lane.device, &identity()).unwrap(); - let indices: Vec = STRIP.iter().flat_map(|i| i.to_le_bytes()).collect(); - let indices = buffer_with(&lane.device, &indices).unwrap(); - let mut descriptor = TextureDescriptor::texture_2d(pf, SIDE, SIDE, false); - descriptor.usage = TextureUsage::RENDER_TARGET | TextureUsage::SHADER_READ; - descriptor.resource_options = ResourceOptions::shared(); - let target = lane.device.new_texture(&descriptor).unwrap(); - let mut pass = RenderPassDescriptor::new(); - let color = &mut pass.color_attachments[0]; - color.texture = Some(target.clone()); - color.load_action = LoadAction::Load; - color.store_action = StoreAction::Store; - let zeros = vec![0u8; (4 * SIDE * SIDE) as usize]; - // The pass's draws. - let draw = |e: &mut RenderCommandEncoder| { - e.set_render_pipeline_state(&state).unwrap(); - e.set_vertex_buffer(Some(&positions), 0, 0).unwrap(); - e.set_vertex_buffer(Some(&uniforms), 0, 1).unwrap(); - e.draw_primitives(PrimitiveType::Triangle, 0, 3, 1, 0) - .unwrap(); - e.draw_indexed_primitives( - PrimitiveType::TriangleStrip, - STRIP.len() as u32, - IndexType::UInt16, - &indices, - 0, - 2, - 0, - 0, - ) - .unwrap(); - }; - // One run of the pass over zero words: the words it leaves, and whether it announced. - let run = || { - target - .replace_region(Region::new_2d(0, 0, SIDE, SIDE), 0, 0, &zeros, 4 * SIDE, 0) - .unwrap(); - lane.run(&pass, |_, e, _| draw(e)).unwrap(); - let words = lane.read(&target, (0, 0), 4, BlitOption::None); - let announced = counts(&messages.take_notices()).contains_key(&UNREACHED_TILES); - (words, announced) - }; - let before = lane.device.work_counts(); - let (words, announced) = run(); - assert!(announced, "the first run announces"); - assert!( - words == rewritten(&every_tile()), - "the first run rewrites every tile" - ); - // The capture forms are translated on the pool, then made at later runs. - let began = Instant::now(); - let exact = loop { - let (words, announced) = run(); - if !announced { - break words; - } - assert!(words == rewritten(&every_tile()), "an announced run"); - assert!( - began.elapsed() < WAIT, - "no run's capture was ready within {WAIT:?}" - ); - std::thread::sleep(Duration::from_millis(20)); - }; - assert!(exact == rewritten(&REACHED), "the captured run's tiles"); - let tallied = lane.device.work_counts(); - let (words, announced) = run(); - assert!(!announced && words == exact, "the run after it"); - let after = lane.device.work_counts(); - assert!( - after.capture_reach_passes - before.capture_reach_passes >= 2, - "{before:?} {after:?}" - ); - // Its tally: the primitives reach 4 of the 16 tiles its viewport reaches. - assert_eq!(tally(&tallied, &after), (4, 16, 0, 1)); - // The same draws in a pass that loads the color `DontCare` (a dont-care load's clear, - // `clear_reach.rs`) or `Clear`: no load pass takes it, so no capture runs. - for load in [LoadAction::DontCare, LoadAction::Clear] { - let mut other = RenderPassDescriptor::new(); - let color = &mut other.color_attachments[0]; - color.texture = Some(target.clone()); - color.load_action = load; - color.store_action = StoreAction::Store; - let counted = lane.device.work_counts().capture_reach_passes; - lane.run(&other, |_, e, _| draw(e)).unwrap(); - let captured = lane.device.work_counts().capture_reach_passes - counted; - assert_eq!(captured, 0, "a {load:?} load captures nothing"); - messages.take_notices(); - } - quiet(lane, &messages); -} - -/// The atlas passes' height, in pixels: eight tiles. -const ATLAS_HEIGHT: u64 = 256; - -/// The atlas passes' scissored cells. -const CELLS: [ScissorRect; 2] = [ - ScissorRect { - x: 0, - y: 0, - width: 166, - height: 166, - }, - ScissorRect { - x: 166, - y: 0, - width: 166, - height: 166, - }, -]; - -/// Each cell's small rects, `[x0, y0, x1, y1]` in pixels: their edges off the tile grid, one -/// rect across x = 64. -const RECTS: [&[[f32; 4]]; 2] = [ - &[ - [10.0, 10.0, 26.0, 26.0], - [60.0, 40.0, 70.0, 50.0], - [100.0, 130.0, 120.0, 150.0], - ], - &[[180.0, 10.0, 200.0, 20.0], [290.0, 140.0, 300.0, 158.0]], -]; - -/// The tiles each cell's rects reach, `(x, y)`. -const RECT_TILES: [&[(u64, u64)]; 2] = - [&[(0, 0), (1, 1), (2, 1), (3, 4)], &[(5, 0), (6, 0), (9, 4)]]; - -/// A two-plane target's color words of every bit, once a pass rewrote the tiles `tiles` (the -/// top two bits zeroed) and kept every other. -fn two_plane_rewritten([width, height]: [u64; 2], tiles: &[(u64, u64)]) -> Vec { - (0..height) - .flat_map(|y| (0..width).map(move |x| (x, y))) - .flat_map(|(x, y)| match tiles.contains(&(x / 32, y / 32)) { - true => 0x3fff_ffffu32.to_le_bytes(), - false => u32::MAX.to_le_bytes(), - }) - .collect() -} - -/// An atlas pass as the consumer's draw them: an `RGB10A8_2P_XR10` color attachment of 256x256 (one -/// cell) or 384x256 (both) whose color words hold every bit, loaded and stored, beside two -/// memoryless `RGBA16Float` colors and a memoryless `Depth32Float` depth, each cleared and not -/// stored; in each cell, under its scissor, its small rects, each an indexed (`uint16`) list of two -/// triangles at its own base vertex, but for the third, a strip of four vertices without indices. -/// Every color's write mask is none of its channels. The first run rewrites every tile the cells' -/// scissors reach and announces `unreached-tiles-rewritten`; a later run, once the capture forms -/// and pipelines are made, rewrites the tiles the rects reach alone, Metal's answer, and announces -/// nothing. -#[test] -fn an_atlas_pass_of_scissored_cells_rewrites_the_tiles_its_rects_reach() { - let (messages, _cache, lane) = lane_with(|options| { - options.announce_each = [UNREACHED_TILES].into_iter().collect(); - }); - let bitcode = llvm_assemble(&engine_dir().join("rch_vertex_math.ll")).unwrap(); - let library = lane.device.new_library_with_air(&bitcode).unwrap(); - let function = |name: &str| { - StageSource::Function( - library - .new_function_with_name(name) - .unwrap() - .function_descriptor(), - ) - }; - let pf = PixelFormat::RGB10A82PXR10; - let side = PixelFormat::RGBA16Float; - let mut state = RenderPipelineDescriptor::new(function("rch_vertex_math")); - state.fragment = Some(function("rch_vertex_math_color")); - for (index, format) in [pf, side, side].into_iter().enumerate() { - let mut none = ColorAttachmentDescriptor::new(format); - none.write_mask = ColorWriteMask::NONE; - state.color_attachments[index] = Some(none); - } - state.depth_format = Some(PixelFormat::Depth32Float); - let state = lane - .device - .new_render_pipeline_state(&state, &PipelineOptions::default()) - .unwrap(); - let uniforms = buffer_with(&lane.device, &identity()).unwrap(); - let list: Vec = [0u16, 1, 2, 2, 1, 3] - .iter() - .flat_map(|i| i.to_le_bytes()) - .collect(); - let list = buffer_with(&lane.device, &list).unwrap(); - for (width, cells) in [(256u64, 1usize), (384, 2)] { - let extent = [width, ATLAS_HEIGHT]; - let at = |x: f32, y: f32| { - [ - 2.0 * x / width as f32 - 1.0, - 1.0 - 2.0 * y / ATLAS_HEIGHT as f32, - 0.5, - 1.0, - ] - }; - let positions: Vec = RECTS[..cells] - .iter() - .flat_map(|rects| rects.iter()) - .flat_map(|&[x0, y0, x1, y1]| [at(x0, y0), at(x1, y0), at(x0, y1), at(x1, y1)]) - .flatten() - .flat_map(f32::to_le_bytes) - .collect(); - let positions = buffer_with(&lane.device, &positions).unwrap(); - let mut descriptor = TextureDescriptor::texture_2d(pf, width, ATLAS_HEIGHT, false); - descriptor.usage = TextureUsage::RENDER_TARGET | TextureUsage::SHADER_READ; - descriptor.resource_options = ResourceOptions::shared(); - let target = lane.device.new_texture(&descriptor).unwrap(); - let transient = |format: PixelFormat| { - let mut descriptor = TextureDescriptor::texture_2d(format, width, ATLAS_HEIGHT, false); - descriptor.usage = TextureUsage::RENDER_TARGET; - descriptor.resource_options = super::memoryless::memoryless_options(); - lane.device.new_texture(&descriptor).unwrap() - }; - let mut pass = RenderPassDescriptor::new(); - let color = &mut pass.color_attachments[0]; - color.texture = Some(target.clone()); - color.load_action = LoadAction::Load; - color.store_action = StoreAction::Store; - for index in [1, 2] { - let color = &mut pass.color_attachments[index]; - color.texture = Some(transient(side)); - color.load_action = LoadAction::Clear; - color.store_action = StoreAction::DontCare; - } - pass.depth_attachment.texture = Some(transient(PixelFormat::Depth32Float)); - pass.depth_attachment.load_action = LoadAction::Clear; - pass.depth_attachment.clear_depth = 1.0; - pass.depth_attachment.store_action = StoreAction::DontCare; - let filled = vec![0xffu8; (4 * width * ATLAS_HEIGHT) as usize]; - // One run of the pass over words of every bit: the words it leaves, and whether it - // announced. - let run = || { - target - .replace_region( - Region::new_2d(0, 0, width, ATLAS_HEIGHT), - 0, - 0, - &filled, - 4 * width, - 0, - ) - .unwrap(); - lane.run(&pass, |_, e, _| { - e.set_render_pipeline_state(&state).unwrap(); - e.set_vertex_buffer(Some(&positions), 0, 0).unwrap(); - e.set_vertex_buffer(Some(&uniforms), 0, 1).unwrap(); - let mut rect = 0u32; - for (cell, rects) in CELLS[..cells].iter().zip(RECTS) { - e.set_scissor_rect(*cell).unwrap(); - for _ in rects { - match rect { - 2 => e.draw_primitives(PrimitiveType::TriangleStrip, 4 * rect, 4, 1, 0), - _ => e.draw_indexed_primitives( - PrimitiveType::Triangle, - 6, - IndexType::UInt16, - &list, - 0, - 1, - 4 * rect as i32, - 0, - ), - } - .unwrap(); - rect += 1; - } - } - }) - .unwrap(); - let words = lane.read(&target, (0, 0), 4, BlitOption::None); - let announced = counts(&messages.take_notices()).contains_key(&UNREACHED_TILES); - (words, announced) - }; - // The host's reach: every tile the cells' scissors reach. - let last = (CELLS[cells - 1].x + CELLS[cells - 1].width - 1) / 32; - let scissored: Vec<(u64, u64)> = (0..=165 / 32) - .flat_map(|y| (0..=last).map(move |x| (x, y))) - .collect(); - let reached: Vec<(u64, u64)> = RECT_TILES[..cells].concat(); - // The first target's first run asks for the draws' capture forms; the second target's - // draws take the same ones, already made or being made. - let mut ran = run(); - assert!(ran.1 || cells > 1, "{width}: the first run announces"); - let began = Instant::now(); - let exact = loop { - let (words, announced) = ran; - if !announced { - break words; - } - assert!( - words == two_plane_rewritten(extent, &scissored), - "{width}: an announced run rewrites the scissors' tiles" - ); - assert!( - began.elapsed() < WAIT, - "{width}: no run's capture was ready within {WAIT:?}" - ); - std::thread::sleep(Duration::from_millis(20)); - ran = run(); - }; - assert!( - exact == two_plane_rewritten(extent, &reached), - "{width}: the captured run's tiles" - ); - let tallied = lane.device.work_counts(); - let (words, announced) = run(); - assert!(!announced && words == exact, "{width}: the run after it"); - // Its tally: the rects reach a few of the tiles the scissors reach. - let counted = (reached.len() as u64, scissored.len() as u64, 0, 1); - let after = lane.device.work_counts(); - assert_eq!(tally(&tallied, &after), counted, "{width}"); - } - quiet(lane, &messages); -} diff --git a/crates/metal2vulkan-validation/src/runtime_lane/degrade_notices.rs b/crates/metal2vulkan-validation/src/runtime_lane/degrade_notices.rs index 1cc136249..b76659194 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/degrade_notices.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/degrade_notices.rs @@ -165,7 +165,7 @@ use super::compressed_decode::BLOCK_DECODES; use super::cross_class_reads::CROSS_CLASS; use super::depth_denormals::{DEPTH_DENORMALS, SIGNED_DEPTH_TESTS}; use super::detach_textures::DETACHED_REACHES; -use super::extended_range_blends::{EXTENDED_RANGE_BITS, STORED_CODES, UNREACHED_TILES}; +use super::extended_range_blends::{EXTENDED_RANGE_BITS, STORED_CODES}; use super::extended_range_resolve::XR_RESOLVE; use super::extended_range_two_planes::HEAP_PLANES; use super::first_use::FIRST_SPARSE; @@ -534,7 +534,6 @@ fn every_kind_has_a_site_a_lane_test_takes() { &HEAP_PLANES, &TWO_PLANE_COPIES, &EXTENDED_RANGE_BITS, - &UNREACHED_TILES, &SNORM_MINIMUM, &SHARED_EXPONENT, &STORED_CODES, diff --git a/crates/metal2vulkan-validation/src/runtime_lane/extended_range_blend_table.rs b/crates/metal2vulkan-validation/src/runtime_lane/extended_range_blend_table.rs index 2ee0604ca..a379e2adf 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/extended_range_blend_table.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/extended_range_blend_table.rs @@ -13,10 +13,10 @@ //! 0 through a blit, a two-plane format's alpha bytes as `round(255 a)` of a `float` read. Where it //! lies: a texture of the device's own, a placement heap's, and (the two-plane formats) one over //! the planes of a `'b3a8'` surface, whose bytes are read where Metal keeps them. A pass that -//! announces `extended-range-bits-kept` (a heap's two-plane texture, a shadow of the heap's bytes -//! the load pass does not take) keeps the bits the codes leave unused in the texels its draws do -//! not write, where Metal's pass rewrites them: its bands are compared with those bits as Metal's -//! pass leaves them ([`as_metal_leaves`]), the codes exactly. A differing band is printed on an +//! announces `extended-range-bits-kept` (every pass that loads the target: the device's store) +//! keeps the bits the codes leave unused in the texels its draws do not write, where Metal's pass +//! rewrites them: its bands are compared with those bits as Metal's pass leaves them +//! ([`as_metal_leaves`]), the codes exactly. A differing band is printed on an //! `XR-TABLE-DIFFERS` line. //! //! The table of the probe built without fast math (`xr_blends::safe_table`) is @@ -796,12 +796,15 @@ fn a_memoryless_color_2_blends_as_a_stored_color_does() { }) .unwrap(); let (stored_plane, stored_alpha) = bytes_of(&lane, (&stored, None), layout, &table); + // The pass loads color 0, so its texels the draws do not write keep their bytes, the device's + // store (`extended-range-bits-kept`): each band is compared with the bits its codes leave unused + // as Metal's pass leaves them, the codes exactly. for (row, _) in &made { let at = row.config * BAND; - let band = &stored_plane[4 * at..4 * (at + BAND)]; + let band = as_metal_leaves(layout, &stored_plane[4 * at..4 * (at + BAND)]); let alpha_band = &stored_alpha[at..at + BAND]; assert_eq!( - (xr_blends::fnv(band), xr_blends::fnv(alpha_band)), + (xr_blends::fnv(&band), xr_blends::fnv(alpha_band)), (row.plane, row.alpha), "cfg {}: the stored color 0 is not Metal's", row.config diff --git a/crates/metal2vulkan-validation/src/runtime_lane/extended_range_blends.rs b/crates/metal2vulkan-validation/src/runtime_lane/extended_range_blends.rs index 7c90cc789..cde6f2b27 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/extended_range_blends.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/extended_range_blends.rs @@ -37,9 +37,9 @@ use metal2vulkan::metal::{ }; use metal2vulkan::pipeline::{ColorAttachmentDescriptor, RenderPipelineDescriptor, StageSource}; use metal2vulkan_runtime::{ - BlitOption, Buffer, ClearColor, Degradation, Error, IndirectCommandBufferDescriptor, - LoadAction, PipelineOptions, Region, RenderPassDescriptor, ResourceOptions, StoreAction, - Texture, TextureDescriptor, + BlitOption, Buffer, ClearColor, DebugMessage, Degradation, Error, + IndirectCommandBufferDescriptor, LoadAction, PipelineOptions, Region, RenderPassDescriptor, + ResourceOptions, StoreAction, Texture, TextureDescriptor, }; use std::collections::BTreeSet; @@ -689,22 +689,17 @@ fn a_blend_of_a_computed_float4_into_extended_range_announces_its_source() { assert_eq!(counts(¬ices).get(&float_source), None, "{notices:?}"); } -/// The kind a draw in a pass that loads an extended-range color the load pass does not take -/// announces. +/// The kind a draw in a pass that loads an extended-range, padded or bfloat color announces. pub(super) const EXTENDED_RANGE_BITS: [Degradation; 1] = [Degradation::ExtendedRangeBitsKept]; -/// The kind a pass whose load pass rewrites every tile of its render area, where none of its -/// color attachments is cleared, announces. -pub(super) const UNREACHED_TILES: [Degradation; 1] = [Degradation::UnreachedTilesRewritten]; - /// A draw into `BGR10_XR` holding the probe's random texels under a write mask of none of its -/// channels: every texel ends with its codes and its bits 30 and 31 ones, as Metal's pass leaves -/// each tile a draw reaches (on an Apple M4 and an Apple M3 Max; the full-screen -/// triangle reaches every tile), through the load pass (`render/unused_bits_load.rs`). -/// `extended-range-bits-kept` is not announced, and `unreached-tiles-rewritten` is, once (the pass -/// clears no color). A draw under every channel announces neither bits kind. +/// channels: every texel keeps its bytes, the device's store (`render/tile_store.rs`), where +/// Metal's pass leaves each tile a draw reaches with its bits 30 and 31 ones (on an Apple M4 and +/// an Apple M3 Max; the full-screen triangle reaches every tile); `extended-range-bits-kept` is +/// announced once. A draw under every channel, whose texels the draw writes, announces it no +/// more (once per device). #[test] -fn a_draw_under_an_empty_mask_leaves_metals_unused_bits() { +fn a_draw_under_an_empty_mask_keeps_the_unused_bits_and_says_so() { let (messages, _cache, lane) = lane(); let halves = halves(); let pf = PixelFormat::BGR10XR; @@ -716,17 +711,21 @@ fn a_draw_under_an_empty_mask_leaves_metals_unused_bits() { let first = made(&lane, &[draw_descriptor(&lane, none)]); draw(&lane, &t, &halves, none).expect("no channel"); let got = lane.read(&t, (0, 0), 4, BlitOption::None); - let want: Vec = plane + let canonical = plane .chunks(4) - .flat_map(|w| (u32::from_le_bytes([w[0], w[1], w[2], w[3]]) | 0xc000_0000).to_le_bytes()) - .collect(); + .filter(|w| u32::from_le_bytes([w[0], w[1], w[2], w[3]]) >> 30 != 3) + .count(); + println!("EXTENDED-RANGE-BITS-KEPT {canonical} texels Metal's pass would rewrite"); assert!( - got == want, - "the texels differ from Metal's: {}", + canonical > 0, + "the probe's texels hold no bits Metal rewrites" + ); + assert!( + got == plane, + "the texels differ from their bytes: {}", first_texels(&got, 4) ); - let counts = assert_made_once(&messages, &UNREACHED_TILES, &first); - assert!(!counts.contains_key(&EXTENDED_RANGE_BITS[0]), "{counts:?}"); + assert_made_once(&messages, &EXTENDED_RANGE_BITS, &first); let t = filled(&lane, pf, (&plane, &alpha)); let every = ColorAttachmentDescriptor::new(pf); let first = made(&lane, &[draw_descriptor(&lane, every)]); @@ -736,11 +735,9 @@ fn a_draw_under_an_empty_mask_leaves_metals_unused_bits() { quiet(lane, &messages); } -/// A pass that loads a 4x multisampled `BGR10_XR` attachment, which the load pass does not take -/// (no copy reaches a multisampled image's samples, `render/unused_bits_load.rs`), and draws -/// announces `extended-range-bits-kept` once, naming color 0, and not -/// `unreached-tiles-rewritten`: the attachment keeps the bits its draws do not write, which -/// Metal's pass rewrites in each tile a draw reaches. +/// A pass that loads a 4x multisampled `BGR10_XR` attachment and draws announces +/// `extended-range-bits-kept` once, naming color 0: the attachment keeps the bits its draws do not +/// write, which Metal's pass rewrites in each tile a draw reaches. #[test] fn a_multisampled_extended_range_color_keeps_its_unused_bits_and_says_so() { let (messages, _cache, lane) = lane(); @@ -775,8 +772,7 @@ fn a_multisampled_extended_range_color_keeps_its_unused_bits_and_says_so() { descriptor.color_attachments[0] = Some(ColorAttachmentDescriptor::new(pf)); descriptor.raster_sample_count = 4; messages.restore_notices(notices); - let counts = assert_made_once(&messages, &EXTENDED_RANGE_BITS, &made(&lane, &[descriptor])); - assert!(!counts.contains_key(&UNREACHED_TILES[0]), "{counts:?}"); + assert_made_once(&messages, &EXTENDED_RANGE_BITS, &made(&lane, &[descriptor])); quiet(lane, &messages); } @@ -784,16 +780,13 @@ fn a_multisampled_extended_range_color_keeps_its_unused_bits_and_says_so() { /// buffers of words of all ones), every one loaded, of a state that writes white to color 0 /// under a write mask of none of its channels, on a device that asks for the kinds at every /// occurrence (`DeviceOptions::announce_each`), with a draw and an indirect command buffer's -/// execution of a draw: the load pass (`render/unused_bits_load.rs`) takes every color, so -/// `extended-range-bits-kept` is not announced, and the padded -/// colors' words are Metal's, every one `0xffc0` (Metal rewrites a padded attachment's words in -/// a loading pass that draws, the colors its function does not write too). The pass clears no -/// color, so `unreached-tiles-rewritten` is announced, naming the three. A pass that clears and -/// stores the padded colors announces none of the kinds: Metal's pass then rewrites every tile. One -/// that draws nothing announces nothing. +/// execution of a draw: `extended-range-bits-kept` is announced, naming the three loaded colors, +/// and the padded colors, which the function does not write, keep their bytes, the device's store +/// (Metal's pass leaves each word `0xffc0`, its low six bits zeroed). A pass that clears and +/// stores the padded colors names color 0 alone; one that draws nothing announces nothing. #[test] -fn a_pass_of_extended_range_and_padded_colors_names_unreached_tiles_unless_one_is_cleared() { - let kinds = [EXTENDED_RANGE_BITS[0], UNREACHED_TILES[0]]; +fn a_pass_of_extended_range_and_padded_colors_names_each_loaded_color() { + let kinds = [EXTENDED_RANGE_BITS[0]]; let (messages, _cache, lane) = lane_with(|options| options.announce_each = kinds.into_iter().collect()); let (w, h) = (WIDTH as u64, HEIGHT as u64); @@ -879,36 +872,41 @@ fn a_pass_of_extended_range_and_padded_colors_names_unreached_tiles_unless_one_i .unwrap(); messages.take_notices() }; - let notices = drawn(LoadAction::Load, true); - let announced = counts(¬ices); - assert!( - !announced.contains_key(&EXTENDED_RANGE_BITS[0]), - "{announced:?}" - ); - assert!(announced.contains_key(&UNREACHED_TILES[0]), "{announced:?}"); - for message in ¬ices { - let notice = message.degradation.as_ref().unwrap(); - if notice.degradation == UNREACHED_TILES[0] { - for color in ["color 0", "color 1", "color 2"] { - assert!(notice.object.contains(color), "{}", message.text); + // The colors each announcement names, of the passes' notices. + let named = |notices: &[DebugMessage]| -> Vec { + let colors = ["color 0", "color 1", "color 2"]; + let mut named = vec![false; colors.len()]; + for message in notices { + let notice = message.degradation.as_ref().unwrap(); + if notice.degradation != EXTENDED_RANGE_BITS[0] { + continue; + } + for (seen, color) in named.iter_mut().zip(colors) { + *seen |= notice.object.contains(color); } } - } + named + }; + let notices = drawn(LoadAction::Load, true); + assert!( + counts(¬ices).contains_key(&EXTENDED_RANGE_BITS[0]), + "{:?}", + counts(¬ices) + ); + assert_eq!(named(¬ices), [true, true, true]); for (pf, buffer) in padded.iter().zip(&buffers) { - let row = 2 * u64::from(ExtendedRange::of(*pf).unwrap().raw_components()) * w; let bytes = read_buffer(buffer, 0, bpr * h).unwrap(); for (y, line) in bytes.chunks(bpr as usize).enumerate() { - let (words, rest) = line.split_at(row as usize); assert!( - words.chunks(2).all(|word| word == [0xc0, 0xff]), + line.iter().all(|&b| b == 0xff), "{pf:?} row {y}: {:02x?}", - &words[..8] + &line[..8] ); - assert!(rest.iter().all(|&b| b == 0xff), "{pf:?} row {y}'s padding"); } } - let announced = counts(&drawn(LoadAction::Clear, true)); - assert!(announced.is_empty(), "{announced:?}"); + let notices = drawn(LoadAction::Clear, true); + assert!(!notices.is_empty(), "a pass of a loaded BGR10_XR color"); + assert_eq!(named(¬ices), [true, false, false]); let announced = counts(&drawn(LoadAction::Load, false)); assert!(announced.is_empty(), "{announced:?}"); quiet(lane, &messages); @@ -982,8 +980,9 @@ fn tile_read(held: [f32; 4]) -> [f32; 4] { /// to the source range and alpha to `[0, 1]` (`tile_read`; where the earlier model, /// each draw reading the codes the one before stored, differed from Metal at 3, 558 of 4, 096 /// texels of the probe's own such pass), and the store writes the last `half`'s encode as a -/// kernel's write (`ExtendedRange::clear_texel`); colors 1 and 2 keep their texels, color 2's color -/// words' top two bits zeroed as Metal's pass leaves them. The pipeline is made on every device: +/// kernel's write (`ExtendedRange::clear_texel`); colors 1 and 2 keep their bytes, the device's +/// store, where Metal's pass zeroes color 2's color words' top two bits (`extended-range-bits-kept` +/// says so, `render/tile_store.rs`). The pipeline is made on every device: /// one that fetches through the interlock writes the storage form and holds color 0's `half` shadow /// from the second draw on (`render/extended_shadow.rs`), one with raster-order attachment access /// reads an input attachment of the raw texels and writes the raw output, each draw reading the @@ -1131,13 +1130,9 @@ fn a_fetched_two_plane_attachment_written_unblended_stores_metals_write() { let count = (0..COUNT) .filter(|&i| got_words[i] != want_words[i] || got_alpha[i] != want_alpha[i]) .count(); - // Color 2, loaded and unwritten, keeps its codes and alpha bytes, its color words' top two - // bits zeroed as Metal's pass leaves each tile a draw reaches. - let canonical: Vec = other_plane - .chunks(4) - .flat_map(|w| (u32::from_le_bytes([w[0], w[1], w[2], w[3]]) & 0x3fff_ffff).to_le_bytes()) - .collect(); - let kept = lane.read(&other, (0, 0), 4, BlitOption::None) == canonical + // Color 2, loaded and unwritten, keeps its bytes, the device's store, where Metal's pass + // zeroes its color words' top two bits in each tile a draw reaches. + let kept = lane.read(&other, (0, 0), 4, BlitOption::None) == other_plane && alpha_of(&other) == other_alpha && lane.read(&covered, (0, 0), 4, BlitOption::None) == covered_texels; println!( diff --git a/crates/metal2vulkan-validation/src/runtime_lane/padded_loads.rs b/crates/metal2vulkan-validation/src/runtime_lane/padded_loads.rs index 2d0fca8fc..1c2e9f751 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/padded_loads.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/padded_loads.rs @@ -20,21 +20,17 @@ //! //! Metal's pass that loads such a texture and draws writes every word of its render area rounded //! up to 32 texels back, the words no fragment writes and the channels the mask leaves out as -//! the write of their code's read (`ExtendedRange::load_code`: their code with its low six bits -//! zeroed, an `_sRGB` twin's through Metal's table). The runtime rewrites them so before the -//! pass (`render/unused_bits_load.rs`), so every case is Metal's, and none announces -//! `extended-range-bits-kept` (once `padded-bits-kept`). (The probes' passes also cleared and -//! stored a second color attachment, under which Metal's pass rewrites every tile of the render -//! area, the tiles no draw reaches too. The lane's draw of no vertices and its scissored draw have -//! it too, since without it the first reaches no tile and the pass keeps every word, and the second -//! only the tiles its scissor rectangle overlaps; the lane's other passes have none, and their -//! draws reach every tile alike.) The device's work counts show the path ran: one load pass per -//! case that draws, none for the case that does not, over the region's texels -//! (`WorkCounts::unused_bits_load_passes` and `unused_bits_load_texels`). +//! the write of their code's read (their code with its low six bits zeroed, an `_sRGB` twin's +//! through Metal's table). The device's store keeps those words (`render/tile_store.rs`), and +//! every pass that draws announces `extended-range-bits-kept`: a case whose draw writes every +//! word is Metal's, and in every other case each word the draw does not write keeps its bytes. +//! (The probes' passes also cleared and stored a second color attachment, under which Metal's +//! pass rewrites every tile of the render area, the tiles no draw reaches too. The lane's draw of +//! no vertices and its scissored draw have it too, as the probes' did.) use super::degrade_notices::counts; use super::extended_range_targets::digest; -use super::resolves::{lane, quiet, Lane}; +use super::resolves::{lane_with, quiet, Lane}; use super::{buffer_with, read_buffer}; use crate::candidate::runtime_samples::{library, shape}; use metal2vulkan::metal::{ @@ -636,66 +632,82 @@ fn run(lane: &Lane, (pf, bits, pass): (PixelFormat, u64, Pass)) -> (Vec, boo (words, padded) } -/// The load passes case `pass` records and the texels they zero: none where it does not draw, -/// else one over its render area (the attachment's, or the smaller render target size) rounded -/// up to 32 texels a side, within the attachment. -fn loads(pass: Pass) -> (u64, u64) { - // The render area and the attachment's extent: a texture buffer's is its one row. - let ((w, h), within) = match pass { - Pass::Undrawn => return (0, 0), - Pass::TextureBuffer => ((WIDTH, 1), (WIDTH, 1)), - Pass::Sized(w, h) => ((w, h), (WIDTH, HEIGHT)), - _ => ((WIDTH, HEIGHT), (WIDTH, HEIGHT)), +/// Whether case `(bits, pass)`'s draw writes channel `c` of texel `(x, y)`: a channel its +/// write mask keeps (red 8, green 4), in a texel the draw covers (the whole texture, the scissor +/// rectangle, the smaller render target size, a texture buffer's one row; none for a draw of no +/// vertices or no draw). +fn writes((bits, pass): (u64, Pass), (x, y): (u64, u64), c: u64) -> bool { + let channel = [8, 4][c as usize]; + let covered = match pass { + Pass::Whole | Pass::Executed | Pass::ArrayView | Pass::ArrayViewOfOne => true, + Pass::Scissored => (37..37 + 54).contains(&x) && (13..13 + 57).contains(&y), + Pass::Sized(w, h) => x < w && y < h, + Pass::TextureBuffer => y == 0, + Pass::NoVertices | Pass::Undrawn => false, }; - let region = |side: u64, within: u64| side.next_multiple_of(32).min(within); - (1, region(w, within.0) * region(h, within.1)) + covered && bits & channel != 0 } -/// Every case's words are Metal's, the bytes between the rows stay, no case announces -/// `extended-range-bits-kept`, and each case that draws recorded one load pass over its region's texels -/// (the module docs). +/// Every case keeps the words its draw does not write and the bytes between the rows, a case +/// whose draw writes every word is Metal's, and every case that draws announces +/// `extended-range-bits-kept` (the module docs). #[test] -fn a_loading_pass_that_draws_leaves_metals_padded_words() { - let (messages, _cache, lane) = lane(); +fn a_loading_pass_that_draws_keeps_the_padded_words_it_does_not_write() { + let kept = Degradation::ExtendedRangeBitsKept; + let (messages, _cache, lane) = + lane_with(|options| options.announce_each = [kept].into_iter().collect()); let mut differ = Vec::new(); - let (mut passes, mut texels) = (0, 0); + let (mut whole, mut kept_words) = (0, 0); for case in METAL { let (pf, bits, pass, metal) = case; - let before = lane.device.work_counts(); - let (words, padded) = run(&lane, (pf, bits, pass)); - let after = lane.device.work_counts(); - let recorded = ( - after.unused_bits_load_passes - before.unused_bits_load_passes, - after.unused_bits_load_texels - before.unused_bits_load_texels, - ); - assert_eq!( - recorded, - loads(pass), - "{pf:?} {bits} {pass:?}: the load passes" - ); - passes += recorded.0; - texels += recorded.1; + let channels = match pf { + PixelFormat::R10UnormX6 | PixelFormat::R10UnormX6SRGB => 1, + _ => 2, + }; + let (got, padded) = run(&lane, (pf, bits, pass)); assert!( padded, "{pf:?} {bits} {pass:?}: the bytes between the rows changed" ); - let got = digest(&words); - if got != metal { - eprintln!("PADDED-LOADS-DIFFERS {pf:?} mask {bits} {pass:?}: {got}"); + let input = words(channels); + let mut every = true; + let mut moved = 0; + for (i, (g, w)) in got.chunks(2).zip(input.chunks(2)).enumerate() { + let i = i as u64; + let (texel, c) = (i / channels, i % channels); + if writes((bits, pass), (texel % WIDTH, texel / WIDTH), c) { + continue; + } + every = false; + kept_words += 1; + moved += u64::from(g != w); + } + if moved > 0 { + eprintln!("PADDED-LOADS-DIFFERS {pf:?} mask {bits} {pass:?}: {moved} words moved"); differ.push(case); } + if every { + whole += 1; + let got = digest(&got); + if got != metal { + eprintln!("PADDED-LOADS-DIFFERS {pf:?} mask {bits} {pass:?}: {got}"); + differ.push(case); + } + } let announced = counts(&messages.take_notices()); - assert!( - !announced.contains_key(&Degradation::ExtendedRangeBitsKept), + assert_eq!( + announced.contains_key(&kept), + pass != Pass::Undrawn, "{pf:?} {bits} {pass:?}: {announced:?}" ); } eprintln!( - "PADDED-LOADS {} cases, {} differ: {passes} load passes recorded, {texels} texels zeroed", + "PADDED-LOADS {} cases, {} differ: {whole} drawn whole against Metal's, {kept_words} \ + words kept", METAL.len(), differ.len() ); - assert!(passes > 0 && texels > 0, "no load pass ran"); + assert!(whole > 0 && kept_words > 0, "no case of either kind ran"); assert!( differ.is_empty(), "{} of {} cases differ: {differ:?}", diff --git a/crates/metal2vulkan-validation/src/runtime_lane/rgb10a2_srgb.rs b/crates/metal2vulkan-validation/src/runtime_lane/rgb10a2_srgb.rs index cdcb8428a..e1c4f7216 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/rgb10a2_srgb.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/rgb10a2_srgb.rs @@ -27,8 +27,9 @@ //! Metal stores `0x00000000` in each (`rgb10a2-srgb-stores-f` and `-h`). //! - **Loads.** A 1024 x 4 target holding every color code in each channel and each alpha code, //! loaded and stored by a pass whose draw writes another attachment alone: `load -//! `. Each color code moves as `R10Unorm_X6_sRGB`'s does (`ExtendedRange::load_code`, -//! the runtime's load pass), alpha's stays. +//! `. Each color code moves as `R10Unorm_X6_sRGB`'s does through Metal's table, alpha's +//! stays; the device's store keeps every code (`extended-range-bits-kept`), so the lane holds +//! it to the words loaded and prints Metal's digest beside it. //! //! The device's `isRGB10A2GammaSupported` answers as the texture's linear filter does. A //! difference is printed on an `RGB10A2-SRGB-DIFFERS` line. @@ -459,7 +460,7 @@ fn blit_words(lane: &Lane, target: &Texture, (width, height): (u64, u64)) -> Vec words(&read_buffer(&back, 0, length).unwrap()) } -/// Clears, a draw's stores and a loading pass's rewrite of a 586 attachment are Metal's. +/// Clears and a draw's stores of a 586 attachment are Metal's; a loading pass keeps its words. #[test] fn passes_clear_store_and_load_rgb10a2_srgb_as_metal_does() { let (messages, _cache, lane) = lane_with(|_| {}); @@ -653,8 +654,12 @@ fn passes_clear_store_and_load_rgb10a2_srgb_as_metal_does() { writeln!(text, "load {i} {b:08x} {a:08x}").unwrap(); } covers(&text, after.len(), "loads"); - if digest(&text) != LOADS { - wrong.push(format!("loads {} (Metal's {LOADS})", digest(&text))); + println!("RGB10A2-SRGB-LOADS {}: Metal's {LOADS}", digest(&text)); + if after != before { + let moved = before.iter().zip(&after).filter(|(b, a)| b != a).count(); + wrong.push(format!( + "loads: {moved} words moved, where the device's store keeps them" + )); } for line in &wrong { println!("RGB10A2-SRGB-DIFFERS {}: {line}", lane.device.name()); diff --git a/crates/metal2vulkan-validation/src/runtime_lane/rotated_textures.rs b/crates/metal2vulkan-validation/src/runtime_lane/rotated_textures.rs index 7ac1420ec..6177c1105 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/rotated_textures.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/rotated_textures.rs @@ -13,7 +13,8 @@ //! every tile of a pass that draws (announced once, `RotatedLoadTiles`) and none of one that does //! not, as Metal; a resolve lands as a store does; the bytes between the plane's rows stay. A //! rotated texture of a padded 10-bit or extended-range format that such a pass loads keeps its -//! codes with the bits they leave unused as Metal's tile store makes them. CPU access and blits +//! codes and the bits they leave unused, the device's store, where Metal's tile store makes those +//! bits canonical (announced, `ExtendedRangeBitsKept`). CPU access and blits //! address the plane as the texture's own extent at the plane's rows, turned or not, refused where //! those rows run past the buffer; a fragment's `read()` sees the stored frame unturned. A view of the texture in another 8-bit RGBA format acts as the //! texture does; other views are refused. The creators refuse what Metal asserts on, and the @@ -564,16 +565,15 @@ fn loads_of_rotation_4_land_mirrored_and_passes_without_draws_keep_every_texel() quiet(&messages); } -/// A texel of the rotated attachments [`unused_bits_of_rotated_textures_are_metals`] loads: the +/// A texel of the rotated attachments [`unused_bits_of_rotated_textures_are_kept`] loads: the /// format, its bytes, the write mask its draw takes, its bytes at the stored texel `(sx, sy)` -/// (codes naming the texel and channel, the bits they leave unused not Metal's), Metal's store -/// of those bytes, and its drawn texel's bytes, where the mask writes one. +/// (codes naming the texel and channel, the bits they leave unused not Metal's), and its drawn +/// texel's bytes, where the mask writes one. struct UnusedBitsCase { pf: PixelFormat, texel: u64, mask: ColorWriteMask, named: fn((u64, u64)) -> Vec, - stored: fn(&[u8]) -> Vec, drawn: Option>, } @@ -590,17 +590,9 @@ fn padded_named((sx, sy): (u64, u64), channels: u64) -> Vec { .collect() } -/// Metal's store of padded words: each word's low six bits zeroed. -fn padded_stored(bytes: &[u8]) -> Vec { - bytes - .chunks(2) - .flat_map(|w| (u16::from_le_bytes([w[0], w[1]]) & !0x3f).to_le_bytes()) - .collect() -} - /// The cases: `R10Unorm_X6` and `RG10Unorm_X12` drawn in codes 341 and 682 (the color /// `(1/3, 2/3, 0, 1)`, exactly), and `BGR10_XR` under an empty write mask, its bits 30 and 31 -/// zero or one by texel (Metal's store sets them). +/// zero or one by texel (Metal's store would set them). fn unused_bits_cases() -> [UnusedBitsCase; 3] { [ UnusedBitsCase { @@ -608,7 +600,6 @@ fn unused_bits_cases() -> [UnusedBitsCase; 3] { texel: 2, mask: ColorWriteMask::ALL, named: |at| padded_named(at, 1), - stored: padded_stored, drawn: Some((341u16 << 6).to_le_bytes().to_vec()), }, UnusedBitsCase { @@ -616,7 +607,6 @@ fn unused_bits_cases() -> [UnusedBitsCase; 3] { texel: 4, mask: ColorWriteMask::ALL, named: |at| padded_named(at, 2), - stored: padded_stored, drawn: Some( [341u16 << 6, 682 << 6] .iter() @@ -633,10 +623,6 @@ fn unused_bits_cases() -> [UnusedBitsCase; 3] { let top = (sx + 2 * sy) % 4; ((top << 30 | codes) as u32).to_le_bytes().to_vec() }, - stored: |bytes| { - let word = u32::from_le_bytes([bytes[0], bytes[1], bytes[2], bytes[3]]); - (word | 0xc000_0000).to_le_bytes().to_vec() - }, drawn: None, }, ] @@ -645,28 +631,21 @@ fn unused_bits_cases() -> [UnusedBitsCase; 3] { /// Rotated textures of `R10Unorm_X6`, `RG10Unorm_X12` and `BGR10_XR` ([`unused_bits_cases`]), of /// every rotation, a frame of one 32x32 tile and one of two each way, over planes whose texels /// name their stored position: a pass that loads the texture and draws its top-left 8x4 texels -/// stores the drawn texels where the mask writes them and leaves every other texel's codes where -/// a load and a store put them (at rotation 4 the mirror [`loaded_from`] gives), the bits they -/// leave unused as Metal's store makes them (a padded word's low six bits zeroed, `BGR10_XR`'s bits -/// 30 and 31 set), the bytes between rows kept. That is Metal's store in each tile the draw -/// reaches (on an M4 and the consumer's runs of them on an M3 Max; the -/// turns): the runtime rewrites the twin of the pass's frame after its copy in, so no pass -/// announces `extended-range-bits-kept`. In a frame of two tiles the one the draw does not reach is -/// rewritten as well, where Metal keeps its texels' bytes (`unreached-tiles-rewritten`, announced -/// by each such pass), but where capture replay found the draw's reach (a texture that is not a -/// rotated frame, once its capture form is made): that pass keeps it, Metal's answer, and announces -/// nothing. +/// stores the drawn texels where the mask writes them and leaves every other texel's bytes where +/// a load and a store put them (at rotation 4 the mirror [`loaded_from`] gives), the bits their +/// codes leave unused as they were, the bytes between rows kept: the device's store, where +/// Metal's makes those bits canonical in each tile the draw reaches (a padded word's low six bits +/// zeroed, `BGR10_XR`'s bits 30 and 31 set). Each pass announces `extended-range-bits-kept`. #[test] -fn unused_bits_of_rotated_textures_are_metals() { - use super::extended_range_blends::{EXTENDED_RANGE_BITS, UNREACHED_TILES}; +fn unused_bits_of_rotated_textures_are_kept() { + use super::extended_range_blends::EXTENDED_RANGE_BITS; let cache = ScratchCache::new().unwrap(); let messages = Messages::default(); // Each pass's announcement says which reach it took (below). let device = validated_device_with(TEST_DEVICE, &messages, cache.path(), |options| { - options.announce_each = UNREACHED_TILES.into_iter().collect(); + options.announce_each = EXTENDED_RANGE_BITS.into_iter().collect(); }) .unwrap(); - let mut announced = 0; let lane = Lane::new(&device); let color: Vec = [1.0f32 / 3.0, 2.0 / 3.0, 0.0, 1.0] .iter() @@ -695,7 +674,7 @@ fn unused_bits_of_rotated_textures_are_metals() { for sx in 0..sw { put(&mut before, (sx, sy), &(case.named)((sx, sy))); let from = loaded_from(rotation, sw, (sx, sy)); - put(&mut want, (sx, sy), &(case.stored)(&(case.named)(from))); + put(&mut want, (sx, sy), &(case.named)(from)); } } if let Some(drawn) = &case.drawn { @@ -727,39 +706,19 @@ fn unused_bits_of_rotated_textures_are_metals() { command_buffer.commit().unwrap(); command_buffer.wait_until_completed_for(WAIT).unwrap(); assert_eq!(command_buffer.status(), CommandBufferStatus::Completed); - // A pass whose draws' reach capture replay found (a texture that is not a - // rotated frame, once its capture form is made: `render/capture.rs`) rewrites the - // tile the draw reaches alone and keeps every other texel's bytes, Metal's answer; - // one that announces rewrites every tile. let counted = super::degrade_notices::counts(&messages.take_notices()); assert_eq!( counted.get(&EXTENDED_RANGE_BITS[0]), - None, + Some(&1), "{what}: {counted:?}" ); - let reached = |(x, y): (u64, u64)| x < 32 && y < 32; - if counted.contains_key(&UNREACHED_TILES[0]) { - announced += 1; - } else { - let mut exact = before.clone(); - for y in 0..h { - for x in (0..w).filter(|&x| reached((x, y))) { - let (sx, sy) = stored_at(rotation, (w, h), (x, y)); - let at = (sy * bpr + sx * case.texel) as usize; - let texel = at..at + case.texel as usize; - exact[texel.clone()].copy_from_slice(&want[texel]); - } - } - want = exact; - } if let Some(at) = first_difference(&bytes_of(&plane), &want, bpr) { panic!("{what}: {at} (texels counted as 4 bytes)"); } - eprintln!("ROTATED-UNUSED-BITS {what}: Metal's bytes"); + eprintln!("ROTATED-UNUSED-BITS {what}: the kept bytes"); } } } - assert!(announced > 0, "a frame of two tiles announces"); quiet(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/snorm_tile_store.rs b/crates/metal2vulkan-validation/src/runtime_lane/snorm_tile_store.rs index 451784680..b9aaa4ed2 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/snorm_tile_store.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/snorm_tile_store.rs @@ -11,7 +11,7 @@ //! //! The runtime keeps the device's load and store, so the texels keep their codes and words, and //! a draw in such a pass announces `snorm-minimum-kept` or `shared-exponent-kept`, naming the -//! attachment, with no load pass. On a driver whose pass stores them as Metal's +//! attachment. On a driver whose pass stores them as Metal's //! (`DriverFact::TileStoreIsMetals`: MoltenVK, whose pass is a Metal pass) the texels take Metal's //! codes and words, and nothing is announced. @@ -113,17 +113,11 @@ fn metals_store(lane: &Lane) -> bool { .contains(&DriverFact::TileStoreIsMetals) } -/// The load passes the lane's device recorded so far. -fn load_passes(lane: &Lane) -> u64 { - lane.device.work_counts().unused_bits_load_passes -} - /// A pass that loads a 4² target of each signed normalized format holding the minimum code in -/// every channel and draws under a write mask of none of its channels, recording no load pass: -/// where the device's store is Metal's, every texel takes the code above and nothing is +/// every channel and draws under a write mask of none of its channels: where the device's store is Metal's, every texel takes the code above and nothing is /// announced; else every code stays and `snorm-minimum-kept` is announced once (the device asks /// for it at each occurrence), naming color 0 and its format. A pass that loads the minimum codes -/// again and draws nothing keeps every one, records no load pass and announces nothing, as +/// again and draws nothing keeps every one and announces nothing, as /// Metal's keeps every texel. #[test] fn a_drawing_pass_keeps_a_snorm_minimum_code_and_says_so() { @@ -138,15 +132,12 @@ fn a_drawing_pass_keeps_a_snorm_minimum_code_and_says_so() { .new_render_pipeline_state(&unwritten(&lane, pf), &PipelineOptions::default()) .unwrap(); let (t, bytes) = minimum_codes(&lane, pf, texel, code); - let before = load_passes(&lane); lane.run(&pass(&t, LoadAction::Load), |l, e, h| { l.draw(e, h, &pipeline, 0.5) }) .unwrap(); - let loads = load_passes(&lane) - before; let got = lane.read(&t, (0, 0), texel, BlitOption::None); let notices = messages.take_notices(); - assert_eq!(loads, 0, "{pf:?}: load passes"); if metals { let raised = filled(texel, above); assert!(got == raised, "{pf:?}: not Metal's codes: {got:02x?}"); @@ -166,13 +157,7 @@ fn a_drawing_pass_keeps_a_snorm_minimum_code_and_says_so() { assert!(named, "{pf:?}: the notice names no color 0"); } upload(&t, texel, &bytes); - let before = load_passes(&lane); lane.run(&pass(&t, LoadAction::Load), |_, _, _| {}).unwrap(); - assert_eq!( - load_passes(&lane), - before, - "{pf:?}: a pass of no draw's load pass" - ); let got = lane.read(&t, (0, 0), texel, BlitOption::None); assert!( got == bytes, @@ -189,7 +174,7 @@ fn a_drawing_pass_keeps_a_snorm_minimum_code_and_says_so() { /// A pass that loads a 4² `RGB9E5Float` target whose every word is unnormalized (mantissas 1, 2 /// and 3 under the exponent 20: its largest mantissa below 256) and draws under a write mask of -/// none of its channels, recording no load pass: where the device's store is Metal's, every word +/// none of its channels: where the device's store is Metal's, every word /// takes Metal's (mantissas 128, 256 and 384 under the exponent 13) and nothing is announced; /// else every word stays and `shared-exponent-kept` is announced once (the device asks for it at /// each occurrence), naming color 0 and its format. A pass that loads it and draws nothing @@ -232,15 +217,12 @@ fn a_drawing_pass_keeps_an_unnormalized_shared_exponent_word_and_says_so() { let bytes = word.to_le_bytes().repeat((SIZE * SIZE) as usize); t.replace_region(Region::new_2d(0, 0, SIZE, SIZE), 0, 0, &bytes, 4 * SIZE, 0) .unwrap(); - let before = load_passes(&lane); lane.run(&pass(&t, LoadAction::Load), |l, e, h| { l.draw(e, h, &pipeline, 0.5) }) .unwrap(); - let loads = load_passes(&lane) - before; let got = lane.read(&t, (0, 0), 4, BlitOption::None); let notices = messages.take_notices(); - assert_eq!(loads, 0, "{pf:?} on {name}: load passes"); if metals { let normalized = metal.to_le_bytes().repeat((SIZE * SIZE) as usize); assert!( diff --git a/crates/metal2vulkan-validation/src/runtime_lane/tile_reach_kernel.rs b/crates/metal2vulkan-validation/src/runtime_lane/tile_reach_kernel.rs deleted file mode 100644 index 17287e13d..000000000 --- a/crates/metal2vulkan-validation/src/runtime_lane/tile_reach_kernel.rs +++ /dev/null @@ -1,656 +0,0 @@ -//! The tile reach kernel (`bind::tile_reach_module`) on the device the cfg selects, under the -//! validation layer. Each pass of the product's fixture -//! (`fixtures/public/tile_reach/device_passes.txt`: every measured case drawn, each in a slice of -//! its own, and seeded random passes, with the rule's answers; the product's -//! `bind::tile_reach::tests::device` checks it is the rule's, and the kernel's through the CPU -//! interpreter) is dispatched on the device's own `VkQueue` (`CommandQueue::with_vk_queue`), over -//! three of the runtime's `Shared` buffers: the primitives, the header and states, and the mask, -//! cleared. Its mask's set bits and the header's two counts are the rule's, bit for bit. A device -//! without `shaderInt64` is refused `Feature::TileReach`, printed. -//! -//! The kernel's cost on a large pass is measured and printed (`TILEREACH-TIME`), not judged: two -//! seeded passes over a 3840 by 2160 target, a mesh of 18,432 triangles tiling it and a scatter of -//! 16,384 triangles, lines and points of every size. Each pass first runs 64 times back to back in -//! one submission, so the GPU leaves its idle clocks, and then 21 times alone and 32 times back to -//! back, timed by GPU timestamps about the dispatches where the queue writes them and by the -//! host's time from the submission to its fence; a pass of no primitives gives the dispatch's own -//! cost. - -use super::degrade_notices::on_device; -use super::{buffer_with, read_buffer}; -use crate::candidate::LoaderWord; -use crate::gpu::wait::{self, SubmissionBackend}; -use crate::gpu::TEST_DEVICE; -use ash::vk; -use metal2vulkan::bind::{tile_reach_module, TileReachModule as M}; -use metal2vulkan::error::{Error as TranslateError, Feature}; -use metal2vulkan_runtime::{Buffer, CommandQueue, Device}; -use std::time::{Duration, Instant}; - -/// The product's fixture (the module docs). -const FIXTURE: &str = include_str!("../../fixtures/public/tile_reach/device_passes.txt"); - -/// One pass of the fixture: the header's fields, the states' and primitives' words, and the -/// rule's answer. -#[derive(Debug, Default)] -struct Case { - area: [u32; 2], - samples: u32, - layers: u32, - states: Vec, - primitives: Vec, - near_far: u32, - unmeasured: u32, - bits: Vec, -} - -impl Case { - fn count(&self) -> u32 { - (self.primitives.len() / M::PRIMITIVE_WORDS as usize) as u32 - } - - /// The pass buffer's bytes: the header, then the states. - fn pass_bytes(&self) -> Vec { - let header = M::header(self.area, self.samples, self.layers, self.count()); - let states = self.states.iter().flat_map(|w| w.to_le_bytes()); - header.into_iter().chain(states).collect() - } -} - -/// The fixture's passes, in order. -fn cases() -> Vec { - let mut cases: Vec = Vec::new(); - let number = |s: &str| s.parse::().expect("a number"); - let word = |s: &str| u32::from_str_radix(s, 16).expect("a hex word"); - for line in FIXTURE.lines().filter(|l| !l.starts_with('#')) { - let mut fields = line.split_whitespace(); - let tag = fields.next().expect("a tag"); - let rest: Vec<&str> = fields.collect(); - if tag == "pass" { - let [w, h, samples, layers] = [0, 1, 2, 3].map(|i| number(rest[i])); - cases.push(Case { - area: [w, h], - samples, - layers, - ..Case::default() - }); - continue; - } - let case = cases.last_mut().expect("a pass first"); - match tag { - "state" => case.states.extend(rest.iter().map(|s| word(s))), - "primitive" => case.primitives.extend(rest.iter().map(|s| word(s))), - "expect" => [case.near_far, case.unmeasured] = [0, 1].map(|i| number(rest[i])), - "bits" => case.bits.extend(rest.iter().map(|s| number(s))), - other => panic!("an unknown line {other:?}"), - } - } - cases -} - -/// The test's Vulkan objects on the runtime's device: the kernel's pipeline, a descriptor set of -/// its three storage buffers, a command buffer, a fence and two timestamp queries. Destroyed on -/// drop, after its last submission was waited for. -struct Kernel { - driver: ash::Device, - word: LoaderWord, - module: vk::ShaderModule, - set_layout: vk::DescriptorSetLayout, - layout: vk::PipelineLayout, - pipeline: vk::Pipeline, - descriptors: vk::DescriptorPool, - set: vk::DescriptorSet, - pool: vk::CommandPool, - buffer: vk::CommandBuffer, - fence: vk::Fence, - queries: vk::QueryPool, - /// The queue family's `timestampValidBits` (0: it writes none) and the device's - /// `timestampPeriod`, nanoseconds a tick. - stamp_bits: u32, - period: f64, -} - -/// What one dispatch took: the host's time from its submission to its fence, and the GPU's -/// between the timestamps about it, where the queue writes them. -#[derive(Clone, Copy, Debug)] -struct Took { - wall: Duration, - gpu: Option, -} - -impl Kernel { - /// Made on `device` before it submitted anything, so the loader word is the device's own. - fn new(device: &Device, spirv: &[u32]) -> Kernel { - // SAFETY: read while the device lives; the objects are destroyed in `drop`, before it. - let raw = unsafe { device.raw() }; - let driver = raw.device.clone(); - // SAFETY: the handle is the live device's. - let word = unsafe { LoaderWord::of_device(driver.handle()) }; - let info = vk::ShaderModuleCreateInfo::default().code(spirv); - // SAFETY: the device is live; `info` points at the module's words for the call. - let module = unsafe { driver.create_shader_module(&info, None) }.unwrap(); - let bindings = [M::PRIMITIVES_BINDING, M::PASS_BINDING, M::TILES_BINDING].map(|binding| { - vk::DescriptorSetLayoutBinding::default() - .binding(binding) - .descriptor_type(vk::DescriptorType::STORAGE_BUFFER) - .descriptor_count(1) - .stage_flags(vk::ShaderStageFlags::COMPUTE) - }); - let info = vk::DescriptorSetLayoutCreateInfo::default().bindings(&bindings); - // SAFETY: the device is live. - let set_layout = unsafe { driver.create_descriptor_set_layout(&info, None) }.unwrap(); - let set_layouts = [set_layout]; - let info = vk::PipelineLayoutCreateInfo::default().set_layouts(&set_layouts); - // SAFETY: the device is live. - let layout = unsafe { driver.create_pipeline_layout(&info, None) }.unwrap(); - let stage = vk::PipelineShaderStageCreateInfo::default() - .stage(vk::ShaderStageFlags::COMPUTE) - .module(module) - .name(c"main"); - let info = vk::ComputePipelineCreateInfo::default() - .stage(stage) - .layout(layout); - // SAFETY: the device is live; every pointer in `info` outlives the call. - let pipeline = - unsafe { driver.create_compute_pipelines(vk::PipelineCache::null(), &[info], None) } - .map_err(|(_, error)| error) - .unwrap()[0]; - let sizes = [vk::DescriptorPoolSize::default() - .ty(vk::DescriptorType::STORAGE_BUFFER) - .descriptor_count(3)]; - let info = vk::DescriptorPoolCreateInfo::default() - .max_sets(1) - .pool_sizes(&sizes); - // SAFETY: the device is live. - let descriptors = unsafe { driver.create_descriptor_pool(&info, None) }.unwrap(); - let info = vk::DescriptorSetAllocateInfo::default() - .descriptor_pool(descriptors) - .set_layouts(&set_layouts); - // SAFETY: the device is live; the pool holds one set of the layout's. - let set = unsafe { driver.allocate_descriptor_sets(&info) }.unwrap()[0]; - let info = vk::CommandPoolCreateInfo::default() - .queue_family_index(raw.queue_family) - .flags(vk::CommandPoolCreateFlags::RESET_COMMAND_BUFFER); - // SAFETY: the device is live; the pool is the test's own. - let pool = unsafe { driver.create_command_pool(&info, None) }.unwrap(); - let allocation = vk::CommandBufferAllocateInfo::default() - .command_pool(pool) - .level(vk::CommandBufferLevel::PRIMARY) - .command_buffer_count(1); - // SAFETY: the device is live; the loader serves the call after the word is put back. - let buffer = unsafe { - word.restore(); - #[expect( - clippy::disallowed_methods, - reason = "the runtime's device, after the loader word is put back" - )] - let buffer = driver.allocate_command_buffers(&allocation); - buffer - } - .unwrap()[0]; - // SAFETY: the device is live. - let fence = unsafe { driver.create_fence(&vk::FenceCreateInfo::default(), None) }.unwrap(); - let info = vk::QueryPoolCreateInfo::default() - .query_type(vk::QueryType::TIMESTAMP) - .query_count(2); - // SAFETY: the device is live. - let queries = unsafe { driver.create_query_pool(&info, None) }.unwrap(); - // SAFETY: instance-level queries of the live device's physical device. - let (stamp_bits, period) = unsafe { - let families = raw - .instance - .get_physical_device_queue_family_properties(raw.physical_device); - let limits = raw - .instance - .get_physical_device_properties(raw.physical_device) - .limits; - ( - families[raw.queue_family as usize].timestamp_valid_bits, - f64::from(limits.timestamp_period), - ) - }; - Kernel { - driver, - word, - module, - set_layout, - layout, - pipeline, - descriptors, - set, - pool, - buffer, - fence, - queries, - stamp_bits, - period, - } - } - - /// Bind `buffers` (primitives, pass, mask), dispatch `groups` workgroups `times` times back - /// to back (a barrier between) on `queue`'s `VkQueue` and wait for them: the mask and the - /// counts are then the host's to read. The times taken are the whole submission's. - fn run(&self, queue: &CommandQueue, buffers: [&Buffer; 3], groups: u32, times: u32) -> Took { - let driver = &self.driver; - let infos = buffers.map(|b| { - // SAFETY: the buffer lives past the submission, which is waited for below. - let (handle, offset) = unsafe { b.vk_buffer() }; - [vk::DescriptorBufferInfo::default() - .buffer(handle) - .offset(offset) - .range(b.length())] - }); - let bindings = [M::PRIMITIVES_BINDING, M::PASS_BINDING, M::TILES_BINDING]; - let writes: Vec> = (0..3) - .map(|i| { - vk::WriteDescriptorSet::default() - .dst_set(self.set) - .dst_binding(bindings[i]) - .descriptor_type(vk::DescriptorType::STORAGE_BUFFER) - .buffer_info(&infos[i]) - }) - .collect(); - let after = vk::MemoryBarrier::default() - .src_access_mask(vk::AccessFlags::SHADER_WRITE) - .dst_access_mask(vk::AccessFlags::HOST_READ); - let begin = vk::CommandBufferBeginInfo::default() - .flags(vk::CommandBufferUsageFlags::ONE_TIME_SUBMIT); - // SAFETY: the set and the command buffer are the test's own and not in use (the last - // submission was waited for); the buffers are live and no work of the runtime's touches - // them (the host wrote them, which the submission makes visible). - unsafe { - driver.update_descriptor_sets(&writes, &[]); - driver.begin_command_buffer(self.buffer, &begin).unwrap(); - driver.cmd_reset_query_pool(self.buffer, self.queries, 0, 2); - driver.cmd_bind_pipeline(self.buffer, vk::PipelineBindPoint::COMPUTE, self.pipeline); - driver.cmd_bind_descriptor_sets( - self.buffer, - vk::PipelineBindPoint::COMPUTE, - self.layout, - M::SET, - &[self.set], - &[], - ); - let top = vk::PipelineStageFlags::TOP_OF_PIPE; - driver.cmd_write_timestamp(self.buffer, top, self.queries, 0); - for at in 0..times { - if at > 0 { - let between = vk::MemoryBarrier::default() - .src_access_mask(vk::AccessFlags::SHADER_WRITE) - .dst_access_mask( - vk::AccessFlags::SHADER_READ | vk::AccessFlags::SHADER_WRITE, - ); - let compute = vk::PipelineStageFlags::COMPUTE_SHADER; - driver.cmd_pipeline_barrier( - self.buffer, - compute, - compute, - vk::DependencyFlags::empty(), - &[between], - &[], - &[], - ); - } - driver.cmd_dispatch(self.buffer, groups, 1, 1); - } - let bottom = vk::PipelineStageFlags::BOTTOM_OF_PIPE; - driver.cmd_write_timestamp(self.buffer, bottom, self.queries, 1); - driver.cmd_pipeline_barrier( - self.buffer, - vk::PipelineStageFlags::COMPUTE_SHADER, - vk::PipelineStageFlags::HOST, - vk::DependencyFlags::empty(), - &[after], - &[], - &[], - ); - driver.end_command_buffer(self.buffer).unwrap(); - } - let buffers = [self.buffer]; - let submit = vk::SubmitInfo::default().command_buffers(&buffers); - let submitted = Instant::now(); - // SAFETY: the command buffer is executable and the fence unsignaled; the submission is - // made under the runtime's lock of its `VkQueue`, and the call waits for nothing. - unsafe { - queue.with_vk_queue(|raw, _| driver.queue_submit(raw, &[submit], self.fence).unwrap()); - } - let backend = SubmissionBackend::vulkan(TEST_DEVICE); - let operation = "the tile reach kernel's dispatch"; - wait::vulkan::wait_for_fence(driver, self.fence, backend, operation).unwrap(); - let wall = submitted.elapsed(); - let gpu = (self.stamp_bits > 0).then(|| { - let mut stamps = [0u64; 2]; - // SAFETY: the submission that wrote both queries completed. - unsafe { - driver.get_query_pool_results( - self.queries, - 0, - &mut stamps, - vk::QueryResultFlags::TYPE_64, - ) - } - .unwrap(); - let mask = match self.stamp_bits { - 64.. => u64::MAX, - bits => (1 << bits) - 1, - }; - let ticks = stamps[1].wrapping_sub(stamps[0]) & mask; - Duration::from_nanos((ticks as f64 * self.period).round() as u64) - }); - // SAFETY: the submission completed: the fence and the command buffer are free. - unsafe { - driver.reset_fences(&[self.fence]).unwrap(); - driver - .reset_command_buffer(self.buffer, vk::CommandBufferResetFlags::empty()) - .unwrap(); - } - Took { wall, gpu } - } -} - -impl Drop for Kernel { - fn drop(&mut self) { - // SAFETY: nothing of the test's is pending (each submission was waited for). - unsafe { - self.word.restore(); - self.driver.destroy_query_pool(self.queries, None); - self.driver.destroy_fence(self.fence, None); - self.driver.destroy_command_pool(self.pool, None); - self.driver.destroy_descriptor_pool(self.descriptors, None); - self.driver.destroy_pipeline(self.pipeline, None); - self.driver.destroy_pipeline_layout(self.layout, None); - self.driver - .destroy_descriptor_set_layout(self.set_layout, None); - self.driver.destroy_shader_module(self.module, None); - } - } -} - -/// The set bits of little-endian mask words. -fn set_bits(bytes: &[u8]) -> Vec { - let mut bits = Vec::new(); - for (i, w) in bytes.as_chunks::<4>().0.iter().enumerate() { - let w = u32::from_le_bytes(*w); - bits.extend( - (0..32) - .filter(|b| w >> b & 1 == 1) - .map(|b| 32 * i as u32 + b), - ); - } - bits -} - -/// Every pass of the fixture binned on the device: its mask's set bits and the header's near-far -/// and unmeasured counts are the rule's (the module docs). -#[test] -fn the_tile_reach_kernel_bins_the_fixture_as_the_rule_does() { - on_device(|device, _messages| { - let module = match tile_reach_module(device.compile_device()) { - Ok(module) => module, - Err(TranslateError::Unsupported(u)) if u.feature == Feature::TileReach => { - eprintln!("TILEREACH: refused on a device without shaderInt64: {u:?}"); - return; - } - Err(error) => panic!("tile_reach_module: {error}"), - }; - let kernel = Kernel::new(device, &module.spirv); - let queue = device.new_command_queue().unwrap(); - let cases = cases(); - let mut wrong = Vec::new(); - let mut primitives = 0; - for (at, case) in cases.iter().enumerate() { - let prims: Vec = case - .primitives - .iter() - .flat_map(|w| w.to_le_bytes()) - .collect(); - let words = M::mask_words(case.area, case.samples, case.layers).max(1) as usize; - let prims = buffer_with(device, &prims).unwrap(); - let pass = buffer_with(device, &case.pass_bytes()).unwrap(); - let tiles = buffer_with(device, &vec![0; 4 * words]).unwrap(); - let groups = case.count().div_ceil(M::LOCAL_SIZE).max(1); - kernel.run(&queue, [&prims, &pass, &tiles], groups, 1); - let header = read_buffer(&pass, 0, 4 * u64::from(M::HEADER_WORDS)).unwrap(); - let count = |w: u32| { - let at = 4 * w as usize; - u32::from_le_bytes(header[at..at + 4].try_into().expect("a word")) - }; - let mask = read_buffer(&tiles, 0, 4 * words as u64).unwrap(); - let got = ( - count(M::NEAR_FAR_WORD), - count(M::UNMEASURED_WORD), - set_bits(&mask), - ); - let want = (case.near_far, case.unmeasured, case.bits.clone()); - if got != want { - let differ: Vec<_> = got - .2 - .iter() - .filter(|b| !want.2.contains(b)) - .chain(want.2.iter().filter(|b| !got.2.contains(b))) - .take(16) - .collect(); - wrong.push(format!( - "pass {at} ({:?}, {} samples): counts {:?}, the rule's {:?}; bits differing \ - (first 16) {differ:?}", - case.area, - case.samples, - (got.0, got.1), - (want.0, want.1) - )); - } - primitives += case.count(); - } - assert!(wrong.is_empty(), "{}", wrong.join("\n")); - eprintln!( - "TILEREACH: {} passes, {primitives} primitives: the rule's on {}", - cases.len(), - device.name() - ); - }); -} - -/// The timed passes' target (the module docs). -const TARGET: [u32; 2] = [3840, 2160]; - -/// A seeded generator (splitmix64) of the timed passes. -struct Seeded(u64); - -impl Seeded { - fn next(&mut self) -> u64 { - self.0 = self.0.wrapping_add(0x9e37_79b9_7f4a_7c15); - let mut z = self.0; - z = (z ^ (z >> 30)).wrapping_mul(0xbf58_476d_1ce4_e5b9); - z = (z ^ (z >> 27)).wrapping_mul(0x94d0_49bb_1331_11eb); - z ^ (z >> 31) - } - - /// A value in `[lo, hi)`. - fn within(&mut self, lo: f64, hi: f64) -> f64 { - lo + (hi - lo) * (self.next() >> 11) as f64 / (1u64 << 53) as f64 - } -} - -/// The clip-space position of the target's pixel `(x, y)` at `w` and depth `z / w` (the whole -/// target's viewport). -fn clip_at(x: f64, y: f64, z: f64, w: f64) -> [f32; 4] { - let [tw, th] = TARGET.map(f64::from); - let xn = 2.0 * x / tw - 1.0; - let yn = 1.0 - 2.0 * y / th; - [(xn * w) as f32, (yn * w) as f32, (z * w) as f32, w as f32] -} - -/// A timed pass: its primitives' and its pass buffer's bytes, and its count. -struct Large { - what: &'static str, - prims: Vec, - count: u32, -} - -impl Large { - /// The pass buffer: the header and the one state (the whole target, no culling, depth - /// clipped), of `count` primitives. - fn pass_bytes(&self, count: u32) -> Vec { - let [w, h] = TARGET; - let viewport = [0.0, 0.0, w as f32, h as f32]; - let state = M::state(viewport, [0, 0, w, h], 0, 0, 0); - let header = M::header(TARGET, 1, 1, count); - header.into_iter().chain(state).collect() - } -} - -/// A mesh of two triangles a cell of 30 by 30 pixels tiling the target, its depth `w` rising -/// from 1 to 4 across it. -fn mesh() -> Large { - let (cols, rows) = (TARGET[0] / 30, TARGET[1] / 30); - let corner = |c: u32, r: u32| { - let w = 1.0 + 3.0 * f64::from(c) / f64::from(cols); - clip_at(f64::from(30 * c), f64::from(30 * r), 0.5, w) - }; - let mut prims = Vec::new(); - for r in 0..rows { - for c in 0..cols { - let [a, b, d, e] = [ - corner(c, r), - corner(c + 1, r), - corner(c, r + 1), - corner(c + 1, r + 1), - ]; - prims.extend(M::primitive(M::TRIANGLE, 0, 0, 0.0, [a, b, d])); - prims.extend(M::primitive(M::TRIANGLE, 0, 0, 0.0, [b, e, d])); - } - } - Large { - what: "mesh", - count: 2 * cols * rows, - prims, - } -} - -/// 16,384 primitives about the target and past its edges: nine in ten triangles of sides from -/// one pixel to 400 (3% across the near plane), the rest lines and points, at depths `w` from -/// 0.5 to 8. -fn scatter() -> Large { - let mut rng = Seeded(0x7111_e7e5); - let count = 16_384; - let [tw, th] = TARGET.map(f64::from); - let mut prims = Vec::new(); - for _ in 0..count { - let (cx, cy) = (rng.within(-64.0, tw + 64.0), rng.within(-64.0, th + 64.0)); - let size = rng.within(0.0, 400f64.ln()).exp(); - let w = rng.within(0.5, 8.0); - let kind = rng.within(0.0, 1.0); - let crossing = rng.within(0.0, 1.0) < 0.03; - let mut vertex = |z: f64| { - let x = cx + size * rng.within(-1.0, 1.0); - let y = cy + size * rng.within(-1.0, 1.0); - clip_at(x, y, z, w) - }; - let prim = if kind < 0.9 { - let first = vertex(if crossing { -0.3 } else { 0.5 }); - M::primitive(M::TRIANGLE, 0, 0, 0.0, [first, vertex(0.5), vertex(0.5)]) - } else if kind < 0.95 { - let ends = [vertex(0.5), vertex(0.5)]; - M::primitive(M::LINE, 0, 0, 0.0, [ends[0], ends[1], [0.0; 4]]) - } else { - let at = vertex(0.5); - let size = rng.within(1.0, 64.0) as f32; - M::primitive(M::POINT, 0, 0, size, [at, [0.0; 4], [0.0; 4]]) - }; - prims.extend(prim); - } - Large { - what: "scatter", - count, - prims, - } -} - -/// The median and the least of `durations`, in microseconds. -fn spread(mut durations: Vec) -> (f64, f64) { - durations.sort(); - let us = |d: Duration| d.as_secs_f64() * 1e6; - (us(durations[durations.len() / 2]), us(durations[0])) -} - -/// The kernel's cost on the large passes (the module docs): printed, `TILEREACH-TIME`. -#[test] -fn the_tile_reach_kernel_times_a_large_pass() { - const WARM: u32 = 64; - const RUNS: usize = 21; - const BATCH: u32 = 32; - on_device(|device, _messages| { - let module = match tile_reach_module(device.compile_device()) { - Ok(module) => module, - Err(TranslateError::Unsupported(u)) if u.feature == Feature::TileReach => { - eprintln!("TILEREACH-TIME: refused on a device without shaderInt64: {u:?}"); - return; - } - Err(error) => panic!("tile_reach_module: {error}"), - }; - let kernel = Kernel::new(device, &module.spirv); - let queue = device.new_command_queue().unwrap(); - let words = M::mask_words(TARGET, 1, 1) as usize; - let tiles = TARGET[0].div_ceil(32) * TARGET[1].div_ceil(32); - for large in [mesh(), scatter()] { - let prims = buffer_with(device, &large.prims).unwrap(); - for (count, what) in [(0, "none"), (large.count, large.what)] { - let mut walls = Vec::with_capacity(RUNS); - let mut gpus = Vec::with_capacity(RUNS); - let mut reached = (0, 0, 0); - let groups = count.div_ceil(M::LOCAL_SIZE).max(1); - let mask = buffer_with(device, &vec![0; 4 * words]).unwrap(); - let pass = buffer_with(device, &large.pass_bytes(count)).unwrap(); - kernel.run(&queue, [&prims, &pass, &mask], groups, WARM); - let batch = kernel.run(&queue, [&prims, &pass, &mask], groups, BATCH); - for _ in 0..RUNS { - let pass = buffer_with(device, &large.pass_bytes(count)).unwrap(); - let mask = buffer_with(device, &vec![0; 4 * words]).unwrap(); - let took = kernel.run(&queue, [&prims, &pass, &mask], groups, 1); - walls.push(took.wall); - gpus.extend(took.gpu); - let header = read_buffer(&pass, 0, 4 * u64::from(M::HEADER_WORDS)).unwrap(); - let word = |w: u32| { - let at = 4 * w as usize; - u32::from_le_bytes(header[at..at + 4].try_into().expect("a word")) - }; - let bits = read_buffer(&mask, 0, 4 * words as u64).unwrap(); - let set = set_bits(&bits).len(); - reached = (set, word(M::NEAR_FAR_WORD), word(M::UNMEASURED_WORD)); - } - if what == "mesh" { - assert_eq!( - reached.0, tiles as usize, - "a mesh tiling the target reaches it all" - ); - } - let (wall, wall_least) = spread(walls); - let per = |d: Duration| d.as_secs_f64() * 1e6 / f64::from(BATCH); - let gpu = match (gpus.len(), batch.gpu) { - (0, _) | (_, None) => "no timestamps".to_string(), - (_, Some(back_to_back)) => { - let (median, least) = spread(gpus); - format!( - "GPU median {median:.1} us, least {least:.1} us, {:.1} us a \ - dispatch back to back", - per(back_to_back) - ) - } - }; - eprintln!( - "TILEREACH-TIME: {what}: {count} primitives over {}x{} on {}: {gpu}; \ - submission to fence median {wall:.1} us, least {wall_least:.1} us, \ - {:.1} us a dispatch back to back ({RUNS} runs alone, {BATCH} back to \ - back, after {WARM}); {} of {tiles} tiles, near-far {}, unmeasured {}", - TARGET[0], - TARGET[1], - device.name(), - per(batch.wall), - reached.0, - reached.1, - reached.2 - ); - } - } - }); -} diff --git a/crates/metal2vulkan-validation/src/runtime_lane/unorm_depth_bias.rs b/crates/metal2vulkan-validation/src/runtime_lane/unorm_depth_bias.rs index 309d8ecde..7673c474f 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/unorm_depth_bias.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/unorm_depth_bias.rs @@ -14,19 +14,17 @@ //! (every code the rule's), and found that a slope alone brings the one unit: [`SLOPE_ALONE`], flat //! triangles (so the slope adds nothing itself) under a constant of 0. //! -//! The device converts every depth, biased or not: the runtime records Metal's bias where the -//! device pins Vulkan's unit (`metal::state::depth_bias`), and the device rounds the sum and -//! converts it its own way. Where the profile takes `DriverDeviation::MetalDepth16Stores` an -//! unbiased depth stores Metal's code, and where it takes `DriverDeviation::MetalDepth16BiasedStores` -//! a biased one: RADV (Mesa 26.2.4, the Radeon 780M) stored every code Metal's, and MoltenVK (1.4.1, -//! an M4), which hands Metal its constant, too (both deviations). ANV (Mesa 26.2.4) stored every -//! unbiased code Metal's (the first), but rounded some biased sums near a code's midpoint to -//! nearest, storing the code next to Metal's. Lavapipe (Mesa 26.0.8 and 26.2.4) scaled every depth -//! by 65535 as a `float` and rounded a tie to even (0.9 as 58982), and NVIDIA's (615.71.09) stored -//! the code below Metal's for a depth up to 0.55 of a code above a midpoint (0.5 as 32767). Where -//! the profile lacks a deviation the runtime announces it, `unorm-depth-rounding` for any depth -//! tested or written and `unorm-depth-bias` for a biased one, and the lane prints the codes that -//! differ from Metal's without holding them. +//! The device biases and converts every depth: the runtime records Metal's constant in the +//! device's own unit (`metal::state::depth_bias`), and the device rounds the sum and converts it +//! its own way. Where the profile takes `DriverDeviation::MetalDepth16Stores` an unbiased depth +//! stores Metal's code, and where it takes `DriverDeviation::MetalDepth16BiasedStores` a biased one: +//! MoltenVK (1.4.1, an M4), which hands Metal its constant, takes both. RADV (Mesa 26.2.4, the +//! Radeon 780M) and ANV (Mesa 26.2.4) stored every unbiased code Metal's (the first). Lavapipe (Mesa +//! 26.0.8 and 26.2.4) scaled every depth by 65535 as a `float` and rounded a tie to even (0.9 as +//! 58982), and NVIDIA's (615.71.09) stored the code below Metal's for a depth up to 0.55 of a code +//! above a midpoint (0.5 as 32767). Where the profile lacks a deviation the runtime announces it, +//! `unorm-depth-rounding` for any depth tested or written and `unorm-depth-bias` for a biased one, +//! and the lane prints the codes that differ from Metal's without holding them. //! //! The render pass's depth decides what a draw stores, whatever the pipeline names: the cases //! drawn by a pipeline that names no depth store the same codes. diff --git a/crates/metal2vulkan/src/bind/capture_assembly.rs b/crates/metal2vulkan/src/bind/capture_assembly.rs deleted file mode 100644 index 3984e9687..000000000 --- a/crates/metal2vulkan/src/bind/capture_assembly.rs +++ /dev/null @@ -1,345 +0,0 @@ -//! The tile reach primitives of a pass's capture draws: the step between capture replay and -//! [`tile_reach_module`](super::tile_reach_module). -//! -//! Capture replay draws each kept draw of a pass again before it, under the capture form of its -//! vertex function, which writes one record a vertex invocation. [`capture_assembly_module`] -//! assembles those records into the pass's primitives as Metal's input assembly does, one tile -//! reach [`primitive`](super::TileReachModule::primitive) record each, which -//! [`tile_reach_module`](super::tile_reach_module) then bins; [`capture_settle_module`] turns the -//! mask it binned into every tile where it counted a primitive near-far or unmeasured (the -//! announced fallback). -//! -//! **The assembly module** (one per device). One `GLCompute` entry `main` with local size -//! ([`CaptureAssemblyModule::LOCAL_SIZE`], 1, 1), no push constants, and three storage buffers of -//! 4-byte words in set 0: -//! -//! - [`RECORDS_BINDING`](CaptureAssemblyModule::RECORDS_BINDING): the capture records, each -//! [`RECORD_WORDS`](CaptureAssemblyModule::RECORD_WORDS) words -//! ([`record`](CaptureAssemblyModule::record)): the clip-space position (four `f32`s), the point -//! size (an `f32`), and a word that is not zero where the vertex's raw index restarts its strip -//! (an indexed draw's index of the index type's all-ones value), then two unused words. The -//! capture form writes vertex `p` of instance `n` (counted from the draw's first instance) of a -//! draw of `count` vertices or indices at the draw's first slot plus `p + n * count`. -//! - [`DRAWS_BINDING`](CaptureAssemblyModule::DRAWS_BINDING): a header of -//! [`HEADER_WORDS`](CaptureAssemblyModule::HEADER_WORDS) words -//! ([`header`](CaptureAssemblyModule::header)): the entries' count and the primitives' total; -//! then the entries, each [`DRAW_WORDS`](CaptureAssemblyModule::DRAW_WORDS) words -//! ([`draw`](CaptureAssemblyModule::draw)), one per instance of each draw, in order: -//! -//! | Word | Contents | -//! |---|---| -//! | 0 | the entry's first primitive: the primitives of the entries before it | -//! | 1 | its primitives ([`primitives`](CaptureAssemblyModule::primitives) of its topology and records) | -//! | 2 | its first record: the slot of the instance's vertex 0 | -//! | 3 | its records: the draw's vertex or index count | -//! | 4 | its topology: the raw `MTLPrimitiveType` ([`PrimitiveType`]) | -//! | 5 | 1 where it restarts: an indexed line or triangle strip (Metal restarts strips at a flagged record; lists and points draw every index), else 0 | -//! | 6 | 1 where it culls: its cull mode is front or back, else 0 | -//! | 7 | the index of the tile reach state it was drawn under | -//! -//! - [`PRIMITIVES_BINDING`](CaptureAssemblyModule::PRIMITIVES_BINDING): the pass's primitives, -//! [`PRIMITIVE_WORDS`](super::TileReachModule::PRIMITIVE_WORDS) words each, which the kernel -//! writes, the buffer [`tile_reach_module`](super::tile_reach_module) reads. -//! -//! **One entry per instance.** An entry covers one instance, so a primitive's place in its -//! entry is a subtraction: the kernel divides nothing (no integer division by a value it reads, -//! which [`tile_reach_module`](super::tile_reach_module)'s docs explain), and a draw of `n` -//! instances takes `n` entries. The host writes no entry of no primitives, so the entries never -//! outnumber the primitives: the draws' buffer holds at most half the primitives' bytes, plus -//! its header. -//! -//! **Invocation `i`** below the header's total (and the primitives the binding holds) finds its -//! entry by a binary search over the first primitives (the last entry whose first primitive is -//! at most `i`), takes `j = i` less that, and writes primitive `i` from the instance's records at -//! the entry's first record plus: -//! -//! - a point list: `j`, a [`POINT`](super::TileReachModule::POINT) of that record's point size; -//! - a line list: `2j`, `2j + 1`; a line strip: `j`, `j + 1` (each a -//! [`LINE`](super::TileReachModule::LINE)); -//! - a triangle list: `3j`, `3j + 1`, `3j + 2`; a triangle strip: `j`, `j + 1`, `j + 2` where the -//! triangle's parity is even, `j`, `j + 2`, `j + 1` where it is odd (Vulkan's strip order, the -//! index rewrite's: every triangle keeps the strip's winding); -//! -//! with the entry's state, layer 0, and the first vertex's point size. A vertex unused by its -//! kind (a point's second and third, a line's third) is written as zeros. -//! -//! **Restart** (an entry that restarts, of a line or triangle strip). A primitive one of whose -//! records is flagged reaches nothing: it is written as a triangle of three equal finite vertices, -//! `(0, 0, 0, 1)`, of size 0. The rule has it reach no tile (zero area) and flags it nothing more -//! than its state flags every primitive drawn under it (inside both depth planes, before the -//! eye, at the viewport's centre; `tile_reach`'s test `assembly`, against the rule and the -//! kernel). A line strip's segment is written so too: a line of no length would count unmeasured. -//! A triangle strip's parity restarts after each flagged record (Metal's, measured, -//! `runtime/src/render/restart.rs`). Where the entry culls, a kept triangle's parity is that of -//! its distance from its piece's first record, the one after the last flagged record before `j` -//! (or the instance's vertex 0 where none is): the kernel scans back at most -//! [`SCAN_LIMIT`](CaptureAssemblyModule::SCAN_LIMIT) records before `j`. Where that passes no -//! flagged record and does not reach vertex 0, the parity is unknown, and the triangle is -//! written with three NaN vertices, which the rule counts unmeasured, so the pass falls back to -//! every tile (the settle module). Where the entry does not cull, a triangle reaches the same -//! tiles in either winding, and its parity is counted from vertex 0, with no scan. -//! -//! **Contained.** Every read and write lies inside its binding. An invocation past the -//! primitives the binding holds writes nothing. A primitive the entries do not describe (no -//! entry, `j` at or past the entry's primitives, a topology that is none) or whose records lie -//! past the entry's records or the records' binding is written as the triangle of NaN vertices: -//! counted unmeasured, never a guess. -//! -//! **The settle module** (one per device). One `GLCompute` entry `main` with local size -//! ([`CaptureSettleModule::LOCAL_SIZE`], 1, 1), no push constants, and three storage buffers in -//! set 0, numbered densely from 0 (as the runtime's owned kernels lay out their set): -//! [`STATUS_BINDING`](CaptureSettleModule::STATUS_BINDING), the command buffer's -//! [`ExecutionStatus`](super::ExecutionStatus) words; -//! [`PASS_BINDING`](CaptureSettleModule::PASS_BINDING), the pass's header and states, read; and -//! [`TILES_BINDING`](CaptureSettleModule::TILES_BINDING), the tile mask (the last two the -//! buffers [`tile_reach_module`](super::tile_reach_module) binds at the same numbers). Where the -//! header's [`NEAR_FAR_WORD`](super::TileReachModule::NEAR_FAR_WORD) or -//! [`UNMEASURED_WORD`](super::TileReachModule::UNMEASURED_WORD) is not zero, invocation `i`, one -//! a word of the mask ([`mask_words`](super::TileReachModule::mask_words) of the header's render -//! area, samples and layers), ORs into word `i` the bits of every tile of the pass it holds (a -//! bit past the pass's last tile is left as it is), and invocation 0 ORs -//! [`CAPTURED_REACH_UNMEASURED`](super::StatusBits::CAPTURED_REACH_UNMEASURED) into the status -//! word, which [`captured_reach_unmeasured`](super::StatusReport::captured_reach_unmeasured) -//! reads back so the runtime can announce the fallback. Where both counts are zero it changes -//! nothing. Dispatch at least one workgroup, so invocation 0 runs. -//! -//! **Arithmetic.** Both kernels copy `f32`s as their bits and hold no float instruction, and -//! compute in `u32` alone: they need nothing of a Vulkan 1.2 device past what every one has. -//! -//! **Synchronization** (consumer): the capture draws' record writes (`SHADER_WRITE` in -//! `VERTEX_SHADER`) and the draws' upload → `SHADER_STORAGE_READ` in `COMPUTE_SHADER` before the -//! assembly; its writes → [`tile_reach_module`](super::tile_reach_module)'s reads; the tile -//! reach dispatch's writes → `SHADER_STORAGE_READ` and `SHADER_STORAGE_WRITE` in `COMPUTE_SHADER` -//! before the settle; its writes → the mask's readers, and the status buffer's reader as every -//! writer of it (`bind::status`). - -use std::sync::Arc; - -use super::index_bounds::finished; -use crate::device::requirements::Requirements; -use crate::device::Device; -use crate::error::Error; -use crate::metal::PrimitiveType; -use crate::pipeline::sym::Symbol; - -mod kernel; - -/// The word positions within the assembly's records ([`CaptureAssemblyModule`]). -mod layout { - /// A capture record's: the position (four `f32`s), the point size, the restart word. - pub(super) const POSITION: u32 = 0; - pub(super) const POINT_SIZE: u32 = 4; - pub(super) const RESTART: u32 = 5; - /// The draws' header's: the entries' count and the primitives' total. - pub(super) const ENTRIES: u32 = 0; - pub(super) const TOTAL: u32 = 1; - /// An entry's (the module docs' table). - pub(super) const FIRST_PRIMITIVE: u32 = 0; - pub(super) const PRIMITIVES: u32 = 1; - pub(super) const FIRST_RECORD: u32 = 2; - pub(super) const RECORDS: u32 = 3; - pub(super) const TOPOLOGY: u32 = 4; - pub(super) const RESTARTS: u32 = 5; - pub(super) const CULLS: u32 = 6; - pub(super) const STATE: u32 = 7; -} - -/// The clip-space vertex, as `f32` bits, of the triangle a primitive that reaches nothing is -/// written as (the module docs): `(0, 0, 0, 1)`. -pub(in crate::bind) const NOTHING: [u32; 4] = [0, 0, 0, 0x3f80_0000]; -/// The clip-space vertex, as `f32` bits, of the triangle a primitive whose reach is unknown is -/// written as (the module docs): four quiet NaNs. -pub(in crate::bind) const UNKNOWN: [u32; 4] = [0x7fc0_0000; 4]; - -/// The crate-owned capture assembly module of one device (the module docs), validated like any -/// output. -#[non_exhaustive] -#[derive(Clone, Debug, PartialEq, Eq)] -pub struct CaptureAssemblyModule { - /// SPIR-V 1.5 words, entry point `main`, its bindings numbered as below in set 0. - pub spirv: Arc<[u32]>, - /// What the module needs from the device: within every Vulkan 1.2 device. - pub requirements: Requirements, -} - -impl CaptureAssemblyModule { - /// Descriptor set of the bindings. - pub const SET: u32 = 0; - /// The capture records, a storage buffer the kernel reads. - pub const RECORDS_BINDING: u32 = 0; - /// The draws' header and entries, a storage buffer the kernel reads. - pub const DRAWS_BINDING: u32 = 1; - /// The pass's primitives, a storage buffer the kernel writes (the buffer tile reach binds at - /// [`PRIMITIVES_BINDING`](super::TileReachModule::PRIMITIVES_BINDING)). - pub const PRIMITIVES_BINDING: u32 = 2; - /// Invocations of one workgroup, along x: one primitive each. - pub const LOCAL_SIZE: u32 = 64; - /// A capture record's words ([`record`](Self::record)): 32 bytes. - pub const RECORD_WORDS: u32 = 8; - /// The draws' header's words ([`header`](Self::header)), before the entries. - pub const HEADER_WORDS: u32 = 2; - /// An entry's words ([`draw`](Self::draw)). - pub const DRAW_WORDS: u32 = 8; - /// The most records the kernel scans back from a kept triangle of a restarting triangle - /// strip that culls, for the last flagged record before it (the module docs). - pub const SCAN_LIMIT: u32 = 256; - - /// A capture record's bytes, as the capture form writes them: the clip-space `position` - /// (`[[position]]`), the `point_size` (`[[point_size]]`; any value where the function writes - /// none), and whether the vertex's raw index restarts its strip (1 or 0), then two words of - /// zeros. - pub fn record(position: [f32; 4], point_size: f32, restart: bool) -> [u8; 32] { - let mut words = [0; Self::RECORD_WORDS as usize]; - for (c, value) in position.iter().enumerate() { - words[layout::POSITION as usize + c] = value.to_bits(); - } - words[layout::POINT_SIZE as usize] = point_size.to_bits(); - words[layout::RESTART as usize] = u32::from(restart); - bytes_of(words) - } - - /// The draws' header's bytes: the count of `entries` that follow it, and the `total` of their - /// primitives (the invocations that write one). - pub fn header(entries: u32, total: u32) -> [u8; 8] { - let mut words = [0; Self::HEADER_WORDS as usize]; - words[layout::ENTRIES as usize] = entries; - words[layout::TOTAL as usize] = total; - bytes_of(words) - } - - /// An entry's bytes, one instance of a draw: its `first_primitive` (the primitives of the - /// entries before it), the slot of its vertex 0 among the records (`first_record`), its - /// `records` (the draw's vertex or index count), its `topology`, whether it `restarts` (an - /// indexed strip, whose flagged records restart it; ignored for a list or points), whether - /// its cull mode `culls` (front or back), and the index of the tile reach `state` it was drawn - /// under. Its primitives are [`primitives`](Self::primitives) of its topology and records. - pub fn draw( - first_primitive: u32, - first_record: u32, - records: u32, - topology: PrimitiveType, - restarts: bool, - culls: bool, - state: u32, - ) -> [u8; 32] { - let mut words = [0; Self::DRAW_WORDS as usize]; - words[layout::FIRST_PRIMITIVE as usize] = first_primitive; - words[layout::PRIMITIVES as usize] = Self::primitives(topology, records); - words[layout::FIRST_RECORD as usize] = first_record; - words[layout::RECORDS as usize] = records; - words[layout::TOPOLOGY as usize] = topology.as_raw(); - words[layout::RESTARTS as usize] = u32::from(restarts); - words[layout::CULLS as usize] = u32::from(culls); - words[layout::STATE as usize] = state; - bytes_of(words) - } - - /// The primitives one instance of `records` vertices or indices of `topology` assembles - /// (with a strip's restarts among them: a primitive a restart drops is written as one that - /// reaches nothing). - pub fn primitives(topology: PrimitiveType, records: u32) -> u32 { - match topology { - PrimitiveType::Point => records, - PrimitiveType::Line => records / 2, - PrimitiveType::LineStrip => records.saturating_sub(1), - PrimitiveType::Triangle => records / 3, - PrimitiveType::TriangleStrip => records.saturating_sub(2), - } - } -} - -/// The crate-owned capture settle module of one device (the module docs), validated like any -/// output. -#[non_exhaustive] -#[derive(Clone, Debug, PartialEq, Eq)] -pub struct CaptureSettleModule { - /// SPIR-V 1.5 words, entry point `main`, its bindings numbered as below in set 0. - pub spirv: Arc<[u32]>, - /// What the module needs from the device: within every Vulkan 1.2 device. - pub requirements: Requirements, -} - -impl CaptureSettleModule { - /// Descriptor set of the bindings, numbered densely from 0. - pub const SET: u32 = 0; - /// The command buffer's [`ExecutionStatus`](super::ExecutionStatus) words, a storage buffer - /// the kernel ORs - /// [`CAPTURED_REACH_UNMEASURED`](super::StatusBits::CAPTURED_REACH_UNMEASURED) into. - pub const STATUS_BINDING: u32 = 0; - /// The pass's header and states, a storage buffer the kernel reads (the buffer tile reach - /// binds at [`PASS_BINDING`](super::TileReachModule::PASS_BINDING)). - pub const PASS_BINDING: u32 = 1; - /// The tile mask, a storage buffer the kernel ORs bits into (the buffer tile reach binds at - /// [`TILES_BINDING`](super::TileReachModule::TILES_BINDING)). - pub const TILES_BINDING: u32 = 2; - /// Invocations of one workgroup, along x: one mask word each. - pub const LOCAL_SIZE: u32 = 64; -} - -/// The little-endian bytes of `N` words. -fn bytes_of(words: [u32; N]) -> [u8; B] { - let mut bytes = [0; B]; - for (at, w) in words.iter().enumerate() { - bytes[4 * at..4 * at + 4].copy_from_slice(&w.to_le_bytes()); - } - bytes -} - -/// The fixed binding numbers of the assembly's symbols. -fn assembly_binding_of(sym: &Symbol) -> Option { - match sym { - Symbol::DescriptorSet(_) => Some(CaptureAssemblyModule::SET), - Symbol::Binding(s) if *s == kernel::RECORDS => Some(CaptureAssemblyModule::RECORDS_BINDING), - Symbol::Binding(s) if *s == kernel::DRAWS => Some(CaptureAssemblyModule::DRAWS_BINDING), - Symbol::Binding(s) if *s == kernel::PRIMITIVES => { - Some(CaptureAssemblyModule::PRIMITIVES_BINDING) - } - _ => None, - } -} - -/// The fixed binding numbers of the settle's symbols. -fn settle_binding_of(sym: &Symbol) -> Option { - match sym { - Symbol::DescriptorSet(_) => Some(CaptureSettleModule::SET), - Symbol::Binding(s) if *s == kernel::PASS => Some(CaptureSettleModule::PASS_BINDING), - Symbol::Binding(s) if *s == kernel::TILES => Some(CaptureSettleModule::TILES_BINDING), - Symbol::Binding(s) if *s == kernel::STATUS => Some(CaptureSettleModule::STATUS_BINDING), - _ => None, - } -} - -/// The capture assembly module of `device`: built with the typed builder, checked by the owned -/// verifier against the device's profile (requirements included), serialized, and numbered with -/// the fixed bindings of [`CaptureAssemblyModule`]. -pub fn capture_assembly_module(device: &Device) -> Result { - let (spirv, requirements) = finished( - device, - kernel::assembly_typed_module()?, - assembly_binding_of, - "the capture assembly", - )?; - Ok(CaptureAssemblyModule { - spirv, - requirements, - }) -} - -/// The capture settle module of `device`: built with the typed builder, checked by the owned -/// verifier against the device's profile (requirements included), serialized, and numbered with -/// the fixed bindings of [`CaptureSettleModule`]. -pub fn capture_settle_module(device: &Device) -> Result { - let (spirv, requirements) = finished( - device, - kernel::settle_typed_module()?, - settle_binding_of, - "the capture settle", - )?; - Ok(CaptureSettleModule { - spirv, - requirements, - }) -} - -#[cfg(test)] -mod tests; diff --git a/crates/metal2vulkan/src/bind/capture_assembly/kernel.rs b/crates/metal2vulkan/src/bind/capture_assembly/kernel.rs deleted file mode 100644 index 2e819cf7c..000000000 --- a/crates/metal2vulkan/src/bind/capture_assembly/kernel.rs +++ /dev/null @@ -1,731 +0,0 @@ -//! The capture assembly and settle kernels: [`assembly_typed_module`] and -//! [`settle_typed_module`], which [`capture_assembly_module`](super::capture_assembly_module) and -//! [`capture_settle_module`](super::capture_settle_module) serialize and the CPU interpreter -//! runs, by the module docs' rules, step for step as the tests' reference assembly states them -//! (`tests.rs`). -//! -//! **No division and no float.** Each kernel copies `f32`s as their bits and computes in `u32`. -//! The records, entries, primitives and mask words a binding holds come by shifts (each record's -//! words are a power of two), an invocation's entry by a binary search, its place in the entry by -//! a subtraction (an entry is one instance), and a triangle's parity by a scan of at most -//! [`SCAN_LIMIT`](A::SCAN_LIMIT) records: nothing divides by a value it reads, which the tile -//! reach kernel's docs explain the price of. - -use crate::bind::status::{StatusBits, StatusWord}; -use crate::bind::tile_reach::{layout as reach, TileReachModule as R, AREA_LIMIT}; -use crate::metal::PrimitiveType; -use crate::pipeline::sym::{ResourceKind, ResourceSlot, Stage, SyntheticBinding}; -use crate::spirv::builder::constructs::{ArmEnd, ArmFn, LoopFn, LoopSpec}; -use crate::spirv::builder::{FunctionBuilder, ModuleBuilder}; -use crate::spirv::error::BResult; -use crate::spirv::ids::{FuncId, GlobalId, TypeId, Value}; -use crate::spirv::ir::{ - natural_layout, AtomicOp, BinOp, ExecMode, ExecModel, IoDir, LayoutRule, MemAccess, Scope, - Semantics, StorageClass, Type, TypedModule, UnOp, -}; - -use super::{layout, CaptureAssemblyModule as A, CaptureSettleModule as S, NOTHING, UNKNOWN}; - -/// The binding symbols of the assembly's records, draws and primitives in its typed module. -pub(super) const RECORDS: ResourceSlot = slot(0); -pub(super) const DRAWS: ResourceSlot = slot(1); -pub(super) const PRIMITIVES: ResourceSlot = slot(2); -/// The binding symbols of the settle's pass, tile mask and `ExecutionStatus` words in its typed -/// module. -pub(super) const PASS: ResourceSlot = slot(0); -pub(super) const TILES: ResourceSlot = slot(1); -pub(super) const STATUS: ResourceSlot = ResourceSlot { - stage: Stage::Kernel, - kind: ResourceKind::Synthetic(SyntheticBinding::ExecutionStatus), - index: 0, -}; - -const fn slot(index: u32) -> ResourceSlot { - ResourceSlot { - stage: Stage::Kernel, - kind: ResourceKind::Buffer, - index, - } -} - -/// The raw topologies (`MTLPrimitiveType`). -const POINTS: u32 = PrimitiveType::Point.as_raw(); -const LINES: u32 = PrimitiveType::Line.as_raw(); -const LINE_STRIP: u32 = PrimitiveType::LineStrip.as_raw(); -const TRIANGLES: u32 = PrimitiveType::Triangle.as_raw(); -const TRIANGLE_STRIP: u32 = PrimitiveType::TriangleStrip.as_raw(); - -/// The shift that counts a binding's records of `words` words, a power of two. -const fn shift(words: u32) -> u32 { - assert!(words.is_power_of_two()); - words.trailing_zeros() -} -const RECORD_SHIFT: u32 = shift(A::RECORD_WORDS); -const DRAW_SHIFT: u32 = shift(A::DRAW_WORDS); -const PRIMITIVE_SHIFT: u32 = shift(R::PRIMITIVE_WORDS); - -fn k32(f: &mut FunctionBuilder<'_>, v: u32) -> BResult { - let c = f.u32_const(v)?; - f.module().const_value(c) -} - -fn op(f: &mut FunctionBuilder<'_>, o: BinOp, a: Value, b: Value) -> BResult { - f.binary(o, a, b) -} - -/// `a o v` for a `u32` constant `v`. -fn opk(f: &mut FunctionBuilder<'_>, o: BinOp, a: Value, v: u32) -> BResult { - let c = k32(f, v)?; - f.binary(o, a, c) -} - -fn sel(f: &mut FunctionBuilder<'_>, c: Value, a: Value, b: Value) -> BResult { - f.select(c, a, b) -} - -fn and(f: &mut FunctionBuilder<'_>, a: Value, b: Value) -> BResult { - f.binary(BinOp::LogicalAnd, a, b) -} - -fn or(f: &mut FunctionBuilder<'_>, a: Value, b: Value) -> BResult { - f.binary(BinOp::LogicalOr, a, b) -} - -fn not(f: &mut FunctionBuilder<'_>, a: Value) -> BResult { - f.unary(UnOp::LogicalNot, a) -} - -/// The smaller of two `u32`s. -fn umin(f: &mut FunctionBuilder<'_>, a: Value, b: Value) -> BResult { - let less = op(f, BinOp::ULessThan, a, b)?; - sel(f, less, a, b) -} - -/// Whether a `u32` is not zero. -fn nonzero(f: &mut FunctionBuilder<'_>, a: Value) -> BResult { - opk(f, BinOp::INotEqual, a, 0) -} - -fn load(f: &mut FunctionBuilder<'_>, p: Value) -> BResult { - f.load(p, MemAccess::default()) -} - -fn store(f: &mut FunctionBuilder<'_>, p: Value, v: Value) -> BResult<()> { - f.store(p, v, MemAccess::default()) -} - -/// A `Function` `u32` holding `v`, as its pointer. -fn local(f: &mut FunctionBuilder<'_>, u32_: TypeId, v: Value) -> BResult { - let var = f.local_var(u32_, None)?; - let p = f.var_ptr(var)?; - store(f, p, v)?; - Ok(p) -} - -/// Word `i` (a `u32`) of a buffer of words, as a pointer. -fn word_ptr(f: &mut FunctionBuilder<'_>, buffer: Value, i: Value) -> BResult { - let zero = k32(f, 0)?; - f.access_chain(buffer, &[zero, i]) -} - -/// Word `i` (a `u32`) of a buffer of words. -fn word(f: &mut FunctionBuilder<'_>, buffer: Value, i: Value) -> BResult { - let p = word_ptr(f, buffer, i)?; - load(f, p) -} - -/// Word `base + at` of a buffer of words. -fn field(f: &mut FunctionBuilder<'_>, buffer: Value, base: Value, at: u32) -> BResult { - let i = opk(f, BinOp::IAdd, base, at)?; - word(f, buffer, i) -} - -/// Run `body` where `c` holds. -fn when<'a>( - f: &mut FunctionBuilder<'_>, - c: Value, - body: impl FnOnce(&mut FunctionBuilder<'_>) -> BResult<()> + 'a, -) -> BResult<()> { - let arm: ArmFn<'_, ()> = Box::new(move |f, _| { - body(f)?; - Ok(ArmEnd::FallThrough(Vec::new())) - }); - f.if_(&mut (), c, arm, None)?; - Ok(()) -} - -/// Run `then` where `c` holds and `other` where it does not. -fn either<'a>( - f: &mut FunctionBuilder<'_>, - c: Value, - then: impl FnOnce(&mut FunctionBuilder<'_>) -> BResult<()> + 'a, - other: impl FnOnce(&mut FunctionBuilder<'_>) -> BResult<()> + 'a, -) -> BResult<()> { - let yes: ArmFn<'_, ()> = Box::new(move |f, _| { - then(f)?; - Ok(ArmEnd::FallThrough(Vec::new())) - }); - let no: ArmFn<'_, ()> = Box::new(move |f, _| { - other(f)?; - Ok(ArmEnd::FallThrough(Vec::new())) - }); - f.if_(&mut (), c, yes, Some(no))?; - Ok(()) -} - -/// Loop: each pass, leave where `stop` (computed first, at the top) holds, else run `body`. -fn repeat<'a>( - f: &mut FunctionBuilder<'_>, - stop: impl FnOnce(&mut FunctionBuilder<'_>) -> BResult + 'a, - body: impl FnOnce(&mut FunctionBuilder<'_>) -> BResult<()> + 'a, -) -> BResult<()> { - let walk: LoopFn<'_, ()> = Box::new(move |f, _, lc| { - let done = stop(f)?; - let leave: ArmFn<'_, ()> = Box::new(|f, _| { - lc.break_(f)?; - Ok(ArmEnd::Exits) - }); - f.if_(&mut (), done, leave, None)?; - body(f) - }); - f.loop_(&mut (), LoopSpec::default(), walk) -} - -/// A `Block { u32 words[]; }` storage buffer bound at `sym`. -fn words_buffer(b: &mut ModuleBuilder, sym: ResourceSlot, u32_: TypeId) -> BResult { - let rta = b.ty(Type::RuntimeArray { - elem: u32_, - stride: Some(4), - })?; - let layout = natural_layout(b.types(), LayoutRule::Std430, true, &[rta])?; - let block = b.ty(Type::Struct { - members: [rta].into(), - layout: Some(layout), - })?; - b.resource(sym, StorageClass::StorageBuffer, block) -} - -/// The `u32` type and the `uvec3` of an invocation's id. -fn types(b: &mut ModuleBuilder) -> BResult<(TypeId, TypeId)> { - let u32_ = b.ty(Type::Int { - width: 32, - signed: false, - })?; - let uvec3 = b.ty(Type::Vector { elem: u32_, len: 3 })?; - Ok((u32_, uvec3)) -} - -/// Make `id` the `GLCompute` entry point of local size (`x`, 1, 1). -fn entry(b: &mut ModuleBuilder, id: FuncId, x: u32) -> BResult<()> { - b.entry( - ExecModel::GLCompute, - id, - vec![ExecMode::LocalSize { x, y: 1, z: 1 }], - )?; - Ok(()) -} - -/// The assembly as a typed module, before serialization: the module -/// [`capture_assembly_module`](super::capture_assembly_module) serializes, which the CPU -/// interpreter runs. Its bindings are the symbols `RECORDS`, `DRAWS` and `PRIMITIVES`. -pub(super) fn assembly_typed_module() -> BResult { - let mut b = ModuleBuilder::new(); - let (u32_, uvec3) = types(&mut b)?; - let records = words_buffer(&mut b, RECORDS, u32_)?; - let draws = words_buffer(&mut b, DRAWS, u32_)?; - let prims = words_buffer(&mut b, PRIMITIVES, u32_)?; - let invocation = b.builtin(crate::spv::BuiltIn::GlobalInvocationId, IoDir::Input, uvec3)?; - let void = b.ty(Type::Void)?; - let mut f = b.function(void)?; - let records = f.module().global_value(records)?; - let draws = f.module().global_value(draws)?; - let prims = f.module().global_value(prims)?; - let invocation = f.module().global_value(invocation)?; - assembly_body(&mut f, u32_, [records, draws, prims], invocation)?; - f.ret(None)?; - let id = f.finish()?; - entry(&mut b, id, A::LOCAL_SIZE)?; - b.finalize() -} - -/// The assembly's buffers, and the whole records its records' binding holds. -#[derive(Clone, Copy)] -struct G { - u32_: TypeId, - records: Value, - draws: Value, - prims: Value, - held: Value, -} - -/// An entry's words (the module docs' table). -#[derive(Clone, Copy)] -struct Entry { - first: Value, - primitives: Value, - first_record: Value, - records: Value, - topology: Value, - restarts: Value, - culls: Value, - state: Value, -} - -/// The entry's body: invocation `i` below the header's total and the primitives the binding -/// holds writes primitive `i`, from its entry where the header names one, else unknown. -fn assembly_body( - f: &mut FunctionBuilder<'_>, - u32_: TypeId, - [records, draws, prims]: [Value; 3], - invocation: Value, -) -> BResult<()> { - let gid = load(f, invocation)?; - let i = f.composite_extract(gid, &[0])?; - let len = f.array_length(records, 0)?; - let g = G { - u32_, - records, - draws, - prims, - held: opk(f, BinOp::ShiftRightLogical, len, RECORD_SHIFT)?, - }; - let len = f.array_length(prims, 0)?; - let out = opk(f, BinOp::ShiftRightLogical, len, PRIMITIVE_SHIFT)?; - let words = f.array_length(draws, 0)?; - let header = opk(f, BinOp::UGreaterThanEqual, words, A::HEADER_WORDS)?; - when(f, header, move |f| { - let at = k32(f, layout::TOTAL)?; - let total = word(f, g.draws, at)?; - let at = k32(f, layout::ENTRIES)?; - let named = word(f, g.draws, at)?; - let after = opk(f, BinOp::ISub, words, A::HEADER_WORDS)?; - let entries = opk(f, BinOp::ShiftRightLogical, after, DRAW_SHIFT)?; - let count = umin(f, named, entries)?; - let below = op(f, BinOp::ULessThan, i, total)?; - let fits = op(f, BinOp::ULessThan, i, out)?; - let go = and(f, below, fits)?; - when(f, go, move |f| { - let some = opk(f, BinOp::UGreaterThan, count, 0)?; - either( - f, - some, - move |f| { - let e = search(f, g, i, count)?; - let e = read_entry(f, g, e)?; - primitive(f, g, i, e) - }, - move |f| { - let zero = k32(f, 0)?; - placeholder(f, g, i, zero, UNKNOWN) - }, - ) - }) - }) -} - -/// The index of the last of the `count` (at least one) entries whose first primitive is at most -/// `i`, by a binary search (the entries' first primitives do not decrease): entry 0 where none -/// is. -fn search(f: &mut FunctionBuilder<'_>, g: G, i: Value, count: Value) -> BResult { - let zero = k32(f, 0)?; - let lo = local(f, g.u32_, zero)?; - let hi = local(f, g.u32_, count)?; - repeat( - f, - move |f| { - let l = load(f, lo)?; - let h = load(f, hi)?; - let span = op(f, BinOp::ISub, h, l)?; - opk(f, BinOp::ULessThanEqual, span, 1) - }, - move |f| { - let l = load(f, lo)?; - let h = load(f, hi)?; - // Below 2^29 entries each: the sum does not wrap. - let mid = op(f, BinOp::IAdd, l, h)?; - let mid = opk(f, BinOp::ShiftRightLogical, mid, 1)?; - let base = entry_base(f, mid)?; - let first = field(f, g.draws, base, layout::FIRST_PRIMITIVE)?; - let up = op(f, BinOp::ULessThanEqual, first, i)?; - let l = sel(f, up, mid, l)?; - let h = sel(f, up, h, mid)?; - store(f, lo, l)?; - store(f, hi, h) - }, - )?; - load(f, lo) -} - -/// The first word of entry `e`. -fn entry_base(f: &mut FunctionBuilder<'_>, e: Value) -> BResult { - let at = opk(f, BinOp::ShiftLeftLogical, e, DRAW_SHIFT)?; - opk(f, BinOp::IAdd, at, A::HEADER_WORDS) -} - -/// Entry `e`'s words. -fn read_entry(f: &mut FunctionBuilder<'_>, g: G, e: Value) -> BResult { - let base = entry_base(f, e)?; - let mut w = |at: u32| field(f, g.draws, base, at); - Ok(Entry { - first: w(layout::FIRST_PRIMITIVE)?, - primitives: w(layout::PRIMITIVES)?, - first_record: w(layout::FIRST_RECORD)?, - records: w(layout::RECORDS)?, - topology: w(layout::TOPOLOGY)?, - restarts: w(layout::RESTARTS)?, - culls: w(layout::CULLS)?, - state: w(layout::STATE)?, - }) -} - -/// Words `at` of record `v` (a `u32`) of the entry's instance, and whether it is there: `v` -/// below the entry's records and its slot below the binding's records. A record not there reads -/// as zeros, and nothing is read. -fn fetch( - f: &mut FunctionBuilder<'_>, - g: G, - e: &Entry, - v: Value, - at: [u32; N], -) -> BResult<([Value; N], Value)> { - let within = op(f, BinOp::ULessThan, v, e.records)?; - let slot = op(f, BinOp::IAdd, e.first_record, v)?; - let held = op(f, BinOp::ULessThan, slot, g.held)?; - let there = and(f, within, held)?; - let zero = k32(f, 0)?; - let mut vars = [zero; N]; - for p in &mut vars { - *p = local(f, g.u32_, zero)?; - } - when(f, there, move |f| { - let base = opk(f, BinOp::ShiftLeftLogical, slot, RECORD_SHIFT)?; - for (p, at) in vars.into_iter().zip(at) { - let w = field(f, g.records, base, at)?; - store(f, p, w)?; - } - Ok(()) - })?; - let mut words = [zero; N]; - for (w, p) in words.iter_mut().zip(vars) { - *w = load(f, p)?; - } - Ok((words, there)) -} - -/// A vertex the primitive reads: its position's four words, its point size, whether it -/// restarts (a `bool`), and whether it is there. -#[derive(Clone, Copy)] -struct Vertex { - position: [Value; 4], - size: Value, - restart: Value, - there: Value, -} - -/// Record `v` of the entry's instance as a vertex. -fn vertex(f: &mut FunctionBuilder<'_>, g: G, e: &Entry, v: Value) -> BResult { - let p = layout::POSITION; - let at = [p, p + 1, p + 2, p + 3, layout::POINT_SIZE, layout::RESTART]; - let (w, there) = fetch(f, g, e, v, at)?; - Ok(Vertex { - position: [w[0], w[1], w[2], w[3]], - size: w[4], - restart: nonzero(f, w[5])?, - there, - }) -} - -/// Write primitive `i` of entry `e` (the module docs): its records, a restart's placeholder, or -/// the unknown one. -fn primitive(f: &mut FunctionBuilder<'_>, g: G, i: Value, e: Entry) -> BResult<()> { - let j = op(f, BinOp::ISub, i, e.first)?; - let in_entry = op(f, BinOp::ULessThan, j, e.primitives)?; - let named = opk(f, BinOp::ULessThanEqual, e.topology, TRIANGLE_STRIP)?; - let is = |f: &mut FunctionBuilder<'_>, t: u32| opk(f, BinOp::IEqual, e.topology, t); - let lines = is(f, LINES)?; - let triangles = is(f, TRIANGLES)?; - let line_strip = is(f, LINE_STRIP)?; - let triangle_strip = is(f, TRIANGLE_STRIP)?; - let point = is(f, POINTS)?; - // The primitive's first record: `j` times its records in a list, `j` in a strip or points. - let (k1, k2, k3) = (k32(f, 1)?, k32(f, 2)?, k32(f, 3)?); - let step = sel(f, triangles, k3, k1)?; - let step = sel(f, lines, k2, step)?; - let a = op(f, BinOp::IMul, j, step)?; - let b = opk(f, BinOp::IAdd, a, 1)?; - let c = opk(f, BinOp::IAdd, a, 2)?; - let two = not(f, point)?; - let three = or(f, triangles, triangle_strip)?; - let va = vertex(f, g, &e, a)?; - let vb = vertex(f, g, &e, b)?; - let vc = vertex(f, g, &e, c)?; - // Each vertex its kind reads is there. - let no_b = not(f, two)?; - let has_b = or(f, no_b, vb.there)?; - let no_c = not(f, three)?; - let has_c = or(f, no_c, vc.there)?; - let there = and(f, va.there, has_b)?; - let there = and(f, there, has_c)?; - let ok = and(f, in_entry, named)?; - let ok = and(f, ok, there)?; - // A restarting strip's primitive one of whose records is flagged reaches nothing. - let strip = or(f, line_strip, triangle_strip)?; - let restarts = nonzero(f, e.restarts)?; - let restarting = and(f, strip, restarts)?; - let touched = or(f, va.restart, vb.restart)?; - let c_flag = and(f, three, vc.restart)?; - let touched = or(f, touched, c_flag)?; - let nothing = and(f, restarting, touched)?; - // A triangle strip's parity: from vertex 0, or, where it restarts and culls, from its piece's - // first record, unknown past the scan. - let parity = opk(f, BinOp::BitwiseAnd, j, 1)?; - let parity = local(f, g.u32_, parity)?; - let zero = k32(f, 0)?; - let lost = local(f, g.u32_, zero)?; - let culls = nonzero(f, e.culls)?; - let scan = and(f, triangle_strip, restarting)?; - let scan = and(f, scan, culls)?; - let kept = not(f, nothing)?; - let scan = and(f, scan, kept)?; - let scan = and(f, scan, ok)?; - when(f, scan, move |f| { - let (odd, known) = piece_parity(f, g, &e, j)?; - store(f, parity, odd)?; - let (k0, k1) = (k32(f, 0)?, k32(f, 1)?); - let unknown = sel(f, known, k0, k1)?; - store(f, lost, unknown) - })?; - let odd = load(f, parity)?; - let odd = nonzero(f, odd)?; - let lost = load(f, lost)?; - let lost = nonzero(f, lost)?; - let fine = not(f, lost)?; - let fine = and(f, ok, fine)?; - either( - f, - fine, - move |f| { - either( - f, - nothing, - move |f| placeholder(f, g, i, e.state, NOTHING), - move |f| { - // Vulkan's strip order: an odd triangle takes its records `j, j + 2, j + 1`. - let swap = and(f, triangle_strip, odd)?; - let zero = k32(f, 0)?; - let mut second = [zero; 4]; - let mut third = [zero; 4]; - let pairs = vb.position.into_iter().zip(vc.position); - for ((s, t), (b, c)) in second.iter_mut().zip(&mut third).zip(pairs) { - let to_second = sel(f, swap, c, b)?; - *s = sel(f, two, to_second, zero)?; - let to_third = sel(f, swap, b, c)?; - *t = sel(f, three, to_third, zero)?; - } - let (kp, kl, kt) = (k32(f, R::POINT)?, k32(f, R::LINE)?, k32(f, R::TRIANGLE)?); - let kind = sel(f, three, kt, kl)?; - let kind = sel(f, point, kp, kind)?; - let vertices = [va.position, second, third]; - emit(f, g, i, [kind, e.state, va.size], vertices) - }, - ) - }, - move |f| placeholder(f, g, i, e.state, UNKNOWN), - ) -} - -/// Primitive `j`'s parity in its piece (1 where odd) and whether it is known (a `bool`): the -/// last flagged record within [`SCAN_LIMIT`](A::SCAN_LIMIT) records before `j` starts its piece -/// after it; with none, the piece starts at vertex 0, known where the scan reached it. -fn piece_parity(f: &mut FunctionBuilder<'_>, g: G, e: &Entry, j: Value) -> BResult<(Value, Value)> { - let bound = k32(f, A::SCAN_LIMIT)?; - let limit = umin(f, j, bound)?; - let (zero, one) = (k32(f, 0)?, k32(f, 1)?); - let back = local(f, g.u32_, one)?; - let found = local(f, g.u32_, zero)?; - let start = local(f, g.u32_, zero)?; - let e = *e; - repeat( - f, - move |f| { - let d = load(f, back)?; - let past = op(f, BinOp::UGreaterThan, d, limit)?; - let got = load(f, found)?; - let got = nonzero(f, got)?; - or(f, past, got) - }, - move |f| { - let d = load(f, back)?; - let q = op(f, BinOp::ISub, j, d)?; - let ([flag], _) = fetch(f, g, &e, q, [layout::RESTART])?; - let flagged = nonzero(f, flag)?; - when(f, flagged, move |f| { - let one = k32(f, 1)?; - store(f, found, one)?; - let after = opk(f, BinOp::IAdd, q, 1)?; - store(f, start, after) - })?; - let next = opk(f, BinOp::IAdd, d, 1)?; - store(f, back, next) - }, - )?; - let got = load(f, found)?; - let got = nonzero(f, got)?; - let near = op(f, BinOp::ULessThanEqual, j, bound)?; - let known = or(f, got, near)?; - let first = load(f, start)?; - let into = op(f, BinOp::ISub, j, first)?; - let odd = opk(f, BinOp::BitwiseAnd, into, 1)?; - Ok((odd, known)) -} - -/// Write primitive `i` as a triangle of three `vertex`es (`NOTHING` or `UNKNOWN`) of size 0, -/// under `state`. -fn placeholder( - f: &mut FunctionBuilder<'_>, - g: G, - i: Value, - state: Value, - vertex: [u32; 4], -) -> BResult<()> { - let kind = k32(f, R::TRIANGLE)?; - let size = k32(f, 0)?; - let mut v = [size; 4]; - for (w, bits) in v.iter_mut().zip(vertex) { - *w = k32(f, bits)?; - } - emit(f, g, i, [kind, state, size], [v; 3]) -} - -/// Write primitive `i`'s record: its kind, state and size, layer 0, and its vertices. -fn emit( - f: &mut FunctionBuilder<'_>, - g: G, - i: Value, - [kind, state, size]: [Value; 3], - vertices: [[Value; 4]; 3], -) -> BResult<()> { - let base = opk(f, BinOp::ShiftLeftLogical, i, PRIMITIVE_SHIFT)?; - let zero = k32(f, 0)?; - let mut words = vec![ - (reach::KIND, kind), - (reach::STATE, state), - (reach::LAYER, zero), - (reach::SIZE, size), - ]; - for (v, vertex) in vertices.iter().enumerate() { - for (c, &w) in vertex.iter().enumerate() { - words.push((reach::VERTICES + 4 * v as u32 + c as u32, w)); - } - } - for (at, w) in words { - let to = opk(f, BinOp::IAdd, base, at)?; - let p = word_ptr(f, g.prims, to)?; - store(f, p, w)?; - } - Ok(()) -} - -/// The settle as a typed module, before serialization: the module -/// [`capture_settle_module`](super::capture_settle_module) serializes, which the CPU interpreter -/// runs. Its bindings are the symbols `PASS`, `TILES` and `STATUS`. -pub(super) fn settle_typed_module() -> BResult { - let mut b = ModuleBuilder::new(); - let (u32_, uvec3) = types(&mut b)?; - let pass = words_buffer(&mut b, PASS, u32_)?; - let tiles = words_buffer(&mut b, TILES, u32_)?; - let status = words_buffer(&mut b, STATUS, u32_)?; - let invocation = b.builtin(crate::spv::BuiltIn::GlobalInvocationId, IoDir::Input, uvec3)?; - let void = b.ty(Type::Void)?; - let mut f = b.function(void)?; - let pass = f.module().global_value(pass)?; - let tiles = f.module().global_value(tiles)?; - let status = f.module().global_value(status)?; - let invocation = f.module().global_value(invocation)?; - settle_body(&mut f, [pass, tiles, status], invocation)?; - f.ret(None)?; - let id = f.finish()?; - entry(&mut b, id, S::LOCAL_SIZE)?; - b.finalize() -} - -/// The settle's body: where the header counted a primitive near-far or unmeasured, invocation -/// `i` below the pass's mask words and the binding's words ORs the bits of the pass's tiles in -/// word `i` into it, and invocation 0 ORs `CAPTURED_REACH_UNMEASURED` into the status word. -fn settle_body( - f: &mut FunctionBuilder<'_>, - [pass, tiles, status]: [Value; 3], - invocation: Value, -) -> BResult<()> { - let gid = load(f, invocation)?; - let i = f.composite_extract(gid, &[0])?; - let len = f.array_length(pass, 0)?; - let header = opk(f, BinOp::UGreaterThanEqual, len, R::HEADER_WORDS)?; - let held = f.array_length(tiles, 0)?; - when(f, header, move |f| { - let at = |f: &mut FunctionBuilder<'_>, w: u32| { - let w = k32(f, w)?; - word(f, pass, w) - }; - let near_far = at(f, R::NEAR_FAR_WORD)?; - let unmeasured = at(f, R::UNMEASURED_WORD)?; - let near_far = nonzero(f, near_far)?; - let unmeasured = nonzero(f, unmeasured)?; - let fell = or(f, near_far, unmeasured)?; - let first = opk(f, BinOp::IEqual, i, 0)?; - let report = and(f, fell, first)?; - when(f, report, move |f| { - let at = k32(f, StatusWord::Status.index())?; - let p = word_ptr(f, status, at)?; - let bit = k32(f, StatusBits::CAPTURED_REACH_UNMEASURED.0)?; - f.atomic(AtomicOp::Or, p, Scope::Device, Semantics::RELAXED, bit)?; - Ok(()) - })?; - // The pass's tiles (`TileReachModule::mask_words`): its render area binned at most - // `AREA_LIMIT` a side, in tiles of 32 by 32 pixels, 32 by 16 at 4 samples. - let samples = at(f, reach::SAMPLES)?; - let four = opk(f, BinOp::IEqual, samples, 4)?; - let (k4, k5) = (k32(f, 4)?, k32(f, 5)?); - let log = sel(f, four, k4, k5)?; - let limit = k32(f, AREA_LIMIT)?; - let mut sides = [log; 2]; - for (side, (w, log)) in sides - .iter_mut() - .zip([(reach::AREA_W, k5), (reach::AREA_H, log)]) - { - let extent = at(f, w)?; - let extent = umin(f, extent, limit)?; - let one = k32(f, 1)?; - let size = op(f, BinOp::ShiftLeftLogical, one, log)?; - let up = op(f, BinOp::IAdd, extent, size)?; - let up = opk(f, BinOp::ISub, up, 1)?; - *side = op(f, BinOp::ShiftRightLogical, up, log)?; - } - let layers = at(f, reach::LAYERS)?; - let count = op(f, BinOp::IMul, sides[0], sides[1])?; - let count = op(f, BinOp::IMul, count, layers)?; - let words = opk(f, BinOp::IAdd, count, 31)?; - let words = opk(f, BinOp::ShiftRightLogical, words, 5)?; - let inside = op(f, BinOp::ULessThan, i, words)?; - let bound = op(f, BinOp::ULessThan, i, held)?; - let go = and(f, inside, bound)?; - let go = and(f, go, fell)?; - when(f, go, move |f| { - // The tiles from word `i`'s first on: all 32 bits, or the low `rest`. - let first = opk(f, BinOp::ShiftLeftLogical, i, 5)?; - let rest = op(f, BinOp::ISub, count, first)?; - let full = opk(f, BinOp::UGreaterThanEqual, rest, 32)?; - let zero = k32(f, 0)?; - let by = sel(f, full, zero, rest)?; - let one = k32(f, 1)?; - let part = op(f, BinOp::ShiftLeftLogical, one, by)?; - let part = opk(f, BinOp::ISub, part, 1)?; - let all = k32(f, u32::MAX)?; - let bits = sel(f, full, all, part)?; - let p = word_ptr(f, tiles, i)?; - let old = load(f, p)?; - let new = op(f, BinOp::BitwiseOr, old, bits)?; - store(f, p, new) - }) - }) -} diff --git a/crates/metal2vulkan/src/bind/capture_assembly/tests.rs b/crates/metal2vulkan/src/bind/capture_assembly/tests.rs deleted file mode 100644 index fd3235161..000000000 --- a/crates/metal2vulkan/src/bind/capture_assembly/tests.rs +++ /dev/null @@ -1,691 +0,0 @@ -//! The capture assembly and settle kernels against plain Rust references, through the CPU -//! interpreter in both invocation orders: the records' and entries' bytes; random draws of every -//! topology, instance counts, restarting strips with flagged records, culling on and off; the -//! scan's bound; entries that describe no primitive; the settle's two cases; and both modules -//! built and valid on every committed device. (That the placeholders reach nothing under the tile -//! reach rule is `tile_reach`'s test `assembly`.) - -use std::path::PathBuf; - -use super::kernel::{ - assembly_typed_module, settle_typed_module, DRAWS, PASS, PRIMITIVES, RECORDS, STATUS, TILES, -}; -use super::{ - capture_assembly_module, capture_settle_module, CaptureAssemblyModule as A, - CaptureSettleModule as S, NOTHING, UNKNOWN, -}; -use crate::bind::status::{ExecutionStatus, StatusBits, StatusWord}; -use crate::bind::tile_reach::TileReachModule as R; -use crate::device::{Device, DeviceDescription, DevicePolicy}; -use crate::metal::PrimitiveType; -use crate::pipeline::sym::ResourceSlot; -use crate::spirv::interp::{run, Buffer, Config, Order, Resources}; -use crate::spirv::ir::TypedModule; -use crate::spirv::testing::assert_valid; - -/// A splitmix64 stream. -struct Rng(u64); - -impl Rng { - fn next(&mut self) -> u64 { - self.0 = self.0.wrapping_add(0x9e37_79b9_7f4a_7c15); - let mut z = self.0; - z = (z ^ (z >> 30)).wrapping_mul(0xbf58_476d_1ce4_e5b9); - z = (z ^ (z >> 27)).wrapping_mul(0x94d0_49bb_1331_11eb); - z ^ (z >> 31) - } - - fn word(&mut self) -> u32 { - self.next() as u32 - } - - /// A number in `[0, n)`. - fn below(&mut self, n: u64) -> u64 { - self.next() % n - } - - /// True `k` times in `n`. - fn chance(&mut self, k: u64, n: u64) -> bool { - self.below(n) < k - } - - fn pick(&mut self, xs: &[X]) -> X { - xs[self.below(xs.len() as u64) as usize] - } -} - -/// Little-endian bytes as words. -fn words(bytes: &[u8]) -> Vec { - bytes - .as_chunks::<4>() - .0 - .iter() - .map(|w| u32::from_le_bytes(*w)) - .collect() -} - -fn bytes(words: &[u32]) -> Vec { - words.iter().flat_map(|w| w.to_le_bytes()).collect() -} - -fn buffer(slot: ResourceSlot, words: &[u32]) -> Buffer { - Buffer { - slot: Some(slot), - address: None, - bytes: bytes(words), - } -} - -/// The topologies, by raw value. -const TOPOLOGIES: [PrimitiveType; 5] = [ - PrimitiveType::Point, - PrimitiveType::Line, - PrimitiveType::LineStrip, - PrimitiveType::Triangle, - PrimitiveType::TriangleStrip, -]; - -/// What the assembly reads: the records, the draws' header and entries (words), and the -/// primitives' binding's words before the run. -#[derive(Clone, Debug)] -struct Batch { - records: Vec<[u32; 8]>, - draws: Vec, - out: Vec, -} - -impl Batch { - /// A batch of `entries` (each [`A::DRAW_WORDS`] words) after a header naming `named` of - /// them and `total` primitives, its primitives' binding `out` words of a fill pattern. - fn of(records: Vec<[u32; 8]>, named: u32, total: u32, entries: &[[u32; 8]], out: u32) -> Batch { - let mut draws = words(&A::header(named, total)); - draws.extend(entries.iter().flatten()); - Batch { - records, - draws, - out: (0..out).map(|w| 0xa5a5_0000 | w).collect(), - } - } - - /// The primitives' binding after the kernel ran, through the interpreter in both orders - /// (alike). - fn kernel(&self, m: &TypedModule) -> Vec { - let records: Vec = self.records.iter().flatten().copied().collect(); - let total = self.draws.get(1).copied().unwrap_or(0); - let mut outs = Vec::new(); - for order in [Order::Forward, Order::Reverse] { - let res = Resources { - buffers: vec![ - buffer(RECORDS, &records), - buffer(DRAWS, &self.draws), - buffer(PRIMITIVES, &self.out), - ], - push: Vec::new(), - spec: Default::default(), - }; - let cfg = Config { - order, - workgroups: [total.div_ceil(A::LOCAL_SIZE).max(1), 1, 1], - step_limit: 1 << 40, - ..Config::default() - }; - outs.push(run(m, &cfg, res).expect("run").buffers); - } - assert_eq!(outs[0], outs[1], "order independent"); - words(&outs[0][2]) - } - - /// The primitives' binding after the reference assembly: each primitive below the header's - /// total and the binding's whole primitives written by [`reference`]. - fn rule(&self) -> Vec { - let mut out = self.out.clone(); - if self.draws.len() < A::HEADER_WORDS as usize { - return out; - } - let (named, total) = (self.draws[0], self.draws[1]); - let entries: Vec<[u32; 8]> = self.draws[A::HEADER_WORDS as usize..] - .as_chunks::<{ A::DRAW_WORDS as usize }>() - .0 - .iter() - .copied() - .take(named as usize) - .collect(); - let fits = out.len() as u32 / R::PRIMITIVE_WORDS; - for i in 0..total.min(fits) { - let at = (i * R::PRIMITIVE_WORDS) as usize; - out[at..at + 16].copy_from_slice(&reference(&self.records, &entries, i)); - } - out - } - - /// Where the kernel and the reference differ, primitive by primitive. - fn differences(&self, m: &TypedModule) -> Vec { - let (kernel, rule) = (self.kernel(m), self.rule()); - if kernel == rule { - return Vec::new(); - } - let mut out = Vec::new(); - for (i, (k, r)) in kernel.chunks(16).zip(rule.chunks(16)).enumerate() { - if k != r { - out.push(format!( - "primitive {i}: kernel {k:08x?}, reference {r:08x?}" - )); - } - } - if out.is_empty() { - out.push("the binding differs past its whole primitives".to_string()); - } - out - } -} - -/// A primitive's 16 words: its kind, state, layer 0, size and vertices. -fn primitive(kind: u32, state: u32, size: u32, vertices: [[u32; 4]; 3]) -> [u32; 16] { - let mut w = [0; 16]; - w[0] = kind; - w[1] = state; - w[3] = size; - for (v, vertex) in vertices.iter().enumerate() { - w[4 + 4 * v..8 + 4 * v].copy_from_slice(vertex); - } - w -} - -/// The triangle of three `vertex`es, of size 0, under `state`. -fn placeholder(vertex: [u32; 4], state: u32) -> [u32; 16] { - primitive(R::TRIANGLE, state, 0, [vertex; 3]) -} - -/// Metal's assembly of primitive `i` of the pass (the module docs), in plain Rust: from the last -/// entry whose first primitive is at most `i` (entry 0 where none is), its `j`th primitive's -/// records, by its topology; a restarting strip's primitive touching a flagged record reaches -/// nothing; a triangle strip's triangle takes its parity from its piece's first record, found -/// over the whole instance, where the entry restarts and culls, and is unknown where the last -/// flagged record before it lies more than the scan's bound back (or, with none, where `j` does); -/// anything the entries do not describe is unknown. -fn reference(records: &[[u32; 8]], entries: &[[u32; 8]], i: u32) -> [u32; 16] { - let Some(e) = entries.iter().rev().find(|e| e[0] <= i).or(entries.first()) else { - return placeholder(UNKNOWN, 0); - }; - let [first, primitives, first_record, count, topology, restarts, culls, state] = *e; - let unknown = placeholder(UNKNOWN, state); - let j = i.wrapping_sub(first); - let record = |v: u32| -> Option<[u32; 8]> { - if v >= count { - return None; - } - let slot = first_record.checked_add(v)?; - records.get(slot as usize).copied() - }; - let (n, a) = match TOPOLOGIES.iter().find(|t| t.as_raw() == topology) { - Some(PrimitiveType::Point) => (1, j), - Some(PrimitiveType::Line) => (2, j.wrapping_mul(2)), - Some(PrimitiveType::LineStrip) => (2, j), - Some(PrimitiveType::Triangle) => (3, j.wrapping_mul(3)), - Some(PrimitiveType::TriangleStrip) => (3, j), - None => return unknown, - }; - if j >= primitives { - return unknown; - } - let Some(vs) = (0..n) - .map(|k| record(a.wrapping_add(k))) - .collect::>>() - else { - return unknown; - }; - let strip = topology == PrimitiveType::LineStrip.as_raw() - || topology == PrimitiveType::TriangleStrip.as_raw(); - let restarting = strip && restarts != 0; - if restarting && vs.iter().any(|r| r[5] != 0) { - return placeholder(NOTHING, state); - } - let triangle_strip = topology == PrimitiveType::TriangleStrip.as_raw(); - let mut odd = j % 2 == 1; - if triangle_strip && restarting && culls != 0 { - let flagged = |q: u32| record(q).is_some_and(|r| r[5] != 0); - let last = (0..j).rev().find(|&q| flagged(q)); - let known = match last { - Some(f) => j - f <= A::SCAN_LIMIT, - None => j <= A::SCAN_LIMIT, - }; - if !known { - return unknown; - } - odd = (j - last.map_or(0, |f| f + 1)) % 2 == 1; - } - let order = match triangle_strip && odd { - true => [0, 2, 1], - false => [0, 1, 2], - }; - let kind = match n { - 1 => R::POINT, - 2 => R::LINE, - _ => R::TRIANGLE, - }; - let mut vertices = [[0; 4]; 3]; - for (slot, &k) in vertices.iter_mut().zip(&order).take(n as usize) { - slot.copy_from_slice(&vs[k][..4]); - } - primitive(kind, state, vs[0][4], vertices) -} - -/// A record of random position and size words (any bits, or finite values), restarting where -/// `flag` (its restart word 1, or another value not zero). -fn random_record(rng: &mut Rng, flag: bool) -> [u32; 8] { - let mut position = [0f32; 4].map(|_| (rng.below(4001) as f32 - 2000.0) / 1000.0); - position[3] = 1.0; - let mut r = A::record(position, rng.below(64) as f32 / 4.0, flag); - if rng.chance(1, 8) { - r[..16].copy_from_slice(&bytes(&[0; 4].map(|_| rng.word()))); - } - let mut w: [u32; 8] = words(&r).try_into().expect("a record"); - if flag && rng.chance(1, 4) { - w[5] = rng.pick(&[2, 7, u32::MAX]); - } - w -} - -/// A seeded batch: up to six draws of random topologies, 1 to 3 instances each, of a few to a -/// few hundred records (some strips longer than the scan's bound), restarting strips with -/// flagged records at several densities, culling or not, under a few states; records of an -/// instance sometimes after a gap; an entry of no primitives sometimes kept. -fn random_batch(rng: &mut Rng) -> Batch { - let mut records = Vec::new(); - let mut entries = Vec::new(); - let mut total = 0; - for _ in 0..1 + rng.below(6) { - let topology = rng.pick(&TOPOLOGIES); - let strip = matches!( - topology, - PrimitiveType::LineStrip | PrimitiveType::TriangleStrip - ); - let long = match topology { - PrimitiveType::TriangleStrip => rng.chance(1, 3), - _ => rng.chance(1, 10), - }; - let count = match long { - true => 240 + rng.below(160), - false => { - let below = rng.pick(&[4, 16, 16, 64, 64]); - rng.below(below) - } - } as u32; - let restarts = rng.chance(3, 4); - let culls = rng.chance(1, 2); - let density = rng.pick(&[0, 0, 2, 8, 40, 200]); - let state = rng.below(4) as u32; - for _ in 0..1 + rng.below(3) { - if rng.chance(1, 4) { - for _ in 0..rng.below(5) { - records.push(random_record(rng, false)); - } - } - let first_record = records.len() as u32; - for _ in 0..count { - let flag = density != 0 && rng.chance(density, 1000); - records.push(random_record(rng, flag)); - } - let primitives = A::primitives(topology, count); - if primitives == 0 && rng.chance(1, 2) { - continue; - } - let restarts = restarts && (strip || rng.chance(1, 2)); - let e = A::draw(total, first_record, count, topology, restarts, culls, state); - entries.push(words(&e).try_into().expect("an entry")); - total += primitives; - } - } - let out = total * R::PRIMITIVE_WORDS + rng.below(20) as u32; - Batch::of(records, entries.len() as u32, total, &entries, out) -} - -/// A capture record's bytes, the draws' header's and an entry's are the documented words, and an -/// instance's primitives are its topology's. -#[test] -fn the_records_and_entries_are_the_documented_words() { - let r = A::record([1.5, -2.0, 0.25, 1.0], 3.0, true); - assert_eq!( - words(&r), - [ - 1.5f32.to_bits(), - (-2.0f32).to_bits(), - 0.25f32.to_bits(), - 1.0f32.to_bits(), - 3.0f32.to_bits(), - 1, - 0, - 0 - ] - ); - assert_eq!(words(&A::record([0.0; 4], 0.0, false))[5], 0); - assert_eq!(r.len(), 4 * A::RECORD_WORDS as usize); - assert_eq!(words(&A::header(7, 300)), [7, 300]); - let e = A::draw(40, 12, 9, PrimitiveType::TriangleStrip, true, false, 3); - assert_eq!(words(&e), [40, 7, 12, 9, 4, 1, 0, 3]); - let e = A::draw(0, 0, 9, PrimitiveType::Line, false, true, 0); - assert_eq!(words(&e), [0, 4, 0, 9, 1, 0, 1, 0]); - assert_eq!(e.len(), 4 * A::DRAW_WORDS as usize); - let primitives = |t: PrimitiveType| [0, 1, 2, 3, 7].map(|n| A::primitives(t, n)); - assert_eq!(primitives(PrimitiveType::Point), [0, 1, 2, 3, 7]); - assert_eq!(primitives(PrimitiveType::Line), [0, 0, 1, 1, 3]); - assert_eq!(primitives(PrimitiveType::LineStrip), [0, 0, 1, 2, 6]); - assert_eq!(primitives(PrimitiveType::Triangle), [0, 0, 0, 1, 2]); - assert_eq!(primitives(PrimitiveType::TriangleStrip), [0, 0, 0, 1, 5]); - assert_eq!(NOTHING.map(f32::from_bits), [0.0, 0.0, 0.0, 1.0]); - assert!(UNKNOWN.iter().all(|&w| f32::from_bits(w).is_nan())); -} - -/// On 48 seeded batches (every topology; 1 to 3 instances; restarting strips with flagged records -/// at several densities, culling or not; strips past the scan's bound; gaps between instances' -/// records; entries of no primitives), the kernel writes the reference's primitives. -#[test] -fn the_kernel_assembles_what_the_reference_does_on_random_draws() { - let m = assembly_typed_module().expect("module"); - let mut rng = Rng(0xca97_0a55); - let mut wrong = Vec::new(); - let (mut unknown, mut nothing) = (0, 0); - for _ in 0..48 { - let batch = random_batch(&mut rng); - let rule = batch.rule(); - for p in rule.as_chunks::<16>().0.iter() { - unknown += usize::from(p[4..8] == UNKNOWN); - nothing += usize::from(p[4..8] == NOTHING && p[0] == R::TRIANGLE && p[3] == 0); - } - wrong.extend(batch.differences(&m)); - } - assert!(wrong.is_empty(), "{}", wrong.join("\n")); - assert!( - unknown > 0 && nothing > 0, - "{unknown} unknown, {nothing} nothing" - ); -} - -/// A restarting triangle strip that culls, of 1000 records flagged at 100 and 700, then an -/// instance flagged nowhere: each triangle touching a flag reaches nothing; a piece's triangles -/// take their parity from its first record (101: even, 102: odd); a triangle is known up to -/// [`A::SCAN_LIMIT`] records past the last flag (356 and 956) and unknown beyond (357, 957), -/// and, with no flag, up to that many past vertex 0. The same strip that does not cull has no -/// unknown triangle and counts parity from vertex 0; one that does not restart ignores the flags. -#[test] -fn a_culling_strip_s_parity_is_its_piece_s_within_the_scan() { - let m = assembly_typed_module().expect("module"); - let mut rng = Rng(0x5ca7_1e55); - let count = 1000; - let mut records: Vec<[u32; 8]> = (0..count) - .map(|p| random_record(&mut rng, p == 100 || p == 700)) - .collect(); - records.extend((0..count).map(|_| random_record(&mut rng, false))); - let per = A::primitives(PrimitiveType::TriangleStrip, count); - for (restarts, culls) in [(true, true), (true, false), (false, true)] { - let entries: Vec<[u32; 8]> = (0..2) - .map(|n| { - let e = A::draw( - n * per, - n * count, - count, - PrimitiveType::TriangleStrip, - restarts, - culls, - 5, - ); - words(&e).try_into().expect("an entry") - }) - .collect(); - let batch = Batch::of(records.clone(), 2, 2 * per, &entries, 2 * per * 16); - let out = batch.kernel(&m); - assert_eq!(out, batch.rule(), "restarts {restarts}, culls {culls}"); - let at = |i: u32| &out[16 * i as usize..16 * i as usize + 16]; - let is = |i: u32, v: [u32; 4]| at(i)[4..8] == v; - let order = |i: u32| -> Vec { - (0..3) - .map(|v| { - let w = &at(i)[4 + 4 * v..8 + 4 * v]; - (0..count) - .find(|&q| records[q as usize][..4] == *w) - .expect("a record's position") - }) - .collect() - }; - let unknown: Vec = (0..2 * per).filter(|&i| is(i, UNKNOWN)).collect(); - let nothing: Vec = (0..2 * per).filter(|&i| is(i, NOTHING)).collect(); - match (restarts, culls) { - (true, true) => { - assert_eq!(nothing, [98, 99, 100, 698, 699, 700]); - assert_eq!(order(101), [101, 102, 103]); - assert_eq!(order(102), [102, 104, 103]); - assert_eq!(order(97), [97, 99, 98]); - assert!(!is(356, UNKNOWN) && is(357, UNKNOWN)); - assert!(!is(956, UNKNOWN) && is(957, UNKNOWN)); - let unflagged = (per + 257..2 * per).count(); - let expect = (357..698).count() + (957..per).count() + unflagged; - assert_eq!(unknown.len(), expect); - assert!(!is(per + 256, UNKNOWN) && is(per + 257, UNKNOWN)); - } - (true, false) => { - assert_eq!(nothing, [98, 99, 100, 698, 699, 700]); - assert!(unknown.is_empty()); - assert_eq!(order(101), [101, 103, 102]); - } - (false, _) => { - assert!(nothing.is_empty() && unknown.is_empty()); - assert_eq!(order(101), [101, 103, 102]); - } - } - } -} - -/// Entries that describe no primitive, and bindings that hold less than the header names: the -/// kernel writes the unknown triangle (no entry, a topology that is none, primitives past the -/// entry's records or the records' binding) and nothing past the primitives' binding or without -/// a header, as the reference does. -#[test] -fn what_the_entries_do_not_describe_is_unknown() { - let m = assembly_typed_module().expect("module"); - let mut rng = Rng(0x0dd5_e575); - let records: Vec<[u32; 8]> = (0..12).map(|_| random_record(&mut rng, false)).collect(); - let raw = |first, primitives, first_record, count, topology, state| { - [ - first, - primitives, - first_record, - count, - topology, - 0, - 0, - state, - ] - }; - let triangles = PrimitiveType::Triangle.as_raw(); - // Each case, the unknown primitives it writes, and the batch. - let cases: Vec<(&str, usize, Batch)> = vec![ - ("no entry", 3, Batch::of(records.clone(), 0, 3, &[], 48)), - ( - "topologies that are none", - 3, - Batch::of( - records.clone(), - 3, - 3, - &[ - raw(0, 1, 0, 3, 5, 1), - raw(1, 1, 0, 3, 7, 2), - raw(2, 1, 0, 3, u32::MAX, 3), - ], - 48, - ), - ), - ( - "primitives past the entry's records", - 2, - Batch::of(records.clone(), 1, 4, &[raw(0, 4, 0, 6, triangles, 1)], 64), - ), - ( - "records past the binding", - 1, - Batch::of(records.clone(), 1, 3, &[raw(0, 3, 6, 9, triangles, 2)], 48), - ), - ( - "a first primitive past the invocation's", - 2, - Batch::of(records.clone(), 1, 3, &[raw(2, 3, 0, 9, triangles, 4)], 48), - ), - ( - "more entries named than held", - 0, - Batch::of(records.clone(), 9, 3, &[raw(0, 3, 0, 9, triangles, 4)], 48), - ), - ( - "a total past the primitives' binding", - 0, - Batch::of(records.clone(), 1, 4, &[raw(0, 4, 0, 12, triangles, 4)], 40), - ), - ]; - let mut wrong = Vec::new(); - for (what, unknown, batch) in cases { - let rule = batch.rule(); - let written = rule - .as_chunks::<16>() - .0 - .iter() - .filter(|p| p[4..8] == UNKNOWN) - .count(); - if written != unknown { - wrong.push(format!( - "{what}: the reference writes {written} unknown, not {unknown}" - )); - } - wrong.extend( - batch - .differences(&m) - .into_iter() - .map(|d| format!("{what}: {d}")), - ); - } - let mut short = Batch::of(records, 1, 3, &[raw(0, 3, 0, 9, triangles, 4)], 48); - short.draws.truncate(1); - assert_eq!(short.kernel(&m), short.out, "no header: nothing written"); - assert!(wrong.is_empty(), "{}", wrong.join("\n")); -} - -/// The settle on passes of render areas past and within the bound, 1, 2 and 4 samples and -/// several layers: where neither count is set the mask and the status are unchanged; where the -/// near-far or the unmeasured count is, every tile's bit of the pass is set, the last word's to -/// its last tile, the words past the pass's mask are unchanged, and the status reports -/// `captured_reach_unmeasured` beside the bits it held. -#[test] -fn the_settle_sets_every_tile_where_a_count_is_set() { - let m = settle_typed_module().expect("module"); - let mut rng = Rng(0x5e77_1e00); - let passes = [ - ([100, 70], 1, 1), - ([300, 300], 4, 3), - ([20000, 100], 1, 1), - ([33, 31], 2, 5), - ([1, 1], 4, 1), - ([4096, 2048], 1, 2), - ]; - for (area, samples, layers) in passes { - let rows = if samples == 4 { 16 } else { 32 }; - let [w, h] = area.map(|a: u32| a.min(16384)); - let tiles = w.div_ceil(32) * h.div_ceil(rows) * layers; - let mask = R::mask_words(area, samples, layers); - assert_eq!(mask, tiles.div_ceil(32)); - for (near_far, unmeasured) in [(0, 0), (3, 0), (0, 1), (2, 5)] { - let mut pass = words(&R::header(area, samples, layers, 9)); - pass[R::NEAR_FAR_WORD as usize] = near_far; - pass[R::UNMEASURED_WORD as usize] = unmeasured; - pass.extend(words(&R::state([0.0; 4], [0; 4], 0, 0, 0))); - let before: Vec = (0..mask + 3).map(|_| rng.word() & rng.word()).collect(); - // Another writer's bit, kept. - let mut status = words(&ExecutionStatus::initial()); - status[StatusWord::Status.index() as usize] = StatusBits::OVERFLOW.0; - let mut outs = Vec::new(); - for order in [Order::Forward, Order::Reverse] { - let res = Resources { - buffers: vec![ - buffer(PASS, &pass), - buffer(TILES, &before), - buffer(STATUS, &status), - ], - push: Vec::new(), - spec: Default::default(), - }; - let cfg = Config { - order, - workgroups: [(mask + 3).div_ceil(S::LOCAL_SIZE), 1, 1], - step_limit: 1 << 32, - ..Config::default() - }; - outs.push(run(&m, &cfg, res).expect("run").buffers); - } - assert_eq!(outs[0], outs[1], "order independent"); - let after = words(&outs[0][1]); - let fell = near_far != 0 || unmeasured != 0; - let expect: Vec = before - .iter() - .enumerate() - .map(|(i, &old)| { - let first = 32 * i as u32; - let bits = match tiles.saturating_sub(first) { - 0 => 0, - rest if rest >= 32 => u32::MAX, - rest => (1 << rest) - 1, - }; - match fell { - true => old | bits, - false => old, - } - }) - .collect(); - let case = format!("{area:?} {samples} {layers} {near_far} {unmeasured}"); - assert_eq!(after, expect, "{case}"); - let report: [u8; ExecutionStatus::BYTES] = outs[0][2].clone().try_into().expect("32"); - let report = ExecutionStatus::decode(&report); - assert_eq!(report.captured_reach_unmeasured, fell, "{case}"); - assert!(report.overflow, "{case}"); - } - } -} - -/// Every committed device (`validation/profiles/*.json`), derived with the default policy, by -/// file stem. -fn committed_devices() -> Vec<(String, Device)> { - let dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../metal2vulkan-validation/profiles"); - let mut out = Vec::new(); - for entry in std::fs::read_dir(&dir).expect("profiles") { - let path = entry.expect("entry").path(); - if path.extension().is_none_or(|x| x != "json") { - continue; - } - let stem = path - .file_stem() - .map(|s| s.to_string_lossy().into_owned()) - .unwrap_or_default(); - let text = std::fs::read_to_string(&path).expect("read"); - let desc = DeviceDescription::from_khronos_json(&text, None).expect("description"); - let device = Device::new(desc, DevicePolicy::default()).expect("device"); - out.push((stem, device)); - } - out.sort_by(|a, b| a.0.cmp(&b.0)); - out -} - -/// On every committed device (those the tile reach module's device tests derive) both modules are -/// built, valid and within the profile: they need nothing past Vulkan 1.2. -#[test] -fn both_modules_are_valid_on_every_committed_device() { - let devices = committed_devices(); - assert!(!devices.is_empty()); - for (name, device) in devices { - let profile = device.profile(); - let assembly = capture_assembly_module(&device).unwrap_or_else(|e| panic!("{name}: {e}")); - assert!(!assembly.spirv.is_empty(), "{name}"); - assert!(profile.check(&assembly.requirements).is_ok(), "{name}"); - assert_valid(assembly_typed_module().expect("module"), profile); - let settle = capture_settle_module(&device).unwrap_or_else(|e| panic!("{name}: {e}")); - assert!(!settle.spirv.is_empty(), "{name}"); - assert!(profile.check(&settle.requirements).is_ok(), "{name}"); - assert_valid(settle_typed_module().expect("module"), profile); - } -} diff --git a/crates/metal2vulkan/src/bind/graphics.rs b/crates/metal2vulkan/src/bind/graphics.rs index dfaa0bf6d..4c7ec4e0b 100644 --- a/crates/metal2vulkan/src/bind/graphics.rs +++ b/crates/metal2vulkan/src/bind/graphics.rs @@ -118,7 +118,7 @@ //! sample, no depth or stencil attachment, no rasterizer discard, no memory the vertex or //! fragment function writes, no attachment in the storage form or input attachment, no //! imageblock, tile memory, shader-side stencil or tests, no interlocked or shadowed colors, no -//! capture form, no tessellation or mesh stages, and no amplified or layered draw. Every other +//! tessellation or mesh stages, and no amplified or layered draw. Every other //! slot the shape names is left out, and the plan's `variant.snapshot_textures` says which it //! kept. Its plan binds each slot's snapshot (`WriteSource::SnapshotTexels`) and leaves which of //! the two draws runs to the consumer (`PushHole::SnapshotPhase`, zero in the plan's bytes); @@ -157,20 +157,6 @@ //! without the early-tests variant, runs the variant whose function runs both, //! `VariantKey::shader_stencil`, in a pass with a depth and a stencil attachment; a pass with a //! stencil attachment alone is `NotImplemented(FramebufferFetch)` at it.) -//! - **Capture form**. A pipeline compiled under `VariantKey::captured_positions` -//! (`RuntimeFact::CapturedPositions`), which a consumer asks for and no bind shape does, plans -//! its own variant. Its draws leave `PushHole::CaptureAddress` to the consumer (the first -//! record's address) and write `PushField::CaptureLayout` from the draw. A direct draw -//! without an index buffer is the vertices form's: its first vertex, vertex count, first -//! instance and 0. A direct indexed draw is the indexed form's: it runs without indices as -//! `index count` vertices from 0 with its instances, its layout `[restarts, index count, base -//! instance, base vertex]` (`restarts` 1 for a line or triangle strip, from -//! `BindState::primitive_type`; `MissingPrimitiveType` without one), leaves -//! `PushHole::CaptureIndexAddress` to the consumer (its first index's address), and reads its -//! indices in the vertex stage as storage (`DrawCommands::uses`). -//! A draw of the other form is `NeedsVariant` with that form; an indexed draw whose indices run -//! past its buffer or whose index offset is not a multiple of the index size, an indirect draw, -//! and an amplified one are `NotImplemented(TileReach)`. //! - **Draws.** A Metal draw maps to the Vulkan draw of the same arguments; an indirect draw is //! GPU-side unless a stage reads `BaseVertexInstance` from push constants or the plan is //! multiview, in which case `indirect_needs_arguments` asks for the CPU read. @@ -179,9 +165,10 @@ //! primitive (`BindState::primitive_type`; `MissingPrimitiveType` without one), a direct or //! indirect draw's alike. An indexed draw of such a pipeline, whose vertices primitives share, //! runs its de-indexed variant of the draw's index type (`BindShape::primitive_id_indices`, -//! `VariantKey::primitive_id_indices`) as the indexed capture form's draw: `index count` -//! vertices from 0, layout `[0, index count, base instance, base vertex]`, its indices read in -//! the vertex stage at `PushHole::CaptureIndexAddress`; any other draw of that variant is +//! `VariantKey::primitive_id_indices`): `index count` vertices from 0 with its instances, +//! layout `[0, index count, base instance, base vertex]` (`PushField::CaptureLayout`), leaving +//! `PushHole::CaptureIndexAddress` to the consumer (its first index's address), and reading its +//! indices in the vertex stage as storage (`DrawCommands::uses`); any other draw of that variant is //! `NeedsVariant` without it. A strip, an indirect indexed draw, indices past their buffer and //! an indexed draw of a plan without the form are `NotImplemented(PrimitiveId)`. A draw of one //! of Metal's private primitive types in the private list form (`BindShape::private_list`, @@ -354,7 +341,7 @@ use crate::pipeline::sym::{ Axis, DispatchKeys, PushField, SlotClass, SlotRef, SpecKey, Stage, SyntheticBinding, }; use crate::pipeline::vertex::{VertexAttribute, VertexStride}; -use crate::pipeline::{AmplificationDraws, CaptureForm, ViewportCompensation}; +use crate::pipeline::{AmplificationDraws, ViewportCompensation}; use crate::vk; /// A Metal draw call. @@ -486,7 +473,7 @@ pub struct DrawCommands { /// dynamic strides makes static pipeline state. pub vertex_strides: Vec<(u32, u32)>, /// The draw's own resources beyond the plan's `uses`: its index buffer and indirect - /// arguments. A capture variant's indexed draw reads its indices in the vertex stage as storage + /// arguments. A de-indexed draw reads its indices in the vertex stage as storage /// (`VERTEX_SHADER`, from the index offset over its indices), by address, and binds no index /// buffer. pub uses: Vec, @@ -1116,15 +1103,6 @@ fn plan(p: &RenderPipeline, device: &Device, shape: &BindShape) -> Result Some(form), - _ => None, - }); - if captured_positions.is_some() && shape.vertex_amplification.count > 1 { - return Err(not_implemented(Feature::TileReach)); - } // A pipeline whose vertex function writes the primitive ID's varying runs an indexed draw // in its de-indexed form, of the draw's index type. let writes_primitive_ids = p.interface.push.iter().any(|pl| { @@ -1357,7 +1335,7 @@ fn plan(p: &RenderPipeline, device: &Device, shape: &BindShape) -> Result Result Result Result reads_root_table = true, PushField::ExecutionStatusAddress => {} - // A capture variant's records, its draw's indices, and its draw's layout: the - // addresses are the consumer's holes, the layout instantiation writes from the - // draw. - PushField::CaptureAddress - | PushField::CaptureIndexAddress - | PushField::CaptureLayout + // A de-indexed or private list draw's indices, and its draw's layout: the address + // is the consumer's hole, the layout instantiation writes from the draw. + PushField::CaptureIndexAddress | PushField::CaptureLayout if stage == Stage::Vertex => {} PushField::BaseVertexInstance if stage == Stage::Vertex => {} // A merged draw replay's header: the consumer's hole. @@ -2536,9 +2509,6 @@ fn plan(p: &RenderPipeline, device: &Device, shape: &BindShape) -> Result Result capture_form(draw)?.index_type(), - _ => None, - }; + if t.deindexed.is_some() { + let asked = draw_index_type(draw); if asked != t.deindexed { return Err(BindError::NeedsVariant { variant: Box::new(VariantKey { @@ -2807,18 +2773,6 @@ impl BindingPlan { }); } } - // A draw of the other capture form runs on that form's variant. - if let Some(form) = t.capture { - let asked = capture_form(draw)?; - if asked != form { - return Err(BindError::NeedsVariant { - variant: Box::new(VariantKey { - captured_positions: Some(asked), - ..self.variant.clone() - }), - }); - } - } instantiate(t, state, draw, commands) } } @@ -4099,111 +4053,29 @@ fn multiview_instances(limit: Option, draw: &DrawCall) -> Result<(), BindEr ))) } -/// The capture form `draw` runs on: a direct draw without an index buffer the vertices form, a -/// direct indexed draw the indexed form of its index type. An indirect draw's counts are the -/// GPU's, and a patch or mesh draw has no vertex function's vertices: each is not implemented -/// (`Feature::TileReach`). -fn capture_form(draw: &DrawCall) -> Result { +/// The index type of `draw`, a direct indexed draw of one of Metal's index types; `None` for any +/// other draw. +fn draw_index_type(draw: &DrawCall) -> Option { match *draw { - DrawCall::Primitives { .. } => Ok(CaptureForm::Vertices), DrawCall::Indexed { index_type, .. } if index_type == vk::IndexType::UINT16 => { - Ok(CaptureForm::Indexed(metal::IndexType::UInt16)) + Some(metal::IndexType::UInt16) } DrawCall::Indexed { index_type, .. } if index_type == vk::IndexType::UINT32 => { - Ok(CaptureForm::Indexed(metal::IndexType::UInt32)) + Some(metal::IndexType::UInt32) } - _ => Err(not_implemented(Feature::TileReach)), + _ => None, } } -/// How a draw of a capture variant runs: `PushField::CaptureLayout`'s words, from which each -/// vertex's record slot follows, and for the indexed form the Vulkan draw it runs as and its index -/// read. -struct CaptureDraw { +/// How an indexed draw runs on the primitive ID's de-indexed variant +/// ([`deindexed_draw`]): `PushField::CaptureLayout`'s words, the Vulkan draw it runs as and its +/// index read. +struct DeindexedDraw { layout: [u32; 4], - /// The indexed form's draw: without indices, `index count` vertices from 0, with the draw's - /// instances. - command: Option, - /// The indexed form's read of its indices, from the index offset, as storage in the vertex - /// stage. - indices: Option, -} - -/// How `draw` (whose `overrun` is [`index_overrun`]'s, of primitive type `primitive`) runs on a -/// capture variant of `form`: a draw of the vertices form as it is, with layout `[vertex start, -/// vertex count, base instance, 0]`; one of the indexed form as `index count` vertices from 0, -/// with layout `[restarts, index count, base instance, base vertex]`, `restarts` 1 for a line or -/// triangle strip, which Metal restarts at the all-ones index (`MissingPrimitiveType` without a -/// primitive type). An indexed draw whose indices run past its buffer, or whose index offset is -/// not a multiple of the index size, is not implemented (`feature`, the form's). A draw of -/// another form never reaches here (`instantiate_draw` asks for its variant). -fn capture_draw( - form: CaptureForm, - draw: &DrawCall, - overrun: Option, - primitive: Option, - feature: Feature, -) -> Result { - match (capture_form(draw)?, *draw) { - ( - asked @ CaptureForm::Vertices, - DrawCall::Primitives { - vertex_start, - vertex_count, - base_instance, - .. - }, - ) if asked == form => Ok(CaptureDraw { - layout: [vertex_start, vertex_count, base_instance, 0], - command: None, - indices: None, - }), - ( - asked @ CaptureForm::Indexed(_), - DrawCall::Indexed { - index_type, - index_count, - index_offset, - instance_count, - base_vertex, - base_instance, - .. - }, - ) if asked == form => { - let size = index_bytes(index_type) - .ok_or_else(|| internal("an indexed capture draw without an index size"))?; - if overrun.is_some() || !index_offset.is_multiple_of(size) { - return Err(not_implemented(feature)); - } - let restarts = match primitive.ok_or(BindError::MissingPrimitiveType)? { - metal::PrimitiveType::LineStrip | metal::PrimitiveType::TriangleStrip => 1, - metal::PrimitiveType::Point - | metal::PrimitiveType::Line - | metal::PrimitiveType::Triangle => 0, - }; - Ok(CaptureDraw { - // The base vertex's two's-complement bits: the function adds it wrapping. - layout: [restarts, index_count, base_instance, base_vertex as u32], - command: Some(vk::DrawCommand::Draw { - vertex_count: index_count, - instance_count, - first_vertex: 0, - first_instance: base_instance, - }), - indices: Some(ResourceUse { - resource: UseTarget::IndexBuffer, - access: AccessSet::READ, - class: AccessClass::Storage, - stages: vk::PipelineStageFlags2::VERTEX_SHADER, - range: Some(ByteRange { - offset: 0, - len: u64::from(index_count) * size, - }), - }), - }) - } - _ => Err(internal("a draw of another capture form than its plan's")), - } + /// Without indices, `index count` vertices from 0, with the draw's instances. + command: vk::DrawCommand, + /// Its read of its indices, from the index offset, as storage in the vertex stage. + indices: ResourceUse, } /// `PushField::VerticesPerPrimitive` for `draw` of primitive type `primitive` @@ -4211,7 +4083,7 @@ fn capture_draw( /// strip or points. The vertex function reads the draw's first vertex as its base vertex, an /// indirect draw's from its arguments as the GPU draws it. An indexed draw shares a vertex among /// primitives, whose flat inputs read it alike: it runs `from_zero`, its indices drawn as -/// vertices from 0 (the de-indexed or the indexed capture form, [`capture_draw`]), and is +/// vertices from 0 (the de-indexed form, [`deindexed_draw`]), and is /// otherwise `NotImplemented(PrimitiveId)`. A draw in the private list form (`listed`) is the /// consumer's list, run without indices whatever its call: twice that where it lists Metal's /// quads or quad strip as two triangles a quad (`quads`), whose primitive Metal counts once. @@ -4237,33 +4109,70 @@ fn vertices_per_primitive( } /// How an indexed draw runs on the primitive ID's de-indexed variant of index type `ty` -/// (`VariantKey::primitive_id_indices`): as the indexed capture form's draw ([`capture_draw`]), -/// `index count` vertices from 0 without indices, with layout `[0, index count, base instance, -/// base vertex]`, its indices read in the vertex stage. A line or triangle strip, which Metal -/// restarts at the all-ones index, an indexed draw whose indices run past its buffer or whose -/// index offset is not a multiple of the index size, and any other draw are -/// `NotImplemented(PrimitiveId)` (`MissingPrimitiveType` without a primitive type). +/// (`VariantKey::primitive_id_indices`): `index count` vertices from 0 without indices, with the +/// draw's instances, its layout `[0, index count, base instance, base vertex]`, its indices read +/// in the vertex stage. A line or triangle strip, which Metal restarts at the all-ones index, an +/// indexed draw whose indices run past its buffer or whose index offset is not a multiple of the +/// index size, and any other draw are `NotImplemented(PrimitiveId)` (`MissingPrimitiveType` +/// without a primitive type). A draw of another index type never reaches here +/// (`instantiate_draw` asks for its variant). fn deindexed_draw( ty: metal::IndexType, draw: &DrawCall, overrun: Option, primitive: Option, -) -> Result { - match (primitive.ok_or(BindError::MissingPrimitiveType)?, draw) { - ( - metal::PrimitiveType::Point - | metal::PrimitiveType::Line - | metal::PrimitiveType::Triangle, - DrawCall::Indexed { .. }, - ) => capture_draw( - CaptureForm::Indexed(ty), - draw, - overrun, - primitive, - Feature::PrimitiveId, - ), - _ => Err(not_implemented(Feature::PrimitiveId)), +) -> Result { + let listed = match primitive.ok_or(BindError::MissingPrimitiveType)? { + metal::PrimitiveType::Point + | metal::PrimitiveType::Line + | metal::PrimitiveType::Triangle => true, + metal::PrimitiveType::LineStrip | metal::PrimitiveType::TriangleStrip => false, + }; + let DrawCall::Indexed { + index_type, + index_count, + index_offset, + instance_count, + base_vertex, + base_instance, + .. + } = *draw + else { + return Err(not_implemented(Feature::PrimitiveId)); + }; + if !listed { + return Err(not_implemented(Feature::PrimitiveId)); } + if draw_index_type(draw) != Some(ty) { + return Err(internal( + "a de-indexed draw of another index type than its plan's", + )); + } + let size = index_bytes(index_type) + .ok_or_else(|| internal("a de-indexed draw without an index size"))?; + if overrun.is_some() || !index_offset.is_multiple_of(size) { + return Err(not_implemented(Feature::PrimitiveId)); + } + Ok(DeindexedDraw { + // The base vertex's two's-complement bits: the function adds it wrapping. + layout: [0, index_count, base_instance, base_vertex as u32], + command: vk::DrawCommand::Draw { + vertex_count: index_count, + instance_count, + first_vertex: 0, + first_instance: base_instance, + }, + indices: ResourceUse { + resource: UseTarget::IndexBuffer, + access: AccessSet::READ, + class: AccessClass::Storage, + stages: vk::PipelineStageFlags2::VERTEX_SHADER, + range: Some(ByteRange { + offset: 0, + len: u64::from(index_count) * size, + }), + }, + }) } /// The commands of `draw` of `state`, written over `out` (`BindingPlan::instantiate_draw_into`): @@ -4299,18 +4208,11 @@ fn instantiate( } = out; let overrun = index_overrun(t.robust_index_fetch, draw); let (command, base) = vk_draw(draw, overrun); - let capture = match (t.capture, t.deindexed) { - (Some(form), _) => Some(capture_draw( - form, - draw, - overrun, - state.primitive_type, - Feature::TileReach, - )?), - (None, Some(ty)) => Some(deindexed_draw(ty, draw, overrun, state.primitive_type)?), - (None, None) => None, + let deindexed = match t.deindexed { + Some(ty) => Some(deindexed_draw(ty, draw, overrun, state.primitive_type)?), + None => None, }; - let command = capture.as_ref().and_then(|c| c.command).unwrap_or(command); + let command = deindexed.as_ref().map_or(command, |d| d.command); // A mesh render pipeline makes mesh draws, and only it does. let mesh = match (&t.mesh, mesh_threads(draw)) { (Some(m), Some(_)) => Some(mesh_draw(m, draw, command)?), @@ -4388,7 +4290,6 @@ fn instantiate( let bytes: FieldBytes = match f.field { PushField::RootTableAddress | PushField::ExecutionStatusAddress - | PushField::CaptureAddress | PushField::CaptureIndexAddress | PushField::MergedDrawAddress | PushField::SnapshotPhase @@ -4404,7 +4305,6 @@ fn instantiate( PushField::ExecutionStatusAddress => { PushHole::ExecutionStatusAddress { stages, offset } } - PushField::CaptureAddress => PushHole::CaptureAddress { stages, offset }, PushField::SnapshotPhase => PushHole::SnapshotPhase { stages, offset }, PushField::MergedDrawAddress => { PushHole::MergedDrawAddress { stages, offset } @@ -4416,9 +4316,9 @@ fn instantiate( }); continue; } - PushField::CaptureLayout => match &capture { - Some(c) => FieldBytes::words(c.layout.iter().copied()), - None => return Err(internal("a capture layout without its capture form")), + PushField::CaptureLayout => match &deindexed { + Some(d) => FieldBytes::words(d.layout.iter().copied()), + None => return Err(internal("a draw layout without its de-indexed form")), }, PushField::ShadowStencilState => { let Some(shadow) = &t.shadow_stencil else { @@ -4509,7 +4409,7 @@ fn instantiate( FieldBytes::words(base) } PushField::VerticesPerPrimitive => { - let from_zero = capture.as_ref().is_some_and(|c| c.command.is_some()); + let from_zero = deindexed.is_some(); let form = (from_zero, t.private_list, state.quad_primitive_ids); FieldBytes::of( &vertices_per_primitive(draw, state.primitive_type, form)?.to_le_bytes(), @@ -4716,10 +4616,10 @@ fn instantiate( Some(m) => (m.dispatch, Some(m.specialization)), None => (None, None), }; - // The indexed capture form reads its indices in the vertex stage, by address, and binds no - // index buffer. + // The de-indexed form reads its indices in the vertex stage, by address, and binds no index + // buffer. uses.clear(); - match capture.as_ref().and_then(|c| c.indices) { + match deindexed.as_ref().map(|d| d.indices) { Some(indices) => uses.push(indices), None => draw_uses(uses, draw, overrun, t.tessellation.as_ref()), } diff --git a/crates/metal2vulkan/src/bind/graphics/tests.rs b/crates/metal2vulkan/src/bind/graphics/tests.rs index 47fc16f4f..0c8fb06f2 100644 --- a/crates/metal2vulkan/src/bind/graphics/tests.rs +++ b/crates/metal2vulkan/src/bind/graphics/tests.rs @@ -604,7 +604,6 @@ fn instantiation_bounds_a_draw_by_its_index_buffer() { shadow_stencil: None, mesh: None, shader_tests: None, - capture: None, deindexed: None, private_list: false, storage_kept: 0, @@ -653,7 +652,6 @@ fn a_draw_of_no_index_binds_inside_the_buffer() { shadow_stencil: None, mesh: None, shader_tests: None, - capture: None, deindexed: None, private_list: false, storage_kept: 0, @@ -737,7 +735,6 @@ fn an_unbounded_indexed_indirect_draw_reads_its_arguments() { shadow_stencil: None, mesh: None, shader_tests: None, - capture: None, deindexed: None, private_list: false, storage_kept: 0, @@ -795,7 +792,6 @@ fn draws_bind_vertex_buffers_at_aligned_offsets_with_their_windows() { shadow_stencil: None, mesh: None, shader_tests: None, - capture: None, deindexed: None, private_list: false, storage_kept: 0, @@ -886,7 +882,6 @@ fn inline_vertex_bytes_bind_the_strides_a_dynamic_layout_reads() { shadow_stencil: None, mesh: None, shader_tests: None, - capture: None, deindexed: None, private_list: false, storage_kept: 0, @@ -1521,7 +1516,6 @@ fn mesh_template(flat: bool, multiples: Vec) -> GraphicsTemplate { records: None, }), shader_tests: None, - capture: None, deindexed: None, private_list: false, storage_kept: 0, diff --git a/crates/metal2vulkan/src/bind/instantiate.rs b/crates/metal2vulkan/src/bind/instantiate.rs index 4c899a4c6..9b2698468 100644 --- a/crates/metal2vulkan/src/bind/instantiate.rs +++ b/crates/metal2vulkan/src/bind/instantiate.rs @@ -82,28 +82,14 @@ pub enum PushHole { stages: vk::ShaderStageFlags, offset: u32, }, - /// The device address of the draw's first capture record, as a `u64` at `offset` of a - /// capture variant's vertex push bytes (`VariantKey::captured_positions`): a multiple of 16, - /// in a buffer of `SHADER_DEVICE_ADDRESS` usage that the draw's vertex stage writes - /// (`VERTEX_SHADER`, `SHADER_WRITE`), holding 32 bytes for each vertex of each instance the - /// draw runs (each index of an indexed draw). The record of the draw's vertex `v` (from its - /// first; an indexed draw's index position) in instance `i` (from its first) is at - /// `32 (v + i · vertex count)`: its clip position's four `f32`s at byte 0, as the vertex - /// function returned them (before any viewport compensation), its point size's `f32` at byte - /// 16 (1.0 where the function writes none), a `u32` at byte 20 that is 1 where an indexed - /// draw's index there is its type's all-ones value (Metal's strip restart index) and 0 - /// otherwise, and two words the draw leaves as they were. - CaptureAddress { - stages: vk::ShaderStageFlags, - offset: u32, - }, - /// The device address of an indexed capture draw's first index (`CaptureForm::Indexed`), as - /// a `u64` at `offset` of the capture variant's vertex push bytes: the draw's index buffer's + /// The device address of a de-indexed draw's first index (`VariantKey::primitive_id_indices`), + /// as a `u64` at `offset` of the variant's vertex push bytes: the draw's index buffer's /// address plus its index offset, which the binder requires to be a multiple of the index - /// size, in a buffer of `SHADER_DEVICE_ADDRESS` usage whose address is a multiple of 4. The - /// draw reads its indices there in the vertex stage (`DrawCommands::uses`, as storage); a - /// `u16` index is read in the aligned 4-byte word that holds it, which lies inside the - /// `VkBuffer` an `IndexBufferRef` describes. + /// size, in a buffer of `SHADER_DEVICE_ADDRESS` usage whose address is a multiple of 4; or a + /// private list form draw's list (`VariantKey::private_list`). The draw reads its indices + /// there in the vertex stage (`DrawCommands::uses`, as storage); a `u16` index is read in the + /// aligned 4-byte word that holds it, which lies inside the `VkBuffer` an `IndexBufferRef` + /// describes. CaptureIndexAddress { stages: vk::ShaderStageFlags, offset: u32, @@ -697,7 +683,7 @@ pub(crate) fn bind_buffers( /// The bytes of one push field ([`put`]): held in place up to [`FieldBytes::INLINE`] bytes, as /// every field of a few words is, so writing a draw's or a dispatch's fields allocates nothing; -/// a longer one (a capture's layout) on the heap. +/// a longer one on the heap. pub(crate) enum FieldBytes { /// The first `len` bytes of `bytes`. Inline { diff --git a/crates/metal2vulkan/src/bind/mod.rs b/crates/metal2vulkan/src/bind/mod.rs index e6bb36288..fd613b3b2 100644 --- a/crates/metal2vulkan/src/bind/mod.rs +++ b/crates/metal2vulkan/src/bind/mod.rs @@ -95,13 +95,7 @@ //! [`two_plane_texels_module`]; a blit into such a texture of a heap writes the heap's bytes at //! Metal's rows through [`plane_bytes_copy_module`]. A heap texture over host pages keeps its //! elements in the heap's bytes in Metal's tiled layout, moved between its image and those bytes -//! through [`tiled_texels_module`]. A render pass that loads an extended-range, padded 10-bit or -//! bfloat color attachment and draws first rewrites the bits its codes leave unused through -//! [`unused_bits_module`] of its format, in the 32 x 32 tiles a mask names, as Metal's tile store -//! does. The tiles a pass's draws reach, which Metal's tile store writes back, are the mask one -//! dispatch of [`tile_reach_module`] bins its captured primitives into: [`capture_assembly_module`] -//! assembles them from a pass's capture draws' records, and [`capture_settle_module`] widens the -//! mask to every tile where the binning counted a primitive it cannot answer. An ASTC LDR texture +//! through [`tiled_texels_module`]. An ASTC LDR texture //! on a device without its block is read through a twin of Metal's decode of its blocks //! ([`AstcDecode`], in the texels [`AstcTexels`] names), which [`astc_decode_module`] writes from //! the blocks each write left, each decode module of [`BlockDecodeModule`]'s shape; a @@ -132,7 +126,6 @@ pub(crate) mod acceleration; pub(crate) mod argument_buffer; pub(crate) mod astc_decode; pub(crate) mod block_decode; -pub(crate) mod capture_assembly; pub(crate) mod chroma_decode; pub(crate) mod color_resolve; pub(crate) mod depth_stencil_copy; @@ -173,10 +166,8 @@ pub(crate) mod status; pub(crate) mod table; pub(crate) mod tessellation_scan; pub(crate) mod tile_map; -pub(crate) mod tile_reach; pub(crate) mod tiled_texels; pub(crate) mod two_plane_texels; -pub(crate) mod unused_bits; pub(crate) mod visibility_combine; pub(crate) mod visibility_resolve; pub(crate) mod ycbcr_convert; @@ -195,9 +186,6 @@ pub use argument_buffer::{ }; pub use astc_decode::{astc_decode_module, AstcDecode, AstcTexels}; pub use block_decode::BlockDecodeModule; -pub use capture_assembly::{ - capture_assembly_module, capture_settle_module, CaptureAssemblyModule, CaptureSettleModule, -}; pub use chroma_decode::{chroma_decode_module, ChromaDecode}; pub use color_resolve::{ color_resolve_modules, ColorResolveFormat, ColorResolveModules, ResolveChannel, ResolveRule, @@ -327,10 +315,8 @@ pub use tessellation_scan::{ tessellation_scan_module, TessellationScanKernel, TessellationScanModule, }; pub use tile_map::{SparseTileMap, TileMapError, TileMapping}; -pub use tile_reach::{tile_reach_module, TileReachModule}; pub use tiled_texels::{tiled_texels_module, TiledLevelMove, TiledTexelsModule}; pub use two_plane_texels::{two_plane_texels_module, PlaneLayout, TwoPlaneTexelsModule}; -pub use unused_bits::{unused_bits_module, TexelWords, UnusedBitsModule}; pub use visibility_combine::{ visibility_combine_module, ContinuedResult, VisibilityCombine, VisibilityCombineModule, }; diff --git a/crates/metal2vulkan/src/bind/plan.rs b/crates/metal2vulkan/src/bind/plan.rs index 72e48ec7e..c465e7891 100644 --- a/crates/metal2vulkan/src/bind/plan.rs +++ b/crates/metal2vulkan/src/bind/plan.rs @@ -216,13 +216,9 @@ pub struct GraphicsTemplate { /// encoder's stencil state and references as `PushField::ShaderStencilState`. #[cfg_attr(feature = "serde", serde(default))] pub(crate) shader_tests: Option, - /// A pipeline compiled in a capture form (`VariantKey::captured_positions`): its draws write - /// `PushField::CaptureLayout`, and an indexed form's run without indices. - #[cfg_attr(feature = "serde", serde(default))] - pub(crate) capture: Option, /// A pipeline compiled in the primitive ID's de-indexed form of this index type /// (`VariantKey::primitive_id_indices`): its indexed draws write `PushField::CaptureLayout` - /// and run without indices, as the indexed capture form's do. + /// and run without indices. #[cfg_attr(feature = "serde", serde(default))] pub(crate) deindexed: Option, /// A pipeline compiled in the private list form (`VariantKey::private_list`): its draws are diff --git a/crates/metal2vulkan/src/bind/replay/tests.rs b/crates/metal2vulkan/src/bind/replay/tests.rs index 5c710b82a..faab205b5 100644 --- a/crates/metal2vulkan/src/bind/replay/tests.rs +++ b/crates/metal2vulkan/src/bind/replay/tests.rs @@ -307,9 +307,7 @@ fn run_preprocess( PushHole::ExecutionStatusAddress { offset, .. } => (offset, STATUS), PushHole::CommandRecordsAddress { offset, .. } => (offset, RECORDS), PushHole::ReplayRegionAddress { .. } => panic!("the preprocess reads no region"), - PushHole::CaptureAddress { .. } | PushHole::CaptureIndexAddress { .. } => { - panic!("the preprocess captures no vertex") - } + PushHole::CaptureIndexAddress { .. } => panic!("the preprocess reads no index"), PushHole::SnapshotPhase { .. } => panic!("the preprocess draws no snapshot"), PushHole::MergedDrawAddress { .. } => panic!("the preprocess draws no merged draw"), }; diff --git a/crates/metal2vulkan/src/bind/state.rs b/crates/metal2vulkan/src/bind/state.rs index 8196fcf35..1645e9dd9 100644 --- a/crates/metal2vulkan/src/bind/state.rs +++ b/crates/metal2vulkan/src/bind/state.rs @@ -91,14 +91,12 @@ pub struct BindState { #[cfg_attr(feature = "serde", serde(default))] pub depth_stencil: metal::state::DepthStencilDescriptor, /// The draw's primitive type (`drawPrimitives:`'s or `drawIndexedPrimitives:`'s - /// `primitiveType`), which two draws read: one of an indexed capture variant - /// (`CaptureForm::Indexed`), as Metal restarts a line or triangle strip at the index type's - /// all-ones index and shades no vertex there, and draws every index of a list or of points; - /// and one of a pipeline whose vertex function writes the primitive ID - /// (`LoweringInputs::primitive_id_varying`), whose `PushField::VerticesPerPrimitive` holds - /// the type's vertices per primitive. `None` where the consumer does not say; such a draw is - /// `BindError::MissingPrimitiveType`. Only a draw's bytes depend on it, so it is not part of - /// the shape. + /// `primitiveType`), which a draw of a pipeline whose vertex function writes the primitive ID + /// reads (`LoweringInputs::primitive_id_varying`): its `PushField::VerticesPerPrimitive` holds + /// the type's vertices per primitive, and an indexed strip, which Metal restarts at the index + /// type's all-ones index, does not run de-indexed. `None` where the consumer does not say; + /// such a draw is `BindError::MissingPrimitiveType`. Only a draw's bytes depend on it, so it + /// is not part of the shape. #[cfg_attr(feature = "serde", serde(default))] pub primitive_type: Option, /// The index type of a direct indexed draw of a pipeline whose vertex function writes the diff --git a/crates/metal2vulkan/src/bind/status.rs b/crates/metal2vulkan/src/bind/status.rs index 5dc442ab4..5736f1c51 100644 --- a/crates/metal2vulkan/src/bind/status.rs +++ b/crates/metal2vulkan/src/bind/status.rs @@ -5,7 +5,7 @@ //! [`ExecutionStatus::decode`] after the last one (a `SHADER_WRITE -> HOST_READ` barrier first); //! the resident-set miss counter, the indirect clamp, the device replay's preprocess, the index //! bounds pass, an absent argument's read, the mesh and tessellation scans, a sample through a -//! cubic argument sampler, the capture settle, and a sequentially consistent fence write the words +//! cubic argument sampler, and a sequentially consistent fence write the words //! named here. /// The `ExecutionStatus` buffer. @@ -26,9 +26,7 @@ impl ExecutionStatus { /// What the buffer's bytes report after the command buffer ran. The consumer maps `overflow`, a /// replay fault, an index pool overflow, an absent argument read, a mesh records fault, a mesh /// grid Metal's GPU discards or the device cannot launch, and a cubic argument sampler's sample - /// to a command-buffer execution error, treats resident-set - /// misses by its own policy, and announces a captured reach the rule does not answer as its - /// pass's fallback to every tile. + /// to a command-buffer execution error, and treats resident-set misses by its own policy. pub fn decode(bytes: &[u8; ExecutionStatus::BYTES]) -> StatusReport { let word = |w: StatusWord| { let at = w.byte_offset() as usize; @@ -46,7 +44,6 @@ impl ExecutionStatus { index_pool_overflow: bits.contains(StatusBits::INDEX_POOL_OVERFLOW), absent_argument_read: bits.contains(StatusBits::ABSENT_ARGUMENT_READ), cubic_argument_sampler: bits.contains(StatusBits::CUBIC_ARGUMENT_SAMPLER), - captured_reach_unmeasured: bits.contains(StatusBits::CAPTURED_REACH_UNMEASURED), mesh_grid_discarded: bits.contains(StatusBits::MESH_GRID_DISCARDED), mesh_grid_past_limits: bits.contains(StatusBits::MESH_GRID_PAST_LIMITS), mesh_records_overflow: (bits.contains(StatusBits::MESH_RECORDS_OVERFLOW)).then(|| { @@ -115,11 +112,6 @@ pub struct StatusReport { /// `Cubic`, whose bicubic filter it does not emulate there /// (`RuntimeFact::CubicArgumentSampler`): no result of the command buffer is then Metal's. pub cubic_argument_sampler: bool, - /// A pass's captured primitives held one whose tiles the tile reach rule does not answer (one - /// across the near or far plane under depth clipping, or one past what was measured), so the - /// capture settle took every tile of the pass's mask (`bind::CaptureSettleModule`): the - /// pass's reach is the announced fallback, not its draws' tiles. - pub captured_reach_unmeasured: bool, /// An indirect mesh draw's arguments pass (or an emulated one's object arguments pass) met an /// object grid that Metal's GPU discards (`StatusBits::MESH_GRID_DISCARDED`): that draw drew /// nothing, and the command buffer fails as Metal's does (`MTLCommandBufferErrorInternal`). @@ -244,10 +236,6 @@ impl StatusBits { /// (`RuntimeFact::CubicArgumentSampler`): its result is the device's through a nearest /// placeholder, not Metal's. pub const CUBIC_ARGUMENT_SAMPLER: StatusBits = StatusBits(1 << 6); - /// A capture settle found its pass's tile reach header counting a primitive near-far or - /// unmeasured, and set every tile of the pass's mask (`bind::CaptureSettleModule`): the pass - /// takes the announced fallback. - pub const CAPTURED_REACH_UNMEASURED: StatusBits = StatusBits(1 << 7); /// A tessellation scan found no room in the command buffer's records pool for an emulated /// tessellation draw's records, or the draw's records passed a `u32`, and the draw drew /// nothing (`bind::TessellationScanModule`); the fault words name the command buffer's first @@ -363,7 +351,6 @@ mod tests { StatusBits::ABSENT_ARGUMENT_READ, StatusBits::MESH_RECORDS_OVERFLOW, StatusBits::CUBIC_ARGUMENT_SAMPLER, - StatusBits::CAPTURED_REACH_UNMEASURED, ]; let mut all = 0u32; for b in bits { @@ -420,11 +407,6 @@ mod tests { cubic[0..4].copy_from_slice(&StatusBits::CUBIC_ARGUMENT_SAMPLER.0.to_le_bytes()); let c = ExecutionStatus::decode(&cubic); assert!(c.cubic_argument_sampler && !c.absent_argument_read && !c.overflow); - assert!(!c.captured_reach_unmeasured && !r.captured_reach_unmeasured); - let mut reach = [0u8; 32]; - reach[0..4].copy_from_slice(&StatusBits::CAPTURED_REACH_UNMEASURED.0.to_le_bytes()); - let u = ExecutionStatus::decode(&reach); - assert!(u.captured_reach_unmeasured && !u.cubic_argument_sampler && !u.overflow); assert!(r.absent_argument_read && !r.index_pool_overflow && !r.overflow); assert_eq!(r.mesh_records_overflow, None); bytes = [0u8; 32]; diff --git a/crates/metal2vulkan/src/bind/tile_reach.rs b/crates/metal2vulkan/src/bind/tile_reach.rs deleted file mode 100644 index aa16af73e..000000000 --- a/crates/metal2vulkan/src/bind/tile_reach.rs +++ /dev/null @@ -1,290 +0,0 @@ -//! Which tiles of a render pass Metal's tile store writes back: the tiles its draws' primitives -//! reach. -//! -//! An Apple GPU bins a pass's primitives into tiles and loads and stores only the tiles a -//! primitive reaches, which decides what a `DontCare` load clears (`clear_reach`), which tiles a -//! rotated texture's frame turns, and which tiles an extended-range or padded 10-bit attachment's -//! store makes canonical ([`unused_bits_module`](super::unused_bits_module)). Measured on an Apple -//! M4 under macOS 27.0.1 (111 cases, each in a process of its own; alike in every case on an Apple -//! M3 Max under macOS 26.7, the kit `share-reach`; 168 cases on the small-primitive cull; and our -//! probes on a point's square): -//! -//! - **Tiles** are 32 by 32 pixels from the render area's origin at 1 and 2 samples, 32 by 16 at -//! 4, whatever the attachments' formats and count (up to eight `RGBA32Float`); each is -//! half-open, `[32i, 32i + 32)` along x. -//! - **Vertices** snap to 1/256 of a pixel, to the nearest: a right edge at `32 - 1/512` reaches -//! the next tile, one at `32 - 1/256` does not. Coordinates of 1e5 pixels snap exactly. -//! - **A triangle** reaches every tile its closed area meets, clipped by the viewport, the -//! scissor and the render area, each a half-open rectangle (a viewport over `[32, 64)` reaches -//! tile 1 alone): its area, not its bounding box, and an edge on `x = 32` reaches the tile -//! right of it. It reaches none where it is culled: by the cull mode and winding, at zero area -//! (through pixel centres too), wholly past the near or far plane (but under depth clamp), or by -//! the small-primitive cull: where its closed box, in window coordinates snapped to 1/256 (the -//! viewport's, before the scissor and the render area clip it), holds at most 12 pixel centres -//! (any shape, 1 by 12 to 12 by 1) and its closed area none of them (a sample on an edge -//! counts, though the fill rule that shades is top-left). A box of 13 or more is kept, holding -//! a sample or not. At 2 samples a box of up to 12 of their positions is tested too, at 4 one -//! of up to 24 (Metal's default positions, Vulkan's standard ones), in every slope measured. A -//! fragment that discards or fails a test still reaches. A triangle across the near plane -//! reaches by the clipped polygon. -//! - **A point** reaches what a closed square about its snapped centre meets (a size of 0 or 0.25 -//! too, a centre past the viewport too; no sample cull): from half its size back, rounded half -//! up to 1/256 of a pixel (its left and top edges reach a tile only from more than half a unit -//! past it), over its size rounded to the nearest 1/16 of a pixel (its right and bottom edges -//! follow from the left and top ones, up to four units past the exact square); a size past 511 -//! draws as 511. -//! - **A line** reaches what a parallelogram meets: half a pixel each way across its major axis, -//! extended half a pixel past each end along it, a 45-degree line taken as y-major; no sample -//! cull. -//! - **A draw** reaches the same directly or indirectly; one of no instances, one by a pipeline -//! that does not rasterize, and a pass without a draw call reach nothing. A layered pass's -//! draw reaches the tiles of the slice it renders alone. -//! - **A clear.** In a pass with a draw call (of no instances too), an attachment loaded `Clear` -//! and stored, color, depth or stencil, makes every tile of the render area reached; one whose -//! store is `DontCare` does not. -//! -//! The rule is checked here as a plain function the tests hold, against every measured case. -//! [`tile_reach_module`] bins a pass's captured primitives on the device by it; its consumers in -//! the runtime follow (the later steps). -//! -//! **The module** (one per device). One `GLCompute` entry `main` with local size -//! ([`TileReachModule::LOCAL_SIZE`], 1, 1), no push constants, and three storage buffers of 4-byte -//! words in set 0: -//! -//! - [`PRIMITIVES_BINDING`](TileReachModule::PRIMITIVES_BINDING): the pass's primitives, each -//! [`PRIMITIVE_WORDS`](TileReachModule::PRIMITIVE_WORDS) words -//! ([`primitive`](TileReachModule::primitive)): its kind, its state, its layer, a point's size, -//! and three clip-space vertices (a point's first, a line's first two); -//! - [`PASS_BINDING`](TileReachModule::PASS_BINDING): the header -//! ([`header`](TileReachModule::header)), [`HEADER_WORDS`](TileReachModule::HEADER_WORDS) -//! words: the render area, the samples, the layers, the primitives' count, and the two counts the -//! kernel adds to, then the states, each [`STATE_WORDS`](TileReachModule::STATE_WORDS) words -//! ([`state`](TileReachModule::state)): the viewport, the scissor, the cull mode, the winding and -//! the depth clip mode a primitive was drawn under; -//! - [`TILES_BINDING`](TileReachModule::TILES_BINDING): the tile mask, one bit a tile of the -//! pass (32 by 32 pixels, 32 by 16 at 4 samples; bit `t % 32` of word `t / 32`), tile `t = -//! (layer * tile_rows + y) * tiles_per_row + x`, which the kernel ORs bits into. -//! -//! Invocation `i` below the count bins primitive `i` into its slice's tiles (a layer past the -//! pass's into the first), and adds one to the header's word -//! [`NEAR_FAR_WORD`](TileReachModule::NEAR_FAR_WORD) where the primitive crossed the near or far -//! plane under depth clipping (its reach is its clipped polygon's, whose new vertices Apple's -//! clipper may place otherwise) and to [`UNMEASURED_WORD`](TileReachModule::UNMEASURED_WORD) where -//! its reach is past what was measured (a vertex not finite, with a subnormal component, at or -//! behind the eye or snapped past 2^21 pixels; a viewport edge past that; a line of no length; a -//! point past the depth range, or of a size negative, not a number or subnormal; a state past the -//! header's or a kind not one of [`POINT`](TileReachModule::POINT), -//! [`LINE`](TileReachModule::LINE) and [`TRIANGLE`](TileReachModule::TRIANGLE)). The kernel's -//! arithmetic is exact on every device (`kernel.rs`): the reach of each primitive is the rule's. -//! -//! **Synchronization** (consumer): the writes of the primitives, the pass and the cleared mask -//! (`TRANSFER_WRITE` or `SHADER_WRITE`) → `SHADER_STORAGE_READ` and `SHADER_STORAGE_WRITE` in -//! `COMPUTE_SHADER` before the dispatch; its writes → the mask's and the counts' readers. - -use std::sync::Arc; - -use crate::budget::{Budget, Meter}; -use crate::device::requirements::{Requirements, VkFeature}; -use crate::device::Device; -use crate::error::{Capability, Error, Feature, InternalError, InternalKind, Unsupported}; -use crate::pipeline::sym::Symbol; - -mod kernel; - -/// The word positions within the kernel's records ([`TileReachModule`]); the capture assembly -/// writes primitives and the capture settle reads the header by them (`capture_assembly.rs`). -pub(super) mod layout { - /// The header's: the render area's width and height, the samples, the layers, the count. - pub(in crate::bind) const AREA_W: u32 = 0; - pub(in crate::bind) const AREA_H: u32 = 1; - pub(in crate::bind) const SAMPLES: u32 = 2; - pub(in crate::bind) const LAYERS: u32 = 3; - pub(super) const COUNT: u32 = 4; - /// A state's, from its first word: the viewport (four `f32`s), the scissor (four words), the - /// cull mode, the winding and the depth clip mode. - pub(super) const VIEWPORT: u32 = 0; - pub(super) const SCISSOR: u32 = 4; - pub(super) const CULL: u32 = 8; - pub(super) const WINDING: u32 = 9; - pub(super) const DEPTH_CLIP: u32 = 10; - /// A primitive's: its kind, state, layer, size (an `f32`) and vertices (twelve `f32`s). - pub(in crate::bind) const KIND: u32 = 0; - pub(in crate::bind) const STATE: u32 = 1; - pub(in crate::bind) const LAYER: u32 = 2; - pub(in crate::bind) const SIZE: u32 = 3; - pub(in crate::bind) const VERTICES: u32 = 4; -} - -/// The crate-owned tile reach module of one device (the module docs), validated like any output. -#[non_exhaustive] -#[derive(Clone, Debug, PartialEq, Eq)] -pub struct TileReachModule { - /// SPIR-V 1.5 words, entry point `main`, its bindings numbered as below in set 0. - pub spirv: Arc<[u32]>, - /// What the module needs from the device: within every Vulkan 1.2 device with - /// `shaderInt64`. - pub requirements: Requirements, -} - -impl TileReachModule { - /// Descriptor set of the bindings. - pub const SET: u32 = 0; - /// The primitives, a storage buffer the kernel reads. - pub const PRIMITIVES_BINDING: u32 = 0; - /// The header and the states, a storage buffer the kernel reads and counts into. - pub const PASS_BINDING: u32 = 1; - /// The tile mask, a storage buffer the kernel ORs bits into. - pub const TILES_BINDING: u32 = 2; - /// Invocations of one workgroup, along x: one primitive each. - pub const LOCAL_SIZE: u32 = 64; - /// A primitive's words ([`primitive`](Self::primitive)). - pub const PRIMITIVE_WORDS: u32 = 16; - /// The header's words ([`header`](Self::header)), before the states. - pub const HEADER_WORDS: u32 = 8; - /// A state's words ([`state`](Self::state)). - pub const STATE_WORDS: u32 = 12; - /// The header's word the kernel adds one to for each primitive that crossed the near or far - /// plane under depth clipping. - pub const NEAR_FAR_WORD: u32 = 5; - /// The header's word the kernel adds one to for each primitive whose reach is past what was - /// measured (the module docs). - pub const UNMEASURED_WORD: u32 = 6; - /// The kind of a point (`MTLPrimitiveTypePoint`'s primitives). - pub const POINT: u32 = 0; - /// The kind of a line (`MTLPrimitiveTypeLine` and `LineStrip`'s). - pub const LINE: u32 = 1; - /// The kind of a triangle (`MTLPrimitiveTypeTriangle` and `TriangleStrip`'s). - pub const TRIANGLE: u32 = 2; - - /// The header's bytes: the render area's width and height in pixels (at most 16384 each, a - /// larger side binned as 16384), its samples (1, 2 or 4; another count bins as 1), its layers - /// (1 for a pass that is not layered), and the count of primitives; the two counts zero. - pub fn header(area: [u32; 2], samples: u32, layers: u32, count: u32) -> [u8; 32] { - let mut words = [0; Self::HEADER_WORDS as usize]; - words[layout::AREA_W as usize] = area[0]; - words[layout::AREA_H as usize] = area[1]; - words[layout::SAMPLES as usize] = samples; - words[layout::LAYERS as usize] = layers; - words[layout::COUNT as usize] = count; - bytes_of(words) - } - - /// A state's bytes: the viewport (`MTLViewport`'s `originX`, `originY`, `width` and `height` - /// as the rasterizer takes them, in `f32`), the scissor rectangle (`MTLScissorRect`'s `x`, - /// `y`, `width` and `height`), and the raw values of the `MTLCullMode`, the `MTLWinding` and - /// the `MTLDepthClipMode` a primitive was drawn under. - pub fn state( - viewport: [f32; 4], - scissor: [u32; 4], - cull: u32, - winding: u32, - depth_clip: u32, - ) -> [u8; 48] { - let mut words = [0; Self::STATE_WORDS as usize]; - for i in 0..4 { - words[layout::VIEWPORT as usize + i] = viewport[i].to_bits(); - words[layout::SCISSOR as usize + i] = scissor[i]; - } - words[layout::CULL as usize] = cull; - words[layout::WINDING as usize] = winding; - words[layout::DEPTH_CLIP as usize] = depth_clip; - bytes_of(words) - } - - /// A primitive's bytes: its `kind` ([`POINT`](Self::POINT), [`LINE`](Self::LINE) or - /// [`TRIANGLE`](Self::TRIANGLE)), the index of the `state` it was drawn under among the - /// pass's, the `layer` it renders (`[[render_target_array_index]]`; 0 where none), a point's - /// `size` in pixels (`[[point_size]]`), and its clip-space `vertices` (`[[position]]`): a - /// point's first, a line's first two, a triangle's three, in the order the draw assembled - /// them. - pub fn primitive( - kind: u32, - state: u32, - layer: u32, - size: f32, - vertices: [[f32; 4]; 3], - ) -> [u8; 64] { - let mut words = [0; Self::PRIMITIVE_WORDS as usize]; - words[layout::KIND as usize] = kind; - words[layout::STATE as usize] = state; - words[layout::LAYER as usize] = layer; - words[layout::SIZE as usize] = size.to_bits(); - for (v, vertex) in vertices.iter().enumerate() { - for (c, value) in vertex.iter().enumerate() { - words[layout::VERTICES as usize + 4 * v + c] = value.to_bits(); - } - } - bytes_of(words) - } - - /// The tile mask's words of a pass of render area `area`, `samples` and `layers` (the - /// header's): one bit a tile of each slice. - pub fn mask_words(area: [u32; 2], samples: u32, layers: u32) -> u32 { - let tile_rows = match samples { - 4 => 16, - _ => 32, - }; - let [w, h] = area.map(|a| a.min(AREA_LIMIT)); - let tiles = w.div_ceil(32) * h.div_ceil(tile_rows) * layers; - tiles.div_ceil(32) - } -} - -/// The largest render area side the kernel bins, in pixels (Metal's): a larger side is binned as -/// this one, which keeps every product of the kernel's integer tests within an `i64`. -pub(super) const AREA_LIMIT: u32 = 16384; - -/// The little-endian bytes of `N` words. -fn bytes_of(words: [u32; N]) -> [u8; B] { - let mut bytes = [0; B]; - for (at, w) in words.iter().enumerate() { - bytes[4 * at..4 * at + 4].copy_from_slice(&w.to_le_bytes()); - } - bytes -} - -/// The fixed binding numbers of the module's symbols. -fn binding_of(sym: &Symbol) -> Option { - match sym { - Symbol::DescriptorSet(_) => Some(TileReachModule::SET), - Symbol::Binding(s) if *s == kernel::PRIMITIVES => Some(TileReachModule::PRIMITIVES_BINDING), - Symbol::Binding(s) if *s == kernel::PASS => Some(TileReachModule::PASS_BINDING), - Symbol::Binding(s) if *s == kernel::TILES => Some(TileReachModule::TILES_BINDING), - _ => None, - } -} - -/// The tile reach module of `device`: built with the typed builder, checked by the owned verifier -/// against the device's profile (requirements included), serialized, and numbered with the fixed -/// bindings of [`TileReachModule`]. A device without `shaderInt64`, which the kernel's exact -/// arithmetic needs, is [`Feature::TileReach`] needing it. -pub fn tile_reach_module(device: &Device) -> Result { - let profile = device.profile(); - if !profile - .fields() - .enabled - .features - .contains(&VkFeature::ShaderInt64) - { - let int64 = Capability::Feature(VkFeature::ShaderInt64); - return Err(Unsupported::needs_any_of(Feature::TileReach, vec![vec![int64]]).into()); - } - let m = kernel::typed_module()?; - let mut meter = Meter::new(&Budget::default()); - crate::spirv::verify::verify(&m, profile, &mut meter)?; - let r = crate::spirv::serialize::serialize(m)?; - profile.check(&r.requirements).map_err(|c| { - Error::Internal(InternalError::new( - InternalKind::RequirementsExceedProfile, - format!("the tile reach kernel needs {c:?}"), - )) - })?; - let words = crate::spirv::serialize::relocate(&r, &binding_of)?; - Ok(TileReachModule { - spirv: words.into(), - requirements: r.requirements, - }) -} - -#[cfg(test)] -mod tests; diff --git a/crates/metal2vulkan/src/bind/tile_reach/kernel.rs b/crates/metal2vulkan/src/bind/tile_reach/kernel.rs deleted file mode 100644 index 9f487c7fe..000000000 --- a/crates/metal2vulkan/src/bind/tile_reach/kernel.rs +++ /dev/null @@ -1,2247 +0,0 @@ -//! The tile reach kernel: [`typed_module`], which [`tile_reach_module`](super::tile_reach_module) -//! serializes and the CPU interpreter runs. It bins a pass's primitives into the tile mask by the -//! rule of the module docs, step for step as the reference function the tests hold computes it -//! (`tests/reference.rs`, whose names each step below gives). -//! -//! **Exactness.** The kernel has no float instruction: it holds every `f32` as its bits (`u32`) -//! and computes the window transform's and the clipper's arithmetic in integers, as IEEE defines -//! it ([`quotient`], [`product`], [`sum`]: each rounded once to nearest even, subnormal operands -//! and results exact, Rust's `/`, `*`, `+` and `-`), and the comparisons from the bits -//! ([`negative`], [`nonnegative`], [`nonpositive`], [`exceeds`]). So a device that flushes -//! subnormals to zero, contracts a multiply and an add, or compiles with fast math computes what -//! the reference does (lavapipe flushes: a vertex at `z = -1e-40` crosses the near plane, which -//! it did not see). The snap to 1/256 of a pixel reads the window position's bits ([`snap`]), and -//! every test after it is in 64-bit integers, which the coordinate limit (2^29 units, the render -//! area at most 16384 pixels a side) keeps from overflowing. -//! -//! **No integer division.** Compilers lower a 64-bit division into a long chain of 64-bit steps, -//! and a kernel holding many of them grows past the registers of a device, spilling (RADV's -//! compiler then got some of its lines' reaches wrong in wave64). So the kernel divides nothing -//! but by constants: the significands' quotient is found a bit at a time in 32-bit words -//! ([`significand_quotient`]), the tiles a box meets by shifts (a tile's sides are powers of two), -//! a line's box over its length by products ([`small_quotients`]), and the small-primitive cull -//! tests each sample position its box holds ([`holds_sample`]). - -use crate::pipeline::sym::{ResourceKind, ResourceSlot, Stage}; -use crate::spirv::builder::constructs::{ArmEnd, ArmFn, LoopFn, LoopSpec}; -use crate::spirv::builder::{FunctionBuilder, ModuleBuilder}; -use crate::spirv::error::{BResult, BuildError, TypeRule}; -use crate::spirv::ids::{FuncId, GlobalId, TypeId, Value}; -use crate::spirv::ir::{ - natural_layout, AtomicOp, BinOp, ConstBits, Constant, ConvOp, ExecMode, ExecModel, GlslOp, - IoDir, LayoutRule, MemAccess, Scope, Semantics, StorageClass, Type, TypedModule, UnOp, -}; - -use super::{layout, TileReachModule as M, AREA_LIMIT}; - -/// The binding symbols of the primitives, the pass and the tile mask in the typed module. -pub(super) const PRIMITIVES: ResourceSlot = ResourceSlot { - stage: Stage::Kernel, - kind: ResourceKind::Buffer, - index: 0, -}; -pub(super) const PASS: ResourceSlot = ResourceSlot { - stage: Stage::Kernel, - kind: ResourceKind::Buffer, - index: 1, -}; -pub(super) const TILES: ResourceSlot = ResourceSlot { - stage: Stage::Kernel, - kind: ResourceKind::Buffer, - index: 2, -}; - -/// Units of a pixel a vertex snaps to. -const UNIT: i64 = 256; -/// The largest snapped coordinate: past it a coordinate is clamped and flagged unmeasured. -const LIMIT: u32 = 1 << 29; -/// The most vertices the clipper holds: 9, the most a triangle's polygon reaches. Sutherland-Hodgman -/// keeps each vertex on the plane's inner side and adds one for each edge whose ends lie on -/// opposite sides. Around a closed polygon of `n` vertices, `k` of them inside, the side changes -/// at most `2 min(k, n - k)` times, so the result holds at most `k + 2 min(k, n - k)` vertices: -/// at most 4 from 3, 6 from 4 and 9 from 6. The planes are at most three (near, far, eye), so a -/// triangle's polygon holds at most 9 and a segment's 2. The count looks only at which side each -/// vertex lies on, so it holds whatever the rounding of the vertices the clipper makes, even where -/// that rounding leaves a polygon not convex (exact arithmetic gives at most 6). The test -/// `the_clipper_holds_its_most_vertices` clips a hexagon to 9. -pub(super) const POLYGON: u32 = 9; -/// The largest point size Metal draws, in pixels: a larger size draws as this one. -const POINT_SIZE_LIMIT: f32 = 511.0; - -/// The words of the per-primitive context `bin` reads (a `Private` array of `i64`): the region, -/// the tile's width and height in units, the tiles of a row and of a column, the first row of -/// tiles of the primitive's slice, and the tile's width and height in units as powers of two. -mod ctx { - pub(super) const RX0: u32 = 0; - pub(super) const RX1: u32 = 1; - pub(super) const RY0: u32 = 2; - pub(super) const RY1: u32 = 3; - pub(super) const TW: u32 = 4; - pub(super) const TH: u32 = 5; - pub(super) const TILES_X: u32 = 6; - pub(super) const TILES_Y: u32 = 7; - pub(super) const BASE: u32 = 8; - pub(super) const SHIFT_X: u32 = 9; - pub(super) const SHIFT_Y: u32 = 10; - pub(super) const WORDS: u32 = 11; -} - -/// The kernel's types. -#[derive(Clone, Copy)] -struct T { - bool_: TypeId, - u32_: TypeId, - u64_: TypeId, - i64_: TypeId, - /// A clip-space vertex: its four `f32`s' bits (`uvec4`). - vec4: TypeId, -} - -/// What the main function's parts take: the types, the routines, the buffers, the flags and the -/// clipper's arrays (pointers), and the primitive's state. -#[derive(Clone, Copy)] -struct K { - t: T, - r: Routines, - near_far: Value, - unmeasured: Value, - poly: Value, - scratch: Value, - n: Value, - pts: Value, - /// The viewport's origin and size (`f32` bits). - vp: [Value; 4], - /// Whether depth clamps rather than clips (`bool`). - clamp: Value, - /// The raw cull mode and winding, and the pass's samples (`u32`). - cull: Value, - winding: Value, - samples: Value, -} - -fn k32(f: &mut FunctionBuilder<'_>, v: u32) -> BResult { - let c = f.u32_const(v)?; - f.module().const_value(c) -} - -fn k64(f: &mut FunctionBuilder<'_>, t: T, v: i64) -> BResult { - let c = f.module().constant(Constant::Scalar { - ty: t.i64_, - bits: ConstBits(v as u64), - })?; - f.module().const_value(c) -} - -fn ku64(f: &mut FunctionBuilder<'_>, t: T, v: u64) -> BResult { - let c = f.module().constant(Constant::Scalar { - ty: t.u64_, - bits: ConstBits(v), - })?; - f.module().const_value(c) -} - -/// The `bool` `false`. -fn falsy(f: &mut FunctionBuilder<'_>, t: T) -> BResult { - let c = f.module().constant(Constant::Scalar { - ty: t.bool_, - bits: ConstBits(0), - })?; - f.module().const_value(c) -} - -fn op(f: &mut FunctionBuilder<'_>, o: BinOp, a: Value, b: Value) -> BResult { - f.binary(o, a, b) -} - -/// `a o v` for a `u32` constant `v`. -fn opk(f: &mut FunctionBuilder<'_>, o: BinOp, a: Value, v: u32) -> BResult { - let c = k32(f, v)?; - f.binary(o, a, c) -} - -/// `a o v` for an `i64` constant `v`. -fn op64(f: &mut FunctionBuilder<'_>, t: T, o: BinOp, a: Value, v: i64) -> BResult { - let c = k64(f, t, v)?; - f.binary(o, a, c) -} - -fn sel(f: &mut FunctionBuilder<'_>, c: Value, a: Value, b: Value) -> BResult { - f.select(c, a, b) -} - -fn and(f: &mut FunctionBuilder<'_>, a: Value, b: Value) -> BResult { - f.binary(BinOp::LogicalAnd, a, b) -} - -fn or(f: &mut FunctionBuilder<'_>, a: Value, b: Value) -> BResult { - f.binary(BinOp::LogicalOr, a, b) -} - -fn not(f: &mut FunctionBuilder<'_>, a: Value) -> BResult { - f.unary(UnOp::LogicalNot, a) -} - -/// The smaller of two `i64`s. -fn smin(f: &mut FunctionBuilder<'_>, a: Value, b: Value) -> BResult { - let less = f.binary(BinOp::SLessThan, a, b)?; - f.select(less, a, b) -} - -/// The larger of two `i64`s. -fn smax(f: &mut FunctionBuilder<'_>, a: Value, b: Value) -> BResult { - let more = f.binary(BinOp::SGreaterThan, a, b)?; - f.select(more, a, b) -} - -/// The magnitude of an `i64`. -fn sabs(f: &mut FunctionBuilder<'_>, t: T, a: Value) -> BResult { - let zero = k64(f, t, 0)?; - let neg = f.binary(BinOp::SLessThan, a, zero)?; - let minus = f.unary(UnOp::SNegate, a)?; - f.select(neg, minus, a) -} - -/// A `u32` as an `i64` of its value. -fn widen(f: &mut FunctionBuilder<'_>, t: T, a: Value) -> BResult { - let u = f.convert(ConvOp::UConvert, a, t.u64_)?; - f.convert(ConvOp::Bitcast, u, t.i64_) -} - -/// The low 32 bits of an `i64` or a `u64`, as a `u32`. -fn low(f: &mut FunctionBuilder<'_>, t: T, a: Value) -> BResult { - let u = match f.value_ty(a)? == t.i64_ { - true => f.convert(ConvOp::Bitcast, a, t.u64_)?, - false => a, - }; - f.convert(ConvOp::UConvert, u, t.u32_) -} - -/// `n / 256` rounded down (`i64`). -fn floor_unit(f: &mut FunctionBuilder<'_>, n: Value) -> BResult { - opk(f, BinOp::ShiftRightArithmetic, n, 8) -} - -/// `n / 256` rounded up (`i64`). -fn ceil_unit(f: &mut FunctionBuilder<'_>, n: Value) -> BResult { - let minus = f.unary(UnOp::SNegate, n)?; - let q = floor_unit(f, minus)?; - f.unary(UnOp::SNegate, q) -} - -fn load(f: &mut FunctionBuilder<'_>, p: Value) -> BResult { - f.load(p, MemAccess::default()) -} - -fn store(f: &mut FunctionBuilder<'_>, p: Value, v: Value) -> BResult<()> { - f.store(p, v, MemAccess::default()) -} - -/// Element `i` (a `u32`) of the array a pointer points at. -fn at(f: &mut FunctionBuilder<'_>, array: Value, i: Value) -> BResult { - f.access_chain(array, &[i]) -} - -/// Element `i` (a constant) of the array a pointer points at. -fn atk(f: &mut FunctionBuilder<'_>, array: Value, i: u32) -> BResult { - let i = k32(f, i)?; - f.access_chain(array, &[i]) -} - -/// Word `i` (a `u32`) of a buffer of words. -fn word(f: &mut FunctionBuilder<'_>, buffer: Value, i: Value) -> BResult { - let zero = k32(f, 0)?; - let p = f.access_chain(buffer, &[zero, i])?; - load(f, p) -} - -/// Set the `u32` flag a pointer points at where `c` holds. -fn flag_if(f: &mut FunctionBuilder<'_>, flag: Value, c: Value) -> BResult<()> { - let old = load(f, flag)?; - let one = k32(f, 1)?; - let new = sel(f, c, one, old)?; - store(f, flag, new) -} - -/// Run `body` where `c` holds. -fn when<'a>( - f: &mut FunctionBuilder<'_>, - c: Value, - body: impl FnOnce(&mut FunctionBuilder<'_>) -> BResult<()> + 'a, -) -> BResult<()> { - let arm: ArmFn<'_, ()> = Box::new(move |f, _| { - body(f)?; - Ok(ArmEnd::FallThrough(Vec::new())) - }); - f.if_(&mut (), c, arm, None)?; - Ok(()) -} - -/// Run `then` where `c` holds and `other` where it does not. -fn either<'a>( - f: &mut FunctionBuilder<'_>, - c: Value, - then: impl FnOnce(&mut FunctionBuilder<'_>) -> BResult<()> + 'a, - other: impl FnOnce(&mut FunctionBuilder<'_>) -> BResult<()> + 'a, -) -> BResult<()> { - let yes: ArmFn<'_, ()> = Box::new(move |f, _| { - then(f)?; - Ok(ArmEnd::FallThrough(Vec::new())) - }); - let no: ArmFn<'_, ()> = Box::new(move |f, _| { - other(f)?; - Ok(ArmEnd::FallThrough(Vec::new())) - }); - f.if_(&mut (), c, yes, Some(no))?; - Ok(()) -} - -/// Run `body(i)` for each `u32` `i` from `first` while `i < end` (`end` read once, before). -fn count<'a>( - f: &mut FunctionBuilder<'_>, - t: T, - first: u32, - end: Value, - body: impl FnOnce(&mut FunctionBuilder<'_>, Value) -> BResult<()> + 'a, -) -> BResult<()> { - let var = f.local_var(t.u32_, None)?; - let p = f.var_ptr(var)?; - let first = k32(f, first)?; - store(f, p, first)?; - let walk: LoopFn<'_, ()> = Box::new(move |f, _, lc| { - let i = load(f, p)?; - let done = op(f, BinOp::UGreaterThanEqual, i, end)?; - let stop: ArmFn<'_, ()> = Box::new(|f, _| { - lc.break_(f)?; - Ok(ArmEnd::Exits) - }); - f.if_(&mut (), done, stop, None)?; - let next = opk(f, BinOp::IAdd, i, 1)?; - store(f, p, next)?; - body(f, i) - }); - f.loop_(&mut (), LoopSpec::default(), walk) -} - -/// Run `body(i)` for each `i64` `i` from `lo` to `hi` inclusive. -fn span<'a>( - f: &mut FunctionBuilder<'_>, - t: T, - lo: Value, - hi: Value, - body: impl FnOnce(&mut FunctionBuilder<'_>, Value) -> BResult<()> + 'a, -) -> BResult<()> { - let var = f.local_var(t.i64_, None)?; - let p = f.var_ptr(var)?; - store(f, p, lo)?; - let walk: LoopFn<'_, ()> = Box::new(move |f, _, lc| { - let i = load(f, p)?; - let done = op(f, BinOp::SGreaterThan, i, hi)?; - let stop: ArmFn<'_, ()> = Box::new(|f, _| { - lc.break_(f)?; - Ok(ArmEnd::Exits) - }); - f.if_(&mut (), done, stop, None)?; - let next = op64(f, t, BinOp::IAdd, i, 1)?; - store(f, p, next)?; - body(f, i) - }); - f.loop_(&mut (), LoopSpec::default(), walk) -} - -// ---- f32 arithmetic in integers ---- - -/// The exponent field of `f32` bits. -fn exponent(f: &mut FunctionBuilder<'_>, b: Value) -> BResult { - let e = opk(f, BinOp::ShiftRightLogical, b, 23)?; - opk(f, BinOp::BitwiseAnd, e, 0xff) -} - -/// Whether `f32` bits are not finite. -fn not_finite(f: &mut FunctionBuilder<'_>, b: Value) -> BResult { - let e = exponent(f, b)?; - opk(f, BinOp::IEqual, e, 0xff) -} - -/// Whether `f32` bits are subnormal (zero exponent, a fraction). -fn subnormal(f: &mut FunctionBuilder<'_>, b: Value) -> BResult { - let e = exponent(f, b)?; - let tiny = opk(f, BinOp::IEqual, e, 0)?; - let fr = opk(f, BinOp::BitwiseAnd, b, 0x7f_ffff)?; - let some = opk(f, BinOp::INotEqual, fr, 0)?; - and(f, tiny, some) -} - -/// Whether `f32` bits are a NaN. -fn nan(f: &mut FunctionBuilder<'_>, b: Value) -> BResult { - let m = opk(f, BinOp::BitwiseAnd, b, 0x7fff_ffff)?; - opk(f, BinOp::UGreaterThan, m, 0x7f80_0000) -} - -/// Whether the `f32` of bits `b` is below zero (`x < 0.0`): its sign set, not a zero or a NaN. -fn negative(f: &mut FunctionBuilder<'_>, b: Value) -> BResult { - let m = opk(f, BinOp::BitwiseAnd, b, 0x7fff_ffff)?; - let some = opk(f, BinOp::INotEqual, m, 0)?; - let number = opk(f, BinOp::ULessThanEqual, m, 0x7f80_0000)?; - let signed = opk(f, BinOp::UGreaterThanEqual, b, 0x8000_0000)?; - let n = and(f, some, number)?; - and(f, n, signed) -} - -/// Whether the `f32` of bits `b` is at least zero (`x >= 0.0`): neither below zero nor a NaN. -fn nonnegative(f: &mut FunctionBuilder<'_>, b: Value) -> BResult { - let below = negative(f, b)?; - let nan = nan(f, b)?; - let out = or(f, below, nan)?; - not(f, out) -} - -/// Whether the `f32` of bits `b` is at most zero (`x <= 0.0`): below zero or a zero. -fn nonpositive(f: &mut FunctionBuilder<'_>, b: Value) -> BResult { - let below = negative(f, b)?; - let m = opk(f, BinOp::BitwiseAnd, b, 0x7fff_ffff)?; - let zero = opk(f, BinOp::IEqual, m, 0)?; - or(f, below, zero) -} - -/// Whether the `f32` of bits `b` exceeds the positive finite `limit` (`x > limit`): positive -/// floats order as their bits. -fn exceeds(f: &mut FunctionBuilder<'_>, b: Value, limit: f32) -> BResult { - let nan = nan(f, b)?; - let number = not(f, nan)?; - let above = opk(f, BinOp::ULessThan, b, 0x8000_0000)?; - let past = opk(f, BinOp::UGreaterThan, b, limit.to_bits())?; - let a = and(f, number, above)?; - and(f, a, past) -} - -/// The classes and parts of `f32` bits: the sign bit (`u32`, 0 or `0x8000_0000`), whether a NaN, -/// an infinity or a zero, and its significand and exponent ([`normalized`]). -#[derive(Clone, Copy)] -struct Unpacked { - sign: Value, - nan: Value, - inf: Value, - zero: Value, - m: Value, - e: Value, -} - -fn unpack(f: &mut FunctionBuilder<'_>, t: T, b: Value) -> BResult { - let sign = opk(f, BinOp::BitwiseAnd, b, 0x8000_0000)?; - let e = exponent(f, b)?; - let fr = opk(f, BinOp::BitwiseAnd, b, 0x7f_ffff)?; - let top = opk(f, BinOp::IEqual, e, 0xff)?; - let some = opk(f, BinOp::INotEqual, fr, 0)?; - let whole = not(f, some)?; - let nan = and(f, top, some)?; - let inf = and(f, top, whole)?; - let m = opk(f, BinOp::BitwiseAnd, b, 0x7fff_ffff)?; - let zero = opk(f, BinOp::IEqual, m, 0)?; - let (m, e) = normalized(f, t, e, fr, zero)?; - Ok(Unpacked { - sign, - nan, - inf, - zero, - m, - e, - }) -} - -/// An `f32` significand and exponent of finite, non-zero bits `e` and `fr` (exponent field and -/// fraction): `(m, e')` with `m` in `[2^23, 2^24)` and the value `m * 2^(e' - 150)` (`e'` an -/// `i64`). A zero gives `2^23` and an exponent no caller reads. -fn normalized( - f: &mut FunctionBuilder<'_>, - t: T, - e: Value, - fr: Value, - zero: Value, -) -> BResult<(Value, Value)> { - let normal = opk(f, BinOp::INotEqual, e, 0)?; - let implicit = opk(f, BinOp::BitwiseOr, fr, 0x80_0000)?; - let m = sel(f, normal, implicit, fr)?; - let one_bit = k32(f, 0x80_0000)?; - let m = sel(f, zero, one_bit, m)?; - let msb = f.glsl(GlslOp::FindUMsb, &[m])?; - let k23 = k32(f, 23)?; - let lz = op(f, BinOp::ISub, k23, msb)?; - let m = op(f, BinOp::ShiftLeftLogical, m, lz)?; - let one = k32(f, 1)?; - let e = sel(f, normal, e, one)?; - let e = widen(f, t, e)?; - let lz = widen(f, t, lz)?; - let e = op(f, BinOp::ISub, e, lz)?; - Ok((m, e)) -} - -/// The position of the leading one of a non-zero `u64`, an `i64` (`FindUMsb` takes 32 bits). -fn msb64(f: &mut FunctionBuilder<'_>, t: T, s: Value) -> BResult { - let hi = opk(f, BinOp::ShiftRightLogical, s, 32)?; - let hi = low(f, t, hi)?; - let lo = low(f, t, s)?; - let some_hi = opk(f, BinOp::INotEqual, hi, 0)?; - let mh = f.glsl(GlslOp::FindUMsb, &[hi])?; - let mh = opk(f, BinOp::IAdd, mh, 32)?; - let ml = f.glsl(GlslOp::FindUMsb, &[lo])?; - let msb = sel(f, some_hi, mh, ml)?; - widen(f, t, msb) -} - -/// The bits of the `f32` of sign `sign` (a sign bit) and magnitude `s * 2^k` for the `u64` `s` -/// whose leading one is at `p` and whose value's biased exponent is `biased` (both `i64`; `k` -/// follows from them), rounded once to nearest even, with `sticky` (a `bool`) where the exact -/// magnitude lies past `s`'s last bit: subnormal where `biased` is not positive, infinite past the -/// largest finite value. Every caller keeps at least six bits below the rounded significand. -fn pack( - f: &mut FunctionBuilder<'_>, - t: T, - sign: Value, - s: Value, - sticky: Value, - p: Value, - biased: Value, -) -> BResult { - let zero_e = k64(f, t, 0)?; - let one_e = k64(f, t, 1)?; - let sub = op(f, BinOp::SLessThanEqual, biased, zero_e)?; - let below = op(f, BinOp::ISub, one_e, biased)?; - let extra = sel(f, sub, below, zero_e)?; - let shift = op64(f, t, BinOp::ISub, p, 23)?; - let shift = op(f, BinOp::IAdd, shift, extra)?; - let k63 = k64(f, t, 63)?; - let shift = smin(f, shift, k63)?; - let shift = smax(f, shift, zero_e)?; - let sh = low(f, t, shift)?; - let mant = op(f, BinOp::ShiftRightLogical, s, sh)?; - let one64 = ku64(f, t, 1)?; - let zero64 = ku64(f, t, 0)?; - let unit = op(f, BinOp::ShiftLeftLogical, one64, sh)?; - let mask = op(f, BinOp::ISub, unit, one64)?; - let rem = op(f, BinOp::BitwiseAnd, s, mask)?; - let half = opk(f, BinOp::ShiftRightLogical, unit, 1)?; - let above = op(f, BinOp::UGreaterThan, rem, half)?; - let tie = op(f, BinOp::IEqual, rem, half)?; - let odd = op(f, BinOp::BitwiseAnd, mant, one64)?; - let odd = op(f, BinOp::INotEqual, odd, zero64)?; - let tie_up = or(f, sticky, odd)?; - let tie_up = and(f, tie, tie_up)?; - let up = or(f, above, tie_up)?; - let carry = sel(f, up, one64, zero64)?; - let mant = op(f, BinOp::IAdd, mant, carry)?; - let mant = low(f, t, mant)?; - // A normal result's field below its significand's implicit bit, which carries into it. - let field = op(f, BinOp::ISub, biased, one_e)?; - let field = sel(f, sub, zero_e, field)?; - let k300 = k64(f, t, 300)?; - let field = smin(f, field, k300)?; - let field = low(f, t, field)?; - let field = opk(f, BinOp::ShiftLeftLogical, field, 23)?; - let enc = op(f, BinOp::IAdd, field, mant)?; - let over = opk(f, BinOp::UGreaterThanEqual, enc, 0x7f80_0000)?; - let inf_bits = k32(f, 0x7f80_0000)?; - let enc = sel(f, over, inf_bits, enc)?; - op(f, BinOp::BitwiseOr, sign, enc) -} - -/// `floor(mx * 2^30 / my)` of significands `mx` and `my` in `[2^23, 2^24)` (`u32`s), in -/// `(2^29, 2^31)`, and whether a remainder is left (a `bool`): restoring division, one quotient -/// bit a step from the place of `2^0` in `mx / my` (below 2) to that of `2^-30`, in 32-bit words -/// (the remainder stays below `2 my`), dividing nothing (the module docs). -fn significand_quotient( - f: &mut FunctionBuilder<'_>, - t: T, - mx: Value, - my: Value, -) -> BResult<(Value, Value)> { - let rest = f.local_var(t.u32_, None)?; - let rest = f.var_ptr(rest)?; - let quot = f.local_var(t.u32_, None)?; - let quot = f.var_ptr(quot)?; - store(f, rest, mx)?; - let zero = k32(f, 0)?; - store(f, quot, zero)?; - let steps = k32(f, 31)?; - count(f, t, 0, steps, move |f, _| { - let r = load(f, rest)?; - let fits = op(f, BinOp::UGreaterThanEqual, r, my)?; - let less = op(f, BinOp::ISub, r, my)?; - let r = sel(f, fits, less, r)?; - let r = opk(f, BinOp::ShiftLeftLogical, r, 1)?; - store(f, rest, r)?; - let (one, zero) = (k32(f, 1)?, k32(f, 0)?); - let bit = sel(f, fits, one, zero)?; - let q = load(f, quot)?; - let q = opk(f, BinOp::ShiftLeftLogical, q, 1)?; - let q = op(f, BinOp::BitwiseOr, q, bit)?; - store(f, quot, q) - })?; - let q = load(f, quot)?; - let r = load(f, rest)?; - let left = opk(f, BinOp::INotEqual, r, 0)?; - Ok((q, left)) -} - -/// The bits of the IEEE `f32` quotient `x / y` of bits `x` and `y`, rounded once to nearest -/// even, subnormal operands and results exact (Rust's `x / y`; a NaN is `0x7fc0_0000`): from the -/// operands' significands' quotient to 31 bits and whether a remainder is left -/// ([`significand_quotient`]). -fn quotient(f: &mut FunctionBuilder<'_>, t: T, x: Value, y: Value) -> BResult { - let ux = unpack(f, t, x)?; - let uy = unpack(f, t, y)?; - let sign = op(f, BinOp::BitwiseXor, ux.sign, uy.sign)?; - let nan = or(f, ux.nan, uy.nan)?; - let infs = and(f, ux.inf, uy.inf)?; - let zeros = and(f, ux.zero, uy.zero)?; - let nan = or(f, nan, infs)?; - let nan = or(f, nan, zeros)?; - let inf = or(f, ux.inf, uy.zero)?; - let zero = or(f, ux.zero, uy.inf)?; - // The significands' quotient, scaled by 2^30: its leading one at 29 or 30. - let (q, sticky) = significand_quotient(f, t, ux.m, uy.m)?; - let q = f.convert(ConvOp::UConvert, q, t.u64_)?; - let p = msb64(f, t, q)?; - // The value's leading one is 2^(p - 30 + ex - ey). - let d = op(f, BinOp::ISub, ux.e, uy.e)?; - let biased = op(f, BinOp::IAdd, d, p)?; - let biased = op64(f, t, BinOp::IAdd, biased, 97)?; - let r = pack(f, t, sign, q, sticky, p, biased)?; - special( - f, - sign, - [(nan, None), (inf, Some(0x7f80_0000)), (zero, Some(0))], - r, - ) -} - -/// The bits of the IEEE `f32` product `x * y` of bits `x` and `y`, rounded once to nearest even, -/// subnormal operands and results exact (Rust's `x * y`): from the 48-bit product of the -/// significands. -fn product(f: &mut FunctionBuilder<'_>, t: T, x: Value, y: Value) -> BResult { - let ux = unpack(f, t, x)?; - let uy = unpack(f, t, y)?; - let sign = op(f, BinOp::BitwiseXor, ux.sign, uy.sign)?; - let nan = or(f, ux.nan, uy.nan)?; - let a = and(f, ux.inf, uy.zero)?; - let b = and(f, ux.zero, uy.inf)?; - let nan = or(f, nan, a)?; - let nan = or(f, nan, b)?; - let inf = or(f, ux.inf, uy.inf)?; - let zero = or(f, ux.zero, uy.zero)?; - let mx = f.convert(ConvOp::UConvert, ux.m, t.u64_)?; - let my = f.convert(ConvOp::UConvert, uy.m, t.u64_)?; - let s = op(f, BinOp::IMul, mx, my)?; - let p = msb64(f, t, s)?; - // The value's leading one is 2^(p + ex + ey - 300). - let e = op(f, BinOp::IAdd, ux.e, uy.e)?; - let biased = op(f, BinOp::IAdd, e, p)?; - let biased = op64(f, t, BinOp::ISub, biased, 173)?; - let exact = falsy(f, t)?; - let r = pack(f, t, sign, s, exact, p, biased)?; - special( - f, - sign, - [(nan, None), (inf, Some(0x7f80_0000)), (zero, Some(0))], - r, - ) -} - -/// The bits of the IEEE `f32` sum `x + y` of bits `x` and `y`, rounded once to nearest even, -/// subnormal operands and results exact (Rust's `x + y`): the smaller magnitude aligned to the -/// larger's with 30 bits below its significand, the bits shifted past them jammed into the last -/// (so a sum or a difference rounds as the exact one), and an exact cancellation `+0`. -fn sum(f: &mut FunctionBuilder<'_>, t: T, x: Value, y: Value) -> BResult { - let ux = unpack(f, t, x)?; - let uy = unpack(f, t, y)?; - let apart = op(f, BinOp::INotEqual, ux.sign, uy.sign)?; - let nan = or(f, ux.nan, uy.nan)?; - let infs = and(f, ux.inf, uy.inf)?; - let opposed = and(f, infs, apart)?; - let nan = or(f, nan, opposed)?; - // The larger magnitude first. - let higher = op(f, BinOp::SGreaterThan, ux.e, uy.e)?; - let level = op(f, BinOp::IEqual, ux.e, uy.e)?; - let more = op(f, BinOp::UGreaterThanEqual, ux.m, uy.m)?; - let level_more = and(f, level, more)?; - let x_big = or(f, higher, level_more)?; - let (eb, es) = (sel(f, x_big, ux.e, uy.e)?, sel(f, x_big, uy.e, ux.e)?); - let (mb, ms) = (sel(f, x_big, ux.m, uy.m)?, sel(f, x_big, uy.m, ux.m)?); - let sign = sel(f, x_big, ux.sign, uy.sign)?; - let mb = f.convert(ConvOp::UConvert, mb, t.u64_)?; - let mb = opk(f, BinOp::ShiftLeftLogical, mb, 30)?; - let ms = f.convert(ConvOp::UConvert, ms, t.u64_)?; - let ms = opk(f, BinOp::ShiftLeftLogical, ms, 30)?; - let d = op(f, BinOp::ISub, eb, es)?; - let k63 = k64(f, t, 63)?; - let d = smin(f, d, k63)?; - let d = low(f, t, d)?; - let shifted = op(f, BinOp::ShiftRightLogical, ms, d)?; - let one64 = ku64(f, t, 1)?; - let zero64 = ku64(f, t, 0)?; - let unit = op(f, BinOp::ShiftLeftLogical, one64, d)?; - let mask = op(f, BinOp::ISub, unit, one64)?; - let lost = op(f, BinOp::BitwiseAnd, ms, mask)?; - let sticky = op(f, BinOp::INotEqual, lost, zero64)?; - let jam = sel(f, sticky, one64, zero64)?; - let small = op(f, BinOp::BitwiseOr, shifted, jam)?; - let plus = op(f, BinOp::IAdd, mb, small)?; - let minus = op(f, BinOp::ISub, mb, small)?; - let s = sel(f, apart, minus, plus)?; - let cancelled = op(f, BinOp::IEqual, s, zero64)?; - let p = msb64(f, t, s)?; - // The value's leading one is 2^(p + eb - 180). - let biased = op(f, BinOp::IAdd, eb, p)?; - let biased = op64(f, t, BinOp::ISub, biased, 53)?; - let exact = falsy(f, t)?; - let r = pack(f, t, sign, s, exact, p, biased)?; - let zero = k32(f, 0)?; - let r = sel(f, cancelled, zero, r)?; - // A zero operand gives the other (two zeros, -0 only where both are); an infinity itself. - let both = op(f, BinOp::BitwiseAnd, ux.sign, uy.sign)?; - let zeros = and(f, ux.zero, uy.zero)?; - let r = sel(f, uy.zero, x, r)?; - let r = sel(f, ux.zero, y, r)?; - let r = sel(f, zeros, both, r)?; - let r = sel(f, uy.inf, y, r)?; - let r = sel(f, ux.inf, x, r)?; - let nan_bits = k32(f, 0x7fc0_0000)?; - sel(f, nan, nan_bits, r) -} - -/// `r`, but the first of `cases` that holds: a NaN (`None`), or `sign` with the given magnitude -/// bits. -fn special( - f: &mut FunctionBuilder<'_>, - sign: Value, - cases: [(Value, Option); 3], - r: Value, -) -> BResult { - let mut r = r; - for (holds, magnitude) in cases.into_iter().rev() { - let v = match magnitude { - Some(m) => opk(f, BinOp::BitwiseOr, sign, m)?, - None => k32(f, 0x7fc0_0000)?, - }; - r = sel(f, holds, v, r)?; - } - Ok(r) -} - -/// Define a routine `(u32, u32) -> u32` of `f32` bits computing `body`. -fn define_binary( - b: &mut ModuleBuilder, - t: T, - body: fn(&mut FunctionBuilder<'_>, T, Value, Value) -> BResult, -) -> BResult { - let mut f = b.routine(t.u32_)?; - let x = f.param(t.u32_)?; - let y = f.param(t.u32_)?; - let r = body(&mut f, t, x, y)?; - f.ret(Some(r))?; - f.finish() -} - -/// The kernel's routines: the `f32` arithmetic on bits and `bin`. -#[derive(Clone, Copy)] -struct Routines { - divide: FuncId, - multiply: FuncId, - add: FuncId, - bin: FuncId, -} - -/// Call routine `r` on `x` and `y`. -fn call2(f: &mut FunctionBuilder<'_>, r: FuncId, x: Value, y: Value) -> BResult { - f.call(r, &[x, y])? - .ok_or(BuildError::Type(TypeRule::FunctionSignature)) -} - -/// The bits of `x / y` ([`quotient`]). -fn divide(f: &mut FunctionBuilder<'_>, k: &K, x: Value, y: Value) -> BResult { - call2(f, k.r.divide, x, y) -} - -/// The bits of `x * y` ([`product`]). -fn mul(f: &mut FunctionBuilder<'_>, k: &K, x: Value, y: Value) -> BResult { - call2(f, k.r.multiply, x, y) -} - -/// The bits of `x + y` ([`sum`]). -fn add(f: &mut FunctionBuilder<'_>, k: &K, x: Value, y: Value) -> BResult { - call2(f, k.r.add, x, y) -} - -/// The bits of `-x`. -fn neg(f: &mut FunctionBuilder<'_>, x: Value) -> BResult { - opk(f, BinOp::BitwiseXor, x, 0x8000_0000) -} - -/// The bits of `x - y`: `x + (-y)`, as IEEE defines it. -fn sub(f: &mut FunctionBuilder<'_>, k: &K, x: Value, y: Value) -> BResult { - let minus = neg(f, y)?; - add(f, k, x, minus) -} - -/// The `f32` coordinate of bits `c` (pixels) snapped to 1/256 of a pixel, ties to even (an `i64`), and -/// whether it lies within the coordinates measured (a `bool`): past the limit it is clamped to -/// it, and a value not finite is 0 (the reference's `snap_clamped`). From its bits: `c * 256` is -/// `m * 2^(e - 142)`. -fn snap(f: &mut FunctionBuilder<'_>, t: T, c: Value) -> BResult<(Value, Value)> { - let b = c; - let e = exponent(f, b)?; - let finite = opk(f, BinOp::INotEqual, e, 0xff)?; - let fr = opk(f, BinOp::BitwiseAnd, b, 0x7f_ffff)?; - let normal = opk(f, BinOp::INotEqual, e, 0)?; - let implicit = opk(f, BinOp::BitwiseOr, fr, 0x80_0000)?; - let m = sel(f, normal, implicit, fr)?; - let one = k32(f, 1)?; - let e = sel(f, normal, e, one)?; - // From 148 on, |c * 256| >= 2^29: clamped. From 142, a whole number: m shifted left. - let big = opk(f, BinOp::UGreaterThanEqual, e, 148)?; - let whole = opk(f, BinOp::UGreaterThanEqual, e, 142)?; - let k142 = k32(f, 142)?; - let k147 = k32(f, 147)?; - let left_e = sel(f, big, k147, e)?; - let left_e = sel(f, whole, left_e, k142)?; - let lsh = op(f, BinOp::ISub, left_e, k142)?; - let left = op(f, BinOp::ShiftLeftLogical, m, lsh)?; - // Below 142: m shifted right by 142 - e, rounded to nearest even; past 24 places, zero. - let right_e = sel(f, whole, k142, e)?; - let r = op(f, BinOp::ISub, k142, right_e)?; - let gone = opk(f, BinOp::UGreaterThanEqual, r, 25)?; - let k24 = k32(f, 24)?; - let r = sel(f, gone, k24, r)?; - let q = op(f, BinOp::ShiftRightLogical, m, r)?; - let unit = op(f, BinOp::ShiftLeftLogical, one, r)?; - let mask = op(f, BinOp::ISub, unit, one)?; - let rem = op(f, BinOp::BitwiseAnd, m, mask)?; - let half = op(f, BinOp::ShiftRightLogical, unit, one)?; - let above = op(f, BinOp::UGreaterThan, rem, half)?; - let tie = op(f, BinOp::IEqual, rem, half)?; - let odd = op(f, BinOp::BitwiseAnd, q, one)?; - let odd = opk(f, BinOp::INotEqual, odd, 0)?; - let tie = and(f, tie, odd)?; - let up = or(f, above, tie)?; - let zero = k32(f, 0)?; - let carry = sel(f, up, one, zero)?; - let right = op(f, BinOp::IAdd, q, carry)?; - let right = sel(f, gone, zero, right)?; - let mag = sel(f, whole, left, right)?; - let limit = k32(f, LIMIT)?; - let mag = sel(f, big, limit, mag)?; - let mag = sel(f, finite, mag, zero)?; - let mag = widen(f, t, mag)?; - let neg = opk(f, BinOp::ShiftRightLogical, b, 31)?; - let neg = opk(f, BinOp::INotEqual, neg, 0)?; - let minus = f.unary(UnOp::SNegate, mag)?; - let value = sel(f, neg, minus, mag)?; - let small = not(f, big)?; - let measured = and(f, finite, small)?; - Ok((value, measured)) -} - -/// The snapped window position of the clip-space vertex `v` (four `f32`s' bits) under the viewport, -/// flagging unmeasured a coordinate past the limit or not finite (the reference's `snapped`). -fn window(f: &mut FunctionBuilder<'_>, k: &K, v: [Value; 4]) -> BResult<[Value; 2]> { - let t = k.t; - let [ox, oy, w, h] = k.vp; - let half = k32(f, 0.5f32.to_bits())?; - let px = mul(f, k, w, half)?; - let py = mul(f, k, h, half)?; - let xn = divide(f, k, v[0], v[3])?; - let yn = divide(f, k, v[1], v[3])?; - let a = mul(f, k, px, xn)?; - let b = add(f, k, ox, px)?; - let x = add(f, k, a, b)?; - let npy = neg(f, py)?; - let a = mul(f, k, npy, yn)?; - let b = add(f, k, oy, py)?; - let y = add(f, k, a, b)?; - let (sx, mx) = snap(f, t, x)?; - let (sy, my) = snap(f, t, y)?; - let measured = and(f, mx, my)?; - let off = not(f, measured)?; - flag_if(f, k.unmeasured, off)?; - Ok([sx, sy]) -} - -/// The four components of a vertex (`uvec4`). -fn parts(f: &mut FunctionBuilder<'_>, v: Value) -> BResult<[Value; 4]> { - Ok([ - f.composite_extract(v, &[0])?, - f.composite_extract(v, &[1])?, - f.composite_extract(v, &[2])?, - f.composite_extract(v, &[3])?, - ]) -} - -/// The signed distance (`f32` bits) of the clip-space vertex `v` from plane `p` (a `u32`: 0 near, `z`; 1 far, -/// `w - z`; 2 the eye, `w`), inside where not negative (the reference's `depth_planes` and its -/// `w` plane). -fn distance(f: &mut FunctionBuilder<'_>, k: &K, v: [Value; 4], p: Value) -> BResult { - let far = sub(f, k, v[3], v[2])?; - let is_near = opk(f, BinOp::IEqual, p, 0)?; - let is_far = opk(f, BinOp::IEqual, p, 1)?; - let d = sel(f, is_far, far, v[3])?; - sel(f, is_near, v[2], d) -} - -/// Clip the `inputs` (two or three `vec4`s) into the polygon (`k.poly`, `k.n`): flagged and empty -/// where a component is not finite, flagged where one is subnormal; then by the near and far -/// planes under depth clipping (empty where wholly past one, flagged near-far where crossing it) -/// and by `w >= 0` where a vertex has `w <= 0` (flagged unmeasured), Sutherland-Hodgman in `f32` -/// (the reference's `depth_clipped` and `clip`). -fn clip(f: &mut FunctionBuilder<'_>, k: &K, inputs: &[Value]) -> BResult<()> { - let t = k.t; - let mut nonfinite = falsy(f, t)?; - let mut tiny = nonfinite; - for &v in inputs { - for b in parts(f, v)? { - let nf = not_finite(f, b)?; - nonfinite = or(f, nonfinite, nf)?; - let sn = subnormal(f, b)?; - tiny = or(f, tiny, sn)?; - } - } - flag_if(f, k.unmeasured, tiny)?; - flag_if(f, k.unmeasured, nonfinite)?; - for (i, &v) in inputs.iter().enumerate() { - let p = atk(f, k.poly, i as u32)?; - store(f, p, v)?; - } - let len = k32(f, inputs.len() as u32)?; - let zero = k32(f, 0)?; - let n = sel(f, nonfinite, zero, len)?; - store(f, k.n, n)?; - let planes = k32(f, 3)?; - let k = *k; - count(f, t, 0, planes, move |f, p| { - let n = load(f, k.n)?; - let eye = opk(f, BinOp::IEqual, p, 2)?; - let clips = not(f, k.clamp)?; - let active = or(f, eye, clips)?; - let some = opk(f, BinOp::INotEqual, n, 0)?; - let go = and(f, active, some)?; - when(f, go, move |f| plane(f, &k, p, n)) - }) -} - -/// Clip the polygon of `n` vertices by plane `p` where the reference does (the module's -/// [`clip`]). -fn plane(f: &mut FunctionBuilder<'_>, k: &K, p: Value, n: Value) -> BResult<()> { - let t = k.t; - let any_neg = f.local_var(t.u32_, None)?; - let any_neg = f.var_ptr(any_neg)?; - let all_neg = f.local_var(t.u32_, None)?; - let all_neg = f.var_ptr(all_neg)?; - let any_eye = f.local_var(t.u32_, None)?; - let any_eye = f.var_ptr(any_eye)?; - let (zero, one) = (k32(f, 0)?, k32(f, 1)?); - store(f, any_neg, zero)?; - store(f, all_neg, one)?; - store(f, any_eye, zero)?; - let kk = *k; - count(f, t, 0, n, move |f, j| { - let v = at(f, kk.poly, j)?; - let v = load(f, v)?; - let v = parts(f, v)?; - let d = distance(f, &kk, v, p)?; - let neg = negative(f, d)?; - let eye = nonpositive(f, v[3])?; - flag_if(f, any_neg, neg)?; - flag_if(f, any_eye, eye)?; - let pos = not(f, neg)?; - let old = load(f, all_neg)?; - let zero = k32(f, 0)?; - let new = sel(f, pos, zero, old)?; - store(f, all_neg, new) - })?; - let any_neg = load(f, any_neg)?; - let any_neg = opk(f, BinOp::INotEqual, any_neg, 0)?; - let all_neg = load(f, all_neg)?; - let all_neg = opk(f, BinOp::INotEqual, all_neg, 0)?; - let any_eye = load(f, any_eye)?; - let any_eye = opk(f, BinOp::INotEqual, any_eye, 0)?; - let eye = opk(f, BinOp::IEqual, p, 2)?; - let depth = not(f, eye)?; - let empty = and(f, depth, all_neg)?; - let trigger = sel(f, eye, any_eye, any_neg)?; - let k = *k; - either( - f, - empty, - move |f| { - let zero = k32(f, 0)?; - store(f, k.n, zero) - }, - move |f| { - when(f, trigger, move |f| { - let depth = not(f, eye)?; - flag_if(f, k.near_far, depth)?; - flag_if(f, k.unmeasured, eye)?; - cut(f, &k, p, n) - }) - }, - ) -} - -/// Sutherland-Hodgman: the polygon of `n` vertices cut by plane `p` into the scratch array, then -/// copied back (the reference's `clip`; a polygon of two vertices is a segment). -fn cut(f: &mut FunctionBuilder<'_>, k: &K, p: Value, n: Value) -> BResult<()> { - let t = k.t; - let out = f.local_var(t.u32_, None)?; - let out = f.var_ptr(out)?; - let zero = k32(f, 0)?; - store(f, out, zero)?; - let segment = opk(f, BinOp::IEqual, n, 2)?; - let one = k32(f, 1)?; - let edges = sel(f, segment, one, n)?; - let k = *k; - count(f, t, 0, edges, move |f, i| { - let next = opk(f, BinOp::IAdd, i, 1)?; - let wraps = op(f, BinOp::IEqual, next, n)?; - let zero = k32(f, 0)?; - let next = sel(f, wraps, zero, next)?; - let a = at(f, k.poly, i)?; - let a = load(f, a)?; - let b = at(f, k.poly, next)?; - let b = load(f, b)?; - let av = parts(f, a)?; - let bv = parts(f, b)?; - let da = distance(f, &k, av, p)?; - let db = distance(f, &k, bv, p)?; - let ina = nonnegative(f, da)?; - let inb = nonnegative(f, db)?; - when(f, ina, move |f| push(f, &k, out, a))?; - let crosses = op(f, BinOp::LogicalNotEqual, ina, inb)?; - when(f, crosses, move |f| { - let gap = sub(f, &k, da, db)?; - let s = divide(f, &k, da, gap)?; - let mut made = [av[0]; 4]; - for c in 0..4 { - let step = sub(f, &k, bv[c], av[c])?; - let step = mul(f, &k, s, step)?; - made[c] = add(f, &k, av[c], step)?; - } - let v = f.composite_construct(k.t.vec4, &made)?; - push(f, &k, out, v) - })?; - let last = and(f, segment, inb)?; - when(f, last, move |f| push(f, &k, out, b)) - })?; - let made = load(f, out)?; - count(f, t, 0, made, move |f, j| { - let from = at(f, k.scratch, j)?; - let v = load(f, from)?; - let to = at(f, k.poly, j)?; - store(f, to, v) - })?; - store(f, k.n, made) -} - -/// Append `v` to the scratch array (never past its length, which no clip reaches: [`POLYGON`]). -fn push(f: &mut FunctionBuilder<'_>, k: &K, out: Value, v: Value) -> BResult<()> { - let i = load(f, out)?; - let room = opk(f, BinOp::ULessThan, i, POLYGON)?; - let k = *k; - when(f, room, move |f| { - let p = at(f, k.scratch, i)?; - store(f, p, v)?; - let next = opk(f, BinOp::IAdd, i, 1)?; - store(f, out, next) - }) -} - -/// A job for `bin`: of each axis, the closed box `[lo, hi]` over its denominator `den`, and -/// `lo / den` and `hi / den` rounded down (`i64`s: `[lo, hi, den, lo / den, hi / den]`); and up to -/// three half-planes `gx * x + gy * y + c >= 0` (in units), unused ones zero. -struct Job { - x: [Value; 5], - y: [Value; 5], - planes: [[Value; 3]; 3], -} - -/// An axis of a job of denominator 1: `[lo, hi, 1, lo, hi]`. -fn whole(f: &mut FunctionBuilder<'_>, t: T, lo: Value, hi: Value) -> BResult<[Value; 5]> { - let one = k64(f, t, 1)?; - Ok([lo, hi, one, lo, hi]) -} - -/// Bin a job (the function [`define_bin`] defines). -fn call_bin(f: &mut FunctionBuilder<'_>, k: &K, job: Job) -> BResult<()> { - let mut args = Vec::with_capacity(BIN_PARAMS); - args.extend(job.x); - args.extend(job.y); - for p in job.planes { - args.extend(p); - } - f.call(k.r.bin, &args)?; - Ok(()) -} - -/// Three unused half-planes. -fn no_planes(f: &mut FunctionBuilder<'_>, t: T) -> BResult<[[Value; 3]; 3]> { - let zero = k64(f, t, 0)?; - Ok([[zero; 3]; 3]) -} - -/// The parameters of `bin` ([`define_bin`]). -const BIN_PARAMS: usize = 19; - -/// The function `bin(x, y, planes)` of a [`Job`]'s 19 `i64`s, in its fields' order: each tile of -/// the primitive's slice the job meets, within the region (the context), sets its bit of the mask. -/// A tile meets it where its rectangle clipped by the region (half open) is not empty, the job's -/// box meets it, and no half-plane separates it, the rectangle's far edges approached from inside -/// (the reference's `bin` and `meets`). The tiles' sides are powers of two, so the tiles the box -/// can meet follow from its bounds over their denominators by shifts. -fn define_bin(b: &mut ModuleBuilder, t: T, tiles: GlobalId, context: GlobalId) -> BResult { - let void = b.ty(Type::Void)?; - let mut f = b.routine(void)?; - let mut p = Vec::with_capacity(BIN_PARAMS); - for _ in 0..BIN_PARAMS { - p.push(f.param(t.i64_)?); - } - bin_body(&mut f, t, tiles, context, &p)?; - f.ret(None)?; - f.finish() -} - -/// The body of `bin` over its parameters `p` ([`define_bin`]). -fn bin_body( - f: &mut FunctionBuilder<'_>, - t: T, - tiles: GlobalId, - context: GlobalId, - p: &[Value], -) -> BResult<()> { - let [lo_x, hi_x, den_x, qlo_x, qhi_x] = [p[0], p[1], p[2], p[3], p[4]]; - let [lo_y, hi_y, den_y, qlo_y, qhi_y] = [p[5], p[6], p[7], p[8], p[9]]; - let planes = [ - [p[10], p[11], p[12]], - [p[13], p[14], p[15]], - [p[16], p[17], p[18]], - ]; - let context = f.module().global_value(context)?; - let tiles = f.module().global_value(tiles)?; - let mut c = [lo_x; ctx::WORDS as usize]; - for (i, w) in c.iter_mut().enumerate() { - let at = atk(f, context, i as u32)?; - *w = load(f, at)?; - } - let [rx0, rx1, ry0, ry1, tw, th, tiles_x, tiles_y, base, shift_x, shift_y] = c; - // The tiles the box and the region can meet: `floor(lo / den / size)` is - // `floor(floor(lo / den) / size)`, a shift of the job's quotient by the size's power of two. - let range = |f: &mut FunctionBuilder<'_>, - q: [Value; 2], - r0: Value, - r1: Value, - shift: Value, - count: Value| - -> BResult<(Value, Value)> { - let shift = low(f, t, shift)?; - let first = op(f, BinOp::ShiftRightArithmetic, q[0], shift)?; - let zero = k64(f, t, 0)?; - let first = smax(f, first, zero)?; - let r_first = op(f, BinOp::ShiftRightArithmetic, r0, shift)?; - let first = smax(f, first, r_first)?; - let last = op(f, BinOp::ShiftRightArithmetic, q[1], shift)?; - let end = op64(f, t, BinOp::ISub, count, 1)?; - let last = smin(f, last, end)?; - let r_end = op64(f, t, BinOp::ISub, r1, 1)?; - let r_last = op(f, BinOp::ShiftRightArithmetic, r_end, shift)?; - let last = smin(f, last, r_last)?; - Ok((first, last)) - }; - let (tx0, tx1) = range(f, [qlo_x, qhi_x], rx0, rx1, shift_x, tiles_x)?; - let (ty0, ty1) = range(f, [qlo_y, qhi_y], ry0, ry1, shift_y, tiles_y)?; - let words = f.array_length(tiles, 0)?; - let words = widen(f, t, words)?; - span(f, t, ty0, ty1, move |f, ty| { - span(f, t, tx0, tx1, move |f, tx| { - let edge = - |f: &mut FunctionBuilder<'_>, i: Value, size: Value, r0: Value, r1: Value| { - let start = op(f, BinOp::IMul, i, size)?; - let end = op(f, BinOp::IAdd, start, size)?; - Ok::<_, BuildError>((smax(f, r0, start)?, smin(f, r1, end)?)) - }; - let (x0, x1) = edge(f, tx, tw, rx0, rx1)?; - let (y0, y1) = edge(f, ty, th, ry0, ry1)?; - let wide = op(f, BinOp::SLessThan, x0, x1)?; - let tall = op(f, BinOp::SLessThan, y0, y1)?; - let mut ok = and(f, wide, tall)?; - for (lo, hi, den, a0, a1) in [(lo_x, hi_x, den_x, x0, x1), (lo_y, hi_y, den_y, y0, y1)] - { - let far = op(f, BinOp::IMul, a1, den)?; - let near = op(f, BinOp::IMul, a0, den)?; - let before = op(f, BinOp::SLessThan, lo, far)?; - let after = op(f, BinOp::SGreaterThanEqual, hi, near)?; - ok = and(f, ok, before)?; - ok = and(f, ok, after)?; - } - let zero = k64(f, t, 0)?; - for [gx, gy, c] in planes { - let gx_pos = op(f, BinOp::SGreaterThan, gx, zero)?; - let gy_pos = op(f, BinOp::SGreaterThan, gy, zero)?; - let x = sel(f, gx_pos, x1, x0)?; - let y = sel(f, gy_pos, y1, y0)?; - let a = op(f, BinOp::IMul, gx, x)?; - let b = op(f, BinOp::IMul, gy, y)?; - let v = op(f, BinOp::IAdd, a, b)?; - let v = op(f, BinOp::IAdd, v, c)?; - let below = op(f, BinOp::SLessThan, v, zero)?; - let on = op(f, BinOp::IEqual, v, zero)?; - let toward = or(f, gx_pos, gy_pos)?; - let on = and(f, on, toward)?; - let out = or(f, below, on)?; - let kept = not(f, out)?; - ok = and(f, ok, kept)?; - } - let row = op(f, BinOp::IAdd, base, ty)?; - let tile = op(f, BinOp::IMul, row, tiles_x)?; - let tile = op(f, BinOp::IAdd, tile, tx)?; - let w = opk(f, BinOp::ShiftRightArithmetic, tile, 5)?; - let held = op(f, BinOp::SLessThan, w, words)?; - let ok = and(f, ok, held)?; - when(f, ok, move |f| { - let w = low(f, t, w)?; - let tile = low(f, t, tile)?; - let bit = opk(f, BinOp::BitwiseAnd, tile, 31)?; - let one = k32(f, 1)?; - let bit = op(f, BinOp::ShiftLeftLogical, one, bit)?; - let zero = k32(f, 0)?; - let p = f.access_chain(tiles, &[zero, w])?; - f.atomic(AtomicOp::Or, p, Scope::Device, Semantics::RELAXED, bit)?; - Ok(()) - }) - }) - }) -} - -/// Where a point of the `f32` `size` pixels (not negative, at most 511) reaches about its snapped -/// centre, in units (`i64`s): how far back its square starts and its extent from there, half its -/// size back with the start rounded half up, and its size rounded to the nearest 1/16 of a pixel, -/// a half up (the reference's `point_extent`). In integers from its bits: `size * 256 * 2^24` is `m << (e - -/// 118)`, exact from `e = 118` (a size from half a unit) to 135 (511); below, both are zero. -fn point_extent(f: &mut FunctionBuilder<'_>, t: T, size: Value) -> BResult<(Value, Value)> { - let b = size; - let e = exponent(f, b)?; - let fr = opk(f, BinOp::BitwiseAnd, b, 0x7f_ffff)?; - let normal = opk(f, BinOp::INotEqual, e, 0)?; - let implicit = opk(f, BinOp::BitwiseOr, fr, 0x80_0000)?; - let m = sel(f, normal, implicit, fr)?; - let tiny = opk(f, BinOp::ULessThan, e, 118)?; - let k118 = k32(f, 118)?; - let e = sel(f, tiny, k118, e)?; - let sh = op(f, BinOp::ISub, e, k118)?; - let m = f.convert(ConvOp::UConvert, m, t.u64_)?; - let n = op(f, BinOp::ShiftLeftLogical, m, sh)?; - let n = f.convert(ConvOp::Bitcast, n, t.i64_)?; - // ceil((n - 2^24) / 2^25): half the size less half a unit, rounded up. - let less = op64(f, t, BinOp::ISub, n, 1 << 24)?; - let minus = f.unary(UnOp::SNegate, less)?; - let down = opk(f, BinOp::ShiftRightArithmetic, minus, 25)?; - let back = f.unary(UnOp::SNegate, down)?; - // n / 2^28 (the size in sixteenths of a pixel) rounded to nearest, a half up. - let up = op64(f, t, BinOp::IAdd, n, 1 << 27)?; - let sixteenths = opk(f, BinOp::ShiftRightArithmetic, up, 28)?; - let extent = op64(f, t, BinOp::IMul, sixteenths, 16)?; - let zero = k64(f, t, 0)?; - let back = sel(f, tiny, zero, back)?; - let extent = sel(f, tiny, zero, extent)?; - Ok((back, extent)) -} - -/// A point's reach (the reference's `point`): none and flagged where its position is not finite -/// or at or behind the eye, or past the depth range under depth clipping; flagged where a -/// component is subnormal, or its size negative, not a number or subnormal (drawn as 0); its size -/// clamped to 511; the square of [`point_extent`] about its snapped centre. -fn point(f: &mut FunctionBuilder<'_>, k: &K, v: Value, size: Value) -> BResult<()> { - let t = k.t; - let c = parts(f, v)?; - let mut bad = falsy(f, t)?; - let mut tiny = bad; - for b in c { - let nf = not_finite(f, b)?; - bad = or(f, bad, nf)?; - let sn = subnormal(f, b)?; - tiny = or(f, tiny, sn)?; - } - let behind = nonpositive(f, c[3])?; - let bad = or(f, bad, behind)?; - flag_if(f, k.unmeasured, bad)?; - let good = not(f, bad)?; - let k = *k; - when(f, good, move |f| { - flag_if(f, k.unmeasured, tiny)?; - let far = sub(f, &k, c[3], c[2])?; - let near_out = negative(f, c[2])?; - let far_out = negative(f, far)?; - let out = or(f, near_out, far_out)?; - let clips = not(f, k.clamp)?; - let past = and(f, clips, out)?; - flag_if(f, k.unmeasured, past)?; - let drawn = not(f, past)?; - when(f, drawn, move |f| { - let ok = nonnegative(f, size)?; - let not_ok = not(f, ok)?; - flag_if(f, k.unmeasured, not_ok)?; - let zero = k32(f, 0)?; - let s = sel(f, ok, size, zero)?; - let sn = subnormal(f, s)?; - flag_if(f, k.unmeasured, sn)?; - let limit = k32(f, POINT_SIZE_LIMIT.to_bits())?; - let big = exceeds(f, s, POINT_SIZE_LIMIT)?; - let s = sel(f, big, limit, s)?; - let [cx, cy] = window(f, &k, c)?; - let (back, extent) = point_extent(f, t, s)?; - let x0 = op(f, BinOp::ISub, cx, back)?; - let x1 = op(f, BinOp::IAdd, x0, extent)?; - let y0 = op(f, BinOp::ISub, cy, back)?; - let y1 = op(f, BinOp::IAdd, y0, extent)?; - let job = Job { - x: whole(f, t, x0, x1)?, - y: whole(f, t, y0, y1)?, - planes: no_planes(f, t)?, - }; - call_bin(f, &k, job) - }) - }) -} - -/// A line's reach (the reference's `line`): its segment clipped, its ends snapped; a line of no -/// length flagged and binned as the square of a pixel about its end; another as the -/// parallelogram half a pixel across its major axis, extended half a pixel past each end along -/// it (a 45-degree line taken as y-major): the box of its major axis in units, of its minor axis -/// over the major's length `d`, and the two half-planes `|dx (y - py) - dy (x - px)| <= 128 d`. -fn line(f: &mut FunctionBuilder<'_>, k: &K, ends: [Value; 2]) -> BResult<()> { - clip(f, k, &ends)?; - let n = load(f, k.n)?; - let two = opk(f, BinOp::UGreaterThanEqual, n, 2)?; - let k = *k; - when(f, two, move |f| { - let t = k.t; - let a = atk(f, k.poly, 0)?; - let a = load(f, a)?; - let b = atk(f, k.poly, 1)?; - let b = load(f, b)?; - let a = parts(f, a)?; - let b = parts(f, b)?; - let p = window(f, &k, a)?; - let q = window(f, &k, b)?; - let dx = op(f, BinOp::ISub, q[0], p[0])?; - let dy = op(f, BinOp::ISub, q[1], p[1])?; - let zx = op64(f, t, BinOp::IEqual, dx, 0)?; - let zy = op64(f, t, BinOp::IEqual, dy, 0)?; - let zero_length = and(f, zx, zy)?; - either( - f, - zero_length, - move |f| { - let one = k32(f, 1)?; - store(f, k.unmeasured, one)?; - let mut square = [[p[0]; 5]; 2]; - for (axis, c) in [p[0], p[1]].into_iter().enumerate() { - let lo = op64(f, t, BinOp::ISub, c, 128)?; - let hi = op64(f, t, BinOp::IAdd, c, 128)?; - square[axis] = whole(f, t, lo, hi)?; - } - let job = Job { - x: square[0], - y: square[1], - planes: no_planes(f, t)?, - }; - call_bin(f, &k, job) - }, - move |f| parallelogram(f, &k, p, q, [dx, dy]), - ) - }) -} - -/// The job of a line from `p` to `q` of length `delta`, not zero ([`line()`]). -fn parallelogram( - f: &mut FunctionBuilder<'_>, - k: &K, - p: [Value; 2], - q: [Value; 2], - delta: [Value; 2], -) -> BResult<()> { - let t = k.t; - let [dx, dy] = delta; - let adx = sabs(f, t, dx)?; - let ady = sabs(f, t, dy)?; - let x_major = op(f, BinOp::SGreaterThan, adx, ady)?; - let d = sel(f, x_major, adx, ady)?; - let half_d = op64(f, t, BinOp::IMul, d, 128)?; - // The box of axis `a` as the major axis (in units, over 1) and as the minor one (over `d`), - // with the minor one's bounds over `d` rounded down: `floor(start / d)` is - // `p + floor(-along / d)` and `floor(end / d)` is `q + floor(along / d)`. - let mut major = [[p[0]; 2]; 2]; - let mut minor = [[p[0]; 4]; 2]; - for a in 0..2 { - let lo = smin(f, p[a], q[a])?; - let hi = smax(f, p[a], q[a])?; - major[a] = [ - op64(f, t, BinOp::ISub, lo, 128)?, - op64(f, t, BinOp::IAdd, hi, 128)?, - ]; - let along = op64(f, t, BinOp::IMul, delta[a], 128)?; - let start = op(f, BinOp::IMul, p[a], d)?; - let start = op(f, BinOp::ISub, start, along)?; - let end = op(f, BinOp::IMul, q[a], d)?; - let end = op(f, BinOp::IAdd, end, along)?; - let lo = smin(f, start, end)?; - let hi = smax(f, start, end)?; - let (ahead, back) = small_quotients(f, t, along, d)?; - let start_q = op(f, BinOp::IAdd, p[a], back)?; - let end_q = op(f, BinOp::IAdd, q[a], ahead)?; - let lo_q = smin(f, start_q, end_q)?; - let hi_q = smax(f, start_q, end_q)?; - minor[a] = [ - op(f, BinOp::ISub, lo, half_d)?, - op(f, BinOp::IAdd, hi, half_d)?, - op64(f, t, BinOp::ISub, lo_q, 128)?, - op64(f, t, BinOp::IAdd, hi_q, 128)?, - ]; - } - let one = k64(f, t, 1)?; - let mut axes = [[p[0]; 5]; 2]; - for (a, axis) in axes.iter_mut().enumerate() { - // Axis `a` is the major one where `x_major` is `a == 0`. - let is_major = match a { - 0 => x_major, - _ => not(f, x_major)?, - }; - let [lo, hi] = major[a]; - let [mlo, mhi, mqlo, mqhi] = minor[a]; - *axis = [ - sel(f, is_major, lo, mlo)?, - sel(f, is_major, hi, mhi)?, - sel(f, is_major, one, d)?, - sel(f, is_major, lo, mqlo)?, - sel(f, is_major, hi, mqhi)?, - ]; - } - // dx (y - py) - dy (x - px) = dx y - dy x + c0, c0 = dy px - dx py. - let a = op(f, BinOp::IMul, dy, p[0])?; - let b = op(f, BinOp::IMul, dx, p[1])?; - let c0 = op(f, BinOp::ISub, a, b)?; - let ndy = f.unary(UnOp::SNegate, dy)?; - let ndx = f.unary(UnOp::SNegate, dx)?; - let c_a = op(f, BinOp::IAdd, c0, half_d)?; - let c_b = op(f, BinOp::ISub, half_d, c0)?; - let zero = k64(f, t, 0)?; - call_bin( - f, - k, - Job { - x: axes[0], - y: axes[1], - planes: [[ndy, dx, c_a], [dy, ndx, c_b], [zero; 3]], - }, - ) -} - -/// `(floor(along / d), floor(-along / d))` for `i64`s `along` and `d > 0` with `|along| <= 128 d` -/// (a line's minor axis): from `floor(|along| / d)`, at most 128, found a bit at a time from 128 -/// down by products (no division), and whether it is exact. -fn small_quotients( - f: &mut FunctionBuilder<'_>, - t: T, - along: Value, - d: Value, -) -> BResult<(Value, Value)> { - let u = sabs(f, t, along)?; - let mut q = k64(f, t, 0)?; - for bit in [128, 64, 32, 16, 8, 4, 2, 1] { - let more = op64(f, t, BinOp::IAdd, q, bit)?; - let product = op(f, BinOp::IMul, more, d)?; - let fits = op(f, BinOp::SLessThanEqual, product, u)?; - q = sel(f, fits, more, q)?; - } - let product = op(f, BinOp::IMul, q, d)?; - let exact = op(f, BinOp::IEqual, product, u)?; - let (zero, one) = (k64(f, t, 0)?, k64(f, t, 1)?); - let up = sel(f, exact, zero, one)?; - let ceil = op(f, BinOp::IAdd, q, up)?; - let down = f.unary(UnOp::SNegate, ceil)?; - let ahead_pos = op(f, BinOp::SGreaterThanEqual, along, zero)?; - Ok((sel(f, ahead_pos, q, down)?, sel(f, ahead_pos, down, q)?)) -} - -/// A triangle's reach (the reference's `triangle`): its polygon clipped, its vertices snapped, -/// and each triangle of its fan from the first vertex not of zero area, not culled by face and -/// not by the small-primitive cull, binned as its box and its three edges' half-planes. -fn triangle(f: &mut FunctionBuilder<'_>, k: &K, vertices: [Value; 3]) -> BResult<()> { - clip(f, k, &vertices)?; - let n = load(f, k.n)?; - let three = opk(f, BinOp::UGreaterThanEqual, n, 3)?; - let k = *k; - when(f, three, move |f| { - let t = k.t; - count(f, t, 0, n, move |f, j| { - let v = at(f, k.poly, j)?; - let v = load(f, v)?; - let v = parts(f, v)?; - let [x, y] = window(f, &k, v)?; - let i = opk(f, BinOp::IMul, j, 2)?; - let px = at(f, k.pts, i)?; - store(f, px, x)?; - let i = opk(f, BinOp::IAdd, i, 1)?; - let py = at(f, k.pts, i)?; - store(f, py, y) - })?; - let last = opk(f, BinOp::ISub, n, 1)?; - count(f, t, 1, last, move |f, i| fan(f, &k, i)) - }) -} - -/// The snapped vertex `j` (a `u32`) of the polygon. -fn vertex(f: &mut FunctionBuilder<'_>, k: &K, j: Value) -> BResult<[Value; 2]> { - let i = opk(f, BinOp::IMul, j, 2)?; - let x = at(f, k.pts, i)?; - let x = load(f, x)?; - let i = opk(f, BinOp::IAdd, i, 1)?; - let y = at(f, k.pts, i)?; - let y = load(f, y)?; - Ok([x, y]) -} - -/// The fan's triangle of the polygon's vertices 0, `i` and `i + 1` ([`triangle`]). -fn fan(f: &mut FunctionBuilder<'_>, k: &K, i: Value) -> BResult<()> { - let t = k.t; - let zero32 = k32(f, 0)?; - let a = vertex(f, k, zero32)?; - let b = vertex(f, k, i)?; - let next = opk(f, BinOp::IAdd, i, 1)?; - let c = vertex(f, k, next)?; - let ux = op(f, BinOp::ISub, b[0], a[0])?; - let uy = op(f, BinOp::ISub, b[1], a[1])?; - let vx = op(f, BinOp::ISub, c[0], a[0])?; - let vy = op(f, BinOp::ISub, c[1], a[1])?; - let l = op(f, BinOp::IMul, ux, vy)?; - let r = op(f, BinOp::IMul, uy, vx)?; - let area = op(f, BinOp::ISub, l, r)?; - let zero = k64(f, t, 0)?; - let some = op(f, BinOp::INotEqual, area, zero)?; - // Clockwise in window coordinates, y down, is a positive area. - let pos = op(f, BinOp::SGreaterThan, area, zero)?; - let cw = opk(f, BinOp::IEqual, k.winding, 0)?; - let front = op(f, BinOp::LogicalEqual, pos, cw)?; - let back = not(f, front)?; - let cull_front = opk(f, BinOp::IEqual, k.cull, 1)?; - let cull_back = opk(f, BinOp::IEqual, k.cull, 2)?; - let culled_front = and(f, cull_front, front)?; - let culled_back = and(f, cull_back, back)?; - let culled = or(f, culled_front, culled_back)?; - let kept = not(f, culled)?; - let go = and(f, some, kept)?; - let k = *k; - when(f, go, move |f| { - let (one, minus) = (k64(f, t, 1)?, k64(f, t, -1)?); - let sign = sel(f, pos, one, minus)?; - let tri = [a, b, c]; - let culled = sample_culled(f, &k, tri, sign)?; - let drawn = not(f, culled)?; - when(f, drawn, move |f| { - let mut x = [a[0]; 5]; - let mut y = [a[0]; 5]; - for (axis, out) in [(0, &mut x), (1, &mut y)] { - let lo = smin(f, a[axis], b[axis])?; - let lo = smin(f, lo, c[axis])?; - let hi = smax(f, a[axis], b[axis])?; - let hi = smax(f, hi, c[axis])?; - *out = whole(f, t, lo, hi)?; - } - let mut planes = no_planes(f, t)?; - for (e, plane) in planes.iter_mut().enumerate() { - let (p, q) = (tri[e], tri[(e + 1) % 3]); - // sign * cross(q - p, (x, y) - p) >= 0. - let rise = op(f, BinOp::ISub, p[1], q[1])?; - let gx = op(f, BinOp::IMul, sign, rise)?; - let run = op(f, BinOp::ISub, q[0], p[0])?; - let gy = op(f, BinOp::IMul, sign, run)?; - let a = op(f, BinOp::IMul, gx, p[0])?; - let b = op(f, BinOp::IMul, gy, p[1])?; - let s = op(f, BinOp::IAdd, a, b)?; - let c = f.unary(UnOp::SNegate, s)?; - *plane = [gx, gy, c]; - } - call_bin(f, &k, Job { x, y, planes }) - }) - }) -} - -/// The default sample positions of a pixel in units (Metal's, Vulkan's standard ones) at 1, 2 and -/// 4 samples (the reference's `sample_offsets`). -const OFFSETS: [&[[i64; 2]]; 3] = [ - &[[128, 128]], - &[[192, 192], [64, 64]], - &[[96, 32], [224, 96], [32, 160], [160, 224]], -]; - -/// Whether the small-primitive cull drops the triangle `tri` of orientation `sign` (the -/// reference's `sample_culled`): its closed box holds at most 12 sample positions (24 at 4 -/// samples) and its closed area none of them, position by position (`covers_sample`). An -/// offset whose columns the box holds none of holds no position, so it is not walked. -fn sample_culled( - f: &mut FunctionBuilder<'_>, - k: &K, - tri: [[Value; 2]; 3], - sign: Value, -) -> BResult { - let t = k.t; - let four = opk(f, BinOp::IEqual, k.samples, 4)?; - let two = opk(f, BinOp::IEqual, k.samples, 2)?; - let many = or(f, four, two)?; - let untrue = falsy(f, t)?; - let truthy = not(f, untrue)?; - let mut lo = [tri[0][0]; 2]; - let mut hi = [tri[0][0]; 2]; - for axis in 0..2 { - let l = smin(f, tri[0][axis], tri[1][axis])?; - lo[axis] = smin(f, l, tri[2][axis])?; - let h = smax(f, tri[0][axis], tri[1][axis])?; - hi[axis] = smax(f, h, tri[2][axis])?; - } - let zero = k64(f, t, 0)?; - // The sample positions' columns or rows within `[lo, hi]` at offset `o`. - let span_of = |f: &mut FunctionBuilder<'_>, lo: Value, hi: Value, o: Value| { - let a = op(f, BinOp::ISub, hi, o)?; - let a = floor_unit(f, a)?; - let b = op(f, BinOp::ISub, lo, o)?; - let b = ceil_unit(f, b)?; - let s = op(f, BinOp::ISub, a, b)?; - let s = op64(f, t, BinOp::IAdd, s, 1)?; - smax(f, s, zero) - }; - let mut offsets = Vec::with_capacity(4); - let mut boxed = zero; - for s in 0..4 { - let mut o = [zero; 2]; - for (axis, slot) in o.iter_mut().enumerate() { - let at = |n: usize| OFFSETS[n].get(s).map_or(0, |p| p[axis]); - let v4 = k64(f, t, at(2))?; - let v2 = k64(f, t, at(1))?; - let v1 = k64(f, t, at(0))?; - let v = sel(f, two, v2, v1)?; - *slot = sel(f, four, v4, v)?; - } - let active = match s { - 0 => truthy, - 1 => many, - _ => four, - }; - let cols = span_of(f, lo[0], hi[0], o[0])?; - let rows = span_of(f, lo[1], hi[1], o[1])?; - let held = op(f, BinOp::IMul, cols, rows)?; - let held = sel(f, active, held, zero)?; - boxed = op(f, BinOp::IAdd, boxed, held)?; - let some = op(f, BinOp::SGreaterThan, cols, zero)?; - let walk = and(f, active, some)?; - offsets.push((o, walk)); - } - let (k24, k12) = (k64(f, t, 24)?, k64(f, t, 12)?); - let tested = sel(f, four, k24, k12)?; - let few = op(f, BinOp::SLessThanEqual, boxed, tested)?; - let covers = f.local_var(t.u32_, None)?; - let covers = f.var_ptr(covers)?; - let zero32 = k32(f, 0)?; - store(f, covers, zero32)?; - when(f, few, move |f| { - for (o, walk) in offsets { - when(f, walk, move |f| { - let mut ends = [[o[0]; 2]; 2]; - for (axis, end) in ends.iter_mut().enumerate() { - let first = op(f, BinOp::ISub, lo[axis], o[axis])?; - let last = op(f, BinOp::ISub, hi[axis], o[axis])?; - *end = [ceil_unit(f, first)?, floor_unit(f, last)?]; - } - span(f, t, ends[1][0], ends[1][1], move |f, row| { - span(f, t, ends[0][0], ends[0][1], move |f, column| { - let hit = holds_sample(f, t, tri, sign, o, [column, row])?; - flag_if(f, covers, hit) - }) - }) - })?; - } - Ok(()) - })?; - let covers = load(f, covers)?; - let none = opk(f, BinOp::IEqual, covers, 0)?; - and(f, few, none) -} - -/// Whether the sample position of column and row `at` at offset `o` (`256 at + o` units) lies -/// within the closed triangle `tri` of orientation `sign`: on the inner side of each edge or on it, -/// `sign * cross(b - a, p - a) >= 0` (the reference's `covers_sample`, position by position: the -/// box holds at most 24 of them). -fn holds_sample( - f: &mut FunctionBuilder<'_>, - t: T, - tri: [[Value; 2]; 3], - sign: Value, - o: [Value; 2], - at: [Value; 2], -) -> BResult { - let mut point = [o[0]; 2]; - for (axis, c) in point.iter_mut().enumerate() { - let u = op64(f, t, BinOp::IMul, at[axis], UNIT)?; - *c = op(f, BinOp::IAdd, u, o[axis])?; - } - let zero = k64(f, t, 0)?; - let mut sides = [zero; 3]; - for (e, inner) in sides.iter_mut().enumerate() { - let (a, b) = (tri[e], tri[(e + 1) % 3]); - let run = op(f, BinOp::ISub, b[0], a[0])?; - let rise = op(f, BinOp::ISub, b[1], a[1])?; - let px = op(f, BinOp::ISub, point[0], a[0])?; - let py = op(f, BinOp::ISub, point[1], a[1])?; - let l = op(f, BinOp::IMul, run, py)?; - let r = op(f, BinOp::IMul, rise, px)?; - let cross = op(f, BinOp::ISub, l, r)?; - let cross = op(f, BinOp::IMul, sign, cross)?; - *inner = op(f, BinOp::SGreaterThanEqual, cross, zero)?; - } - let two = and(f, sides[0], sides[1])?; - and(f, two, sides[2]) -} - -/// A `Block { u32 words[]; }` storage buffer bound at `sym`. -fn words_buffer(b: &mut ModuleBuilder, sym: ResourceSlot, u32_: TypeId) -> BResult { - let rta = b.ty(Type::RuntimeArray { - elem: u32_, - stride: Some(4), - })?; - let layout = natural_layout(b.types(), LayoutRule::Std430, true, &[rta])?; - let block = b.ty(Type::Struct { - members: [rta].into(), - layout: Some(layout), - })?; - b.resource(sym, StorageClass::StorageBuffer, block) -} - -/// A `Function` array of `len` elements of `elem`, as its pointer. -fn array_var(f: &mut FunctionBuilder<'_>, elem: TypeId, len: u32) -> BResult { - let len = f.u32_const(len)?; - let ty = f.module().ty(Type::Array { - elem, - len, - stride: None, - })?; - let v = f.local_var(ty, None)?; - f.var_ptr(v) -} - -/// The module as a typed module, before serialization: the module -/// [`tile_reach_module`](super::tile_reach_module) serializes, which the CPU interpreter runs. -/// Its bindings are the symbols `PRIMITIVES`, `PASS` and `TILES`. -pub(super) fn typed_module() -> BResult { - let mut b = ModuleBuilder::new(); - let (t, uvec3) = types(&mut b)?; - let prims = words_buffer(&mut b, PRIMITIVES, t.u32_)?; - let pass = words_buffer(&mut b, PASS, t.u32_)?; - let tiles = words_buffer(&mut b, TILES, t.u32_)?; - let invocation = b.builtin(crate::spv::BuiltIn::GlobalInvocationId, IoDir::Input, uvec3)?; - let (r, context) = routines(&mut b, t, tiles)?; - let void = b.ty(Type::Void)?; - let mut f = b.function(void)?; - let g = [prims, pass, context, invocation]; - main_body(&mut f, t, r, g)?; - f.ret(None)?; - let id = f.finish()?; - entry(&mut b, id)?; - b.finalize() -} - -/// The kernel's routines, over the mask `tiles`, and the `Private` context `bin` reads. -fn routines(b: &mut ModuleBuilder, t: T, tiles: GlobalId) -> BResult<(Routines, GlobalId)> { - let words = b.constant(Constant::Scalar { - ty: t.u32_, - bits: ConstBits(u64::from(ctx::WORDS)), - })?; - let ctx_ty = b.ty(Type::Array { - elem: t.i64_, - len: words, - stride: None, - })?; - let context = b.plain_global(StorageClass::Private, ctx_ty, None)?; - let r = Routines { - divide: define_binary(b, t, quotient)?, - multiply: define_binary(b, t, product)?, - add: define_binary(b, t, sum)?, - bin: define_bin(b, t, tiles, context)?, - }; - Ok((r, context)) -} - -/// The kernel's types, and the `uvec3` of its invocation's id. -fn types(b: &mut ModuleBuilder) -> BResult<(T, TypeId)> { - let bool_ = b.ty(Type::Bool)?; - let u32_ = b.ty(Type::Int { - width: 32, - signed: false, - })?; - let u64_ = b.ty(Type::Int { - width: 64, - signed: false, - })?; - let i64_ = b.ty(Type::Int { - width: 64, - signed: true, - })?; - let vec4 = b.ty(Type::Vector { elem: u32_, len: 4 })?; - let uvec3 = b.ty(Type::Vector { elem: u32_, len: 3 })?; - let t = T { - bool_, - u32_, - u64_, - i64_, - vec4, - }; - Ok((t, uvec3)) -} - -/// Make `id` the `GLCompute` entry point of local size ([`TileReachModule::LOCAL_SIZE`](M), 1, -/// 1). -fn entry(b: &mut ModuleBuilder, id: FuncId) -> BResult<()> { - b.entry( - ExecModel::GLCompute, - id, - vec![ExecMode::LocalSize { - x: M::LOCAL_SIZE, - y: 1, - z: 1, - }], - )?; - Ok(()) -} - -/// The words of one record of [`arithmetic_module`]: in, the bits of an `f32` `x`, `y` and a -/// point size; out, the bits of the kernel's quotient `x / y`, product `x * y` and sum `x + y`, -/// `x` snapped (an `i64`, its low word first) and whether it lay within the coordinates measured -/// (1 or 0), and the size's point extent (how far back and the extent, each a word). -#[cfg(test)] -pub(super) const ARITHMETIC_WORDS: u32 = 11; - -/// A probe of the kernel's arithmetic for the tests: invocation `i` reads record `i` of the -/// buffer `PRIMITIVES` (records of [`ARITHMETIC_WORDS`], as many as it holds) and writes the -/// results of [`quotient`], [`product`], [`sum`], [`snap`] and [`point_extent`] into it, as the -/// kernel computes them. -#[cfg(test)] -pub(super) fn arithmetic_module() -> BResult { - let mut b = ModuleBuilder::new(); - let (t, uvec3) = types(&mut b)?; - let records = words_buffer(&mut b, PRIMITIVES, t.u32_)?; - let invocation = b.builtin(crate::spv::BuiltIn::GlobalInvocationId, IoDir::Input, uvec3)?; - let divide = define_binary(&mut b, t, quotient)?; - let multiply = define_binary(&mut b, t, product)?; - let plus = define_binary(&mut b, t, sum)?; - let void = b.ty(Type::Void)?; - let mut f = b.function(void)?; - let records = f.module().global_value(records)?; - let invocation = f.module().global_value(invocation)?; - let gid = load(&mut f, invocation)?; - let i = f.composite_extract(gid, &[0])?; - let len = f.array_length(records, 0)?; - let held = opk(&mut f, BinOp::UDiv, len, ARITHMETIC_WORDS)?; - let inside = op(&mut f, BinOp::ULessThan, i, held)?; - when(&mut f, inside, move |f| { - let base = opk(f, BinOp::IMul, i, ARITHMETIC_WORDS)?; - let field = |f: &mut FunctionBuilder<'_>, at: u32| { - let w = opk(f, BinOp::IAdd, base, at)?; - let zero = k32(f, 0)?; - f.access_chain(records, &[zero, w]) - }; - let mut input = [base; 3]; - for (at, v) in input.iter_mut().enumerate() { - let p = field(f, at as u32)?; - *v = load(f, p)?; - } - let [x, y, size] = input; - let q = call2(f, divide, x, y)?; - let m = call2(f, multiply, x, y)?; - let a = call2(f, plus, x, y)?; - let (s, measured) = snap(f, t, x)?; - let s_lo = low(f, t, s)?; - let s_hi = opk(f, BinOp::ShiftRightArithmetic, s, 32)?; - let s_hi = low(f, t, s_hi)?; - let (one, zero) = (k32(f, 1)?, k32(f, 0)?); - let measured = sel(f, measured, one, zero)?; - let (back, extent) = point_extent(f, t, size)?; - let back = low(f, t, back)?; - let extent = low(f, t, extent)?; - for (at, v) in [ - (3, q), - (4, m), - (5, a), - (6, s_lo), - (7, s_hi), - (8, measured), - (9, back), - (10, extent), - ] { - let p = field(f, at)?; - store(f, p, v)?; - } - Ok(()) - })?; - f.ret(None)?; - let id = f.finish()?; - entry(&mut b, id)?; - b.finalize() -} - -/// The words of one record of [`clip_module`]: the plane (0 near, 1 far, 2 the eye), the -/// polygon's vertices' count, and [`POLYGON`] vertices (four `f32`s' bits each); out, the count -/// and the vertices of the polygon clipped. -#[cfg(test)] -pub(super) const CLIP_WORDS: u32 = 2 + 4 * POLYGON; - -/// A probe of the clipper for the tests: invocation `i` reads record `i` of the buffer -/// `PRIMITIVES` (records of [`CLIP_WORDS`], as many as it holds), clips its polygon by its plane -/// as the kernel does where the plane cuts it ([`cut`]), and writes the result into it. -#[cfg(test)] -pub(super) fn clip_module() -> BResult { - let mut b = ModuleBuilder::new(); - let (t, uvec3) = types(&mut b)?; - let records = words_buffer(&mut b, PRIMITIVES, t.u32_)?; - let tiles = words_buffer(&mut b, TILES, t.u32_)?; - let invocation = b.builtin(crate::spv::BuiltIn::GlobalInvocationId, IoDir::Input, uvec3)?; - let (r, _) = routines(&mut b, t, tiles)?; - let void = b.ty(Type::Void)?; - let mut f = b.function(void)?; - let records = f.module().global_value(records)?; - let invocation = f.module().global_value(invocation)?; - let gid = load(&mut f, invocation)?; - let i = f.composite_extract(gid, &[0])?; - let len = f.array_length(records, 0)?; - let held = opk(&mut f, BinOp::UDiv, len, CLIP_WORDS)?; - let inside = op(&mut f, BinOp::ULessThan, i, held)?; - let mut flags = [i; 2]; - for flag in &mut flags { - let v = f.local_var(t.u32_, None)?; - *flag = f.var_ptr(v)?; - } - let poly = array_var(&mut f, t.vec4, POLYGON)?; - let scratch = array_var(&mut f, t.vec4, POLYGON)?; - let pts = array_var(&mut f, t.i64_, 2 * POLYGON)?; - let n = f.local_var(t.u32_, None)?; - let n = f.var_ptr(n)?; - when(&mut f, inside, move |f| { - let base = opk(f, BinOp::IMul, i, CLIP_WORDS)?; - let field = |f: &mut FunctionBuilder<'_>, at: u32| { - let w = opk(f, BinOp::IAdd, base, at)?; - let zero = k32(f, 0)?; - f.access_chain(records, &[zero, w]) - }; - let p = field(f, 0)?; - let plane = load(f, p)?; - let p = field(f, 1)?; - let count = load(f, p)?; - for j in 0..POLYGON { - let mut c = [i; 4]; - for (at, w) in c.iter_mut().enumerate() { - let p = field(f, 2 + 4 * j + at as u32)?; - *w = load(f, p)?; - } - let v = f.composite_construct(t.vec4, &c)?; - let to = atk(f, poly, j)?; - store(f, to, v)?; - } - store(f, n, count)?; - let zero = k32(f, 0)?; - let k = K { - t, - r, - near_far: flags[0], - unmeasured: flags[1], - poly, - scratch, - n, - pts, - vp: [zero; 4], - clamp: falsy(f, t)?, - cull: zero, - winding: zero, - samples: zero, - }; - cut(f, &k, plane, count)?; - let made = load(f, n)?; - let p = field(f, 1)?; - store(f, p, made)?; - for j in 0..POLYGON { - let from = atk(f, poly, j)?; - let v = load(f, from)?; - for c in 0..4 { - let w = f.composite_extract(v, &[c])?; - let p = field(f, 2 + 4 * j + c)?; - store(f, p, w)?; - } - } - Ok(()) - })?; - f.ret(None)?; - let id = f.finish()?; - entry(&mut b, id)?; - b.finalize() -} - -/// The entry's body: invocation `i` below the header's count bins primitive `i`, and counts it -/// in the header's near-far and unmeasured words where it is flagged so. -fn main_body( - f: &mut FunctionBuilder<'_>, - t: T, - r: Routines, - globals: [GlobalId; 4], -) -> BResult<()> { - let [prims, pass, context, invocation] = globals; - let prims = f.module().global_value(prims)?; - let pass = f.module().global_value(pass)?; - let context = f.module().global_value(context)?; - let invocation = f.module().global_value(invocation)?; - let gid = load(f, invocation)?; - let i = f.composite_extract(gid, &[0])?; - let at = k32(f, layout::COUNT)?; - let total = word(f, pass, at)?; - let inside = op(f, BinOp::ULessThan, i, total)?; - let near_far = f.local_var(t.u32_, None)?; - let near_far = f.var_ptr(near_far)?; - let unmeasured = f.local_var(t.u32_, None)?; - let unmeasured = f.var_ptr(unmeasured)?; - let zero = k32(f, 0)?; - store(f, near_far, zero)?; - store(f, unmeasured, zero)?; - let poly = array_var(f, t.vec4, POLYGON)?; - let scratch = array_var(f, t.vec4, POLYGON)?; - let pts = array_var(f, t.i64_, 2 * POLYGON)?; - let n = f.local_var(t.u32_, None)?; - let n = f.var_ptr(n)?; - let parts = Parts { - t, - r, - prims, - pass, - context, - near_far, - unmeasured, - poly, - scratch, - n, - pts, - }; - when(f, inside, move |f| { - primitive(f, parts, i)?; - for (flag, w) in [ - (near_far, M::NEAR_FAR_WORD), - (unmeasured, M::UNMEASURED_WORD), - ] { - let set = load(f, flag)?; - let set = opk(f, BinOp::INotEqual, set, 0)?; - when(f, set, move |f| { - let zero = k32(f, 0)?; - let w = k32(f, w)?; - let p = f.access_chain(pass, &[zero, w])?; - let one = k32(f, 1)?; - f.atomic(AtomicOp::IAdd, p, Scope::Device, Semantics::RELAXED, one)?; - Ok(()) - })?; - } - Ok(()) - }) -} - -/// What [`primitive`] starts from: the main function's buffers and variables. -#[derive(Clone, Copy)] -struct Parts { - t: T, - r: Routines, - prims: Value, - pass: Value, - context: Value, - near_far: Value, - unmeasured: Value, - poly: Value, - scratch: Value, - n: Value, - pts: Value, -} - -/// Bin primitive `i`: read its record and its state (a state past the pass's is flagged -/// unmeasured and reaches nothing), set the context, and bin it by its kind (another kind is -/// flagged unmeasured and reaches nothing). -fn primitive(f: &mut FunctionBuilder<'_>, p: Parts, i: Value) -> BResult<()> { - let t = p.t; - let base = opk(f, BinOp::IMul, i, M::PRIMITIVE_WORDS)?; - let field = |f: &mut FunctionBuilder<'_>, at: u32| { - let w = opk(f, BinOp::IAdd, base, at)?; - word(f, p.prims, w) - }; - let kind = field(f, layout::KIND)?; - let state = field(f, layout::STATE)?; - let layer = field(f, layout::LAYER)?; - let size = field(f, layout::SIZE)?; - let mut vertices = Vec::with_capacity(3); - for v in 0..3 { - let mut c = Vec::with_capacity(4); - for i in 0..4 { - let w = field(f, layout::VERTICES + 4 * v + i)?; - c.push(w); - } - vertices.push(f.composite_construct(t.vec4, &c)?); - } - let len = f.array_length(p.pass, 0)?; - let header = opk(f, BinOp::UGreaterThanEqual, len, M::HEADER_WORDS)?; - let after = opk(f, BinOp::ISub, len, M::HEADER_WORDS)?; - let states = opk(f, BinOp::UDiv, after, M::STATE_WORDS)?; - let zero = k32(f, 0)?; - let states = sel(f, header, states, zero)?; - let valid = op(f, BinOp::ULessThan, state, states)?; - let invalid = not(f, valid)?; - flag_if(f, p.unmeasured, invalid)?; - let vertices = [vertices[0], vertices[1], vertices[2]]; - when(f, valid, move |f| { - let k = setup(f, p, state, layer)?; - let is = |f: &mut FunctionBuilder<'_>, v: u32| opk(f, BinOp::IEqual, kind, v); - let point_kind = is(f, M::POINT)?; - when(f, point_kind, move |f| point(f, &k, vertices[0], size))?; - let line_kind = is(f, M::LINE)?; - when(f, line_kind, move |f| { - line(f, &k, [vertices[0], vertices[1]]) - })?; - let triangle_kind = is(f, M::TRIANGLE)?; - when(f, triangle_kind, move |f| triangle(f, &k, vertices))?; - let other = opk(f, BinOp::UGreaterThan, kind, M::TRIANGLE)?; - flag_if(f, k.unmeasured, other) - }) -} - -/// Read the primitive's state and set the context: the region (the viewport's, flagged -/// unmeasured where its edges lie past the coordinates measured, the scissor's and the render -/// area's), the tiles and the slice (a layer past the pass's renders its first). -fn setup(f: &mut FunctionBuilder<'_>, p: Parts, state: Value, layer: Value) -> BResult { - let t = p.t; - let header = |f: &mut FunctionBuilder<'_>, at: u32| { - let at = k32(f, at)?; - word(f, p.pass, at) - }; - let aw = header(f, layout::AREA_W)?; - let ah = header(f, layout::AREA_H)?; - let samples = header(f, layout::SAMPLES)?; - let layers = header(f, layout::LAYERS)?; - let base = opk(f, BinOp::IMul, state, M::STATE_WORDS)?; - let base = opk(f, BinOp::IAdd, base, M::HEADER_WORDS)?; - let field = |f: &mut FunctionBuilder<'_>, at: u32| { - let w = opk(f, BinOp::IAdd, base, at)?; - word(f, p.pass, w) - }; - let mut vp = [state; 4]; - for (i, v) in vp.iter_mut().enumerate() { - *v = field(f, layout::VIEWPORT + i as u32)?; - } - let mut scissor = [state; 4]; - for (i, s) in scissor.iter_mut().enumerate() { - let w = field(f, layout::SCISSOR + i as u32)?; - *s = widen(f, t, w)?; - } - let cull = field(f, layout::CULL)?; - let winding = field(f, layout::WINDING)?; - let clip_mode = field(f, layout::DEPTH_CLIP)?; - let clamp = opk(f, BinOp::IEqual, clip_mode, 1)?; - // The viewport's extent along each axis, snapped. - let mut measured = Vec::with_capacity(4); - let mut view = [[state; 2]; 2]; - for axis in 0..2 { - let (o, e) = (vp[axis], vp[axis + 2]); - let (a, ma) = snap(f, t, o)?; - let end = call2(f, p.r.add, o, e)?; - let (b, mb) = snap(f, t, end)?; - measured.push(ma); - measured.push(mb); - view[axis] = [smin(f, a, b)?, smax(f, a, b)?]; - } - let mut all = measured[0]; - for &m in &measured[1..] { - all = and(f, all, m)?; - } - let off = not(f, all)?; - flag_if(f, p.unmeasured, off)?; - let mut region = [state; 4]; - for (axis, extent) in [aw, ah].into_iter().enumerate() { - let limit = k32(f, AREA_LIMIT)?; - let big = op(f, BinOp::UGreaterThan, extent, limit)?; - let extent = sel(f, big, limit, extent)?; - let extent = widen(f, t, extent)?; - let extent = op64(f, t, BinOp::IMul, extent, UNIT)?; - let start = op64(f, t, BinOp::IMul, scissor[axis], UNIT)?; - let end = op(f, BinOp::IAdd, scissor[axis], scissor[axis + 2])?; - let end = op64(f, t, BinOp::IMul, end, UNIT)?; - let zero = k64(f, t, 0)?; - let lo = smax(f, view[axis][0], start)?; - let lo = smax(f, lo, zero)?; - let hi = smin(f, view[axis][1], end)?; - let hi = smin(f, hi, extent)?; - region[2 * axis] = lo; - region[2 * axis + 1] = hi; - } - let four = opk(f, BinOp::IEqual, samples, 4)?; - let (k16, k32_) = (k32(f, 16)?, k32(f, 32)?); - let th_px = sel(f, four, k16, k32_)?; - // The tile's sides in pixels and in units as powers of two. - let (k4, k5) = (k32(f, 4)?, k32(f, 5)?); - let th_log = sel(f, four, k4, k5)?; - let mut tiles = [state; 2]; - let mut shifts = [state; 2]; - for (axis, (extent, size, log)) in [(aw, k32_, k5), (ah, th_px, th_log)] - .into_iter() - .enumerate() - { - let limit = k32(f, AREA_LIMIT)?; - let big = op(f, BinOp::UGreaterThan, extent, limit)?; - let extent = sel(f, big, limit, extent)?; - let up = op(f, BinOp::IAdd, extent, size)?; - let up = opk(f, BinOp::ISub, up, 1)?; - let n = op(f, BinOp::ShiftRightLogical, up, log)?; - tiles[axis] = widen(f, t, n)?; - let units = opk(f, BinOp::IAdd, log, UNIT.trailing_zeros())?; - shifts[axis] = widen(f, t, units)?; - } - let tw = k64(f, t, 32 * UNIT)?; - let th = widen(f, t, th_px)?; - let th = op64(f, t, BinOp::IMul, th, UNIT)?; - let inside = op(f, BinOp::ULessThan, layer, layers)?; - let zero = k32(f, 0)?; - let slice = sel(f, inside, layer, zero)?; - let slice = widen(f, t, slice)?; - let first = op(f, BinOp::IMul, slice, tiles[1])?; - for (at, v) in [ - (ctx::RX0, region[0]), - (ctx::RX1, region[1]), - (ctx::RY0, region[2]), - (ctx::RY1, region[3]), - (ctx::TW, tw), - (ctx::TH, th), - (ctx::TILES_X, tiles[0]), - (ctx::TILES_Y, tiles[1]), - (ctx::BASE, first), - (ctx::SHIFT_X, shifts[0]), - (ctx::SHIFT_Y, shifts[1]), - ] { - let w = atk(f, p.context, at)?; - store(f, w, v)?; - } - Ok(K { - t, - r: p.r, - near_far: p.near_far, - unmeasured: p.unmeasured, - poly: p.poly, - scratch: p.scratch, - n: p.n, - pts: p.pts, - vp, - clamp, - cull, - winding, - samples, - }) -} diff --git a/crates/metal2vulkan/src/bind/tile_reach/tests.rs b/crates/metal2vulkan/src/bind/tile_reach/tests.rs deleted file mode 100644 index d11fa95ce..000000000 --- a/crates/metal2vulkan/src/bind/tile_reach/tests.rs +++ /dev/null @@ -1,381 +0,0 @@ -mod assembly; -mod device; -mod kernel; -mod measured; -mod points; -mod reference; - -use reference::{every_tile, reach, Cull, Flags, Primitive, Raster, Winding}; -use std::collections::BTreeSet; - -/// The probes' attachment side, in pixels. -const FRAME: u32 = 128; - -/// The clip-space vertex the probes drew at pixel `(x, y)` of the frame (y down) at depth 0.5. -fn clip(x: f64, y: f64) -> [f32; 4] { - clip_z(x, y, 0.5) -} - -/// The clip-space vertex at pixel `(x, y)` and depth `z`, as the probes made it: each -/// coordinate in `f64`, then rounded to `f32`. -fn clip_z(x: f64, y: f64, z: f64) -> [f32; 4] { - clip_in([FRAME; 2], x, y, z) -} - -/// The clip-space vertex at pixel `(x, y)` and depth `z` of a frame of `frame` pixels, as the -/// probes made it. -fn clip_in(frame: [u32; 2], x: f64, y: f64, z: f64) -> [f32; 4] { - let [w, h] = frame.map(f64::from); - [ - (2.0 * x / w - 1.0) as f32, - (1.0 - 2.0 * y / h) as f32, - z as f32, - 1.0, - ] -} - -/// The two triangles of the rectangle `[x0, x1] x [y0, y1]`, at depth 0.5. -fn quad(x0: f64, y0: f64, x1: f64, y1: f64) -> Vec<[f32; 4]> { - quad_z(x0, y0, x1, y1, 0.5) -} - -/// The two triangles of the rectangle `[x0, x1] x [y0, y1]` at depth `z`. -fn quad_z(x0: f64, y0: f64, x1: f64, y1: f64, z: f64) -> Vec<[f32; 4]> { - [(x0, y0), (x1, y0), (x0, y1), (x1, y0), (x1, y1), (x0, y1)] - .into_iter() - .map(|(x, y)| clip_z(x, y, z)) - .collect() -} - -/// The probes' triangle over the whole frame. -fn full() -> Vec<[f32; 4]> { - vec![ - clip(-128.0, -128.0), - clip(384.0, -128.0), - clip(-128.0, 384.0), - ] -} - -/// What a probe's draw assembled its vertices into. -#[derive(Clone, Copy, Debug, PartialEq, Eq)] -enum Topology { - /// A triangle list. - Triangles, - /// A line list. - Lines, - /// A point list. - Points, -} - -/// A probe's draw call. -#[derive(Clone, Copy, Debug, PartialEq, Eq)] -enum Draw { - /// Drawn directly. - Direct, - /// Drawn from an indirect buffer's arguments. - Indirect, - /// Drawn with no instances. - NoInstances, - /// By a pipeline that does not rasterize. - Unrasterized, - /// No draw call. - None, -} - -/// Another attachment of a probe's pass. -#[derive(Clone, Copy, Debug, PartialEq, Eq)] -enum Other { - /// None. - None, - /// A color attachment loaded `Clear` and stored. - ColorClearStore, - /// A color attachment loaded `Clear`, its store `DontCare`. - ColorClearDontCare, - /// A depth attachment loaded `Clear` and stored. - DepthClearStore, - /// A stencil attachment loaded `Clear` and stored. - StencilClearStore, -} - -/// A measured case: its pass and draw, and the tiles the M4 reached. -struct Row { - probe: &'static str, - name: &'static str, - topology: Topology, - vertices: Vec<[f32; 4]>, - size: f32, - raster: Raster, - draw: Draw, - other: Other, - slices: u32, - layer: u32, - reached: Vec, -} - -/// A case of `probe` drawing `drawn` over the whole frame. -fn row(probe: &'static str, name: &'static str, drawn: (Topology, Vec<[f32; 4]>)) -> Row { - Row { - probe, - name, - topology: drawn.0, - vertices: drawn.1, - size: 1.0, - raster: Raster::over([FRAME; 2]), - draw: Draw::Direct, - other: Other::None, - slices: 1, - layer: 0, - reached: Vec::new(), - } -} - -fn tris(v: Vec<[f32; 4]>) -> (Topology, Vec<[f32; 4]>) { - (Topology::Triangles, v) -} - -fn lines(v: Vec<[f32; 4]>) -> (Topology, Vec<[f32; 4]>) { - (Topology::Lines, v) -} - -fn points(v: Vec<[f32; 4]>) -> (Topology, Vec<[f32; 4]>) { - (Topology::Points, v) -} - -impl Row { - fn size(mut self, size: f64) -> Row { - self.size = size as f32; - self - } - - fn cull(mut self, cull: Cull) -> Row { - self.raster.cull = cull; - self - } - - fn scissor(mut self, scissor: [u32; 4]) -> Row { - self.raster.scissor = scissor; - self - } - - fn viewport(mut self, viewport: [f64; 4]) -> Row { - self.raster.viewport = viewport.map(|c| c as f32); - self - } - - fn clamp(mut self) -> Row { - self.raster.clamp = true; - self - } - - fn samples(mut self, samples: u32) -> Row { - self.raster.samples = samples; - self - } - - /// A render area (the descriptor's target size) of `side` over the frame: the default - /// viewport and scissor follow it. - fn area(mut self, side: u32) -> Row { - let samples = self.raster.samples; - self.raster = Raster::over([side; 2]); - self.raster.samples = samples; - self - } - - fn slices(mut self, slices: u32) -> Row { - self.slices = slices; - self - } - - fn layer(mut self, layer: u32) -> Row { - self.layer = layer; - self - } - - fn unrasterized(mut self) -> Row { - self.draw = Draw::Unrasterized; - self - } - - fn draw(mut self, draw: Draw) -> Row { - self.draw = draw; - self - } - - fn other(mut self, other: Other) -> Row { - self.other = other; - self - } - - /// A fragment function that discards: the reach does not follow it. - fn discards(self) -> Row { - self - } - - fn reaches(mut self, reached: &[&str]) -> Row { - self.reached = reached.iter().map(|s| s.to_string()).collect(); - self - } - - /// The primitives the draw assembled. - fn primitives(&self) -> Vec { - let v = &self.vertices; - match self.topology { - Topology::Triangles => v - .as_chunks::<3>() - .0 - .iter() - .map(|t| Primitive::Triangle([t[0], t[1], t[2]])) - .collect(), - Topology::Lines => v - .as_chunks::<2>() - .0 - .iter() - .map(|l| Primitive::Line([l[0], l[1]])) - .collect(), - Topology::Points => v.iter().map(|&p| Primitive::Point(p, self.size)).collect(), - } - } - - /// The tiles the rule reaches, slice by slice: every tile of each where another attachment - /// is cleared and stored in a pass with a draw call, else the tiles of the slice the draw - /// renders (a layer past the pass's renders its first) its primitives reach. - fn answer(&self) -> (Vec>, Flags) { - let mut flags = Flags::default(); - let called = self.draw != Draw::None; - let cleared = matches!( - self.other, - Other::ColorClearStore | Other::DepthClearStore | Other::StencilClearStore - ); - let drawn = matches!(self.draw, Draw::Direct | Draw::Indirect); - let slice = if self.layer < self.slices { - self.layer - } else { - 0 - }; - let slices = (0..self.slices) - .map(|s| { - if cleared && called { - return every_tile(&self.raster); - } - let mut tiles = BTreeSet::new(); - if drawn && s == slice { - for prim in self.primitives() { - tiles.extend(reach(&self.raster, &prim, &mut flags)); - } - } - tiles - }) - .collect(); - (slices, flags) - } - - /// The tiles the M4 reached, slice by slice. - fn measured(&self) -> Vec> { - self.reached - .iter() - .map(|slice| { - let mut tiles = BTreeSet::new(); - for (y, line) in slice.split(' ').enumerate() { - for (x, c) in line.chars().enumerate() { - if c == 'R' { - tiles.insert([x as u32, y as u32]); - } - } - } - tiles - }) - .collect() - } -} - -/// Every measured case reaches the tiles the M4 reached, and only the case across the near plane is -/// flagged (its reach that of the clipped polygon). -#[test] -fn the_rule_reaches_every_measured_answer() { - let mut rows = measured::rows(); - assert_eq!(rows.len(), 111, "the probes' cases"); - rows.extend(measured::later_rows()); - rows.extend(points::rows()); - let mut wrong = Vec::new(); - for row in &rows { - let (answer, flags) = row.answer(); - let near_far = row.name == "near_cross"; - let expected_flags = Flags { - near_far, - unmeasured: false, - }; - if answer != row.measured() || flags != expected_flags { - wrong.push(format!( - "{}/{}: reached {:?} ({flags:?}), measured {:?}", - row.probe, - row.name, - answer, - row.measured() - )); - } - } - assert!(wrong.is_empty(), "{}", wrong.join("\n")); -} - -/// Winding and the cull mode: a clockwise triangle (y down) faces front by default, and the -/// other winding turns it. -#[test] -fn the_cull_follows_the_winding() { - let t = Primitive::Triangle([clip(40.0, 40.0), clip(50.0, 40.0), clip(40.0, 50.0)]); - let mut raster = Raster::over([FRAME; 2]); - let reached = |raster: &Raster| !reach(raster, &t, &mut Flags::default()).is_empty(); - for (cull, winding, drawn) in [ - (Cull::Back, Winding::Clockwise, true), - (Cull::Front, Winding::Clockwise, false), - (Cull::Back, Winding::CounterClockwise, false), - (Cull::Front, Winding::CounterClockwise, true), - (Cull::None, Winding::CounterClockwise, true), - ] { - raster.cull = cull; - raster.winding = winding; - assert_eq!(reached(&raster), drawn, "{cull:?} {winding:?}"); - } -} - -/// A vertex past the coordinates measured, a line of no length, and a point past the depth range -/// are flagged unmeasured; a triangle across the far plane is flagged near-far. -#[test] -fn unmeasured_cases_are_flagged() { - let raster = Raster::over([FRAME; 2]); - let flags = |prim: Primitive| { - let mut flags = Flags::default(); - reach(&raster, &prim, &mut flags); - flags - }; - let unmeasured = Flags { - near_far: false, - unmeasured: true, - }; - assert_eq!( - flags(Primitive::Triangle([ - clip(-1e7, 40.0), - clip(1e7, 40.0), - clip(0.0, 1e7) - ])), - unmeasured - ); - assert_eq!( - flags(Primitive::Line([clip(40.0, 40.0), clip(40.0, 40.0)])), - unmeasured - ); - assert_eq!( - flags(Primitive::Point(clip_z(40.0, 40.0, 1.5), 1.0)), - unmeasured - ); - assert_eq!( - flags(Primitive::Triangle([ - clip(40.0, 40.0), - clip(40.0, 60.0), - clip_z(80.0, 50.0, 1.5) - ])), - Flags { - near_far: true, - unmeasured: false - } - ); -} diff --git a/crates/metal2vulkan/src/bind/tile_reach/tests/assembly.rs b/crates/metal2vulkan/src/bind/tile_reach/tests/assembly.rs deleted file mode 100644 index 474399eae..000000000 --- a/crates/metal2vulkan/src/bind/tile_reach/tests/assembly.rs +++ /dev/null @@ -1,77 +0,0 @@ -//! The capture assembly's two placeholders (`bind::capture_assembly`'s module docs) under the -//! rule and the kernel: the triangle of three `(0, 0, 0, 1)` vertices, which a restart writes, -//! reaches no tile and is flagged only where its state's viewport flags every primitive drawn -//! under it; the triangle of three NaN vertices, which an unknown parity writes, reaches no tile -//! and is counted unmeasured. - -use std::collections::BTreeMap; - -use super::kernel::{random_pass, Drawn, Pass, Rng}; -use super::reference::{reach, snap_clamped, Flags, Primitive, Raster}; -use super::{measured, points}; -use crate::bind::capture_assembly::{NOTHING, UNKNOWN}; -use crate::bind::tile_reach::kernel::typed_module; - -/// Under every measured case's state and the states of 64 seeded random passes (viewports, -/// scissors, culls, windings, depth clipped and clamped, 1, 2, 4 and other sample counts), the -/// rule reaches no tile with either placeholder and flags them as the module docs say, and the -/// kernel bins them as the rule does. -#[test] -fn the_capture_assembly_s_placeholders_reach_nothing() { - let nothing = Primitive::Triangle([NOTHING.map(f32::from_bits); 3]); - let unknown = Primitive::Triangle([UNKNOWN.map(f32::from_bits); 3]); - let mut rows = measured::rows(); - rows.extend(measured::later_rows()); - rows.extend(points::rows()); - let mut states: Vec = rows.iter().map(|r| r.raster).collect(); - let mut rng = Rng(0xa55e_b1e0); - let areas = [[128, 128], [96, 64], [33, 31], [1, 1], [16384, 200]]; - for _ in 0..64 { - let area = rng.pick(&areas); - let samples = rng.pick(&[1, 2, 4, 3]); - let pass = random_pass(&mut rng, area, samples, 1); - states.extend(pass.states.into_iter().map(|mut s| { - s.area = area; - s.samples = samples; - s - })); - } - let mut wrong = Vec::new(); - // The kernel's passes: one per render area and samples, both placeholders under each state. - let mut passes: BTreeMap<([u32; 2], u32), Pass> = BTreeMap::new(); - for state in &states { - let [ox, oy, w, h] = state.viewport; - let viewport = [ox, ox + w, oy, oy + h] - .into_iter() - .all(|c| snap_clamped(c).1); - for (prim, unmeasured) in [(nothing, !viewport), (unknown, true)] { - let mut flags = Flags::default(); - let tiles = reach(state, &prim, &mut flags); - let expected = Flags { - near_far: false, - unmeasured, - }; - if !tiles.is_empty() || flags != expected { - wrong.push(format!("{prim:?} under {state:?}: {tiles:?}, {flags:?}")); - } - } - let pass = passes - .entry((state.area, state.samples)) - .or_insert_with(|| Pass { - area: state.area, - samples: state.samples, - layers: 1, - states: Vec::new(), - drawn: Vec::new(), - }); - let at = pass.states.len() as u32; - pass.states.push(*state); - pass.drawn.push(Drawn::of(nothing, at, 0)); - pass.drawn.push(Drawn::of(unknown, at, 0)); - } - let m = typed_module().expect("module"); - for pass in passes.values() { - wrong.extend(pass.differences(&m)); - } - assert!(wrong.is_empty(), "{}", wrong.join("\n")); -} diff --git a/crates/metal2vulkan/src/bind/tile_reach/tests/device.rs b/crates/metal2vulkan/src/bind/tile_reach/tests/device.rs deleted file mode 100644 index d71d8d120..000000000 --- a/crates/metal2vulkan/src/bind/tile_reach/tests/device.rs +++ /dev/null @@ -1,159 +0,0 @@ -//! The kernel on a device: the fixture of passes and the rule's answers -//! (`validation/fixtures/public/tile_reach/device_passes.txt`) that the validation crate's lane -//! `runtime_lane::tile_reach_kernel` dispatches on the device its cfg selects and compares bit for -//! bit. The passes hold every measured case drawn (directly or indirectly), each case under a -//! state of its own and in a slice of its own, grouped by render area and samples, and seeded -//! random passes ([`random_pass`]). Here the committed fixture is checked to be the rule's -//! answers for them, and the kernel's through the interpreter. - -use std::collections::BTreeMap; -use std::fmt::Write as _; -use std::path::PathBuf; - -use super::kernel::{cull, random_pass, winding, Drawn, Pass, Rng}; -use super::{measured, points, Draw}; -use crate::bind::tile_reach::kernel::typed_module; -use crate::bind::tile_reach::TileReachModule as M; - -/// The fixture, from this crate's directory. -const FIXTURE: &str = "../metal2vulkan-validation/fixtures/public/tile_reach/device_passes.txt"; - -/// The command that prints the fixture between [`BEGIN`] and [`END`]. -const PRINT: &str = "cargo nextest run -p metal2vulkan --all-features --lib --run-ignored \ - ignored-only --no-capture -E 'test(/print_the_device_passes/)'"; - -const BEGIN: &str = "----- device_passes.txt begins -----"; -const END: &str = "----- device_passes.txt ends -----"; - -/// The random passes beside the measured cases. -const RANDOM_PASSES: usize = 16; - -/// The passes: the measured cases drawn, one pass per render area and samples (each case's -/// primitives in a slice of their own, under its state; slice 0 holds none), then -/// [`RANDOM_PASSES`] seeded random passes of 32 primitives. -fn device_passes() -> Vec { - let mut rows = measured::rows(); - rows.extend(measured::later_rows()); - rows.extend(points::rows()); - let mut groups: BTreeMap<([u32; 2], u32), Pass> = BTreeMap::new(); - for row in rows - .iter() - .filter(|r| matches!(r.draw, Draw::Direct | Draw::Indirect)) - { - let (area, samples) = (row.raster.area, row.raster.samples); - let pass = groups.entry((area, samples)).or_insert_with(|| Pass { - area, - samples, - layers: 1, - states: Vec::new(), - drawn: Vec::new(), - }); - let state = pass.states.len() as u32; - pass.states.push(row.raster); - let layer = pass.layers; - pass.layers += 1; - let drawn = row.primitives().into_iter(); - pass.drawn - .extend(drawn.map(|prim| Drawn::of(prim, state, layer))); - } - let mut passes: Vec = groups.into_values().collect(); - let mut rng = Rng(0xde71_ce5e); - let areas = [ - [128, 128], - [96, 64], - [200, 72], - [33, 31], - [256, 40], - [160, 96], - ]; - for _ in 0..RANDOM_PASSES { - let area = rng.pick(&areas); - let samples = rng.pick(&[1, 2, 4, 3]); - passes.push(random_pass(&mut rng, area, samples, 32)); - } - passes -} - -/// Little-endian bytes as words, in hex. -fn hex(bytes: &[u8]) -> String { - let words: Vec = bytes - .as_chunks::<4>() - .0 - .iter() - .map(|w| format!("{:08x}", u32::from_le_bytes(*w))) - .collect(); - words.join(" ") -} - -/// The fixture's text for `passes` (its header states the format). -fn fixture(passes: &[Pass]) -> String { - let mut out = String::new(); - out.push_str( - "# The tile reach kernel on a device: passes and the\n\ - # rule's answers, generated by bind::tile_reach::tests::device from the measured cases\n\ - # and seeded random passes. Our own synthetic data. Print it again with\n", - ); - let _ = writeln!(out, "# {PRINT}"); - out.push_str( - "# Per pass: `pass `; each state, `state` and its 12\n\ - # words (TileReachModule::state); each primitive, `primitive` and its 16 words\n\ - # (TileReachModule::primitive), words in hex; `expect `, the\n\ - # header's two counts; and the tile mask's set bits, `bits` and up to 16 indices a line.\n", - ); - for pass in passes { - let [w, h] = pass.area; - let _ = writeln!(out, "pass {w} {h} {} {}", pass.samples, pass.layers); - for s in &pass.states { - let words = M::state( - s.viewport, - s.scissor, - cull(s.cull), - winding(s.winding), - u32::from(s.clamp), - ); - let _ = writeln!(out, "state {}", hex(&words)); - } - for d in &pass.drawn { - let _ = writeln!(out, "primitive {}", hex(&d.record())); - } - let rule = pass.rule(); - let _ = writeln!(out, "expect {} {}", rule.near_far, rule.unmeasured); - let [gx, gy] = pass.grid(); - let mut bits = Vec::new(); - for (slice, tiles) in rule.slices.iter().enumerate() { - for [x, y] in tiles { - bits.push((slice as u32 * gy + y) * gx + x); - } - } - bits.sort_unstable(); - for line in bits.chunks(16) { - let line: Vec = line.iter().map(u32::to_string).collect(); - let _ = writeln!(out, "bits {}", line.join(" ")); - } - } - out -} - -/// The committed fixture is the rule's answers for the passes, and the kernel bins each pass as -/// the rule does through the interpreter (both invocation orders). -#[test] -fn the_device_passes_are_the_rules_answers_and_the_kernels() { - let passes = device_passes(); - let m = typed_module().expect("module"); - let wrong: Vec = passes.iter().flat_map(|p| p.differences(&m)).collect(); - assert!(wrong.is_empty(), "{}", wrong.join("\n")); - let path = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join(FIXTURE); - let committed = std::fs::read_to_string(&path).unwrap_or_default(); - assert!( - committed == fixture(&passes), - "{FIXTURE} is not the rule's answers: print it with\n {PRINT}\nand write the lines \ - between `{BEGIN}` and `{END}` to it" - ); -} - -/// Print the fixture between [`BEGIN`] and [`END`] (the module docs). -#[test] -#[ignore = "prints the device fixture"] -fn print_the_device_passes() { - println!("{BEGIN}\n{}{END}", fixture(&device_passes())); -} diff --git a/crates/metal2vulkan/src/bind/tile_reach/tests/kernel.rs b/crates/metal2vulkan/src/bind/tile_reach/tests/kernel.rs deleted file mode 100644 index 0ef77dfa8..000000000 --- a/crates/metal2vulkan/src/bind/tile_reach/tests/kernel.rs +++ /dev/null @@ -1,831 +0,0 @@ -//! The kernel against the reference function, through the CPU interpreter: built and valid -//! where a device has `shaderInt64` and refused where it does not; its arithmetic Rust's (the -//! division, the snap and a point's extent); and its mask and counts the rule's on every measured -//! case (the M4's tiles themselves where the case's answer is its primitives' reach) and on -//! seeded random passes. - -use std::collections::BTreeSet; -use std::path::PathBuf; - -use super::reference::{ - clip, point_extent, reach, snap_clamped, Cull, Flags, Primitive, Raster, Winding, - POINT_SIZE_LIMIT, -}; -use super::{clip_in, measured, points, Draw, Other, Row}; -use crate::bind::tile_reach::kernel::{ - arithmetic_module, clip_module, typed_module, ARITHMETIC_WORDS, CLIP_WORDS, PASS, POLYGON, - PRIMITIVES, TILES, -}; -use crate::bind::tile_reach::{tile_reach_module, TileReachModule as M}; -use crate::device::requirements::VkFeature; -use crate::device::{Device, DeviceDescription, DevicePolicy}; -use crate::error::{Capability, Error, Feature, Needs}; -use crate::pipeline::sym::ResourceSlot; -use crate::spirv::interp::{run, Buffer, Config, Order, Resources}; -use crate::spirv::ir::TypedModule; -use crate::spirv::testing::assert_valid; - -/// Every committed device (`validation/profiles/*.json`), derived with the default policy, by -/// file stem. -fn committed_devices() -> Vec<(String, Device)> { - let dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../metal2vulkan-validation/profiles"); - let mut out = Vec::new(); - for entry in std::fs::read_dir(&dir).expect("profiles") { - let path = entry.expect("entry").path(); - if path.extension().is_none_or(|x| x != "json") { - continue; - } - let stem = path - .file_stem() - .map(|s| s.to_string_lossy().into_owned()) - .unwrap_or_default(); - let text = std::fs::read_to_string(&path).expect("read"); - let desc = DeviceDescription::from_khronos_json(&text, None).expect("description"); - let device = Device::new(desc, DevicePolicy::default()).expect("device"); - out.push((stem, device)); - } - out.sort_by(|a, b| a.0.cmp(&b.0)); - out -} - -/// On every committed device the module is built, valid and within the profile where the device -/// has `shaderInt64`, and refused as `Feature::TileReach` needing it where it does not. -#[test] -fn the_module_is_valid_with_int64_and_refused_without() { - let (mut built, mut refused) = (0, 0); - for (name, device) in committed_devices() { - let profile = device.profile(); - let int64 = profile - .fields() - .enabled - .features - .contains(&VkFeature::ShaderInt64); - match tile_reach_module(&device) { - Ok(m) => { - assert!(int64, "{name}"); - assert!(!m.spirv.is_empty(), "{name}"); - assert!(profile.check(&m.requirements).is_ok(), "{name}"); - assert_valid(typed_module().expect("module"), profile); - built += 1; - } - Err(Error::Unsupported(u)) => { - assert!(!int64, "{name}"); - assert_eq!(u.feature, Feature::TileReach, "{name}"); - let needs = vec![vec![Capability::Feature(VkFeature::ShaderInt64)]]; - assert_eq!(u.needs, Needs::AnyOf(needs), "{name}"); - refused += 1; - } - Err(other) => panic!("{name}: {other}"), - } - } - assert!(built > 0 && refused > 0, "{built} built, {refused} refused"); -} - -/// A splitmix64 stream. -pub(super) struct Rng(pub(super) u64); - -impl Rng { - fn next(&mut self) -> u64 { - self.0 = self.0.wrapping_add(0x9e37_79b9_7f4a_7c15); - let mut z = self.0; - z = (z ^ (z >> 30)).wrapping_mul(0xbf58_476d_1ce4_e5b9); - z = (z ^ (z >> 27)).wrapping_mul(0x94d0_49bb_1331_11eb); - z ^ (z >> 31) - } - - fn word(&mut self) -> u32 { - self.next() as u32 - } - - /// A number in `[0, n)`. - fn below(&mut self, n: u64) -> u64 { - self.next() % n - } - - /// True `k` times in `n`. - fn chance(&mut self, k: u64, n: u64) -> bool { - self.below(n) < k - } - - pub(super) fn pick(&mut self, xs: &[X]) -> X { - xs[self.below(xs.len() as u64) as usize] - } - - /// A number in `[lo, hi)` on a grid of `1 / steps`. - fn grid(&mut self, lo: f64, hi: f64, steps: f64) -> f64 { - let n = ((hi - lo) * steps).max(1.0) as u64; - lo + self.below(n) as f64 / steps - } -} - -/// Bits the arithmetic meets at its edges: zeros, subnormals, normals' bounds, the snap's limit -/// and its whole-number threshold, infinities and a NaN. -const EDGE_BITS: [u32; 20] = [ - 0x0000_0000, - 0x8000_0000, - 0x0000_0001, - 0x8000_0001, - 0x0040_0000, - 0x007f_ffff, - 0x0080_0000, - 0x0080_0001, - 0x3f00_0000, - 0x3f80_0000, - 0xbf80_0000, - 0x3fc0_0000, - 0x4a00_0000, - 0x49ff_ffff, - 0x4e00_0000, - 0x4dff_ffff, - 0x7f7f_ffff, - 0x7f80_0000, - 0xff80_0000, - 0x7fc0_0000, -]; - -/// A point size in `[0, 511]` the extent's rounding meets: on its ties (an odd number of units, -/// an odd number of 1/32 pixels), beside them, or anywhere. -fn size_bits(rng: &mut Rng) -> u32 { - let size = match rng.below(5) { - 0 => (2 * rng.below(256 * 255) + 1) as f32 / 256.0, - 1 => (2 * rng.below(16 * 511) + 1) as f32 / 32.0, - 2 => { - let tie = (2 * rng.below(16 * 511) + 1) as f32 / 32.0; - let s = f32::from_bits(tie.to_bits().wrapping_add(rng.pick(&[1, u32::MAX]))); - s.clamp(0.0, POINT_SIZE_LIMIT) - } - 3 => f32::from_bits(rng.word() & 0x43ff_ffff).min(POINT_SIZE_LIMIT), - _ => rng.grid(0.0, 511.0, 4096.0) as f32, - }; - size.to_bits() -} - -/// The kernel's division, multiplication and addition give Rust's `/`, `*` and `+` (a NaN for a -/// NaN), and its snap and point extent the reference's, bit for bit, on edge operands (zeros, -/// subnormals, the largest finite values, infinities, a NaN) and on 6000 random ones (any bits; -/// near-equal exponents, where a sum cancels; coordinates on and beside the snap's ties). -#[test] -fn the_kernels_arithmetic_is_the_references() { - let mut rng = Rng(0x7ea1_0d71); - let mut records: Vec<[u32; 3]> = Vec::new(); - for x in EDGE_BITS { - for y in EDGE_BITS { - records.push([x, y, size_bits(&mut rng)]); - } - } - for _ in 0..6000 { - let x = match rng.below(4) { - 0 => rng.word(), - // A coordinate on a tie of the snap (k + 1/2 units), or one bit beside one. - 1 => { - let tie = (rng.below(1 << 22) as f64 * 2.0 + 1.0) / 512.0; - let tie = tie as f32 * rng.pick(&[1.0, -1.0]); - tie.to_bits().wrapping_add(rng.pick(&[0, 1, u32::MAX])) - } - // Exponents about the snap's thresholds. - 2 => ((rng.below(40) as u32 + 115) << 23) | (rng.word() & 0x807f_ffff), - _ => (rng.grid(-1e5, 1e5, 65536.0) as f32).to_bits(), - }; - let y = match rng.below(3) { - 0 => rng.word(), - 1 => (x & 0xff80_0000) ^ (rng.word() & 0x807f_ffff), - _ => (rng.grid(0.01, 16.0, 1024.0) as f32).to_bits(), - }; - records.push([x, y, size_bits(&mut rng)]); - } - let words = ARITHMETIC_WORDS as usize; - let mut bytes = Vec::with_capacity(records.len() * words * 4); - for r in &records { - for w in 0..words { - bytes.extend(r.get(w).copied().unwrap_or(0).to_le_bytes()); - } - } - let m = arithmetic_module().expect("module"); - let cfg = Config { - workgroups: [(records.len() as u32).div_ceil(M::LOCAL_SIZE), 1, 1], - step_limit: 1 << 40, - ..Config::default() - }; - let res = Resources { - buffers: vec![buffer(PRIMITIVES, bytes)], - push: Vec::new(), - spec: Default::default(), - }; - let out = run(&m, &cfg, res).expect("run").buffers.swap_remove(0); - let mut wrong = Vec::new(); - for (i, r) in records.iter().enumerate() { - let w = |k: usize| word(&out, i * words + k); - let (x, y, size) = ( - f32::from_bits(r[0]), - f32::from_bits(r[1]), - f32::from_bits(r[2]), - ); - for (what, at, want) in [("/", 3, x / y), ("*", 4, x * y), ("+", 5, x + y)] { - let got = f32::from_bits(w(at)); - if !(want.to_bits() == got.to_bits() || (want.is_nan() && got.is_nan())) { - wrong.push(format!( - "{x:e} {what} {y:e} ({:#x} {what} {:#x}): {got:e} ({:#x}), not {want:e} \ - ({:#x})", - r[0], - r[1], - w(at), - want.to_bits() - )); - } - } - let snapped = (i64::from(w(7)) << 32) | i64::from(w(6)); - let measured = w(8) == 1; - if (snapped, measured) != snap_clamped(x) { - let want = snap_clamped(x); - wrong.push(format!("snap {x:e}: {snapped} {measured}, not {want:?}")); - } - let extent = (i64::from(w(9)), i64::from(w(10))); - if extent != point_extent(size) { - let want = point_extent(size); - wrong.push(format!("point size {size:e}: {extent:?}, not {want:?}")); - } - } - assert!(wrong.is_empty(), "{}", wrong.join("\n")); -} - -/// The clipper holds the most vertices a polygon reaches ([`POLYGON`], 9): a hexagon whose -/// vertices lie by turns in front of the eye and behind it clips by the eye's plane to 9, which -/// only a polygon the clipper's rounding left not convex can be; and on seeded polygons of 2 to 6 -/// vertices, by each plane, the clipper's polygon is the reference's, bit for bit. -#[test] -fn the_clipper_holds_its_most_vertices() { - let planes: [fn(&[f32; 4]) -> f32; 3] = [|v| v[2], |v| v[3] - v[2], |v| v[3]]; - let hexagon: Vec<[f32; 4]> = (0..6) - .map(|j| { - let a = j as f32 * std::f32::consts::FRAC_PI_3; - [a.cos(), a.sin(), 0.5, if j % 2 == 0 { 1.0 } else { -0.5 }] - }) - .collect(); - assert_eq!(clip(&hexagon, planes[2]).len(), POLYGON as usize); - let mut cases = vec![(2, hexagon)]; - let mut rng = Rng(0xc11b_0009); - for _ in 0..600 { - let n = rng.pick(&[2, 3, 4, 5, 6]); - let plane = rng.below(3) as u32; - let polygon = (0..n) - .map(|_| [0; 4].map(|_| rng.grid(-2.0, 2.0, 64.0) as f32)) - .collect(); - cases.push((plane, polygon)); - } - let words = CLIP_WORDS as usize; - let mut bytes = Vec::with_capacity(cases.len() * words * 4); - for (plane, polygon) in &cases { - let mut record = vec![0u32; words]; - record[0] = *plane; - record[1] = polygon.len() as u32; - for (j, v) in polygon.iter().enumerate() { - for (c, x) in v.iter().enumerate() { - record[2 + 4 * j + c] = x.to_bits(); - } - } - bytes.extend(record.iter().flat_map(|w| w.to_le_bytes())); - } - let m = clip_module().expect("module"); - let cfg = Config { - workgroups: [(cases.len() as u32).div_ceil(M::LOCAL_SIZE), 1, 1], - step_limit: 1 << 40, - ..Config::default() - }; - let res = Resources { - buffers: vec![buffer(PRIMITIVES, bytes)], - push: Vec::new(), - spec: Default::default(), - }; - let out = run(&m, &cfg, res).expect("run").buffers.swap_remove(0); - let (mut wrong, mut most) = (Vec::new(), 0); - for (i, (plane, polygon)) in cases.iter().enumerate() { - let w = |k: usize| word(&out, i * words + k); - let want = clip(polygon, planes[*plane as usize]); - let got: Vec<[f32; 4]> = (0..w(1) as usize) - .map(|j| [0, 1, 2, 3].map(|c| f32::from_bits(w(2 + 4 * j + c)))) - .collect(); - let bits = - |p: &[[f32; 4]]| -> Vec { p.iter().flatten().map(|x| x.to_bits()).collect() }; - if bits(&got) != bits(&want) { - wrong.push(format!( - "plane {plane} of {polygon:?}: {got:?}, not {want:?}" - )); - } - most = most.max(got.len()); - } - assert!(wrong.is_empty(), "{}", wrong.join("\n")); - assert_eq!(most, POLYGON as usize); -} - -fn buffer(slot: ResourceSlot, bytes: Vec) -> Buffer { - Buffer { - slot: Some(slot), - address: None, - bytes, - } -} - -/// Word `i` of little-endian bytes. -fn word(bytes: &[u8], i: usize) -> u32 { - u32::from_le_bytes(bytes[4 * i..4 * i + 4].try_into().expect("a word")) -} - -/// One primitive of a pass: its reference form, the kind the kernel reads (its own, or one that -/// is none), the index of its state and its layer. -#[derive(Clone, Copy, Debug)] -pub(super) struct Drawn { - prim: Primitive, - kind: u32, - state: u32, - layer: u32, -} - -impl Drawn { - pub(super) fn of(prim: Primitive, state: u32, layer: u32) -> Drawn { - let kind = match prim { - Primitive::Point(..) => M::POINT, - Primitive::Line(_) => M::LINE, - Primitive::Triangle(_) => M::TRIANGLE, - }; - Drawn { - prim, - kind, - state, - layer, - } - } - - pub(super) fn record(&self) -> [u8; 64] { - let none = [0.0; 4]; - let (size, vertices) = match self.prim { - Primitive::Point(v, size) => (size, [v, none, none]), - Primitive::Line([a, b]) => (1.0, [a, b, none]), - Primitive::Triangle(t) => (1.0, t), - }; - M::primitive(self.kind, self.state, self.layer, size, vertices) - } -} - -/// A pass the kernel bins: its render area, samples and layers, the states its primitives were -/// drawn under (their area and samples the pass's), and its primitives. -#[derive(Clone, Debug)] -pub(super) struct Pass { - pub(super) area: [u32; 2], - pub(super) samples: u32, - pub(super) layers: u32, - pub(super) states: Vec, - pub(super) drawn: Vec, -} - -/// What a pass binned: the tiles `[x, y]` each slice reached, and the primitives counted near-far -/// and unmeasured. -#[derive(Debug, PartialEq, Eq)] -pub(super) struct Binned { - pub(super) slices: Vec>, - pub(super) near_far: u32, - pub(super) unmeasured: u32, -} - -pub(super) fn cull(c: Cull) -> u32 { - match c { - Cull::None => 0, - Cull::Front => 1, - Cull::Back => 2, - } -} - -pub(super) fn winding(w: Winding) -> u32 { - match w { - Winding::Clockwise => 0, - Winding::CounterClockwise => 1, - } -} - -impl Pass { - /// The tiles of a slice's row and column. - pub(super) fn grid(&self) -> [u32; 2] { - let th = if self.samples == 4 { 16 } else { 32 }; - [self.area[0].div_ceil(32), self.area[1].div_ceil(th)] - } - - /// The rule's answer: each primitive's reach by the reference function, into the slice it - /// renders (a layer past the pass's renders its first); a state past the pass's or a kind - /// that is none reach nothing, flagged unmeasured. - pub(super) fn rule(&self) -> Binned { - let mut out = Binned { - slices: vec![BTreeSet::new(); self.layers as usize], - near_far: 0, - unmeasured: 0, - }; - for d in &self.drawn { - let mut flags = Flags::default(); - match self.states.get(d.state as usize) { - Some(_) if d.kind > M::TRIANGLE => flags.unmeasured = true, - None => flags.unmeasured = true, - Some(state) => { - let mut raster = *state; - raster.area = self.area; - raster.samples = self.samples; - let tiles = reach(&raster, &d.prim, &mut flags); - let slice = if d.layer < self.layers { d.layer } else { 0 }; - out.slices[slice as usize].extend(tiles); - } - } - out.near_far += u32::from(flags.near_far); - out.unmeasured += u32::from(flags.unmeasured); - } - out - } - - /// The kernel's answer, through the interpreter in both invocation orders (alike). - fn kernel(&self, m: &TypedModule) -> Binned { - let prims: Vec = self.drawn.iter().flat_map(|d| d.record()).collect(); - let count = self.drawn.len() as u32; - let mut pass = M::header(self.area, self.samples, self.layers, count).to_vec(); - for s in &self.states { - pass.extend(M::state( - s.viewport, - s.scissor, - cull(s.cull), - winding(s.winding), - u32::from(s.clamp), - )); - } - let words = M::mask_words(self.area, self.samples, self.layers).max(1) as usize; - let mut outs = Vec::new(); - for order in [Order::Forward, Order::Reverse] { - let res = Resources { - buffers: vec![ - buffer(PRIMITIVES, prims.clone()), - buffer(PASS, pass.clone()), - buffer(TILES, vec![0; 4 * words]), - ], - push: Vec::new(), - spec: Default::default(), - }; - let cfg = Config { - order, - workgroups: [count.div_ceil(M::LOCAL_SIZE).max(1), 1, 1], - step_limit: 1 << 40, - ..Config::default() - }; - outs.push(run(m, &cfg, res).expect("run").buffers); - } - assert_eq!(outs[0], outs[1], "order independent"); - let buffers = &outs[0]; - let [gx, gy] = self.grid().map(|g| g as usize); - let mut slices = vec![BTreeSet::new(); self.layers as usize]; - for i in 0..words { - let w = word(&buffers[2], i); - for bit in (0..32).filter(|b| w >> b & 1 == 1) { - let tile = 32 * i + bit; - let (slice, at) = (tile / (gx * gy), tile % (gx * gy)); - assert!(slice < slices.len(), "a bit past the pass's tiles"); - slices[slice].insert([(at % gx) as u32, (at / gx) as u32]); - } - } - Binned { - slices, - near_far: word(&buffers[1], M::NEAR_FAR_WORD as usize), - unmeasured: word(&buffers[1], M::UNMEASURED_WORD as usize), - } - } - - /// Where the kernel and the rule differ: each primitive that differs alone, else the pass. - pub(super) fn differences(&self, m: &TypedModule) -> Vec { - if self.kernel(m) == self.rule() { - return Vec::new(); - } - let mut out = Vec::new(); - for d in &self.drawn { - let alone = Pass { - drawn: vec![*d], - ..self.clone() - }; - let (kernel, rule) = (alone.kernel(m), alone.rule()); - if kernel != rule { - let state = self.states.get(d.state as usize); - out.push(format!( - "{d:?} under {state:?} (area {:?}, {} samples): kernel {kernel:?}, rule {rule:?}", - self.area, self.samples - )); - } - } - if out.is_empty() { - out.push(format!("the pass {self:?} differs, no primitive alone")); - } - out - } -} - -/// The pass of a measured case: its draw's primitives, under its one state. -fn pass_of(row: &Row) -> Pass { - Pass { - area: row.raster.area, - samples: row.raster.samples, - layers: row.slices, - states: vec![row.raster], - drawn: row - .primitives() - .into_iter() - .map(|p| Drawn::of(p, 0, row.layer)) - .collect(), - } -} - -/// On every measured case drawn directly or indirectly, the kernel bins what the rule does, and, -/// where the case's answer is its primitives' reach (no attachment cleared and stored), the -/// tiles the M4 reached. -#[test] -fn the_kernel_reaches_every_measured_answer() { - let m = typed_module().expect("module"); - let mut rows = measured::rows(); - rows.extend(measured::later_rows()); - rows.extend(points::rows()); - let mut wrong = Vec::new(); - let mut checked = 0; - for row in rows - .iter() - .filter(|r| matches!(r.draw, Draw::Direct | Draw::Indirect)) - { - let pass = pass_of(row); - let kernel = pass.kernel(&m); - let rule = pass.rule(); - if kernel != rule { - wrong.push(format!( - "{}/{}: kernel {kernel:?}, rule {rule:?}", - row.probe, row.name - )); - } - if matches!(row.other, Other::None | Other::ColorClearDontCare) - && kernel.slices != row.measured() - { - wrong.push(format!( - "{}/{}: kernel {:?}, measured {:?}", - row.probe, - row.name, - kernel.slices, - row.measured() - )); - } - checked += 1; - } - assert!(wrong.is_empty(), "{}", wrong.join("\n")); - assert!(checked > 300, "{checked} cases"); -} - -/// A random state over a render area of `area`: Metal's defaults, or a viewport and a scissor of -/// its own (past the area too, the viewport flipped at times), any cull mode and winding, depth -/// clipped or clamped. -fn state(rng: &mut Rng, area: [u32; 2]) -> Raster { - let mut r = Raster::over(area); - let [w, h] = area.map(f64::from); - if rng.chance(1, 2) { - let ox = rng.grid(-w / 4.0, w, 512.0); - let oy = rng.grid(-h / 4.0, h, 512.0); - let vw = rng.grid(1.0, 1.5 * w + 1.0, 512.0); - let vh = rng.grid(1.0, 1.5 * h + 1.0, 512.0) * rng.pick(&[1.0, 1.0, 1.0, -1.0]); - r.viewport = [ox, oy, vw, vh].map(|c| c as f32); - } - if rng.chance(1, 2) { - let sx = rng.below(u64::from(area[0]) + 8) as u32; - let sy = rng.below(u64::from(area[1]) + 8) as u32; - let sw = rng.below(u64::from(area[0]) + 8) as u32; - let sh = rng.below(u64::from(area[1]) + 8) as u32; - r.scissor = [sx, sy, sw, sh]; - } - r.cull = rng.pick(&[Cull::None, Cull::Front, Cull::Back]); - r.winding = rng.pick(&[Winding::Clockwise, Winding::CounterClockwise]); - r.clamp = rng.chance(1, 3); - r -} - -/// A random pixel position about a render area of `area`: on or beside a tile's corner (within -/// 1/64 of a pixel, on 1/512 steps), anywhere about the area on 1/1024 steps, or far past it. -fn position(rng: &mut Rng, area: [u32; 2], tile: [u32; 2]) -> [f64; 2] { - let near = |rng: &mut Rng, extent: u32, size: u32| { - let k = rng.below(u64::from(extent / size) + 3) as f64 - 1.0; - k * f64::from(size) + (rng.below(17) as f64 - 8.0) / 512.0 - }; - let [w, h] = area.map(f64::from); - match rng.below(10) { - 0..=3 => [near(rng, area[0], tile[0]), near(rng, area[1], tile[1])], - 4..=8 => [ - rng.grid(-40.0, w + 40.0, 1024.0), - rng.grid(-40.0, h + 40.0, 1024.0), - ], - _ => [ - rng.grid(-2e5, 2e5, 4.0) * rng.pick(&[1.0, 1e-3]), - rng.grid(-2e5, 2e5, 4.0) * rng.pick(&[1.0, 1e-3]), - ], - } -} - -/// The clip-space vertex at pixel `p` of a frame of `area` and depth `z`, at `w` (its -/// coordinates scaled by it), each rounded to `f32`. -fn vertex(area: [u32; 2], p: [f64; 2], z: f64, w: f64) -> [f32; 4] { - let [x, y, _, _] = clip_in(area, p[0], p[1], z); - [ - (f64::from(x) * w) as f32, - (f64::from(y) * w) as f32, - (z * w) as f32, - w as f32, - ] -} - -/// A random depth and `w` for a primitive's vertices: within the depth range at `w = 1` mostly, -/// at times in perspective or across the near or far plane. -fn depth(rng: &mut Rng) -> (f64, f64) { - let z = match rng.chance(1, 5) { - true => rng.grid(-1.0, 2.0, 256.0), - false => rng.grid(0.0, 1.0, 256.0), - }; - let w = match rng.chance(1, 3) { - true => rng.pick(&[0.5, 2.0, 3.0, 0.3, 7.25, 1.0e3]) * rng.grid(0.5, 2.0, 64.0), - false => 1.0, - }; - (z, w) -} - -/// `v` with one component at times replaced by a value the rule flags: not finite, subnormal, -/// huge, or a `w` at or behind the eye. -fn spoiled(rng: &mut Rng, mut v: [f32; 4]) -> [f32; 4] { - if rng.chance(1, 30) { - let c = rng.below(4) as usize; - v[c] = rng.pick(&[ - f32::NAN, - f32::INFINITY, - f32::NEG_INFINITY, - 1.0e-40, - -1.0e-40, - 1.0e30, - -1.0e30, - 0.0, - -1.0, - ]); - } - v -} - -/// A random point size: fractional, on the extent's ties, zero, past the largest, or flagged -/// (negative, not a number, subnormal). -fn point_size(rng: &mut Rng) -> f32 { - match rng.below(8) { - 0 => rng.pick(&[0.0, 0.25, 1.0, 511.0, 511.5, 600.0, f32::INFINITY]), - 1 => rng.pick(&[f32::NAN, -1.0, 1.0e-40, -0.0]), - 2 => (2 * rng.below(2048) + 1) as f32 / 32.0, - 3 => (2 * rng.below(8192) + 1) as f32 / 256.0, - _ => rng.grid(0.0, 80.0, 512.0) as f32, - } -} - -/// A random primitive about a render area of `area`: a point, a line (at times of no length or -/// at 45 degrees), or a triangle (at times small, for the small-primitive cull). -fn primitive(rng: &mut Rng, area: [u32; 2], tile: [u32; 2]) -> Primitive { - let (z, w) = depth(rng); - let at = |rng: &mut Rng, p: [f64; 2]| { - let (dz, dw) = match rng.chance(1, 4) { - true => depth(rng), - false => (z, w), - }; - spoiled(rng, vertex(area, p, dz, dw)) - }; - let p = position(rng, area, tile); - match rng.below(10) { - 0..=2 => Primitive::Point(at(rng, p), point_size(rng)), - 3..=5 => { - let q = match rng.below(6) { - 0 => p, - 1 => { - let d = rng.grid(-40.0, 40.0, 256.0); - [p[0] + d, p[1] + d * rng.pick(&[1.0, -1.0])] - } - _ => position(rng, area, tile), - }; - Primitive::Line([at(rng, p), at(rng, q)]) - } - _ => { - let small = rng.chance(1, 2); - let near = |rng: &mut Rng| match small { - true => [ - p[0] + rng.grid(-4.0, 4.0, 64.0), - p[1] + rng.grid(-4.0, 4.0, 64.0), - ], - false => position(rng, area, tile), - }; - let (b, c) = (near(rng), near(rng)); - Primitive::Triangle([at(rng, p), at(rng, b), at(rng, c)]) - } - } -} - -/// A random pass of `area` and `samples`: a few states; each primitive in a slice of its own -/// (slice 0 holding those whose layer is past the pass's), a few under a state past the pass's -/// or of a kind that is none. -pub(super) fn random_pass(rng: &mut Rng, area: [u32; 2], samples: u32, count: u32) -> Pass { - let states: Vec = (0..1 + rng.below(3)).map(|_| state(rng, area)).collect(); - let tile = [32, if samples == 4 { 16 } else { 32 }]; - let layers = count + 1; - let drawn = (0..count) - .map(|i| { - let prim = primitive(rng, area, tile); - let state = match rng.chance(1, 40) { - true => states.len() as u32 + rng.below(3) as u32, - false => rng.below(states.len() as u64) as u32, - }; - let layer = match rng.chance(1, 20) { - true => layers + rng.below(4) as u32, - false => i + 1, - }; - let mut d = Drawn::of(prim, state, layer); - if rng.chance(1, 40) { - d.kind = rng.pick(&[3, 4, u32::MAX]); - } - d - }) - .collect(); - Pass { - area, - samples, - layers, - states, - drawn, - } -} - -/// On seeded random passes (render areas of a pixel to a few tiles, 1, 2 and 4 samples and -/// other counts, viewports, scissors, culls and windings, depth clipped and clamped; points, -/// lines and triangles about tile edges, in perspective, across the near and far planes, with -/// values the rule flags), the kernel bins what the rule does. -#[test] -fn the_kernel_bins_what_the_rule_does_on_random_passes() { - let m = typed_module().expect("module"); - let mut rng = Rng(0x0d67_1a2b); - let areas = [ - [128, 128], - [96, 64], - [200, 72], - [33, 31], - [256, 40], - [1, 1], - [64, 200], - [160, 96], - ]; - let mut wrong = Vec::new(); - for _ in 0..96 { - let area = rng.pick(&areas); - let samples = rng.pick(&[1, 1, 2, 4, 4, 3, 8]); - let pass = random_pass(&mut rng, area, samples, 32); - wrong.extend(pass.differences(&m)); - } - assert!(wrong.is_empty(), "{}", wrong.join("\n")); -} - -/// On the largest render areas (16384 pixels a side and others large), small primitives about -/// tile edges anywhere in the area, at every sample count, bin as the rule does. -#[test] -fn the_kernel_bins_what_the_rule_does_on_large_areas() { - let m = typed_module().expect("module"); - let mut rng = Rng(0x1a29_e5ee); - let mut wrong = Vec::new(); - for (area, samples) in [([16384, 16384], 1), ([16384, 9000], 4), ([12000, 16384], 2)] { - let tile = [32, if samples == 4 { 16 } else { 32 }]; - let states = vec![Raster::over(area), state(&mut rng, area)]; - let drawn = (0..6) - .map(|i| { - let [w, h] = area.map(f64::from); - let p = match rng.chance(1, 2) { - true => [ - (rng.below(u64::from(area[0] / tile[0])) * u64::from(tile[0])) as f64 - + (rng.below(17) as f64 - 8.0) / 512.0, - (rng.below(u64::from(area[1] / tile[1])) * u64::from(tile[1])) as f64 - + (rng.below(17) as f64 - 8.0) / 512.0, - ], - false => [rng.grid(0.0, w, 512.0), rng.grid(0.0, h, 512.0)], - }; - let near = |rng: &mut Rng| { - [ - p[0] + rng.grid(-24.0, 24.0, 256.0), - p[1] + rng.grid(-24.0, 24.0, 256.0), - ] - }; - let v = |q: [f64; 2]| vertex(area, q, 0.5, 1.0); - let prim = match i % 3 { - 0 => Primitive::Point(v(p), point_size(&mut rng).min(64.0)), - 1 => Primitive::Line([v(p), v(near(&mut rng))]), - _ => Primitive::Triangle([v(p), v(near(&mut rng)), v(near(&mut rng))]), - }; - Drawn::of(prim, (i % 2) as u32, i as u32) - }) - .collect(); - let pass = Pass { - area, - samples, - layers: 6, - states, - drawn, - }; - wrong.extend(pass.differences(&m)); - } - assert!(wrong.is_empty(), "{}", wrong.join("\n")); -} diff --git a/crates/metal2vulkan/src/bind/tile_reach/tests/measured.rs b/crates/metal2vulkan/src/bind/tile_reach/tests/measured.rs deleted file mode 100644 index 633d6c448..000000000 --- a/crates/metal2vulkan/src/bind/tile_reach/tests/measured.rs +++ /dev/null @@ -1,1115 +0,0 @@ -//! Every case our probes measured on an Apple M4 under macOS 27.0.1 (each in a process of its own; -//! the kit `share-reach` measured the same 111 answers on an Apple M3 Max under macOS 26.7), as the -//! probes drew it, and the tiles it reached: a `DontCare`-loaded, stored color attachment prefilled -//! with 0x11 bytes, whose reached tiles hold zero or the draw's red and whose others keep the bytes -//! (the module docs). Our own probes. - -use super::reference::Cull; -use super::{clip, clip_z, full, lines, points, quad, quad_z, row, tris, Draw, Other, Row}; - -/// The rows in the probes' order, each with the tiles (`R`) it reached of the 128 by 128 -/// attachment, row by row of tiles (32 by 16 at 4 samples), slice by slice. -pub(super) fn rows() -> Vec { - vec![ - row("reach1", "nodraw", tris(Vec::new())) - .draw(Draw::None) - .reaches(&[".... .... .... ...."]), - row("reach1", "full", tris(full())).reaches(&["RRRR RRRR RRRR RRRR"]), - row("reach1", "quad_t11", tris(quad(40.0, 40.0, 50.0, 50.0))) - .reaches(&[".... .R.. .... ...."]), - row( - "reach1", - "tiny_nocenter_t11", - tris(vec![clip(40.1, 40.1), clip(40.4, 40.1), clip(40.1, 40.4)]), - ) - .reaches(&[".... .... .... ...."]), - row( - "reach1", - "tiny_center_t11", - tris(vec![clip(40.3, 40.3), clip(40.8, 40.3), clip(40.3, 40.8)]), - ) - .reaches(&[".... .R.. .... ...."]), - row( - "reach1", - "corner_tri95", - tris(vec![clip(0.0, 0.0), clip(95.0, 0.0), clip(0.0, 95.0)]), - ) - .reaches(&["RRR. RR.. R... ...."]), - row( - "reach1", - "upper_right_half", - tris(vec![clip(0.0, 0.0), clip(128.0, 0.0), clip(128.0, 128.0)]), - ) - .reaches(&["RRRR .RRR ..RR ...R"]), - row( - "reach1", - "sliver_diag", - tris(vec![clip(2.0, 2.0), clip(126.0, 126.0), clip(3.2, 2.0)]), - ) - .reaches(&["RR.. .RR. ..RR ...R"]), - row( - "reach1", - "sliver_diag_nocenter", - tris(vec![clip(2.6, 2.6), clip(125.6, 125.6), clip(2.62, 2.58)]), - ) - .reaches(&["RR.. .RR. ..RR ...R"]), - row( - "reach1", - "straddle_nocenter", - tris(quad(31.6, 10.0, 32.4, 20.0)), - ) - .reaches(&[".... .... .... ...."]), - row( - "reach1", - "edge_exact_left", - tris(quad(20.0, 20.0, 32.0, 30.0)), - ) - .reaches(&["RR.. .... .... ...."]), - row( - "reach1", - "edge_near_right", - tris(quad(20.0, 20.0, 32.3, 30.0)), - ) - .reaches(&["RR.. .... .... ...."]), - row( - "reach1", - "edge_center_right", - tris(quad(20.0, 20.0, 32.6, 30.0)), - ) - .reaches(&["RR.. .... .... ...."]), - row( - "reach1", - "backface_culled_t11", - tris(vec![clip(40.0, 40.0), clip(40.0, 50.0), clip(50.0, 40.0)]), - ) - .cull(Cull::Back) - .reaches(&[".... .... .... ...."]), - row( - "reach1", - "frontface_t11", - tris(vec![clip(40.0, 40.0), clip(50.0, 40.0), clip(40.0, 50.0)]), - ) - .cull(Cull::Back) - .reaches(&[".... .R.. .... ...."]), - row( - "reach1", - "degenerate_row0", - tris(vec![clip(2.0, 10.0), clip(64.0, 10.0), clip(126.0, 10.0)]), - ) - .reaches(&[".... .... .... ...."]), - row("reach1", "discard_t11", tris(quad(40.0, 40.0, 50.0, 50.0))) - .discards() - .reaches(&[".... .R.. .... ...."]), - row("reach1", "scissor_t11", tris(full())) - .scissor([40, 40, 10, 10]) - .reaches(&[".... .R.. .... ...."]), - row( - "reach1", - "scissor_nocover", - tris(quad(2.0, 2.0, 10.0, 10.0)), - ) - .scissor([40, 40, 10, 10]) - .reaches(&[".... .... .... ...."]), - row("reach1", "viewport_t11", tris(full())) - .viewport([32.0, 32.0, 32.0, 32.0]) - .reaches(&[".... .R.. .... ...."]), - row( - "reach1", - "off_partial", - tris(vec![ - clip(100.0, 100.0), - clip(300.0, 100.0), - clip(100.0, 300.0), - ]), - ) - .reaches(&[".... .... .... ...R"]), - row( - "reach1", - "off_all", - tris(vec![ - clip(200.0, 200.0), - clip(300.0, 200.0), - clip(200.0, 300.0), - ]), - ) - .reaches(&[".... .... .... ...."]), - row( - "reach1", - "behind_near", - tris(vec![ - clip_z(40.0, 40.0, -0.5), - clip_z(50.0, 40.0, -0.5), - clip_z(40.0, 50.0, -0.5), - ]), - ) - .reaches(&[".... .... .... ...."]), - row("reach1", "point1_t11", points(vec![clip(40.5, 40.5)])) - .size(1.0) - .reaches(&[".... .R.. .... ...."]), - row("reach1", "point40_center", points(vec![clip(64.0, 64.0)])) - .size(40.0) - .reaches(&[".... .RR. .RR. ...."]), - row( - "reach1", - "line_row1", - lines(vec![clip(2.0, 40.5), clip(126.0, 40.5)]), - ) - .reaches(&[".... RRRR .... ...."]), - row( - "reach1", - "line_diag", - lines(vec![clip(2.0, 2.0), clip(126.0, 126.0)]), - ) - .reaches(&["RR.. RRR. .RRR ..RR"]), - // The small-primitive cull: a triangle whose box holds a pixel centre it does not cover. - row( - "reach2", - "box_centre_nocover_t11", - tris(vec![clip(40.0, 40.0), clip(40.95, 40.0), clip(40.0, 40.95)]), - ) - .reaches(&[".... .... .... ...."]), - row( - "reach2", - "box_centres_nocover_straddle", - tris(vec![clip(31.0, 40.0), clip(32.6, 40.0), clip(31.0, 40.6)]), - ) - .reaches(&[".... .... .... ...."]), - row( - "reach2", - "covers_one_centre_straddle", - tris(vec![clip(31.0, 40.0), clip(32.6, 40.0), clip(31.0, 41.2)]), - ) - .reaches(&[".... RR.. .... ...."]), - // Sub-pixel right edges below a tile boundary: x in [24, 32 - d], y in [8, 16]. - row( - "reach2", - "snapR_1_16", - tris(quad(24.0, 8.0, 32.0 - 1.0 / 16.0, 16.0)), - ) - .reaches(&["R... .... .... ...."]), - row( - "reach2", - "snapR_1_64", - tris(quad(24.0, 8.0, 32.0 - 1.0 / 64.0, 16.0)), - ) - .reaches(&["R... .... .... ...."]), - row( - "reach2", - "snapR_1_256", - tris(quad(24.0, 8.0, 32.0 - 1.0 / 256.0, 16.0)), - ) - .reaches(&["R... .... .... ...."]), - row( - "reach2", - "snapR_1_512", - tris(quad(24.0, 8.0, 32.0 - 1.0 / 512.0, 16.0)), - ) - .reaches(&["RR.. .... .... ...."]), - row( - "reach2", - "snapR_1_4096", - tris(quad(24.0, 8.0, 32.0 - 1.0 / 4096.0, 16.0)), - ) - .reaches(&["RR.. .... .... ...."]), - row("reach2", "edgeR_32", tris(quad(24.0, 8.0, 32.0, 16.0))) - .reaches(&["RR.. .... .... ...."]), - row("reach2", "edgeL_32", tris(quad(32.0, 8.0, 40.0, 16.0))) - .reaches(&[".R.. .... .... ...."]), - row( - "reach2", - "snapB_1_16", - tris(quad(8.0, 24.0, 16.0, 32.0 - 1.0 / 16.0)), - ) - .reaches(&["R... .... .... ...."]), - row( - "reach2", - "snapB_1_512", - tris(quad(8.0, 24.0, 16.0, 32.0 - 1.0 / 512.0)), - ) - .reaches(&["R... R... .... ...."]), - row("reach2", "edgeB_32", tris(quad(8.0, 24.0, 16.0, 32.0))) - .reaches(&["R... R... .... ...."]), - // Corner touches. - row( - "reach2", - "corner_tri96", - tris(vec![clip(0.0, 0.0), clip(96.0, 0.0), clip(0.0, 96.0)]), - ) - .reaches(&["RRRR RRR. RR.. R..."]), - row( - "reach2", - "corner_tri32", - tris(vec![clip(0.0, 0.0), clip(32.0, 0.0), clip(0.0, 32.0)]), - ) - .reaches(&["RR.. R... .... ...."]), - row( - "reach2", - "corner_tri64_from_t11", - tris(vec![clip(40.0, 40.0), clip(64.0, 40.0), clip(40.0, 64.0)]), - ) - .reaches(&[".... .RR. .R.. ...."]), - // Points (square of the point size around the centre). - row("reach2", "point1_straddle", points(vec![clip(31.75, 10.5)])) - .size(1.0) - .reaches(&["RR.. .... .... ...."]), - row("reach2", "point1_at32", points(vec![clip(32.0, 10.5)])) - .size(1.0) - .reaches(&["RR.. .... .... ...."]), - row("reach2", "point2_at33", points(vec![clip(33.0, 10.5)])) - .size(2.0) - .reaches(&[".R.. .... .... ...."]), - row( - "reach2", - "point_half_nocover", - points(vec![clip(40.0, 40.0)]), - ) - .size(0.5) - .reaches(&[".... .R.. .... ...."]), - row( - "reach2", - "point40_off_right", - points(vec![clip(130.0, 64.0)]), - ) - .size(40.0) - .reaches(&[".... ...R ...R ...."]), - // Lines. - row( - "reach2", - "line_y31_9", - lines(vec![clip(2.0, 31.9), clip(20.0, 31.9)]), - ) - .reaches(&["R... R... .... ...."]), - row( - "reach2", - "line_y32", - lines(vec![clip(2.0, 32.0), clip(20.0, 32.0)]), - ) - .reaches(&["R... R... .... ...."]), - row( - "reach2", - "line_y31_5", - lines(vec![clip(2.0, 31.5), clip(20.0, 31.5)]), - ) - .reaches(&["R... R... .... ...."]), - row( - "reach2", - "line_short_nocover", - lines(vec![clip(40.1, 40.1), clip(40.4, 40.1)]), - ) - .reaches(&[".... .R.. .... ...."]), - row( - "reach2", - "line_x_to_32", - lines(vec![clip(10.0, 10.5), clip(32.0, 10.5)]), - ) - .reaches(&["RR.. .... .... ...."]), - // Depth clipping. - row( - "reach2", - "far_clipped_t11", - tris(quad_z(40.0, 40.0, 50.0, 50.0, 1.5)), - ) - .reaches(&[".... .... .... ...."]), - row( - "reach2", - "far_clamped_t11", - tris(quad_z(40.0, 40.0, 50.0, 50.0, 1.5)), - ) - .clamp() - .reaches(&[".... .R.. .... ...."]), - // Indirect and empty instanced draws. - row("reach2", "indirect_t11", tris(quad(40.0, 40.0, 50.0, 50.0))) - .draw(Draw::Indirect) - .reaches(&[".... .R.. .... ...."]), - row( - "reach2", - "instances0_t11", - tris(quad(40.0, 40.0, 50.0, 50.0)), - ) - .draw(Draw::NoInstances) - .reaches(&[".... .... .... ...."]), - // Huge coordinates: an edge across the frame at y = 40 and at y = 32. - row( - "reach2", - "huge_edge_y40", - tris(vec![clip(-1e5, 40.0), clip(1e5, 40.0), clip(0.0, 1e5)]), - ) - .reaches(&[".... RRRR RRRR RRRR"]), - row( - "reach2", - "huge_edge_y32", - tris(vec![clip(-1e5, 32.0), clip(1e5, 32.0), clip(0.0, 1e5)]), - ) - .reaches(&[".... RRRR RRRR RRRR"]), - // Fractional and straddling viewports over a full-frame triangle. - row("reach2", "viewport_frac_t11", tris(full())) - .viewport([32.25, 32.25, 31.5, 31.5]) - .reaches(&[".... .R.. .... ...."]), - row("reach2", "viewport_cross", tris(full())) - .viewport([20.0, 20.0, 20.0, 20.0]) - .reaches(&["RR.. RR.. .... ...."]), - // Tile size for wider attachments: a quad over pixels 2 to 6. - row("reach2", "rgba8_t00", tris(quad(2.0, 2.0, 6.0, 6.0))) - .reaches(&["R... .... .... ...."]), - row("reach2", "rgba16f_t00", tris(quad(2.0, 2.0, 6.0, 6.0))) - .reaches(&["R... .... .... ...."]), - row("reach2", "rgba32f_t00", tris(quad(2.0, 2.0, 6.0, 6.0))) - .reaches(&["R... .... .... ...."]), - row("reach2", "rgba32f_x4_t00", tris(quad(2.0, 2.0, 6.0, 6.0))) - .reaches(&["R... .... .... ...."]), - row("reach2", "rgba16f_x8_t00", tris(quad(2.0, 2.0, 6.0, 6.0))) - .reaches(&["R... .... .... ...."]), - row("reach2", "rgba32f_x8_t00", tris(quad(2.0, 2.0, 6.0, 6.0))) - .reaches(&["R... .... .... ...."]), - // The fill rule: one pixel centre (40.5, 40.5) on one edge of a triangle covering no other. - row( - "reach3", - "fill_left_on_centre", - tris(vec![clip(40.5, 40.0), clip(40.9, 40.5), clip(40.5, 41.0)]), - ) - .reaches(&[".... .R.. .... ...."]), - row( - "reach3", - "fill_right_on_centre", - tris(vec![clip(40.5, 40.0), clip(40.5, 41.0), clip(40.1, 40.5)]), - ) - .reaches(&[".... .R.. .... ...."]), - row( - "reach3", - "fill_top_on_centre", - tris(vec![clip(40.0, 40.5), clip(41.0, 40.5), clip(40.5, 40.9)]), - ) - .reaches(&[".... .R.. .... ...."]), - row( - "reach3", - "fill_bottom_on_centre", - tris(vec![clip(40.0, 40.5), clip(40.5, 40.1), clip(41.0, 40.5)]), - ) - .reaches(&[".... .R.. .... ...."]), - row( - "reach3", - "fill_vertex_on_centre", - tris(vec![clip(40.5, 40.5), clip(40.9, 40.6), clip(40.6, 40.9)]), - ) - .reaches(&[".... .R.. .... ...."]), - // Line ends and widths (horizontal, at a pixel centre row). - row( - "reach3", - "line_end_31_6", - lines(vec![clip(10.0, 10.5), clip(31.6, 10.5)]), - ) - .reaches(&["RR.. .... .... ...."]), - row( - "reach3", - "line_end_31_9", - lines(vec![clip(10.0, 10.5), clip(31.9, 10.5)]), - ) - .reaches(&["RR.. .... .... ...."]), - row( - "reach3", - "line_y31_4", - lines(vec![clip(2.0, 31.4), clip(20.0, 31.4)]), - ) - .reaches(&["R... .... .... ...."]), - row( - "reach3", - "line_y31_45", - lines(vec![clip(2.0, 31.45), clip(20.0, 31.45)]), - ) - .reaches(&["R... .... .... ...."]), - row( - "reach3", - "line_steep_x31_6", - lines(vec![clip(31.6, 2.0), clip(31.6, 20.0)]), - ) - .reaches(&["RR.. .... .... ...."]), - row( - "reach3", - "line_shallow_cross", - lines(vec![clip(2.0, 31.0), clip(60.0, 33.0)]), - ) - .reaches(&["RR.. RR.. .... ...."]), - // Near-plane clipping: the unclipped triangle reaches tile (2,1), the clipped part (1,1) alone. - row( - "reach3", - "near_cross", - tris(vec![ - clip(40.0, 40.0), - clip(40.0, 60.0), - clip_z(80.0, 50.0, -0.5), - ]), - ) - .reaches(&[".... .R.. .... ...."]), - // The cull against the scissor: samples covered only outside the scissor, area inside it. - row( - "reach3", - "scissor_cull_order", - tris(vec![clip(2.0, 2.0), clip(4.0, 2.0), clip(52.2, 52.0)]), - ) - .scissor([50, 50, 4, 4]) - .reaches(&[".... .R.. .... ...."]), - row( - "reach3", - "scissor_cull_order_noscissor", - tris(vec![clip(2.0, 2.0), clip(4.0, 2.0), clip(52.2, 52.0)]), - ) - .reaches(&["RR.. .R.. .... ...."]), - // Multisampled tiles and sample positions. - row("reach3", "ms4_quad_t00", tris(quad(2.0, 2.0, 6.0, 6.0))) - .samples(4) - .reaches(&["R... .... .... .... .... .... .... ...."]), - row("reach3", "ms4_edge_y16", tris(quad(2.0, 8.0, 6.0, 16.0))) - .samples(4) - .reaches(&["R... R... .... .... .... .... .... ...."]), - row("reach3", "ms4_edge_y15_9", tris(quad(2.0, 8.0, 6.0, 15.9))) - .samples(4) - .reaches(&["R... .... .... .... .... .... .... ...."]), - row( - "reach3", - "ms4_tiny_sample_not_centre", - tris(vec![ - clip(40.3, 40.05), - clip(40.45, 40.05), - clip(40.3, 40.2), - ]), - ) - .samples(4) - .reaches(&[".... .... .R.. .... .... .... .... ...."]), - row( - "reach3", - "ms1_tiny_sample_not_centre", - tris(vec![ - clip(40.3, 40.05), - clip(40.45, 40.05), - clip(40.3, 40.2), - ]), - ) - .reaches(&[".... .... .... ...."]), - row("reach3", "ms2_quad_t00", tris(quad(2.0, 2.0, 6.0, 6.0))) - .samples(2) - .reaches(&["R... .... .... ...."]), - row("reach3", "ms2_edge_y16", tris(quad(2.0, 8.0, 6.0, 16.0))) - .samples(2) - .reaches(&["R... .... .... ...."]), - // Another attachment's clear. - row( - "reach3", - "clear_c1_store_quad_t11", - tris(quad(40.0, 40.0, 50.0, 50.0)), - ) - .other(Other::ColorClearStore) - .reaches(&["RRRR RRRR RRRR RRRR"]), - row( - "reach3", - "clear_c1_store_instances0", - tris(quad(40.0, 40.0, 50.0, 50.0)), - ) - .other(Other::ColorClearStore) - .draw(Draw::NoInstances) - .reaches(&["RRRR RRRR RRRR RRRR"]), - row( - "reach3", - "clear_c1_store_nodraw", - tris(quad(40.0, 40.0, 50.0, 50.0)), - ) - .other(Other::ColorClearStore) - .draw(Draw::None) - .reaches(&[".... .... .... ...."]), - row( - "reach3", - "clear_c1_dontcare_quad_t11", - tris(quad(40.0, 40.0, 50.0, 50.0)), - ) - .other(Other::ColorClearDontCare) - .reaches(&[".... .R.. .... ...."]), - row( - "reach3", - "clear_depth_store_quad_t11", - tris(quad(40.0, 40.0, 50.0, 50.0)), - ) - .other(Other::DepthClearStore) - .reaches(&["RRRR RRRR RRRR RRRR"]), - row( - "reach3", - "clear_stencil_store_quad_t11", - tris(quad(40.0, 40.0, 50.0, 50.0)), - ) - .other(Other::StencilClearStore) - .reaches(&["RRRR RRRR RRRR RRRR"]), - row( - "reach3", - "clear_depth_store_instances0", - tris(quad(40.0, 40.0, 50.0, 50.0)), - ) - .other(Other::DepthClearStore) - .draw(Draw::NoInstances) - .reaches(&["RRRR RRRR RRRR RRRR"]), - // Diagonal lines near a tile edge: a parallelogram of vertical extent 1 reaches y = 32 from - // a centre line starting at (40, 31.0); a rectangle of width 1 reaches only y = 31.71. - row( - "reach4", - "line45_from_40_31_0", - lines(vec![clip(40.0, 31.0), clip(60.0, 11.0)]), - ) - .reaches(&[".R.. .... .... ...."]), - row( - "reach4", - "line45_from_40_31_3", - lines(vec![clip(40.0, 31.3), clip(60.0, 11.3)]), - ) - .reaches(&[".R.. .... .... ...."]), - row( - "reach4", - "line45_from_40_30_8", - lines(vec![clip(40.0, 30.8), clip(60.0, 10.8)]), - ) - .reaches(&[".R.. .... .... ...."]), - row( - "reach4", - "line_shallow_end_31_0", - lines(vec![clip(10.0, 20.0), clip(31.0, 21.0)]), - ) - .reaches(&["R... .... .... ...."]), - row( - "reach4", - "line_shallow_end_31_4", - lines(vec![clip(10.0, 20.0), clip(31.4, 21.0)]), - ) - .reaches(&["R... .... .... ...."]), - // Degenerate (zero-area) triangles through pixel centres, and off them. - row( - "reach4", - "degenerate_on_centres", - tris(vec![clip(2.0, 10.5), clip(64.0, 10.5), clip(126.0, 10.5)]), - ) - .reaches(&[".... .... .... ...."]), - row( - "reach4", - "degenerate_vertical_on_centres", - tris(vec![clip(40.5, 2.0), clip(40.5, 64.0), clip(40.5, 126.0)]), - ) - .reaches(&[".... .... .... ...."]), - row( - "reach4", - "degenerate_point", - tris(vec![clip(40.5, 40.5), clip(40.5, 40.5), clip(40.5, 40.5)]), - ) - .reaches(&[".... .... .... ...."]), - // The sample cull against the viewport: samples covered only outside the viewport. - row( - "reach4", - "viewport_cull_order", - tris(vec![clip(2.0, 2.0), clip(4.0, 2.0), clip(52.2, 52.0)]), - ) - .viewport([48.0, 48.0, 16.0, 16.0]) - .reaches(&[".... .R.. .... ...."]), - // A render area of 40 over an attachment of 128: a full draw, and a quad past the area. - row("reach4", "area40_full", tris(full())) - .area(40) - .reaches(&["RR.. RR.. .... ...."]), - row( - "reach4", - "area40_quad_past", - tris(quad(60.0, 60.0, 70.0, 70.0)), - ) - .area(40) - .reaches(&["R... .... .... ...."]), - // Slices: a triangle in tile (1,1) rendered to slice 1 of 2. - row( - "reach4", - "layered_slice1_t11", - tris(quad(40.0, 40.0, 50.0, 50.0)), - ) - .slices(2) - .layer(1) - .reaches(&[".... .... .... ....", ".... .R.. .... ...."]), - row( - "reach4", - "layered_slice0_t11", - tris(quad(40.0, 40.0, 50.0, 50.0)), - ) - .slices(2) - .layer(0) - .reaches(&[".... .R.. .... ....", ".... .... .... ...."]), - // No rasterization, and points of size 0 and 0.25. - row( - "reach4", - "no_raster_t11", - tris(quad(40.0, 40.0, 50.0, 50.0)), - ) - .unrasterized() - .reaches(&[".... .... .... ...."]), - row("reach4", "point_size0_t11", points(vec![clip(40.5, 40.5)])) - .size(0.0) - .reaches(&[".... .R.. .... ...."]), - row( - "reach4", - "point_size0_25_straddle", - points(vec![clip(32.0, 40.5)]), - ) - .size(0.25) - .reaches(&[".... RR.. .... ...."]), - ] -} - -/// The triangle with a corner at `(cx + ex, cy + ey)` and legs `leg` along +x and +y (y down), as -/// our probe drew it. -fn corner(cx: f64, cy: f64, ex: f64, ey: f64, leg: f64) -> Vec<[f32; 4]> { - vec![ - clip(cx + ex, cy + ey), - clip(cx + ex + leg, cy + ey), - clip(cx + ex, cy + ey + leg), - ] -} - -/// The sliver from `(x, x + 0.25)` to `(x + l, x + l + 0.25)`, its third vertex `(x, x + 0.35)`: -/// in a band of `y - x` that holds no pixel centre. -fn sliver(x: f64, l: f64) -> Vec<[f32; 4]> { - vec![ - clip(x, x + 0.25), - clip(x + l, x + l + 0.25), - clip(x, x + 0.35), - ] -} - -/// The sliver from `(40, y0)` along `(w, h)`, of slope `p / q`, its third vertex `0.3 / q` below -/// its first, in a band of `y - (p / q) x` midway between the values pixel centres take. -fn band(w: f64, h: f64, p: f64, q: f64) -> Vec<[f32; 4]> { - let m = p / q; - let gap = 1.0 / q; - let t = 0.3 * gap; - let mid = 0.5 - p / (2.0 * q) + gap / 2.0; - let mut r = (40.0 * m + mid - t / 2.0 - 40.0) % gap; - if r < 0.0 { - r += gap; - } - let y0 = 40.0 + r; - vec![clip(40.0, y0), clip(40.0 + w, y0 + h), clip(40.0, y0 + t)] -} - -/// The diagonal sliver from `(40, 40 + b)` to `(40 + l, 40 + l + b)`, its third vertex 0.1 below -/// its first. -fn diag(l: f64, b: f64) -> Vec<[f32; 4]> { - vec![ - clip(40.0, 40.0 + b), - clip(40.0 + l, 40.0 + l + b), - clip(40.0, 40.0 + b + 0.1), - ] -} - -/// Our probes (an Apple M4 under macOS 27.0.1, each case in a process of its own, two rounds -/// alike): the small-primitive cull's precision (1/256), its space (the viewport's), what makes it -/// test a triangle's samples (a box of at most 12 pixel centres at 1 sample, 10 or 20 positions at -/// 2 or 4) and the default sample positions. Our own probes, built in their order and given the -/// answers of `REACH5` to `REACH9`. -pub(super) fn later_rows() -> Vec { - let mut drawn: Vec<(&'static str, Vec<[f32; 4]>, u32, Option<[f64; 4]>)> = Vec::new(); - let mut add = |probe: &'static str, v: Vec<[f32; 4]>, samples: u32, vp: Option<[f64; 4]>| { - drawn.push((probe, v, samples, vp)); - }; - for j in 1..=10 { - let e = 0.6 * 2f64.powi(-j); - add("reach5", corner(40.5, 40.5, e, e, 0.4), 1, None); - } - for j in [2, 4, 5, 8, 9] { - let e = 0.6 * 2f64.powi(-j); - add("reach5", corner(40.5, 40.5, e, 0.0, 0.4), 1, None); - add("reach5", corner(40.5, 40.5, 0.0, e, 0.4), 1, None); - } - add("reach5", corner(40.5, 40.5, -0.01, -0.01, 0.4), 1, None); - let quarter = vec![clip(2.4, 2.4), clip(3.6, 2.4), clip(2.4, 3.6)]; - add("reach5", quarter.clone(), 1, Some([32.0, 32.0, 32.0, 32.0])); - add("reach5", quarter, 1, None); - let shifted = vec![clip(40.1, 40.1), clip(40.4, 40.1), clip(40.1, 40.4)]; - add( - "reach5", - shifted.clone(), - 1, - Some([0.25, 0.25, 128.0, 128.0]), - ); - add("reach5", shifted, 1, None); - let half = vec![clip(40.3, 40.3), clip(40.8, 40.3), clip(40.3, 40.8)]; - add("reach5", half, 1, Some([0.0, 0.0, 64.0, 64.0])); - let positions: [(u32, &[(f64, f64)]); 2] = [ - (2, &[(0.75, 0.75), (0.25, 0.25)]), - ( - 4, - &[ - (0.375, 0.125), - (0.875, 0.375), - (0.125, 0.625), - (0.625, 0.875), - ], - ), - ]; - for (n, at) in positions { - for &(px, py) in at { - let v = corner(40.0 + px - 0.03, 40.0 + py - 0.03, 0.0, 0.0, 0.1); - add("reach5", v.clone(), n, None); - if n == 4 { - add("reach5", v, 1, None); - } - } - } - add("reach5", corner(40.47, 40.47, 0.0, 0.0, 0.1), 4, None); - add("reach5", corner(40.22, 40.22, 0.0, 0.0, 0.1), 4, None); - let lengths = [ - 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 5.0, 6.0, 7.0, 8.0, 10.0, 12.0, 16.0, 24.0, 32.0, - 48.0, 64.0, 80.0, - ]; - for l in lengths { - add("reach6", sliver(40.0, l), 1, None); - } - for l in [1.5, 2.0, 3.0, 4.0, 6.0] { - add("reach6", sliver(41.0, l), 1, None); - add("reach6", sliver(33.0, l), 1, None); - } - for l in [2.0, 4.0, 8.0] { - let s = sliver(40.0, l); - add("reach6", vec![s[0], s[2], s[1]], 1, None); - } - let diagonals = [ - (40.6, 3.2), - (40.5, 3.0), - (40.4, 3.0), - (40.0, 3.1), - (40.0, 3.2), - (40.0, 3.3), - (40.0, 3.4), - (40.0, 3.49), - (40.0, 3.0), - (40.0, 3.5), - ]; - for (x, l) in diagonals { - add("reach7", sliver(x, l), 1, None); - } - for l in [1.0, 1.4, 1.5, 1.6, 1.75, 2.0, 3.0] { - let steep = vec![ - clip(40.0, 80.1), - clip(40.0 + l, 80.1 + 2.0 * l), - clip(40.0, 80.3), - ]; - let shallow = vec![ - clip(40.0, 20.35), - clip(40.0 + 2.0 * l, 20.35 + l), - clip(40.0, 20.65), - ]; - add("reach7", steep, 1, None); - add("reach7", shallow, 1, None); - } - let boxes = [ - (8.0, 1.0, 1.0, 8.0), - (1.0, 8.0, 8.0, 1.0), - (6.0, 1.2, 1.0, 5.0), - (5.0, 1.5, 3.0, 10.0), - (4.5, 2.7, 3.0, 5.0), - (2.0, 5.2, 13.0, 5.0), - (2.0, 4.6, 23.0, 10.0), - (1.8, 4.5, 5.0, 2.0), - (3.4, 3.4, 1.0, 1.0), - (3.6, 3.6, 1.0, 1.0), - ]; - for (w, h, p, q) in boxes { - add("reach8", band(w, h, p, q), 1, None); - } - let counted = [ - (1.3, 9.0, 1.0), - (1.8, 3.0, 1.0), - (3.2, 1.0, 1.0), - (4.3, 1.0, 2.0), - (5.6, 1.0, 3.0), - (11.6, 1.0, 9.0), - (1.4, 9.0, 1.0), - (12.6, 1.0, 9.0), - (2.1, 3.0, 1.0), - (6.6, 1.0, 3.0), - (1.4, 10.0, 1.0), - (13.6, 1.0, 10.0), - (2.6, 2.0, 1.0), - (4.6, 1.0, 2.0), - (1.3, 11.0, 1.0), - (2.4, 3.0, 1.0), - (7.6, 1.0, 4.0), - (1.4, 11.0, 1.0), - ]; - for (w, p, q) in counted { - add("reach9", band(w, w * (p / q), p, q), 1, None); - } - for l in [1.0, 1.25, 1.5, 1.75, 2.0, 2.25, 2.5, 3.0, 3.5, 4.0] { - add("reach9", diag(l, 0.05), 4, None); - } - for l in [1.5, 2.0, 2.5, 3.0, 3.5, 4.0] { - add("reach9", diag(l, 0.25), 2, None); - } - for &(samples, x0, y0, w, h, t) in SLIVERS10 { - let v = vec![clip(x0, y0), clip(x0 + w, y0 + h), clip(x0, y0 + t)]; - add("reach10", v, samples, None); - } - let answers: Vec<&(&str, &str)> = [REACH5, REACH6, REACH7, REACH8, REACH9, REACH10] - .iter() - .flat_map(|a| a.iter()) - .collect(); - assert_eq!(drawn.len(), answers.len(), "the later probes' cases"); - drawn - .into_iter() - .zip(answers) - .map(|((probe, v, samples, vp), &(name, tiles))| { - let mut r = row(probe, name, tris(v)).samples(samples); - if let Some(vp) = vp { - r = r.viewport(vp); - } - r.reaches(&[tiles]) - }) - .collect() -} - -/// Our probe's answers, in the probe's order. -const REACH5: &[(&str, &str)] = &[ - ("cull_xy_e1", ".... .... .... ...."), - ("cull_xy_e2", ".... .... .... ...."), - ("cull_xy_e3", ".... .... .... ...."), - ("cull_xy_e4", ".... .... .... ...."), - ("cull_xy_e5", ".... .... .... ...."), - ("cull_xy_e6", ".... .... .... ...."), - ("cull_xy_e7", ".... .... .... ...."), - ("cull_xy_e8", ".... .... .... ...."), - ("cull_xy_e9", ".... .R.. .... ...."), - ("cull_xy_e10", ".... .R.. .... ...."), - ("cull_x_e2", ".... .... .... ...."), - ("cull_y_e2", ".... .... .... ...."), - ("cull_x_e4", ".... .... .... ...."), - ("cull_y_e4", ".... .... .... ...."), - ("cull_x_e5", ".... .... .... ...."), - ("cull_y_e5", ".... .... .... ...."), - ("cull_x_e8", ".... .... .... ...."), - ("cull_y_e8", ".... .... .... ...."), - ("cull_x_e9", ".... .R.. .... ...."), - ("cull_y_e9", ".... .R.. .... ...."), - ("cull_before", ".... .R.. .... ...."), - ("vp_quarter_frame_covers", ".... .... .... ...."), - ("vp_quarter_frame_covers_control", "R... .... .... ...."), - ("vp_shift_viewport_covers", ".... .R.. .... ...."), - ("vp_shift_control", ".... .... .... ...."), - ("vp_half_frame_covers", ".... .... .... ...."), - ("ms2_pos0", ".... .R.. .... ...."), - ("ms2_pos1", ".... .R.. .... ...."), - ("ms4_pos0", ".... .... .R.. .... .... .... .... ...."), - ("ms1_pos4_0", ".... .... .... ...."), - ("ms4_pos1", ".... .... .R.. .... .... .... .... ...."), - ("ms1_pos4_1", ".... .... .... ...."), - ("ms4_pos2", ".... .... .R.. .... .... .... .... ...."), - ("ms1_pos4_2", ".... .... .... ...."), - ("ms4_pos3", ".... .... .R.. .... .... .... .... ...."), - ("ms1_pos4_3", ".... .... .... ...."), - ("ms4_centre", ".... .... .... .... .... .... .... ...."), - ("ms4_quarter", ".... .... .... .... .... .... .... ...."), -]; -/// Our probe's answers, in the probe's order. -const REACH6: &[(&str, &str)] = &[ - ("sliver_40_L0.5", ".... .... .... ...."), - ("sliver_40_L1.0", ".... .... .... ...."), - ("sliver_40_L1.5", ".... .... .... ...."), - ("sliver_40_L2.0", ".... .... .... ...."), - ("sliver_40_L2.5", ".... .... .... ...."), - ("sliver_40_L3.0", ".... .... .... ...."), - ("sliver_40_L3.5", ".... .R.. .... ...."), - ("sliver_40_L4.0", ".... .R.. .... ...."), - ("sliver_40_L5.0", ".... .R.. .... ...."), - ("sliver_40_L6.0", ".... .R.. .... ...."), - ("sliver_40_L7.0", ".... .R.. .... ...."), - ("sliver_40_L8.0", ".... .R.. .... ...."), - ("sliver_40_L10.0", ".... .R.. .... ...."), - ("sliver_40_L12.0", ".... .R.. .... ...."), - ("sliver_40_L16.0", ".... .R.. .... ...."), - ("sliver_40_L24.0", ".... .R.. .RR. ...."), - ("sliver_40_L32.0", ".... .R.. .RR. ...."), - ("sliver_40_L48.0", ".... .R.. .RR. ...."), - ("sliver_40_L64.0", ".... .R.. .RR. ..RR"), - ("sliver_40_L80.0", ".... .R.. .RR. ..RR"), - ("sliver_41_L1.5", ".... .... .... ...."), - ("sliver_33_L1.5", ".... .... .... ...."), - ("sliver_41_L2.0", ".... .... .... ...."), - ("sliver_33_L2.0", ".... .... .... ...."), - ("sliver_41_L3.0", ".... .... .... ...."), - ("sliver_33_L3.0", ".... .... .... ...."), - ("sliver_41_L4.0", ".... .R.. .... ...."), - ("sliver_33_L4.0", ".... .R.. .... ...."), - ("sliver_41_L6.0", ".... .R.. .... ...."), - ("sliver_33_L6.0", ".... .R.. .... ...."), - ("sliver_40_L2.0_ccw", ".... .... .... ...."), - ("sliver_40_L4.0_ccw", ".... .R.. .... ...."), - ("sliver_40_L8.0_ccw", ".... .R.. .... ...."), -]; -/// Our probe's answers, in the probe's order. -const REACH7: &[(&str, &str)] = &[ - ("diag_40.6_L3.2", ".... .... .... ...."), - ("diag_40.5_L3.0", ".... .... .... ...."), - ("diag_40.4_L3.0", ".... .... .... ...."), - ("diag_40.0_L3.1", ".... .... .... ...."), - ("diag_40.0_L3.2", ".... .... .... ...."), - ("diag_40.0_L3.3", ".... .... .... ...."), - ("diag_40.0_L3.4", ".... .... .... ...."), - ("diag_40.0_L3.49", ".... .... .... ...."), - ("diag_40.0_L3.0", ".... .... .... ...."), - ("diag_40.0_L3.5", ".... .R.. .... ...."), - ("steep_L1.0", ".... .... .... ...."), - ("shallow_L1.0", ".... .... .... ...."), - ("steep_L1.4", ".... .... .... ...."), - ("shallow_L1.4", ".... .... .... ...."), - ("steep_L1.5", ".... .... .... ...."), - ("shallow_L1.5", ".... .... .... ...."), - ("steep_L1.6", ".... .... .... ...."), - ("shallow_L1.6", ".... .... .... ...."), - ("steep_L1.75", ".... .... .... ...."), - ("shallow_L1.75", ".... .... .... ...."), - ("steep_L2.0", ".... .... .... ...."), - ("shallow_L2.0", ".... .... .... ...."), - ("steep_L3.0", ".... .... .R.. ...."), - ("shallow_L3.0", ".R.. .... .... ...."), -]; -/// Our probe's answers, in the probe's order. -const REACH8: &[(&str, &str)] = &[ - ("band_8.0x1.0", ".... .... .... ...."), - ("band_1.0x8.0", ".... .... .... ...."), - ("band_6.0x1.2", ".... .... .... ...."), - ("band_5.0x1.5", ".... .... .... ...."), - ("band_4.5x2.7", ".... .R.. .... ...."), - ("band_2.0x5.2", ".... .... .... ...."), - ("band_2.0x4.6", ".... .... .... ...."), - ("band_1.8x4.5", ".... .... .... ...."), - ("band_3.4x3.4", ".... .... .... ...."), - ("band_3.6x3.6", ".... .R.. .... ...."), -]; -/// Our probe's answers, in the probe's order. -const REACH9: &[(&str, &str)] = &[ - ("n12_w1.3_m9_1", ".... .... .... ...."), - ("n12_w1.8_m3_1", ".... .... .... ...."), - ("n12_w3.2_m1_1", ".... .... .... ...."), - ("n12_w4.3_m1_2", ".... .... .... ...."), - ("n12_w5.6_m1_3", ".... .... .... ...."), - ("n12_w11.6_m1_9", ".... .... .... ...."), - ("n13_w1.4_m9_1", ".... .R.. .... ...."), - ("n13_w12.6_m1_9", ".... .R.. .... ...."), - ("n14_w2.1_m3_1", ".... .R.. .... ...."), - ("n14_w6.6_m1_3", ".... .R.. .... ...."), - ("n14_w1.4_m10_1", ".... .R.. .... ...."), - ("n14_w13.6_m1_10", ".... .R.. .... ...."), - ("n15_w2.6_m2_1", ".... .R.. .... ...."), - ("n15_w4.6_m1_2", ".... .R.. .... ...."), - ("n15_w1.3_m11_1", ".... .R.. .... ...."), - ("n16_w2.4_m3_1", ".... .R.. .... ...."), - ("n16_w7.6_m1_4", ".... .R.. .... ...."), - ("n16_w1.4_m11_1", ".... .R.. .... ...."), - ("ms4_diag_L1.0", ".... .... .... .... .... .... .... ...."), - ("ms4_diag_L1.25", ".... .... .... .... .... .... .... ...."), - ("ms4_diag_L1.5", ".... .... .... .... .... .... .... ...."), - ("ms4_diag_L1.75", ".... .... .... .... .... .... .... ...."), - ("ms4_diag_L2.0", ".... .... .... .... .... .... .... ...."), - ("ms4_diag_L2.25", ".... .... .... .... .... .... .... ...."), - ("ms4_diag_L2.5", ".... .... .R.. .... .... .... .... ...."), - ("ms4_diag_L3.0", ".... .... .R.. .... .... .... .... ...."), - ("ms4_diag_L3.5", ".... .... .R.. .... .... .... .... ...."), - ("ms4_diag_L4.0", ".... .... .R.. .... .... .... .... ...."), - ("ms2_diag_L1.5", ".... .... .... ...."), - ("ms2_diag_L2.0", ".... .... .... ...."), - ("ms2_diag_L2.5", ".... .R.. .... ...."), - ("ms2_diag_L3.0", ".... .R.. .... ...."), - ("ms2_diag_L3.5", ".... .R.. .... ...."), - ("ms2_diag_L4.0", ".... .R.. .... ...."), -]; - -/// Our probe's slivers, in the probe's order: at `samples` samples, the triangle -/// `(x0, y0)`, `(x0 + w, y0 + h)`, `(x0, y0 + t)` (pixels, y down), holding no sample position, -/// its closed box holding 11 to 14 positions at 2 samples and 21 to 24 at 4, in several slopes. -const SLIVERS10: &[(u32, f64, f64, f64, f64, f64)] = &[ - (2, 40.4375, 40.3, 1.75, 3.5, 0.15), - (2, 40.3125, 40.36875, 3.46875, 1.734375, 0.075), - (2, 40.0, 40.849999999999994, 1.28125, 3.84375, 0.3), - (2, 40.8125, 40.22083333366666, 3.46875, 1.15625, 0.1), - (2, 40.0, 40.35, 2.421875, 2.421875, 0.3), - (2, 40.1875, 40.8, 1.59375, 3.1875, 0.15), - (2, 40.0, 40.2125, 3.125, 1.5625, 0.075), - (2, 40.0, 40.849999999999994, 1.3125, 3.9375, 0.3), - ( - 2, - 40.1875, - 40.01250000033333, - 3.78125, - 1.2604166666666665, - 0.1, - ), - (2, 40.3125, 40.6625, 2.46875, 2.46875, 0.3), - (2, 40.1875, 40.412499999999994, 1.453125, 4.359375, 0.3), - (2, 40.0, 40.28333333366667, 4.46875, 1.4895833333333333, 0.1), - (2, 40.0, 40.425, 1.78125, 3.5625, 0.15), - (2, 40.0, 40.2125, 3.28125, 1.640625, 0.075), - (2, 40.0, 40.849999999999994, 1.484375, 4.453125, 0.3), - ( - 2, - 40.1875, - 40.01250000033333, - 4.09375, - 1.3645833333333333, - 0.1, - ), - (4, 40.6875, 40.4875, 1.390625, 4.171875, 0.15), - ( - 4, - 40.0625, - 40.162499999783336, - 4.09375, - 1.3645833333333333, - 0.0500000001, - ), - (4, 40.25, 40.175, 2.40625, 2.40625, 0.15), - (4, 40.3125, 40.5125, 1.59375, 3.1875, 0.22499999999999998), - (4, 40.1875, 40.2875, 3.21875, 1.609375, 0.11249999999999999), - (4, 40.1875, 40.9875, 1.390625, 4.171875, 0.15), - (4, 40.0, 40.925, 2.40625, 2.40625, 0.15), - (4, 40.0625, 40.0125, 1.59375, 3.1875, 0.22499999999999998), - (4, 40.6875, 40.0375, 3.21875, 1.609375, 0.11249999999999999), - (4, 40.25, 40.175, 2.484375, 2.484375, 0.15), - (4, 40.0625, 40.0125, 1.703125, 3.40625, 0.22499999999999998), - (4, 40.0, 40.19375, 3.40625, 1.703125, 0.11249999999999999), - ( - 4, - 40.4375, - 40.287499999783336, - 4.078125, - 1.359375, - 0.0500000001, - ), -]; - -/// Our probe's answers, in the probe's order. -const REACH10: &[(&str, &str)] = &[ - ("ms2_c11_m2_1", ".... .... .... ...."), - ("ms2_c11_m1_2", ".... .... .... ...."), - ("ms2_c11_m3_1", ".... .... .... ...."), - ("ms2_c11_m1_3", ".... .... .... ...."), - ("ms2_c12_m1_1", ".... .... .... ...."), - ("ms2_c12_m2_1", ".... .... .... ...."), - ("ms2_c12_m1_2", ".... .... .... ...."), - ("ms2_c12_m3_1", ".... .... .... ...."), - ("ms2_c12_m1_3", ".... .... .... ...."), - ("ms2_c13_m1_1", ".... .R.. .... ...."), - ("ms2_c13_m3_1", ".... .R.. .... ...."), - ("ms2_c13_m1_3", ".... .R.. .... ...."), - ("ms2_c14_m2_1", ".... .R.. .... ...."), - ("ms2_c14_m1_2", ".... .R.. .... ...."), - ("ms2_c14_m3_1", ".... .R.. .... ...."), - ("ms2_c14_m1_3", ".... .R.. .... ...."), - ("ms4_c21_m3_1", ".... .... .... .... .... .... .... ...."), - ("ms4_c21_m1_3", ".... .... .... .... .... .... .... ...."), - ("ms4_c22_m1_1", ".... .... .... .... .... .... .... ...."), - ("ms4_c22_m2_1", ".... .... .... .... .... .... .... ...."), - ("ms4_c22_m1_2", ".... .... .... .... .... .... .... ...."), - ("ms4_c22_m3_1", ".... .... .... .... .... .... .... ...."), - ("ms4_c23_m1_1", ".... .... .... .... .... .... .... ...."), - ("ms4_c23_m2_1", ".... .... .... .... .... .... .... ...."), - ("ms4_c23_m1_2", ".... .... .... .... .... .... .... ...."), - ("ms4_c24_m1_1", ".... .... .... .... .... .... .... ...."), - ("ms4_c24_m2_1", ".... .... .... .... .... .... .... ...."), - ("ms4_c24_m1_2", ".... .... .... .... .... .... .... ...."), - ("ms4_c24_m1_3", ".... .... .... .... .... .... .... ...."), -]; diff --git a/crates/metal2vulkan/src/bind/tile_reach/tests/points.rs b/crates/metal2vulkan/src/bind/tile_reach/tests/points.rs deleted file mode 100644 index ba084ad6e..000000000 --- a/crates/metal2vulkan/src/bind/tile_reach/tests/points.rs +++ /dev/null @@ -1,2187 +0,0 @@ -//! A point's square, measured (on an Apple M4 under macOS 27.0.1, our probes -//! likewise; each case in a process of its own, two rounds alike): a 2048 by 64 single-sampled -//! frame (64 by 2 tiles), a `DontCare`-loaded, stored color attachment -//! prefilled with 0x11 bytes, one point a case, its centre and size as the probe computed them -//! (in `f64`, rounded to `f32`), and the tile columns of each tile row it reached. Our own probes; -//! their cases: the right, left, top and bottom edges against a tile's at sizes about 1.3 pixels, -//! 0 to 30000.5 units (of 1/256 of a pixel) of half size and on the ties of the rounding of the -//! size to 1/16 of a pixel, at x = 64 and x = 1024; large sizes and their clamp; centres past the -//! viewport. - -use super::reference::Raster; -use super::{clip_in, points, Row}; - -/// The probes' frame, in pixels. -const FRAME: [u32; 2] = [2048, 64]; - -/// A case of `probe`: a point at `(x, y)` of `size` pixels, and the tile columns each tile row -/// reached. -fn wide( - probe: &'static str, - name: &'static str, - x: f64, - y: f64, - size: f64, - reached: [&[u32]; 2], -) -> Row { - let tiles = reached.map(|cols| { - (0..FRAME[0] / 32) - .map(|c| if cols.contains(&c) { 'R' } else { '.' }) - .collect::() - }); - let reached = tiles.join(" "); - let mut row = super::row(probe, name, points(vec![clip_in(FRAME, x, y, 0.5)])); - row.raster = Raster::over(FRAME); - row.size(size).reaches(&[reached.as_str()]) -} - -/// Every case, in the probes' order. -pub(super) fn rows() -> Vec { - vec![ - wide( - "reach11", - "frac0.25_right_k166", - 64.0 - 166.0 / 256.0, - 16.5, - (166.0 + 0.25) / 128.0, - [&[1, 2], &[]], - ), - wide( - "reach11", - "frac0.25_left_k166", - 64.0 + 166.0 / 256.0, - 16.5, - (166.0 + 0.25) / 128.0, - [&[2], &[]], - ), - wide( - "reach11", - "frac0.25_right_k167", - 64.0 - 167.0 / 256.0, - 16.5, - (166.0 + 0.25) / 128.0, - [&[1, 2], &[]], - ), - wide( - "reach11", - "frac0.25_left_k167", - 64.0 + 167.0 / 256.0, - 16.5, - (166.0 + 0.25) / 128.0, - [&[2], &[]], - ), - wide( - "reach11", - "frac0.5_right_k166", - 64.0 - 166.0 / 256.0, - 16.5, - (166.0 + 0.5) / 128.0, - [&[1, 2], &[]], - ), - wide( - "reach11", - "frac0.5_left_k166", - 64.0 + 166.0 / 256.0, - 16.5, - (166.0 + 0.5) / 128.0, - [&[2], &[]], - ), - wide( - "reach11", - "frac0.5_right_k167", - 64.0 - 167.0 / 256.0, - 16.5, - (166.0 + 0.5) / 128.0, - [&[1, 2], &[]], - ), - wide( - "reach11", - "frac0.5_left_k167", - 64.0 + 167.0 / 256.0, - 16.5, - (166.0 + 0.5) / 128.0, - [&[2], &[]], - ), - wide( - "reach11", - "frac0.75_right_k166", - 64.0 - 166.0 / 256.0, - 16.5, - (166.0 + 0.75) / 128.0, - [&[1, 2], &[]], - ), - wide( - "reach11", - "frac0.75_left_k166", - 64.0 + 166.0 / 256.0, - 16.5, - (166.0 + 0.75) / 128.0, - [&[1, 2], &[]], - ), - wide( - "reach11", - "frac0.75_right_k167", - 64.0 - 167.0 / 256.0, - 16.5, - (166.0 + 0.75) / 128.0, - [&[1, 2], &[]], - ), - wide( - "reach11", - "frac0.75_left_k167", - 64.0 + 167.0 / 256.0, - 16.5, - (166.0 + 0.75) / 128.0, - [&[2], &[]], - ), - wide( - "reach11", - "centre166.4_right", - 64.0 - 166.4 / 256.0, - 16.5, - 166.25 / 128.0, - [&[1, 2], &[]], - ), - wide( - "reach11", - "centre166.4_left", - 64.0 + 166.4 / 256.0, - 16.5, - 166.25 / 128.0, - [&[2], &[]], - ), - wide( - "reach11", - "centre166.6_right", - 64.0 - 166.6 / 256.0, - 16.5, - 166.25 / 128.0, - [&[1, 2], &[]], - ), - wide( - "reach11", - "centre166.6_left", - 64.0 + 166.6 / 256.0, - 16.5, - 166.25 / 128.0, - [&[2], &[]], - ), - wide( - "reach11", - "large40", - 1024.25, - 16.5, - 40.0, - [&[31, 32], &[31, 32]], - ), - wide( - "reach11", - "large511", - 1024.25, - 16.5, - 511.0, - [ - &[ - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - ], - &[ - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - ], - ], - ), - wide( - "reach11", - "large512", - 1024.25, - 16.5, - 512.0, - [ - &[ - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - ], - &[ - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - ], - ], - ), - wide( - "reach11", - "large513", - 1024.25, - 16.5, - 513.0, - [ - &[ - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - ], - &[ - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - ], - ], - ), - wide( - "reach11", - "large1000", - 1024.25, - 16.5, - 1000.0, - [ - &[ - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - ], - &[ - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - ], - ], - ), - wide( - "reach11", - "large2000", - 1024.25, - 16.5, - 2000.0, - [ - &[ - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - ], - &[ - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - ], - ], - ), - wide( - "reach11", - "large8192", - 1024.25, - 16.5, - 8192.0, - [ - &[ - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - ], - &[ - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - ], - ], - ), - wide("reach11", "past64", -30.0, 16.5, 64.0, [&[0], &[0]]), - wide("reach11", "past200", -98.0, 16.5, 200.0, [&[0], &[0]]), - wide("reach11", "past1000", -498.0, 16.5, 1000.0, [&[], &[]]), - wide( - "reach12", - "right_h166.25_k168", - 64.0 - 168.0 / 256.0, - 16.5, - 166.25 / 128.0, - [&[1, 2], &[]], - ), - wide( - "reach12", - "right_h166.125_k167", - 64.0 - 167.0 / 256.0, - 16.5, - 166.125 / 128.0, - [&[1, 2], &[]], - ), - wide( - "reach12", - "right_h166.0625_k167", - 64.0 - 167.0 / 256.0, - 16.5, - 166.0625 / 128.0, - [&[1, 2], &[]], - ), - wide( - "reach12", - "right_h166.03125_k167", - 64.0 - 167.0 / 256.0, - 16.5, - 166.03125 / 128.0, - [&[1, 2], &[]], - ), - wide( - "reach12", - "right_h166.0_k167", - 64.0 - 167.0 / 256.0, - 16.5, - 166.0 / 128.0, - [&[1, 2], &[]], - ), - wide( - "reach12", - "right_h165.875_k167", - 64.0 - 167.0 / 256.0, - 16.5, - 165.875 / 128.0, - [&[1, 2], &[]], - ), - wide( - "reach12", - "right_h166.25_k167", - 64.0 - 167.0 / 256.0, - 16.5, - 166.25 / 128.0, - [&[1, 2], &[]], - ), - wide( - "reach12", - "left_h166.5_k166", - 64.0 + 166.0 / 256.0, - 16.5, - 166.5 / 128.0, - [&[2], &[]], - ), - wide( - "reach12", - "left_h166.53125_k166", - 64.0 + 166.0 / 256.0, - 16.5, - 166.53125 / 128.0, - [&[1, 2], &[]], - ), - wide( - "reach12", - "left_h166.5625_k166", - 64.0 + 166.0 / 256.0, - 16.5, - 166.5625 / 128.0, - [&[1, 2], &[]], - ), - wide( - "reach12", - "left_h166.625_k166", - 64.0 + 166.0 / 256.0, - 16.5, - 166.625 / 128.0, - [&[1, 2], &[]], - ), - wide( - "reach12", - "left_h166.6875_k166", - 64.0 + 166.0 / 256.0, - 16.5, - 166.6875 / 128.0, - [&[1, 2], &[]], - ), - wide( - "reach12", - "left_h166.75_k166", - 64.0 + 166.0 / 256.0, - 16.5, - 166.75 / 128.0, - [&[1, 2], &[]], - ), - wide( - "reach12", - "top_f0.25_k166", - 16.0, - 32.0 + 166.0 / 256.0, - (166.0 + 0.25) / 128.0, - [&[], &[0]], - ), - wide( - "reach12", - "bottom_f0.25_k166", - 16.0, - 32.0 - 166.0 / 256.0, - (166.0 + 0.25) / 128.0, - [&[0], &[0]], - ), - wide( - "reach12", - "top_f0.25_k167", - 16.0, - 32.0 + 167.0 / 256.0, - (166.0 + 0.25) / 128.0, - [&[], &[0]], - ), - wide( - "reach12", - "bottom_f0.25_k167", - 16.0, - 32.0 - 167.0 / 256.0, - (166.0 + 0.25) / 128.0, - [&[0], &[0]], - ), - wide( - "reach12", - "top_f0.5_k166", - 16.0, - 32.0 + 166.0 / 256.0, - (166.0 + 0.5) / 128.0, - [&[], &[0]], - ), - wide( - "reach12", - "bottom_f0.5_k166", - 16.0, - 32.0 - 166.0 / 256.0, - (166.0 + 0.5) / 128.0, - [&[0], &[0]], - ), - wide( - "reach12", - "top_f0.5_k167", - 16.0, - 32.0 + 167.0 / 256.0, - (166.0 + 0.5) / 128.0, - [&[], &[0]], - ), - wide( - "reach12", - "bottom_f0.5_k167", - 16.0, - 32.0 - 167.0 / 256.0, - (166.0 + 0.5) / 128.0, - [&[0], &[0]], - ), - wide( - "reach12", - "top_f0.75_k166", - 16.0, - 32.0 + 166.0 / 256.0, - (166.0 + 0.75) / 128.0, - [&[0], &[0]], - ), - wide( - "reach12", - "bottom_f0.75_k166", - 16.0, - 32.0 - 166.0 / 256.0, - (166.0 + 0.75) / 128.0, - [&[0], &[0]], - ), - wide( - "reach12", - "top_f0.75_k167", - 16.0, - 32.0 + 167.0 / 256.0, - (166.0 + 0.75) / 128.0, - [&[], &[0]], - ), - wide( - "reach12", - "bottom_f0.75_k167", - 16.0, - 32.0 - 167.0 / 256.0, - (166.0 + 0.75) / 128.0, - [&[0], &[0]], - ), - wide( - "reach12", - "large510.5", - 1024.5, - 16.5, - 510.5, - [ - &[ - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - ], - &[ - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - ], - ], - ), - wide( - "reach12", - "large511.0", - 1024.5, - 16.5, - 511.0, - [ - &[ - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, - ], - &[ - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, - ], - ], - ), - wide( - "reach12", - "large511.25", - 1024.5, - 16.5, - 511.25, - [ - &[ - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, - ], - &[ - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, - ], - ], - ), - wide( - "reach12", - "large600.0", - 1024.5, - 16.5, - 600.0, - [ - &[ - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, - ], - &[ - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, - ], - ], - ), - wide( - "reach13", - "right_b64_h0.0_k1", - 64.0 - 1.0 / 256.0, - 16.5, - 0.0 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h0.0_k2", - 64.0 - 2.0 / 256.0, - 16.5, - 0.0 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h0.0_k3", - 64.0 - 3.0 / 256.0, - 16.5, - 0.0 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h0.0_k4", - 64.0 - 4.0 / 256.0, - 16.5, - 0.0 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h0.0_k5", - 64.0 - 5.0 / 256.0, - 16.5, - 0.0 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h0.0_k7", - 64.0 - 7.0 / 256.0, - 16.5, - 0.0 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h0.0_k9", - 64.0 - 9.0 / 256.0, - 16.5, - 0.0 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h0.0_k13", - 64.0 - 13.0 / 256.0, - 16.5, - 0.0 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h0.0_k17", - 64.0 - 17.0 / 256.0, - 16.5, - 0.0 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h0.0_k25", - 64.0 - 25.0 / 256.0, - 16.5, - 0.0 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h0.0_k33", - 64.0 - 33.0 / 256.0, - 16.5, - 0.0 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h0.0_k49", - 64.0 - 49.0 / 256.0, - 16.5, - 0.0 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h0.0_k64", - 64.0 - 64.0 / 256.0, - 16.5, - 0.0 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h8.0_k9", - 64.0 - 9.0 / 256.0, - 16.5, - 8.0 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h8.0_k10", - 64.0 - 10.0 / 256.0, - 16.5, - 8.0 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h8.0_k11", - 64.0 - 11.0 / 256.0, - 16.5, - 8.0 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h8.0_k12", - 64.0 - 12.0 / 256.0, - 16.5, - 8.0 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h8.0_k13", - 64.0 - 13.0 / 256.0, - 16.5, - 8.0 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h8.0_k15", - 64.0 - 15.0 / 256.0, - 16.5, - 8.0 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h8.0_k17", - 64.0 - 17.0 / 256.0, - 16.5, - 8.0 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h8.0_k21", - 64.0 - 21.0 / 256.0, - 16.5, - 8.0 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h8.0_k25", - 64.0 - 25.0 / 256.0, - 16.5, - 8.0 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h8.0_k33", - 64.0 - 33.0 / 256.0, - 16.5, - 8.0 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h8.0_k41", - 64.0 - 41.0 / 256.0, - 16.5, - 8.0 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h8.0_k57", - 64.0 - 57.0 / 256.0, - 16.5, - 8.0 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h8.0_k72", - 64.0 - 72.0 / 256.0, - 16.5, - 8.0 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h32.0_k33", - 64.0 - 33.0 / 256.0, - 16.5, - 32.0 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h32.0_k34", - 64.0 - 34.0 / 256.0, - 16.5, - 32.0 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h32.0_k35", - 64.0 - 35.0 / 256.0, - 16.5, - 32.0 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h32.0_k36", - 64.0 - 36.0 / 256.0, - 16.5, - 32.0 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h32.0_k37", - 64.0 - 37.0 / 256.0, - 16.5, - 32.0 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h32.0_k39", - 64.0 - 39.0 / 256.0, - 16.5, - 32.0 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h32.0_k41", - 64.0 - 41.0 / 256.0, - 16.5, - 32.0 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h32.0_k45", - 64.0 - 45.0 / 256.0, - 16.5, - 32.0 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h32.0_k49", - 64.0 - 49.0 / 256.0, - 16.5, - 32.0 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h32.0_k57", - 64.0 - 57.0 / 256.0, - 16.5, - 32.0 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h32.0_k65", - 64.0 - 65.0 / 256.0, - 16.5, - 32.0 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h32.0_k81", - 64.0 - 81.0 / 256.0, - 16.5, - 32.0 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h32.0_k96", - 64.0 - 96.0 / 256.0, - 16.5, - 32.0 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h166.0_k167", - 64.0 - 167.0 / 256.0, - 16.5, - 166.0 / 128.0, - [&[1, 2], &[]], - ), - wide( - "reach13", - "right_b64_h166.0_k168", - 64.0 - 168.0 / 256.0, - 16.5, - 166.0 / 128.0, - [&[1, 2], &[]], - ), - wide( - "reach13", - "right_b64_h166.0_k169", - 64.0 - 169.0 / 256.0, - 16.5, - 166.0 / 128.0, - [&[1, 2], &[]], - ), - wide( - "reach13", - "right_b64_h166.0_k170", - 64.0 - 170.0 / 256.0, - 16.5, - 166.0 / 128.0, - [&[1, 2], &[]], - ), - wide( - "reach13", - "right_b64_h166.0_k171", - 64.0 - 171.0 / 256.0, - 16.5, - 166.0 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h166.0_k173", - 64.0 - 173.0 / 256.0, - 16.5, - 166.0 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h166.0_k175", - 64.0 - 175.0 / 256.0, - 16.5, - 166.0 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h166.0_k179", - 64.0 - 179.0 / 256.0, - 16.5, - 166.0 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h166.0_k183", - 64.0 - 183.0 / 256.0, - 16.5, - 166.0 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h166.0_k191", - 64.0 - 191.0 / 256.0, - 16.5, - 166.0 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h166.0_k199", - 64.0 - 199.0 / 256.0, - 16.5, - 166.0 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h166.0_k215", - 64.0 - 215.0 / 256.0, - 16.5, - 166.0 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h166.0_k230", - 64.0 - 230.0 / 256.0, - 16.5, - 166.0 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h166.25_k167", - 64.0 - 167.0 / 256.0, - 16.5, - 166.25 / 128.0, - [&[1, 2], &[]], - ), - wide( - "reach13", - "right_b64_h166.25_k168", - 64.0 - 168.0 / 256.0, - 16.5, - 166.25 / 128.0, - [&[1, 2], &[]], - ), - wide( - "reach13", - "right_b64_h166.25_k169", - 64.0 - 169.0 / 256.0, - 16.5, - 166.25 / 128.0, - [&[1, 2], &[]], - ), - wide( - "reach13", - "right_b64_h166.25_k170", - 64.0 - 170.0 / 256.0, - 16.5, - 166.25 / 128.0, - [&[1, 2], &[]], - ), - wide( - "reach13", - "right_b64_h166.25_k171", - 64.0 - 171.0 / 256.0, - 16.5, - 166.25 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h166.25_k173", - 64.0 - 173.0 / 256.0, - 16.5, - 166.25 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h166.25_k175", - 64.0 - 175.0 / 256.0, - 16.5, - 166.25 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h166.25_k179", - 64.0 - 179.0 / 256.0, - 16.5, - 166.25 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h166.25_k183", - 64.0 - 183.0 / 256.0, - 16.5, - 166.25 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h166.25_k191", - 64.0 - 191.0 / 256.0, - 16.5, - 166.25 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h166.25_k199", - 64.0 - 199.0 / 256.0, - 16.5, - 166.25 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h166.25_k215", - 64.0 - 215.0 / 256.0, - 16.5, - 166.25 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h166.25_k230", - 64.0 - 230.0 / 256.0, - 16.5, - 166.25 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h166.5_k167", - 64.0 - 167.0 / 256.0, - 16.5, - 166.5 / 128.0, - [&[1, 2], &[]], - ), - wide( - "reach13", - "right_b64_h166.5_k168", - 64.0 - 168.0 / 256.0, - 16.5, - 166.5 / 128.0, - [&[1, 2], &[]], - ), - wide( - "reach13", - "right_b64_h166.5_k169", - 64.0 - 169.0 / 256.0, - 16.5, - 166.5 / 128.0, - [&[1, 2], &[]], - ), - wide( - "reach13", - "right_b64_h166.5_k170", - 64.0 - 170.0 / 256.0, - 16.5, - 166.5 / 128.0, - [&[1, 2], &[]], - ), - wide( - "reach13", - "right_b64_h166.5_k171", - 64.0 - 171.0 / 256.0, - 16.5, - 166.5 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h166.5_k173", - 64.0 - 173.0 / 256.0, - 16.5, - 166.5 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h166.5_k175", - 64.0 - 175.0 / 256.0, - 16.5, - 166.5 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h166.5_k179", - 64.0 - 179.0 / 256.0, - 16.5, - 166.5 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h166.5_k183", - 64.0 - 183.0 / 256.0, - 16.5, - 166.5 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h166.5_k191", - 64.0 - 191.0 / 256.0, - 16.5, - 166.5 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h166.5_k199", - 64.0 - 199.0 / 256.0, - 16.5, - 166.5 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h166.5_k215", - 64.0 - 215.0 / 256.0, - 16.5, - 166.5 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h166.5_k230", - 64.0 - 230.0 / 256.0, - 16.5, - 166.5 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h166.75_k167", - 64.0 - 167.0 / 256.0, - 16.5, - 166.75 / 128.0, - [&[1, 2], &[]], - ), - wide( - "reach13", - "right_b64_h166.75_k168", - 64.0 - 168.0 / 256.0, - 16.5, - 166.75 / 128.0, - [&[1, 2], &[]], - ), - wide( - "reach13", - "right_b64_h166.75_k169", - 64.0 - 169.0 / 256.0, - 16.5, - 166.75 / 128.0, - [&[1, 2], &[]], - ), - wide( - "reach13", - "right_b64_h166.75_k170", - 64.0 - 170.0 / 256.0, - 16.5, - 166.75 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h166.75_k171", - 64.0 - 171.0 / 256.0, - 16.5, - 166.75 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h166.75_k173", - 64.0 - 173.0 / 256.0, - 16.5, - 166.75 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h166.75_k175", - 64.0 - 175.0 / 256.0, - 16.5, - 166.75 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h166.75_k179", - 64.0 - 179.0 / 256.0, - 16.5, - 166.75 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h166.75_k183", - 64.0 - 183.0 / 256.0, - 16.5, - 166.75 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h166.75_k191", - 64.0 - 191.0 / 256.0, - 16.5, - 166.75 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h166.75_k199", - 64.0 - 199.0 / 256.0, - 16.5, - 166.75 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h166.75_k215", - 64.0 - 215.0 / 256.0, - 16.5, - 166.75 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b64_h166.75_k230", - 64.0 - 230.0 / 256.0, - 16.5, - 166.75 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "right_b1024_h166.25_k167", - 1024.0 - 167.0 / 256.0, - 16.5, - 166.25 / 128.0, - [&[31, 32], &[]], - ), - wide( - "reach13", - "right_b1024_h166.25_k168", - 1024.0 - 168.0 / 256.0, - 16.5, - 166.25 / 128.0, - [&[31, 32], &[]], - ), - wide( - "reach13", - "right_b1024_h166.25_k169", - 1024.0 - 169.0 / 256.0, - 16.5, - 166.25 / 128.0, - [&[31, 32], &[]], - ), - wide( - "reach13", - "right_b1024_h166.25_k170", - 1024.0 - 170.0 / 256.0, - 16.5, - 166.25 / 128.0, - [&[31, 32], &[]], - ), - wide( - "reach13", - "right_b1024_h166.25_k171", - 1024.0 - 171.0 / 256.0, - 16.5, - 166.25 / 128.0, - [&[31], &[]], - ), - wide( - "reach13", - "right_b1024_h166.25_k173", - 1024.0 - 173.0 / 256.0, - 16.5, - 166.25 / 128.0, - [&[31], &[]], - ), - wide( - "reach13", - "right_b1024_h166.25_k175", - 1024.0 - 175.0 / 256.0, - 16.5, - 166.25 / 128.0, - [&[31], &[]], - ), - wide( - "reach13", - "right_b1024_h166.25_k179", - 1024.0 - 179.0 / 256.0, - 16.5, - 166.25 / 128.0, - [&[31], &[]], - ), - wide( - "reach13", - "right_b1024_h166.25_k183", - 1024.0 - 183.0 / 256.0, - 16.5, - 166.25 / 128.0, - [&[31], &[]], - ), - wide( - "reach13", - "right_b1024_h166.25_k191", - 1024.0 - 191.0 / 256.0, - 16.5, - 166.25 / 128.0, - [&[31], &[]], - ), - wide( - "reach13", - "right_b1024_h166.25_k199", - 1024.0 - 199.0 / 256.0, - 16.5, - 166.25 / 128.0, - [&[31], &[]], - ), - wide( - "reach13", - "right_b1024_h166.25_k215", - 1024.0 - 215.0 / 256.0, - 16.5, - 166.25 / 128.0, - [&[31], &[]], - ), - wide( - "reach13", - "right_b1024_h166.25_k230", - 1024.0 - 230.0 / 256.0, - 16.5, - 166.25 / 128.0, - [&[31], &[]], - ), - wide( - "reach13", - "right_b1024_h4096.0_k4097", - 1024.0 - 4097.0 / 256.0, - 16.5, - 4096.0 / 128.0, - [&[30, 31], &[30, 31]], - ), - wide( - "reach13", - "right_b1024_h4096.0_k4098", - 1024.0 - 4098.0 / 256.0, - 16.5, - 4096.0 / 128.0, - [&[30, 31], &[30, 31]], - ), - wide( - "reach13", - "right_b1024_h4096.0_k4099", - 1024.0 - 4099.0 / 256.0, - 16.5, - 4096.0 / 128.0, - [&[30, 31], &[30, 31]], - ), - wide( - "reach13", - "right_b1024_h4096.0_k4100", - 1024.0 - 4100.0 / 256.0, - 16.5, - 4096.0 / 128.0, - [&[30, 31], &[30, 31]], - ), - wide( - "reach13", - "right_b1024_h4096.0_k4101", - 1024.0 - 4101.0 / 256.0, - 16.5, - 4096.0 / 128.0, - [&[30, 31], &[30, 31]], - ), - wide( - "reach13", - "right_b1024_h4096.0_k4103", - 1024.0 - 4103.0 / 256.0, - 16.5, - 4096.0 / 128.0, - [&[30, 31], &[30, 31]], - ), - wide( - "reach13", - "right_b1024_h4096.0_k4105", - 1024.0 - 4105.0 / 256.0, - 16.5, - 4096.0 / 128.0, - [&[30, 31], &[30, 31]], - ), - wide( - "reach13", - "right_b1024_h4096.0_k4109", - 1024.0 - 4109.0 / 256.0, - 16.5, - 4096.0 / 128.0, - [&[30, 31], &[30, 31]], - ), - wide( - "reach13", - "right_b1024_h4096.0_k4113", - 1024.0 - 4113.0 / 256.0, - 16.5, - 4096.0 / 128.0, - [&[30, 31], &[30, 31]], - ), - wide( - "reach13", - "right_b1024_h4096.0_k4121", - 1024.0 - 4121.0 / 256.0, - 16.5, - 4096.0 / 128.0, - [&[30, 31], &[30, 31]], - ), - wide( - "reach13", - "right_b1024_h4096.0_k4129", - 1024.0 - 4129.0 / 256.0, - 16.5, - 4096.0 / 128.0, - [&[30, 31], &[30, 31]], - ), - wide( - "reach13", - "right_b1024_h4096.0_k4145", - 1024.0 - 4145.0 / 256.0, - 16.5, - 4096.0 / 128.0, - [&[30, 31], &[30, 31]], - ), - wide( - "reach13", - "right_b1024_h4096.0_k4160", - 1024.0 - 4160.0 / 256.0, - 16.5, - 4096.0 / 128.0, - [&[30, 31], &[30, 31]], - ), - wide( - "reach13", - "right_b1024_h30000.5_k30001", - 1024.0 - 30001.0 / 256.0, - 16.5, - 30000.5 / 128.0, - [ - &[24, 25, 26, 27, 28, 29, 30, 31], - &[24, 25, 26, 27, 28, 29, 30, 31], - ], - ), - wide( - "reach13", - "right_b1024_h30000.5_k30002", - 1024.0 - 30002.0 / 256.0, - 16.5, - 30000.5 / 128.0, - [ - &[24, 25, 26, 27, 28, 29, 30, 31], - &[24, 25, 26, 27, 28, 29, 30, 31], - ], - ), - wide( - "reach13", - "right_b1024_h30000.5_k30003", - 1024.0 - 30003.0 / 256.0, - 16.5, - 30000.5 / 128.0, - [ - &[24, 25, 26, 27, 28, 29, 30, 31], - &[24, 25, 26, 27, 28, 29, 30, 31], - ], - ), - wide( - "reach13", - "right_b1024_h30000.5_k30004", - 1024.0 - 30004.0 / 256.0, - 16.5, - 30000.5 / 128.0, - [ - &[24, 25, 26, 27, 28, 29, 30, 31], - &[24, 25, 26, 27, 28, 29, 30, 31], - ], - ), - wide( - "reach13", - "right_b1024_h30000.5_k30005", - 1024.0 - 30005.0 / 256.0, - 16.5, - 30000.5 / 128.0, - [ - &[24, 25, 26, 27, 28, 29, 30, 31], - &[24, 25, 26, 27, 28, 29, 30, 31], - ], - ), - wide( - "reach13", - "right_b1024_h30000.5_k30007", - 1024.0 - 30007.0 / 256.0, - 16.5, - 30000.5 / 128.0, - [ - &[24, 25, 26, 27, 28, 29, 30, 31], - &[24, 25, 26, 27, 28, 29, 30, 31], - ], - ), - wide( - "reach13", - "right_b1024_h30000.5_k30009", - 1024.0 - 30009.0 / 256.0, - 16.5, - 30000.5 / 128.0, - [ - &[24, 25, 26, 27, 28, 29, 30, 31], - &[24, 25, 26, 27, 28, 29, 30, 31], - ], - ), - wide( - "reach13", - "right_b1024_h30000.5_k30013", - 1024.0 - 30013.0 / 256.0, - 16.5, - 30000.5 / 128.0, - [ - &[24, 25, 26, 27, 28, 29, 30, 31], - &[24, 25, 26, 27, 28, 29, 30, 31], - ], - ), - wide( - "reach13", - "right_b1024_h30000.5_k30017", - 1024.0 - 30017.0 / 256.0, - 16.5, - 30000.5 / 128.0, - [ - &[24, 25, 26, 27, 28, 29, 30, 31], - &[24, 25, 26, 27, 28, 29, 30, 31], - ], - ), - wide( - "reach13", - "right_b1024_h30000.5_k30025", - 1024.0 - 30025.0 / 256.0, - 16.5, - 30000.5 / 128.0, - [ - &[24, 25, 26, 27, 28, 29, 30, 31], - &[24, 25, 26, 27, 28, 29, 30, 31], - ], - ), - wide( - "reach13", - "right_b1024_h30000.5_k30033", - 1024.0 - 30033.0 / 256.0, - 16.5, - 30000.5 / 128.0, - [ - &[24, 25, 26, 27, 28, 29, 30, 31], - &[24, 25, 26, 27, 28, 29, 30, 31], - ], - ), - wide( - "reach13", - "right_b1024_h30000.5_k30049", - 1024.0 - 30049.0 / 256.0, - 16.5, - 30000.5 / 128.0, - [ - &[24, 25, 26, 27, 28, 29, 30, 31], - &[24, 25, 26, 27, 28, 29, 30, 31], - ], - ), - wide( - "reach13", - "right_b1024_h30000.5_k30064", - 1024.0 - 30064.0 / 256.0, - 16.5, - 30000.5 / 128.0, - [ - &[24, 25, 26, 27, 28, 29, 30, 31], - &[24, 25, 26, 27, 28, 29, 30, 31], - ], - ), - wide( - "reach13", - "left_b64_h0.5_k0", - 64.0 + 0.0 / 256.0, - 16.5, - 0.5 / 128.0, - [&[2], &[]], - ), - wide( - "reach13", - "left_b64_h0.53125_k0", - 64.0 + 0.0 / 256.0, - 16.5, - 0.53125 / 128.0, - [&[1], &[]], - ), - wide( - "reach13", - "left_b64_h8.5_k8", - 64.0 + 8.0 / 256.0, - 16.5, - 8.5 / 128.0, - [&[2], &[]], - ), - wide( - "reach13", - "left_b64_h8.53125_k8", - 64.0 + 8.0 / 256.0, - 16.5, - 8.53125 / 128.0, - [&[1, 2], &[]], - ), - wide( - "reach13", - "left_b1024_h166.5_k166", - 1024.0 + 166.0 / 256.0, - 16.5, - 166.5 / 128.0, - [&[32], &[]], - ), - wide( - "reach13", - "left_b1024_h166.53125_k166", - 1024.0 + 166.0 / 256.0, - 16.5, - 166.53125 / 128.0, - [&[31, 32], &[]], - ), - wide( - "reach13", - "left_b1024_h4096.5_k4096", - 1024.0 + 4096.0 / 256.0, - 16.5, - 4096.5 / 128.0, - [&[32, 33], &[32, 33]], - ), - wide( - "reach13", - "left_b1024_h4096.53125_k4096", - 1024.0 + 4096.0 / 256.0, - 16.5, - 4096.53125 / 128.0, - [&[31, 32], &[31, 32]], - ), - wide( - "reach13", - "left_b1024_h30000.5_k30000", - 1024.0 + 30000.0 / 256.0, - 16.5, - 30000.5 / 128.0, - [ - &[32, 33, 34, 35, 36, 37, 38, 39], - &[32, 33, 34, 35, 36, 37, 38, 39], - ], - ), - wide( - "reach13", - "left_b1024_h30000.53125_k30000", - 1024.0 + 30000.0 / 256.0, - 16.5, - 30000.53125 / 128.0, - [ - &[31, 32, 33, 34, 35, 36, 37, 38, 39], - &[31, 32, 33, 34, 35, 36, 37, 38, 39], - ], - ), - wide( - "reach13", - "bottom_h166.25_k168", - 16.0, - 32.0 - 168.0 / 256.0, - 166.25 / 128.0, - [&[0], &[0]], - ), - wide( - "reach13", - "bottom_h166.25_k170", - 16.0, - 32.0 - 170.0 / 256.0, - 166.25 / 128.0, - [&[0], &[0]], - ), - wide( - "reach13", - "bottom_h166.25_k174", - 16.0, - 32.0 - 174.0 / 256.0, - 166.25 / 128.0, - [&[0], &[]], - ), - wide( - "reach13", - "bottom_h166.25_k182", - 16.0, - 32.0 - 182.0 / 256.0, - 166.25 / 128.0, - [&[0], &[]], - ), - wide( - "reach13", - "bottom_h166.25_k198", - 16.0, - 32.0 - 198.0 / 256.0, - 166.25 / 128.0, - [&[0], &[]], - ), - wide( - "reach13", - "bottom_h166.25_k230", - 16.0, - 32.0 - 230.0 / 256.0, - 166.25 / 128.0, - [&[0], &[]], - ), - wide( - "reach13", - "top_h8.5_k8", - 16.0, - 32.0 + 8.0 / 256.0, - 8.5 / 128.0, - [&[], &[0]], - ), - wide( - "reach13", - "top_h8.53125_k8", - 16.0, - 32.0 + 8.0 / 256.0, - 8.53125 / 128.0, - [&[0], &[0]], - ), - wide( - "reach13", - "clamp_s511.0_j-1", - 1023.5 + -1.0 / 256.0, - 16.5, - 511.0, - [ - &[ - 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - ], - &[ - 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - ], - ], - ), - wide( - "reach13", - "clamp_s511.0_j0", - 1023.5 + 0.0 / 256.0, - 16.5, - 511.0, - [ - &[ - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - ], - &[ - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - ], - ], - ), - wide( - "reach13", - "clamp_s511.0_j1", - 1023.5 + 1.0 / 256.0, - 16.5, - 511.0, - [ - &[ - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - ], - &[ - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - ], - ], - ), - wide( - "reach13", - "clamp_s511.0078125_j-1", - 1023.5 + -1.0 / 256.0, - 16.5, - 511.0078125, - [ - &[ - 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - ], - &[ - 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - ], - ], - ), - wide( - "reach13", - "clamp_s511.0078125_j0", - 1023.5 + 0.0 / 256.0, - 16.5, - 511.0078125, - [ - &[ - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - ], - &[ - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - ], - ], - ), - wide( - "reach13", - "clamp_s511.0078125_j1", - 1023.5 + 1.0 / 256.0, - 16.5, - 511.0078125, - [ - &[ - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - ], - &[ - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - ], - ], - ), - wide( - "reach13", - "clamp_s600.0_j-1", - 1023.5 + -1.0 / 256.0, - 16.5, - 600.0, - [ - &[ - 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - ], - &[ - 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - ], - ], - ), - wide( - "reach13", - "clamp_s600.0_j0", - 1023.5 + 0.0 / 256.0, - 16.5, - 600.0, - [ - &[ - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - ], - &[ - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - ], - ], - ), - wide( - "reach13", - "clamp_s600.0_j1", - 1023.5 + 1.0 / 256.0, - 16.5, - 600.0, - [ - &[ - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - ], - &[ - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - ], - ], - ), - wide( - "reach14", - "right_b64_s8.0_k1", - 64.0 - 1.0 / 256.0, - 16.5, - 8.0 / 256.0, - [&[1, 2], &[]], - ), - wide( - "reach14", - "right_b64_s8.0_k12", - 64.0 - 12.0 / 256.0, - 16.5, - 8.0 / 256.0, - [&[1, 2], &[]], - ), - wide( - "reach14", - "right_b64_s8.0_k13", - 64.0 - 13.0 / 256.0, - 16.5, - 8.0 / 256.0, - [&[1], &[]], - ), - wide( - "reach14", - "right_b64_s24.0_k4", - 64.0 - 4.0 / 256.0, - 16.5, - 24.0 / 256.0, - [&[1, 2], &[]], - ), - wide( - "reach14", - "right_b64_s24.0_k5", - 64.0 - 5.0 / 256.0, - 16.5, - 24.0 / 256.0, - [&[1, 2], &[]], - ), - wide( - "reach14", - "right_b64_s24.0_k20", - 64.0 - 20.0 / 256.0, - 16.5, - 24.0 / 256.0, - [&[1, 2], &[]], - ), - wide( - "reach14", - "right_b64_s24.0_k21", - 64.0 - 21.0 / 256.0, - 16.5, - 24.0 / 256.0, - [&[1], &[]], - ), - wide( - "reach14", - "right_b64_s328.0_k156", - 64.0 - 156.0 / 256.0, - 16.5, - 328.0 / 256.0, - [&[1, 2], &[]], - ), - wide( - "reach14", - "right_b64_s328.0_k157", - 64.0 - 157.0 / 256.0, - 16.5, - 328.0 / 256.0, - [&[1, 2], &[]], - ), - wide( - "reach14", - "right_b64_s328.0_k172", - 64.0 - 172.0 / 256.0, - 16.5, - 328.0 / 256.0, - [&[1, 2], &[]], - ), - wide( - "reach14", - "right_b64_s328.0_k173", - 64.0 - 173.0 / 256.0, - 16.5, - 328.0 / 256.0, - [&[1], &[]], - ), - wide( - "reach14", - "right_b64_s344.0_k164", - 64.0 - 164.0 / 256.0, - 16.5, - 344.0 / 256.0, - [&[1, 2], &[]], - ), - wide( - "reach14", - "right_b64_s344.0_k165", - 64.0 - 165.0 / 256.0, - 16.5, - 344.0 / 256.0, - [&[1, 2], &[]], - ), - wide( - "reach14", - "right_b64_s344.0_k180", - 64.0 - 180.0 / 256.0, - 16.5, - 344.0 / 256.0, - [&[1, 2], &[]], - ), - wide( - "reach14", - "right_b64_s344.0_k181", - 64.0 - 181.0 / 256.0, - 16.5, - 344.0 / 256.0, - [&[1], &[]], - ), - wide( - "reach14", - "right_b1024_s65544.0_k32764", - 1024.0 - 32764.0 / 256.0, - 16.5, - 65544.0 / 256.0, - [ - &[24, 25, 26, 27, 28, 29, 30, 31, 32], - &[24, 25, 26, 27, 28, 29, 30, 31, 32], - ], - ), - wide( - "reach14", - "right_b1024_s65544.0_k32765", - 1024.0 - 32765.0 / 256.0, - 16.5, - 65544.0 / 256.0, - [ - &[23, 24, 25, 26, 27, 28, 29, 30, 31, 32], - &[23, 24, 25, 26, 27, 28, 29, 30, 31, 32], - ], - ), - wide( - "reach14", - "right_b1024_s65544.0_k32780", - 1024.0 - 32780.0 / 256.0, - 16.5, - 65544.0 / 256.0, - [ - &[23, 24, 25, 26, 27, 28, 29, 30, 31, 32], - &[23, 24, 25, 26, 27, 28, 29, 30, 31, 32], - ], - ), - wide( - "reach14", - "right_b1024_s65544.0_k32781", - 1024.0 - 32781.0 / 256.0, - 16.5, - 65544.0 / 256.0, - [ - &[23, 24, 25, 26, 27, 28, 29, 30, 31], - &[23, 24, 25, 26, 27, 28, 29, 30, 31], - ], - ), - wide( - "reach14", - "right_b64_s1000.5_k508", - 64.0 - 508.0 / 256.0, - 16.5, - 1000.5 / 256.0, - [&[1, 2], &[]], - ), - wide( - "reach14", - "right_b64_s1000.5_k509", - 64.0 - 509.0 / 256.0, - 16.5, - 1000.5 / 256.0, - [&[1], &[]], - ), - wide( - "reach14", - "right_b64_s1001.0_k508", - 64.0 - 508.0 / 256.0, - 16.5, - 1001.0 / 256.0, - [&[1, 2], &[]], - ), - wide( - "reach14", - "right_b64_s1001.0_k509", - 64.0 - 509.0 / 256.0, - 16.5, - 1001.0 / 256.0, - [&[1], &[]], - ), - wide( - "reach14", - "right_b64_s1001.5_k507", - 64.0 - 507.0 / 256.0, - 16.5, - 1001.5 / 256.0, - [&[1, 2], &[]], - ), - wide( - "reach14", - "right_b64_s1001.5_k508", - 64.0 - 508.0 / 256.0, - 16.5, - 1001.5 / 256.0, - [&[1], &[]], - ), - wide( - "reach14", - "bottom_s24.0_k4", - 16.0, - 32.0 - 4.0 / 256.0, - 24.0 / 256.0, - [&[0], &[0]], - ), - wide( - "reach14", - "bottom_s24.0_k5", - 16.0, - 32.0 - 5.0 / 256.0, - 24.0 / 256.0, - [&[0], &[0]], - ), - wide( - "reach14", - "bottom_s24.0_k20", - 16.0, - 32.0 - 20.0 / 256.0, - 24.0 / 256.0, - [&[0], &[0]], - ), - wide( - "reach14", - "bottom_s24.0_k21", - 16.0, - 32.0 - 21.0 / 256.0, - 24.0 / 256.0, - [&[0], &[]], - ), - wide( - "reach14", - "bottom_s328.0_k156", - 16.0, - 32.0 - 156.0 / 256.0, - 328.0 / 256.0, - [&[0], &[0]], - ), - wide( - "reach14", - "bottom_s328.0_k157", - 16.0, - 32.0 - 157.0 / 256.0, - 328.0 / 256.0, - [&[0], &[0]], - ), - wide( - "reach14", - "bottom_s328.0_k172", - 16.0, - 32.0 - 172.0 / 256.0, - 328.0 / 256.0, - [&[0], &[0]], - ), - wide( - "reach14", - "bottom_s328.0_k173", - 16.0, - 32.0 - 173.0 / 256.0, - 328.0 / 256.0, - [&[0], &[]], - ), - wide( - "reach14", - "bottom_s1001.5_k507", - 16.0, - 32.0 - 507.0 / 256.0, - 1001.5 / 256.0, - [&[0], &[0]], - ), - wide( - "reach14", - "bottom_s1001.5_k508", - 16.0, - 32.0 - 508.0 / 256.0, - 1001.5 / 256.0, - [&[0], &[]], - ), - ] -} diff --git a/crates/metal2vulkan/src/bind/tile_reach/tests/reference.rs b/crates/metal2vulkan/src/bind/tile_reach/tests/reference.rs deleted file mode 100644 index bf335cab2..000000000 --- a/crates/metal2vulkan/src/bind/tile_reach/tests/reference.rs +++ /dev/null @@ -1,526 +0,0 @@ -//! The tile reach rule (the module docs) as a plain function over one primitive's clip-space -//! vertices: the reference every measured case checks, and the kernel answers as. -//! -//! Arithmetic: a vertex's window position in `f32` (`x_w = (w / 2) * x_ndc + (o_x + w / 2)`, y -//! down, each operation rounded on its own), snapped to 1/256 of a pixel ties to even (the cases -//! measured cannot tell even from up), and every test after that in integers: a primitive's -//! closed area against a half-open rectangle by the separating axes of both (the rectangle's far -//! edges approached from inside, [`meets`]), a triangle's sample cull row by row of samples -//! ([`covers_sample`]), a point's square from its integer extent ([`point_extent`]). - -use std::collections::BTreeSet; - -/// Units of a pixel a vertex snaps to. -pub(super) const SUBPIXEL: i64 = 256; - -/// The largest snapped coordinate the rule is measured near (1e5 pixels) is far below this (2^21 -/// pixels): past it a coordinate is clamped and the answer flagged unmeasured. Below it every -/// product the kernel's integer tests form fits an `i64`. -pub(super) const COORDINATE_LIMIT: i64 = 1 << 29; - -/// The largest point size Metal draws, in pixels: a larger size draws as this one. -pub(super) const POINT_SIZE_LIMIT: f32 = 511.0; - -/// Which faces a draw culls. -#[derive(Clone, Copy, Debug, PartialEq, Eq)] -pub(super) enum Cull { - /// None. - None, - /// Front faces. - Front, - /// Back faces. - Back, -} - -/// Which winding faces front. -#[derive(Clone, Copy, Debug, PartialEq, Eq)] -pub(super) enum Winding { - /// Clockwise in window coordinates (y down), Metal's default. - Clockwise, - /// Counter-clockwise. - CounterClockwise, -} - -/// A draw's rasterization state: the pass's render area and samples, the encoder's viewport, -/// scissor, cull mode, winding and depth clip mode. -#[derive(Clone, Copy, Debug)] -pub(super) struct Raster { - /// The render area's width and height, in pixels. - pub area: [u32; 2], - /// The viewport's origin and size, in pixels. - pub viewport: [f32; 4], - /// The scissor rectangle's origin and size, in pixels. - pub scissor: [u32; 4], - /// The cull mode. - pub cull: Cull, - /// The front-facing winding. - pub winding: Winding, - /// Whether depth clamps rather than clips. - pub clamp: bool, - /// The pass's samples per pixel: 1, 2 or 4. - pub samples: u32, -} - -impl Raster { - /// Metal's defaults over a render area of `area`: the viewport and scissor of the area, no - /// cull, clockwise front faces, depth clipped, one sample. - pub(super) fn over(area: [u32; 2]) -> Raster { - Raster { - area, - viewport: [0.0, 0.0, area[0] as f32, area[1] as f32], - scissor: [0, 0, area[0], area[1]], - cull: Cull::None, - winding: Winding::Clockwise, - clamp: false, - samples: 1, - } - } - - /// A tile's width and height in pixels: 32 by 32, 32 by 16 at 4 samples. - pub(super) fn tile(&self) -> [u32; 2] { - match self.samples { - 4 => [32, 16], - _ => [32, 32], - } - } - - /// The sample positions of a pixel in 1/256 units: Metal's defaults, Vulkan's standard ones - /// (a triangle holding each one alone reaches, at 2 and at 4 samples). - fn sample_offsets(&self) -> &'static [[i64; 2]] { - match self.samples { - 2 => &[[192, 192], [64, 64]], - 4 => &[[96, 32], [224, 96], [32, 160], [160, 224]], - _ => &[[128, 128]], - } - } - - /// The half-open rectangle `[x0, x1) x [y0, y1)`, in 1/256 units, that clips every - /// primitive: the viewport's, the scissor's and the render area's. - fn region(&self) -> [i64; 4] { - let [ox, oy, w, h] = self.viewport; - let along = |o: f32, e: f32| { - let (a, b) = (snap_clamped(o).0, snap_clamped(o + e).0); - (a.min(b), a.max(b)) - }; - let (vx0, vx1) = along(ox, w); - let (vy0, vy1) = along(oy, h); - let [sx, sy, sw, sh] = self.scissor.map(i64::from); - let [aw, ah] = self.area.map(i64::from); - [ - vx0.max(sx * SUBPIXEL).max(0), - vx1.min((sx + sw) * SUBPIXEL).min(aw * SUBPIXEL), - vy0.max(sy * SUBPIXEL).max(0), - vy1.min((sy + sh) * SUBPIXEL).min(ah * SUBPIXEL), - ] - } - - /// Whether the viewport's edges lie within the coordinates measured. - fn viewport_measured(&self) -> bool { - let [ox, oy, w, h] = self.viewport; - [ox, ox + w, oy, oy + h] - .into_iter() - .all(|c| snap_clamped(c).1) - } - - /// The window position of the clip-space vertex `v`, unsnapped. - fn window(&self, v: [f32; 4]) -> [f32; 2] { - let [ox, oy, w, h] = self.viewport; - let (xn, yn) = (v[0] / v[3], v[1] / v[3]); - let (px, py) = (w * 0.5, h * 0.5); - [px * xn + (ox + px), -py * yn + (oy + py)] - } -} - -/// One primitive's clip-space vertices. -#[derive(Clone, Copy, Debug)] -pub(super) enum Primitive { - /// A point and its size. - Point([f32; 4], f32), - /// A line's two ends. - Line([[f32; 4]; 2]), - /// A triangle's three vertices. - Triangle([[f32; 4]; 3]), -} - -/// Why the tiles a primitive reached may not be Metal's. -#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] -pub(super) struct Flags { - /// A primitive crossed the near or far plane under depth clipping: its reach is that of the - /// clipped polygon, whose new vertices Apple's clipper may place otherwise (unmeasured). - pub near_far: bool, - /// A case the measurements do not cover: a vertex not finite, with a subnormal component, at - /// or behind the eye, or past the coordinates measured; a viewport past them; a line of no - /// length; a point past the depth range, or of a size negative, not a number or subnormal. - pub unmeasured: bool, -} - -/// The tiles `[x, y]` that `prim`, drawn under `raster`, reaches. -pub(super) fn reach(raster: &Raster, prim: &Primitive, flags: &mut Flags) -> BTreeSet<[u32; 2]> { - let mut tiles = BTreeSet::new(); - if !raster.viewport_measured() { - flags.unmeasured = true; - } - match *prim { - Primitive::Point(v, size) => point(raster, v, size, flags, &mut tiles), - Primitive::Line(ends) => line(raster, ends, flags, &mut tiles), - Primitive::Triangle(vertices) => triangle(raster, vertices, flags, &mut tiles), - } - tiles -} - -/// Every tile of the render area, as a pass's clear reaches it. -pub(super) fn every_tile(raster: &Raster) -> BTreeSet<[u32; 2]> { - let [tw, th] = raster.tile(); - let [w, h] = raster.area; - (0..h.div_ceil(th)) - .flat_map(|y| (0..w.div_ceil(tw)).map(move |x| [x, y])) - .collect() -} - -/// The coordinate `c` snapped to 1/256, and whether it lay within the coordinates measured. -pub(super) fn snap_clamped(c: f32) -> (i64, bool) { - let scaled = f64::from(c) * SUBPIXEL as f64; - if !scaled.is_finite() { - return (0, false); - } - let limit = COORDINATE_LIMIT as f64; - if scaled.abs() >= limit { - return (scaled.clamp(-limit, limit) as i64, false); - } - (scaled.round_ties_even() as i64, true) -} - -/// The snapped window position of the clip-space vertex `v`. -fn snapped(raster: &Raster, v: [f32; 4], flags: &mut Flags) -> [i64; 2] { - let [x, y] = raster.window(v); - let (x, xi) = snap_clamped(x); - let (y, yi) = snap_clamped(y); - if !(xi && yi) { - flags.unmeasured = true; - } - [x, y] -} - -/// The planes a primitive is clipped by, as signed distances (inside where not negative): -/// `z >= 0` and `z <= w` under depth clipping. -fn depth_planes(raster: &Raster) -> Vec f32> { - let near: fn(&[f32; 4]) -> f32 = |v| v[2]; - let far: fn(&[f32; 4]) -> f32 = |v| v[3] - v[2]; - match raster.clamp { - true => Vec::new(), - false => vec![near, far], - } -} - -/// `polygon` clipped by the plane `distance` (Sutherland-Hodgman, in `f32`); a polygon of two -/// vertices is a segment. -pub(super) fn clip(polygon: &[[f32; 4]], distance: fn(&[f32; 4]) -> f32) -> Vec<[f32; 4]> { - let mut out = Vec::new(); - let n = polygon.len(); - let edges = if n == 2 { 1 } else { n }; - for i in 0..edges { - let (a, b) = (polygon[i], polygon[(i + 1) % n]); - let (da, db) = (distance(&a), distance(&b)); - if da >= 0.0 { - out.push(a); - } - if (da >= 0.0) != (db >= 0.0) { - let t = da / (da - db); - out.push([0, 1, 2, 3].map(|k| a[k] + t * (b[k] - a[k]))); - } - if n == 2 && db >= 0.0 { - out.push(b); - } - } - out -} - -/// `vertices` clipped by the depth planes (flagging a crossing) and by `w > 0` (flagging a -/// vertex at or behind the eye); empty where wholly past one plane. -fn depth_clipped(raster: &Raster, vertices: &[[f32; 4]], flags: &mut Flags) -> Vec<[f32; 4]> { - if vertices.iter().flatten().any(|c| !c.is_finite()) { - flags.unmeasured = true; - return Vec::new(); - } - if vertices.iter().flatten().any(|c| c.is_subnormal()) { - flags.unmeasured = true; - } - let mut polygon = vertices.to_vec(); - for plane in depth_planes(raster) { - if polygon.iter().all(|v| plane(v) < 0.0) { - return Vec::new(); - } - if polygon.iter().any(|v| plane(v) < 0.0) { - flags.near_far = true; - polygon = clip(&polygon, plane); - } - } - if polygon.iter().any(|v| v[3] <= 0.0) { - flags.unmeasured = true; - polygon = clip(&polygon, |v| v[3]); - } - polygon -} - -/// A triangle's reach (the module docs). -fn triangle( - raster: &Raster, - vertices: [[f32; 4]; 3], - flags: &mut Flags, - tiles: &mut BTreeSet<[u32; 2]>, -) { - let polygon = depth_clipped(raster, &vertices, flags); - if polygon.len() < 3 { - return; - } - let points: Vec<[i64; 2]> = polygon.iter().map(|&v| snapped(raster, v, flags)).collect(); - for i in 1..points.len() - 1 { - let t = [points[0], points[i], points[i + 1]]; - let area = cross(t[0], t[1], t[2]); - if area == 0 { - continue; - } - // Clockwise in window coordinates, y down, is a positive area. - let front = (area > 0) == (raster.winding == Winding::Clockwise); - let culled = match raster.cull { - Cull::None => false, - Cull::Front => front, - Cull::Back => !front, - }; - if culled || sample_culled(raster, t, area.signum()) { - continue; - } - let polygon: Vec<[i128; 2]> = t.iter().map(|p| p.map(i128::from)).collect(); - bin(raster, &polygon, 1, tiles); - } -} - -/// Twice the signed area of the triangle `a`, `b`, `c`. -fn cross(a: [i64; 2], b: [i64; 2], c: [i64; 2]) -> i128 { - let d = |p: [i64; 2], q: [i64; 2]| [i128::from(q[0] - p[0]), i128::from(q[1] - p[1])]; - let (u, v) = (d(a, b), d(a, c)); - u[0] * v[1] - u[1] * v[0] -} - -/// `n / d` rounded down. -fn floor_div(n: i128, d: i128) -> i128 { - let q = n / d; - if (n % d != 0) && ((n < 0) != (d < 0)) { - q - 1 - } else { - q - } -} - -/// `n / d` rounded up. -fn ceil_div(n: i128, d: i128) -> i128 { - -floor_div(-n, d) -} - -/// Whether the small-primitive cull drops the triangle `t` of orientation `sign`: one whose box -/// (closed) holds few sample positions and whose closed area holds none of them. The cull tests a -/// box of at most 12 positions at 1 and 2 samples and of at most 24 at 4, in every shape measured -/// (1 by 12 to 12 by 1 pixel centres; slopes from 1 in 3 to 3 in 1 at 2 and 4 samples), and -/// keeps one of more. -fn sample_culled(raster: &Raster, t: [[i64; 2]; 3], sign: i128) -> bool { - let tested = match raster.samples { - 4 => 24, - _ => 12, - }; - box_samples(raster, t) <= tested && !covers_sample(raster, t, sign) -} - -/// The sample positions the closed box of `t` holds. -fn box_samples(raster: &Raster, t: [[i64; 2]; 3]) -> i128 { - let unit = i128::from(SUBPIXEL); - let span = |axis: usize, offset: i64| { - let lo = i128::from(t.iter().map(|p| p[axis]).min().unwrap_or(0)); - let hi = i128::from(t.iter().map(|p| p[axis]).max().unwrap_or(0)); - let o = i128::from(offset); - (floor_div(hi - o, unit) - ceil_div(lo - o, unit) + 1).max(0) - }; - raster - .sample_offsets() - .iter() - .map(|&[ox, oy]| span(0, ox) * span(1, oy)) - .sum() -} - -/// Whether the closed triangle `t`, of orientation `sign`, holds a sample of the plane: row by -/// row of sample positions, the span the three edges leave holds one. -fn covers_sample(raster: &Raster, t: [[i64; 2]; 3], sign: i128) -> bool { - let unit = i128::from(SUBPIXEL); - let min_y = i128::from(t.iter().map(|p| p[1]).min().unwrap_or(0)); - let max_y = i128::from(t.iter().map(|p| p[1]).max().unwrap_or(0)); - for &[ox, oy] in raster.sample_offsets() { - let (ox, oy) = (i128::from(ox), i128::from(oy)); - for row in ceil_div(min_y - oy, unit)..=floor_div(max_y - oy, unit) { - let y = row * unit + oy; - let (mut lo, mut hi) = (i128::MIN, i128::MAX); - let mut empty = false; - for k in 0..3 { - let (a, b) = (t[k].map(i128::from), t[(k + 1) % 3].map(i128::from)); - // sign * cross(b - a, (x, y) - a) >= 0, as alpha - beta * x >= 0. - let beta = sign * (b[1] - a[1]); - let alpha = sign * ((b[0] - a[0]) * (y - a[1]) + (b[1] - a[1]) * a[0]); - match beta.signum() { - 1 => hi = hi.min(floor_div(alpha, beta)), - -1 => lo = lo.max(ceil_div(alpha, beta)), - _ => empty |= alpha < 0, - } - } - if !empty && lo <= hi && ceil_div(lo - ox, unit) <= floor_div(hi - ox, unit) { - return true; - } - } - } - false -} - -/// Add each tile the closed convex `polygon` meets, its vertices in 1/256 units times `scale`, -/// within the region of `raster`. -fn bin(raster: &Raster, polygon: &[[i128; 2]], scale: i128, tiles: &mut BTreeSet<[u32; 2]>) { - let [x0, x1, y0, y1] = raster.region().map(i128::from); - let [tw, th] = raster.tile().map(|t| i128::from(t) * i128::from(SUBPIXEL)); - let [w, h] = raster.area; - for ty in 0..h.div_ceil(raster.tile()[1]) { - for tx in 0..w.div_ceil(raster.tile()[0]) { - let (i, j) = (i128::from(tx), i128::from(ty)); - let rect = [ - x0.max(i * tw), - x1.min((i + 1) * tw), - y0.max(j * th), - y1.min((j + 1) * th), - ]; - if rect[0] < rect[1] && rect[2] < rect[3] && meets(polygon, scale, rect) { - tiles.insert([tx, ty]); - } - } - } -} - -/// Whether the closed convex `polygon` (in 1/256 units times `scale`, of non-zero area) meets -/// the half-open rectangle `[x0, x1) x [y0, y1)` (in 1/256 units): no separating axis among the -/// rectangle's two and the polygon's edge normals, the rectangle's far edges taken an -/// infinitesimal inside it (a tie on one of them separates). -fn meets(polygon: &[[i128; 2]], scale: i128, [x0, x1, y0, y1]: [i128; 4]) -> bool { - let [x0, x1, y0, y1] = [x0, x1, y0, y1].map(|c| c * scale); - let xs = polygon.iter().map(|p| p[0]); - let ys = polygon.iter().map(|p| p[1]); - let (min_x, max_x) = (xs.clone().min(), xs.max()); - let (min_y, max_y) = (ys.clone().min(), ys.max()); - let (Some(min_x), Some(max_x), Some(min_y), Some(max_y)) = (min_x, max_x, min_y, max_y) else { - return false; - }; - if !(min_x < x1 && max_x >= x0 && min_y < y1 && max_y >= y0) { - return false; - } - let n = polygon.len(); - let doubled: i128 = (0..n) - .map(|i| { - let (p, q) = (polygon[i], polygon[(i + 1) % n]); - p[0] * q[1] - p[1] * q[0] - }) - .sum(); - let sign = doubled.signum(); - for i in 0..n { - let (p, q) = (polygon[i], polygon[(i + 1) % n]); - // f(x, y) = sign * cross(q - p, (x, y) - p), not negative inside. - let gx = -sign * (q[1] - p[1]); - let gy = sign * (q[0] - p[0]); - let x = if gx > 0 { x1 } else { x0 }; - let y = if gy > 0 { y1 } else { y0 }; - let f = gx * (x - p[0]) + gy * (y - p[1]); - if f < 0 || (f == 0 && (gx > 0 || gy > 0)) { - return false; - } - } - true -} - -/// A line's reach (the module docs). -fn line(raster: &Raster, ends: [[f32; 4]; 2], flags: &mut Flags, tiles: &mut BTreeSet<[u32; 2]>) { - let segment = depth_clipped(raster, &ends, flags); - if segment.len() < 2 { - return; - } - let [p, q] = [segment[0], segment[1]].map(|v| snapped(raster, v, flags).map(i128::from)); - let (dx, dy) = (q[0] - p[0], q[1] - p[1]); - let half = i128::from(SUBPIXEL / 2); - if dx == 0 && dy == 0 { - flags.unmeasured = true; - let square = [[-1, -1], [1, -1], [1, 1], [-1, 1]] - .map(|[sx, sy]| [p[0] + sx * half, p[1] + sy * half]); - bin(raster, &square, 1, tiles); - return; - } - // Scaled by the major axis's extent: the ends move half a pixel along the major axis, along - // the line, and the sides lie half a pixel each way across it. - let x_major = dx.abs() > dy.abs(); - let scale = if x_major { dx.abs() } else { dy.abs() }; - let along = [half * dx, half * dy]; - let across = match x_major { - true => [0, half * scale], - false => [half * scale, 0], - }; - let (p, q) = (p.map(|c| c * scale), q.map(|c| c * scale)); - let start = [p[0] - along[0], p[1] - along[1]]; - let end = [q[0] + along[0], q[1] + along[1]]; - let quad = [ - [start[0] - across[0], start[1] - across[1]], - [end[0] - across[0], end[1] - across[1]], - [end[0] + across[0], end[1] + across[1]], - [start[0] + across[0], start[1] + across[1]], - ]; - bin(raster, &quad, scale, tiles); -} - -/// Where a point of `size` pixels (not negative, at most [`POINT_SIZE_LIMIT`]) reaches about its -/// snapped centre, in 1/256 units: how far back from the centre its square starts, along x and -/// along y, and its extent from there. It starts half its size back, the start rounded half up -/// (the left and top edges reach from more than half a unit past a tile's edge), and spans its -/// size rounded to the nearest 1/16 of a pixel, a half up (the right and bottom edges follow from -/// the left and top ones). -pub(super) fn point_extent(size: f32) -> (i64, i64) { - // Exact in f64: an f32 size below 512 times 256. - let units = f64::from(size) * SUBPIXEL as f64; - let back = (units / 2.0 - 0.5).ceil() as i64; - let extent = ((units / 16.0 + 0.5).floor() * 16.0) as i64; - (back, extent) -} - -/// A point's reach (the module docs). -fn point( - raster: &Raster, - v: [f32; 4], - size: f32, - flags: &mut Flags, - tiles: &mut BTreeSet<[u32; 2]>, -) { - if v.iter().any(|c| !c.is_finite()) || v[3] <= 0.0 { - flags.unmeasured = true; - return; - } - if v.iter().any(|c| c.is_subnormal()) { - flags.unmeasured = true; - } - if depth_planes(raster).iter().any(|plane| plane(&v) < 0.0) { - flags.unmeasured = true; - return; - } - let size = match size >= 0.0 { - true => size, - false => { - flags.unmeasured = true; - 0.0 - } - }; - if size.is_subnormal() { - flags.unmeasured = true; - } - let (back, extent) = point_extent(size.min(POINT_SIZE_LIMIT)); - let [cx, cy] = snapped(raster, v, flags); - let [x0, y0] = [cx - back, cy - back].map(i128::from); - let [x1, y1] = [x0, y0].map(|c| c + i128::from(extent)); - bin(raster, &[[x0, y0], [x1, y0], [x1, y1], [x0, y1]], 1, tiles); -} diff --git a/crates/metal2vulkan/src/bind/unused_bits.rs b/crates/metal2vulkan/src/bind/unused_bits.rs deleted file mode 100644 index f2578fdbc..000000000 --- a/crates/metal2vulkan/src/bind/unused_bits.rs +++ /dev/null @@ -1,602 +0,0 @@ -//! An extended-range or padded 10-bit texture's words as Metal's tile store leaves them. -//! -//! A render pass on an Apple GPU stores its attachments a 32 x 32 tile at a time. A pass that -//! loads a color attachment of an extended-range format (`BGR10_XR`, `BGRA10_XR`, -//! `RGB10A8_2P_XR10`, their `_sRGB` twins), a padded 10-bit one (`R10Unorm_X6`, -//! `RG10Unorm_X12`, their `_sRGB` twins) or `RGB10A2Unorm_sRGB` and records a draw writes every -//! texel of each tile it stores back, where a channel a fragment writes takes the write; every -//! other texel keeps its codes, the bits they leave unused made canonical (on an Apple M4 and the -//! consumer's Apple M3 Max): -//! -//! - `BGR10_XR`'s word: bits 30 and 31 set; -//! - `BGRA10_XR`'s four 16-bit fields: each field's low six bits cleared, and the alpha field's -//! code clamped to `[384, 894]`; -//! - the two-plane formats' color word: bits 30 and 31 cleared (the alpha byte kept); -//! - a padded 16-bit word: its low six bits cleared, an `_sRGB` twin's code through Metal's table -//! (`ExtendedRange::load_code`: 23 codes of `R10Unorm_X6_sRGB` move, 1021 of -//! `RG10Unorm_X12_sRGB`); -//! - `RGB10A2Unorm_sRGB`'s word: each color field's code through `R10Unorm_X6_sRGB`'s table, alpha's -//! kept (an Apple M3 Max under macOS 27.0.1: 260 of 4096 words move); -//! - a bfloat format's 16-bit code (`R16Bfloat`, `RG16Bfloat`, `RGBA16Bfloat`): its value through -//! `half` to nearest even and back to the nearest bfloat code, ties to even, a NaN `0x7fc0` -//! (`ExtendedRange::load_code`; on an Apple M4 under macOS 27.0.1: 56,829 of the -//! 65,536 codes move, in every tile a draw reaches). -//! -//! A consumer copies the region's texels, row after row, into a buffer of words, one dispatch of -//! [`unused_bits_module`] of the texture's form rewrites the words of the tiles a mask names, and -//! it copies them back before the pass: the pass's write masks, discards, tests and uncovered -//! texels then keep Metal's words. -//! -//! **The module** (one per device, format and [`TexelWords`]). One `GLCompute` entry `main` with -//! local size ([`UnusedBitsModule::LOCAL_SIZE`], 1, 1), no push constants, and three storage -//! buffers of 4-byte words in set 0: -//! -//! - [`WORDS_BINDING`](UnusedBitsModule::WORDS_BINDING): the texels, each row -//! `row_words` words (its texels, then any padding to a word), the rows of each layer -//! `layer_rows` apart, layer after layer, from the region's row `first_row`; -//! - [`TILES_BINDING`](UnusedBitsModule::TILES_BINDING): the tile mask, one bit a 32 x 32 tile -//! (bit `t % 32` of word `t / 32`), tile `t = (layer * tile_rows + y / 32) * tiles_per_row + -//! x / 32` of the texel at `(x, y)` of a layer, `tile_rows = ceil(layer_rows / 32)`; -//! - [`SHAPE_BINDING`](UnusedBitsModule::SHAPE_BINDING): `[row_words, first_row, layer_rows, -//! tiles_per_row]` ([`UnusedBitsModule::shape`]). -//! -//! Invocation `i` below the texels' words rewrites word `i` where its texel's tile's bit is set -//! (a tile past the mask's words is not); one past them writes nothing. A consumer whose words -//! exceed `maxStorageBufferRange` or `maxComputeWorkGroupCount[0]` workgroups binds them in -//! bands of rows, each with its `first_row`, one dispatch each: no word reads another. -//! -//! **Synchronization** (consumer): the copy into the words and the mask's and shape's writes -//! (`TRANSFER_WRITE`) → `SHADER_STORAGE_READ` and `SHADER_STORAGE_WRITE` in `COMPUTE_SHADER` -//! before the dispatch; its writes → `TRANSFER_READ` before the words are copied back. - -use std::sync::Arc; - -use crate::budget::{Budget, Meter}; -use crate::device::requirements::Requirements; -use crate::device::Device; -use crate::error::{Error, Feature, InternalError, InternalKind, Unsupported}; -use crate::metal::format::ExtendedRange; -use crate::metal::PixelFormat; -use crate::pipeline::sym::{ResourceKind, ResourceSlot, Stage, Symbol}; -use crate::spirv::builder::constructs::{ArmEnd, ArmFn}; -use crate::spirv::builder::{FunctionBuilder, ModuleBuilder}; -use crate::spirv::error::BResult; -use crate::spirv::ids::{GlobalId, TypeId, Value}; -use crate::spirv::ir::{ - natural_layout, BinOp, ConstBits, Constant, ExecMode, ExecModel, GlslOp, IoDir, LayoutRule, - MemAccess, StorageClass, Type, TypedModule, -}; - -/// The crate-owned unused bits module of one device, format and [`TexelWords`], validated like -/// any output: the words of the texels Metal's tile store rewrites (the module docs). -#[non_exhaustive] -#[derive(Clone, Debug, PartialEq, Eq)] -pub struct UnusedBitsModule { - /// SPIR-V 1.5 words, entry point `main`, its bindings numbered as below in set 0. - pub spirv: Arc<[u32]>, - /// What the module needs from the device (within every Vulkan 1.2 device). - pub requirements: Requirements, -} - -impl UnusedBitsModule { - /// Descriptor set of the bindings. - pub const SET: u32 = 0; - /// The texels' words, a storage buffer the dispatch rewrites in place. - pub const WORDS_BINDING: u32 = 0; - /// The tile mask, a storage buffer of one bit a tile. - pub const TILES_BINDING: u32 = 1; - /// The shape ([`shape`](Self::shape)), a storage buffer of [`SHAPE_WORDS`](Self::SHAPE_WORDS) - /// words. - pub const SHAPE_BINDING: u32 = 2; - /// Invocations of one workgroup, along x: one 4-byte word each. - pub const LOCAL_SIZE: u32 = 64; - /// The side of a tile, in texels. - pub const TILE: u32 = 32; - /// The shape's words. - pub const SHAPE_WORDS: u32 = 4; - - /// The shape's bytes: each row's words, the region's row of the first word bound, each - /// layer's rows, and the tiles of a layer's row of tiles (the module docs). - pub fn shape(row_words: u32, first_row: u32, layer_rows: u32, tiles_per_row: u32) -> [u8; 16] { - let mut bytes = [0; 16]; - for (at, word) in [row_words, first_row, layer_rows, tiles_per_row] - .into_iter() - .enumerate() - { - bytes[4 * at..4 * at + 4].copy_from_slice(&word.to_le_bytes()); - } - bytes - } - - /// The bytes of one texel of `format` held as `words`: an extended-range, padded or bfloat - /// format's raw texel (`ExtendedRange::raw_format`) or a two-plane format's color word - /// alone. `None` where `format` has no such words: another format, or - /// [`TexelWords::ColorPlane`] of a format but a two-plane one. - pub fn texel_bytes(format: PixelFormat, words: TexelWords) -> Option { - let rule = rule(format, words)?; - let form = ExtendedRange::of(format)?; - Some(match (rule, form) { - (Rule::Padded(_), ExtendedRange::R10X6 | ExtendedRange::R10X6Srgb) => 2, - (Rule::Bfloat, ExtendedRange::R16Bfloat) => 2, - (Rule::Bfloat, ExtendedRange::Rgba16Bfloat) => 8, - (Rule::Fields | Rule::PlaneTexel, _) => 8, - _ => 4, - }) - } -} - -/// How a consumer holds a texture's texels in the words it binds. -#[non_exhaustive] -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub enum TexelWords { - /// The raw texels of `ExtendedRange::raw_format`: a two-plane format's color word and then its - /// alpha byte in a word of its own. - Raw, - /// A two-plane format's color words alone, as Metal lays its plane 0 in memory (a texture over - /// a surface's planes or a heap's bytes). - ColorPlane, -} - -/// What the kernel does to each word. -#[derive(Clone, Debug, PartialEq, Eq)] -enum Rule { - /// Bits 30 and 31 set: `BGR10_XR`'s word. - OnesOnTop, - /// Bits 30 and 31 cleared: a two-plane format's color word. - ZerosOnTop, - /// A two-plane format's raw texel: the even word's bits 30 and 31 cleared, the odd word (the - /// alpha byte) kept. - PlaneTexel, - /// `BGRA10_XR`'s fields: each field's low six bits cleared, and the odd word's high field - /// (alpha) code clamped to `[384, 894]`. - Fields, - /// A padded form's two 16-bit words: each one's low six bits cleared, or each one's code - /// replaced by the table's word for it (an `_sRGB` twin's, [`rewritten_words`]). - Padded(Option>), - /// `RGB10A2Unorm_sRGB`'s word: each color field's code replaced by the table's code for it - /// (`ExtendedRange::load_code`), alpha's kept. - SrgbFields(Vec), - /// A bfloat form's two 16-bit codes: each one's value through `half` and back - /// (`ExtendedRange::load_code`, [`bfloat_load`]). - Bfloat, -} - -/// The rule of `format`'s texels held as `words`, or `None` where it has none. -fn rule(format: PixelFormat, words: TexelWords) -> Option { - extended_rule(ExtendedRange::of(format)?, words) -} - -/// The rule of an extended-range, padded or bfloat `form`'s texels held as `words`, or `None` -/// where it has none. -fn extended_rule(form: ExtendedRange, words: TexelWords) -> Option { - Some(match (form, words) { - (ExtendedRange::Bgr10 { .. }, TexelWords::Raw) => Rule::OnesOnTop, - (ExtendedRange::Bgra10 { .. }, TexelWords::Raw) => Rule::Fields, - (ExtendedRange::Planes { .. }, TexelWords::Raw) => Rule::PlaneTexel, - (ExtendedRange::Planes { .. }, TexelWords::ColorPlane) => Rule::ZerosOnTop, - (_, TexelWords::ColorPlane) => return None, - (ExtendedRange::Rgb10A2Srgb, TexelWords::Raw) => Rule::SrgbFields( - (0..1024u32) - .map(|c| form.load_code(c)) - .collect::>()?, - ), - _ if form.padded() => Rule::Padded(rewritten_words(form)), - _ if form.bfloat() => Rule::Bfloat, - _ => return None, - }) -} - -/// The mask a padded linear form's word is ANDed with: the top ten bits of each of its two 16-bit -/// words. `BGRA10_XR`'s fields take it too. -const FIELDS_MASK: u32 = 0xffc0_ffc0; -/// The color word's code bits: bits 30 and 31 apart. -const CODES: u32 = 0x3fff_ffff; -/// `BGRA10_XR`'s alpha codes Metal's store keeps. -const ALPHA_CODES: [u32; 2] = [384, 894]; - -/// The words of the codes a loading pass leaves for each code `c` of `form`, `load_code(c) << 6` -/// (`ExtendedRange::load_code`), or `None` where every code stays (the linear forms: a mask -/// does) or `form` is not padded. -fn rewritten_words(form: ExtendedRange) -> Option> { - let words: Vec = (0..1024u32) - .map(|c| form.load_code(c).map(|m| m << 6)) - .collect::>()?; - let moved = words.iter().zip(0u32..).any(|(&w, c)| w != c << 6); - moved.then_some(words) -} - -/// A `Private` `u32[1024]` holding `words`. -fn words_table(b: &mut ModuleBuilder, u32_: TypeId, words: &[u32]) -> BResult { - let len = b.constant(Constant::Scalar { - ty: u32_, - bits: ConstBits(words.len() as u64), - })?; - let arr = b.ty(Type::Array { - elem: u32_, - len, - stride: None, - })?; - let mut parts = Vec::with_capacity(words.len()); - for &w in words { - parts.push(b.constant(Constant::Scalar { - ty: u32_, - bits: ConstBits(u64::from(w)), - })?); - } - let init = b.constant(Constant::Composite { - ty: arr, - parts: parts.into(), - })?; - b.plain_global(StorageClass::Private, arr, Some(init)) -} - -/// The binding symbols of the words, the mask and the shape in the typed module. -const WORDS: ResourceSlot = ResourceSlot { - stage: Stage::Kernel, - kind: ResourceKind::Buffer, - index: 0, -}; -const TILES: ResourceSlot = ResourceSlot { - stage: Stage::Kernel, - kind: ResourceKind::Buffer, - index: 1, -}; -const SHAPE: ResourceSlot = ResourceSlot { - stage: Stage::Kernel, - kind: ResourceKind::Buffer, - index: 2, -}; - -/// A `Block { u32 words[]; }` storage buffer bound at `sym`. -fn words_buffer(b: &mut ModuleBuilder, sym: ResourceSlot, u32_: TypeId) -> BResult { - let rta = b.ty(Type::RuntimeArray { - elem: u32_, - stride: Some(4), - })?; - let layout = natural_layout(b.types(), LayoutRule::Std430, true, &[rta])?; - let block = b.ty(Type::Struct { - members: [rta].into(), - layout: Some(layout), - })?; - b.resource(sym, StorageClass::StorageBuffer, block) -} - -fn u32_value(f: &mut FunctionBuilder<'_>, v: u32) -> BResult { - let c = f.u32_const(v)?; - f.module().const_value(c) -} - -/// `rule`'s rewrite of `word`, the `odd` (a `bool`) word of its texel; `table` is a padded -/// `_sRGB` twin's table of rewritten words ([`words_table`]). -fn rewritten( - f: &mut FunctionBuilder<'_>, - rule: &Rule, - table: Option, - word: Value, - odd: Value, -) -> BResult { - Ok(match rule { - Rule::OnesOnTop => { - let top = u32_value(f, !CODES)?; - f.binary(BinOp::BitwiseOr, word, top)? - } - Rule::ZerosOnTop => { - let codes = u32_value(f, CODES)?; - f.binary(BinOp::BitwiseAnd, word, codes)? - } - Rule::PlaneTexel => { - let codes = u32_value(f, CODES)?; - let color = f.binary(BinOp::BitwiseAnd, word, codes)?; - f.select(odd, word, color)? - } - Rule::Fields => extended_range_fields(f, word, odd)?, - Rule::Padded(_) => { - let Some(table) = table else { - let mask = u32_value(f, FIELDS_MASK)?; - return f.binary(BinOp::BitwiseAnd, word, mask); - }; - // Each 16-bit word's code indexes the table of its rewritten word. - let (k6, k16) = (u32_value(f, 6)?, u32_value(f, 16)?); - let low = u32_value(f, 0xffff)?; - let table = f.module().global_value(table)?; - let lo = f.binary(BinOp::BitwiseAnd, word, low)?; - let lo = f.binary(BinOp::ShiftRightLogical, lo, k6)?; - let hi = f.binary(BinOp::ShiftRightLogical, word, k16)?; - let hi = f.binary(BinOp::ShiftRightLogical, hi, k6)?; - let lo = f.access_chain(table, &[lo])?; - let lo = f.load(lo, MemAccess::default())?; - let hi = f.access_chain(table, &[hi])?; - let hi = f.load(hi, MemAccess::default())?; - let hi = f.binary(BinOp::ShiftLeftLogical, hi, k16)?; - f.binary(BinOp::BitwiseOr, lo, hi)? - } - Rule::SrgbFields(_) => { - let table = table.ok_or(crate::spirv::error::BuildError::Operand { - op: crate::spv::Op::AccessChain, - rule: crate::spirv::error::OperandRule::NotPointer, - })?; - let table = f.module().global_value(table)?; - let field = u32_value(f, 0x3ff)?; - let alpha = u32_value(f, !CODES)?; - let mut out = f.binary(BinOp::BitwiseAnd, word, alpha)?; - for shift in [0u32, 10, 20] { - let k = u32_value(f, shift)?; - let c = f.binary(BinOp::ShiftRightLogical, word, k)?; - let c = f.binary(BinOp::BitwiseAnd, c, field)?; - let c = f.access_chain(table, &[c])?; - let c = f.load(c, MemAccess::default())?; - let c = f.binary(BinOp::ShiftLeftLogical, c, k)?; - out = f.binary(BinOp::BitwiseOr, out, c)?; - } - out - } - Rule::Bfloat => { - let (k16, low) = (u32_value(f, 16)?, u32_value(f, 0xffff)?); - let lo = f.binary(BinOp::BitwiseAnd, word, low)?; - let lo = bfloat_load(f, lo)?; - let hi = f.binary(BinOp::ShiftRightLogical, word, k16)?; - let hi = bfloat_load(f, hi)?; - let hi = f.binary(BinOp::ShiftLeftLogical, hi, k16)?; - f.binary(BinOp::BitwiseOr, lo, hi)? - } - }) -} - -/// `x >> k` rounded to nearest, ties to even (`k` at most 31, `x` below `2^30`). -fn shift_nearest_even(f: &mut FunctionBuilder<'_>, x: Value, k: Value) -> BResult { - let (zero, one) = (u32_value(f, 0)?, u32_value(f, 1)?); - let q = f.binary(BinOp::ShiftRightLogical, x, k)?; - let back = f.binary(BinOp::ShiftLeftLogical, q, k)?; - let rest = f.binary(BinOp::ISub, x, back)?; - // Twice the rest against `2^k`: past it rounds up, at it (a tie) up to an even quotient. - let twice = f.binary(BinOp::ShiftLeftLogical, rest, one)?; - let unit = f.binary(BinOp::ShiftLeftLogical, one, k)?; - let past = f.binary(BinOp::UGreaterThan, twice, unit)?; - let tie = f.binary(BinOp::IEqual, twice, unit)?; - let odd = f.binary(BinOp::BitwiseAnd, q, one)?; - let odd = f.binary(BinOp::INotEqual, odd, zero)?; - let tie_up = f.binary(BinOp::LogicalAnd, tie, odd)?; - let up = f.binary(BinOp::LogicalOr, past, tie_up)?; - let up = f.select(up, one, zero)?; - f.binary(BinOp::IAdd, q, up) -} - -/// The bfloat code a loading pass leaves for the code `code` (a `u32` below `0x10000`; -/// `ExtendedRange::load_code`): a NaN `0x7fc0`; at least `65536` in magnitude the infinity of -/// its sign; a value `half` holds (at least `2^-14`) itself; a smaller one rounded to a multiple -/// of `2^-24` (nearest, ties to even), then to the bfloat code nearest that (ties to even), its -/// sign kept. Integer operations on the bits alone, so no float mode changes the answer. -fn bfloat_load(f: &mut FunctionBuilder<'_>, code: Value) -> BResult { - let c = |f: &mut FunctionBuilder<'_>, v: u32| u32_value(f, v); - let sign_bit = c(f, 0x8000)?; - let sign = f.binary(BinOp::BitwiseAnd, code, sign_bit)?; - let magnitude_bits = c(f, 0x7fff)?; - let mag = f.binary(BinOp::BitwiseAnd, code, magnitude_bits)?; - // The code's exponent field and its significand (the hidden bit set past the subnormals). - let k7 = c(f, 7)?; - let exponent = f.binary(BinOp::ShiftRightLogical, mag, k7)?; - let fraction_bits = c(f, 0x7f)?; - let fraction = f.binary(BinOp::BitwiseAnd, mag, fraction_bits)?; - let (zero, one) = (c(f, 0)?, c(f, 1)?); - let subnormal = f.binary(BinOp::IEqual, exponent, zero)?; - let hidden = c(f, 0x80)?; - let normal = f.binary(BinOp::BitwiseOr, fraction, hidden)?; - let significand = f.select(subnormal, fraction, normal)?; - let exponent = f.select(subnormal, one, exponent)?; - // The value in units of `2^-24`, `significand * 2^(exponent - 110)`: four times the - // significand shifted right by `112 - exponent`, rounded to nearest even. - let top = c(f, 112)?; - let capped = f.glsl(GlslOp::UMin, &[exponent, top])?; - let k = f.binary(BinOp::ISub, top, capped)?; - let k31 = c(f, 31)?; - let k = f.glsl(GlslOp::UMin, &[k, k31])?; - let k2 = c(f, 2)?; - let quad = f.binary(BinOp::ShiftLeftLogical, significand, k2)?; - let units = shift_nearest_even(f, quad, k)?; - // Those units (at most `2^10`) rounded to eight significant bits, the bfloat's. - let by_two = shift_nearest_even(f, units, one)?; - let by_two = f.binary(BinOp::ShiftLeftLogical, by_two, one)?; - let by_four = shift_nearest_even(f, units, k2)?; - let by_four = f.binary(BinOp::ShiftLeftLogical, by_four, k2)?; - let (k256, k512) = (c(f, 256)?, c(f, 512)?); - let nine = f.binary(BinOp::UGreaterThanEqual, units, k256)?; - let ten = f.binary(BinOp::UGreaterThanEqual, units, k512)?; - let units = f.select(nine, by_two, units)?; - let units = f.select(ten, by_four, units)?; - // The `float` of `units * 2^-24`, its top 16 bits: the exponent field `msb + 103` and the - // bits below the most significant one. - let msb = f.glsl(GlslOp::FindUMsb, &[units])?; - let bias = c(f, 103)?; - let field = f.binary(BinOp::IAdd, msb, bias)?; - let k23 = c(f, 23)?; - let field = f.binary(BinOp::ShiftLeftLogical, field, k23)?; - let up = f.binary(BinOp::ISub, k23, msb)?; - let mantissa = f.binary(BinOp::ShiftLeftLogical, units, up)?; - let mantissa_bits = c(f, 0x7f_ffff)?; - let mantissa = f.binary(BinOp::BitwiseAnd, mantissa, mantissa_bits)?; - let bits = f.binary(BinOp::BitwiseOr, field, mantissa)?; - let k16 = c(f, 16)?; - let small = f.binary(BinOp::ShiftRightLogical, bits, k16)?; - let none = f.binary(BinOp::IEqual, units, zero)?; - let small = f.select(none, zero, small)?; - let small = f.binary(BinOp::BitwiseOr, small, sign)?; - // The value `half` holds, the infinity past it, and a NaN. - let least_normal = c(f, 0x3880)?; - let held = f.binary(BinOp::UGreaterThanEqual, mag, least_normal)?; - let out = f.select(held, code, small)?; - let overflow = c(f, 0x4780)?; - let past = f.binary(BinOp::UGreaterThanEqual, mag, overflow)?; - let infinity = c(f, 0x7f80)?; - let signed_infinity = f.binary(BinOp::BitwiseOr, infinity, sign)?; - let out = f.select(past, signed_infinity, out)?; - let nan = f.binary(BinOp::UGreaterThan, mag, infinity)?; - let quiet = c(f, 0x7fc0)?; - f.select(nan, quiet, out) -} - -/// `BGRA10_XR`'s `word`, the `odd` (a `bool`) word of its texel, with each field's low six bits -/// cleared and (the odd word's high field) alpha's code clamped to `[384, 894]`: Metal's tile -/// store. -fn extended_range_fields(f: &mut FunctionBuilder<'_>, word: Value, odd: Value) -> BResult { - let mask = u32_value(f, FIELDS_MASK)?; - let even = f.binary(BinOp::BitwiseAnd, word, mask)?; - // The odd word: red's field, then alpha's code clamped. - let low_mask = u32_value(f, FIELDS_MASK & 0xffff)?; - let low = f.binary(BinOp::BitwiseAnd, word, low_mask)?; - let k22 = u32_value(f, 22)?; - let code = f.binary(BinOp::ShiftRightLogical, word, k22)?; - let [least, most] = ALPHA_CODES; - let (least, most) = (u32_value(f, least)?, u32_value(f, most)?); - let below = f.binary(BinOp::ULessThan, code, least)?; - let code = f.select(below, least, code)?; - let above = f.binary(BinOp::UGreaterThan, code, most)?; - let code = f.select(above, most, code)?; - let high = f.binary(BinOp::ShiftLeftLogical, code, k22)?; - let odd_word = f.binary(BinOp::BitwiseOr, low, high)?; - f.select(odd, odd_word, even) -} - -/// The module as a typed module, before serialization: the module [`unused_bits_module`] -/// serializes, which the CPU interpreter runs, of `rule` over texels of `texel_bytes` bytes. Its -/// bindings are the symbols `WORDS`, `TILES` and `SHAPE`. -fn typed_module(rule: &Rule, texel_bytes: u32) -> BResult { - let mut b = ModuleBuilder::new(); - let u32_ = b.ty(Type::Int { - width: 32, - signed: false, - })?; - let uvec3 = b.ty(Type::Vector { elem: u32_, len: 3 })?; - let words = words_buffer(&mut b, WORDS, u32_)?; - let tiles = words_buffer(&mut b, TILES, u32_)?; - let shape = words_buffer(&mut b, SHAPE, u32_)?; - let table = match rule { - Rule::Padded(Some(t)) | Rule::SrgbFields(t) => Some(words_table(&mut b, u32_, t)?), - _ => None, - }; - let invocation = b.builtin(crate::spv::BuiltIn::GlobalInvocationId, IoDir::Input, uvec3)?; - let void = b.ty(Type::Void)?; - let mut f = b.function(void)?; - let zero = u32_value(&mut f, 0)?; - let invocation = f.module().global_value(invocation)?; - let invocation = f.load(invocation, MemAccess::default())?; - let i = f.composite_extract(invocation, &[0])?; - let words = f.module().global_value(words)?; - let tiles = f.module().global_value(tiles)?; - let shape = f.module().global_value(shape)?; - let count = f.array_length(words, 0)?; - let inside = f.binary(BinOp::ULessThan, i, count)?; - let rule = rule.clone(); - let rewrite: ArmFn<'_, ()> = Box::new(move |f, _| { - let shape_word = |f: &mut FunctionBuilder<'_>, at: u32| -> BResult { - let at = u32_value(f, at)?; - let p = f.access_chain(shape, &[zero, at])?; - f.load(p, MemAccess::default()) - }; - let row_words = shape_word(f, 0)?; - let first_row = shape_word(f, 1)?; - let layer_rows = shape_word(f, 2)?; - let tiles_per_row = shape_word(f, 3)?; - let (k1, k5, k31) = (u32_value(f, 1)?, u32_value(f, 5)?, u32_value(f, 31)?); - // The word's row of the region (across its layers), and its word in that row. - let row = f.binary(BinOp::UDiv, i, row_words)?; - let row = f.binary(BinOp::IAdd, first_row, row)?; - let w = f.binary(BinOp::UMod, i, row_words)?; - let layer = f.binary(BinOp::UDiv, row, layer_rows)?; - let y = f.binary(BinOp::UMod, row, layer_rows)?; - // The word's first texel: its byte in the row over the texel's bytes. - let four = u32_value(f, 4)?; - let texel = u32_value(f, texel_bytes)?; - let byte = f.binary(BinOp::IMul, w, four)?; - let x = f.binary(BinOp::UDiv, byte, texel)?; - let tile_rows = f.binary(BinOp::IAdd, layer_rows, k31)?; - let tile_rows = f.binary(BinOp::ShiftRightLogical, tile_rows, k5)?; - let tile_y = f.binary(BinOp::ShiftRightLogical, y, k5)?; - let tile_x = f.binary(BinOp::ShiftRightLogical, x, k5)?; - let tile = f.binary(BinOp::IMul, layer, tile_rows)?; - let tile = f.binary(BinOp::IAdd, tile, tile_y)?; - let tile = f.binary(BinOp::IMul, tile, tiles_per_row)?; - let tile = f.binary(BinOp::IAdd, tile, tile_x)?; - let at = f.binary(BinOp::ShiftRightLogical, tile, k5)?; - let bit = f.binary(BinOp::BitwiseAnd, tile, k31)?; - let mask_words = f.array_length(tiles, 0)?; - let named = f.binary(BinOp::ULessThan, at, mask_words)?; - // A tile past the mask's words reads as unset (its word read from 0, which exists). - let read_at = f.select(named, at, zero)?; - let p = f.access_chain(tiles, &[zero, read_at])?; - let mask = f.load(p, MemAccess::default())?; - let mask = f.binary(BinOp::ShiftRightLogical, mask, bit)?; - let mask = f.binary(BinOp::BitwiseAnd, mask, k1)?; - let set = f.binary(BinOp::INotEqual, mask, zero)?; - let set = f.binary(BinOp::LogicalAnd, set, named)?; - let odd = f.binary(BinOp::BitwiseAnd, w, k1)?; - let odd = f.binary(BinOp::INotEqual, odd, zero)?; - let p = f.access_chain(words, &[zero, i])?; - let word = f.load(p, MemAccess::default())?; - let made = rewritten(f, &rule, table, word, odd)?; - let kept = f.select(set, made, word)?; - f.store(p, kept, MemAccess::default())?; - Ok(ArmEnd::FallThrough(Vec::new())) - }); - f.if_(&mut (), inside, rewrite, None)?; - f.ret(None)?; - let id = f.finish()?; - b.entry( - ExecModel::GLCompute, - id, - vec![ExecMode::LocalSize { - x: UnusedBitsModule::LOCAL_SIZE, - y: 1, - z: 1, - }], - )?; - b.finalize() -} - -/// The fixed binding numbers of the module's symbols. -fn binding_of(sym: &Symbol) -> Option { - match sym { - Symbol::DescriptorSet(_) => Some(UnusedBitsModule::SET), - Symbol::Binding(s) if *s == WORDS => Some(UnusedBitsModule::WORDS_BINDING), - Symbol::Binding(s) if *s == TILES => Some(UnusedBitsModule::TILES_BINDING), - Symbol::Binding(s) if *s == SHAPE => Some(UnusedBitsModule::SHAPE_BINDING), - _ => None, - } -} - -/// The unused bits module of `device` for textures of `format` held as `words`: built with the -/// typed builder, checked by the owned verifier against the device's profile (requirements -/// included), serialized, and numbered with the fixed bindings of [`UnusedBitsModule`]. A format -/// that has no such words ([`UnusedBitsModule::texel_bytes`] is `None`) is -/// `NotImplemented(Format)`. -pub fn unused_bits_module( - device: &Device, - format: PixelFormat, - words: TexelWords, -) -> Result { - let (Some(rule), Some(texel_bytes)) = ( - rule(format, words), - UnusedBitsModule::texel_bytes(format, words), - ) else { - return Err(Unsupported::not_implemented(Feature::Format).into()); - }; - let profile = device.profile(); - let m = typed_module(&rule, texel_bytes)?; - let mut meter = Meter::new(&Budget::default()); - crate::spirv::verify::verify(&m, profile, &mut meter)?; - let r = crate::spirv::serialize::serialize(m)?; - profile.check(&r.requirements).map_err(|c| { - Error::Internal(InternalError::new( - InternalKind::RequirementsExceedProfile, - format!("the unused bits kernel needs {c:?}"), - )) - })?; - let words = crate::spirv::serialize::relocate(&r, &binding_of)?; - Ok(UnusedBitsModule { - spirv: words.into(), - requirements: r.requirements, - }) -} - -#[cfg(test)] -mod tests; diff --git a/crates/metal2vulkan/src/bind/unused_bits/tests.rs b/crates/metal2vulkan/src/bind/unused_bits/tests.rs deleted file mode 100644 index e481c1691..000000000 --- a/crates/metal2vulkan/src/bind/unused_bits/tests.rs +++ /dev/null @@ -1,316 +0,0 @@ -use super::{rule, typed_module, TexelWords, UnusedBitsModule, SHAPE, TILES, WORDS}; -use crate::metal::format::ExtendedRange; -use crate::metal::PixelFormat; -use crate::spirv::interp::{run, Buffer, Config, Order, Resources}; -use crate::spirv::testing::{assert_valid, committed_profiles}; - -/// Every format and the words it is held in. -fn formats() -> Vec<(PixelFormat, TexelWords)> { - let mut all = Vec::new(); - for (plain, srgb) in [ - (PixelFormat::BGR10XR, PixelFormat::BGR10XRSRGB), - (PixelFormat::BGRA10XR, PixelFormat::BGRA10XRSRGB), - (PixelFormat::RGB10A82PXR10, PixelFormat::RGB10A82PXR10SRGB), - ] { - all.push((plain, TexelWords::Raw)); - all.push((srgb, TexelWords::Raw)); - } - for format in [PixelFormat::RGB10A82PXR10, PixelFormat::RGB10A82PXR10SRGB] { - all.push((format, TexelWords::ColorPlane)); - } - for format in [ - PixelFormat::R10UnormX6, - PixelFormat::RG10UnormX12, - PixelFormat::R10UnormX6SRGB, - PixelFormat::RG10UnormX12SRGB, - PixelFormat::R16Bfloat, - PixelFormat::RG16Bfloat, - PixelFormat::RGBA16Bfloat, - ] { - all.push((format, TexelWords::Raw)); - } - all -} - -/// The module of `format` held as `words`. -fn module(format: PixelFormat, words: TexelWords) -> crate::spirv::ir::TypedModule { - let rule = rule(format, words).expect("a rule"); - let bytes = UnusedBitsModule::texel_bytes(format, words).expect("texel bytes"); - typed_module(&rule, bytes).expect("module") -} - -#[test] -fn the_unused_bits_kernel_is_valid_on_every_committed_profile() { - for (_, p) in committed_profiles().expect("profiles") { - for (format, words) in formats() { - assert_valid(module(format, words), &p); - } - } -} - -/// Only a two-plane format has color-plane words, and a format Metal's tile store keeps has no -/// rule. -#[test] -fn only_a_two_plane_format_has_color_plane_words() { - for (format, words) in formats() { - assert!(rule(format, words).is_some(), "{format:?} {words:?}"); - let plane = rule(format, TexelWords::ColorPlane).is_some(); - let two_planes = matches!( - ExtendedRange::of(format), - Some(ExtendedRange::Planes { .. }) - ); - assert_eq!(plane, two_planes, "{format:?}"); - } - for format in [ - PixelFormat::RGBA8Unorm, - PixelFormat::RGBA16Float, - PixelFormat::RG11B10Float, - PixelFormat::RGBA8Snorm, - PixelFormat::RGB9E5Float, - ] { - assert!(rule(format, TexelWords::Raw).is_none(), "{format:?}"); - assert!(UnusedBitsModule::texel_bytes(format, TexelWords::Raw).is_none()); - } -} - -/// Metal's store of `word`, the `odd` word of its texel, of `format` held as `words` (the module -/// docs), computed here apart from the kernel. -fn stored(format: PixelFormat, words: TexelWords, word: u32, odd: bool) -> u32 { - let codes = 0x3fff_ffff; - let form = ExtendedRange::of(format).expect("an extended-range, padded or bfloat form"); - match (form, words) { - (ExtendedRange::Bgr10 { .. }, _) => word | !codes, - (ExtendedRange::Planes { .. }, TexelWords::Raw) if odd => word, - (ExtendedRange::Planes { .. }, _) => word & codes, - (ExtendedRange::Bgra10 { .. }, _) if !odd => word & 0xffc0_ffc0, - (ExtendedRange::Bgra10 { .. }, _) => (word & 0xffc0) | (word >> 22).clamp(384, 894) << 22, - _ if form.bfloat() => { - let code = |h: u32| form.load_code(h).expect("a bfloat code"); - code(word & 0xffff) | code(word >> 16) << 16 - } - _ => { - let half = |h: u32| form.load_code(h >> 6).expect("a padded code") << 6; - half(word & 0xffff) | half(word >> 16) << 16 - } - } -} - -/// A splitmix64 stream: every bit of each word random. -struct Rng(u64); - -impl Rng { - fn next(&mut self) -> u32 { - self.0 = self.0.wrapping_add(0x9e37_79b9_7f4a_7c15); - let mut z = self.0; - z = (z ^ (z >> 30)).wrapping_mul(0xbf58_476d_1ce4_e5b9); - z = (z ^ (z >> 27)).wrapping_mul(0x94d0_49bb_1331_11eb); - (z ^ (z >> 31)) as u32 - } -} - -/// Run the kernel of `format` held as `words` over `bytes` with the mask `tiles` and the shape -/// `shape`, in `groups` workgroups, both invocation orders. -fn rewritten( - (format, words): (PixelFormat, TexelWords), - bytes: &[u8], - tiles: &[u32], - shape: [u8; 16], - groups: u32, -) -> Vec { - let m = module(format, words); - let mut out = Vec::new(); - for order in [Order::Forward, Order::Reverse] { - let res = Resources { - buffers: vec![ - Buffer { - slot: Some(WORDS), - address: None, - bytes: bytes.to_vec(), - }, - Buffer { - slot: Some(TILES), - address: None, - bytes: tiles.iter().flat_map(|w| w.to_le_bytes()).collect(), - }, - Buffer { - slot: Some(SHAPE), - address: None, - bytes: shape.to_vec(), - }, - ], - push: Vec::new(), - spec: Default::default(), - }; - let cfg = Config { - order, - workgroups: [groups, 1, 1], - ..Config::default() - }; - out.push(run(&m, &cfg, res).expect("run").buffers.swap_remove(0)); - } - assert_eq!(out[0], out[1], "order independent"); - out.swap_remove(0) -} - -/// A region of 70 texels a row (rows padded to a word), 40 rows a layer, 2 layers, bound from -/// row 3 on, under a mask of every third tile: each word of a set tile's texel takes Metal's -/// store, every other word stays, for every format, and invocations past the words write nothing. -#[test] -fn each_word_of_a_masked_tile_takes_metals_store_and_no_other_changes() { - let (columns, layer_rows, layers, first_row) = (70u32, 40u32, 2u32, 3u32); - let tiles_per_row = columns.div_ceil(UnusedBitsModule::TILE); - let tile_rows = layer_rows.div_ceil(UnusedBitsModule::TILE); - let tiles = layers * tile_rows * tiles_per_row; - let mask: Vec = (0..tiles.div_ceil(32)) - .map(|at| { - (0..32) - .filter(|bit| (32 * at + bit) % 3 == 0) - .fold(0, |m, bit| m | 1 << bit) - }) - .collect(); - let set = |tile: u32| tile < tiles && mask[(tile / 32) as usize] >> (tile % 32) & 1 == 1; - for (format, words) in formats() { - let texel = UnusedBitsModule::texel_bytes(format, words).unwrap(); - let row_words = (columns * texel).div_ceil(4); - let rows = layers * layer_rows - first_row; - let mut rng = Rng(u64::from(texel) << 32 | u64::from(row_words)); - let before: Vec = (0..rows * row_words).map(|_| rng.next()).collect(); - let bytes: Vec = before.iter().flat_map(|w| w.to_le_bytes()).collect(); - let groups = (before.len() as u32).div_ceil(UnusedBitsModule::LOCAL_SIZE) + 1; - let shape = UnusedBitsModule::shape(row_words, first_row, layer_rows, tiles_per_row); - let after = rewritten((format, words), &bytes, &mask, shape, groups); - let (mut changed, mut kept) = (0, 0); - for (i, (&word, got)) in before.iter().zip(after.chunks(4)).enumerate() { - let i = i as u32; - let row = first_row + i / row_words; - let w = i % row_words; - let (layer, y) = (row / layer_rows, row % layer_rows); - let x = 4 * w / texel; - let tile = (layer * tile_rows + y / 32) * tiles_per_row + x / 32; - let want = match set(tile) { - true => stored(format, words, word, w % 2 == 1), - false => word, - }; - let got = u32::from_le_bytes([got[0], got[1], got[2], got[3]]); - assert_eq!( - got, want, - "{format:?} {words:?} word {i} (row {row}, word {w}, tile {tile}): {word:08x}" - ); - match got == word { - true => kept += 1, - false => changed += 1, - } - } - assert!(changed > 0 && kept > 0, "{format:?} {words:?}"); - } -} - -/// Every 16-bit word of a padded linear form keeps its top ten bits and loses its low six, and an -/// `_sRGB` twin's takes its code's load code (`ExtendedRange::load_code`: 23 codes of -/// `R10Unorm_X6_sRGB` move, 1021 of `RG10Unorm_X12_sRGB`), every value of a word among them, -/// under a mask of every tile, across several workgroups. -#[test] -fn every_padded_word_takes_its_code_s_load_code_with_its_low_six_bits_zeroed() { - let halves: Vec = (0..=u16::MAX).collect(); - let bytes: Vec = halves.iter().flat_map(|h| h.to_le_bytes()).collect(); - let words = (bytes.len() / 4) as u32; - let groups = words.div_ceil(UnusedBitsModule::LOCAL_SIZE) + 1; - for format in [ - PixelFormat::R10UnormX6, - PixelFormat::RG10UnormX12, - PixelFormat::R10UnormX6SRGB, - PixelFormat::RG10UnormX12SRGB, - ] { - let form = ExtendedRange::of(format).expect("a padded form"); - let moved = (0..1024).filter(|&c| form.load_code(c) != Some(c)).count(); - let want_moved = match form { - ExtendedRange::R10X6Srgb => 23, - ExtendedRange::Rg10X12Srgb => 1021, - _ => 0, - }; - assert_eq!(moved, want_moved, "{form:?}"); - let want: Vec = halves - .iter() - .flat_map(|&h| { - let c = form.load_code(u32::from(h >> 6)).expect("a padded code"); - (u16::try_from(c << 6).expect("a word")).to_le_bytes() - }) - .collect(); - // One row of every word: its texels' tiles all set. - let texel = UnusedBitsModule::texel_bytes(format, TexelWords::Raw).unwrap(); - let tiles_per_row = (4 * words / texel).div_ceil(32); - let mask = vec![u32::MAX; tiles_per_row.div_ceil(32) as usize]; - let shape = UnusedBitsModule::shape(words, 0, 1, tiles_per_row); - assert_eq!( - rewritten((format, TexelWords::Raw), &bytes, &mask, shape, groups), - want, - "{form:?}" - ); - } -} - -/// Every code of each bfloat form takes its load code (`ExtendedRange::load_code`, measured for -/// every code), under a mask of every tile, across several workgroups: 56,829 -/// codes move (the NaNs to `0x7fc0`, the magnitudes from 65,536 to infinity, those below -/// `2^-14` to `half`'s step), the 8,707 others stay. -#[test] -fn every_bfloat_code_takes_its_load_code() { - let codes: Vec = (0..=u16::MAX).collect(); - let bytes: Vec = codes.iter().flat_map(|h| h.to_le_bytes()).collect(); - let words = (bytes.len() / 4) as u32; - let groups = words.div_ceil(UnusedBitsModule::LOCAL_SIZE) + 1; - for format in [ - PixelFormat::R16Bfloat, - PixelFormat::RG16Bfloat, - PixelFormat::RGBA16Bfloat, - ] { - let form = ExtendedRange::of(format).expect("a bfloat form"); - let load = |c: u16| form.load_code(u32::from(c)).expect("a bfloat code"); - let moved = codes.iter().filter(|&&c| load(c) != u32::from(c)).count(); - assert_eq!(moved, 56_829, "{form:?}"); - // A few of Metal's answers: the NaNs, an overflow, the codes `half` - // holds, and the double rounding below `2^-14`. - for (code, metal) in [ - (0x7f81, 0x7fc0), - (0xffff, 0x7fc0), - (0xff7a, 0xff80), - (0x4780, 0x7f80), - (0x477f, 0x477f), - (0x3880, 0x3880), - (0x8001, 0x8000), - (0x0001, 0x0000), - (0x3301, 0x3380), - ] { - assert_eq!(load(code), metal, "{form:?} {code:#06x}"); - } - let want: Vec = codes - .iter() - .flat_map(|&c| (u16::try_from(load(c)).expect("a code")).to_le_bytes()) - .collect(); - let texel = UnusedBitsModule::texel_bytes(format, TexelWords::Raw).unwrap(); - let tiles_per_row = (4 * words / texel).div_ceil(32); - let mask = vec![u32::MAX; tiles_per_row.div_ceil(32) as usize]; - let shape = UnusedBitsModule::shape(words, 0, 1, tiles_per_row); - assert_eq!( - rewritten((format, TexelWords::Raw), &bytes, &mask, shape, groups), - want, - "{form:?}" - ); - } -} - -/// A mask of no word leaves every word, and a tile past the mask's words reads as unset. -#[test] -fn a_tile_past_the_mask_is_not_rewritten() { - let form = (PixelFormat::BGR10XR, TexelWords::Raw); - // Two layers of one row of 64 texels, 40 tiles a row: the first row's tiles 0 and 1 are the - // mask's one word's bits 0 and 1 (tile 0 set), and the second's, 40 and 41, lie past it. - let bytes = vec![0u8; 4 * 128]; - let shape = UnusedBitsModule::shape(64, 0, 1, 40); - let after = rewritten(form, &bytes, &[0b01], shape, 2); - for (i, word) in after.chunks(4).enumerate() { - let word = u32::from_le_bytes([word[0], word[1], word[2], word[3]]); - let want = if i < 32 { 0xc000_0000 } else { 0 }; - assert_eq!(word, want, "word {i}"); - } -} diff --git a/crates/metal2vulkan/src/cache/codec.rs b/crates/metal2vulkan/src/cache/codec.rs index 92ba9eb92..558ed8ce6 100644 --- a/crates/metal2vulkan/src/cache/codec.rs +++ b/crates/metal2vulkan/src/cache/codec.rs @@ -53,8 +53,8 @@ use crate::pipeline::layout::{ BindingSource, DescriptorBinding, DescriptorSetLayout, PipelineLayout, PushConstantRange, }; use crate::pipeline::lower_inputs::{ - BlendEquation, CaptureForm, ChannelWrite, ColorGroup, ExtendedRangeColor, FactorLane, - RotatedBlendForm, VertexFetch, + BlendEquation, ChannelWrite, ColorGroup, ExtendedRangeColor, FactorLane, RotatedBlendForm, + VertexFetch, }; use crate::pipeline::stage_io::{ CoverageLoop, CoverageLoopRefusal, DepthCompares, DepthMode, Interpolation as IoInterpolation, @@ -876,7 +876,6 @@ codec_enum! { VertexDepthClamp, BlendColor, ShaderTestsState, - CaptureAddress, CaptureLayout, CaptureIndexAddress, StorageKeptChannels, @@ -1176,7 +1175,6 @@ codec_enum! { WordAttachment { Packed16 { fields }, Srgb8 { fields }, Rgb9e5 } FactorLane { Zero, One, Output(f0) } RotatedBlendForm { Premultiplied, Unmeasured } - CaptureForm { Vertices, Indexed(f0) } TextureWriteRoundingMode { TowardZero, NearestEven } CompareFunction { Never, Less, Equal, LessEqual, Greater, NotEqual, GreaterEqual, Always } CoverageLoopRefusal { @@ -1247,7 +1245,6 @@ codec_enum! { CubicSampler { slot }, CubicArgumentSampler { stage }, ShaderTests { formatless, multisampled, planes }, - CapturedPositions { form }, HeapRawSamples { stage, sampler }, ShaderStencilTest { formatless }, ExtendedRangeInputBlend { color, blend, kept }, diff --git a/crates/metal2vulkan/src/cache/mod.rs b/crates/metal2vulkan/src/cache/mod.rs index 86f7fcb47..d9880d6dc 100644 --- a/crates/metal2vulkan/src/cache/mod.rs +++ b/crates/metal2vulkan/src/cache/mod.rs @@ -36,7 +36,7 @@ use std::fmt; pub use crate::air::container::Hash256; use crate::device::Device; -use crate::pipeline::lower_inputs::{CaptureForm, StorageImageChoice}; +use crate::pipeline::lower_inputs::StorageImageChoice; use crate::pipeline::sym::{SlotRef, SnapshotForm}; use crate::vk; @@ -60,7 +60,7 @@ mod tests; /// unchanged version, and its bless records the version. Independent of the crate's version and of /// [`ARTIFACT_FORMAT_VERSION`]. The commit that bumps it says what changed; this comment keeps no /// history. -pub const SEMANTICS_VERSION: u32 = 1909; +pub const SEMANTICS_VERSION: u32 = 1910; /// The byte-layout version of encoded artifacts (`CompiledFunction::to_bytes` and the /// [`PipelineArtifact`] encodings). Every encoded artifact carries it, and a decode under another @@ -93,7 +93,7 @@ pub const ARTIFACT_FORMAT_VERSION: u32 = 476; /// changes no behaviour, and then updates that hash alone with the commit saying why, or changes /// behaviour and also bumps this version. The commit that bumps it says what changed; this comment /// keeps no history. -pub const RUNTIME_VERSION: u32 = 1681; +pub const RUNTIME_VERSION: u32 = 1682; /// The digest of the sources this build of the crate was compiled from: SHA-256, as lowercase hex, /// of the manifest, the build script, and exactly the files the crate roots' module tree compiles @@ -379,14 +379,6 @@ pub struct VariantKey { serde(default, with = "crate::pipeline::serde_pairs") )] pub cubic_samplers: BTreeMap, - /// The capture form of the vertex function (`LoweringInputs::captured_positions`): besides - /// its outputs, each vertex it runs writes Metal's clip position and point size to a record - /// at `PushHole::CaptureAddress`, the positions a tile reach kernel bins, for the draws of - /// its [`CaptureForm`]. A consumer asks for it itself (no bind shape does), for a draw it runs - /// again before its pass, and the plan of a pipeline compiled under it states it; a draw of - /// the other form is `BindError::NeedsVariant` with that form. - #[cfg_attr(feature = "serde", serde(default))] - pub captured_positions: Option, /// The de-indexed form of a pipeline whose vertex function writes the primitive ID's varying /// (`LoweringInputs::primitive_id_indices`, `BindShape::primitive_id_indices`): the vertex /// function of an indexed draw of this index type runs the draw's indices as `index count` @@ -547,7 +539,6 @@ impl VariantKey { && !self.shader_stencil && !self.window_depth_varying && self.cubic_samplers.is_empty() - && self.captured_positions.is_none() && self.primitive_id_indices.is_none() && !self.quad_primitive_ids && !self.private_list @@ -564,7 +555,7 @@ impl VariantKey { /// the fragment function the colors it writes zero to and those it drops, its depth's clamp /// range and whether its draws' tests are read-only, for a tile function the imageblock bytes /// its pass keeps, and for the vertex function the - /// dropped `Layer` output, the viewport compensation, the window depth and the capture form + /// dropped `Layer` output, the viewport compensation and the window depth /// (a vertex function's projection is /// derived from the vertex descriptor and /// [`pulled_vertex_buffers`](VariantKey::pulled_vertex_buffers) when the pipeline compiles, @@ -685,9 +676,6 @@ impl VariantKey { } out.window_depth_varying = self.window_depth_varying && stage == crate::pipeline::sym::Stage::Vertex; - out.captured_positions = self - .captured_positions - .filter(|_| stage == crate::pipeline::sym::Stage::Vertex); out.primitive_id_indices = self .primitive_id_indices .filter(|_| stage == crate::pipeline::sym::Stage::Vertex); diff --git a/crates/metal2vulkan/src/cache/tests.rs b/crates/metal2vulkan/src/cache/tests.rs index 1e35e6e55..f842a8c52 100644 --- a/crates/metal2vulkan/src/cache/tests.rs +++ b/crates/metal2vulkan/src/cache/tests.rs @@ -1294,76 +1294,6 @@ fn the_dropped_vertex_layer_variant_round_trips() { } } -/// A render pipeline whose vertex function is compiled in a capture form round trips with its -/// `CapturedPositions` fact and its capture push fields (the index address in the indexed form), -/// and the decoded pipeline's plan states the variant, so a cached capture variant settles as the -/// compiled one does. -#[test] -fn the_captured_positions_variant_round_trips() { - use crate::cache::VariantKey; - use crate::pipeline::facts::RuntimeFact; - use crate::pipeline::sym::PushField; - use crate::pipeline::CaptureForm; - let dev = device("moltenvk-m3"); - let Some(bc) = fixture("rch_vertex_math") else { - return; - }; - let f = Library::from_air(&bc) - .and_then(|lib| lib.function("rch_vertex_math")) - .expect("vertex"); - let d = RenderPipelineDescriptor::new(StageSource::Function(FunctionDescriptor::new(f))); - for form in [ - CaptureForm::Vertices, - CaptureForm::Indexed(crate::metal::IndexType::UInt16), - ] { - let mut key = VariantKey::new(); - key.captured_positions = Some(form); - let pipeline = dev - .compile_render_variant(&d, &key, &Budget::standard()) - .expect("pipeline"); - let decoded = RenderPipeline::from_bytes(&pipeline.to_bytes(), &dev).expect("decoded"); - assert_eq!(decoded, pipeline); - assert!(decoded - .dependencies - .iter() - .any(|d| d.fact == RuntimeFact::CapturedPositions { form })); - let placed = |field| { - decoded - .interface - .push - .iter() - .any(|p| p.fields.iter().any(|f| f.field == field)) - }; - assert!(placed(PushField::CaptureAddress), "{form:?}"); - assert!(placed(PushField::CaptureLayout), "{form:?}"); - assert_eq!( - placed(PushField::CaptureIndexAddress), - form != CaptureForm::Vertices, - "{form:?}" - ); - check_plan(&decoded, &dev, &key); - } -} - -/// `decoded`'s plan for `rch_vertex_math`'s buffers states `key`. -fn check_plan(decoded: &RenderPipeline, dev: &Device, key: &crate::cache::VariantKey) { - use crate::bind::{BindState, BoundBuffer, StageTable}; - let buffer = |length| BoundBuffer::Buffer { - length, - offset: 0, - gpu_address: 0x1_0000, - device_address: Some(0x7_0000_0000), - attribute_stride: None, - }; - let mut vertex = StageTable::default(); - vertex.buffers.insert(0, buffer(1024)); - vertex.buffers.insert(1, buffer(256)); - let mut state = BindState::default(); - state.stages.insert(Stage::Vertex, vertex); - let plan = decoded.plan(dev, &state.shape()).expect("plan"); - assert_eq!(&plan.variant, key); -} - /// A render pipeline compiled under the amplification draws variant round trips with its fact and /// its amplification push fields, and the decoded pipeline's plan for a state whose amplification /// multiview cannot express states the variant, so a cached variant settles as the compiled one diff --git a/crates/metal2vulkan/src/device/driver_facts.rs b/crates/metal2vulkan/src/device/driver_facts.rs index 26020bce5..67531f765 100644 --- a/crates/metal2vulkan/src/device/driver_facts.rs +++ b/crates/metal2vulkan/src/device/driver_facts.rs @@ -307,24 +307,16 @@ pub(crate) fn among( /// /// `MetalDepth16BiasedStores`, measured by /// `runtime_lane::unorm_depth_bias::a_constant_bias_on_a_16_bit_unorm_depth_stores_metals_codes` -/// (every depth and constant of the probes' draws, each biased by the device: our probe at -/// d51c2aa8, 2026-10-07): -/// - RADV, Mesa 26.2.4 on the Radeon 780M, through `VK_EXT_depth_bias_control`'s float -/// representation with `depthBiasExact`: every code Metal's. -/// - MoltenVK 1.4.1 on Apple's GPUs, which takes Metal's constant in Metal's own unit (it has no -/// `VK_EXT_depth_bias_control`): every code Metal's on an M4 mini. On -/// every Apple GPU by construction: MoltenVK 1.4.1 hands the recorded constant, slope and clamp -/// unchanged to the render encoder's `setDepthBias:slopeScale:clamp:` +/// (every depth and constant of the probes' draws, each biased by the device): +/// - MoltenVK 1.4.1 on Apple's GPUs, which takes Metal's constant in Metal's own unit: every code +/// Metal's on an M4 mini. On every Apple GPU by construction: MoltenVK 1.4.1 hands the recorded +/// constant, slope and clamp unchanged to the render encoder's `setDepthBias:slopeScale:clamp:` /// (`MVKCommandEncoderState.mm`) and makes the depth Metal's own `Depth16Unorm` /// (`MVKPixelFormats.mm`), so Metal biases and stores the depth on whichever Apple GPU runs it. /// -/// Measured not to have it, so not listed, each storing the code next to Metal's for a sum near a -/// code's midpoint: ANV, Mesa 26.2.4 on the Iris Xe (RPL-P), which rounds the sum to nearest, not -/// toward zero; lavapipe, Mesa 26.0.8 on LLVM 21.1.8, x86_64 (the linux-gate container), which also -/// scales it by 65535 as a `float` (0 biased by 0.5 stored as 2 where Metal's is 1); NVIDIA's -/// 615.71.09 on the RTX 5080 Laptop GPU, through `depthBiasExact` in 2^-16, whose conversion of -/// every depth rounds down near a midpoint (`MetalDepth16Stores` above). ANV on the UHD 770 (RPL-S) -/// is unmeasured. +/// Not listed: every other driver. Each biases Metal's constant `c` by its own unit (Vulkan's `r` +/// of a 16-bit unorm depth, at most twice 2^-16), where Metal biases by `c + 1` units of 1/65535 +/// (`c - 1` below 0), so a constant bias stores another code than Metal's. /// /// `MetalInterpolation`: MoltenVK 1.4.1 hands each fragment input to Metal with its /// interpolation (SPIRV-Cross `adec7acb` writes it as a `[[user(...)]]` input qualified @@ -600,11 +592,6 @@ pub(crate) const DEVIATIONS: &[Measured] = &[ (INTEL_VENDOR_ID, INTEL_UHD_770_RPL_S), ), moltenvk_on_apple(DriverDeviation::MetalDepth16Stores), - mesa_on( - DriverDeviation::MetalDepth16BiasedStores, - DriverId::MESA_RADV, - (AMD_VENDOR_ID, AMD_RADEON_780M), - ), moltenvk_on_apple(DriverDeviation::MetalDepth16BiasedStores), moltenvk_on_apple(DriverDeviation::MetalInterpolation), moltenvk_on_apple(DriverDeviation::MetalFirstVertexIndices), diff --git a/crates/metal2vulkan/src/device/enables.rs b/crates/metal2vulkan/src/device/enables.rs index ed61241db..52035d449 100644 --- a/crates/metal2vulkan/src/device/enables.rs +++ b/crates/metal2vulkan/src/device/enables.rs @@ -348,7 +348,6 @@ fn facts(ext: VkExtension) -> ExtensionFacts { | E::KhrMaintenance8 | E::KhrShaderFma | E::ExtDepthRangeUnrestricted - | E::ExtDepthBiasControl | E::ExtDepthClipEnable | E::ExtDepthClampControl | E::ExtSampleLocations @@ -388,6 +387,9 @@ fn facts(ext: VkExtension) -> ExtensionFacts { | E::KhrShaderSubgroupRotate => fact(true, Some(4), &[]), // Enabled only as another extension's requirement. E::ExtCustomBorderColor => fact(false, None, &[]), + // Described, never enabled: a depth bias counts the device's own unit + // (`metal::state::depth_bias`), so the core reads none of its features. + E::ExtDepthBiasControl => fact(false, None, &[]), E::KhrDynamicRendering => fact(false, Some(3), &[]), // Object and mesh functions. `VK_KHR_spirv_1_4` is core at the 1.2 floor. E::ExtMeshShader => fact(true, None, &[]), diff --git a/crates/metal2vulkan/src/device/mechanism.rs b/crates/metal2vulkan/src/device/mechanism.rs index 8a4cf9461..067fcdeaa 100644 --- a/crates/metal2vulkan/src/device/mechanism.rs +++ b/crates/metal2vulkan/src/device/mechanism.rs @@ -222,9 +222,6 @@ pub fn mechanism(fact: &RuntimeFact, profile: &DeviceProfile) -> Mechanism { // The planner admits a listed cubic sampler beside the stage's sampler table; the // function marks the `ExecutionStatus` buffer where it reaches one. RuntimeFact::CubicArgumentSampler { .. } => Mechanism::PlanTimeCheck, - // A pipeline compiled in the capture form, which a consumer asks for; its plans state - // it, and the binder writes each draw's capture layout. - RuntimeFact::CapturedPositions { .. } => Mechanism::Variant, // The planner refuses a texture a heap holds by its raw texels alone that a plan names // beside the stage; a consumer's own heap announces one. RuntimeFact::HeapRawSamples { .. } => Mechanism::PlanTimeCheck, diff --git a/crates/metal2vulkan/src/device/requirements.rs b/crates/metal2vulkan/src/device/requirements.rs index 0c2575f1e..38dd9f435 100644 --- a/crates/metal2vulkan/src/device/requirements.rs +++ b/crates/metal2vulkan/src/device/requirements.rs @@ -770,9 +770,9 @@ pub enum VkProperty { /// The device stores every depth a draw biases on a `Depth16Unorm` attachment as Metal's code /// (the driver's measured deviation /// [`DriverDeviation::MetalDepth16BiasedStores`](crate::error::DriverDeviation::MetalDepth16BiasedStores)). - /// No Vulkan query reports it: Vulkan leaves the biased sum's rounding to the device. No module - /// requires it: every biased depth is the device's own, and where the profile lacks it the - /// runtime announces `unorm-depth-bias`. + /// No Vulkan query reports it: Vulkan leaves the bias's unit and the biased sum's rounding to + /// the device. No module requires it: every biased depth is the device's own, and where the + /// profile lacks it the runtime announces `unorm-depth-bias`. MetalDepth16BiasedStores, /// The device interpolates a varying as Metal does, bit for bit (the driver's measured /// deviation diff --git a/crates/metal2vulkan/src/device/tests/driver_facts.rs b/crates/metal2vulkan/src/device/tests/driver_facts.rs index b2205ed13..34fecdf43 100644 --- a/crates/metal2vulkan/src/device/tests/driver_facts.rs +++ b/crates/metal2vulkan/src/device/tests/driver_facts.rs @@ -281,7 +281,6 @@ fn the_profile_takes_the_deviations_its_driver_is_measured_with() { D::MetalHalfTexelWrites, D::MetalNormStorageWrites, D::MetalDepth16Stores, - D::MetalDepth16BiasedStores, ], (false, "intel-irisxe-rplp-anv") => vec![ D::MetalFloatDenormals, diff --git a/crates/metal2vulkan/src/device/tests/enables.rs b/crates/metal2vulkan/src/device/tests/enables.rs index c2bd96ba6..fa9a1be5b 100644 --- a/crates/metal2vulkan/src/device/tests/enables.rs +++ b/crates/metal2vulkan/src/device/tests/enables.rs @@ -67,16 +67,26 @@ fn recommendations_are_closed_fixed_points_on_every_committed_profile() { } // Every listed feature with a member is recommended (the committed profiles list only // exposed features whose extensions' requirements are listed), except the buffer - // update-after-bind features VUID 10247 forbids beside `robustBufferAccess`. + // update-after-bind features VUID 10247 forbids beside `robustBufferAccess`, and + // `VK_EXT_depth_bias_control`'s, an extension the core reads nothing of. let forbidden = |f: VkFeature| { !desc.robust_buffer_access_update_after_bind && desc.has(VkFeature::RobustBufferAccess) && BUFFER_UPDATE_AFTER_BIND.contains(&f) }; + let unread = [ + VkFeature::DepthBiasControl, + VkFeature::FloatRepresentation, + VkFeature::DepthBiasExact, + ]; + assert!( + !rec.extensions.contains(&VkExtension::ExtDepthBiasControl), + "{stem}" + ); for &f in &desc.features { assert_eq!( rec.features.contains(&f), - f.exposure().has_member(desc.api_version) && !forbidden(f), + f.exposure().has_member(desc.api_version) && !forbidden(f) && !unread.contains(&f), "{stem}: {f:?}" ); if forbidden(f) { diff --git a/crates/metal2vulkan/src/device/tests/mechanism.rs b/crates/metal2vulkan/src/device/tests/mechanism.rs index 025321b28..86ae169c1 100644 --- a/crates/metal2vulkan/src/device/tests/mechanism.rs +++ b/crates/metal2vulkan/src/device/tests/mechanism.rs @@ -188,9 +188,6 @@ fn every_fact() -> Vec { planes: true, }, RuntimeFact::StorageTextureIntegerChannels { slot }, - RuntimeFact::CapturedPositions { - form: crate::pipeline::CaptureForm::Indexed(crate::metal::IndexType::UInt16), - }, RuntimeFact::HeapRawSamples { stage: Stage::Fragment, sampler: Some(1), @@ -334,7 +331,6 @@ fn variant(f: &RuntimeFact) -> usize { RuntimeFact::CubicSampler { .. } => 68, RuntimeFact::CubicArgumentSampler { .. } => 69, RuntimeFact::ShaderTests { .. } => 70, - RuntimeFact::CapturedPositions { .. } => 72, RuntimeFact::HeapRawSamples { .. } => 73, RuntimeFact::ShaderStencilTest { .. } => 74, RuntimeFact::ExtendedRangeInputBlend { .. } => 75, @@ -349,7 +345,7 @@ fn variant(f: &RuntimeFact) -> usize { RuntimeFact::ObjectThreadgroupArena { .. } => 85, RuntimeFact::WordInputMerge { .. } => 87, RuntimeFact::ReplayBindings => 88, - RuntimeFact::MergedDraws => 89, + RuntimeFact::MergedDraws => 72, RuntimeFact::QuadPrimitiveIds => 58, RuntimeFact::RotatedWeights => 82, RuntimeFact::PrivateList => 86, @@ -362,7 +358,7 @@ fn variant(f: &RuntimeFact) -> usize { fn mechanism_is_total_over_every_fact_and_profile() { let facts = every_fact(); let covered: std::collections::BTreeSet = facts.iter().map(variant).collect(); - assert_eq!(covered, (0..90).collect(), "every_fact misses a variant"); + assert_eq!(covered, (0..89).collect(), "every_fact misses a variant"); for (stem, _) in super::committed_profiles() { let dev = device(&stem); let p = dev.profile(); @@ -445,8 +441,7 @@ fn mechanism_is_total_over_every_fact_and_profile() { | RuntimeFact::MovableStorageWrites { .. } | RuntimeFact::ConstexprSampled { .. } | RuntimeFact::CubicSampler { .. } - | RuntimeFact::AnisotropicSampler { .. } - | RuntimeFact::CapturedPositions { .. } => Mechanism::Variant, + | RuntimeFact::AnisotropicSampler { .. } => Mechanism::Variant, RuntimeFact::ImageViewShape { .. } | RuntimeFact::StorageTextureLevelViews { .. } | RuntimeFact::UlongAtomicView { .. } => Mechanism::BinderView, diff --git a/crates/metal2vulkan/src/error/mod.rs b/crates/metal2vulkan/src/error/mod.rs index 5bfba6c9c..2dad0af32 100644 --- a/crates/metal2vulkan/src/error/mod.rs +++ b/crates/metal2vulkan/src/error/mod.rs @@ -764,11 +764,11 @@ pub enum DriverDeviation { /// `unorm-depth-rounding` at a draw that tests or writes such a depth. MetalDepth16Stores, /// The device stores every depth a draw biases on a `Depth16Unorm` attachment as Metal's code, - /// the bias recorded as [`depth_bias`](crate::metal::state::depth_bias) records it - /// (`VkProperty::MetalDepth16BiasedStores`): Metal biases by `c ± 1` units of 1/65535 as - /// `float` (one unit for a slope alone), adds the bias to the depth rounding toward zero, and - /// stores the sum rounded to nearest, a tie up. Vulkan leaves the sum's rounding, and without - /// `depthBiasExact` the unit, to the device. Every biased depth is the device's own, the + /// Metal's constant recorded in the device's unit as [`depth_bias`](crate::metal::state::depth_bias) + /// records it (`VkProperty::MetalDepth16BiasedStores`): Metal biases by `c ± 1` units of + /// 1/65535 as `float` (one unit for a slope alone), adds the bias to the depth rounding toward + /// zero, and stores the sum rounded to nearest, a tie up. Vulkan leaves the unit (at most twice + /// 2^-16) and the sum's rounding to the device. Every biased depth is the device's own, the /// attachment's fixed-function bias applied; no module reads the deviation. Unmeasured, the /// runtime announces `unorm-depth-bias` at a draw that biases such a depth by a constant, or /// by a slope alone. @@ -1443,16 +1443,6 @@ pub enum Feature { /// the interlocked storage form, where Metal's measured model does not hold the part it names /// ([`ExtendedRangeBlend`]). Every other such blend is Metal's arithmetic, bit for bit. ExtendedRangeBlend(ExtendedRangeBlend), - /// The tiles a render pass's primitives reach, binned on the device - /// ([`tile_reach_module`](crate::bind::tile_reach_module)), on a device without what the - /// kernel's exact arithmetic needs: `shaderInt64` ([`Needs::AnyOf`]). Also the capture form - /// of a vertex function, whose records hold the positions the kernel bins - /// (`LoweringInputs::captured_positions`): on a device without device addresses or - /// `vertexPipelineStoresAndAtomics` (naming what it needs), and, not implemented, for a - /// post-tessellation vertex function, an attribute a hand-built projection fetches in fixed - /// function under the indexed form, an indirect or amplified draw, and an indexed draw whose - /// indices run past its buffer or whose index offset is not a multiple of the index size. - TileReach, /// A program-scope buffer binding of MSL 3.2 (macOS 15 and later), `constant T* constant p /// [[buffer(n)]];` in Apple's `!air.global_bindings` list, valid AIR this version does not /// implement yet. @@ -1947,9 +1937,8 @@ pub enum BindError { /// and instantiates the dispatch there. Nothing is dispatched on the plan asked. A draw answers /// it when the pipeline planned is not the variant its vertex function's render target slice /// asks for at the shape's render target array length (`VariantKey::dropped_vertex_layer`); - /// `variant` is then the plan's own. A draw of a capture variant answers it when the draw is of - /// the other capture form (`VariantKey::captured_positions`): `variant` is the plan's with the - /// draw's form. Boxed: a key holds a set per kind of variant, and the error stays small. + /// `variant` is then the plan's own. Boxed: a key holds a set per kind of variant, and the + /// error stays small. NeedsVariant { variant: Box, }, @@ -2018,9 +2007,10 @@ pub enum BindError { /// not a mesh render pipeline, or a draw of primitives or patches with one (Metal ends the /// process on `drawPrimitives` with a mesh pipeline state). InvalidMeshDraw { mesh: bool }, - /// An indexed draw of an indexed capture variant (`CaptureForm::Indexed`) whose bind state - /// names no primitive type (`BindState::primitive_type`): whether the draw restarts at the - /// index type's all-ones index, where Metal shades no vertex, depends on it. + /// A draw of a pipeline whose vertex function writes the primitive ID + /// (`LoweringInputs::primitive_id_varying`) whose bind state names no primitive type + /// (`BindState::primitive_type`): its vertices per primitive, and whether an indexed draw + /// runs de-indexed (a strip's does not), depend on it. MissingPrimitiveType, } diff --git a/crates/metal2vulkan/src/lower/arith/extended_range/tests.rs b/crates/metal2vulkan/src/lower/arith/extended_range/tests.rs index 84e0fce89..81d2748e9 100644 --- a/crates/metal2vulkan/src/lower/arith/extended_range/tests.rs +++ b/crates/metal2vulkan/src/lower/arith/extended_range/tests.rs @@ -1975,24 +1975,6 @@ fn padded_srgb_forms_read_and_write_metals_codes() { assert_eq!(*g, want, "{form:?} values {r}, {gr}"); } } - // The crate's clear texels and load codes agree with the write rule (the runtime's clear - // writes `clear_texel`, its load pass `load_code`). - for c in 0..1024u32 { - let read = step(c << 6); - let code = padded_srgb_code(ExtendedRange::R10X6Srgb, read); - assert_eq!( - ExtendedRange::R10X6Srgb.load_code(c), - Some(code), - "code {c}" - ); - let read = linear(c << 6); - let code = padded_srgb_code(ExtendedRange::Rg10X12Srgb, read); - assert_eq!( - ExtendedRange::Rg10X12Srgb.load_code(c), - Some(code), - "code {c}" - ); - } } /// `a / 3` correctly rounded to `f32` (`a` below 4): the `f64` quotient's neighbours compared @@ -2088,12 +2070,7 @@ fn rgb10a2_srgb_reads_and_writes_metals_codes() { let word = code(0) | code(1) << 10 | code(2) << 20 | alpha_code(v[3]) << 30; assert_eq!(*g, [word, 0, 0, 0], "values {v:?}"); } - // The crate's clear texels and load codes agree with the rules (the runtime's clear writes - // `clear_texel`, its load pass `load_code`, alpha kept). - for c in 0..1024u32 { - let code = padded_srgb_code(ExtendedRange::R10X6Srgb, step(c)); - assert_eq!(form.load_code(c), Some(code), "code {c}"); - } + // The crate's clear texels agree with the rules (the runtime's clear writes `clear_texel`). let half = |v: f64| crate::float16::f16_bits_to_f32(crate::float16::f32_to_f16_bits(v as f32)); for color in [ [0.25, 0.5, 0.75, 0.4], diff --git a/crates/metal2vulkan/src/lower/push.rs b/crates/metal2vulkan/src/lower/push.rs index 6f0e55eb6..96f5f8fff 100644 --- a/crates/metal2vulkan/src/lower/push.rs +++ b/crates/metal2vulkan/src/lower/push.rs @@ -70,7 +70,6 @@ pub const fn shape(f: PushField) -> FieldShape { match f { PushField::RootTableAddress | PushField::ExecutionStatusAddress - | PushField::CaptureAddress | PushField::CaptureIndexAddress | PushField::MergedDrawAddress | PushField::CommandRecordsAddress @@ -109,7 +108,7 @@ pub const fn shape(f: PushField) -> FieldShape { PushField::ShaderTestsState => FieldShape::UVec4Array(1), // The faces' stencil words, the references, and a zero word. PushField::ShaderStencilState => FieldShape::UVec4Array(1), - // The draw's first vertex, vertex count, first instance, and a zero word. + // A zero word, the index count, the first instance, and the base vertex. PushField::CaptureLayout => FieldShape::UVec4Array(1), // Four bits of kept channels per color attachment. PushField::StorageKeptChannels => FieldShape::U32, @@ -457,12 +456,12 @@ mod tests { } } - /// A vertex function's capture addresses are holes the consumer fills, which must be in the - /// push block: the placement order puts them right after the two other addresses, so the vertex - /// window holds them whatever else the function reads, and its layout follows the window's + /// A vertex function's index address is a hole the consumer fills, which must be in the push + /// block: the placement order puts it right after the two other addresses, so the vertex + /// window holds it whatever else the function reads, and its layout follows the window's /// other fields. #[test] - fn the_capture_address_is_always_placed_in_the_vertex_window() { + fn the_index_address_is_always_placed_in_the_vertex_window() { let mut later = BTreeSet::from([ PushField::AmplificationId, PushField::AmplificationLayerOffset, @@ -479,7 +478,6 @@ mod tests { let (start, end) = window(Stage::Vertex); for (root, status) in [(false, false), (true, false), (false, true), (true, true)] { let mut fields = later.clone(); - fields.insert(PushField::CaptureAddress); fields.insert(PushField::CaptureIndexAddress); if root { fields.insert(PushField::RootTableAddress); @@ -488,25 +486,14 @@ mod tests { fields.insert(PushField::ExecutionStatusAddress); } let placement = check(Stage::Vertex, &fields); - let capture = placement - .fields - .iter() - .find(|f| f.field == PushField::CaptureAddress) - .expect("placed"); let at = start + 8 * (u32::from(root) + u32::from(status)); - assert_eq!(capture.loc, PushLoc::Push { offset: at }, "{root} {status}"); let index = placement .fields .iter() .find(|f| f.field == PushField::CaptureIndexAddress) .expect("placed"); - let after = at + capture.size; - assert_eq!( - index.loc, - PushLoc::Push { offset: after }, - "{root} {status}" - ); - assert!(after + index.size <= end); + assert_eq!(index.loc, PushLoc::Push { offset: at }, "{root} {status}"); + assert!(at + index.size <= end); let layout = placement .fields .iter() diff --git a/crates/metal2vulkan/src/lower/sampler/anisotropic/tests.rs b/crates/metal2vulkan/src/lower/sampler/anisotropic/tests.rs index 9c25f6012..9a85ca3bd 100644 --- a/crates/metal2vulkan/src/lower/sampler/anisotropic/tests.rs +++ b/crates/metal2vulkan/src/lower/sampler/anisotropic/tests.rs @@ -123,8 +123,8 @@ declare { <4 x float>, i8 } @air.sample_texture_2d_grad.v4f32(ptr addrspace(1), "#; /// Committed profile `stem` without `samplerAnisotropy`: every Vulkan sampler is isotropic there, -/// so Metal's anisotropic filter is emulated (the emulation's home besides a cube's unmeasured -/// gradient route), the profile the emulation's shape tests compile under. +/// so Metal's anisotropic filter is emulated (the emulation's home), the profile the emulation's +/// shape tests compile under. fn p(stem: &str) -> DeviceProfile { let mut desc = crate::pipeline::testing::description(stem).expect(stem); desc.features.remove(&VkFeature::SamplerAnisotropy); diff --git a/crates/metal2vulkan/src/lower/stage_io/fetch.rs b/crates/metal2vulkan/src/lower/stage_io/fetch.rs index 98323eba4..0f36b9d3a 100644 --- a/crates/metal2vulkan/src/lower/stage_io/fetch.rs +++ b/crates/metal2vulkan/src/lower/stage_io/fetch.rs @@ -19,8 +19,8 @@ //! `u32` arithmetic, where `element` is the step's element index: //! //! - `PerVertex`: `VertexIndex` (it includes the base vertex in Vulkan as `[[vertex_id]]` does in -//! Metal); in the indexed capture form (`CaptureForm::Indexed`), whose draw has no indices, the -//! vertex the draw's index names ([`Step::CapturedVertex`], `super::CapturedIndex`), as +//! Metal); in the de-indexed and private list forms, whose draws have no indices, the vertex +//! the draw's index names ([`Step::CapturedVertex`], `super::CapturedIndex`), as //! `[[vertex_id]]` reads it there; //! - `PerInstance` with rate 1: `InstanceIndex` (which includes the base instance in both APIs); //! - `PerInstance` with rate `n > 1`: `base + (InstanceIndex - base) / n`, the element the @@ -341,7 +341,7 @@ pub enum Step { /// A kernel stage-in step through the index buffer on `axis`: the index at the thread position /// clamped to the region's last element, plus the region's origin. Indexed { axis: u8, index: IndexRead }, - /// A per-vertex step in the indexed capture form: the vertex the draw's index names + /// A per-vertex step in the de-indexed or private list form: the vertex the draw's index names /// (`super::CapturedIndex`), read once at entry. CapturedVertex, } @@ -489,7 +489,7 @@ pub(super) fn select( narrow_float_nans(cx, encoding, form); let s = slot(Stage::Vertex, buffer); let draw_parameters = cx.profile.fields().draw_parameters; - // The indexed capture form's per-vertex element is the vertex its index names. + // The de-indexed and private list forms' per-vertex element is the vertex its index names. let captured = super::plan::captured_index_type(cx); if let (VertexStepFunction::PerVertex, Some(ty)) = (step_function, captured) { super::plan::captured_index(cx, ty)?; diff --git a/crates/metal2vulkan/src/lower/stage_io/mod.rs b/crates/metal2vulkan/src/lower/stage_io/mod.rs index c66b17af1..a5966f8cc 100644 --- a/crates/metal2vulkan/src/lower/stage_io/mod.rs +++ b/crates/metal2vulkan/src/lower/stage_io/mod.rs @@ -48,8 +48,8 @@ //! macOS 27.0.1: lists, strips, lines, points, indirect draws). The varying's `VertexIndex` is a //! draw's own only without indices: an indexed draw's primitives share vertices, so it runs in //! the de-indexed form (`LoweringInputs::primitive_id_indices`), `index count` vertices from 0 -//! that read their indices at the draw's index address as the indexed capture form does -//! ([`CapturedIndex`]), whose first vertex is 0. A vertex function that writes memory is +//! that read their indices at the draw's index address ([`CapturedIndex`]), whose first vertex +//! is 0. A vertex function that writes memory is //! refused there (it would run once per index), and so are the draws the binder cannot run //! so (`NotImplemented(PrimitiveId)`). A draw of one of Metal's private primitive types in the //! private list form (`LoweringInputs::private_list`) runs its list's positions from its first @@ -112,8 +112,9 @@ //! flips y with a negative viewport) and their depth and stencil modes. //! //! A vertex function's position is decorated `Invariant`, `[[invariant]]` in Metal or not: every -//! pipeline that draws a vertex function computes its position the same way, so the tile reach's -//! capture of a draw's positions holds the positions the draw rasterizes. +//! pipeline that draws a vertex function computes its position the same way, so a draw run +//! through more than one variant of its pipeline (each color group's) rasterizes the same +//! positions in each. //! //! A fragment function compiled for a render pipeline that rasterizes more than one sample //! (`LoweringInputs::multisampled`) reads what Metal reads at the pixel center in every invocation @@ -258,11 +259,12 @@ pub enum Source { /// `shaderDrawParameters`: the lane of `PushField::BaseVertexInstance` that holds the draw's /// `base`, into an integer of this form. DrawBase { base: DrawBase, form: Form }, - /// A vertex function's `[[vertex_id]]` in the indexed capture form: the vertex its index - /// names ([`CapturedIndex`]), into an integer of this form. + /// A vertex function's `[[vertex_id]]` in the de-indexed or private list form: the vertex its + /// index names ([`CapturedIndex`]), into an integer of this form. CapturedVertex(Form), - /// A vertex function's `[[base_vertex]]` in the indexed capture form: the draw's base vertex, - /// lane 3 of `PushField::CaptureLayout`, into an integer of this form. + /// A vertex function's `[[base_vertex]]` in the de-indexed or private list form: the draw's + /// base vertex, lane 3 of `PushField::CaptureLayout` (the word before the private list), + /// into an integer of this form. CapturedBaseVertex(Form), /// A merged draw's vertex function's `[[vertex_id]]`, `[[instance_id]]`, `[[base_vertex]]` or /// `[[base_instance]]` (`LoweringInputs::merged_draws`): its corner's command's, which the @@ -455,12 +457,9 @@ pub struct StageIoPlan { /// A vertex function compiled under `LoweringInputs::window_depth_varying` writes its /// position's window depth to a varying ([`WindowDepth`]). pub window_depth: Option, - /// A vertex function compiled under `LoweringInputs::captured_positions` writes each - /// vertex's capture record ([`Capture`]). - pub capture: Option, - /// A vertex function compiled in the indexed capture form (`CaptureForm::Indexed`) reads its - /// vertex from the draw's index buffer ([`CapturedIndex`]): planned where the function reads - /// it (`[[vertex_id]]`, a per-vertex attribute, or its record's restart flag). + /// A vertex function compiled in the de-indexed or private list form reads its vertex from + /// the draw's indices ([`CapturedIndex`]): planned where the function reads it + /// (`[[vertex_id]]`, a per-vertex attribute, `[[base_vertex]]` or the primitive ID). pub captured_index: Option, /// A vertex function compiled under `LoweringInputs::merged_draws` finds its corner's command /// at entry ([`MergedRead`]). @@ -521,7 +520,7 @@ pub enum FirstVertex { /// indirect one's from its arguments read on the CPU). Push, /// Vertex 0: the de-indexed form draws an indexed draw's indices as `index count` vertices - /// from 0 (`LoweringInputs::primitive_id_indices`), as the indexed capture form does. + /// from 0 (`LoweringInputs::primitive_id_indices`). Zero, } @@ -545,36 +544,14 @@ pub struct WindowDepth { /// entry, two extracts, the division, and the store. const WINDOW_DEPTH_WORDS: u64 = 40; -/// How a vertex function compiled under `LoweringInputs::captured_positions` writes its capture -/// record at each return: the value it returns to its `Position` object (`position`, Metal's -/// clip position, before any compensation) and to its own `PointSize` object (`point_size`; 1.0 -/// where it writes none), and the restart flag (the indexed form's raw index is its type's -/// all-ones value, [`CapturedIndex`]; 0 in the vertices form), stored as one record of -/// [`CAPTURE_RECORD_BYTES`] at its slot from `PushField::CaptureAddress`. The slot is `p + -/// (InstanceIndex - first instance) · vertex count` from `PushField::CaptureLayout`, `p` being -/// `VertexIndex` less the first vertex in the vertices form and `VertexIndex` itself in the -/// indexed form (`vertex` and `instance` are the two input builtins' objects), in 64 bits. -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] -pub struct Capture { - pub position: usize, - pub point_size: Option, - pub vertex: usize, - pub instance: usize, -} - -/// The bytes of one capture record: the clip position's four `f32`s at 0, the point size's -/// `f32` at 16, the restart flag's `u32` at 20, and words 6 and 7 reserved (unwritten). -pub(crate) const CAPTURE_RECORD_BYTES: u64 = 32; - -/// How a vertex function compiled in the indexed capture form (`CaptureForm::Indexed`) reads its -/// vertex: its stream position `p = VertexIndex` (`vertex` is the input builtin's object; the -/// capture draw starts at vertex 0) names the raw index of type `ty` at -/// `PushField::CaptureIndexAddress + p · size`, read once at entry (`u16`: from the aligned word -/// that holds it, shifted by its address's bit 1), and the vertex is the raw index plus the -/// layout's base vertex (lane 3), wrapping as `u32`s. Where the draw restarts (lane 0 of -/// `PushField::CaptureLayout` is not 0: a line or triangle strip) and the raw index is the type's -/// all-ones value, the invocation stores its record's restart flag alone and returns before any -/// fetch or instruction of the body, as Metal shades no vertex there. +/// How a vertex function compiled in the primitive ID's de-indexed form +/// (`LoweringInputs::primitive_id_indices`) reads its vertex: its stream position +/// `p = VertexIndex` (`vertex` is the input builtin's object; the draw starts at vertex 0) names +/// the raw index of type `ty` at `PushField::CaptureIndexAddress + p · size`, read once at entry +/// (`u16`: from the aligned word that holds it, shifted by its address's bit 1), and the vertex is +/// the raw index plus the layout's base vertex (lane 3 of `PushField::CaptureLayout`), wrapping +/// as `u32`s. The draw is a list or points: a strip, which Metal restarts at the all-ones index, +/// does not run so (`bind::graphics`). /// /// In the private list form (`LoweringInputs::private_list`, `first` is the draw's first vertex) /// the draw runs its list from `first` without indices: the raw index, a `u32`, lies at @@ -592,17 +569,9 @@ pub struct CapturedIndex { /// The words a vertex function's index read adds: its input builtin's variable, decorations and /// interface entry, its load, the layout's extract, the 64-bit address arithmetic, the device /// place (its block and pointer types, conversion and access chain), the load, a `u16`'s -/// alignment and shift, the base vertex's extract and add, and the restart test, its record -/// address and the selection that returns at a strip's restart index (measured 186 for `u32` and -/// 224 for `u16` on `tests::engine_vertex_capture`'s function). +/// alignment and shift, and the base vertex's extract and add (at most 224, a `u16` read's). pub(super) const CAPTURED_INDEX_WORDS: u64 = 400; -/// The words a vertex function's capture adds: the two input builtins' variables, decorations -/// and interface entries, their loads, the layout's extracts, the slot's 64-bit arithmetic, the -/// three device places (their block and pointer types, conversions and access chains), and the -/// three stores (measured 246 to 259 on `tests::engine_vertex_capture`'s functions). -const CAPTURE_WORDS: u64 = 300; - /// Plan an emulated post-tessellation vertex function's primitive ID output under /// `LoweringInputs::primitive_id_varying`: the index of its object, the flat `uint` varying of /// `IoRole::PrimitiveId` to which its entry wrapper writes its patch's position in the draw @@ -1146,15 +1115,12 @@ fn metal_interpolated_constant( /// come after it in program order and never reach it, as Metal's attribute is fetched before its /// function runs. pub fn emit_entry(cx: &mut EmitCx<'_>, fb: &mut FunctionBuilder<'_>) -> BResult<()> { - // The indexed capture form's raw index, read once in the first block, where it dominates - // every use, and a strip's restart index's return before the body. + // The de-indexed or private list form's raw index, read once in the first block, where it + // dominates every use, and the private list form's base vertex. if let Some(c) = cx.plan.families.stage_io.captured_index { - let raw = cx.captured_index(fb)?; - match c.first { - Some(_) => { - cx.listed_base(fb)?; - } - None => skip_restart(cx, fb, c, raw)?, + cx.captured_index(fb)?; + if c.first.is_some() { + cx.listed_base(fb)?; } } // A merged draw's vertex finds its corner's command before the body, which every read of the @@ -1605,7 +1571,6 @@ pub fn emit_return( let compensation = plan.compensation; let depth_clamp = plan.depth_clamp; let window_depth = plan.window_depth; - let capture = plan.capture; let primitive_id = plan.primitive_id; // The private masks: the pixel's ANDed into the function's own `[[sample_mask]]` output // where this return stores one, else stored as that output. @@ -1631,17 +1596,8 @@ pub fn emit_return( Some(_) => Some(selected_viewport(cx, fb, x, returned, &outputs)?), None => None, }; - // The capture record's position and point size, as the function returns them. - let (mut clip, mut size) = (None, None); for o in &outputs { let part = output_part(cx, fb, x, returned, o)?; - if let Some(c) = capture { - if c.position == o.link.object { - clip = Some(part); - } else if c.point_size == Some(o.link.object) { - size = Some(part); - } - } let part = match point_size_object(&cx.plan.families.stage_io.objects, o.link.object) { true => metal_point_size(fb, part)?, @@ -1675,9 +1631,6 @@ pub fn emit_return( }; store(cx, fb, &o.link, part)?; } - if let (Some(c), Some(clip)) = (capture, clip) { - store_capture(cx, fb, c, clip, size)?; - } for s in &seconds { let first = match returned { Returned::Struct => fb.composite_extract(x, &[s.field])?, @@ -1756,8 +1709,7 @@ fn point_size_object(objects: &[IoObject], object: usize) -> bool { /// The point size `size` (an `f32`) a vertex or mesh function stores to `PointSize`, as Metal /// draws it: [`METAL_POINT_SIZE_LIMIT`] where `size` is past it (an infinity too), `size` itself /// otherwise. A NaN fails the ordered comparison and is stored as written: Metal's answer for a -/// NaN, a negative or a denormal size is not measured (the tile reach reference flags them -/// unmeasured, `bind::tile_reach`). +/// NaN, a negative or a denormal size is not measured. pub(crate) fn metal_point_size(fb: &mut FunctionBuilder<'_>, size: SValue) -> BResult { let f32_ = fb.module().ty(SType::Float { width: 32 })?; let limit = fb.module().constant(Constant::Scalar { @@ -1832,193 +1784,9 @@ fn store_primitive_id( store(cx, fb, &link, id) } -/// Store vertex capture record `c` ([`Capture`]): the clip position `clip` and the point size -/// `size` (1.0 where the function writes none) at the vertex's slot from -/// `PushField::CaptureAddress`, its address and slot in 64 bits. Words 5 to 7 are left unwritten. -fn store_capture( - cx: &mut EmitCx<'_>, - fb: &mut FunctionBuilder<'_>, - c: Capture, - clip: SValue, - size: Option, -) -> BResult<()> { - let u64_ = fb.module().ty(SType::Int { - width: 64, - signed: false, - })?; - let f32_ = fb.module().ty(SType::Float { width: 32 })?; - let vec4 = fb.module().ty(SType::Vector { elem: f32_, len: 4 })?; - let k64 = |fb: &mut FunctionBuilder<'_>, x: u64| -> BResult { - let k = fb.module().constant(Constant::Scalar { - ty: u64_, - bits: ConstBits(x), - })?; - fb.module().const_value(k) - }; - let record = record_address(cx, fb, c)?; - let place = fb.device_place(record, vec4)?; - let aligned = |n| MemAccess { - aligned: Some(n), - ..MemAccess::default() - }; - fb.store(place, clip, aligned(16))?; - let size = match size { - Some(size) => size, - None => { - let one = fb.module().constant(Constant::Scalar { - ty: f32_, - bits: ConstBits(u64::from(1.0f32.to_bits())), - })?; - fb.module().const_value(one)? - } - }; - let sixteen = k64(fb, 16)?; - let at = fb.binary(BinOp::IAdd, record, sixteen)?; - let place = fb.device_place(at, f32_)?; - fb.store(place, size, aligned(4))?; - // The restart flag: the indexed form's raw index is its type's all-ones value. - let u32_ = fb.module().ty(SType::Int { - width: 32, - signed: false, - })?; - let k32 = |fb: &mut FunctionBuilder<'_>, x: u32| crate::memory::leaf::k32(fb, x); - let flag = match cx.plan.families.stage_io.captured_index { - Some(c) => { - let raw = cx.captured_index(fb)?; - let all = k32(fb, all_ones(c.ty))?; - let restart = fb.binary(BinOp::IEqual, raw, all)?; - let one = k32(fb, 1)?; - let zero = k32(fb, 0)?; - fb.select(restart, one, zero)? - } - None => k32(fb, 0)?, - }; - let twenty = k64(fb, 20)?; - let at = fb.binary(BinOp::IAdd, record, twenty)?; - let place = fb.device_place(at, u32_)?; - fb.store(place, flag, aligned(4)) -} - -/// The address of capture record `c` of the invocation ([`Capture`]): `32 · slot` past -/// `PushField::CaptureAddress`, `slot = p + (InstanceIndex - first instance) · vertex count` from -/// `PushField::CaptureLayout`, where `p` is `VertexIndex` less the layout's first vertex in the -/// vertices form, and `VertexIndex` itself in the indexed form, whose draw starts at vertex 0 (its -/// layout's lane 0 says whether the draw restarts). The subtractions wrap as `u32`s; the rest is -/// 64-bit. -fn record_address( - cx: &mut EmitCx<'_>, - fb: &mut FunctionBuilder<'_>, - c: Capture, -) -> BResult { - let u64_ = fb.module().ty(SType::Int { - width: 64, - signed: false, - })?; - let layout = cx.push_field(fb, PushField::CaptureLayout)?; - let count = fb.composite_extract(layout, &[0, 1])?; - let first_instance = fb.composite_extract(layout, &[0, 2])?; - let load = |cx: &mut EmitCx<'_>, fb: &mut FunctionBuilder<'_>, object| -> BResult { - let g = global(cx, object)?; - let p = fb.module().global_value(g)?; - fb.load(p, MemAccess::default()) - }; - let vertex = load(cx, fb, c.vertex)?; - let instance = load(cx, fb, c.instance)?; - // The draw's vertex and instance, each from its first, wrapping as `u32`s. - let vertex = match cx.plan.families.stage_io.captured_index { - Some(_) => vertex, - None => { - let first_vertex = fb.composite_extract(layout, &[0, 0])?; - fb.binary(BinOp::ISub, vertex, first_vertex)? - } - }; - let instance = fb.binary(BinOp::ISub, instance, first_instance)?; - let wide = |fb: &mut FunctionBuilder<'_>, x: SValue| fb.convert(ConvOp::UConvert, x, u64_); - let vertex = wide(fb, vertex)?; - let instance = wide(fb, instance)?; - let count = wide(fb, count)?; - let rows = fb.binary(BinOp::IMul, instance, count)?; - let slot = fb.binary(BinOp::IAdd, vertex, rows)?; - let bytes = fb.module().constant(Constant::Scalar { - ty: u64_, - bits: ConstBits(CAPTURE_RECORD_BYTES), - })?; - let bytes = fb.module().const_value(bytes)?; - let offset = fb.binary(BinOp::IMul, slot, bytes)?; - let base = cx.push_field(fb, PushField::CaptureAddress)?; - fb.binary(BinOp::IAdd, base, offset) -} - -/// The indexed capture form's return at a strip's restart index: where the draw restarts (lane 0 of -/// `PushField::CaptureLayout` is not 0) and the raw index `raw` is its type's all-ones value, Metal -/// shades no vertex, so the invocation stores its record's restart flag (1, at byte 20; the -/// record's other words are left as they were) where it has a record, and returns before any fetch -/// or instruction of the body. A list or point draw shades that index as any other. -fn skip_restart( - cx: &mut EmitCx<'_>, - fb: &mut FunctionBuilder<'_>, - c: CapturedIndex, - raw: SValue, -) -> BResult<()> { - use crate::spirv::builder::constructs::{ArmEnd, ArmFn}; - let k32 = |fb: &mut FunctionBuilder<'_>, x: u32| crate::memory::leaf::k32(fb, x); - let layout = cx.push_field(fb, PushField::CaptureLayout)?; - let restarts = fb.composite_extract(layout, &[0, 0])?; - let zero = k32(fb, 0)?; - let strip = fb.binary(BinOp::INotEqual, restarts, zero)?; - let all = k32(fb, all_ones(c.ty))?; - let at_restart = fb.binary(BinOp::IEqual, raw, all)?; - let skip = fb.binary(BinOp::LogicalAnd, strip, at_restart)?; - let flag = match cx.plan.families.stage_io.capture { - Some(record) => { - let u64_ = fb.module().ty(SType::Int { - width: 64, - signed: false, - })?; - let u32_ = fb.module().ty(SType::Int { - width: 32, - signed: false, - })?; - let record = record_address(cx, fb, record)?; - let twenty = fb.module().constant(Constant::Scalar { - ty: u64_, - bits: ConstBits(20), - })?; - let twenty = fb.module().const_value(twenty)?; - let at = fb.binary(BinOp::IAdd, record, twenty)?; - Some((fb.device_place(at, u32_)?, k32(fb, 1)?)) - } - None => None, - }; - let leave: ArmFn<'_, ()> = Box::new(move |fb, _| { - if let Some((place, one)) = flag { - fb.store( - place, - one, - MemAccess { - aligned: Some(4), - ..MemAccess::default() - }, - )?; - } - fb.ret(None)?; - Ok(ArmEnd::Exits) - }); - fb.if_(&mut (), skip, leave, None)?; - Ok(()) -} - -/// The all-ones index of `ty`, Metal's strip restart index. -fn all_ones(ty: crate::metal::IndexType) -> u32 { - match ty { - crate::metal::IndexType::UInt16 => 0xffff, - crate::metal::IndexType::UInt32 => u32::MAX, - } -} - -/// The raw index an indexed capture form's vertex reads ([`CapturedIndex`]), loaded in the open -/// block: `PushField::CaptureIndexAddress + p · size` with `p = VertexIndex` (the capture draw -/// starts at vertex 0), in 64 bits. A `u32` index is read where it lies (the address is a +/// The raw index a de-indexed or private list form's vertex reads ([`CapturedIndex`]), loaded in +/// the open block: `PushField::CaptureIndexAddress + p · size` with `p = VertexIndex` (the +/// de-indexed draw starts at vertex 0), in 64 bits. A `u32` index is read where it lies (the address is a /// multiple of 4); a `u16` one from the aligned word that holds it, shifted right by 16 where its /// address's bit 1 is set, and masked to 16 bits. [`EmitCx::captured_index`] reads it once where /// it dominates. @@ -2027,7 +1795,7 @@ pub(crate) fn read_captured_index( fb: &mut FunctionBuilder<'_>, ) -> BResult { let Some(c) = cx.plan.families.stage_io.captured_index else { - return Err(cx.fail("a capture index read without its plan")); + return Err(cx.fail("an index read without its plan")); }; let u64_ = fb.module().ty(SType::Int { width: 64, @@ -2084,8 +1852,8 @@ pub(crate) fn read_captured_index( } } -/// The vertex an indexed capture form's function runs ([`CapturedIndex`]): its raw index plus -/// the base vertex ([`captured_base_vertex`]), wrapping as `u32`s. +/// The vertex a de-indexed or private list form's function runs ([`CapturedIndex`]): its raw +/// index plus the base vertex ([`captured_base_vertex`]), wrapping as `u32`s. pub(super) fn captured_vertex( cx: &mut EmitCx<'_>, fb: &mut FunctionBuilder<'_>, @@ -2604,9 +2372,13 @@ fn nan_drop(cx: &mut EmitCx<'_>) -> BResult> { /// flushes denormals keeps a positive one and makes -0 and a negative one +0 alike. A positive NaN /// fails Metal's depth test, `Always` included: neither depth nor color is written and no sample /// counts; the invocation is dropped by `kill` ([`nan_drop`]), which drops the same, though Metal -/// also runs the stencil's depth-fail operation; a device that clamps the depth itself stores a NaN -/// as anything (ANV: 0, its color written), so every profile drops it. In a function looping over -/// its covered samples the value passes unchanged. The selects run only where the plan `clamps`, +/// also runs the stencil's depth-fail operation. The drop is capability on every profile: no device +/// has a defined form, since Vulkan leaves a NaN depth undefined after its clamp and range step, +/// with or without depth clamp ("Depth Clamping and Range Adjustment": "If zf is not in the range +/// [zmin, zmax], then zf is undefined following this step", and a NaN lies in no range; only +/// `depthClampZeroOne`, which no profile enables, keeps a float depth unchanged), and a device +/// that clamps the depth itself stores a NaN as anything (ANV: 0, its color written). In a +/// function looping over its covered samples the value passes unchanged. The selects run only where the plan `clamps`, /// the device storing the value unclamped; elsewhere its own clamp gives Metal's answers. /// /// Under `range`, `PushField::DepthClampRange`'s `[low, high]`, the value is then clamped to the diff --git a/crates/metal2vulkan/src/lower/stage_io/plan.rs b/crates/metal2vulkan/src/lower/stage_io/plan.rs index 385a5af4f..92234516f 100644 --- a/crates/metal2vulkan/src/lower/stage_io/plan.rs +++ b/crates/metal2vulkan/src/lower/stage_io/plan.rs @@ -19,7 +19,7 @@ use crate::lower::stage_io::{ use crate::pipeline::artifact::PrecisionNote; use crate::pipeline::facts::RuntimeFact; use crate::pipeline::lower_inputs::{ - CaptureForm, FactorLane, RotatedBlendForm, VertexFetch, ViewportCompensation, + FactorLane, RotatedBlendForm, VertexFetch, ViewportCompensation, }; use crate::pipeline::stage_io::{ DepthMode, Interpolation, IoNumeric, IoRole, IoType, IoVariable, Sampling, StageBuiltin, @@ -480,9 +480,9 @@ pub fn param(cx: &mut SelectCx<'_>, b: &ParamBinding) -> Result<(), Error> { .copied(); let pulled = entry.filter(|f| matches!(f, VertexFetch::Pulled { .. })); let f = io_form(cx, ty)?; - // The indexed capture form's and the de-indexed form's draws have no indices, so - // fixed-function input would fetch at the stream position: their projection pulls - // every attribute, and a hand-built one that does not is refused. + // The de-indexed and private list forms' draws have no indices, so fixed-function + // input would fetch at the stream position: their projection pulls every attribute, + // and a hand-built one that does not is refused. if pulled.is_none() && captured_index_type(cx).is_some() { return Err(Unsupported::not_implemented(indices_feature(cx)).into()); } @@ -720,8 +720,9 @@ pub fn param(cx: &mut SelectCx<'_>, b: &ParamBinding) -> Result<(), Error> { { return zero_index(cx, b, ty, StageBuiltin::ViewportIndex); } - // The indexed capture form draws without indices: its vertex is the one its index names, - // and its base vertex the layout's, whatever the profile's draw parameters. + // The de-indexed and private list forms draw without indices: the vertex is the one its + // index names, and its base vertex the layout's (the list's), whatever the profile's draw + // parameters. (ParamRole::Builtin(Builtin::VertexId), Stage::Vertex) if captured_index_type(cx).is_some() => { @@ -2446,10 +2447,6 @@ pub fn entry(cx: &mut SelectCx<'_>) -> Result<(), Error> { sp.words = sp.words.saturating_add(super::WINDOW_DEPTH_WORDS); } } - // The capture form: each vertex's clip position and point size, written to its record. - if let (Some(form), Stage::Vertex) = (cx.inputs.captured_positions, cx.stage) { - capture(cx, form)?; - } // The primitive ID a fragment function reads from its varying (an emulated post-tessellation // vertex function's is its patch's position, `lower::tessellation::emulated`). if cx.inputs.primitive_id_varying && cx.stage == Stage::Vertex { @@ -2499,83 +2496,14 @@ pub fn entry(cx: &mut SelectCx<'_>) -> Result<(), Error> { Ok(()) } -/// Plan a vertex function's capture form `form` (`LoweringInputs::captured_positions`): the -/// record of its `Position` output and its own `PointSize` output ([`super::Capture`]), the -/// record's address and layout push fields, the vertex and instance indices, the indexed form's -/// index read ([`captured_index`], whatever else the function reads: its record's restart flag -/// and a strip's restart test need it), and -/// `RuntimeFact::CapturedPositions`, which every function compiled in the form states, so its -/// plans state the variant. A function that writes no position rasterizes nothing and plans no -/// record. Refused [`Feature::TileReach`]: a post-tessellation vertex function (its vertices are -/// the tessellator's, not the draw's), and a device without device addresses or without the -/// vertex stage's stores, naming what it needs. -fn capture(cx: &mut SelectCx<'_>, form: CaptureForm) -> Result<(), Error> { - if matches!(cx.entry.ep.stage, AirStage::Vertex { patch: Some(_) }) { - return Err(Unsupported::not_implemented(Feature::TileReach).into()); - } - cx.facts.insert(RuntimeFact::CapturedPositions { form }); - // The indexed form reads its index whatever else it reads: a strip's restart index runs no - // body. - if let Some(ty) = form.index_type() { - captured_index(cx, ty)?; - } - let output = |o: &IoObject, b| matches!(o, IoObject::Builtin { builtin, dir: IoDir::Output, .. } if *builtin == b); - let sp = &cx.families.stage_io; - let Some(position) = sp.objects.iter().position(|o| output(o, B::Position)) else { - return Ok(()); - }; - // The function's own point size: the default one the vertex stage writes is planned later, - // and the record takes 1.0 for it. - let point_size = sp - .outputs - .iter() - .map(|o| o.link.object) - .find(|&i| sp.objects.get(i).is_some_and(|o| output(o, B::PointSize))); - refuse_unaddressed(cx)?; - let f = cx.profile.fields(); - let enabled = &f.enabled.features; - if let Some(stores) = - crate::lower::access::dynamic::stage_stores(Stage::Vertex).find(|s| !enabled.contains(s)) - { - return Err(Unsupported::needs(Feature::TileReach, Capability::Feature(stores)).into()); - } - cx.push.insert(PushField::CaptureAddress); - cx.push.insert(PushField::CaptureLayout); - let sp = &mut cx.families.stage_io; - let vertex = builtin( - sp, - B::VertexIndex, - IoDir::Input, - Shape::U32, - StageBuiltin::VertexIndex, - ); - let instance = builtin( - sp, - B::InstanceIndex, - IoDir::Input, - Shape::U32, - StageBuiltin::InstanceIndex, - ); - sp.capture = Some(super::Capture { - position, - point_size, - vertex, - instance, - }); - sp.words = sp.words.saturating_add(super::CAPTURE_WORDS); - Ok(()) -} - /// The index type of the draw whose indices a vertex function reads at their address: the -/// indexed capture form's (`CaptureForm::Indexed`), else the private list form's `u32` -/// (`LoweringInputs::private_list`), else the primitive ID's de-indexed form's -/// (`LoweringInputs::primitive_id_indices`, under `primitive_id_varying`); `None` for any other -/// function. +/// private list form's `u32` (`LoweringInputs::private_list`), else the primitive ID's de-indexed +/// form's (`LoweringInputs::primitive_id_indices`, under `primitive_id_varying`); `None` for any +/// other function. pub(super) fn captured_index_type(cx: &SelectCx<'_>) -> Option { - match (cx.stage, cx.inputs.captured_positions) { - (Stage::Vertex, Some(form)) => form.index_type(), - (Stage::Vertex, None) if cx.inputs.private_list => Some(crate::metal::IndexType::UInt32), - (Stage::Vertex, None) => cx + match cx.stage { + Stage::Vertex if cx.inputs.private_list => Some(crate::metal::IndexType::UInt32), + Stage::Vertex => cx .inputs .primitive_id_indices .filter(|_| cx.inputs.primitive_id_varying), @@ -2586,22 +2514,20 @@ pub(super) fn captured_index_type(cx: &SelectCx<'_>) -> Option) -> bool { - cx.stage == Stage::Vertex && cx.inputs.captured_positions.is_none() && cx.inputs.private_list + cx.stage == Stage::Vertex && cx.inputs.private_list } -/// The feature a form that reads a draw's indices or records at their addresses serves: tile -/// reach for the capture form, Metal's private primitive types for the private list form, the -/// primitive ID for its de-indexed form. +/// The feature a form that reads a draw's indices at their address serves: Metal's private +/// primitive types for the private list form, the primitive ID for its de-indexed form. fn indices_feature(cx: &SelectCx<'_>) -> Feature { - match cx.inputs.captured_positions { - Some(_) => Feature::TileReach, - None if listed(cx) => Feature::PrivatePrimitives, - None => Feature::PrimitiveId, + match listed(cx) { + true => Feature::PrivatePrimitives, + false => Feature::PrimitiveId, } } -/// Refuse the capture form or the de-indexed form ([`indices_feature`]) on a device without -/// device addresses, naming what it needs: the records and the indices are reached by address. +/// Refuse the de-indexed or private list form ([`indices_feature`]) on a device without device +/// addresses, naming what it needs: the indices are reached by address. fn refuse_unaddressed(cx: &SelectCx<'_>) -> Result<(), Error> { if cx.profile.fields().buffer_access != crate::device::profile::BufferAccess::Addressed { return Err(Unsupported::needs_any_of( @@ -2613,9 +2539,9 @@ fn refuse_unaddressed(cx: &SelectCx<'_>) -> Result<(), Error> { Ok(()) } -/// Plan the index read of type `ty` of the indexed capture form, the de-indexed form or the -/// private list form once ([`super::CapturedIndex`]): its address push field, the capture and -/// de-indexed forms' layout, the private list form's first vertex (as the primitive ID's, +/// Plan the index read of type `ty` of the de-indexed form or the private list form once +/// ([`super::CapturedIndex`]): its address push field, the de-indexed form's layout, the private +/// list form's first vertex (as the primitive ID's, /// [`first_vertex`]) and its fact, and the vertex index builtin. Refused ([`indices_feature`]) on /// a device without device addresses. pub(super) fn captured_index( @@ -2651,7 +2577,8 @@ pub(super) fn captured_index( } /// Plan builtin parameter `b` of AIR type `ty`, a scalar integer, of a vertex function in the -/// indexed capture form of index type `index` (`None` for `[[base_vertex]]`): `[[vertex_id]]` is +/// de-indexed or private list form of index type `index` (`None` for `[[base_vertex]]`): +/// `[[vertex_id]]` is /// the vertex its index names ([`Source::CapturedVertex`]), `[[base_vertex]]` the layout's base /// vertex ([`Source::CapturedBaseVertex`]). fn captured_param( @@ -2690,14 +2617,13 @@ fn captured_param( /// (`Unsupported{GpuEncodedIndirectCommands, NotImplemented}`): one compiled without /// `replay_bindings`, or under an input that reads the draw's own vertex or instance indices or /// draws it more than once (the primitive ID's varying or de-indexed form, the private list form, -/// the capture form, amplifications drawn apart, tessellation). +/// amplifications drawn apart, tessellation). fn merged(cx: &mut SelectCx<'_>) -> Result<(), Error> { let i = cx.inputs; if !i.replay_bindings || i.primitive_id_varying || i.primitive_id_indices.is_some() || i.private_list - || i.captured_positions.is_some() || i.amplification_draws.is_some() || i.tessellation.is_some() { @@ -2880,8 +2806,9 @@ fn output(cx: &mut SelectCx<'_>, o: &OutputBinding, ty: AirTypeId) -> Result { let f = io_form(cx, ty)?; float_lanes(f, 4)?; @@ -3192,10 +3119,7 @@ pub fn finish(cx: &mut SelectCx<'_>) -> Result<(), Error> { // where Metal shades each vertex the indices name as its GPU shades it: a function that // writes memory would write once per index. The private list form runs it once per list // position, as Metal runs its private types. - let deindexed = cx.stage == Stage::Vertex - && cx.inputs.captured_positions.is_none() - && captured_index_type(cx).is_some() - && !listed(cx); + let deindexed = cx.stage == Stage::Vertex && captured_index_type(cx).is_some() && !listed(cx); if deindexed && writes { return Err(Unsupported::not_implemented(Feature::PrimitiveId).into()); } diff --git a/crates/metal2vulkan/src/metal/format/mod.rs b/crates/metal2vulkan/src/metal/format/mod.rs index a3e7ac2c1..0dfb913ca 100644 --- a/crates/metal2vulkan/src/metal/format/mod.rs +++ b/crates/metal2vulkan/src/metal/format/mod.rs @@ -188,8 +188,9 @@ pub enum FormatEmulation { /// function reads and writes through its slot's [`ExtendedRange`] variant /// (`LoweringInputs::extended_range`), converting Metal's values in the shader. Exact for a /// sampled image a function fetches from and for a storage image; admitted for those usages - /// and for a color attachment, whose render pass clears and loads the raw codes as Metal's does - /// (`clear_texel`; the runtime's load pass). Metal filters no bfloat texel (a linear sample + /// and for a color attachment, whose render pass clears the raw codes as Metal's does + /// (`clear_texel`) and keeps the codes its draws do not write, where Metal's pass takes them + /// through `half` (the runtime's `extended-range-bits-kept`). Metal filters no bfloat texel (a linear sample /// reads the nearest texel) and blends none (its validation asserts), so a filter and a blend /// are not admitted. Bfloat, @@ -349,9 +350,9 @@ pub enum ExtendedRange { /// a `half` read with ties away from zero), and alpha's 2-bit code `a` reads `a / 3` /// correctly rounded and a write stores the exact product of the value, clamped to `[0, 1]` /// (a NaN 0), with 3, rounded to nearest. A render pass's store rounds a `float` output to - /// `half` toward zero first, a clear goes through `half` (nearest even), and a pass that loads - /// it and draws elsewhere writes each color code back as `R10Unorm_X6_sRGB`'s - /// ([`load_code`](Self::load_code)), alpha kept. + /// `half` toward zero first, a clear goes through `half` (nearest even), and Metal's pass that + /// loads it and draws elsewhere writes each color code back as `R10Unorm_X6_sRGB`'s, alpha + /// kept, where the device's pass keeps the codes (the runtime's `extended-range-bits-kept`). Rgb10A2Srgb, /// `R16Bfloat` (26): a bfloat code (the top 16 bits of an IEEE `float`) in a little-endian /// 16-bit word, held as `R16_UINT` ([`FormatEmulation::Bfloat`]). Measured on an Apple M4 @@ -738,41 +739,6 @@ impl ExtendedRange { ExtendedRange::Rgba16Bfloat => rgba, } } - - /// The code a padded form's word of code `c` holds after a render pass that loads it and - /// draws, where no draw writes it: Metal's pass reads the word and writes it back, its - /// decoded value encoded again (an Apple M4 and an Apple M3 Max, byte-identical). `c` itself - /// for `R10Unorm_X6` and `RG10Unorm_X12`; `R10Unorm_X6_sRGB`'s write of its read, which moves - /// the 23 codes no write stores, and so does each color channel's code of `RGB10A2Unorm_sRGB` - /// (an Apple M3 Max under macOS 27.0.1, every code; its alpha's code stays); - /// `RG10Unorm_X12_sRGB`'s write code of `c`. A bfloat form's code - /// `c` (each channel's 16-bit word) holds the code a `Clear` of its value stores under - /// [`ClearRoute::ThroughHalf`] ([`clear_texel`](Self::clear_texel)): the `float` of its bits - /// rounded to `half` to nearest even (past the largest `half`, the infinity), then the bfloat - /// code nearest that, ties to even, a NaN `0x7fc0` (an Apple M4 under macOS 27.0.1: every code - /// of each bfloat format through a pass that loads it and draws into another attachment; 56,829 - /// codes move). The M4's pass alone is measured. `None` for another form, or a code past the - /// form's (1023, or a bfloat form's `0xffff`). - pub fn load_code(self, c: u32) -> Option { - if self.bfloat() { - let c = u16::try_from(c).ok()?; - let value = f64::from(f32::from_bits(u32::from(c) << 16)); - return Some(self.clear_texel([value; 4], ClearRoute::ThroughHalf)[0]); - } - let at = usize::try_from(c).ok().filter(|&c| c < 1024)?; - match self { - ExtendedRange::R10X6 | ExtendedRange::Rg10X12 => Some(c), - ExtendedRange::R10X6Srgb | ExtendedRange::Rgb10A2Srgb => { - let step = padded_srgb::R10X6_SRGB_DECODE_STEPS[at]; - let first = &padded_srgb::R10X6_SRGB_ENCODE_FIRST; - Some(first.partition_point(|&f| f <= step).saturating_sub(1) as u32) - } - ExtendedRange::Rg10X12Srgb => { - Some(u32::from(padded_srgb::RG10X12_SRGB_WRITE_CODES[at])) - } - _ => None, - } - } } /// How Metal converts a render pass's clear color to a bfloat attachment's codes diff --git a/crates/metal2vulkan/src/metal/format/padded_srgb.rs b/crates/metal2vulkan/src/metal/format/padded_srgb.rs index e3140d6e3..ec0c770bf 100644 --- a/crates/metal2vulkan/src/metal/format/padded_srgb.rs +++ b/crates/metal2vulkan/src/metal/format/padded_srgb.rs @@ -2,8 +2,8 @@ //! Apple M3 Max under macOS 26.7 (the M3's and the M4's files byte-identical): `R10Unorm_X6_sRGB`'s //! decode step of every code and first encode index of every code, and `RG10Unorm_X12_sRGB`'s code //! of every linear write code. The shader's `lower::arith::extended_range` declares them once per -//! module that reads or writes such a texture; the runtime's clear values and load pass read them -//! through `ExtendedRange::clear_texel` and `ExtendedRange::load_code`. +//! module that reads or writes such a texture; the runtime's clear values read them through +//! `ExtendedRange::clear_texel`. /// The decode step `s` of every code `c` of `R10Unorm_X6_sRGB`: Metal reads `s / 8192` (every /// code read). diff --git a/crates/metal2vulkan/src/metal/state.rs b/crates/metal2vulkan/src/metal/state.rs index 804631375..dd7342344 100644 --- a/crates/metal2vulkan/src/metal/state.rs +++ b/crates/metal2vulkan/src/metal/state.rs @@ -402,41 +402,19 @@ pub struct DepthBias { /// primitives take a bias at all. It follows the topology only, never the bias values, so one /// pipeline serves every bias the encoder sets. pub enable: bool, - /// `depthBiasConstantFactor`: Metal's `depthBias`, in the unit `unit` names. + /// `depthBiasConstantFactor`: Metal's `depthBias`, in the device's unit `r` for the depth + /// attachment's format. pub constant_factor: f32, /// `depthBiasClamp`: Metal's `clamp` (0 does not clamp in either API). pub clamp: f32, /// `depthBiasSlopeFactor`: Metal's `slopeScale`. pub slope_factor: f32, - /// The unit `constant_factor` counts, and so the command that records the three factors. - pub unit: DepthBiasUnit, -} - -/// The unit a [`DepthBias`]'s constant factor counts (Vulkan's r), which names the command that -/// records the factors. -#[non_exhaustive] -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub enum DepthBiasUnit { - /// The device's own for the depth attachment's format: `vkCmdSetDepthBias`. - Device, - /// Depth itself, so the constant factor is the bias: `vkCmdSetDepthBias2EXT` with a - /// `VkDepthBiasRepresentationInfoEXT` of `VK_DEPTH_BIAS_REPRESENTATION_FLOAT_EXT` and - /// `depthBiasExact` (`VK_EXT_depth_bias_control`'s `floatRepresentation` and - /// `depthBiasExact`). - Depth, - /// 2^-n for a depth aspect of n fixed-point bits: `vkCmdSetDepthBias2EXT` with a - /// `VkDepthBiasRepresentationInfoEXT` of - /// `VK_DEPTH_BIAS_REPRESENTATION_LEAST_REPRESENTABLE_VALUE_FORMAT_EXT` and `depthBiasExact` - /// (`VK_EXT_depth_bias_control`'s `depthBiasExact`). - ExactFormatUnit, } /// The Vulkan depth bias of the render encoder's `setDepthBias:slopeScale:clamp:` for a pipeline -/// of `topology` (`GraphicsState::topology`, or the draw's from [`input_assembly`]), in a pass -/// whose depth attachment's texture is of `depth_format` (`None` without one). `DEPTH_BIAS` is -/// dynamic state on every render pipeline: create the pipeline with `enable` and record the three -/// factors by the command `unit` names (Metal's default is no bias, all three 0). +/// of `topology` (`GraphicsState::topology`, or the draw's from [`input_assembly`]). `DEPTH_BIAS` +/// is dynamic state on every render pipeline: create the pipeline with `enable` and record the +/// three factors with `vkCmdSetDepthBias` (Metal's default is no bias, all three 0). /// /// Metal biases triangles only, never points or lines; Vulkan biases triangles (a tessellation /// pipeline's included) and may bias points and lines, so `enable` is set for triangle and patch @@ -444,26 +422,22 @@ pub enum DepthBiasUnit { /// `depthBiasClamp` (`VUID-vkCmdSetDepthBias-depthBiasClamp-00790`) unless both bias factors are /// 0, when no bias exists to clamp and the clamp is dropped. /// -/// A float depth format's constant factor counts Vulkan's r, which is Metal's. A `Depth16Unorm` -/// depth's is Metal's own rule (measured on an Apple M3 Max and an M4, plain and validated, and on -/// the M3 Max under macOS 27.0.1 with slopes too): wherever the constant `c` (finite) or the slope -/// factor is nonzero, the constant biases by `c + 1` units of 1/65535 for `c` of 0 or more and -/// `c - 1` below, as `float` (so a slope alone brings one unit), which is added to the depth -/// rounded toward zero, and the sum stored rounded to nearest. Vulkan leaves a unorm -/// format's unit to the device, up to twice 2^-16, unless `depthBiasExact` pins it: with -/// `floatRepresentation` too the factor is that bias in depth ([`DepthBiasUnit::Depth`]), and with -/// `depthBiasExact` alone it is the same bias counted in 2^-16 -/// ([`DepthBiasUnit::ExactFormatUnit`]), a scale by a power of two, so the device adds Metal's -/// `float` bias either way. The device's own addition rounds the sum, to nearest where measured, so -/// a biased depth within one `float` ulp above a code's midpoint can store one code above Metal's. -/// A device without `depthBiasExact` takes Metal's `c` in its own unit ([`DepthBiasUnit::Device`]), -/// as a Metal device does; elsewhere that unit is the device's. +/// The constant factor counts the device's own unit `r` on every depth format. A float depth +/// format's is Metal's (`2^(e - n)` of the primitive's largest exponent). A `Depth16Unorm` depth's +/// is the device's: Vulkan leaves a fixed-point format's `r` to the implementation, at most +/// `2 × 2^-16` ("Depth Bias"), where Metal biases by its own rule (measured on an Apple M3 Max and +/// an M4, plain and validated, and on the M3 Max under macOS 27.0.1 with slopes too): wherever the +/// constant `c` (finite) or the slope factor is nonzero, by `c + 1` units of 1/65535 for `c` of 0 +/// or more and `c - 1` below, as `float` (so a slope alone brings one unit), added to the depth +/// rounded toward zero, and the sum stored rounded to nearest. The runtime announces the device's +/// bias there (`unorm-depth-bias`) where the profile does not take +/// [`DriverDeviation::MetalDepth16BiasedStores`](crate::error::DriverDeviation::MetalDepth16BiasedStores) +/// (MoltenVK, which hands Metal its constant). pub fn depth_bias( topology: vk::PrimitiveTopology, depth_bias: f32, slope_scale: f32, clamp: f32, - depth_format: Option, profile: &DeviceProfile, ) -> Result { use vk::PrimitiveTopology as T; @@ -482,45 +456,19 @@ pub fn depth_bias( constant_factor: 0.0, clamp: 0.0, slope_factor: 0.0, - unit: DepthBiasUnit::Device, }); } if clamp != 0.0 { require(profile, VkFeature::DepthBiasClamp, Feature::DepthBiasClamp)?; } - let enabled = &profile.fields().enabled.features; - // A bias is set (the return above): a constant, a slope or both. - let unorm16 = depth_format == Some(PixelFormat::Depth16Unorm) - && depth_bias.is_finite() - && enabled.contains(&VkFeature::DepthBiasExact); - let (constant_factor, unit) = if !unorm16 { - (depth_bias, DepthBiasUnit::Device) - } else { - let units = depth16_units(depth_bias); - if enabled.contains(&VkFeature::FloatRepresentation) { - ((units / 65535.0) as f32, DepthBiasUnit::Depth) - } else { - ( - (units * 65536.0 / 65535.0) as f32, - DepthBiasUnit::ExactFormatUnit, - ) - } - }; Ok(DepthBias { enable, - constant_factor, + constant_factor: depth_bias, clamp, slope_factor: slope_scale, - unit, }) } -/// Metal's `c ± 1` units of 1/65535 for a `Depth16Unorm` depth's constant `c` (finite), exact in -/// `f64`: `c + 1` for `c` of 0 or more, `c - 1` below ([`depth_bias`]). -fn depth16_units(c: f32) -> f64 { - f64::from(c) + if c >= 0.0 { 1.0 } else { -1.0 } -} - #[cfg(test)] mod tests { use super::*; @@ -702,24 +650,23 @@ mod tests { constant_factor, clamp, slope_factor, - unit: DepthBiasUnit::Device, }) }; assert_eq!( - depth_bias(triangles, 1.0, 2.0, 0.0, None, floor.profile()), + depth_bias(triangles, 1.0, 2.0, 0.0, floor.profile()), bias(true, 1.0, 0.0, 2.0) ); assert_eq!( - depth_bias(triangles, 1.0, 2.0, 0.5, None, floor.profile()), + depth_bias(triangles, 1.0, 2.0, 0.5, floor.profile()), Err(needs(Feature::DepthBiasClamp, VkFeature::DepthBiasClamp)) ); assert_eq!( - depth_bias(triangles, 1.0, 2.0, -0.5, None, lavapipe.profile()), + depth_bias(triangles, 1.0, 2.0, -0.5, lavapipe.profile()), bias(true, 1.0, -0.5, 2.0) ); // No bias to clamp: the clamp is dropped on any device. assert_eq!( - depth_bias(triangles, 0.0, 0.0, 0.5, None, floor.profile()), + depth_bias(triangles, 0.0, 0.0, 0.5, floor.profile()), bias(true, 0.0, 0.0, 0.0) ); assert_eq!( @@ -728,7 +675,6 @@ mod tests { 1.0, 0.0, 0.0, - None, floor.profile() ), bias(true, 1.0, 0.0, 0.0) @@ -737,7 +683,7 @@ mod tests { for &ty in PrimitiveType::ALL { let (topology, _) = input_assembly(ty); let triangle = matches!(ty, PrimitiveType::Triangle | PrimitiveType::TriangleStrip); - let mapped = depth_bias(topology, 1.0, 2.0, 0.5, None, lavapipe.profile()).unwrap(); + let mapped = depth_bias(topology, 1.0, 2.0, 0.5, lavapipe.profile()).unwrap(); assert_eq!(mapped.enable, triangle, "{ty:?}"); if !triangle { assert_eq!( @@ -747,72 +693,39 @@ mod tests { constant_factor: 0.0, clamp: 0.0, slope_factor: 0.0, - unit: DepthBiasUnit::Device, } ); - assert!(depth_bias(topology, 1.0, 2.0, 0.5, None, floor.profile()).is_ok()); + assert!(depth_bias(topology, 1.0, 2.0, 0.5, floor.profile()).is_ok()); } } } - /// A `Depth16Unorm` depth's constant bias is Metal's `c ± 1` units of 1/65535 as `float` - /// (one unit for a constant of 0 beside a slope): in depth where the device has - /// `floatRepresentation` and `depthBiasExact`, in 2^-16 where it has `depthBiasExact` alone, - /// and Metal's `c` in the device's own unit elsewhere, as on a float depth format. + /// A constant bias is Metal's constant in the device's own unit on every device: a + /// `Depth16Unorm` depth takes no unit of Metal's (`c ± 1` units of 1/65535) through + /// `depthBiasExact` where the device supports it (lavapipe's and NVIDIA's do), nor one for a + /// slope alone. #[test] - fn a_unorm_depth_bias_is_metals_where_the_device_pins_its_unit() { + fn a_unorm_depth_bias_is_metals_constant_in_the_devices_unit() { let triangles = vk::PrimitiveTopology::TRIANGLE_LIST; - let d16 = Some(PixelFormat::Depth16Unorm); - let (lavapipe, nvidia, moltenvk) = ( - committed("lavapipe"), - committed("nvidia-rtx5080-laptop"), - committed("moltenvk-m3"), - ); - let mapped = |device: &Device, constant: f32, format| { - let bias = depth_bias(triangles, constant, 0.5, 0.0, format, device.profile()).unwrap(); - assert_eq!(bias.slope_factor, 0.5); - (bias.constant_factor, bias.unit) - }; - for (constant, units) in [ - (3.0f32, 4.0f64), - (-3.0, -4.0), - (0.5, 1.5), - (-1000.0, -1001.0), - ] { - assert_eq!( - mapped(&lavapipe, constant, d16), - ((units / 65535.0) as f32, DepthBiasUnit::Depth) - ); - let (scaled, unit) = mapped(&nvidia, constant, d16); - assert_eq!(unit, DepthBiasUnit::ExactFormatUnit); - // A power of two apart: the device's 2^-16 times the factor is the same `float`. - assert_eq!(scaled / 65536.0, (units / 65535.0) as f32); - assert_eq!( - mapped(&moltenvk, constant, d16), - (constant, DepthBiasUnit::Device) - ); - for format in [None, Some(PixelFormat::Depth32Float)] { + for stem in ["lavapipe", "nvidia-rtx5080-laptop", "moltenvk-m3"] { + let device = committed(stem); + for constant in [3.0f32, -3.0, 0.5, -1000.0, 0.0, f32::INFINITY] { + let bias = depth_bias(triangles, constant, 0.5, 0.0, device.profile()).unwrap(); assert_eq!( - mapped(&lavapipe, constant, format), - (constant, DepthBiasUnit::Device) + (bias.constant_factor, bias.slope_factor), + (constant, 0.5), + "{stem} {constant}" ); } + let none = depth_bias(triangles, 0.0, 0.0, 0.0, device.profile()).unwrap(); + assert_eq!(none.constant_factor, 0.0, "{stem}"); + } + // Lavapipe and NVIDIA's devices support `depthBiasExact`, which no bias pins. + for (stem, desc) in committed_descriptions() { + if stem == "lavapipe" || stem == "nvidia-rtx5080-laptop" { + assert!(desc.features.contains(&VkFeature::DepthBiasExact), "{stem}"); + } } - // A slope alone (`mapped`'s 0.5) brings one unit; no bias at all brings none. - assert_eq!( - mapped(&lavapipe, 0.0, d16), - ((1.0f64 / 65535.0) as f32, DepthBiasUnit::Depth) - ); - let none = depth_bias(triangles, 0.0, 0.0, 0.0, d16, lavapipe.profile()).unwrap(); - assert_eq!( - (none.constant_factor, none.unit), - (0.0, DepthBiasUnit::Device) - ); - assert_eq!(mapped(&moltenvk, 0.0, d16), (0.0, DepthBiasUnit::Device)); - assert_eq!( - mapped(&lavapipe, f32::INFINITY, d16), - (f32::INFINITY, DepthBiasUnit::Device) - ); } #[test] diff --git a/crates/metal2vulkan/src/pipeline/api_tests.rs b/crates/metal2vulkan/src/pipeline/api_tests.rs index ee8992719..49e8e971e 100644 --- a/crates/metal2vulkan/src/pipeline/api_tests.rs +++ b/crates/metal2vulkan/src/pipeline/api_tests.rs @@ -228,7 +228,6 @@ mod serde_round_trips { ), )]), cubic_samplers: BTreeMap::from([(slot(Stage::Fragment, SlotClass::Sampler, 0), 0x2d0)]), - captured_positions: Some(crate::pipeline::CaptureForm::Vertices), primitive_id_indices: Some(metal::IndexType::UInt16), quad_primitive_ids: true, private_list: true, @@ -435,9 +434,6 @@ mod serde_round_trips { (4, crate::pipeline::RotatedBlendForm::Premultiplied), (6, crate::pipeline::RotatedBlendForm::Unmeasured), ]), - captured_positions: Some(crate::pipeline::CaptureForm::Indexed( - metal::IndexType::UInt16, - )), extended_shadows: BTreeSet::from([0]), cross_class: BTreeMap::from([( slot(Stage::Fragment, SlotClass::Texture, 10), diff --git a/crates/metal2vulkan/src/pipeline/compile.rs b/crates/metal2vulkan/src/pipeline/compile.rs index f04b2bf97..ee347b076 100644 --- a/crates/metal2vulkan/src/pipeline/compile.rs +++ b/crates/metal2vulkan/src/pipeline/compile.rs @@ -2262,14 +2262,9 @@ fn lower_inputs( } InputsFrom::Vertex(desc, variant, depth, primitive_id, _) => { let attributes = declared_attributes(spec); - // The indexed capture form, the primitive ID's de-indexed form and the private list - // form pull every attribute, whatever the caller's projection would fetch in fixed - // function. - let pull_every = variant - .captured_positions - .is_some_and(|f| f.index_type().is_some()) - || variant.primitive_id_indices.is_some() - || variant.private_list; + // The primitive ID's de-indexed form and the private list form pull every attribute, + // whatever the caller's projection would fetch in fixed function. + let pull_every = variant.primitive_id_indices.is_some() || variant.private_list; let projection = crate::pipeline::link::vertex::vertex_fetch_projection_for( desc, &attributes, diff --git a/crates/metal2vulkan/src/pipeline/compile/key.rs b/crates/metal2vulkan/src/pipeline/compile/key.rs index 91053ade0..c9677cb4c 100644 --- a/crates/metal2vulkan/src/pipeline/compile/key.rs +++ b/crates/metal2vulkan/src/pipeline/compile/key.rs @@ -418,13 +418,6 @@ pub fn function_key( h.bytes(b"cubic-samplers") .bytes(format!("{:?}", inputs.cubic_samplers).as_bytes()); } - // Appended only when set; the indexed form adds its index type. - if let Some(form) = inputs.captured_positions { - h.bytes(b"captured-positions"); - if let Some(ty) = form.index_type() { - h.bytes(b"indexed").u64(u64::from(ty.as_raw())); - } - } // Appended only when set, in its derived `Debug` form, as `dropped_colors` is: the shadowed // variant of a function whose fetch inputs already hold the color (a blend's) is otherwise the // unshadowed one's key, and a cache would hand it the unshadowed artifact. diff --git a/crates/metal2vulkan/src/pipeline/compile/tests.rs b/crates/metal2vulkan/src/pipeline/compile/tests.rs index c7e6481e9..fb9d2b86d 100644 --- a/crates/metal2vulkan/src/pipeline/compile/tests.rs +++ b/crates/metal2vulkan/src/pipeline/compile/tests.rs @@ -620,25 +620,6 @@ fn function_keys_cover_their_inputs() { assert_ne!(with_true, maps(&[(0, edges)])); assert_ne!(maps(&[(0, edges)]), maps(&[(1, edges)])); assert_ne!(maps(&[(0, edges)]), maps(&[(0, mirrored)])); - // So is the vertex function's capture form. - let captured = |form| { - let mut i = LoweringInputs::new(); - i.captured_positions = Some(form); - a.function_compile_key(&fd, &i) - }; - let vertices = captured(crate::pipeline::CaptureForm::Vertices); - let short = captured(crate::pipeline::CaptureForm::Indexed( - crate::metal::IndexType::UInt16, - )); - let long = captured(crate::pipeline::CaptureForm::Indexed( - crate::metal::IndexType::UInt32, - )); - assert_ne!(with_true, vertices); - assert_ne!(dropped, vertices); - assert_ne!(layer, vertices); - assert_ne!(vertices, short); - assert_ne!(vertices, long); - assert_ne!(short, long); // So are the extended-range colors whose `half` shadow the draw's instance holds. let shadowed = |colors: &[u32]| { let mut i = LoweringInputs::new(); @@ -733,7 +714,6 @@ fn the_inputs_encoding_is_the_earlier_derived_debug() { .replace(", address_maps: {}", "") .replace(", cubic_samplers: {}", "") .replace(", rotated_blends: {}", "") - .replace(", captured_positions: None", "") .replace(", extended_shadows: {}", "") .replace(", cross_class: {}", "") .replace(", texture_write_rounding: TowardZero", "") diff --git a/crates/metal2vulkan/src/pipeline/facts.rs b/crates/metal2vulkan/src/pipeline/facts.rs index 1a0aec92b..a79969e3a 100644 --- a/crates/metal2vulkan/src/pipeline/facts.rs +++ b/crates/metal2vulkan/src/pipeline/facts.rs @@ -573,15 +573,6 @@ pub enum RuntimeFact { multisampled: bool, planes: bool, }, - /// The vertex function was compiled in capture form `form` (`VariantKey::captured_positions`, - /// `LoweringInputs::captured_positions`): each vertex it runs writes a 32-byte record of its - /// clip position, point size and restart flag from `PushField::CaptureAddress`, at the slot - /// `PushField::CaptureLayout` gives it, which the binder writes per draw; the indexed form - /// reads its vertices' indices from `PushField::CaptureIndexAddress`. Its plans state the - /// variant. - CapturedPositions { - form: crate::pipeline::lower_inputs::CaptureForm, - }, /// The `stage` function samples, gathers, or queries a level of a heap texture of a sampled /// float class of one sample, where for a texture a heap holds by its raw texels alone /// (`bind::heap_raw_form`) it reads the class's neutral (zero, or the neutral's level) where diff --git a/crates/metal2vulkan/src/pipeline/link.rs b/crates/metal2vulkan/src/pipeline/link.rs index 00d37e5d8..c6795a08f 100644 --- a/crates/metal2vulkan/src/pipeline/link.rs +++ b/crates/metal2vulkan/src/pipeline/link.rs @@ -79,7 +79,6 @@ use crate::pipeline::descriptor::{ ColorAttachmentDescriptor, MeshPipelineDescriptor, RenderPipelineDescriptor, TessellationDescriptor, VertexDescriptor, }; -use crate::pipeline::facts::RuntimeFact; use crate::pipeline::graphics::GraphicsState; use crate::pipeline::interface::{PipelineInterface, StageDescriptor, StageInterface}; use crate::pipeline::layout::{ @@ -411,19 +410,11 @@ pub fn link( (Some(_), _) | (_, Some(_)) => { tessellation::vertex_input_state(vs, r.vertex_descriptor.as_ref())? } - // A vertex function compiled in the indexed capture form pulled every attribute: - // its fact says so. (None, None) => { let vi = vertex::vertex_input_state( vs, r.vertex_descriptor.as_ref(), &r.pulled_vertex_buffers, - stages.first().is_some_and(|a| { - a.facts.iter().any(|f| { - matches!(f, RuntimeFact::CapturedPositions { form } - if form.index_type().is_some()) - }) - }), &table.locations, p, )?; diff --git a/crates/metal2vulkan/src/pipeline/link/graphics.rs b/crates/metal2vulkan/src/pipeline/link/graphics.rs index 6716fb8e5..9347645cc 100644 --- a/crates/metal2vulkan/src/pipeline/link/graphics.rs +++ b/crates/metal2vulkan/src/pipeline/link/graphics.rs @@ -1093,13 +1093,12 @@ fn uniform_blend( /// `NotImplemented(Format)`: Metal keeps a masked channel's code but rewrites the texel's other /// bits (`BGRA10_XR`'s alpha clamped even where masked, its low bits and `BGR10_XR`'s top bits /// made canonical), which a mask of the raw components cannot express. A padded form's channels are -/// its raw words, one each, and the mask is theirs: a loading pass that draws keeps a masked -/// channel's code and zeroes its word's low six bits, every word of each tile it stores alike (an -/// Apple M3 Max and an M4, byte-identical), which a consumer's load pass does before the pass (the -/// runtime's `render/unused_bits_load.rs`, `bind::unused_bits_module`), so a channel the mask -/// leaves out keeps the word Metal's pass leaves. A bfloat form's channels are its own (red; red -/// and green; all four), each a raw component; a mask of some of them is unmeasured and refused as -/// above. +/// its raw words, one each, and the mask is theirs: a channel the mask leaves out keeps its word +/// as the device's pass stores it, where Metal's loading pass that draws keeps the channel's code +/// and zeroes its word's low six bits, every word of each tile it stores alike (an Apple M3 Max +/// and an M4, byte-identical; the runtime's `extended-range-bits-kept`). A bfloat form's channels +/// are its own (red; red and green; all four), each a raw component; a mask of some of them is +/// unmeasured and refused as above. fn extended_write_mask( form: ExtendedRange, mask: vk::ColorComponentFlags, diff --git a/crates/metal2vulkan/src/pipeline/link/vertex.rs b/crates/metal2vulkan/src/pipeline/link/vertex.rs index ab2bf1643..374d9e95b 100644 --- a/crates/metal2vulkan/src/pipeline/link/vertex.rs +++ b/crates/metal2vulkan/src/pipeline/link/vertex.rs @@ -53,10 +53,11 @@ //! shape binds such a layout at an offset or with a per-bind stride fixed-function input //! cannot fetch. It runs after the items above, so the variant's fixed-function bindings are //! exactly the projection's others, attribute for attribute; -//! 8. the **indexed capture form** (`CaptureForm::Indexed`) pulls every remaining fixed-function -//! attribute: its draw runs without indices, so fixed-function input would fetch at the stream -//! position, where the function reads the vertex its index names. The layouts it pulls are not a -//! pulled-vertex-buffer variant's (`variant_pulled` keeps item 7's). +//! 8. the **de-indexed and private list forms** (`VariantKey::primitive_id_indices`, +//! `VariantKey::private_list`) pull every remaining fixed-function attribute in the projection +//! their compile takes: their draw runs without indices, so fixed-function input would fetch at +//! the stream position, where the function reads the vertex its index names. The layouts they +//! pull are not a pulled-vertex-buffer variant's (`variant_pulled` keeps item 7's). //! //! A fixed-function entry keeps nothing of the format (`VertexFetch::FixedFunction`): no //! instruction of the module names it, so every format the device fetches in fixed function @@ -276,7 +277,7 @@ fn resolve<'a>( moved.insert(r.attr.buffer_index); } } - // The indexed capture form (item 8). + // The de-indexed and private list forms (item 8). if pull_every { for r in out.values_mut() { r.fetch = AttributeFetch::Pulled; @@ -312,9 +313,10 @@ pub fn vertex_fetch_projection( vertex_fetch_projection_for(desc, attributes, p, &BTreeSet::new(), false) } -/// `vertex_fetch_projection` under a pulled-vertex-buffer variant and capture form: the -/// attributes of the layouts in `pulled_vertex_buffers` (`VariantKey::pulled_vertex_buffers`) -/// are pulled (item 7), and every attribute when `pull_every` (the indexed capture form, item 8). +/// `vertex_fetch_projection` under a pulled-vertex-buffer variant and a form that pulls every +/// attribute: the attributes of the layouts in `pulled_vertex_buffers` +/// (`VariantKey::pulled_vertex_buffers`) are pulled (item 7), and every attribute when +/// `pull_every` (the de-indexed and private list forms, item 8). pub fn vertex_fetch_projection_for( desc: Option<&VertexDescriptor>, attributes: &BTreeMap, @@ -427,21 +429,19 @@ fn rounds_twice_to_half(e: Encoding) -> bool { } /// The vertex input state of vertex stage `vs` for descriptor `desc` under the -/// pulled-vertex-buffer variant `pulled_vertex_buffers` and, when `pull_every`, the indexed -/// capture form (see the module docs), with each fixed-function attribute at the location link -/// assigned its key. Fixed-function bindings are numbered densely in Metal buffer-index order; +/// pulled-vertex-buffer variant `pulled_vertex_buffers` (see the module docs), with each +/// fixed-function attribute at the location link assigned its key. Fixed-function bindings are numbered densely in Metal buffer-index order; /// `variant_pulled` records the layouts the variant moved. pub fn vertex_input_state( vs: &StageInterface, desc: Option<&VertexDescriptor>, pulled_vertex_buffers: &BTreeSet, - pull_every: bool, locations: &Locations, p: &DeviceProfile, ) -> Result { let used = vs.io.attributes(); let numeric: BTreeMap = used.iter().map(|(a, (n, _))| (*a, *n)).collect(); - let (resolved, moved) = resolve(desc, &numeric, p, pulled_vertex_buffers, pull_every)?; + let (resolved, moved) = resolve(desc, &numeric, p, pulled_vertex_buffers, false)?; for (a, (_, fetch)) in &used { // The stage was compiled under another projection (a `Compiled` stage source whose // `LowerInputs` do not fit this descriptor). diff --git a/crates/metal2vulkan/src/pipeline/lower_inputs.rs b/crates/metal2vulkan/src/pipeline/lower_inputs.rs index 1e92be806..5a5c2f54c 100644 --- a/crates/metal2vulkan/src/pipeline/lower_inputs.rs +++ b/crates/metal2vulkan/src/pipeline/lower_inputs.rs @@ -121,8 +121,8 @@ pub struct LoweringInputs { /// command's draw's, and its buffers are in the command's vertex slot table. A fragment /// function under it reads no buffer and no `[[primitive_id]]`, which a merged draw does not /// keep per command: one that does is `Unsupported{GpuEncodedIndirectCommands, - /// NotImplemented}`, and so is a vertex function that writes the primitive ID's varying, - /// draws amplifications as draws of their own or captures its positions. The vertex function + /// NotImplemented}`, and so is a vertex function that writes the primitive ID's varying or + /// draws amplifications as draws of their own. The vertex function /// states `RuntimeFact::MergedDraws`. Any other stage compiles as without it. #[cfg_attr(feature = "serde", serde(default))] pub merged_draws: bool, @@ -268,8 +268,7 @@ pub struct LoweringInputs { /// without indices, so its stream position `p = VertexIndex` is the position the primitive /// ID divides, `(VertexIndex - 0) / n`. The vertex reads its raw index at /// `PushField::CaptureIndexAddress + p · size` and runs `raw + base vertex` from - /// `PushField::CaptureLayout` `[0, index count, base instance, base vertex]`, as the indexed - /// capture form does (`CaptureForm::Indexed`, without its records): `[[vertex_id]]`, + /// `PushField::CaptureLayout` `[0, index count, base instance, base vertex]`: `[[vertex_id]]`, /// `[[base_vertex]]` and every per-vertex attribute, all pulled, read that vertex. Refused /// `NotImplemented(PrimitiveId)`: a vertex function that writes device memory, which would run /// once per index rather than once per vertex Metal shades, and a hand-built projection @@ -669,22 +668,6 @@ pub struct LoweringInputs { /// function. #[cfg_attr(feature = "serde", serde(default))] pub rotated_blends: BTreeMap, - /// A vertex function's capture form (`VariantKey::captured_positions`, [`CaptureForm`]): at - /// each return it also writes a 32-byte record of the vertex, its `[[position]]` as returned - /// (Metal's clip position, before any viewport compensation) at byte 0, its `[[point_size]]` - /// (1.0 where it writes none) at byte 16, and a `u32` restart flag at byte 20 (1 where the - /// indexed form's index is its type's all-ones value, Metal's strip restart index; 0 - /// otherwise and in the vertices form), words 6 and 7 left unwritten, at - /// `PushField::CaptureAddress + 32 slot`, `slot = p + (InstanceIndex - first instance) · - /// vertex count` in 64 bits from `PushField::CaptureLayout` (`p` is `VertexIndex` less the - /// first vertex in the vertices form, `VertexIndex` itself in the indexed form), and states - /// `RuntimeFact::CapturedPositions`. A function that writes no position plans no record. - /// Under [`CaptureForm::Indexed`] the function also reads its vertex from the draw's - /// index buffer (see there). Refused `Feature::TileReach`: a device without device addresses - /// or the vertex stage's stores, and a post-tessellation vertex function. Any other function - /// compiles as without it. - #[cfg_attr(feature = "serde", serde(default))] - pub captured_positions: Option, /// The extended-range color attachments, by color index, whose `half` shadow the draw's /// render pass instance holds (`VariantKey::extended_shadows`): Metal's tile memory holds /// such an attachment as `half` through the pass and rounds it to the codes once at the @@ -873,44 +856,6 @@ impl ColorGroup { } } -/// The draws a vertex function's capture form (`LoweringInputs::captured_positions`) runs -/// under: each writes one record per vertex per instance, `p + (InstanceIndex - first instance) · -/// vertex count` from `PushField::CaptureLayout`, for stream position `p` (see each form). -#[non_exhaustive] -#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub enum CaptureForm { - /// The draw's own non-indexed draw (`drawPrimitives:`), drawn as it is: the layout is - /// `[vertex start, vertex count, base instance, 0]`, and the function sees its vertices as - /// the draw does. - Vertices, - /// An indexed draw (`drawIndexedPrimitives:`) of this index type, drawn without indices as - /// `index count` vertices from vertex 0 with the draw's instance count and base instance: the - /// layout is `[restarts, index count, base instance, base vertex]`, `restarts` 1 for a line - /// or triangle strip. Stream position `p = VertexIndex` reads the draw's raw index at - /// `PushField::CaptureIndexAddress + p · size` (the binder's consumer folds the index buffer's - /// offset into the address; a `u16` index is read from the aligned word that holds it), and - /// the vertex is `raw + base vertex` in wrapping `u32` arithmetic. That vertex is - /// `[[vertex_id]]` and every per-vertex attribute's element, and the layout's base vertex is - /// `[[base_vertex]]`; the instance builtins are the draw's. Every attribute is pulled - /// (fixed-function input would fetch at `p`): an attribute a hand-built projection fetches in - /// fixed function is refused `Feature::TileReach`. The record's restart flag is 1 where the - /// raw index is the type's all-ones value. Where the draw restarts and the raw index is that - /// value, Metal shades no vertex: the function stores its record's restart flag alone and - /// returns before its body. - Indexed(metal::IndexType), -} - -impl CaptureForm { - /// The index type of the indexed form; `None` for the vertices form. - pub fn index_type(self) -> Option { - match self { - CaptureForm::Vertices => None, - CaptureForm::Indexed(ty) => Some(ty), - } - } -} - /// How the blend of an attachment held with its channels rotated reads the fragment function's /// first output there (`LoweringInputs::rotated_blends`). Apple's blend does not compute each /// factor pair alike in its color and alpha arithmetic, and the rotation moves Metal's blue into diff --git a/crates/metal2vulkan/src/pipeline/mod.rs b/crates/metal2vulkan/src/pipeline/mod.rs index 90a45eff9..22192a211 100644 --- a/crates/metal2vulkan/src/pipeline/mod.rs +++ b/crates/metal2vulkan/src/pipeline/mod.rs @@ -131,9 +131,9 @@ pub use layout::{ }; pub use link::heap_unused_while_pending; pub use lower_inputs::{ - AliasView, AmplificationDraws, BlendEquation, CaptureForm, ChannelWrite, ColorGroup, - ExtendedRangeColor, FactorLane, FetchedAttachment, FramebufferFetchInputs, LoweringInputs, - RotatedBlendForm, StorageImageChoice, StorageImageClass, VertexFetch, VertexFetchProjection, + AliasView, AmplificationDraws, BlendEquation, ChannelWrite, ColorGroup, ExtendedRangeColor, + FactorLane, FetchedAttachment, FramebufferFetchInputs, LoweringInputs, RotatedBlendForm, + StorageImageChoice, StorageImageClass, VertexFetch, VertexFetchProjection, ViewportCompensation, }; pub use table::FunctionHandle; diff --git a/crates/metal2vulkan/src/pipeline/sym.rs b/crates/metal2vulkan/src/pipeline/sym.rs index 3c59fff81..b2ab864be 100644 --- a/crates/metal2vulkan/src/pipeline/sym.rs +++ b/crates/metal2vulkan/src/pipeline/sym.rs @@ -846,17 +846,13 @@ pub enum PushField { /// Device address of the `ExecutionStatus` buffer: a function that counts resident-set misses /// has dynamic roots, so it reaches memory by device address already. ExecutionStatusAddress, - /// Device address (`u64`) of the draw's first capture record, which a vertex function - /// compiled under `LoweringInputs::captured_positions` writes its vertices' records from - /// (`RuntimeFact::CapturedPositions`): a hole the consumer fills - /// (`PushHole::CaptureAddress`), placed with the other addresses so the vertex window + /// Device address (`u64`) of the first index a de-indexed draw reads + /// (`LoweringInputs::primitive_id_indices`): the index buffer's address plus the draw's index + /// buffer offset, a multiple of the index size; or of a private list form draw's list + /// (`LoweringInputs::private_list`). A vertex function compiled in either form reads its + /// stream position's raw index there: a hole the consumer fills + /// (`PushHole::CaptureIndexAddress`), placed with the other addresses so the vertex window /// always holds it. - CaptureAddress, - /// Device address (`u64`) of the first index an indexed capture draw reads - /// (`CaptureForm::Indexed`): the index buffer's address plus the draw's index buffer offset, - /// a multiple of the index size. A vertex function compiled in that form reads its stream - /// position's raw index there: a hole the consumer fills (`PushHole::CaptureIndexAddress`), - /// placed beside `CaptureAddress`. CaptureIndexAddress, /// Device address (`u64`) of a merged draw replay's header (`bind::replay`'s `merged.rs`), /// which a vertex function compiled under `LoweringInputs::merged_draws` reads its corner's @@ -1009,15 +1005,11 @@ pub enum PushField { /// clip mode is `MTLDepthClipModeClamp` in bit 4; words 1 and 2 the bits of viewport 0's near /// and far depth (`f32`); word 3 is 0 (`bind::shader_tests_words`). ShaderTestsState, - /// The draw's capture layout for a vertex function compiled under - /// `LoweringInputs::captured_positions` (`RuntimeFact::CapturedPositions`), a `uvec4`. In the - /// vertices form: the draw's first vertex, its vertex count, its first instance, and 0. In the - /// indexed form, whose draw runs from vertex 0: 1 where the draw restarts at the index type's - /// all-ones index (a line or triangle strip, `BindState::primitive_type`) and 0 otherwise, - /// the index count, the first instance, and the base vertex. Stream position `p` (`VertexIndex` - /// less the first vertex in the vertices form, `VertexIndex` itself in the indexed form) of - /// instance `i` writes record `p + (i - first instance) · count` from - /// `PushField::CaptureAddress`. + /// The draw's layout for a vertex function compiled in the primitive ID's de-indexed form + /// (`LoweringInputs::primitive_id_indices`), a `uvec4`, of a draw run from vertex 0: 0, the + /// index count, the first instance, and the base vertex. Stream position `p = VertexIndex` + /// reads its raw index at `PushField::CaptureIndexAddress`, and its vertex is that index plus + /// the base vertex. CaptureLayout, /// The channels each storage-form color attachment's write keeps from its texel, where the /// fragment function takes them from the draw: one `u32` whose bits `4c` to `4c + 3` are color @@ -1176,7 +1168,6 @@ mod tests { let ordered = [ PushField::RootTableAddress, PushField::ExecutionStatusAddress, - PushField::CaptureAddress, PushField::CaptureIndexAddress, PushField::SnapshotPhase, PushField::DispatchRegion, diff --git a/crates/metal2vulkan/src/spirv/requirements/writes.rs b/crates/metal2vulkan/src/spirv/requirements/writes.rs index 9b9f6b0f4..fe053bd33 100644 --- a/crates/metal2vulkan/src/spirv/requirements/writes.rs +++ b/crates/metal2vulkan/src/spirv/requirements/writes.rs @@ -21,12 +21,8 @@ //! selected value), is the function's: the guest never holds the status buffer's address, so no //! write of the guest's is taken for the product's. //! -//! A vertex function's capture records are the product's too: they hand the draw's clip positions -//! to the tile reach kernel, and a capture variant writes memory exactly where the function does. -//! They are written at the push block's `CaptureAddress` member plus the vertex's record offset, so -//! the trace also ends at an `OpIAdd` whose one operand is a load of either address member, -//! whatever the other: the guest holds neither address, so no sum of the guest's has such an -//! operand. +//! The trace also ends at an `OpIAdd` whose one operand is a load of the address member, whatever +//! the other: the guest does not hold the address, so no sum of the guest's has such an operand. //! //! An emulated mesh function's records (`Synthetic(MeshRecords)`) are the product's too, traced as //! the status buffer's binding is: they hand the function's outputs to the pipeline's synthesized @@ -112,8 +108,7 @@ struct Status<'m> { shadows: Vec, /// The push block's variable. block: Option, - /// The indices of its `ExecutionStatusAddress` and `CaptureAddress` members, the product's - /// addresses. + /// The indices of its `ExecutionStatusAddress` members, the product's address. members: Vec, /// The defining instruction of every access chain, `OpConvertUToPtr`, `OpIAdd`, and load; /// empty when the module reaches no status buffer. @@ -155,12 +150,7 @@ impl<'m> Status<'m> { s.members = m .push_members() .iter() - .filter(|p| { - matches!( - p.field, - PushField::ExecutionStatusAddress | PushField::CaptureAddress - ) - }) + .filter(|p| matches!(p.field, PushField::ExecutionStatusAddress)) .map(|p| p.index) .collect(); s.block = Some(g.value); @@ -212,7 +202,7 @@ impl<'m> Status<'m> { self.shadows.contains(&image) } - /// Whether pointer `ptr` addresses the `ExecutionStatus` buffer or a capture record. + /// Whether pointer `ptr` addresses the `ExecutionStatus` buffer. fn addresses(&self, m: &TypedModule, ptr: Value) -> BResult { let mut v = ptr; // Each step moves to an operand of the value's defining instruction, which SSA defines @@ -236,7 +226,7 @@ impl<'m> Status<'m> { }) => match (constant(m, *a)?, constant(m, *b)?) { (false, true) => *a, (true, false) => *b, - // A product address plus any offset (a capture record's). + // The product's address plus any offset. (false, false) => { return Ok(self.loads_member(m, *a)? || self.loads_member(m, *b)?) } @@ -249,7 +239,7 @@ impl<'m> Status<'m> { Ok(false) } - /// Whether `v` is a load of one of the push block's product address members. + /// Whether `v` is a load of the push block's product address member. fn loads_member(&self, m: &TypedModule, v: Value) -> BResult { match self.defs.get(&v) { Some(Inst::Load { ptr, .. }) => self.is_member(m, *ptr), @@ -257,8 +247,7 @@ impl<'m> Status<'m> { } } - /// Whether `ptr` points to the push block's `ExecutionStatusAddress` or `CaptureAddress` - /// member. + /// Whether `ptr` points to the push block's `ExecutionStatusAddress` member. fn is_member(&self, m: &TypedModule, ptr: Value) -> BResult { let (Some(block), Some(Inst::AccessChain { base, indices, .. })) = (self.block, self.defs.get(&ptr)) diff --git a/crates/metal2vulkan/src/spirv/requirements/writes/tests.rs b/crates/metal2vulkan/src/spirv/requirements/writes/tests.rs index 9d3e664b8..0f7ce76e3 100644 --- a/crates/metal2vulkan/src/spirv/requirements/writes/tests.rs +++ b/crates/metal2vulkan/src/spirv/requirements/writes/tests.rs @@ -261,9 +261,9 @@ fn a_colors_storage_form_and_half_shadow_writes_are_not_the_functions() { assert!(writes_memory(&image_write(ResourceKind::Texture)).expect("a texture")); } -/// A module that stores as a vertex function's capture record does: a `vec4` at -/// `address + slot * 32` and an `f32` 16 bytes past it, `slot` an input's value (not a -/// constant), `address` the push block's member of `address`. +/// A module that stores a record at a slot the draw computes: a `vec4` at `address + slot * 32` +/// and an `f32` 16 bytes past it, `slot` an input's value (not a constant), `address` the push +/// block's member of `address`. fn record_store(address: PushField) -> TypedModule { let mut b = ModuleBuilder::new(); let u32_ = int(&mut b, 32); @@ -302,11 +302,11 @@ fn record_store(address: PushField) -> TypedModule { fragment(b, main) } -/// A capture record's stores, at the push block's `CaptureAddress` plus an offset that is not a -/// constant, are the product's; the same stores from another `u64` address member -/// (`RootTableAddress`, whose trace reaches the push block's load) are the function's. +/// Stores at the push block's `ExecutionStatusAddress` plus an offset that is not a constant are +/// the product's; the same stores from another `u64` address member (`RootTableAddress`, whose +/// trace reaches the push block's load) are the function's. #[test] -fn the_capture_records_are_not_the_functions_writes() { - assert!(!writes_memory(&record_store(PushField::CaptureAddress)).expect("capture")); +fn stores_past_the_status_address_are_not_the_functions_writes() { + assert!(!writes_memory(&record_store(PushField::ExecutionStatusAddress)).expect("status")); assert!(writes_memory(&record_store(PushField::RootTableAddress)).expect("another address")); } diff --git a/crates/metal2vulkan/src/tests/engine_extended_range/targets.rs b/crates/metal2vulkan/src/tests/engine_extended_range/targets.rs index 380bed55f..d74d429ea 100644 --- a/crates/metal2vulkan/src/tests/engine_extended_range/targets.rs +++ b/crates/metal2vulkan/src/tests/engine_extended_range/targets.rs @@ -447,9 +447,8 @@ fn fragment_outputs_to_bfloat_targets_write_raw_codes() { /// A padded attachment (`R10Unorm_X6`, `RG10Unorm_X12`, and their `_sRGB` twins, the store's code /// through the twin's table) links under every write mask, the fixture's `float4` fill writing the -/// raw words its mask keeps: a channel is a raw word, and one the mask leaves out keeps the word a -/// consumer's load pass left, as Metal's pass leaves it (`bind::unused_bits_module`). Each module -/// passes L3. +/// raw words its mask keeps: a channel is a raw word, and one the mask leaves out keeps the word +/// the pass loaded. Each module passes L3. #[test] fn padded_targets_write_the_words_their_mask_keeps() { let Some(bc) = fixture() else { diff --git a/crates/metal2vulkan/src/tests/engine_vertex_capture.rs b/crates/metal2vulkan/src/tests/engine_vertex_capture.rs deleted file mode 100644 index 6898c06bc..000000000 --- a/crates/metal2vulkan/src/tests/engine_vertex_capture.rs +++ /dev/null @@ -1,1228 +0,0 @@ -//! A vertex function's capture form (`LoweringInputs::captured_positions`), over the owned fixtures -//! `engine/rch_vertex_math` (a position from a buffer at its vertex index through three -//! matrices, no point size) and `engine/stage_io` (`stage_io_vertex`: a position, a point size, -//! and the vertex and instance indices of its own) and `engine/vertex_amplification` (a -//! post-tessellation vertex function): -//! -//! - Captured, the function states `RuntimeFact::CapturedPositions`, reads -//! `PushField::CaptureAddress` (a `u64` in its push window) and `PushField::CaptureLayout` (a -//! `uvec4`), declares the vertex and instance indices, stores through physical storage buffer -//! addresses (so it needs `bufferDeviceAddress` and `vertexPipelineStoresAndAtomics`), and still -//! writes no memory of its own (`StageInterface::writes_memory`); every module passes L3 and -//! the words the capture adds are bounded. Compiled without it the function is unchanged. -//! - A device without device addresses, or without the vertex stage's stores, refuses the capture -//! `Feature::TileReach`, naming what it needs; a post-tessellation vertex function is -//! `NotImplemented(TileReach)`. -//! - The capture variant of a render pipeline has its own keys, states its fact as a variant, its -//! plan settles on its own key, and a direct draw leaves `PushHole::CaptureAddress` in the -//! vertex window and writes the draw's first vertex, vertex count and first instance as its -//! layout; an indexed draw of it asks for the indexed form's variant, and an indirect or -//! amplified one is `NotImplemented(TileReach)`. -//! - The indexed form (`CaptureForm::Indexed`) reads each vertex from the draw's index buffer at -//! `PushField::CaptureIndexAddress`, on the CPU interpreter: `u16` indices at 2- and 4-aligned -//! addresses and `u32` ones, with a wrapping base vertex and instances, feed `[[vertex_id]]` and -//! every pulled attribute, and each record's restart flag marks the all-ones index. Its -//! projection pulls every attribute; its pipeline links, plans itself, and its indexed draws run -//! without indices, reading the indices in the vertex stage. -//! -//! `llvm-as` assembles the fixtures; a missing tool skips visibly. No GPU is used. - -use std::collections::{BTreeMap, BTreeSet}; -use std::path::Path; - -use crate::bind::{ - AccessClass, BindState, BoundBuffer, ByteRange, DrawCall, IndexBufferRef, IndirectRef, - PushHole, ResourceUse, StageTable, UseTarget, VertexAmplification, ViewMapping, -}; -use crate::budget::Budget; -use crate::cache::VariantKey; -use crate::device::requirements::{SpirvCapability, VkFeature as F}; -use crate::device::{Device, DeviceDescription, DevicePolicy, DeviceProfile}; -use crate::error::{BindError, Capability, Error, Feature, Unsupported}; -use crate::library::{FunctionArtifact, Library}; -use crate::lower::select::Plan; -use crate::memory::contain; -use crate::metal::{self, IndexType, VertexFormat}; -use crate::pipeline::descriptor::{ - FunctionDescriptor, RenderPipelineDescriptor, StageSource, VertexAttributeDescriptor, - VertexBufferLayoutDescriptor, VertexDescriptor, -}; -use crate::pipeline::facts::{Mechanism, RuntimeFact}; -use crate::pipeline::interface::{AccessSet, PushLoc}; -use crate::pipeline::link::vertex::vertex_fetch_projection_for; -use crate::pipeline::link::{link, LinkInputs}; -use crate::pipeline::lower_inputs::{ - CaptureForm, LoweringInputs, VertexFetch, VertexFetchProjection, -}; -use crate::pipeline::relocate::relocate; -use crate::pipeline::stage_io::{IoNumeric, StageBuiltin}; -use crate::pipeline::sym::{PushField, ResourceKind, ResourceSlot, Stage}; -use crate::pipeline::testing::{ - compile_with, engine_dir, llvm_assemble, typed_module_with, AssembleError, -}; -use crate::spirv::interp::{run as interp_run, Buffer, Config, Resources}; -use crate::spirv::ir::TypedModule; -use crate::spirv::testing::check_words_valid; -use crate::vk; - -/// The bitcode of the owned fixture `stem` (`engine/.ll`), or `None` (printed) where -/// `llvm-as` is missing. -fn fixture(stem: &str) -> Option> { - match llvm_assemble(&engine_dir().join(format!("{stem}.ll"))) { - Ok(b) => Some(b), - Err(AssembleError::Missing(why)) => { - eprintln!("SKIPPED: {why}"); - None - } - Err(AssembleError::Rejected(why)) => panic!("llvm-as rejected {stem}.ll: {why}"), - } -} - -fn description(stem: &str) -> DeviceDescription { - let path = Path::new(env!("CARGO_MANIFEST_DIR")) - .join("../metal2vulkan-validation/profiles") - .join(format!("{stem}.json")); - let text = std::fs::read_to_string(path).expect("profile"); - DeviceDescription::from_khronos_json(&text, None).expect("description") -} - -fn device_of(desc: DeviceDescription) -> Device { - Device::new(desc, DevicePolicy::default()).expect("device") -} - -/// The lowering inputs of capture form `form`, or of none. -fn inputs(form: Option) -> LoweringInputs { - let mut inputs = LoweringInputs::new(); - inputs.captured_positions = form; - inputs -} - -/// Link `a` alone, relocate it, and run L3; its relocated words. -fn validate(a: &FunctionArtifact, p: &DeviceProfile) -> Vec { - let linked = link(&[a], &LinkInputs::standalone(), p).unwrap_or_else(|e| panic!("link: {e}")); - let words = relocate(a, &linked.table).expect("relocate"); - check_words_valid(&words, &a.requirements, p).unwrap_or_else(|e| panic!("L3: {e}")); - words -} - -/// `e` without the location an `Unsupported` carries. -fn unlocated(e: Error) -> Error { - match e { - Error::Unsupported(u) => Error::Unsupported(Unsupported { - location: None, - ..u - }), - other => other, - } -} - -fn physical_addresses() -> SpirvCapability { - SpirvCapability::from_raw(crate::spv::Capability::PhysicalStorageBufferAddresses as u32) -} - -/// Each entry compiled without the capture and with it: the fact, the two push fields (the -/// address in the vertex window), the indices, the device-address stores and their needs, no -/// memory of the function's own, L3, and the words the capture adds (printed; bounded: measured -/// 246 to 259 on lavapipe and MoltenVK). -#[test] -fn a_captured_vertex_function_writes_its_records() { - let entries = [ - ("rch_vertex_math", "rch_vertex_math"), - ("stage_io", "stage_io_vertex"), - ]; - for stem in ["lavapipe", "moltenvk-m3"] { - let dev = device_of(description(stem)); - let p = dev.profile(); - for (fixture_stem, entry) in entries { - let Some(bc) = fixture(fixture_stem) else { - return; - }; - let what = format!("{stem} {entry}"); - let plain = compile_with(&bc, entry, p, &inputs(None)) - .unwrap_or_else(|e| panic!("{what}: {e}")); - let plain_words = validate(&plain, p).len(); - assert!( - !plain - .facts - .iter() - .any(|f| matches!(f, RuntimeFact::CapturedPositions { .. })), - "{what}" - ); - assert!( - !plain.interface.push.fields.iter().any(|f| matches!( - f.field, - PushField::CaptureAddress | PushField::CaptureLayout - )), - "{what}" - ); - let a = compile_with(&bc, entry, p, &inputs(Some(CaptureForm::Vertices))) - .unwrap_or_else(|e| panic!("{what} captured: {e}")); - let words = validate(&a, p).len(); - assert!( - a.facts.contains(&RuntimeFact::CapturedPositions { - form: CaptureForm::Vertices - }), - "{what}" - ); - let field = |field: PushField| { - a.interface - .push - .fields - .iter() - .find(|f| f.field == field) - .copied() - .unwrap_or_else(|| panic!("{what}: no {field:?}")) - }; - let address = field(PushField::CaptureAddress); - let PushLoc::Push { offset } = address.loc else { - panic!("{what}: the capture address spilled: {address:?}"); - }; - assert_eq!(address.size, 8, "{what}"); - assert!(offset + 8 <= 64, "{what}: {offset}"); - assert_eq!(field(PushField::CaptureLayout).size, 16, "{what}"); - let builtins = &a.interface.io.builtins; - assert!(builtins.contains(&StageBuiltin::VertexIndex), "{what}"); - assert!(builtins.contains(&StageBuiltin::InstanceIndex), "{what}"); - // Its records are stored through device addresses from the vertex stage. - let r = &a.requirements; - assert!( - r.spirv_capabilities.contains(&physical_addresses()), - "{what}" - ); - assert!(r.features.contains(&F::BufferDeviceAddress), "{what}"); - assert!( - r.features.contains(&F::VertexPipelineStoresAndAtomics), - "{what}" - ); - assert!( - !plain - .requirements - .features - .contains(&F::VertexPipelineStoresAndAtomics), - "{what}" - ); - // The records are the product's: the function writes no memory of its own. - assert!(!a.interface.writes_memory, "{what}"); - let added = words as i64 - plain_words as i64; - println!("{what}: the capture adds {added} words to {plain_words}"); - assert!((0..=300).contains(&added), "{what}: {added} words"); - } - } -} - -/// The capture needs device addresses and the vertex stage's stores, refused `TileReach` -/// naming them; a post-tessellation vertex function's vertices are the tessellator's, so its -/// capture is not implemented. -#[test] -fn the_capture_needs_addresses_and_vertex_stores() { - let Some(bc) = fixture("rch_vertex_math") else { - return; - }; - let Some(amplification) = fixture("vertex_amplification") else { - return; - }; - let floor = device_of(description("vk12-floor")); - let p = floor.profile(); - compile_with(&bc, "rch_vertex_math", p, &inputs(None)).expect("without the capture"); - for form in [ - CaptureForm::Vertices, - CaptureForm::Indexed(IndexType::UInt16), - ] { - let refusal = compile_with(&bc, "rch_vertex_math", p, &inputs(Some(form))) - .map(|_| ()) - .map_err(unlocated); - assert_eq!( - refusal, - Err(Error::Unsupported(Unsupported::needs_any_of( - Feature::TileReach, - vec![p.addressed_needs()] - ))), - "{form:?}" - ); - } - let mut desc = description("moltenvk-m3"); - assert!(desc.features.remove(&F::VertexPipelineStoresAndAtomics)); - let without = device_of(desc); - let refusal = compile_with( - &bc, - "rch_vertex_math", - without.profile(), - &inputs(Some(CaptureForm::Vertices)), - ) - .map(|_| ()) - .map_err(unlocated); - assert_eq!( - refusal, - Err(Error::Unsupported(Unsupported::needs( - Feature::TileReach, - Capability::Feature(F::VertexPipelineStoresAndAtomics) - ))) - ); - let lavapipe = device_of(description("lavapipe")); - let refusal = compile_with( - &lification, - "amp_post_tessellation", - lavapipe.profile(), - &inputs(Some(CaptureForm::Indexed(IndexType::UInt32))), - ) - .map(|_| ()) - .map_err(unlocated); - assert_eq!( - refusal, - Err(Error::Unsupported(Unsupported::not_implemented( - Feature::TileReach - ))) - ); -} - -/// `rch_vertex_math`'s buffers: its positions at 0 and its matrices at 1. -fn bound() -> BindState { - let buffer = |length| BoundBuffer::Buffer { - length, - offset: 0, - gpu_address: 0x1_0000, - device_address: Some(0x7_0000_0000), - attribute_stride: None, - }; - let mut v = StageTable::default(); - v.buffers.insert(0, buffer(1024)); - v.buffers.insert(1, buffer(256)); - let mut s = BindState::default(); - s.stages.insert(Stage::Vertex, v); - s -} - -/// The capture variant of `rch_vertex_math`'s render pipeline: its own keys, its fact as a -/// variant, a plan that settles on its key, and a direct draw's hole and layout; the base -/// pipeline's plan asks for no capture. An indexed draw of the variant asks for the indexed form -/// of its index type; an indirect or amplified one is `NotImplemented(TileReach)`. -#[test] -fn a_capture_variant_plans_itself_and_writes_each_draws_layout() { - let Some(bc) = fixture("rch_vertex_math") else { - return; - }; - let budget = Budget::standard(); - let lib = Library::from_air(&bc).expect("library"); - let function = FunctionDescriptor::new(lib.function("rch_vertex_math").expect("function")); - let d = RenderPipelineDescriptor::new(StageSource::Function(function.clone())); - let mut key = VariantKey::new(); - key.captured_positions = Some(CaptureForm::Vertices); - assert!(!key.is_empty()); - assert_eq!( - key.lowering_inputs(Stage::Vertex).captured_positions, - Some(CaptureForm::Vertices) - ); - assert_eq!( - key.lowering_inputs(Stage::Fragment).captured_positions, - None - ); - for stem in ["lavapipe", "moltenvk-m3"] { - let dev = device_of(description(stem)); - let base = dev - .compile_render_pipeline(&d, &budget) - .unwrap_or_else(|e| panic!("{stem}: {e}")); - let keys = dev - .render_variant_key(&d, &key, &budget, &crate::pipeline::StageEntries::new()) - .expect("keys"); - let base_keys = dev.render_pipeline_key(&d, &budget).expect("keys"); - assert_ne!(keys.vertex, base_keys.vertex, "{stem}"); - assert_ne!(keys.pipeline, base_keys.pipeline, "{stem}"); - let vertex_inputs = keys.vertex_inputs.clone().expect("vertex inputs"); - assert_eq!( - vertex_inputs.captured_positions, - Some(CaptureForm::Vertices), - "{stem}" - ); - assert_eq!( - keys.vertex, - dev.function_compile_key(&function, &vertex_inputs), - "{stem}" - ); - let p = dev - .compile_render_variant(&d, &key, &budget) - .unwrap_or_else(|e| panic!("{stem}: {e}")); - assert_eq!(p.key, keys.pipeline, "{stem}"); - for m in &p.stages { - check_words_valid(&m.spirv, &p.requirements, dev.profile()) - .unwrap_or_else(|e| panic!("{stem} {:?}: L3: {e}", m.stage)); - } - assert!( - p.dependencies.iter().any(|d| d.fact - == RuntimeFact::CapturedPositions { - form: CaptureForm::Vertices - } - && d.mechanism == Mechanism::Variant), - "{stem}" - ); - assert!(!p.graphics.vertex_writes_memory, "{stem}"); - - let state = bound(); - let plan = base.plan(&dev, &state.shape()).expect("base plan"); - assert!(plan.variant.is_empty(), "{stem}"); - let plan = p.plan(&dev, &state.shape()).expect("plan"); - assert_eq!(plan.variant, key, "{stem}"); - let draw = DrawCall::Primitives { - vertex_start: 5, - vertex_count: 7, - instance_count: 2, - base_instance: 3, - }; - let commands = plan - .instantiate_draw(&state, &draw) - .unwrap_or_else(|e| panic!("{stem}: {e:?}")); - let holes: Vec<_> = commands - .push_holes - .iter() - .filter_map(|h| match *h { - PushHole::CaptureAddress { stages, offset } => Some((stages, offset)), - _ => None, - }) - .collect(); - let [(stages, offset)] = holes[..] else { - panic!("{stem}: {:?}", commands.push_holes); - }; - assert_eq!(stages, vk::ShaderStageFlags::VERTEX, "{stem}"); - assert!(offset + 8 <= 64, "{stem}: {offset}"); - let layout = plan - .push - .fields - .iter() - .find(|f| f.stage == Stage::Vertex && f.field == PushField::CaptureLayout) - .expect("placed"); - let crate::bind::FieldLocation::PushWindow { offset } = layout.location else { - panic!("{stem}: the layout spilled: {layout:?}"); - }; - let write = commands - .push_constants - .iter() - .find(|w| w.stages.contains(vk::ShaderStageFlags::VERTEX)) - .expect("vertex push"); - let at = (offset - write.offset) as usize; - let words: Vec = write.bytes[at..at + 16] - .chunks(4) - .map(|w| u32::from_le_bytes(w.try_into().expect("a word"))) - .collect(); - assert_eq!(words, [5, 7, 3, 0], "{stem}"); - - let not_implemented = Err(BindError::Unsupported(Unsupported::not_implemented( - Feature::TileReach, - ))); - let indexed = DrawCall::Indexed { - index_type: vk::IndexType::UINT16, - index_buffer: IndexBufferRef::new(1, 64), - index_count: 3, - index_offset: 0, - instance_count: 1, - base_vertex: 0, - base_instance: 0, - }; - assert_eq!( - plan.instantiate_draw(&state, &indexed).map(|_| ()), - Err(BindError::NeedsVariant { - variant: Box::new(VariantKey { - captured_positions: Some(CaptureForm::Indexed(IndexType::UInt16)), - ..key.clone() - }), - }), - "{stem}" - ); - let indirect = DrawCall::Indirect { - indirect: IndirectRef::new(2, 0), - indexed: None, - }; - assert_eq!( - plan.instantiate_draw(&state, &indirect).map(|_| ()), - not_implemented, - "{stem}" - ); - let mut amplified = bound(); - amplified.vertex_amplification = - VertexAmplification::new(2, vec![ViewMapping::new(0, 0), ViewMapping::new(0, 1)]); - assert_eq!( - p.plan(&dev, &lified.shape()).map(|_| ()), - not_implemented, - "{stem}" - ); - } -} - -// ---- The indexed form (CaptureForm::Indexed) ------------------------------------------------- - -/// Device addresses of the interpreter's address-backed buffers: the records, the indices, the -/// root table and its sink. -const RECORDS: u64 = 0x0000_0040_0000_0000; -const INDICES: u64 = 0x0000_0050_0000_0000; -const TABLE: u64 = 0x0000_0010_0000_0000; -const SINK: u64 = 0x0000_0011_0000_0000; -/// The byte every record is filled with before a run: the words a record leaves unwritten keep it. -const FILL: u8 = 0xAB; - -/// One indexed capture run on the CPU interpreter: the draw's indices of `ty` (as `u32`s) placed -/// `skew` bytes past a 4-aligned address, its base vertex and its instances, and whether it -/// restarts (a strip; the layout's lane 0). -struct IndexedRun<'a> { - ty: IndexType, - indices: &'a [u32], - skew: u64, - base_vertex: i32, - first_instance: u32, - instances: u32, - restarts: bool, -} - -impl IndexedRun<'_> { - fn count(&self) -> u32 { - self.indices.len() as u32 - } - - /// The index buffer's bytes from its 4-aligned start, padded to whole words. - fn index_bytes(&self) -> Vec { - let mut out = vec![0xCDu8; self.skew as usize]; - for &i in self.indices { - match self.ty { - IndexType::UInt16 => out.extend_from_slice(&(i as u16).to_le_bytes()), - IndexType::UInt32 => out.extend_from_slice(&i.to_le_bytes()), - } - } - while !out.len().is_multiple_of(4) { - out.push(0xCD); - } - out - } - - /// The vertex record slot `s` holds: its index position's raw index plus the base vertex. - fn vertex(&self, position: usize) -> u32 { - self.indices[position].wrapping_add(self.base_vertex as u32) - } - - fn restart(&self, position: usize) -> bool { - self.indices[position] - == match self.ty { - IndexType::UInt16 => 0xffff, - IndexType::UInt32 => u32::MAX, - } - } - - /// Whether index position `position` runs no body: a restart index of a draw that restarts. - fn skipped(&self, position: usize) -> bool { - self.restarts && self.restart(position) - } -} - -/// Whether `record` is a skipped restart vertex's: its flag 1 and every other word as it was. -fn skipped_record(record: &[u32; 6]) -> bool { - let fill = u32::from_le_bytes([FILL; 4]); - record[..5] == [fill; 5] && record[5] == 1 -} - -/// The root table with no slot entries (entry 1 the sink), for a module that reads one. -fn root_table() -> Vec { - let mut t = vec![0u8; 32 * 2]; - t[32..40].copy_from_slice(&SINK.to_le_bytes()); - t[40..48].copy_from_slice(&2u64.to_le_bytes()); - t -} - -fn addressed(address: u64, bytes: Vec) -> Buffer { - Buffer { - slot: None, - address: Some(address), - bytes, - } -} - -fn vertex_buffer(index: u32, bytes: Vec) -> Buffer { - Buffer { - slot: Some(ResourceSlot { - stage: Stage::Vertex, - kind: ResourceKind::Buffer, - index, - }), - address: None, - bytes, - } -} - -/// The push bytes of `plan` for `run`: the capture addresses and layout, zero bind residuals, -/// `stride` for every vertex buffer stride, and the root table's address. -fn capture_push(plan: &Plan, run: &IndexedRun<'_>, index_address: u64, stride: u32) -> Vec { - let mut out = vec![0u8; 128]; - for f in &plan.push.fields { - let PushLoc::Push { offset } = f.loc else { - panic!("{:?} spilled to the ArgumentTable", f.field); - }; - let at = offset as usize; - let bytes: Vec = match f.field { - PushField::CaptureAddress => RECORDS.to_le_bytes().to_vec(), - PushField::CaptureIndexAddress => index_address.to_le_bytes().to_vec(), - PushField::CaptureLayout => [ - u32::from(run.restarts), - run.count(), - run.first_instance, - run.base_vertex as u32, - ] - .iter() - .flat_map(|w| w.to_le_bytes()) - .collect(), - PushField::RootTableAddress => TABLE.to_le_bytes().to_vec(), - PushField::SlotBindOffset(_) => vec![0; 4], - PushField::VertexBufferStride(_) => stride.to_le_bytes().to_vec(), - other => panic!("unexpected push field {other:?}"), - }; - out[at..at + bytes.len()].copy_from_slice(&bytes); - } - out -} - -/// Run `m` (planned as `plan`) as `run`'s capture draw: `count` vertices from 0 of its instances, -/// with `extra` buffers bound; the records, as `[clip x, y, z, w, point size, restart flag]` bits -/// per slot, after checking that each record's last two words are unwritten. -fn run_capture( - what: &str, - plan: &Plan, - m: &TypedModule, - run: &IndexedRun<'_>, - stride: u32, - extra: Vec, -) -> Vec<[u32; 6]> { - let slots = (run.count() * run.instances) as usize; - let mut buffers = vec![ - addressed(RECORDS, vec![FILL; 32 * slots]), - addressed(INDICES, run.index_bytes()), - addressed(TABLE, root_table()), - addressed(SINK, vec![0; 64]), - ]; - buffers.extend(extra); - let res = Resources { - buffers, - push: capture_push(plan, run, INDICES + run.skew, stride), - spec: Default::default(), - }; - let cfg = Config { - workgroups: [run.count(), run.instances, 1], - first: [0, run.first_instance], - ..Config::default() - }; - let out = interp_run(m, &cfg, res).unwrap_or_else(|e| panic!("{what}: {e}")); - assert_eq!( - out.buffers[1], - run.index_bytes(), - "{what}: the indices are read only" - ); - out.buffers[0] - .as_chunks::<32>() - .0 - .iter() - .map(|r| { - assert_eq!( - r[24..], - [FILL; 8], - "{what}: words 6 and 7 are left as they were" - ); - let w = |k: usize| u32::from_le_bytes(r[4 * k..4 * k + 4].try_into().expect("word")); - [w(0), w(1), w(2), w(3), w(4), w(5)] - }) - .collect() -} - -/// The lowering inputs of the indexed form of `ty` with projection `fetch`. -fn indexed_inputs(ty: IndexType, fetch: Option) -> LoweringInputs { - let mut i = inputs(Some(CaptureForm::Indexed(ty))); - i.vertex_fetch = fetch; - i -} - -/// The indexed form reads each vertex from the draw's index buffer, on the CPU interpreter: -/// `stage_io_vertex_position` returns `(vid & 1, vid >> 1, 0, 1)`, so each record's clip -/// position names the vertex its `[[vertex_id]]` saw. For `u16` indices at a 2- and a 4-aligned -/// address and `u32` ones, with a negative and a wrapping base vertex and two instances from a -/// nonzero first one: record `p + (i - first instance) · count` holds index position `p`'s vertex -/// (its raw index plus the base vertex, wrapping), point size 1.0, and restart flag 1 exactly at -/// the type's all-ones index; the index read adds a bounded number of words; and the vertices -/// form writes flag 0 at `VertexIndex`'s own vertex. -#[test] -fn an_indexed_capture_reads_each_vertex_from_its_index() { - let Some(bc) = fixture("stage_io") else { - return; - }; - let entry = "stage_io_vertex_position"; - let short = [5u32, 0, 0xffff, 3, 2, 0xfffe]; - let long = [7u32, u32::MAX, 1, 0x8000_0001]; - let runs = [ - IndexedRun { - ty: IndexType::UInt16, - indices: &short, - skew: 2, - base_vertex: -3, - first_instance: 4, - instances: 2, - restarts: true, - }, - IndexedRun { - ty: IndexType::UInt16, - indices: &short, - skew: 0, - base_vertex: 9, - first_instance: 0, - instances: 1, - restarts: false, - }, - IndexedRun { - ty: IndexType::UInt32, - indices: &long, - skew: 0, - base_vertex: 0x10, - first_instance: 1, - instances: 2, - restarts: true, - }, - ]; - for stem in ["lavapipe", "moltenvk-m3"] { - let dev = device_of(description(stem)); - let p = dev.profile(); - let vertices = compile_with(&bc, entry, p, &inputs(Some(CaptureForm::Vertices))) - .unwrap_or_else(|e| panic!("{stem}: {e}")); - let vertices_words = validate(&vertices, p).len(); - for run in &runs { - let what = format!("{stem} {:?} skew {}", run.ty, run.skew); - let i = indexed_inputs(run.ty, None); - let a = compile_with(&bc, entry, p, &i).unwrap_or_else(|e| panic!("{what}: {e}")); - let words = validate(&a, p).len(); - assert!( - a.facts.contains(&RuntimeFact::CapturedPositions { - form: CaptureForm::Indexed(run.ty) - }), - "{what}" - ); - assert!(!a.interface.writes_memory, "{what}"); - let added = words as i64 - vertices_words as i64; - println!("{what}: the index read adds {added} words to {vertices_words}"); - assert!((0..=300).contains(&added), "{what}: {added} words"); - let (plan, m) = - typed_module_with(&bc, entry, p, &i).unwrap_or_else(|e| panic!("{what}: {e}")); - let records = run_capture(&what, &plan, &m, run, 0, Vec::new()); - for (slot, record) in records.iter().enumerate() { - let position = slot % run.count() as usize; - if run.skipped(position) { - assert!(skipped_record(record), "{what}: slot {slot}: {record:x?}"); - continue; - } - let vid = run.vertex(position); - let clip = [(vid & 1) as f32, (vid >> 1) as f32, 0.0, 1.0]; - assert_eq!( - record[..4], - clip.map(f32::to_bits), - "{what}: slot {slot} sees vertex {vid:#x}" - ); - assert_eq!(record[4], 1.0f32.to_bits(), "{what}: slot {slot}"); - assert_eq!( - record[5], - u32::from(run.restart(position)), - "{what}: {slot}" - ); - } - } - // The vertices form: `VertexIndex` from the draw's first vertex, flag 0. - let what = format!("{stem} vertices"); - let (plan, m) = typed_module_with(&bc, entry, p, &inputs(Some(CaptureForm::Vertices))) - .unwrap_or_else(|e| panic!("{what}: {e}")); - let mut push = vec![0u8; 128]; - for f in &plan.push.fields { - let PushLoc::Push { offset } = f.loc else { - panic!("{what}: {:?} spilled", f.field); - }; - let at = offset as usize; - let bytes: Vec = match f.field { - PushField::CaptureAddress => RECORDS.to_le_bytes().to_vec(), - PushField::CaptureLayout => [6u32, 3, 0, 0] - .iter() - .flat_map(|w| w.to_le_bytes()) - .collect(), - other => panic!("{what}: unexpected push field {other:?}"), - }; - push[at..at + bytes.len()].copy_from_slice(&bytes); - } - let res = Resources { - buffers: vec![addressed(RECORDS, vec![FILL; 32 * 3])], - push, - spec: Default::default(), - }; - let cfg = Config { - workgroups: [3, 1, 1], - first: [6, 0], - ..Config::default() - }; - let out = interp_run(&m, &cfg, res).unwrap_or_else(|e| panic!("{what}: {e}")); - for (slot, r) in out.buffers[0].as_chunks::<32>().0.iter().enumerate() { - let vid = 6 + slot as u32; - let w = |k: usize| u32::from_le_bytes(r[4 * k..4 * k + 4].try_into().expect("word")); - assert_eq!(w(0), ((vid & 1) as f32).to_bits(), "{what}: {slot}"); - assert_eq!(w(1), ((vid >> 1) as f32).to_bits(), "{what}: {slot}"); - assert_eq!(w(5), 0, "{what}: {slot}"); - assert_eq!(r[24..], [FILL; 8], "{what}: {slot}"); - } - } -} - -/// `stage_io_vertex`'s attributes, interleaved per vertex in buffer 0 at stride 32. -fn interleaved() -> VertexDescriptor { - let mut d = VertexDescriptor::new(); - d.layouts - .insert(0, VertexBufferLayoutDescriptor::new(Some(32))); - for (index, format, offset) in [ - (0, VertexFormat::Float3, 0), - (1, VertexFormat::Half2, 12), - (4, VertexFormat::UShort2, 16), - (7, VertexFormat::UChar4, 20), - ] { - d.attributes - .insert(index, VertexAttributeDescriptor::new(format, offset, 0)); - } - d -} - -/// The class `stage_io_vertex` declares each attribute it reads as. -fn classes() -> BTreeMap { - BTreeMap::from([ - (0, IoNumeric::Float), - (1, IoNumeric::Float), - (4, IoNumeric::Uint), - (7, IoNumeric::Uint), - ]) -} - -/// The indexed form pulls every attribute, at the vertex its index names: the projection pulls -/// each one (where the plain projection fetches some in fixed function, a hand-built projection -/// that does is refused `NotImplemented(TileReach)`), and on the CPU interpreter -/// `stage_io_vertex`'s position, `float4(attribute 0, 1) * scale`, is the attribute of the -/// vertex each record's index names, including at a list's restart index whose vertex the base -/// vertex wraps back into the buffer. A list's restart index whose vertex lies past the buffer -/// reads zero on a device without buffer robustness, where the function checks its reads itself; -/// a strip's runs no body at all, even on a robust device, where nothing in the shader would -/// bound its fetch. -#[test] -fn an_indexed_capture_pulls_every_attribute_at_its_vertex() { - let Some(bc) = fixture("stage_io") else { - return; - }; - let entry = "stage_io_vertex"; - let desc = interleaved(); - let indices = [3u32, 0, 7, 5, u32::MAX, 2]; - let run = IndexedRun { - ty: IndexType::UInt32, - indices: &indices, - skew: 0, - base_vertex: 2, - first_instance: 0, - instances: 1, - restarts: false, - }; - let far = [1u32, u32::MAX, 4]; - let strip = IndexedRun { - ty: IndexType::UInt32, - indices: &far, - skew: 0, - base_vertex: 0, - first_instance: 0, - instances: 1, - restarts: true, - }; - // Vertex `k`'s attribute 0 is `(k, 2k, 3k)`; buffer 0 holds vertices 0 to 15. - let mut source = vec![0u8; 32 * 16]; - for k in 0..16usize { - for (lane, v) in [k as f32, 2.0 * k as f32, 3.0 * k as f32] - .iter() - .enumerate() - { - source[32 * k + 4 * lane..32 * k + 4 * lane + 4] - .copy_from_slice(&v.to_bits().to_le_bytes()); - } - } - let mut scale = vec![0u8; 256]; - for lane in 0..4 { - scale[4 * lane..4 * lane + 4].copy_from_slice(&1.0f32.to_bits().to_le_bytes()); - } - let mut fixed_seen = false; - for stem in ["lavapipe", "moltenvk-m3"] { - let dev = device_of(description(stem)); - let p = dev.profile(); - let plain = - vertex_fetch_projection_for(Some(&desc), &classes(), p, &BTreeSet::new(), false) - .expect("projection"); - let every = vertex_fetch_projection_for(Some(&desc), &classes(), p, &BTreeSet::new(), true) - .expect("projection"); - assert_eq!(every.attributes.len(), 4, "{stem}"); - assert!( - every - .attributes - .values() - .all(|f| matches!(f, VertexFetch::Pulled { .. })), - "{stem}: {every:?}" - ); - if plain - .attributes - .values() - .any(|f| matches!(f, VertexFetch::FixedFunction)) - { - fixed_seen = true; - let refusal = compile_with( - &bc, - entry, - p, - &indexed_inputs(IndexType::UInt32, Some(plain)), - ) - .map(|_| ()) - .map_err(unlocated); - assert_eq!( - refusal, - Err(Error::Unsupported(Unsupported::not_implemented( - Feature::TileReach - ))), - "{stem}" - ); - } - let what = format!("{stem} pulled"); - let i = indexed_inputs(IndexType::UInt32, Some(every)); - let a = compile_with(&bc, entry, p, &i).unwrap_or_else(|e| panic!("{what}: {e}")); - validate(&a, p); - let (plan, m) = - typed_module_with(&bc, entry, p, &i).unwrap_or_else(|e| panic!("{what}: {e}")); - let records = run_capture( - &what, - &plan, - &m, - &run, - 32, - vec![ - vertex_buffer(0, source.clone()), - vertex_buffer(1, scale.clone()), - ], - ); - for (slot, record) in records.iter().enumerate() { - let k = run.vertex(slot); - assert!(k < 16, "{what}: vertex {k}"); - let clip = [k as f32, 2.0 * k as f32, 3.0 * k as f32, 1.0]; - assert_eq!( - record[..4], - clip.map(f32::to_bits), - "{what}: slot {slot} reads vertex {k}'s attribute" - ); - assert_eq!(record[4], 3.0f32.to_bits(), "{what}: slot {slot}"); - assert_eq!( - record[5], - u32::from(run.restart(slot)), - "{what}: slot {slot}" - ); - } - // A strip's restart index, whose vertex lies far past the buffer: the body never runs, - // so the interpreter, which traps on any access outside a buffer (a robust profile - // checks no read in the shader), sees no fetch there. - let what = format!("{stem} strip"); - let records = run_capture( - &what, - &plan, - &m, - &strip, - 32, - vec![ - vertex_buffer(0, source.clone()), - vertex_buffer(1, scale.clone()), - ], - ); - for (slot, record) in records.iter().enumerate() { - if strip.skipped(slot) { - assert!(skipped_record(record), "{what}: slot {slot}: {record:x?}"); - continue; - } - let k = strip.vertex(slot) as f32; - let clip = [k, 2.0 * k, 3.0 * k, 1.0]; - assert_eq!(record[..4], clip.map(f32::to_bits), "{what}: slot {slot}"); - assert_eq!(record[5], 0, "{what}: slot {slot}"); - } - } - assert!( - fixed_seen, - "no profile fetches an attribute in fixed function" - ); - // A restart index whose vertex lies far past the buffer, on a device without buffer - // robustness, whose reads the function checks itself: every pulled read stays inside the buffer - // and reads zero past it, so the interpreter, which traps on any access outside a buffer, sees - // none, and the record holds the zero attribute's position. - let mut fragile = description("moltenvk-m3"); - fragile.features.remove(&F::RobustBufferAccess); - fragile.features.remove(&F::RobustBufferAccess2); - let dev = device_of(fragile); - let p = dev.profile(); - assert_eq!(contain::encoding(p), contain::Check::InShader); - let run = IndexedRun { - ty: IndexType::UInt32, - indices: &far, - skew: 0, - base_vertex: 0, - first_instance: 0, - instances: 1, - restarts: false, - }; - let what = "moltenvk-m3 without robustness, a list"; - let every = vertex_fetch_projection_for(Some(&desc), &classes(), p, &BTreeSet::new(), true) - .expect("projection"); - let i = indexed_inputs(IndexType::UInt32, Some(every)); - let a = compile_with(&bc, entry, p, &i).unwrap_or_else(|e| panic!("{what}: {e}")); - validate(&a, p); - let (plan, m) = typed_module_with(&bc, entry, p, &i).unwrap_or_else(|e| panic!("{what}: {e}")); - let records = run_capture( - what, - &plan, - &m, - &run, - 32, - vec![vertex_buffer(0, source), vertex_buffer(1, scale)], - ); - for (slot, record) in records.iter().enumerate() { - let k = match slot { - 1 => 0.0, - _ => run.vertex(slot) as f32, - }; - let clip = [k, 2.0 * k, 3.0 * k, 1.0]; - assert_eq!(record[..4], clip.map(f32::to_bits), "{what}: slot {slot}"); - assert_eq!( - record[5], - u32::from(run.restart(slot)), - "{what}: slot {slot}" - ); - } -} - -/// `stage_io_vertex`'s buffers: its interleaved vertices at 0 and `scale` at 1. -fn indexed_state() -> BindState { - let buffer = |length| BoundBuffer::Buffer { - length, - offset: 0, - gpu_address: 0x1_0000, - device_address: Some(0x7_0000_0000), - attribute_stride: None, - }; - let mut v = StageTable::default(); - v.buffers.insert(0, buffer(32 * 64)); - v.buffers.insert(1, buffer(256)); - let mut s = BindState::default(); - s.stages.insert(Stage::Vertex, v); - s -} - -/// The indexed capture variant of `stage_io_vertex`'s render pipeline: its keys name the index -/// type, the pipeline pulls every attribute (link accepts it), its plan settles on its key, and -/// an indexed draw of its type runs without indices as `index count` vertices from 0 with the -/// draw's instances, leaves both capture holes in the vertex window, writes `[restarts, index -/// count, base instance, base vertex]` (`restarts` from the state's primitive type: 1 for a -/// strip, 0 for a list, `MissingPrimitiveType` without one), and reads its indices in the -/// vertex stage as storage. A draw of -/// the other form asks for that form's variant; an indexed draw whose indices pass its buffer or -/// whose offset is not a multiple of the index size, and an indirect one, are -/// `NotImplemented(TileReach)`. -#[test] -fn an_indexed_capture_variant_draws_without_indices() { - let Some(bc) = fixture("stage_io") else { - return; - }; - let budget = Budget::standard(); - let lib = Library::from_air(&bc).expect("library"); - let function = FunctionDescriptor::new(lib.function("stage_io_vertex").expect("function")); - let mut d = RenderPipelineDescriptor::new(StageSource::Function(function)); - d.vertex_descriptor = Some(interleaved()); - let short = CaptureForm::Indexed(IndexType::UInt16); - let mut key = VariantKey::new(); - key.captured_positions = Some(short); - for stem in ["lavapipe", "moltenvk-m3"] { - let dev = device_of(description(stem)); - let entries = crate::pipeline::StageEntries::new(); - let keys = dev - .render_variant_key(&d, &key, &budget, &entries) - .expect("keys"); - let mut long_key = VariantKey::new(); - long_key.captured_positions = Some(CaptureForm::Indexed(IndexType::UInt32)); - let long_keys = dev - .render_variant_key(&d, &long_key, &budget, &entries) - .expect("keys"); - assert_ne!(keys.vertex, long_keys.vertex, "{stem}"); - let vertex_inputs = keys.vertex_inputs.clone().expect("vertex inputs"); - assert_eq!(vertex_inputs.captured_positions, Some(short), "{stem}"); - let projection = vertex_inputs.vertex_fetch.expect("projection"); - assert!( - projection - .attributes - .values() - .all(|f| matches!(f, VertexFetch::Pulled { .. })), - "{stem}: {projection:?}" - ); - let p = dev - .compile_render_variant(&d, &key, &budget) - .unwrap_or_else(|e| panic!("{stem}: {e}")); - assert!(p.vertex_input.bindings.is_empty(), "{stem}"); - assert!(p.vertex_input.attributes.is_empty(), "{stem}"); - assert_eq!(p.vertex_input.pulled.len(), 4, "{stem}"); - for m in &p.stages { - check_words_valid(&m.spirv, &p.requirements, dev.profile()) - .unwrap_or_else(|e| panic!("{stem} {:?}: L3: {e}", m.stage)); - } - assert!( - p.dependencies - .iter() - .any(|d| d.fact == RuntimeFact::CapturedPositions { form: short } - && d.mechanism == Mechanism::Variant), - "{stem}" - ); - let mut state = indexed_state(); - state.primitive_type = Some(metal::PrimitiveType::TriangleStrip); - let plan = p.plan(&dev, &state.shape()).expect("plan"); - assert_eq!(plan.variant, key, "{stem}"); - let indexed = |index_type, index_count, index_offset| DrawCall::Indexed { - index_type, - index_buffer: IndexBufferRef::new(5, 4096), - index_count, - index_offset, - instance_count: 2, - base_vertex: -3, - base_instance: 1, - }; - let commands = plan - .instantiate_draw(&state, &indexed(vk::IndexType::UINT16, 6, 8)) - .unwrap_or_else(|e| panic!("{stem}: {e:?}")); - assert_eq!( - commands.draw, - vk::DrawCommand::Draw { - vertex_count: 6, - instance_count: 2, - first_vertex: 0, - first_instance: 1, - }, - "{stem}" - ); - assert_eq!(commands.index_overrun, None, "{stem}"); - let mut holes: Vec<(&str, u32)> = commands - .push_holes - .iter() - .filter_map(|h| match *h { - PushHole::CaptureAddress { stages, offset } => { - assert_eq!(stages, vk::ShaderStageFlags::VERTEX, "{stem}"); - Some(("records", offset)) - } - PushHole::CaptureIndexAddress { stages, offset } => { - assert_eq!(stages, vk::ShaderStageFlags::VERTEX, "{stem}"); - Some(("indices", offset)) - } - _ => None, - }) - .collect(); - holes.sort(); - let [("indices", indices), ("records", records)] = holes[..] else { - panic!("{stem}: {:?}", commands.push_holes); - }; - assert_eq!( - indices, - records + 8, - "{stem}: the index address follows the records'" - ); - assert!(indices + 8 <= 64, "{stem}: {indices}"); - let layout = plan - .push - .fields - .iter() - .find(|f| f.stage == Stage::Vertex && f.field == PushField::CaptureLayout) - .expect("placed"); - let crate::bind::FieldLocation::PushWindow { offset } = layout.location else { - panic!("{stem}: the layout spilled: {layout:?}"); - }; - let write = commands - .push_constants - .iter() - .find(|w| w.stages.contains(vk::ShaderStageFlags::VERTEX)) - .expect("vertex push"); - let at = (offset - write.offset) as usize; - let words: Vec = write.bytes[at..at + 16] - .chunks(4) - .map(|w| u32::from_le_bytes(w.try_into().expect("a word"))) - .collect(); - assert_eq!(words, [1, 6, 1, (-3i32) as u32], "{stem}"); - // A list shades its restart index: lane 0 is 0. Without a primitive type the draw - // cannot say. - let mut list = state.clone(); - list.primitive_type = Some(metal::PrimitiveType::Triangle); - let commands = plan - .instantiate_draw(&list, &indexed(vk::IndexType::UINT16, 6, 8)) - .unwrap_or_else(|e| panic!("{stem}: {e:?}")); - let write = commands - .push_constants - .iter() - .find(|w| w.stages.contains(vk::ShaderStageFlags::VERTEX)) - .expect("vertex push"); - let at = (offset - write.offset) as usize; - assert_eq!(write.bytes[at..at + 4], [0; 4], "{stem}"); - let mut unsaid = state.clone(); - unsaid.primitive_type = None; - assert_eq!( - plan.instantiate_draw(&unsaid, &indexed(vk::IndexType::UINT16, 6, 8)) - .map(|_| ()), - Err(BindError::MissingPrimitiveType), - "{stem}" - ); - assert_eq!( - commands.uses, - [ResourceUse { - resource: UseTarget::IndexBuffer, - access: AccessSet::READ, - class: AccessClass::Storage, - stages: vk::PipelineStageFlags2::VERTEX_SHADER, - range: Some(ByteRange { offset: 0, len: 12 }), - }], - "{stem}" - ); - - // A draw of the other form asks for its variant. - let needs = |form| { - Err(BindError::NeedsVariant { - variant: Box::new(VariantKey { - captured_positions: Some(form), - ..key.clone() - }), - }) - }; - let primitives = DrawCall::Primitives { - vertex_start: 0, - vertex_count: 3, - instance_count: 1, - base_instance: 0, - }; - assert_eq!( - plan.instantiate_draw(&state, &primitives).map(|_| ()), - needs(CaptureForm::Vertices), - "{stem}" - ); - assert_eq!( - plan.instantiate_draw(&state, &indexed(vk::IndexType::UINT32, 6, 8)) - .map(|_| ()), - needs(CaptureForm::Indexed(IndexType::UInt32)), - "{stem}" - ); - let not_implemented = Err(BindError::Unsupported(Unsupported::not_implemented( - Feature::TileReach, - ))); - for (case, draw) in [ - ("misaligned", indexed(vk::IndexType::UINT16, 6, 3)), - ("past the buffer", indexed(vk::IndexType::UINT16, 4000, 8)), - ( - "indirect", - DrawCall::Indirect { - indirect: IndirectRef::new(2, 0), - indexed: Some((vk::IndexType::UINT16, IndexBufferRef::new(5, 4096), 0)), - }, - ), - ] { - assert_eq!( - plan.instantiate_draw(&state, &draw).map(|_| ()), - not_implemented, - "{stem} {case}" - ); - } - } -} diff --git a/crates/metal2vulkan/src/tests/mod.rs b/crates/metal2vulkan/src/tests/mod.rs index ba9064fa5..1196ff37f 100644 --- a/crates/metal2vulkan/src/tests/mod.rs +++ b/crates/metal2vulkan/src/tests/mod.rs @@ -157,7 +157,6 @@ mod engine_typed_clamp; mod engine_typed_threadgroup; mod engine_uniform_varyings; mod engine_unmeasured_speculation; -mod engine_vertex_capture; mod engine_vertex_fetch; mod engine_vertex_variants; mod engine_viewport_compensation; diff --git a/crates/metal2vulkan/src/tests/owned_divisions.rs b/crates/metal2vulkan/src/tests/owned_divisions.rs index d74681443..56e7e7990 100644 --- a/crates/metal2vulkan/src/tests/owned_divisions.rs +++ b/crates/metal2vulkan/src/tests/owned_divisions.rs @@ -12,14 +12,12 @@ use std::sync::Arc; use crate::bind::{ self, DepthStandInForm, PlanesCopy, RewritePhase, RewriteProgram, TessellationScanKernel, - TexelWords, }; use crate::device::{Device, DevicePolicy}; use crate::error::{Error, Feature}; use crate::metal::format::ExtendedRange; use crate::metal::{ - PixelFormat, TessellationFactorStepFunction as Step, TessellationPartitionMode as Partition, - Winding, + TessellationFactorStepFunction as Step, TessellationPartitionMode as Partition, Winding, }; use crate::pipeline::interface::PatchDomain; use crate::spirv::testing::{all_ones_divisions, committed_descriptions}; @@ -47,24 +45,6 @@ const EXTENDED: [ExtendedRange; 13] = [ ExtendedRange::Rgba16Bfloat, ]; -/// Every format a render pass's load pass rewrites (`bind::unused_bits_module`): the -/// extended-range, padded and bfloat formats. -const UNUSED_BITS: [PixelFormat; 13] = [ - PixelFormat::BGR10XR, - PixelFormat::BGR10XRSRGB, - PixelFormat::BGRA10XR, - PixelFormat::BGRA10XRSRGB, - PixelFormat::RGB10A82PXR10, - PixelFormat::RGB10A82PXR10SRGB, - PixelFormat::R10UnormX6, - PixelFormat::RG10UnormX12, - PixelFormat::R10UnormX6SRGB, - PixelFormat::RG10UnormX12SRGB, - PixelFormat::R16Bfloat, - PixelFormat::RG16Bfloat, - PixelFormat::RGBA16Bfloat, -]; - fn modules() -> Vec { let mut out: Vec = Vec::new(); macro_rules! plain { @@ -73,8 +53,6 @@ fn modules() -> Vec { }; } plain!( - capture_assembly_module, - capture_settle_module, flat_dispatch_module, index_bounds_fill_module, index_bounds_plan_module, @@ -89,7 +67,6 @@ fn modules() -> Vec { rotate_texels_module, rows_copy_module, shadow_merge_module, - tile_reach_module, tiled_texels_module, two_plane_texels_module, visibility_combine_module, @@ -107,14 +84,6 @@ fn modules() -> Vec { Box::new(move |d| Ok(bind::extended_shadow_module(d, form)?.spirv)), ); } - for format in UNUSED_BITS { - for words in [TexelWords::Raw, TexelWords::ColorPlane] { - push( - format!("unused_bits_module({format:?}, {words:?})"), - Box::new(move |d| Ok(bind::unused_bits_module(d, format, words)?.spirv)), - ); - } - } for program in RewriteProgram::ALL { for phase in RewritePhase::ALL { push( diff --git a/crates/metal2vulkan/tests/api_signatures.tsv b/crates/metal2vulkan/tests/api_signatures.tsv index 899b9601d..96ed9374b 100644 --- a/crates/metal2vulkan/tests/api_signatures.tsv +++ b/crates/metal2vulkan/tests/api_signatures.tsv @@ -67,20 +67,6 @@ assoc-const metal2vulkan::bind::BlockDecodeModule::SET pub const SET: u32 assoc-const metal2vulkan::bind::BlockDecodeModule::SHAPE_BINDING pub const SHAPE_BINDING: u32 assoc-const metal2vulkan::bind::BlockDecodeModule::SHAPE_WORDS pub const SHAPE_WORDS: u32 assoc-const metal2vulkan::bind::BlockDecodeModule::TEXELS_BINDING pub const TEXELS_BINDING: u32 -assoc-const metal2vulkan::bind::CaptureAssemblyModule::DRAWS_BINDING pub const DRAWS_BINDING: u32 -assoc-const metal2vulkan::bind::CaptureAssemblyModule::DRAW_WORDS pub const DRAW_WORDS: u32 -assoc-const metal2vulkan::bind::CaptureAssemblyModule::HEADER_WORDS pub const HEADER_WORDS: u32 -assoc-const metal2vulkan::bind::CaptureAssemblyModule::LOCAL_SIZE pub const LOCAL_SIZE: u32 -assoc-const metal2vulkan::bind::CaptureAssemblyModule::PRIMITIVES_BINDING pub const PRIMITIVES_BINDING: u32 -assoc-const metal2vulkan::bind::CaptureAssemblyModule::RECORDS_BINDING pub const RECORDS_BINDING: u32 -assoc-const metal2vulkan::bind::CaptureAssemblyModule::RECORD_WORDS pub const RECORD_WORDS: u32 -assoc-const metal2vulkan::bind::CaptureAssemblyModule::SCAN_LIMIT pub const SCAN_LIMIT: u32 -assoc-const metal2vulkan::bind::CaptureAssemblyModule::SET pub const SET: u32 -assoc-const metal2vulkan::bind::CaptureSettleModule::LOCAL_SIZE pub const LOCAL_SIZE: u32 -assoc-const metal2vulkan::bind::CaptureSettleModule::PASS_BINDING pub const PASS_BINDING: u32 -assoc-const metal2vulkan::bind::CaptureSettleModule::SET pub const SET: u32 -assoc-const metal2vulkan::bind::CaptureSettleModule::STATUS_BINDING pub const STATUS_BINDING: u32 -assoc-const metal2vulkan::bind::CaptureSettleModule::TILES_BINDING pub const TILES_BINDING: u32 assoc-const metal2vulkan::bind::ChromaDecode::ALL pub const ALL: [ChromaDecode; 2] assoc-const metal2vulkan::bind::ChromaDecode::BLOCK_BYTES pub const BLOCK_BYTES: u32 assoc-const metal2vulkan::bind::ChromaDecode::TEXEL_BYTES pub const TEXEL_BYTES: u32 @@ -326,7 +312,6 @@ assoc-const metal2vulkan::bind::ShadowMergeModule::WORDS pub const WORDS: u32 assoc-const metal2vulkan::bind::ShadowMergeRead::ALL pub const ALL: [ShadowMergeRead; 6] assoc-const metal2vulkan::bind::ShadowTexelView::ALL pub const ALL: [ShadowTexelView; 4] assoc-const metal2vulkan::bind::StatusBits::ABSENT_ARGUMENT_READ pub const ABSENT_ARGUMENT_READ: StatusBits -assoc-const metal2vulkan::bind::StatusBits::CAPTURED_REACH_UNMEASURED pub const CAPTURED_REACH_UNMEASURED: StatusBits assoc-const metal2vulkan::bind::StatusBits::CUBIC_ARGUMENT_SAMPLER pub const CUBIC_ARGUMENT_SAMPLER: StatusBits assoc-const metal2vulkan::bind::StatusBits::INDEX_POOL_OVERFLOW pub const INDEX_POOL_OVERFLOW: StatusBits assoc-const metal2vulkan::bind::StatusBits::MESH_GRID_DISCARDED pub const MESH_GRID_DISCARDED: StatusBits @@ -351,19 +336,6 @@ assoc-const metal2vulkan::bind::TessellationScanModule::RECORDS_BINDING pub cons assoc-const metal2vulkan::bind::TessellationScanModule::SET pub const SET: u32 assoc-const metal2vulkan::bind::TessellationScanModule::STATUS_BINDING pub const STATUS_BINDING: u32 assoc-const metal2vulkan::bind::TessellationScanModule::WORK_BINDING pub const WORK_BINDING: u32 -assoc-const metal2vulkan::bind::TileReachModule::HEADER_WORDS pub const HEADER_WORDS: u32 -assoc-const metal2vulkan::bind::TileReachModule::LINE pub const LINE: u32 -assoc-const metal2vulkan::bind::TileReachModule::LOCAL_SIZE pub const LOCAL_SIZE: u32 -assoc-const metal2vulkan::bind::TileReachModule::NEAR_FAR_WORD pub const NEAR_FAR_WORD: u32 -assoc-const metal2vulkan::bind::TileReachModule::PASS_BINDING pub const PASS_BINDING: u32 -assoc-const metal2vulkan::bind::TileReachModule::POINT pub const POINT: u32 -assoc-const metal2vulkan::bind::TileReachModule::PRIMITIVES_BINDING pub const PRIMITIVES_BINDING: u32 -assoc-const metal2vulkan::bind::TileReachModule::PRIMITIVE_WORDS pub const PRIMITIVE_WORDS: u32 -assoc-const metal2vulkan::bind::TileReachModule::SET pub const SET: u32 -assoc-const metal2vulkan::bind::TileReachModule::STATE_WORDS pub const STATE_WORDS: u32 -assoc-const metal2vulkan::bind::TileReachModule::TILES_BINDING pub const TILES_BINDING: u32 -assoc-const metal2vulkan::bind::TileReachModule::TRIANGLE pub const TRIANGLE: u32 -assoc-const metal2vulkan::bind::TileReachModule::UNMEASURED_WORD pub const UNMEASURED_WORD: u32 assoc-const metal2vulkan::bind::TiledTexelsModule::LOCAL_SIZE pub const LOCAL_SIZE: u32 assoc-const metal2vulkan::bind::TiledTexelsModule::MAX_LEVELS pub const MAX_LEVELS: u32 assoc-const metal2vulkan::bind::TiledTexelsModule::SET pub const SET: u32 @@ -377,13 +349,6 @@ assoc-const metal2vulkan::bind::TwoPlaneTexelsModule::SET pub const SET: u32 assoc-const metal2vulkan::bind::TwoPlaneTexelsModule::SHAPE_BINDING pub const SHAPE_BINDING: u32 assoc-const metal2vulkan::bind::TwoPlaneTexelsModule::SHAPE_WORDS pub const SHAPE_WORDS: u32 assoc-const metal2vulkan::bind::TwoPlaneTexelsModule::TEXELS_BINDING pub const TEXELS_BINDING: u32 -assoc-const metal2vulkan::bind::UnusedBitsModule::LOCAL_SIZE pub const LOCAL_SIZE: u32 -assoc-const metal2vulkan::bind::UnusedBitsModule::SET pub const SET: u32 -assoc-const metal2vulkan::bind::UnusedBitsModule::SHAPE_BINDING pub const SHAPE_BINDING: u32 -assoc-const metal2vulkan::bind::UnusedBitsModule::SHAPE_WORDS pub const SHAPE_WORDS: u32 -assoc-const metal2vulkan::bind::UnusedBitsModule::TILE pub const TILE: u32 -assoc-const metal2vulkan::bind::UnusedBitsModule::TILES_BINDING pub const TILES_BINDING: u32 -assoc-const metal2vulkan::bind::UnusedBitsModule::WORDS_BINDING pub const WORDS_BINDING: u32 assoc-const metal2vulkan::bind::VisibilityCombine::ENTRY_WORDS pub const ENTRY_WORDS: usize assoc-const metal2vulkan::bind::VisibilityCombineModule::DEST_BINDING pub const DEST_BINDING: u32 assoc-const metal2vulkan::bind::VisibilityCombineModule::LOCAL_SIZE pub const LOCAL_SIZE: u32 @@ -561,20 +526,6 @@ assoc-const-value metal2vulkan::bind::BlockDecodeModule::SET 0 assoc-const-value metal2vulkan::bind::BlockDecodeModule::SHAPE_BINDING 0 assoc-const-value metal2vulkan::bind::BlockDecodeModule::SHAPE_WORDS 5 assoc-const-value metal2vulkan::bind::BlockDecodeModule::TEXELS_BINDING 2 -assoc-const-value metal2vulkan::bind::CaptureAssemblyModule::DRAWS_BINDING 1 -assoc-const-value metal2vulkan::bind::CaptureAssemblyModule::DRAW_WORDS 8 -assoc-const-value metal2vulkan::bind::CaptureAssemblyModule::HEADER_WORDS 2 -assoc-const-value metal2vulkan::bind::CaptureAssemblyModule::LOCAL_SIZE 64 -assoc-const-value metal2vulkan::bind::CaptureAssemblyModule::PRIMITIVES_BINDING 2 -assoc-const-value metal2vulkan::bind::CaptureAssemblyModule::RECORDS_BINDING 0 -assoc-const-value metal2vulkan::bind::CaptureAssemblyModule::RECORD_WORDS 8 -assoc-const-value metal2vulkan::bind::CaptureAssemblyModule::SCAN_LIMIT 256 -assoc-const-value metal2vulkan::bind::CaptureAssemblyModule::SET 0 -assoc-const-value metal2vulkan::bind::CaptureSettleModule::LOCAL_SIZE 64 -assoc-const-value metal2vulkan::bind::CaptureSettleModule::PASS_BINDING 1 -assoc-const-value metal2vulkan::bind::CaptureSettleModule::SET 0 -assoc-const-value metal2vulkan::bind::CaptureSettleModule::STATUS_BINDING 0 -assoc-const-value metal2vulkan::bind::CaptureSettleModule::TILES_BINDING 2 assoc-const-value metal2vulkan::bind::ChromaDecode::ALL [ChromaDecode::Gbgr, ChromaDecode::Bgrg] assoc-const-value metal2vulkan::bind::ChromaDecode::BLOCK_BYTES 4 assoc-const-value metal2vulkan::bind::ChromaDecode::TEXEL_BYTES 4 @@ -820,7 +771,6 @@ assoc-const-value metal2vulkan::bind::ShadowMergeModule::WORDS 4 assoc-const-value metal2vulkan::bind::ShadowMergeRead::ALL [ShadowMergeRead::Words(ShadowTexelView::R32Uint), ShadowMergeRead::Words(ShadowTexelView::R8G8B8A8Uint), ShadowMergeRead::Words(ShadowTexelView::R32G32Uint), ShadowMergeRead::Words(ShadowTexelView::R32G32B32A32Uint), ShadowMergeRead::B8G8R8A8Unorm, ShadowMergeRead::R8G8B8A8Unorm] assoc-const-value metal2vulkan::bind::ShadowTexelView::ALL [ShadowTexelView::R32Uint, ShadowTexelView::R8G8B8A8Uint, ShadowTexelView::R32G32Uint, ShadowTexelView::R32G32B32A32Uint] assoc-const-value metal2vulkan::bind::StatusBits::ABSENT_ARGUMENT_READ StatusBits(1 <<4) -assoc-const-value metal2vulkan::bind::StatusBits::CAPTURED_REACH_UNMEASURED StatusBits(1 <<7) assoc-const-value metal2vulkan::bind::StatusBits::CUBIC_ARGUMENT_SAMPLER StatusBits(1 <<6) assoc-const-value metal2vulkan::bind::StatusBits::INDEX_POOL_OVERFLOW StatusBits(1 <<3) assoc-const-value metal2vulkan::bind::StatusBits::MESH_GRID_DISCARDED StatusBits(1 <<10) @@ -845,19 +795,6 @@ assoc-const-value metal2vulkan::bind::TessellationScanModule::RECORDS_BINDING 1 assoc-const-value metal2vulkan::bind::TessellationScanModule::SET 0 assoc-const-value metal2vulkan::bind::TessellationScanModule::STATUS_BINDING 2 assoc-const-value metal2vulkan::bind::TessellationScanModule::WORK_BINDING 0 -assoc-const-value metal2vulkan::bind::TileReachModule::HEADER_WORDS 8 -assoc-const-value metal2vulkan::bind::TileReachModule::LINE 1 -assoc-const-value metal2vulkan::bind::TileReachModule::LOCAL_SIZE 64 -assoc-const-value metal2vulkan::bind::TileReachModule::NEAR_FAR_WORD 5 -assoc-const-value metal2vulkan::bind::TileReachModule::PASS_BINDING 1 -assoc-const-value metal2vulkan::bind::TileReachModule::POINT 0 -assoc-const-value metal2vulkan::bind::TileReachModule::PRIMITIVES_BINDING 0 -assoc-const-value metal2vulkan::bind::TileReachModule::PRIMITIVE_WORDS 16 -assoc-const-value metal2vulkan::bind::TileReachModule::SET 0 -assoc-const-value metal2vulkan::bind::TileReachModule::STATE_WORDS 12 -assoc-const-value metal2vulkan::bind::TileReachModule::TILES_BINDING 2 -assoc-const-value metal2vulkan::bind::TileReachModule::TRIANGLE 2 -assoc-const-value metal2vulkan::bind::TileReachModule::UNMEASURED_WORD 6 assoc-const-value metal2vulkan::bind::TiledTexelsModule::LOCAL_SIZE 64 assoc-const-value metal2vulkan::bind::TiledTexelsModule::MAX_LEVELS 16 assoc-const-value metal2vulkan::bind::TiledTexelsModule::SET 0 @@ -871,13 +808,6 @@ assoc-const-value metal2vulkan::bind::TwoPlaneTexelsModule::SET 0 assoc-const-value metal2vulkan::bind::TwoPlaneTexelsModule::SHAPE_BINDING 2 assoc-const-value metal2vulkan::bind::TwoPlaneTexelsModule::SHAPE_WORDS 13 assoc-const-value metal2vulkan::bind::TwoPlaneTexelsModule::TEXELS_BINDING 0 -assoc-const-value metal2vulkan::bind::UnusedBitsModule::LOCAL_SIZE 64 -assoc-const-value metal2vulkan::bind::UnusedBitsModule::SET 0 -assoc-const-value metal2vulkan::bind::UnusedBitsModule::SHAPE_BINDING 2 -assoc-const-value metal2vulkan::bind::UnusedBitsModule::SHAPE_WORDS 4 -assoc-const-value metal2vulkan::bind::UnusedBitsModule::TILE 32 -assoc-const-value metal2vulkan::bind::UnusedBitsModule::TILES_BINDING 1 -assoc-const-value metal2vulkan::bind::UnusedBitsModule::WORDS_BINDING 0 assoc-const-value metal2vulkan::bind::VisibilityCombine::ENTRY_WORDS 4 assoc-const-value metal2vulkan::bind::VisibilityCombineModule::DEST_BINDING 1 assoc-const-value metal2vulkan::bind::VisibilityCombineModule::LOCAL_SIZE 64 @@ -1404,7 +1334,6 @@ enum metal2vulkan::bind::ShadowMergeRead #[derive(Clone, Copy, Debug, PartialEq, enum metal2vulkan::bind::ShadowTexelView #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] pub enum ShadowTexelView enum metal2vulkan::bind::StatusWord #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub enum StatusWord enum metal2vulkan::bind::TessellationRecords #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum TessellationRecords -enum metal2vulkan::bind::TexelWords #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum TexelWords enum metal2vulkan::bind::TextureShape #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub enum TextureShape enum metal2vulkan::bind::TileMapError #[derive(Clone, Debug, PartialEq, Eq)] #[non_exhaustive] pub enum TileMapError enum metal2vulkan::bind::TileMapping #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] pub enum TileMapping @@ -1499,14 +1428,12 @@ enum metal2vulkan::metal::format::FormatEmulation #[cfg_attr(feature = "serde", enum metal2vulkan::metal::format::WordAttachment #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub enum WordAttachment enum metal2vulkan::metal::format::YCbCrReads #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum YCbCrReads enum metal2vulkan::metal::sampler::OpaqueBlackBorder #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum OpaqueBlackBorder -enum metal2vulkan::metal::state::DepthBiasUnit #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum DepthBiasUnit enum metal2vulkan::metal::vertex::AttributeFetch #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum AttributeFetch enum metal2vulkan::pipeline::AccelerationStructureLevel #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub enum AccelerationStructureLevel enum metal2vulkan::pipeline::Axis #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub enum Axis enum metal2vulkan::pipeline::BindingSource #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub enum BindingSource enum metal2vulkan::pipeline::BufferForm #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub enum BufferForm enum metal2vulkan::pipeline::BufferKind #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub enum BufferKind -enum metal2vulkan::pipeline::CaptureForm #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub enum CaptureForm enum metal2vulkan::pipeline::ChannelWrite #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub enum ChannelWrite enum metal2vulkan::pipeline::DescriptorView #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub enum DescriptorView enum metal2vulkan::pipeline::EntryMath #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] pub enum EntryMath @@ -2496,12 +2423,6 @@ field metal2vulkan-runtime::WorkCounts.calibration_deviation_most pub calibratio field metal2vulkan-runtime::WorkCounts.calibration_disagreements pub calibration_disagreements: u64 field metal2vulkan-runtime::WorkCounts.calibration_readings pub calibration_readings: u64 field metal2vulkan-runtime::WorkCounts.calibrations pub calibrations: u64 -field metal2vulkan-runtime::WorkCounts.capture_reach_bound_passes pub capture_reach_bound_passes: u64 -field metal2vulkan-runtime::WorkCounts.capture_reach_narrower_passes pub capture_reach_narrower_passes: u64 -field metal2vulkan-runtime::WorkCounts.capture_reach_passes pub capture_reach_passes: u64 -field metal2vulkan-runtime::WorkCounts.capture_reach_primitives pub capture_reach_primitives: u64 -field metal2vulkan-runtime::WorkCounts.capture_reach_tiles_bound pub capture_reach_tiles_bound: u64 -field metal2vulkan-runtime::WorkCounts.capture_reach_tiles_found pub capture_reach_tiles_found: u64 field metal2vulkan-runtime::WorkCounts.color_group_draws_skipped pub color_group_draws_skipped: u64 field metal2vulkan-runtime::WorkCounts.color_group_passes pub color_group_passes: u64 field metal2vulkan-runtime::WorkCounts.color_group_twins pub color_group_twins: u64 @@ -2916,8 +2837,6 @@ field metal2vulkan-runtime::WorkCounts.uncached_host_images pub uncached_host_im field metal2vulkan-runtime::WorkCounts.unlisted_argument_sampler_buffers pub unlisted_argument_sampler_buffers: u64 field metal2vulkan-runtime::WorkCounts.unrun_instances_ended pub unrun_instances_ended: u64 field metal2vulkan-runtime::WorkCounts.untouched_passes_skipped pub untouched_passes_skipped: u64 -field metal2vulkan-runtime::WorkCounts.unused_bits_load_passes pub unused_bits_load_passes: u64 -field metal2vulkan-runtime::WorkCounts.unused_bits_load_texels pub unused_bits_load_texels: u64 field metal2vulkan-runtime::WorkCounts.upload_chunks_in_device_memory pub upload_chunks_in_device_memory: u64 field metal2vulkan-runtime::WorkCounts.variant_pipelines_made pub variant_pipelines_made: u64 field metal2vulkan-runtime::WorkCounts.variants_taken_back pub variants_taken_back: u64 @@ -3067,10 +2986,6 @@ field metal2vulkan::bind::BufferRange.offset pub offset: u64 field metal2vulkan::bind::BufferRange.range pub range: u64 field metal2vulkan::bind::ByteRange.len pub len: u64 field metal2vulkan::bind::ByteRange.offset pub offset: u64 -field metal2vulkan::bind::CaptureAssemblyModule.requirements pub requirements: Requirements -field metal2vulkan::bind::CaptureAssemblyModule.spirv pub spirv: Arc<[u32]> -field metal2vulkan::bind::CaptureSettleModule.requirements pub requirements: Requirements -field metal2vulkan::bind::CaptureSettleModule.spirv pub spirv: Arc<[u32]> field metal2vulkan::bind::ColorResolveModules.fragment pub fragment: Arc<[u32]> field metal2vulkan::bind::ColorResolveModules.requirements pub requirements: Requirements field metal2vulkan::bind::ColorResolveModules.vertex pub vertex: Arc<[u32]> @@ -3458,7 +3373,6 @@ field metal2vulkan::bind::StageTable.samplers pub samplers: BTreeMap field metal2vulkan::bind::StageTable.threadgroup_lengths pub threadgroup_lengths: BTreeMap field metal2vulkan::bind::StatusReport.absent_argument_read pub absent_argument_read: bool -field metal2vulkan::bind::StatusReport.captured_reach_unmeasured pub captured_reach_unmeasured: bool field metal2vulkan::bind::StatusReport.cubic_argument_sampler pub cubic_argument_sampler: bool field metal2vulkan::bind::StatusReport.index_pool_overflow pub index_pool_overflow: bool field metal2vulkan::bind::StatusReport.mesh_grid_discarded pub mesh_grid_discarded: bool @@ -3504,8 +3418,6 @@ field metal2vulkan::bind::TextureFacts.swizzle pub swizzle: metal::TextureSwizzl field metal2vulkan::bind::TextureFacts.texture_type pub texture_type: metal::TextureType field metal2vulkan::bind::TextureFacts.usage pub usage: metal::TextureUsage field metal2vulkan::bind::TextureFacts.ycbcr_in_place pub ycbcr_in_place: Option -field metal2vulkan::bind::TileReachModule.requirements pub requirements: Requirements -field metal2vulkan::bind::TileReachModule.spirv pub spirv: Arc<[u32]> field metal2vulkan::bind::TileThreadgroupArgument.length pub length: u32 field metal2vulkan::bind::TileThreadgroupArgument.offset pub offset: u32 field metal2vulkan::bind::TileThreadgroupMemory.arguments pub arguments: BTreeMap @@ -3523,8 +3435,6 @@ field metal2vulkan::bind::TiledTexelsModule.requirements pub requirements: Requi field metal2vulkan::bind::TiledTexelsModule.spirv pub spirv: Arc<[u32]> field metal2vulkan::bind::TwoPlaneTexelsModule.requirements pub requirements: Requirements field metal2vulkan::bind::TwoPlaneTexelsModule.spirv pub spirv: Arc<[u32]> -field metal2vulkan::bind::UnusedBitsModule.requirements pub requirements: Requirements -field metal2vulkan::bind::UnusedBitsModule.spirv pub spirv: Arc<[u32]> field metal2vulkan::bind::UsedResource.class pub class: ResourceClass field metal2vulkan::bind::UsedResource.device_address pub device_address: Option field metal2vulkan::bind::UsedResource.gpu_address pub gpu_address: Option @@ -3607,7 +3517,6 @@ field metal2vulkan::cache::VariantKey.address_maps pub address_maps: BTreeMap field metal2vulkan::cache::VariantKey.anisotropic_samplers pub anisotropic_samplers: BTreeSet -field metal2vulkan::cache::VariantKey.captured_positions pub captured_positions: Option field metal2vulkan::cache::VariantKey.color_group pub color_group: u32 field metal2vulkan::cache::VariantKey.cross_class pub cross_class: BTreeMap field metal2vulkan::cache::VariantKey.cubic_samplers pub cubic_samplers: BTreeMap @@ -3965,7 +3874,6 @@ field metal2vulkan::metal::state::DepthBias.clamp pub clamp: f32 field metal2vulkan::metal::state::DepthBias.constant_factor pub constant_factor: f32 field metal2vulkan::metal::state::DepthBias.enable pub enable: bool field metal2vulkan::metal::state::DepthBias.slope_factor pub slope_factor: f32 -field metal2vulkan::metal::state::DepthBias.unit pub unit: DepthBiasUnit field metal2vulkan::metal::state::DepthStencilDescriptor.back_face_stencil pub back_face_stencil: StencilDescriptor field metal2vulkan::metal::state::DepthStencilDescriptor.depth_compare_function pub depth_compare_function: CompareFunction field metal2vulkan::metal::state::DepthStencilDescriptor.depth_write_enabled pub depth_write_enabled: bool @@ -4160,7 +4068,6 @@ field metal2vulkan::pipeline::LoweringInputs.alpha_in_red_colors pub alpha_in_re field metal2vulkan::pipeline::LoweringInputs.alpha_test pub alpha_test: Option field metal2vulkan::pipeline::LoweringInputs.amplification_draws pub amplification_draws: Option field metal2vulkan::pipeline::LoweringInputs.anisotropic_samplers pub anisotropic_samplers: BTreeSet -field metal2vulkan::pipeline::LoweringInputs.captured_positions pub captured_positions: Option field metal2vulkan::pipeline::LoweringInputs.color_group pub color_group: Option field metal2vulkan::pipeline::LoweringInputs.color_writes pub color_writes: BTreeMap; 4]> field metal2vulkan::pipeline::LoweringInputs.cross_class pub cross_class: BTreeMap @@ -4537,8 +4444,6 @@ fn metal2vulkan-runtime::process_exiting pub fn process_exiting() -> bool fn metal2vulkan-runtime::sampler_border_color pub fn sampler_border_color(raw: u64) -> SamplerBorderColor fn metal2vulkan::ash_interop::sampler_create_info pub fn sampler_create_info<'a>(desc: &vk::SamplerDesc, reduction: &'a mut ash::vk::SamplerReductionModeCreateInfo<'static>, border: &'a mut ash::vk::SamplerBorderColorComponentMappingCreateInfoEXT<'static>) -> ash::vk::SamplerCreateInfo<'a> fn metal2vulkan::bind::astc_decode_module pub fn astc_decode_module(device: &Device, decode: AstcDecode, texels: AstcTexels) -> Result -fn metal2vulkan::bind::capture_assembly_module pub fn capture_assembly_module(device: &Device) -> Result -fn metal2vulkan::bind::capture_settle_module pub fn capture_settle_module(device: &Device) -> Result fn metal2vulkan::bind::chroma_decode_module pub fn chroma_decode_module(device: &Device, decode: ChromaDecode) -> Result fn metal2vulkan::bind::color_resolve_modules pub fn color_resolve_modules(device: &Device, format: ColorResolveFormat, samples: u32, source: ResolveSource, feature: Feature) -> Result fn metal2vulkan::bind::depth_split_module pub fn depth_split_module(device: &Device, form: DepthStandInForm, feature: Feature) -> Result @@ -4603,10 +4508,8 @@ fn metal2vulkan::bind::shadow_merge_kept_image_module pub fn shadow_merge_kept_i fn metal2vulkan::bind::shadow_merge_module pub fn shadow_merge_module(device: &Device) -> Result fn metal2vulkan::bind::stencil_split_module pub fn stencil_split_module(device: &Device, feature: Feature) -> Result fn metal2vulkan::bind::tessellation_scan_module pub fn tessellation_scan_module(device: &Device, kernel: &TessellationScanKernel) -> Result -fn metal2vulkan::bind::tile_reach_module pub fn tile_reach_module(device: &Device) -> Result fn metal2vulkan::bind::tiled_texels_module pub fn tiled_texels_module(device: &Device) -> Result fn metal2vulkan::bind::two_plane_texels_module pub fn two_plane_texels_module(device: &Device) -> Result -fn metal2vulkan::bind::unused_bits_module pub fn unused_bits_module(device: &Device, format: PixelFormat, words: TexelWords) -> Result fn metal2vulkan::bind::visibility_combine_module pub fn visibility_combine_module(device: &Device) -> Result fn metal2vulkan::bind::visibility_resolve_module pub fn visibility_resolve_module(device: &Device) -> Result fn metal2vulkan::bind::ycbcr_convert_floats_module pub fn ycbcr_convert_floats_module(device: &Device, conversion: YCbCrConversion) -> Result @@ -4663,7 +4566,7 @@ fn metal2vulkan::metal::state::blend_factor pub fn blend_factor(f: BlendFactor, fn metal2vulkan::metal::state::blend_op pub fn blend_op(op: BlendOperation) -> Result fn metal2vulkan::metal::state::blend_state pub fn blend_state(attachment: &ColorAttachmentDescriptor, profile: &DeviceProfile) -> Result, Error> fn metal2vulkan::metal::state::color_write_mask pub fn color_write_mask(mask: ColorWriteMask) -> Result -fn metal2vulkan::metal::state::depth_bias pub fn depth_bias(topology: vk::PrimitiveTopology, depth_bias: f32, slope_scale: f32, clamp: f32, depth_format: Option, profile: &DeviceProfile) -> Result +fn metal2vulkan::metal::state::depth_bias pub fn depth_bias(topology: vk::PrimitiveTopology, depth_bias: f32, slope_scale: f32, clamp: f32, profile: &DeviceProfile) -> Result fn metal2vulkan::metal::state::depth_clamp_enable pub fn depth_clamp_enable(mode: DepthClipMode, profile: &DeviceProfile) -> Result fn metal2vulkan::metal::state::depth_stencil_state pub fn depth_stencil_state(desc: &DepthStencilDescriptor) -> DepthStencilState fn metal2vulkan::metal::state::index_type pub fn index_type(ty: IndexType) -> vk::IndexType @@ -5117,7 +5020,6 @@ macro-member metal2vulkan-runtime::Degradation::UnorderedDrawBytes UnorderedDraw macro-member metal2vulkan-runtime::Degradation::UnormDepthBias UnormDepthBias = "unorm-depth-bias", Precision, macro-member metal2vulkan-runtime::Degradation::UnormDepthRounding UnormDepthRounding = "unorm-depth-rounding", Precision, macro-member metal2vulkan-runtime::Degradation::UnpackedFillColor UnpackedFillColor = "unpacked-fill-color", Precision, -macro-member metal2vulkan-runtime::Degradation::UnreachedTilesRewritten UnreachedTilesRewritten = "unreached-tiles-rewritten", Precision, macro-member metal2vulkan-runtime::Degradation::UnreadableHandleTexture UnreadableHandleTexture = "unreadable-handle-texture", Precision, macro-member metal2vulkan-runtime::Degradation::UnsizedPoints UnsizedPoints = "unsized-points", Precision, macro-member metal2vulkan-runtime::Degradation::UntimedCommandBuffer UntimedCommandBuffer = "untimed-command-buffer", Precision, @@ -8304,10 +8206,6 @@ method metal2vulkan::bind::BoundBuffer::shape pub fn shape(&self, view_base_alig method metal2vulkan::bind::BoundSampler::new pub fn new(desc: SamplerDescriptor) -> BoundSampler method metal2vulkan::bind::BoundSampler::shape pub fn shape(&self) -> BoundSamplerShape method metal2vulkan::bind::BoundTexture::shape pub fn shape(&self) -> TextureShape -method metal2vulkan::bind::CaptureAssemblyModule::draw pub fn draw(first_primitive: u32, first_record: u32, records: u32, topology: PrimitiveType, restarts: bool, culls: bool, state: u32) -> [u8; 32] -method metal2vulkan::bind::CaptureAssemblyModule::header pub fn header(entries: u32, total: u32) -> [u8; 8] -method metal2vulkan::bind::CaptureAssemblyModule::primitives pub fn primitives(topology: PrimitiveType, records: u32) -> u32 -method metal2vulkan::bind::CaptureAssemblyModule::record pub fn record(position: [f32; 4], point_size: f32, restart: bool) -> [u8; 32] method metal2vulkan::bind::ChromaDecode::block_extent pub fn block_extent(self) -> [u32; 2] method metal2vulkan::bind::ChromaDecode::decode pub fn decode(self, pairs: &[u8], size: [u32; 3]) -> Vec method metal2vulkan::bind::ChromaDecode::decode_into pub fn decode_into(self, pairs: &[u8], [width, height, depth]: [u32; 3], out: &mut [u8]) @@ -8584,10 +8482,6 @@ method metal2vulkan::bind::TessellationScanKernel::max_patch_triangles pub fn ma method metal2vulkan::bind::TextureFacts::new pub fn new(texture_type: metal::TextureType, pixel_format: metal::PixelFormat) -> Self method metal2vulkan::bind::TextureFacts::offset_base_axes pub fn offset_base_axes(&self) -> u8 method metal2vulkan::bind::TextureFacts::shape pub fn shape(&self) -> TextureShape -method metal2vulkan::bind::TileReachModule::header pub fn header(area: [u32; 2], samples: u32, layers: u32, count: u32) -> [u8; 32] -method metal2vulkan::bind::TileReachModule::mask_words pub fn mask_words(area: [u32; 2], samples: u32, layers: u32) -> u32 -method metal2vulkan::bind::TileReachModule::primitive pub fn primitive(kind: u32, state: u32, layer: u32, size: f32, vertices: [[f32; 4]; 3]) -> [u8; 64] -method metal2vulkan::bind::TileReachModule::state pub fn state(viewport: [f32; 4], scissor: [u32; 4], cull: u32, winding: u32, depth_clip: u32) -> [u8; 48] method metal2vulkan::bind::TileThreadgroupArgument::new pub fn new(length: u32, offset: u32) -> TileThreadgroupArgument method metal2vulkan::bind::TileThreadgroupMemory::new pub fn new(length: u32) -> TileThreadgroupMemory method metal2vulkan::bind::TiledLevelMove::invocations pub const fn invocations(&self, into_tight: bool) -> u32 @@ -8596,8 +8490,6 @@ method metal2vulkan::bind::TiledTexelsModule::invocations pub fn invocations(lev method metal2vulkan::bind::TiledTexelsModule::shape pub fn shape(levels: &[TiledLevelMove], into_tight: bool, grid_width: u32) -> Option> method metal2vulkan::bind::TwoPlaneTexelsModule::alpha_words pub const fn alpha_words([width, height]: [u32; 2], slices: u32) -> u32 method metal2vulkan::bind::TwoPlaneTexelsModule::shape pub fn shape([width, height]: [u32; 2], slices: u32, color: PlaneLayout, alpha: PlaneLayout, into_texels: bool, grid_width: u32) -> [u8; 52] -method metal2vulkan::bind::UnusedBitsModule::shape pub fn shape(row_words: u32, first_row: u32, layer_rows: u32, tiles_per_row: u32) -> [u8; 16] -method metal2vulkan::bind::UnusedBitsModule::texel_bytes pub fn texel_bytes(format: PixelFormat, words: TexelWords) -> Option method metal2vulkan::bind::UsedResource::new pub fn new(class: ResourceClass, token: u32) -> UsedResource method metal2vulkan::bind::VertexAmplification::layer pub fn layer(&self, a: u32, length: u32, max: u32) -> u32 method metal2vulkan::bind::VertexAmplification::mapping pub fn mapping(&self, a: u32, max: u32) -> ViewMapping @@ -8865,7 +8757,6 @@ method metal2vulkan::metal::format::ExtendedRange::clear_texel pub fn clear_texe method metal2vulkan::metal::format::ExtendedRange::clear_tile_value pub fn clear_tile_value(self, color: [f64; 4]) -> Option<[f32; 4]> method metal2vulkan::metal::format::ExtendedRange::heap_read pub fn heap_read(self) -> Option method metal2vulkan::metal::format::ExtendedRange::holds_metal_bytes pub fn holds_metal_bytes(self) -> bool -method metal2vulkan::metal::format::ExtendedRange::load_code pub fn load_code(self, c: u32) -> Option method metal2vulkan::metal::format::ExtendedRange::of pub fn of(pf: PixelFormat) -> Option method metal2vulkan::metal::format::ExtendedRange::padded pub fn padded(self) -> bool method metal2vulkan::metal::format::ExtendedRange::padded_srgb pub fn padded_srgb(self) -> bool @@ -8892,7 +8783,6 @@ method metal2vulkan::pipeline::AmplificationDraws::new pub fn new(layered: bool, method metal2vulkan::pipeline::BlendEquation::of pub fn of(c: &crate::pipeline::descriptor::ColorAttachmentDescriptor) -> Option method metal2vulkan::pipeline::BlendState::reads_second_output pub fn reads_second_output(&self) -> bool method metal2vulkan::pipeline::BufferForm::uniform_view pub fn uniform_view(self) -> bool -method metal2vulkan::pipeline::CaptureForm::index_type pub fn index_type(self) -> Option method metal2vulkan::pipeline::ColorAttachmentDescriptor::new pub fn new(pixel_format: metal::PixelFormat) -> ColorAttachmentDescriptor method metal2vulkan::pipeline::ColorAttachmentDescriptor::specialized #[must_use] pub fn specialized(&self) -> ColorAttachmentDescriptor method metal2vulkan::pipeline::ColorAttachmentState::new pub fn new(format: vk::Format, write_mask: vk::ColorComponentFlags, blend: Option) -> ColorAttachmentState @@ -9391,8 +9281,6 @@ struct metal2vulkan::bind::BoundsRunDraw #[derive(Clone, Copy, Debug, PartialEq, struct metal2vulkan::bind::BufferExtent #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub struct BufferExtent struct metal2vulkan::bind::BufferRange #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub struct BufferRange struct metal2vulkan::bind::ByteRange #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub struct ByteRange -struct metal2vulkan::bind::CaptureAssemblyModule #[derive(Clone, Debug, PartialEq, Eq)] #[non_exhaustive] pub struct CaptureAssemblyModule -struct metal2vulkan::bind::CaptureSettleModule #[derive(Clone, Debug, PartialEq, Eq)] #[non_exhaustive] pub struct CaptureSettleModule struct metal2vulkan::bind::ColorResolveFormat #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct ColorResolveFormat struct metal2vulkan::bind::ColorResolveModules #[derive(Clone, Debug, PartialEq, Eq)] #[non_exhaustive] pub struct ColorResolveModules struct metal2vulkan::bind::CompensatedViewport #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, Default, PartialEq)] #[non_exhaustive] pub struct CompensatedViewport @@ -9517,13 +9405,11 @@ struct metal2vulkan::bind::TessellationRecordsFault #[derive(Clone, Copy, Debug, struct metal2vulkan::bind::TessellationScanKernel #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub struct TessellationScanKernel struct metal2vulkan::bind::TessellationScanModule #[derive(Clone, Debug, PartialEq, Eq)] #[non_exhaustive] pub struct TessellationScanModule struct metal2vulkan::bind::TextureFacts #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub struct TextureFacts -struct metal2vulkan::bind::TileReachModule #[derive(Clone, Debug, PartialEq, Eq)] #[non_exhaustive] pub struct TileReachModule struct metal2vulkan::bind::TileThreadgroupArgument #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub struct TileThreadgroupArgument struct metal2vulkan::bind::TileThreadgroupMemory #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub struct TileThreadgroupMemory struct metal2vulkan::bind::TiledLevelMove #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub struct TiledLevelMove struct metal2vulkan::bind::TiledTexelsModule #[derive(Clone, Debug, PartialEq, Eq)] #[non_exhaustive] pub struct TiledTexelsModule struct metal2vulkan::bind::TwoPlaneTexelsModule #[derive(Clone, Debug, PartialEq, Eq)] #[non_exhaustive] pub struct TwoPlaneTexelsModule -struct metal2vulkan::bind::UnusedBitsModule #[derive(Clone, Debug, PartialEq, Eq)] #[non_exhaustive] pub struct UnusedBitsModule struct metal2vulkan::bind::UsedResource #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub struct UsedResource struct metal2vulkan::bind::UsedShape #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub struct UsedShape struct metal2vulkan::bind::VertexAmplification #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub struct VertexAmplification @@ -12096,7 +11982,6 @@ variant metal2vulkan::bind::PredicationOp::WhileFirst WhileFirst variant metal2vulkan::bind::PredicationOp::WhilePast WhilePast variant metal2vulkan::bind::PredicationStepForm::Addressed Addressed variant metal2vulkan::bind::PredicationStepForm::Bound Bound -variant metal2vulkan::bind::PushHole::CaptureAddress CaptureAddress { stages: vk::ShaderStageFlags, offset: u32 } variant metal2vulkan::bind::PushHole::CaptureIndexAddress CaptureIndexAddress { stages: vk::ShaderStageFlags, offset: u32 } variant metal2vulkan::bind::PushHole::CommandRecordsAddress CommandRecordsAddress { stages: vk::ShaderStageFlags, offset: u32 } variant metal2vulkan::bind::PushHole::ExecutionStatusAddress ExecutionStatusAddress { stages: vk::ShaderStageFlags, offset: u32 } @@ -12188,8 +12073,6 @@ variant metal2vulkan::bind::StatusWord::SeqCstFences SeqCstFences variant metal2vulkan::bind::StatusWord::Status Status variant metal2vulkan::bind::TessellationRecords::Exact Exact { records: u32 } variant metal2vulkan::bind::TessellationRecords::Pool Pool -variant metal2vulkan::bind::TexelWords::ColorPlane ColorPlane -variant metal2vulkan::bind::TexelWords::Raw Raw variant metal2vulkan::bind::TextureShape::Buffer Buffer { pixel_format: metal::PixelFormat, swizzle: metal::TextureSwizzleChannels } variant metal2vulkan::bind::TextureShape::Texture Texture { texture_type: metal::TextureType, pixel_format: metal::PixelFormat, sample_count: u32, usage: metal::TextureUsage, mipmap_level_count: u32, sparse: bool, swizzle: metal::TextureSwizzleChannels, address_modes: metal::sampler::AddressModeMap, offset_base_axes: u8, ycbcr_in_place: bool } variant metal2vulkan::bind::TileMapError::Region Region { level: u32, slice: u32, origin: [u32; 3], size: [u32; 3] } @@ -13129,7 +13012,6 @@ variant metal2vulkan::error::Feature::TextureSize TextureSize variant metal2vulkan::error::Feature::TextureSwizzle TextureSwizzle variant metal2vulkan::error::Feature::TextureView TextureView variant metal2vulkan::error::Feature::ThreadgroupMemorySize ThreadgroupMemorySize -variant metal2vulkan::error::Feature::TileReach TileReach variant metal2vulkan::error::Feature::TileShading TileShading variant metal2vulkan::error::Feature::TimelineSemaphores TimelineSemaphores { max_value_difference: u64 } variant metal2vulkan::error::Feature::TriangleFillLines TriangleFillLines @@ -13352,9 +13234,6 @@ variant metal2vulkan::metal::format::YCbCrReads::Srgb Srgb variant metal2vulkan::metal::sampler::OpaqueBlackBorder::Mapped Mapped(vk::ComponentMapping) variant metal2vulkan::metal::sampler::OpaqueBlackBorder::Stated Stated variant metal2vulkan::metal::sampler::OpaqueBlackBorder::Transparent Transparent -variant metal2vulkan::metal::state::DepthBiasUnit::Depth Depth -variant metal2vulkan::metal::state::DepthBiasUnit::Device Device -variant metal2vulkan::metal::state::DepthBiasUnit::ExactFormatUnit ExactFormatUnit variant metal2vulkan::metal::vertex::AttributeFetch::FixedFunction FixedFunction { format: vk::Format, input_rate: vk::VertexInputRate, divisor: u32 } variant metal2vulkan::metal::vertex::AttributeFetch::Pulled Pulled variant metal2vulkan::pipeline::AccelerationStructureLevel::Instance Instance @@ -13382,8 +13261,6 @@ variant metal2vulkan::pipeline::BufferForm::Psb Psb variant metal2vulkan::pipeline::BufferKind::Buffer Buffer variant metal2vulkan::pipeline::BufferKind::IntersectionFunctionTable IntersectionFunctionTable variant metal2vulkan::pipeline::BufferKind::VisibleFunctionTable VisibleFunctionTable -variant metal2vulkan::pipeline::CaptureForm::Indexed Indexed(metal::IndexType) -variant metal2vulkan::pipeline::CaptureForm::Vertices Vertices variant metal2vulkan::pipeline::ChannelWrite::BlendedNearestEven BlendedNearestEven { mantissa: u8, signed: bool } variant metal2vulkan::pipeline::ChannelWrite::Device Device variant metal2vulkan::pipeline::ChannelWrite::FloatNearestEven FloatNearestEven { mantissa: u8, signed: bool } @@ -13515,7 +13392,6 @@ variant metal2vulkan::pipeline::PushField::AmplificationLayerOffset Amplificatio variant metal2vulkan::pipeline::PushField::AmplificationViewportOffset AmplificationViewportOffset variant metal2vulkan::pipeline::PushField::BaseVertexInstance BaseVertexInstance variant metal2vulkan::pipeline::PushField::BlendColor BlendColor -variant metal2vulkan::pipeline::PushField::CaptureAddress CaptureAddress variant metal2vulkan::pipeline::PushField::CaptureIndexAddress CaptureIndexAddress variant metal2vulkan::pipeline::PushField::CaptureLayout CaptureLayout variant metal2vulkan::pipeline::PushField::CommandRecordsAddress CommandRecordsAddress @@ -13594,7 +13470,6 @@ variant metal2vulkan::pipeline::RuntimeFact::BaseVertexInstance BaseVertexInstan variant metal2vulkan::pipeline::RuntimeFact::BicubicTexels BicubicTexels { slot: SlotRef } variant metal2vulkan::pipeline::RuntimeFact::BufferRangeLimit BufferRangeLimit { slot: SlotRef } variant metal2vulkan::pipeline::RuntimeFact::CallStackDepth CallStackDepth { depth: u32 } -variant metal2vulkan::pipeline::RuntimeFact::CapturedPositions CapturedPositions { form: crate::pipeline::lower_inputs::CaptureForm } variant metal2vulkan::pipeline::RuntimeFact::ConstantLanes ConstantLanes { slot: SlotRef } variant metal2vulkan::pipeline::RuntimeFact::ConstexprSampled ConstexprSampled { slot: SlotRef, modes: [crate::metal::SamplerAddressMode; 3] } variant metal2vulkan::pipeline::RuntimeFact::CrossClassReads CrossClassReads { slot: SlotRef } diff --git a/crates/metal2vulkan/tests/api_surface.rs b/crates/metal2vulkan/tests/api_surface.rs index 557bf9d4e..83efc5403 100644 --- a/crates/metal2vulkan/tests/api_surface.rs +++ b/crates/metal2vulkan/tests/api_surface.rs @@ -399,7 +399,6 @@ surface! { struct AliasView N; struct AmplificationDraws N; struct BlendEquation N; - enum CaptureForm N; enum ChannelWrite N; struct ColorGroup N; struct ExtendedRangeColor N; @@ -646,17 +645,8 @@ surface! { fn shadow_merge_kept_image_module; struct ShadowMergeImageModule N; enum ShadowMergeRead E; - fn unused_bits_module; - struct UnusedBitsModule N; fn extended_shadow_module; struct ExtendedShadowModule N; - fn tile_reach_module; - struct TileReachModule N; - fn capture_assembly_module; - struct CaptureAssemblyModule N; - fn capture_settle_module; - struct CaptureSettleModule N; - enum TexelWords N; struct BlockDecodeModule N; fn astc_decode_module; struct AstcDecode N; @@ -956,7 +946,6 @@ surface! { fn polygon_mode; fn depth_clamp_enable; struct DepthBias N; - enum DepthBiasUnit N; fn depth_bias; } "metal::vertex" => metal2vulkan::metal::vertex { diff --git a/docs/API.md b/docs/API.md index c1dbd2b72..810a48b71 100644 --- a/docs/API.md +++ b/docs/API.md @@ -1335,9 +1335,11 @@ bound. - `metal2vulkan-degrade-unorm-depth-bias` (precision). `UnormDepthBias`: A draw biases a `Depth16Unorm` depth by a constant, or by a slope alone, which brings Metal's constant unit, on a device whose driver is not measured to store Metal's codes so - (`DriverDeviation::MetalDepth16BiasedStores`): the device biases and converts the depth. Cost: a - biased depth can store a code next to Metal's: the device rounds the biased sum its own way, and - without depthBiasExact counts the bias in its own unit. + (`DriverDeviation::MetalDepth16BiasedStores`): the device biases by Metal's constant in its own + unit and converts the depth. Cost: a biased depth can store another code than Metal's: the + device biases by the constant c in its own unit, up to twice 2^-16, where Metal biases by c + 1 + units of 1/65535 (c - 1 below 0, one unit for a slope alone), and rounds the biased sum its own + way. - `metal2vulkan-degrade-unorm-depth-rounding` (precision). `UnormDepthRounding`: A draw tests or writes a `Depth16Unorm` depth on a device whose driver is not measured to convert a depth to Metal's code (`DriverDeviation::MetalDepth16Stores`), or a pass clears one to a depth that a @@ -2034,21 +2036,24 @@ bound. the bytes Metal's blit reads from outside the texels: from outside the planes below a width of 4, and those an earlier blit left in a row's padding or past a plane, which Metal keeps. - `metal2vulkan-degrade-extended-range-bits-kept` (precision). `ExtendedRangeBitsKept`: A draw in a - render pass that loads a color attachment of an extended-range or padded 10-bit format + render pass that loads a color attachment of an extended-range, padded 10-bit or bfloat format (`BGR10_XR`, `BGRA10_XR`, `RGB10A8_2P_XR10`, `R10Unorm_X6`, `RG10Unorm_X12` and their sRGB twins, - and `RGB10A2Unorm_sRGB`) and does not discard it at the store, where the pass's load pass does - not take it: a multisampled attachment, a texture held as a shadow of another image or of a - heap's bytes, a sparse one, or one whose image the device does not copy both ways (a padded format takes no multisample texture). Also, once per device, a GPU blit - into, out of or between textures of which one is a `BGRA10_XR` or `BGRA10_XR_sRGB` texture Metal - keeps losslessly compressed: Metal's blit moves the texels through the compression, which clears - the same bits and clamps the same alpha, where the device's copy keeps the bytes. Cost: the - texels the pass's draws do not write keep their bytes; Metal's pass keeps their codes but rewrites - the bits they leave unused in each tile a draw reaches (BGR10_XR's bits 30 and 31 to ones, - BGRA10_XR's low six bits of each field to zeros, the two-plane color word's top two bits to zeros) - and clamps BGRA10_XR's alpha code to [384, 894]: a texel whose bytes no Metal write left (uploaded - bytes, or an alpha code past 894) keeps bytes Metal's pass would change, and a blit through a - BGRA10_XR texture Metal compresses keeps the bytes Metal's blit rewrites so; every such texel - reads the same value either way. + `RGB10A2Unorm_sRGB`, `R16Bfloat`, `RG16Bfloat` and `RGBA16Bfloat`) and does not discard it at the + store, on every device: the device's pass keeps the bytes its draws do not write, where Metal's + pass writes each 32 x 32 tile a draw reaches back through its tile store. Also, once per device, a + GPU blit into, out of or between textures of which one is a `BGRA10_XR` or `BGRA10_XR_sRGB` + texture Metal keeps losslessly compressed: Metal's blit moves the texels through the compression, + which clears the same bits and clamps the same alpha, where the device's copy keeps the bytes. + Cost: the texels the pass's draws do not write keep their bytes; Metal's pass rewrites, in each + tile a draw reaches, the bits their codes leave unused (BGR10_XR's bits 30 and 31 to ones, + BGRA10_XR's low six bits of each field, the two-plane color word's top two bits and a padded + word's low six bits to zeros), clamps BGRA10_XR's alpha code to [384, 894], moves a padded sRGB + twin's code through its table and a bfloat code through half (out of half's range to an infinity + or zero, a NaN to 0x7fc0): a texel whose bytes no Metal write left (uploaded bytes, an alpha code + past 894, a bfloat code off half's grid) keeps bytes Metal's pass would change, and a blit + through a BGRA10_XR texture Metal compresses keeps the bytes Metal's blit rewrites so; an + extended-range texel reads the same value either way, a bfloat code off half's grid reads its own + value where Metal's reads the half it was moved to. - `metal2vulkan-degrade-snorm-minimum-kept` (precision). `SnormMinimumKept`: A draw in a render pass that loads a single-sampled color attachment of a signed normalized format (`R8Snorm`, `RG8Snorm`, `RGBA8Snorm`, `R16Snorm`, `RG16Snorm`, `RGBA16Snorm`) and does not discard it at the store. Cost: @@ -2186,19 +2191,6 @@ bound. read_write access) that does not name it reads what an earlier such write left in the stand-in's sink, where Metal drops those writes and reads zero; a sampled read, and a size query, are Metal's. -- `metal2vulkan-degrade-unreached-tiles-rewritten` (precision). `UnreachedTilesRewritten`: A render - pass that loads a color attachment of an extended-range, padded 10-bit or bfloat format - (`BGR10_XR`, `BGRA10_XR`, `RGB10A8_2P_XR10`, `R10Unorm_X6`, `RG10Unorm_X12` and their sRGB twins, - `RGB10A2Unorm_sRGB`, `R16Bfloat`, `RG16Bfloat` and `RGBA16Bfloat`), stores it and draws, - whose load pass rewrites every 32 x 32 tile of its render area: Metal's pass rewrites - only the tiles a draw's primitives reach, and every tile only where a color attachment of the pass - is cleared and stored (announced where none is, or where the pass renders more than one layer). - Cost: in tiles no draw reaches the pass rewrites what Metal keeps: the unused bits made canonical - (BGR10_XR's bits 30 and 31 ones, BGRA10_XR's low six bits of each field and the two-plane color - word's top two bits zeros) and BGRA10_XR alpha codes clamped to [384, 894], so an out-of-range raw - alpha reads back changed, a padded word's low six bits zeroed (an sRGB twin's code moved through - Metal's table), a bfloat code moved through half (out of half's range to an infinity or zero, a - NaN to 0x7fc0); the tiles a draw reaches are Metal's. - `metal2vulkan-degrade-zero-layer-map-after-release` (precision). `ZeroLayerMapAfterRelease`: A draw in a render pass over a rasterization-rate map of no layers that was made after the device released a map of one or more layers, or reset from one of layers. Cost: the draws write nothing, diff --git a/docs/FAST-PATHS.md b/docs/FAST-PATHS.md index 9cc80020c..fd3bee8b3 100644 --- a/docs/FAST-PATHS.md +++ b/docs/FAST-PATHS.md @@ -68,6 +68,8 @@ known. The rest of the differences are docs/API.md section 9's precision notes. | A vertex attribute that fixed-function vertex input fetches is the device's conversion of its format: a normalized one (`UCharNormalized` through `Short4Normalized` of either sign, `UChar4Normalized_BGRA`, `Int1010102Normalized`, `UInt1010102Normalized`) through its own Vulkan `UNORM` or `SNORM` vertex format, where Metal divides each code by its maximum correctly rounded (an `Int1010102Normalized` 10-bit field it multiplies by `float(1 / 511)` in `float`) and rounds the quotient once to a `half` attribute; a narrow float's (a `half` format, `FloatRG11B10`) read as `float` by the device's widening, NaNs included. The format is `VertexAttribute` state that no instruction names, so every format the device fetches shares one module, and the render pipeline's link notes the conversion on its vertex stage (`pipeline::link::vertex`). **Exempt:** a normalized attribute on a profile that takes `DriverDeviation::MetalNormalizedVertexFetch`, MoltenVK on Apple's GPUs of the Apple M3 Max's macOS 27 identity, which hands the format to Metal's own fetch and was measured to answer Metal's `float` at every code of all 19 normalized formats, per vertex and per instance (`runtime_lane::normalized_vertex_fetch`): its pipeline records no note and requires `VkProperty::MetalNormalizedVertexFetch`, but for a 16-bit format read as `half`, whose `float` the module rounds to `half` again. | The device's conversion is the contract. | One `f32` ulp at some codes on a driver that multiplies by the reciprocal: llvmpipe, read at every code (Mesa 26.0.8 on LLVM 21.1.8, arm64), is within one ulp per vertex at every normalized format (127/255 as `0x3EFEFF00` where Metal reads `0x3EFEFEFF`; `Int1010102Normalized` Metal's), and per instance reads the most negative code of an 8- or 16-bit signed format unclamped (-128/127, -32768/32767) where Metal reads -1; RADV's unsigned formats are Metal's at the sites measured. A 16-bit format read as `half`: one `half` ulp at codes 65455 and 65519 unsigned, 32759 and -32759 signed, on a device whose `float` is Metal's (the quotient rounded to `half` twice). The signed formats are **unaudited** on RADV, ANV and NVIDIA. A narrow float's NaN is the device's widening's, where Metal answers `0x7fc00000`. `DeviceVertexConversion` (`device-vertex-conversion`), `DeviceNanEncoding` (`device-nan-encoding`) | | A texture of an ASTC LDR format on a device without that ASTC format reads a decoded twin of 8-bit codes, each channel the code nearest Metal's 12-bit value (`C >> 4` over 4095); an sRGB form's twin holds Metal's own 8-bit codes, which its slots read through the twin's `R8G8B8A8_SRGB` view, the device's sRGB decode (the texel-conversion row). A texture of an EAC 11-bit format (`R11`, `RG11`, unsigned and signed) on a device without ETC2 reads one of 16-bit normalized codes, each nearest Metal's value (`c / 2047`, signed `c / 1023`). | The device lacks the format; the twin's codes are the compact form the device samples. | Within 1/510 of Metal's value; an EAC 11-bit channel within half a 16-bit step (1/131070, signed 1/65534). `decoded-texel-precision`, announced where such a texture is made | | `generate_mipmaps` of a filtered format is the device's filter of each level at the scaled texel centres: its blit chain (`vkCmdBlitImage` with `VK_FILTER_LINEAR`) where its blits filter the image's format, else the runtime's bilinear (trilinear in 3D) compute filter in `float` (an extended-range format, an 8-bit sRGB texture held as its UNORM twin, a format without blits or linear filtering). An integer format's texels are picked as plain Metal picks them, exactly. | The device's filter is the contract; Apple's datapath is not modelled, and its answers differ between Apple's GPUs. | `DeviceFilteredMipmaps` (`device-filtered-mipmaps`) | +| A draw biasing a `Depth16Unorm` depth by a constant, or by a slope alone, biases by Metal's constant `c` in the device's own unit `r` on every device: Metal biases by `c + 1` units of 1/65535 for `c` of 0 or more and `c - 1` below (one unit for a slope alone), added to the depth rounded toward zero, where Vulkan's `r` of a 16-bit unorm depth is the implementation's, at most `2 × 2^-16`, and the device rounds the sum its own way. MoltenVK hands Metal its constant (`DriverDeviation::MetalDepth16BiasedStores`). | The device's depth bias is the contract. | Another code than Metal's for a biased depth: one unit's difference or more. `UnormDepthBias` (`unorm-depth-bias`) | +| A render pass that loads and stores an extended-range, padded 10-bit or bfloat color attachment (`BGR10_XR`, `BGRA10_XR`, `RGB10A8_2P_XR10`, `R10Unorm_X6`, `RG10Unorm_X12` and their sRGB twins, `RGB10A2Unorm_sRGB`, `R16Bfloat`, `RG16Bfloat`, `RGBA16Bfloat`) keeps the bytes its draws do not write, on every device, MoltenVK included (such an attachment is an image of an unsigned integer format there too): Metal's pass writes each 32 x 32 tile a draw reaches back through its tile store, the unused bits of the codes made canonical, `BGRA10_XR`'s alpha code clamped to `[384, 894]`, a padded sRGB twin's codes through Metal's table and a bfloat code through `half` (a NaN to `0x7fc0`). A single-sampled signed normalized or `RGB9E5Float` attachment likewise keeps its minimum codes and unnormalized words, but on MoltenVK, whose pass is a Metal pass (`DriverFact::TileStoreIsMetals`). | The device's load and store are the contract: no pass rewrites the texels its draws do not write. | Bytes no Metal write left (uploads, copies) differ in the tiles a draw reaches; an extended-range texel reads the same value either way, a bfloat code off `half`'s grid reads its own value. `ExtendedRangeBitsKept` (`extended-range-bits-kept`), `SnormMinimumKept` (`snorm-minimum-kept`), `SharedExponentKept` (`shared-exponent-kept`) | | Depth values outside [0, 1] stored clamped (RADV, ANV) on a device without `VK_EXT_depth_range_unrestricted`. | Vulkan leaves them undefined without the extension: enable it. | `RestrictedDepthRange` (`restricted-depth-range`) | | A multisampled 32-bit float depth written by a blit copy from a buffer or a colour texture, or a separate depth texture's copies to and from its pass's scratch image, on a device whose depth/colour copies are missing or wrong (lavapipe, MoltenVK, NVIDIA's GA10x, a device without `VK_KHR_maintenance8`): the values its driver's fragment depth changes (MoltenVK's, NVIDIA's), or on a driver not measured may change (outside [0, 1], denormals, -0), land changed. | Vulkan writes a multisampled depth image's samples by no other means there but a clear; a driver measured to store every fragment depth unchanged (lavapipe's measured releases) is exact. | `DrawnDepthCopy` (`drawn-depth-copy`) | | Signed zeros, infinities and NaNs where the device lacks `SignedZeroInfNanPreserve` at the operation's width. | A device capability. | `DeviceSignedZeroInfNan` (`device-signed-zero-inf-nan`) | diff --git a/docs/REFUSALS.md b/docs/REFUSALS.md index 6e2eae0b6..c1f1038d1 100644 --- a/docs/REFUSALS.md +++ b/docs/REFUSALS.md @@ -27,7 +27,7 @@ Columns: | Kind | Variants | With a site | Reach system | Reach app | Reach rare | Reach none | Unassessed | |---|---|---|---|---|---|---|---| -| Translator and front-end refusals | 126 | 126 | 6 | 33 | 70 | 17 | 0 | +| Translator and front-end refusals | 125 | 125 | 6 | 32 | 70 | 17 | 0 | | Runtime gaps | 70 | 70 | 1 | 8 | 45 | 16 | 0 | | Apple-only calls | 5 | 5 | 0 | 0 | 0 | 5 | 0 | | Binder refusals at a device limit | 9 | 9 | 0 | 1 | 7 | 1 | 0 | @@ -41,7 +41,7 @@ Columns: | Kind | `metal-measured` | `metal-documented` | `metal-takes` | `device` | `ours` | `unknown` | `delegated` | `-` | |---|---|---|---|---|---|---|---|---| -| Translator and front-end refusals | 0 | 0 | 0 | 48 | 55 | 0 | 0 | 23 | +| Translator and front-end refusals | 0 | 0 | 0 | 48 | 54 | 0 | 0 | 23 | | Runtime gaps | 0 | 0 | 0 | 0 | 70 | 0 | 0 | 0 | | Apple-only calls | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 5 | | Binder refusals at a device limit | 0 | 0 | 0 | 9 | 0 | 0 | 0 | 0 | @@ -91,7 +91,7 @@ Columns: | `BufferRange` | A buffer window beyond the descriptor range limits | devices without a capability the site computes (`needs`); devices without buffer device addresses (`addressed_needs`); every device (no Vulkan mechanism) | `device` | 7: `crates/metal2vulkan-runtime/src/function_table.rs (past_storage_buffer_range)`, `crates/metal2vulkan/src/bind/graphics.rs (patch_binding, 3 sites)` (+3) | `app`: a buffer window past a device's descriptor range | | `Int64Arithmetic` | 64-bit integer arithmetic | devices without VkFeature::ShaderInt64 | `device` | 2: `crates/metal2vulkan/src/lower/arith/legal.rs (check_scalar)`, `crates/metal2vulkan/src/lower/select.rs (selector_form)` | `rare`: 64-bit integers on a device without shaderInt64 | | `Float64Arithmetic` | 64-bit float arithmetic | devices without VkFeature::ShaderFloat64 | `device` | 2: `crates/metal2vulkan/src/device/metal.rs (unsupported_features)`, `crates/metal2vulkan/src/lower/arith/legal.rs (check_scalar)` | `rare`: doubles (MSL has none outside Apple's own code) | -| `Format` | A pixel format not supported for the required use | devices without VkFeature::ShaderStorageImageExtendedFormats; devices without a capability the site computes; devices without a capability the site computes (`alternatives`); devices without a capability the site computes (`c`); devices without a capability the site computes (`missing`); devices without a capability the site computes (`routes`); devices without a format's usage; every device (no Vulkan mechanism); every device (not implemented) | `ours` | 121: `crates/metal2vulkan-runtime/src/binding_view.rs (binding_view)`, `crates/metal2vulkan-runtime/src/blit_plan.rs (check_formats, 3 sites)` (+80) | `system`: pixel formats a device lacks for a use (CoreVideo's 4:2:x and 10-bit formats among them) | +| `Format` | A pixel format not supported for the required use | devices without VkFeature::ShaderStorageImageExtendedFormats; devices without a capability the site computes; devices without a capability the site computes (`alternatives`); devices without a capability the site computes (`c`); devices without a capability the site computes (`missing`); devices without a capability the site computes (`routes`); devices without a format's usage; every device (no Vulkan mechanism); every device (not implemented) | `ours` | 120: `crates/metal2vulkan-runtime/src/binding_view.rs (binding_view)`, `crates/metal2vulkan-runtime/src/blit_plan.rs (check_formats, 3 sites)` (+79) | `system`: pixel formats a device lacks for a use (CoreVideo's 4:2:x and 10-bit formats among them) | | `DivergentImplicitLod` | Divergent implicit-LOD sampling or LOD query through a multi-candidate handle | every device (not implemented) | `ours` | 1: `crates/metal2vulkan/src/lower/sampler/select.rs (select_sampling)` | `app`: implicit-LOD sampling through a dynamically chosen texture | | `ImplicitLodOutsideFragment` | Implicit-LOD sampling outside fragment | every device (not implemented) | `ours` | 3: `crates/metal2vulkan/src/lower/sampler/constexpr.rs (query_min_level)`, `crates/metal2vulkan/src/lower/sampler/select.rs (query_level_measured)` (+1) | `rare`: implicit-LOD sampling outside fragment functions | | `MinLodClamp` | `min_lod_clamp` without `shaderResourceMinLod` | devices without VkFeature::ShaderResourceMinLod; every device (not implemented) | `ours` | 2: `crates/metal2vulkan/src/lower/sampler/select.rs (min_lod)`, `crates/metal2vulkan/src/lower/sampler/select.rs (select_one)` | `rare`: min_lod_clamp on a device without shaderResourceMinLod | @@ -177,7 +177,6 @@ Columns: | `GlobalBuiltinInFragment` | A fragment function's read of a Metal 3.1 program-scope built-in variable that Metal does not lower there | every device (not implemented) | `ours` | 1: `crates/metal2vulkan/src/lower/select.rs (route_air)` | `rare`: Metal 3.1 global built-ins in fragment functions | | `PrivateRenderState` | A private fixed-function property of Metal's pipeline descriptor (Apple SPI, OpenGL on Metal's) set to a value whose effect the translation has... | devices without VkFeature::LogicOp; every device (not implemented) | `ours` | 7: `crates/metal2vulkan/src/bind/heap.rs (array)`, `crates/metal2vulkan/src/bind/plan/resources.rs (write_rounding)` (+5) | `none`: Apple-private pipeline fields of OpenGL on Metal (no public header) | | `ExtendedRangeBlend` | Metal's blend into an extended-range attachment (`BGRA10_XR`, `BGR10_XR`, `RGB10A8_2P_XR10` and their `_sRGB` twins), which the function computes... | every device (not implemented) | `ours` | 4: `crates/metal2vulkan/src/lower/arith/extended_range/blend.rs (refused)`, `crates/metal2vulkan/src/lower/fragment/fetch.rs (plan, 3 sites)` | `system`: the parts of a blend into an extended-range (XR10) attachment the measured model does not hold (second-source factors, the color blend color difference, a one-color-channel mask, float4 and sRGB outside the measured forms); the consumer's guests blend RGB10A8_2P_XR10 attachments | -| `TileReach` | The tiles a render pass's primitives reach, binned on the device ([`tile_reach_module`](crate::bind::tile_reach_module)), on a device without what... | devices short of a Vulkan feature the site names; devices without a capability the site computes (`vec![int64]`); every device (not implemented) | `ours` | 3: `crates/metal2vulkan/src/bind/tile_reach.rs (tile_reach_module)`, `crates/metal2vulkan/src/lower/stage_io/plan.rs (capture, 2 sites)` | `app`: the tiles a pass's draws reach, binned on a device without shaderInt64 | | `ProgramScopeBinding` | A program-scope buffer binding of MSL 3.2 (macOS 15 and later), `constant T* constant p [[buffer(n)]];` in Apple's `!air.global_bindings` list,... | - | `-` | via a helper: 2: `crates/metal2vulkan-air/src/abi/module.rs (decode)`, `crates/metal2vulkan/src/error/mod.rs (from)` | `app`: MSL 3.2 program-scope buffer bindings (macOS 15 and later) | | `SeqCstFence` | A sequentially consistent fence (`seq_cst` `atomic_thread_fence`, an LLVM `fence seq_cst`, or a `seq_cst` barrier ordering device memory), whose... | devices short of a Vulkan feature the site names | `device` | 1: `crates/metal2vulkan/src/lower/sync/barrier.rs (require_seq_cst)` | `rare`: a seq_cst fence in a vertex or fragment stage without its stores and atomics | | `PostDepthCoverage` | The coverage after the depth and stencil tests (`[[sample_mask, post_depth_coverage]]`), read through `VK_EXT_post_depth_coverage` | devices short of a Vulkan extension the site names; devices without VkExtension::ExtPostDepthCoverage | `device` | 2: `crates/metal2vulkan-runtime/src/families/features.rs (state)`, `crates/metal2vulkan/src/lower/stage_io/plan.rs (param)` | `rare`: the coverage after early depth and stencil tests on a device without VK_EXT_post_depth_coverage | @@ -593,7 +592,7 @@ Each refusal's sites, with the function that builds it. - `feature::BufferRange`: `crates/metal2vulkan-runtime/src/function_table.rs (past_storage_buffer_range)`; `crates/metal2vulkan/src/bind/graphics.rs (patch_binding, 3 sites)`; `crates/metal2vulkan/src/bind/instantiate.rs (bind_buffers)`; `crates/metal2vulkan/src/lower/access/function_table.rs (select)`; `crates/metal2vulkan/src/lower/access/mod.rs (place_slots)` - `feature::Int64Arithmetic`: `crates/metal2vulkan/src/lower/arith/legal.rs (check_scalar)`; `crates/metal2vulkan/src/lower/select.rs (selector_form)` - `feature::Float64Arithmetic`: `crates/metal2vulkan/src/device/metal.rs (unsupported_features)`; `crates/metal2vulkan/src/lower/arith/legal.rs (check_scalar)` -- `feature::Format`: `crates/metal2vulkan-runtime/src/binding_view.rs (binding_view)`; `crates/metal2vulkan-runtime/src/blit_plan.rs (check_formats, 3 sites)`; `crates/metal2vulkan-runtime/src/blit_plan.rs (pair_unit)`; `crates/metal2vulkan-runtime/src/blit_plan.rs (plan_levels_copy)`; `crates/metal2vulkan-runtime/src/blit_texture.rs (through_buffer)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs (make_texture_over, 3 sites)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs (texture_buffer_texel)`; `crates/metal2vulkan-runtime/src/color_resolve.rs (of_attachment)`; `crates/metal2vulkan-runtime/src/copy_plan.rs (colour_unit)`; `crates/metal2vulkan-runtime/src/copy_plan.rs (copy_unit, 2 sites)`; `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs (scratch)`; `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs (usable_twin)`; `crates/metal2vulkan-runtime/src/families/features.rs (read_write_tier)`; `crates/metal2vulkan-runtime/src/families/formats.rs (answers, 5 sites)`; `crates/metal2vulkan-runtime/src/families/formats.rs (atomic_gap)`; `crates/metal2vulkan-runtime/src/families/formats.rs (lacking)`; `crates/metal2vulkan-runtime/src/families/formats.rs (none)`; `crates/metal2vulkan-runtime/src/families/formats.rs (sparse_missing)`; `crates/metal2vulkan-runtime/src/families/formats.rs (unsupported)`; `crates/metal2vulkan-runtime/src/image_plan.rs (plan_held, 3 sites)`; `crates/metal2vulkan-runtime/src/render.rs (viewing)`; `crates/metal2vulkan-runtime/src/render_pass.rs (attachment_format)`; `crates/metal2vulkan-runtime/src/render_pass.rs (check_target)`; `crates/metal2vulkan-runtime/src/render_pass.rs (layout)`; `crates/metal2vulkan-runtime/src/render_pass.rs (target)`; `crates/metal2vulkan-runtime/src/resolve.rs (color)`; `crates/metal2vulkan-runtime/src/resolve.rs (unmodelled_resolve)`; `crates/metal2vulkan-runtime/src/sample_copy.rs (checked_twin)`; `crates/metal2vulkan-runtime/src/sample_copy.rs (plan)`; `crates/metal2vulkan-runtime/src/sample_interleave.rs (interleave_merge)`; `crates/metal2vulkan-runtime/src/shadow.rs (unmerged, 2 sites)`; `crates/metal2vulkan-runtime/src/texture.rs (texture_as)`; `crates/metal2vulkan-runtime/src/texture.rs (two_planes_refused)`; `crates/metal2vulkan-runtime/src/texture/decoded_twin.rs (astc_texels)`; `crates/metal2vulkan-runtime/src/texture/decoded_twin.rs (etc_texels)`; `crates/metal2vulkan-runtime/src/texture/decoded_twin.rs (with_decoded_twin)`; `crates/metal2vulkan-runtime/src/texture/heap.rs (planned_heap_texture)`; `crates/metal2vulkan-runtime/src/texture/surface_two_planes.rs (refused)`; `crates/metal2vulkan-runtime/src/texture/ycbcr_image.rs (converted_storage)`; `crates/metal2vulkan-runtime/src/texture/ycbcr_image.rs (new_render_shadow)`; `crates/metal2vulkan-runtime/src/texture/ycbcr_image.rs (ycbcr_write_shadow)`; `crates/metal2vulkan-runtime/src/two_planes.rs (unmeasured)`; `crates/metal2vulkan-runtime/src/view_plan.rs (check_format, 5 sites)`; `crates/metal2vulkan-runtime/src/ycbcr.rs (refused)`; `crates/metal2vulkan/src/bind/extended_shadow.rs (extended_shadow_module)`; `crates/metal2vulkan/src/bind/plan/resources.rs (extended_sampler)`; `crates/metal2vulkan/src/bind/plan/resources.rs (plain_texture, 2 sites)`; `crates/metal2vulkan/src/bind/plan/resources.rs (require_filter_features)`; `crates/metal2vulkan/src/bind/sample_interleave.rs (finish)`; `crates/metal2vulkan/src/bind/sample_interleave.rs (interleave_split_module)`; `crates/metal2vulkan/src/bind/shadow_copy_in.rs (shadow_copy_in_module)`; `crates/metal2vulkan/src/bind/unused_bits.rs (unused_bits_module)`; `crates/metal2vulkan/src/lower/access/tile.rs (storage_format)`; `crates/metal2vulkan/src/lower/fragment/color.rs (select_param, 2 sites)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs (extended_range_blend, 5 sites)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs (plan)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs (select_output, 3 sites)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs (select_read)`; `crates/metal2vulkan/src/lower/sampler/select.rs (select_extended)`; `crates/metal2vulkan/src/lower/sampler/select.rs (texel_in)`; `crates/metal2vulkan/src/lower/stage_io/extended_color.rs (plan)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs (entry)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs (zeroed_output)`; `crates/metal2vulkan/src/lower/stage_io/word_color.rs (plan)`; `crates/metal2vulkan/src/lower/texture/mod.rs (cross_class)`; `crates/metal2vulkan/src/lower/texture/mod.rs (select)`; `crates/metal2vulkan/src/lower/texture/mod.rs (select_image)`; `crates/metal2vulkan/src/lower/texture/mod.rs (select_read_as, 2 sites)`; `crates/metal2vulkan/src/lower/texture/mod.rs (select_write)`; `crates/metal2vulkan/src/lower/texture/slot.rs (atomic_format, 2 sites)`; `crates/metal2vulkan/src/lower/texture/slot.rs (declare_slot, 3 sites)`; `crates/metal2vulkan/src/lower/texture/slot.rs (storage_format, 5 sites)`; `crates/metal2vulkan/src/lower/texture/slot.rs (ulong_format, 3 sites)`; `crates/metal2vulkan/src/metal/format/mod.rs (candidates)`; `crates/metal2vulkan/src/metal/format/mod.rs (held_storage_choice, 3 sites)`; `crates/metal2vulkan/src/metal/format/mod.rs (storage_choice)`; `crates/metal2vulkan/src/metal/format/mod.rs (vk_format, 2 sites)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs (extended_write_mask)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs (graphics_state, 2 sites)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs (reads_alpha_to_coverage, 2 sites)`; `crates/metal2vulkan/src/pipeline/rotated_blend.rs (alpha_in_red_blend)`; `crates/metal2vulkan/src/pipeline/rotated_blend.rs (rotated_blend)` +- `feature::Format`: `crates/metal2vulkan-runtime/src/binding_view.rs (binding_view)`; `crates/metal2vulkan-runtime/src/blit_plan.rs (check_formats, 3 sites)`; `crates/metal2vulkan-runtime/src/blit_plan.rs (pair_unit)`; `crates/metal2vulkan-runtime/src/blit_plan.rs (plan_levels_copy)`; `crates/metal2vulkan-runtime/src/blit_texture.rs (through_buffer)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs (make_texture_over, 3 sites)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs (texture_buffer_texel)`; `crates/metal2vulkan-runtime/src/color_resolve.rs (of_attachment)`; `crates/metal2vulkan-runtime/src/copy_plan.rs (colour_unit)`; `crates/metal2vulkan-runtime/src/copy_plan.rs (copy_unit, 2 sites)`; `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs (scratch)`; `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs (usable_twin)`; `crates/metal2vulkan-runtime/src/families/features.rs (read_write_tier)`; `crates/metal2vulkan-runtime/src/families/formats.rs (answers, 5 sites)`; `crates/metal2vulkan-runtime/src/families/formats.rs (atomic_gap)`; `crates/metal2vulkan-runtime/src/families/formats.rs (lacking)`; `crates/metal2vulkan-runtime/src/families/formats.rs (none)`; `crates/metal2vulkan-runtime/src/families/formats.rs (sparse_missing)`; `crates/metal2vulkan-runtime/src/families/formats.rs (unsupported)`; `crates/metal2vulkan-runtime/src/image_plan.rs (plan_held, 3 sites)`; `crates/metal2vulkan-runtime/src/render.rs (viewing)`; `crates/metal2vulkan-runtime/src/render_pass.rs (attachment_format)`; `crates/metal2vulkan-runtime/src/render_pass.rs (check_target)`; `crates/metal2vulkan-runtime/src/render_pass.rs (layout)`; `crates/metal2vulkan-runtime/src/render_pass.rs (target)`; `crates/metal2vulkan-runtime/src/resolve.rs (color)`; `crates/metal2vulkan-runtime/src/resolve.rs (unmodelled_resolve)`; `crates/metal2vulkan-runtime/src/sample_copy.rs (checked_twin)`; `crates/metal2vulkan-runtime/src/sample_copy.rs (plan)`; `crates/metal2vulkan-runtime/src/sample_interleave.rs (interleave_merge)`; `crates/metal2vulkan-runtime/src/shadow.rs (unmerged, 2 sites)`; `crates/metal2vulkan-runtime/src/texture.rs (texture_as)`; `crates/metal2vulkan-runtime/src/texture.rs (two_planes_refused)`; `crates/metal2vulkan-runtime/src/texture/decoded_twin.rs (astc_texels)`; `crates/metal2vulkan-runtime/src/texture/decoded_twin.rs (etc_texels)`; `crates/metal2vulkan-runtime/src/texture/decoded_twin.rs (with_decoded_twin)`; `crates/metal2vulkan-runtime/src/texture/heap.rs (planned_heap_texture)`; `crates/metal2vulkan-runtime/src/texture/surface_two_planes.rs (refused)`; `crates/metal2vulkan-runtime/src/texture/ycbcr_image.rs (converted_storage)`; `crates/metal2vulkan-runtime/src/texture/ycbcr_image.rs (new_render_shadow)`; `crates/metal2vulkan-runtime/src/texture/ycbcr_image.rs (ycbcr_write_shadow)`; `crates/metal2vulkan-runtime/src/two_planes.rs (unmeasured)`; `crates/metal2vulkan-runtime/src/view_plan.rs (check_format, 5 sites)`; `crates/metal2vulkan-runtime/src/ycbcr.rs (refused)`; `crates/metal2vulkan/src/bind/extended_shadow.rs (extended_shadow_module)`; `crates/metal2vulkan/src/bind/plan/resources.rs (extended_sampler)`; `crates/metal2vulkan/src/bind/plan/resources.rs (plain_texture, 2 sites)`; `crates/metal2vulkan/src/bind/plan/resources.rs (require_filter_features)`; `crates/metal2vulkan/src/bind/sample_interleave.rs (finish)`; `crates/metal2vulkan/src/bind/sample_interleave.rs (interleave_split_module)`; `crates/metal2vulkan/src/bind/shadow_copy_in.rs (shadow_copy_in_module)`; `crates/metal2vulkan/src/lower/access/tile.rs (storage_format)`; `crates/metal2vulkan/src/lower/fragment/color.rs (select_param, 2 sites)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs (extended_range_blend, 5 sites)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs (plan)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs (select_output, 3 sites)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs (select_read)`; `crates/metal2vulkan/src/lower/sampler/select.rs (select_extended)`; `crates/metal2vulkan/src/lower/sampler/select.rs (texel_in)`; `crates/metal2vulkan/src/lower/stage_io/extended_color.rs (plan)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs (entry)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs (zeroed_output)`; `crates/metal2vulkan/src/lower/stage_io/word_color.rs (plan)`; `crates/metal2vulkan/src/lower/texture/mod.rs (cross_class)`; `crates/metal2vulkan/src/lower/texture/mod.rs (select)`; `crates/metal2vulkan/src/lower/texture/mod.rs (select_image)`; `crates/metal2vulkan/src/lower/texture/mod.rs (select_read_as, 2 sites)`; `crates/metal2vulkan/src/lower/texture/mod.rs (select_write)`; `crates/metal2vulkan/src/lower/texture/slot.rs (atomic_format, 2 sites)`; `crates/metal2vulkan/src/lower/texture/slot.rs (declare_slot, 3 sites)`; `crates/metal2vulkan/src/lower/texture/slot.rs (storage_format, 5 sites)`; `crates/metal2vulkan/src/lower/texture/slot.rs (ulong_format, 3 sites)`; `crates/metal2vulkan/src/metal/format/mod.rs (candidates)`; `crates/metal2vulkan/src/metal/format/mod.rs (held_storage_choice, 3 sites)`; `crates/metal2vulkan/src/metal/format/mod.rs (storage_choice)`; `crates/metal2vulkan/src/metal/format/mod.rs (vk_format, 2 sites)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs (extended_write_mask)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs (graphics_state, 2 sites)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs (reads_alpha_to_coverage, 2 sites)`; `crates/metal2vulkan/src/pipeline/rotated_blend.rs (alpha_in_red_blend)`; `crates/metal2vulkan/src/pipeline/rotated_blend.rs (rotated_blend)` - `feature::DivergentImplicitLod`: `crates/metal2vulkan/src/lower/sampler/select.rs (select_sampling)` - `feature::ImplicitLodOutsideFragment`: `crates/metal2vulkan/src/lower/sampler/constexpr.rs (query_min_level)`; `crates/metal2vulkan/src/lower/sampler/select.rs (query_level_measured)`; `crates/metal2vulkan/src/lower/sampler/select.rs (query_min_level)` - `feature::MinLodClamp`: `crates/metal2vulkan/src/lower/sampler/select.rs (min_lod)`; `crates/metal2vulkan/src/lower/sampler/select.rs (select_one)` @@ -679,7 +678,6 @@ Each refusal's sites, with the function that builds it. - `feature::GlobalBuiltinInFragment`: `crates/metal2vulkan/src/lower/select.rs (route_air)` - `feature::PrivateRenderState`: `crates/metal2vulkan/src/bind/heap.rs (array)`; `crates/metal2vulkan/src/bind/plan/resources.rs (write_rounding)`; `crates/metal2vulkan/src/lower/sampler/select.rs (clamps_reference)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs (alpha_test_refused)`; `crates/metal2vulkan/src/lower/texture/mod.rs (mode_rounded_write)`; `crates/metal2vulkan/src/pipeline/private_state.rs (logic_operation)`; `crates/metal2vulkan/src/pipeline/private_state.rs (refused)` - `feature::ExtendedRangeBlend`: `crates/metal2vulkan/src/lower/arith/extended_range/blend.rs (refused)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs (plan, 3 sites)` -- `feature::TileReach`: `crates/metal2vulkan/src/bind/tile_reach.rs (tile_reach_module)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs (capture, 2 sites)` - `feature::ProgramScopeBinding`: `crates/metal2vulkan-air/src/abi/module.rs (decode)`; `crates/metal2vulkan/src/error/mod.rs (from)` - `feature::SeqCstFence`: `crates/metal2vulkan/src/lower/sync/barrier.rs (require_seq_cst)` - `feature::PostDepthCoverage`: `crates/metal2vulkan-runtime/src/families/features.rs (state)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs (param)` diff --git a/scripts/refusal-surface/reach.tsv b/scripts/refusal-surface/reach.tsv index 6eb6a025e..945155d9e 100644 --- a/scripts/refusal-surface/reach.tsv +++ b/scripts/refusal-surface/reach.tsv @@ -229,7 +229,6 @@ gap PrimitiveIdIndices rare an indexed draw of a primitive_id pipeline, on a dev feature PrivateRenderState none Apple-private pipeline fields of OpenGL on Metal (no public header) gap SurfaceDepthStencil rare a blit of the stencil of a Depth32Float_Stencil8 texture over a plane of an IOSurface with planes, or a pass on an X32_Stencil8 one's view as Depth32Float_Stencil8 feature ExtendedRangeBlend system the parts of a blend into an extended-range (XR10) attachment the measured model does not hold (second-source factors, the color blend color difference, a one-color-channel mask, float4 and sRGB outside the measured forms); the consumer's guests blend RGB10A8_2P_XR10 attachments -feature TileReach app the tiles a pass's draws reach, binned on a device without shaderInt64 feature CommandPredication none Apple-private command predication on a device without buffer device addresses feature ProgramScopeBinding app MSL 3.2 program-scope buffer bindings (macOS 15 and later) feature SeqCstFence rare a seq_cst fence in a vertex or fragment stage without its stores and atomics