Push window: each device's maxPushConstantsSize sizes it, up to 256 bytes (rule 2's ninth form)
What: the push window is one value per device, `DeviceProfile::push_window`, the description's
maxPushConstantsSize up to 256 bytes, decided in the profile `Device::from_queries` derives
(device/profile.rs:115). Every window reads it: push placement (`lower::push::window`, `place`,
`spills` and `check_floor` take its bytes; lower/select.rs, lower/access/mod.rs and
lower/access/table.rs pass it), and in the runtime the one pipeline layout's push range
(device.rs:688), the kernel and render pipelines' push checks (pipeline.rs:2119, render.rs:1043)
and the encoder's push bound (encoder.rs:1759). With W that value, a kernel pushes in [0, W), a
vertex function in [base, W - 8) and a fragment function in [base, W); object and mesh functions
keep 0..32 and 32..64. A stage's fields past its window spill to its parameter block, whose
address the window holds, as they did past 256. `from_queries` refuses a maxPushConstantsSize
below 128, Vulkan's least, only (`Unsupported{PushWindow}`, required 128), and the runtime's
floor no longer lists maxPushConstantsSize (floor.rs: its row and PUSH_CONSTANT_BYTES go; the
layout's range was a constant 256). There is no constant 128 path, no switch and no environment
gate: the limit query is the only input. Ported from the held branch steelbrain/amdfloor-window
(d6880ca16b) onto today's development, every line reference confirmed against this tree.
Why: the owner's word choosing option B. A device reporting 128 bytes was refused by the floor;
it now runs with a window of 128.
AGENTS.md rule 2 takes the owner's authorized text: "for eight only" becomes "for nine only",
and the push window joins the list after run-time texel offsets.
Known gap (runtime README, Known gaps of indirect command buffers): in a window of 128 bytes a
command reaches 9 vertex slots, and 8 where the vertex function spills, against 25 and 24 at 256
((W - 8 - 16 - 28) / 8; from code: lower::push's
an_indirect_draw_s_vertex_function_pushes_25_or_9_slot_words). A kernel pushes 8 buffer
addresses beside its dispatch region at 128 bytes against 24 at 256, the rest from its ring.
Caches: a device of 128 and one of 256 share no cached artifact and no pipeline. The profile's
fingerprint hashes every ProfileFields field by Debug (device/profile.rs:312, :327), the limits
included (:346, maxPushConstantsSize at :625); `function_key` hashes the fingerprint
(pipeline/compile/key.rs:182, :189; passed at pipeline/compile.rs:2973), as does
`queried_render_descriptor_key` (key.rs:546); a cached artifact or pipeline loads only under an
equal fingerprint (cache/artifacts.rs:71, :204, :238; cache/envelope.rs:142); and the runtime's
enables digest, which the stage keys check, hashes it (metal2vulkan-runtime/src/device.rs:1533).
SEMANTICS_VERSION stays 2273: no module changes under an unchanged key. Every device
`from_queries` accepted before reports 256 bytes or more (it refused below 256), so its window is
256 as before and its modules are the same bytes; a device of fewer bytes was refused, so it
holds no artifact to go stale, and its modules are new under its own fingerprint. The golden
test at this tree found 0 cells changed under an unchanged key over the 15 committed profiles,
and 1855 under a changed profile fingerprint, runtime-floor's column alone (m3-max-68089; the rows
whose assembler Linux lacks are not observed there).
Golden table: runtime-floor.json and its generator drop the floor block's maxPushConstantsSize
of 256, so the profile reads Vulkan 1.3's least, 128, and its fingerprint moves. Its cells are
re-blessed on development (the bless needs macOS's assembler).
Validation: runtime-sources.sha256 is rewritten (d4a8dbf2...), since device/derive.rs and
device/profile.rs are runtime inputs the guard hashes.
Docs: the runtime README (the floor's limits note and table, compute Parameters, the render push
range, the indirect command buffers' known gaps), docs/API.md section 5 and the from_queries
paragraph, PushWindow's doc, reach.tsv and docs/REFUSALS.md (regenerated; the PushWindow row
only), the device profiles' README, and api_signatures.tsv (DeviceProfile::push_window). The
api_surface table is unchanged: no public type is added.
Tests: lower::push's placement at 256 and 128; from_queries (each committed profile's window is
its limit up to 256, runtime-floor's 128; 128 derives, 64 is refused with required 128); the
tessellation control range, the engine identity and spill tests in each profile's window; and
the runtime's push_window, patch and indirect token tests in two arms each, the device's own
limit and the limit held at 128 by the tests' device shim (tests/command.rs push_window_128,
DeviceOptions::described).
Verified:
- m3-max-68088 (this tree): fmt, the signatures table, the refusal surface, clippy -D warnings
plain, --cfg m2v_gpu and --cfg m2v_cpu_icd, workspace Rustdoc -D warnings: each exit 0. The
runtime suite on lavapipe (--cfg m2v_cpu_icd): 647 passed, 3 skipped. Its push lines read
"push_window: the push window is 256 bytes", "push_window_128: the push window is 128 bytes",
"window 128, 12 buffers: 3 ring writes and 3 pushes over 3 dispatches", "icb_tokens: ... the
push window 256 bytes, 25 slot words", "icb_tokens_128: ... the push window 128 bytes, 9 slot
words", and draw_patches_full_range at 256 and _128 at 128.
- m3-max-68089 (this tree): the core crates 3881 of 3882 passed, 24 skipped; the one failure
is the golden table, stale under runtime-floor's moved fingerprint (1855 cells, one per row
observed on Linux, 0 new, 0 gone, 0 under a changed source, 0 changed under an unchanged key).
Validation 1314 passed, 3 skipped. The translator's push tests print each committed profile's
window: runtime-floor 128, the vertex function ending at 120, 9 inputs; the 14 others 256.
- m3-max-68067: the whole runtime suite on lavapipe at an earlier tree of this change
(a98af765ad, before the rebase onto 91fed9449c and the options alias) with a probe commit that
holds every device's limit at 128 in Device::open (steelbrain/amdfloorb-probe128, never landed):
647 passed, 3 skipped; the conformance replay exited 0; every push line read 128 bytes.
No card under 256 ran it; the 128 form ran on lavapipe with the limit held at 128.
This commit is contained in:
1 parent
951285e7a7
commit
d9077dfa0d
41 files changed
+973
-675
No files matched your search
@@ -58,7 +58,7 @@ order, and a lower one never overrides a higher one.
|
||||
limit and memory-type queries. Product code holds no vendor, device or driver ID, and no
|
||||
runtime policy switch. A test enforces this for `metal2vulkan-runtime`. One form means one form per
|
||||
Vulkan capability: where the floor cannot require a feature, that feature's query may choose a
|
||||
second form, for eight only: 16-bit floats, storage-image reads without a format, 64-bit
|
||||
second form, for nine only: 16-bit floats, storage-image reads without a format, 64-bit
|
||||
atomics, 64-bit floats, SIMD groups (the subgroup size range with its stages and operations,
|
||||
and maximal reconvergence), unified memory (decided by
|
||||
Vulkan's physical device type alone: one copy of a Managed buffer on an integrated or CPU
|
||||
@@ -66,8 +66,10 @@ order, and a lower one never overrides a higher one.
|
||||
target through a counted copy of that target, recorded as a known gap), and run-time texel
|
||||
offsets (a device with the maintenance8 feature takes a run-time texel offset as the sampling
|
||||
or read instruction's own operand; a device without it branches over the offset's values, and
|
||||
that branch's compile time is recorded as a known gap). A second form chosen by anything else
|
||||
is not allowed.
|
||||
that branch's compile time is recorded as a known gap), and the push window (the device's
|
||||
push-constant limit sizes it, up to 256 bytes; on a device below 256 the fields past the window
|
||||
come from the stage's parameter block, and an indirect command carries fewer vertex slots,
|
||||
recorded as a known gap). A second form chosen by anything else is not allowed.
|
||||
3. **Native-like speed.** Structure decides speed: driver-owned memory, optimal images in real
|
||||
layouts, direct addresses, nothing copied that Metal would not copy. Optimal images have two
|
||||
exceptions. A texture over a Shared buffer: a linear image on that buffer's memory, in the
|
||||
|
||||
@@ -2321,8 +2321,10 @@ while the driver's exit handler waited on a lock, with every runtime thread alre
|
||||
most 16) is refused (`Refusal::BufferOffsetAlignment`) before anything is recorded, as Metal's
|
||||
API validation refuses the bind offset. Plain Metal runs such a dispatch at addresses of its
|
||||
own; `docs/API.md` section 10 says which.
|
||||
- Parameters: fields in the push window, `[0, 256)` on every device, are pushed: the dispatch
|
||||
region and up to 24 buffer addresses below the kernel's tail (`docs/API.md` section 5), each
|
||||
- Parameters: fields in the push window, `[0, W)`, are pushed, `W` the device's
|
||||
`maxPushConstantsSize` up to 256 bytes (`DeviceProfile::push_window`: 256 on every lab device,
|
||||
128 on a device that reports Vulkan's least): the dispatch region and up to 24 buffer addresses
|
||||
below the kernel's tail at 256 bytes, 8 at 128 (`docs/API.md` section 5), each
|
||||
kernel pushing only the bytes it reads. The tail placement's price, against the build before
|
||||
it: `wide_bindings` is 4.6% slower on an RTX 3090 and 6.9% slower on an Iris Xe and 9.3% faster
|
||||
on a Radeon 780M; `dispatch_chain` 3.0% slower on the RTX 3090; `bind_2000` 25.4% slower in
|
||||
@@ -3342,9 +3344,10 @@ cache is answered compile-required on both.
|
||||
`Gauges::kernel_entries` the map's entries, compute and render together. Two descriptors that
|
||||
differ only in a field their compile does not read are two contents, each compiled.
|
||||
- A render pipeline's two functions push their values (each buffer's address, each constexpr
|
||||
sampler's index) in one range of the floor's 256 bytes, dense by link: the vertex function's
|
||||
sampler's index) in one range of the device's push window (`W` bytes, 256 or 128, as for a
|
||||
kernel above), dense by link: the vertex function's
|
||||
from 0 (from 24 for a post-tessellation function, whose control stage pushes the factors'
|
||||
address at 0), ending by 248, the fragment function's from the vertex function's end, each value at
|
||||
address at 0), ending by `W - 8` (248 or 120), the fragment function's from the vertex function's end, each value at
|
||||
the next offset aligned to it (a framebuffer fetch's element index, four bytes, before the
|
||||
eight-byte values, where the four bytes below one are free), so only the values the pair uses
|
||||
take space. Compute and render pipelines share the device's one pipeline layout and its one
|
||||
@@ -4317,9 +4320,10 @@ vertex and fragment buffers (`inheritBuffers` false), at most 31 of each stage.
|
||||
ms of GPU time with its executions against 4.372 ms with the same draws direct, the executions
|
||||
1.5% under.
|
||||
- A command's buffer slots reach its functions through the push bytes alone, so each slot a
|
||||
command binds needs its word in the state's 256 push bytes, which the vertex and fragment
|
||||
command binds needs its word in the state's push window, `W` bytes (256, or 128 on a device
|
||||
whose `maxPushConstantsSize` is 128), which the vertex and fragment
|
||||
functions and all their other fields share. The translator places the vertex function's fields
|
||||
from byte 0 to byte 248 (the last 8 bytes are kept for the fragment function's parameter block
|
||||
from byte 0 to byte `W - 8` (the last 8 bytes are kept for the fragment function's parameter block
|
||||
address), in a fixed order:
|
||||
1. its parameter block's address (8 bytes), where any of its fields spill;
|
||||
2. any other leading address (8 bytes, so each costs one slot word);
|
||||
@@ -4334,23 +4338,35 @@ vertex and fragment buffers (`inheritBuffers` false), at most 31 of each stage.
|
||||
only where it pushes nothing past them but one 4-byte word or one bounds field. Anything more
|
||||
makes it spill, the block address joins, and it pushes 24: a slot read at a variable offset adds
|
||||
its bounds and the zero range's address after the slot words, so 25 no longer fit. The fragment
|
||||
function's fields run from where the vertex function's end to byte 256, in the same order and with
|
||||
function's fields run from where the vertex function's end to byte `W`, in the same order and with
|
||||
the same tail, except that a lone field of 8 bytes or less takes no tail. From code: a fragment
|
||||
function whose only field is one slot word fits beside a vertex function of 24 or 25 words. Its
|
||||
room past one slot is not measured. An execution whose command binds a slot whose word sits in a
|
||||
room past one slot is not measured.
|
||||
- On a device whose push window is 128 bytes (its `maxPushConstantsSize` is 128), the vertex
|
||||
function's fields end by byte 120, so a command reaches 9 vertex slots ((120 - 16 - 28) / 8,
|
||||
rounded down) where the vertex function pushes nothing past them but one 4-byte word or one
|
||||
bounds field, and 8 where its fields spill, against 25 and 24 at 256 bytes (from code: the
|
||||
translator's `lower::push` test `an_indirect_draw_s_vertex_function_pushes_25_or_9_slot_words`).
|
||||
A fragment function whose only field is one slot word fits beside a vertex function of 8 or 9
|
||||
words. A state whose vertex function reads more slots than that is refused at its execution
|
||||
(`IndirectCommandsKind::DrawInput`), where at 256 bytes it executes. No lab card reports under
|
||||
256: this form runs on lavapipe with its translator told of 128 bytes (the runtime's tests'
|
||||
`push_window_128`), and on no card. An execution whose command binds a slot whose word sits in a
|
||||
parameter block is refused (`IndirectCommandsKind::DrawInput`). Measured on an RTX 3090 and a
|
||||
Radeon RX 7900 XTX (the consumer's jobs m3-max-63155, 63163 and 63164, the runtime at 173861f4f7):
|
||||
a vertex function reading N buffer slots with a fragment function reading 1 draws for N up to 24,
|
||||
and is refused as `DrawInput` for N from 25 to 29; with 28 slots read, commands that bind up to 24
|
||||
vertex slots draw. The token count binds first only on lavapipe (13 slot words, below).
|
||||
vertex slots draw. The token count binds first only on lavapipe in a window of 256 bytes (13 slot
|
||||
words, below).
|
||||
- Each slot word a command holds is a push constant token of its own, on every device, where a run
|
||||
of words at consecutive offsets could share one: on NVIDIA's driver (620.70.06, an RTX 2080) a
|
||||
24-byte push constant token in an execution of 96 commands or more carried command 31's bytes in
|
||||
every later command, and three 8-byte tokens of the same bytes carried each command's own (a
|
||||
standalone program, which draws right either way on RADV and lavapipe). The cost:
|
||||
- A command takes at most `maxIndirectCommandsTokenCount` less 3 slot words, refused past that
|
||||
(`IndirectCommandsKind::Tokens`). That binds before the push bytes only on lavapipe, at 13. On
|
||||
NVIDIA's driver (29) and RADV (125), the push bytes above run out first.
|
||||
(`IndirectCommandsKind::Tokens`). That binds before the push bytes only on lavapipe in a window
|
||||
of 256 bytes, at 13. On NVIDIA's driver (29) and RADV (125), and in a window of 128 bytes on
|
||||
every device, the push bytes above run out first.
|
||||
- That program's part of 64 commands of three vertex words and one fragment word takes 69,888
|
||||
preprocess bytes on the 2080, against 57,600 with the vertex words in one token (21% more);
|
||||
567,808 against 557,568 on lavapipe; and 19,712 either way on the XTX.
|
||||
@@ -4380,9 +4396,10 @@ vertex and fragment buffers (`inheritBuffers` false), at most 31 of each stage.
|
||||
`maxIndirectSequenceCount` (`Capacity`), a compute state for indirect command buffers
|
||||
(`ComputeCommands`), an execution with a state made without `supportIndirectCommandBuffers`
|
||||
(`UnflaggedState`), one whose slots take more tokens than `maxIndirectCommandsTokenCount`
|
||||
(`Tokens`, which only lavapipe's 16 reach before the push bytes run out), and one whose functions
|
||||
(`Tokens`, which only lavapipe's 16 reach before the push bytes run out, in a window of 256
|
||||
bytes), and one whose functions
|
||||
read what a command cannot carry: a slot the command holds outside the push bytes (at most 24
|
||||
vertex slots once the vertex function spills, above), a fixed-function vertex binding, or a
|
||||
vertex slots once the vertex function spills, 8 in a window of 128 bytes, above), a fixed-function vertex binding, or a
|
||||
vertex layout that must draw from base instance 0 (`DrawInput`).
|
||||
- Commands draw with the executing encoder's render states whatever the descriptor's other
|
||||
`inherit*` properties say. Not built: commands the CPU encodes (`indirectRenderCommandAtIndex:`),
|
||||
@@ -4731,7 +4748,11 @@ Metal's eight color attachments on every device; Vulkan 1.3 requires 4 of it, an
|
||||
`maxFragmentOutputAttachments` holds a fragment function's output to each of them; Vulkan 1.3 and
|
||||
1.4 require 4 of it, and Roadmap 2026 8.
|
||||
A Boolean limit's minimum is 1,
|
||||
`VK_TRUE`; `timestampValidBits` is the queue family's.
|
||||
`VK_TRUE`; `timestampValidBits` is the queue family's. No `maxPushConstantsSize` is asked: the
|
||||
push window, and the pipeline layout's one push range, is the device's `maxPushConstantsSize` up to
|
||||
256 bytes (`metal2vulkan::device::DeviceProfile::push_window`), at least Vulkan's least, 128, and a
|
||||
function's fields past it go to a parameter block whose address the window holds. On a device
|
||||
below 256 an indirect command reaches fewer vertex slots (Known gaps of indirect command buffers).
|
||||
|
||||
| Limit | Minimum | Used for |
|
||||
|---|---|---|
|
||||
@@ -4744,7 +4765,6 @@ A Boolean limit's minimum is 1,
|
||||
| `maxSamplerAllocationCount` | `4000` | Vulkan's minimum: live samplers |
|
||||
| `maxPerStageUpdateAfterBindResources` | `262144` | the four texture and texture-buffer arrays in one stage; a fragment stage needs its `maxColorAttachments` more |
|
||||
| `maxUpdateAfterBindDescriptorsInAllPools` | `274144` | all seven arrays |
|
||||
| `maxPushConstantsSize` | `256` | per-command values: a compute kernel's dispatch region and 24 buffer addresses below its tail, anything larger in a block whose address is pushed; a render pipeline's vertex and fragment functions' values in the same 256 bytes, dense by link, anything larger in a block whose address is pushed |
|
||||
| `maxComputeWorkGroupInvocations` | `1024` | Metal's most threads per threadgroup |
|
||||
| `maxComputeWorkGroupSize[0]` | `1024` | a threadgroup's width |
|
||||
| `maxComputeWorkGroupSize[1]` | `1024` | a threadgroup's height |
|
||||
|
||||
@@ -2420,7 +2420,8 @@ pub struct Metrics {
|
||||
/// [`DeviceOptions::pipeline_cache_dir`]: crate::DeviceOptions::pipeline_cache_dir
|
||||
pub cache_bytes_written: u64,
|
||||
/// Writes into the parameter ring: a dispatch's parameter block, its fields past the push
|
||||
/// window (a kernel with more than 28 buffers), and each `set_bytes` copy, a render
|
||||
/// window (`DeviceProfile::push_window`: a kernel with more than 24 buffer addresses beside
|
||||
/// its dispatch region at 256 bytes, more than 8 at 128), and each `set_bytes` copy, a render
|
||||
/// encoder's too.
|
||||
pub ring_writes: u64,
|
||||
/// `vkCmdPushConstants` recorded: a draw's or a dispatch's push bytes, where the command
|
||||
|
||||
@@ -18,7 +18,7 @@ use crate::instance::{Instance, PhysicalDevice};
|
||||
use crate::kernel_map::KernelMap;
|
||||
use crate::memory::{self, BlockId, BlockMappings, Memory, MemoryClass, Pool};
|
||||
use crate::pass::ResolveModes;
|
||||
use crate::pipeline::{PUSH_BYTES, PUSH_STAGES};
|
||||
use crate::pipeline::PUSH_STAGES;
|
||||
use crate::places::Places;
|
||||
use crate::reaper::{self, Job, Reaper};
|
||||
use crate::record::Recorders;
|
||||
@@ -342,7 +342,7 @@ pub(crate) struct Core {
|
||||
/// The occlusion query pools command buffers take their visibility results' queries from.
|
||||
pub(crate) occlusion: OcclusionPools,
|
||||
/// The one pipeline layout of every pipeline: the empty set 0, set 1, and the push window
|
||||
/// over every stage.
|
||||
/// over every stage, the translator's `DeviceProfile::push_window` bytes.
|
||||
pub(crate) layout: vk::PipelineLayout,
|
||||
/// Set 1: the texture and sampler arrays, and the grants of their indices.
|
||||
pub(crate) arrays: Arrays,
|
||||
@@ -684,9 +684,11 @@ impl Device {
|
||||
(options.pipeline_cache_cap).unwrap_or(cache::DEFAULT_CAP),
|
||||
&counters,
|
||||
);
|
||||
// SAFETY: the device was made from `raw` with `capabilities.features`, and the family is
|
||||
// its queues' family.
|
||||
let made = unsafe { objects(&device, &capabilities, &counters) };
|
||||
// The translator's window: the device's `maxPushConstantsSize` up to 256 bytes.
|
||||
let window = translator.profile().push_window();
|
||||
// SAFETY: the device was made from `raw` with `capabilities.features`, the family is its
|
||||
// queues' family, and its push limit holds the window.
|
||||
let made = unsafe { objects(&device, &capabilities, &counters, window) };
|
||||
let (memory_types, done, arrays, layout) = match made {
|
||||
Ok(made) => made,
|
||||
Err(error) => {
|
||||
@@ -1439,15 +1441,17 @@ unsafe fn consumer_features(
|
||||
}
|
||||
|
||||
/// The memory types the floor chooses on a new device, the completion thread's semaphores, set 1's
|
||||
/// arrays and the pipeline layout.
|
||||
/// arrays and the pipeline layout, whose one push range is `window` bytes.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// `device` was made with `capabilities.features`.
|
||||
/// `device` was made with `capabilities.features`, and its `maxPushConstantsSize` is at least
|
||||
/// `window`.
|
||||
unsafe fn objects(
|
||||
device: &ash::Device,
|
||||
capabilities: &floor::Capabilities,
|
||||
counters: &Counters,
|
||||
window: u32,
|
||||
) -> Result<(floor::MemoryTypes, Done, Arrays, vk::PipelineLayout), Error> {
|
||||
// SAFETY: the caller's contract.
|
||||
let memory_types =
|
||||
@@ -1466,14 +1470,14 @@ unsafe fn objects(
|
||||
let push = [vk::PushConstantRange {
|
||||
stage_flags: PUSH_STAGES,
|
||||
offset: 0,
|
||||
size: PUSH_BYTES,
|
||||
size: window,
|
||||
}];
|
||||
let sets = arrays.set_layouts();
|
||||
let info = vk::PipelineLayoutCreateInfo::default()
|
||||
.set_layouts(&sets)
|
||||
.push_constant_ranges(&push);
|
||||
// SAFETY: the device is live, and the floor holds `PUSH_BYTES` of push constants and set
|
||||
// 1's update-after-bind descriptors in one stage.
|
||||
// SAFETY: the device is live, it holds `window` bytes of push constants (the caller's
|
||||
// contract), and the floor holds set 1's update-after-bind descriptors in one stage.
|
||||
match unsafe { device.create_pipeline_layout(&info, None) } {
|
||||
Ok(layout) => Ok((done, arrays, layout)),
|
||||
Err(result) => {
|
||||
|
||||
@@ -15,7 +15,7 @@ use crate::memory::BlockId;
|
||||
use crate::over::{self, Reached, Span};
|
||||
use crate::pipeline::{
|
||||
address_word, Compiled, ComputePipelineState, FieldValue, Form, Interface, Kernel, Place,
|
||||
Which, PUSH_BYTES, PUSH_STAGES, SQUARE,
|
||||
Which, PUSH_STAGES, SQUARE,
|
||||
};
|
||||
use crate::record::Reach;
|
||||
use crate::ring::CHUNK;
|
||||
@@ -1581,6 +1581,12 @@ impl ComputeCommandEncoder {
|
||||
pub(crate) fn pushed(&self) -> &[u8] {
|
||||
&self.parameters.push
|
||||
}
|
||||
|
||||
/// The parameter block's bytes the encoder's last dispatch filled, which `tests::bicubic`
|
||||
/// reads the words of its fields past the push window from.
|
||||
pub(crate) fn blocked(&self) -> &[u8] {
|
||||
&self.parameters.block
|
||||
}
|
||||
}
|
||||
|
||||
/// A dispatch's parameters: the push window's bytes, and the ring block's with where its address
|
||||
@@ -1751,7 +1757,7 @@ impl Building {
|
||||
parameters.push[at..at + 8].copy_from_slice(&address.to_le_bytes());
|
||||
}
|
||||
let push = ¶meters.push[..];
|
||||
debug_assert!(push.len() <= PUSH_BYTES as usize);
|
||||
debug_assert!(push.len() <= core.translator.profile().push_window() as usize);
|
||||
let command = self.command(Reach::Dispatches {
|
||||
indirect: matches!(launch, Launch::Indirect(..)),
|
||||
})?;
|
||||
|
||||
@@ -1675,8 +1675,9 @@ pub enum KernelInputKind {
|
||||
/// address for it. Metal's counterpart is the kernel's arguments, which Metal binds however
|
||||
/// many there are.
|
||||
ArgumentBlock,
|
||||
/// Arguments whose pushed words are past the push-constant bytes of the runtime's floor.
|
||||
/// Metal's counterpart is the kernel's arguments, which Metal binds however many there are.
|
||||
/// Arguments whose pushed words are past the device's push window
|
||||
/// (`DeviceProfile::push_window`, its `maxPushConstantsSize` up to 256 bytes). Metal's
|
||||
/// counterpart is the kernel's arguments, which Metal binds however many there are.
|
||||
PushBytes,
|
||||
/// A specialization constant the runtime does not set: an explicit imageblock's width or
|
||||
/// height, a sampler state's fields, a constant that is not 4 bytes, the threadgroup memory
|
||||
|
||||
@@ -247,11 +247,6 @@ pub(crate) const SAMPLERS: u32 = 4000;
|
||||
/// Sampler arrays: one per use of a sampler (plain, depth comparison, integer texture).
|
||||
pub(crate) const SAMPLER_ARRAYS: u32 = 3;
|
||||
|
||||
/// Bytes of push constants: a dispatch region and 28 buffer addresses (the translator's push
|
||||
/// window on `Device::from_queries`' profile), which every captured device reports, so no query
|
||||
/// decides it.
|
||||
pub(crate) const PUSH_CONSTANT_BYTES: u32 = 256;
|
||||
|
||||
/// Threads in one compute workgroup: Metal's most threads per threadgroup.
|
||||
pub(crate) const WORKGROUP_INVOCATIONS: u32 = 1024;
|
||||
|
||||
@@ -1553,7 +1548,7 @@ fn second_elements_fit(device: &Queried) -> bool {
|
||||
|
||||
/// Each limit the floor sets: its Vulkan name, the device's value, and the least value the runtime
|
||||
/// uses.
|
||||
pub(crate) fn limits(device: &Queried) -> [(&'static str, u32, u32); 18] {
|
||||
pub(crate) fn limits(device: &Queried) -> [(&'static str, u32, u32); 17] {
|
||||
let limits = &device.limits;
|
||||
let descriptors = &device.vulkan12;
|
||||
// A uniform texel buffer counts as a sampled image, and a storage one as a storage image.
|
||||
@@ -1604,11 +1599,6 @@ pub(crate) fn limits(device: &Queried) -> [(&'static str, u32, u32); 18] {
|
||||
descriptors.max_update_after_bind_descriptors_in_all_pools,
|
||||
4 * TEXTURES + SAMPLER_ARRAYS * SAMPLERS,
|
||||
),
|
||||
(
|
||||
"maxPushConstantsSize",
|
||||
limits.max_push_constants_size,
|
||||
PUSH_CONSTANT_BYTES,
|
||||
),
|
||||
(
|
||||
"maxComputeWorkGroupInvocations",
|
||||
limits.max_compute_work_group_invocations,
|
||||
|
||||
@@ -88,12 +88,6 @@ use std::ffi::CString;
|
||||
use std::sync::atomic::{AtomicU64, Ordering::Relaxed};
|
||||
use std::sync::{Arc, Condvar, Mutex, MutexGuard, OnceLock, PoisonError};
|
||||
|
||||
/// The push window: the parameters a kernel reads from push constants, `[0, 256)` on every device,
|
||||
/// the floor's `maxPushConstantsSize` and the translator's window on `Device::from_queries`'
|
||||
/// profile: a dispatch region and 28 buffer addresses. Fields past it go to a block in the
|
||||
/// parameter ring, whose address is a field in the window.
|
||||
pub(crate) const PUSH_BYTES: u32 = crate::floor::PUSH_CONSTANT_BYTES;
|
||||
|
||||
/// The stages of the layout's one push range, which every `vkCmdPushConstants` names: a
|
||||
/// dispatch's and a draw's pushes are of one range over the compute, vertex and fragment stages.
|
||||
pub(crate) const PUSH_STAGES: vk::ShaderStageFlags = vk::ShaderStageFlags::ALL;
|
||||
@@ -1410,10 +1404,12 @@ fn past_stage_bound(error: &Error) -> bool {
|
||||
}
|
||||
|
||||
/// The runtime's view of the translator's kernel, or what the kernel reads that the compute
|
||||
/// encoder does not supply ([`Gap::KernelInput`] of that kind), the first this finds.
|
||||
/// encoder does not supply ([`Gap::KernelInput`] of that kind), the first this finds, on a device
|
||||
/// whose push window is `window` bytes (`DeviceProfile::push_window`).
|
||||
pub(crate) fn interface(
|
||||
pipeline: &ComputePipeline,
|
||||
required_size: Option<[u32; 3]>,
|
||||
window: u32,
|
||||
) -> Result<Interface, KernelInputKind> {
|
||||
let translated = &pipeline.interface;
|
||||
let stage = &pipeline.stage;
|
||||
@@ -1631,7 +1627,7 @@ pub(crate) fn interface(
|
||||
(1.., Some(at)) if u64::from(block_len) <= CHUNK => at,
|
||||
_ => return Err(KernelInputKind::ArgumentBlock),
|
||||
};
|
||||
if push_len > PUSH_BYTES {
|
||||
if push_len > window {
|
||||
return Err(KernelInputKind::PushBytes);
|
||||
}
|
||||
// The threadgroup memory arguments are the lengths the module specializes on, each by its
|
||||
@@ -2234,7 +2230,8 @@ impl Kernel {
|
||||
pipeline: ComputePipeline,
|
||||
required_size: Option<[u32; 3]>,
|
||||
) -> Result<Kernel, Unmade> {
|
||||
let interface = interface(&pipeline, required_size).map_err(Unmade::Unsupplied)?;
|
||||
let window = core.translator.profile().push_window();
|
||||
let interface = interface(&pipeline, required_size, window).map_err(Unmade::Unsupplied)?;
|
||||
let stage = pipeline.stage;
|
||||
let heavy = Heavy::of(&stage);
|
||||
// The translator's entry points hold no NUL; one that did would name no entry point.
|
||||
|
||||
@@ -79,7 +79,7 @@ use crate::kernel_map::KernelKey;
|
||||
use crate::pass::Pass;
|
||||
use crate::pipeline::{
|
||||
access, loaded, lower, made_through_cache, number_samplers, of_the_device, texture_access,
|
||||
translating, FieldValue, Numbered, PUSH_BYTES,
|
||||
translating, FieldValue, Numbered,
|
||||
};
|
||||
use crate::reaper::{Free, Job};
|
||||
use crate::ring::CHUNK;
|
||||
@@ -595,11 +595,13 @@ fn draw_input() -> Error {
|
||||
///
|
||||
/// Err: [`Gap::RenderPipeline`] of [`RenderPipelineKind::DrawInput`] for a pipeline that reads
|
||||
/// what a draw does not supply: a function table, a table the binder builds, a parameter block
|
||||
/// longer than a ring chunk, a push field or bind-time fact the encoder does not fill, or an
|
||||
/// longer than a ring chunk, push bytes past the device's push `window`
|
||||
/// (`DeviceProfile::push_window`), a push field or bind-time fact the encoder does not fill, or an
|
||||
/// unnormalized constexpr sampler.
|
||||
fn draws(
|
||||
pipeline: &RenderPipeline,
|
||||
nonzero_first_instance: bool,
|
||||
window: u32,
|
||||
) -> Result<(Draws, Numbering), Error> {
|
||||
let translated = &pipeline.interface;
|
||||
if translated.needs_pointer_translation
|
||||
@@ -837,7 +839,7 @@ fn draws(
|
||||
_ => return Err(draw_input()),
|
||||
}
|
||||
}
|
||||
if push_len > PUSH_BYTES {
|
||||
if push_len > window {
|
||||
return Err(draw_input());
|
||||
}
|
||||
let bindings = (pipeline.vertex_input.bindings.iter())
|
||||
@@ -1143,7 +1145,8 @@ impl RenderCompiled {
|
||||
.profile()
|
||||
.limits()
|
||||
.supports_non_zero_first_instance;
|
||||
let (draws, (numbered, constexprs)) = draws(&pipeline, nonzero_first_instance)?;
|
||||
let window = translator.profile().push_window();
|
||||
let (draws, (numbered, constexprs)) = draws(&pipeline, nonzero_first_instance, window)?;
|
||||
let samples = lowered.raster_sample_count;
|
||||
let mut stages = Vec::new();
|
||||
let mut notes: Vec<_> = constexpr_notes(translator.profile(), &constexprs).collect();
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
//! A kernel that samples 2D textures through a bicubic constexpr sampler at normalized
|
||||
//! coordinates (the owned fixture `engine/bcu_formats`, ten slots, the last two with `half`
|
||||
//! results), under a device cfg on every device of the cfg's kind. Each dispatch pushes, for each
|
||||
//! results), under a device cfg on every device of the cfg's kind. Each dispatch passes, for each
|
||||
//! slot, how Metal's bicubic filter treats the format bound there, which selects the filter's arm
|
||||
//! at run time: the linear inner taps for `R32Float`, a clamp to [0, 1] for `RGBA8Unorm`,
|
||||
//! `RGBA16Unorm` and `R8Unorm`, a clamp to [-1, 1] for `RGBA8Snorm`, and no clamp for
|
||||
//! `RGBA16Float`. Each format is bound at every slot over six dispatches; a slot bound to nothing
|
||||
//! pushes the unbound word. A dispatch whose slot holds an `RGBA8Unorm_sRGB` texture is refused,
|
||||
//! naming the slot and the format. The command buffer is never committed.
|
||||
//! `RGBA16Float`. A slot's word is pushed, or in the dispatch's parameter block where the push
|
||||
//! window has no room for it. Each format is bound at every slot over six dispatches; a slot
|
||||
//! bound to nothing passes the unbound word. A dispatch whose slot holds an `RGBA8Unorm_sRGB`
|
||||
//! texture is refused, naming the slot and the format. The command buffer is never committed.
|
||||
//!
|
||||
//! `llvm-as` assembles the kernel; without it the test skips visibly.
|
||||
|
||||
@@ -85,17 +86,11 @@ mod on_device {
|
||||
Ok(vec![CONSTEXPR])
|
||||
})
|
||||
.unwrap_or_else(|error| panic!("{name}: {error}"));
|
||||
// Each slot's field, in the push window.
|
||||
// Each slot's field, in the push window or the parameter block.
|
||||
let mut at = [None; SLOTS];
|
||||
for field in &state.inner.compiled.whole.interface.fields {
|
||||
if let FieldValue::BicubicTexels(slot) = field.value {
|
||||
let Place::Push(offset) = field.place else {
|
||||
panic!("{name}: slot {slot}'s field in a parameter block");
|
||||
};
|
||||
assert!(
|
||||
at[slot as usize].replace(offset as usize).is_none(),
|
||||
"{name}"
|
||||
);
|
||||
assert!(at[slot as usize].replace(field.place).is_none(), "{name}");
|
||||
}
|
||||
}
|
||||
let at = at.map(|at| at.unwrap_or_else(|| panic!("{name}: a slot with no field")));
|
||||
@@ -130,9 +125,13 @@ mod on_device {
|
||||
call(encoder.set_texture(texture, slot as u32));
|
||||
}
|
||||
call(encoder.dispatch_threads([4, 1, 1], [4, 1, 1]));
|
||||
let push = encoder.pushed().to_vec();
|
||||
let (push, block) = (encoder.pushed().to_vec(), encoder.blocked().to_vec());
|
||||
for (slot, k) in (0..SLOTS).zip(d..) {
|
||||
let word = u32::from_le_bytes(push[at[slot]..at[slot] + 4].try_into().unwrap());
|
||||
let (bytes, at) = match at[slot] {
|
||||
Place::Push(at) => (&push, at as usize),
|
||||
Place::Block(at) => (&block, at as usize),
|
||||
};
|
||||
let word = u32::from_le_bytes(bytes[at..at + 4].try_into().unwrap());
|
||||
if (d, slot) == (0, SLOTS - 1) {
|
||||
assert_eq!(word, BICUBIC_TEXELS_UNBOUND, "{name}: slot {slot}, unbound");
|
||||
continue;
|
||||
|
||||
@@ -223,6 +223,23 @@ pub(crate) mod on_device {
|
||||
open_each_device(test, &instance, options, body);
|
||||
}
|
||||
|
||||
/// What a test opens each device with ([`each_device_with`]).
|
||||
pub(crate) type Options = fn() -> DeviceOptions;
|
||||
|
||||
/// The options of a device whose translator reads a `maxPushConstantsSize` of 128, Vulkan's
|
||||
/// least, in place of the device's own (`DeviceOptions::described`): its push window and its
|
||||
/// pipeline layout's push range are 128 bytes. No lab device reports under 256, so a test runs
|
||||
/// the 128-byte window on each device this way.
|
||||
pub(crate) fn push_window_128() -> DeviceOptions {
|
||||
DeviceOptions {
|
||||
described: Some(|mut description| {
|
||||
description.limits.max_push_constants_size = 128;
|
||||
description
|
||||
}),
|
||||
..DeviceOptions::default()
|
||||
}
|
||||
}
|
||||
|
||||
/// [`each_device`] on `instance`.
|
||||
pub(crate) fn on_each_device(
|
||||
test: &str,
|
||||
|
||||
@@ -131,7 +131,7 @@ pub(super) fn at_the_floor() -> Queried {
|
||||
.max_sampler_allocation_count(4000)
|
||||
.max_color_attachments(8)
|
||||
.max_fragment_output_attachments(8)
|
||||
.max_push_constants_size(256)
|
||||
.max_push_constants_size(128)
|
||||
.max_compute_work_group_invocations(1024)
|
||||
.max_compute_work_group_size([1024, 1024, 64])
|
||||
.timestamp_compute_and_graphics(true)
|
||||
@@ -782,7 +782,7 @@ fn each_missing_feature_is_named() {
|
||||
#[test]
|
||||
fn each_low_limit_is_named() {
|
||||
type Lower = fn(&mut Queried);
|
||||
let cases: [(Lower, &str, u32); 19] = [
|
||||
let cases: [(Lower, &str, u32); 18] = [
|
||||
(
|
||||
|d| {
|
||||
d.vulkan12
|
||||
@@ -843,11 +843,6 @@ fn each_low_limit_is_named() {
|
||||
"maxUpdateAfterBindDescriptorsInAllPools",
|
||||
4 * 65_536 + 12_000,
|
||||
),
|
||||
(
|
||||
|d| d.limits.max_push_constants_size = 255,
|
||||
"maxPushConstantsSize",
|
||||
256,
|
||||
),
|
||||
(
|
||||
|d| d.limits.max_compute_work_group_invocations = 1023,
|
||||
"maxComputeWorkGroupInvocations",
|
||||
@@ -1114,7 +1109,7 @@ fn every_missing_item_is_named_at_once() {
|
||||
device.extensions.clear();
|
||||
device.features.vulkan13.dynamic_rendering = vk::FALSE;
|
||||
device.features.core.shader_int64 = vk::FALSE;
|
||||
device.limits.max_push_constants_size = 64;
|
||||
device.limits.max_color_attachments = 4;
|
||||
device.families[0].queue_flags = vk::QueueFlags::COMPUTE;
|
||||
device.memory = memory(&[DEVICE_LOCAL, SHARED_MEMORY]);
|
||||
let Err(below) = decide(&device) else {
|
||||
@@ -1130,9 +1125,9 @@ fn every_missing_item_is_named_at_once() {
|
||||
feature("VkPhysicalDeviceFeatures", "shaderInt64"),
|
||||
feature("VkPhysicalDeviceVulkan13Features", "dynamicRendering"),
|
||||
Missing::Limit {
|
||||
name: "maxPushConstantsSize",
|
||||
device: 64,
|
||||
needed: 256,
|
||||
name: "maxColorAttachments",
|
||||
device: 4,
|
||||
needed: 8,
|
||||
},
|
||||
Missing::QueueFamily,
|
||||
Missing::MemoryType {
|
||||
@@ -1144,7 +1139,7 @@ fn every_missing_item_is_named_at_once() {
|
||||
below.to_string(),
|
||||
"the device is below the runtime's floor: it lacks VK_KHR_swapchain; \
|
||||
VK_EXT_robustness2; VK_EXT_calibrated_timestamps; VK_EXT_line_rasterization; VkPhysicalDeviceFeatures.shaderInt64; VkPhysicalDeviceVulkan13Features.dynamicRendering; \
|
||||
maxPushConstantsSize 64, below 256; a queue family with graphics and compute; a memory \
|
||||
maxColorAttachments 4, below 8; a queue family with graphics and compute; a memory \
|
||||
type with VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | \
|
||||
VK_MEMORY_PROPERTY_HOST_COHERENT_BIT for buffers"
|
||||
);
|
||||
|
||||
@@ -40,7 +40,9 @@
|
||||
//! reads past the end of the buffer its command named reads the bytes past it, each drawing
|
||||
//! as the same draw direct, through the buffer bound at that offset, draws.
|
||||
//! - a state whose fourteen slots apart take 17 tokens is `IndirectCommandsKind::Tokens` on a
|
||||
//! device that takes fewer (lavapipe's 16), and executes on one that takes as many.
|
||||
//! device that takes fewer (lavapipe's 16), and executes on one that takes as many, in a push
|
||||
//! window of 256 bytes; in one of 128 (`push_window_128`), whose vertex function pushes 9 slot
|
||||
//! words at most, it is `IndirectCommandsKind::DrawInput` on every device.
|
||||
//! - the device's caches hold at most their capacities past them: 16 templates, 256 execution
|
||||
//! shapes and 64 command layouts.
|
||||
//! - the preprocess pool: regions held past 64 MiB in use all go back, the idle bytes at most
|
||||
@@ -156,16 +158,18 @@ fn an_executions_tokens_are_a_token_per_slot_word() {
|
||||
mod on_device {
|
||||
use crate::indirect::{Tokens, IDLE_BYTES, LAYOUTS, PART_BYTES, SHAPES, TEMPLATES};
|
||||
use crate::render::Raster;
|
||||
use crate::tests::command::on_device::each_device;
|
||||
use crate::tests::command::on_device::{
|
||||
each_device, each_device_with, push_window_128, Options,
|
||||
};
|
||||
use crate::tests::draw::on_device::{library, pass, read, run, state, target, Buffers};
|
||||
use crate::{
|
||||
Buffer, ColorAttachmentDescriptor, ComputePipelineDescriptor, ComputePipelineState,
|
||||
CullMode, Device, DispatchType, DrawKind, Error, FunctionDescriptor, Gap, HostBytes,
|
||||
IndexBuffer, IndexClass, IndexType, IndirectCommandBuffer, IndirectCommandBufferDescriptor,
|
||||
IndirectCommandType, IndirectCommandsKind, Library, MemoryClass, PixelFormat,
|
||||
PrimitiveType, Refusal, Region, RenderCommandEncoder, RenderPipelineDescriptor,
|
||||
RenderPipelineKind, RenderPipelineState, Resource, ResourceUsage, StageSource,
|
||||
TextureDescriptor, TextureType, TextureUsage, VisibilityResultMode,
|
||||
CullMode, Device, DeviceOptions, DispatchType, DrawKind, Error, FunctionDescriptor, Gap,
|
||||
HostBytes, IndexBuffer, IndexClass, IndexType, IndirectCommandBuffer,
|
||||
IndirectCommandBufferDescriptor, IndirectCommandType, IndirectCommandsKind, Library,
|
||||
MemoryClass, PixelFormat, PrimitiveType, Refusal, Region, RenderCommandEncoder,
|
||||
RenderPipelineDescriptor, RenderPipelineKind, RenderPipelineState, Resource, ResourceUsage,
|
||||
StageSource, TextureDescriptor, TextureType, TextureUsage, VisibilityResultMode,
|
||||
};
|
||||
use ash::vk;
|
||||
use metal2vulkan::metal::VertexFormat;
|
||||
@@ -1152,34 +1156,54 @@ mod on_device {
|
||||
let Some(extras) = library(&engine_dir().join("icb_indexed_extras.ll")) else {
|
||||
return;
|
||||
};
|
||||
each_device("icb_tokens", |name, _, device| {
|
||||
let Some(commands) = commands(name, &device, &descriptor(27, 0), 1) else {
|
||||
return;
|
||||
};
|
||||
let wide = flagged(
|
||||
name,
|
||||
&device,
|
||||
&extras,
|
||||
("icb_extras_wide_vertex", "icb_extras_fragment"),
|
||||
);
|
||||
let tokens = (device.core().indirect.as_ref())
|
||||
.expect("the extension")
|
||||
.limits
|
||||
.tokens;
|
||||
drawn(name, &device, &wide, |e| {
|
||||
match (e.execute_commands_in_buffer(&commands, 0..1), tokens < 17) {
|
||||
(
|
||||
Err(Error::Unsupported(Gap::IndirectCommandBuffers {
|
||||
kind: IndirectCommandsKind::Tokens,
|
||||
})),
|
||||
true,
|
||||
)
|
||||
| (Ok(()), false) => {}
|
||||
(other, _) => panic!("{name}: 17 tokens on a device of {tokens}: {other:?}"),
|
||||
}
|
||||
let arms: [(&str, Options); 2] = [
|
||||
("icb_tokens", DeviceOptions::default),
|
||||
("icb_tokens_128", push_window_128),
|
||||
];
|
||||
for (test, options) in arms {
|
||||
each_device_with(test, options, |name, _, device| {
|
||||
let Some(commands) = commands(name, &device, &descriptor(27, 0), 1) else {
|
||||
return;
|
||||
};
|
||||
let wide = flagged(
|
||||
name,
|
||||
&device,
|
||||
&extras,
|
||||
("icb_extras_wide_vertex", "icb_extras_fragment"),
|
||||
);
|
||||
let tokens = (device.core().indirect.as_ref())
|
||||
.expect("the extension")
|
||||
.limits
|
||||
.tokens;
|
||||
// The slot words the vertex function's window holds beside the execution range,
|
||||
// the sequence and the part's first command, below its tail word: 25 at 256
|
||||
// bytes, 9 at 128.
|
||||
let window = device.translator().profile().push_window();
|
||||
let words = (window - 8 - 16 - 28) / 8;
|
||||
let want = match (words >= 14, tokens < 17) {
|
||||
(false, _) => Some(IndirectCommandsKind::DrawInput),
|
||||
(true, true) => Some(IndirectCommandsKind::Tokens),
|
||||
(true, false) => None,
|
||||
};
|
||||
drawn(name, &device, &wide, |e| {
|
||||
match (e.execute_commands_in_buffer(&commands, 0..1), want) {
|
||||
(
|
||||
Err(Error::Unsupported(Gap::IndirectCommandBuffers { kind })),
|
||||
Some(want),
|
||||
) if kind == want => {}
|
||||
(Ok(()), None) => {}
|
||||
(other, _) => panic!(
|
||||
"{name}: 17 tokens on a device of {tokens}, a window of {window}: \
|
||||
{other:?}, not {want:?}"
|
||||
),
|
||||
}
|
||||
});
|
||||
println!(
|
||||
"{name}: {test}: a state of 17 tokens on a device that takes {tokens}, \
|
||||
the push window {window} bytes, {words} slot words"
|
||||
);
|
||||
});
|
||||
println!("{name}: a state of 17 tokens on a device that takes {tokens}");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// A state made for indirect command buffers fetches its vertex function's `[[stage_in]]`
|
||||
@@ -1362,7 +1386,7 @@ mod on_device {
|
||||
.pipeline(vk::PrimitiveTopology::TRIANGLE_LIST, Raster::default()),
|
||||
);
|
||||
let layout = IndirectDrawLayout::new(31, 31).expect("a layout");
|
||||
let room = crate::pipeline::PUSH_BYTES / 8 - 1;
|
||||
let room = core.translator.profile().push_window() / 8 - 1;
|
||||
let words = room.min(indirect.limits.tokens.saturating_sub(3));
|
||||
let slots = (0..31)
|
||||
.map(|slot| layout.vertex_slot(slot))
|
||||
|
||||
@@ -30,15 +30,17 @@
|
||||
#[cfg(any(m2v_gpu, m2v_cpu_icd))]
|
||||
mod on_device {
|
||||
use crate::tests::blit::on_device::settled;
|
||||
use crate::tests::command::on_device::each_device;
|
||||
use crate::tests::command::on_device::{
|
||||
each_device, each_device_with, push_window_128, Options,
|
||||
};
|
||||
use crate::tests::draw::on_device::{
|
||||
descriptor, examples, floats, library, pass, read, run, state, target, texels, vertices,
|
||||
Buffers, BLACK, BLUE, GREEN, SIDE,
|
||||
};
|
||||
use crate::{
|
||||
Buffer, ColorAttachmentDescriptor, Device, DrawKind, Error, FunctionDescriptor, Gap,
|
||||
Library, PixelFormat, PrimitiveType, Refusal, RenderPipelineDescriptor, RenderPipelineKind,
|
||||
StageSource, TextureUsage,
|
||||
Buffer, ColorAttachmentDescriptor, Device, DeviceOptions, DrawKind, Error,
|
||||
FunctionDescriptor, Gap, Library, PixelFormat, PrimitiveType, Refusal,
|
||||
RenderPipelineDescriptor, RenderPipelineKind, StageSource, TextureUsage,
|
||||
};
|
||||
use metal2vulkan::error::Feature;
|
||||
use metal2vulkan::metal::{
|
||||
@@ -126,11 +128,18 @@ attributes #0 = { mustprogress nofree nosync nounwind willreturn memory(read) }
|
||||
!17 = !{!"Metal", i32 4, i32 0, i32 0}
|
||||
BUFFER_META"#;
|
||||
|
||||
/// The buffer arguments of each of [`wide_fragment`]'s functions: the narrowest pushes
|
||||
/// every field; behind a post-tessellation function whose window started at 0, 19 would end
|
||||
/// the pair's fields at 252, where the factors' 8-byte address no longer fits above them; the
|
||||
/// widest spills.
|
||||
const FRAGMENT_WIDTHS: [u32; 4] = [4, 12, 19, 24];
|
||||
/// The buffer arguments of each of [`wide_fragment`]'s functions in a push window of
|
||||
/// `window` bytes: the narrowest pushes every field. At 256 bytes, behind a post-tessellation
|
||||
/// function whose window started at 0, 19 would end the pair's fields at 252, where the
|
||||
/// factors' 8-byte address no longer fits above them, and the widest spills; at 128 bytes
|
||||
/// every wider one spills.
|
||||
fn fragment_widths(window: u32) -> [u32; 4] {
|
||||
match window {
|
||||
256 => [4, 12, 19, 24],
|
||||
128 => [1, 2, 3, 12],
|
||||
other => panic!("no fragment widths for a push window of {other} bytes"),
|
||||
}
|
||||
}
|
||||
|
||||
/// A fragment function that writes its `user(locn0)` colour plus `width` `float4` buffer
|
||||
/// arguments at indices 0 and on, each read at element 0, a read checked against the
|
||||
@@ -594,12 +603,14 @@ BUFFER_META"#;
|
||||
});
|
||||
}
|
||||
|
||||
/// A patch state whose fragment function's fields fill the floor's push range behind the
|
||||
/// A patch state whose fragment function's fields fill the device's push range behind the
|
||||
/// post-tessellation function's ([`wide_fragment`]) is made, as Metal makes it, and draws its
|
||||
/// patches: the control stage pushes the factors' address at 0, below the post-tessellation
|
||||
/// function's window, and the fragment function's fields past the range go to its block. A
|
||||
/// pair's fields reach past 248 bytes, where no range of the factors' address is left above
|
||||
/// them, and the widest fragment function's spill. Every state is made before any draw.
|
||||
/// patches, at the device's own push window and at 128 bytes (`push_window_128`): the control
|
||||
/// stage pushes the factors' address at 0, below the post-tessellation function's window, and
|
||||
/// the fragment function's fields past the range go to its block. The narrowest fragment
|
||||
/// function pushes every field. At 256 bytes a pair's fields reach past 248, where no range of
|
||||
/// the factors' address is left above them, and the widest fragment function's spill; at 128
|
||||
/// every wider one spills. Every state is made before any draw.
|
||||
/// Buffer `k` holds `2^(k / 4) / 255` in channel `k % 4` and the tints are 0, so the first
|
||||
/// patch's colour holds every bit of the buffers a function reads only where each buffer's
|
||||
/// address and bounds reach it; the second patch is culled.
|
||||
@@ -611,7 +622,7 @@ BUFFER_META"#;
|
||||
return;
|
||||
};
|
||||
let mut fragments = Vec::new();
|
||||
for width in FRAGMENT_WIDTHS {
|
||||
for width in [1, 2, 3, 4, 12, 19, 24] {
|
||||
match llvm_assemble_text(&wide_fragment(width)) {
|
||||
Ok(bitcode) => fragments.push((
|
||||
width,
|
||||
@@ -624,86 +635,107 @@ BUFFER_META"#;
|
||||
Err(error) => panic!("the wide fragment {width}: {error:?}"),
|
||||
}
|
||||
}
|
||||
each_device("draw_patches_full_range", |name, _, device| {
|
||||
let states: Vec<_> = (fragments.iter())
|
||||
.map(|(width, library)| {
|
||||
let mut d = patches(&libraries);
|
||||
d.fragment = Some(StageSource::Function(FunctionDescriptor::new(
|
||||
library
|
||||
.function("tess_wide_fragment")
|
||||
.expect("the function"),
|
||||
)));
|
||||
(
|
||||
*width,
|
||||
state(&format!("{name}: {width} buffers"), &device, &d),
|
||||
)
|
||||
})
|
||||
.collect();
|
||||
let (mut widest, mut spilled) = (0, false);
|
||||
for (width, state) in &states {
|
||||
let draws = &state.inner.compiled.draws;
|
||||
assert!(
|
||||
(draws.fields.iter()).any(|(place, _, value)| matches!(
|
||||
(place, value),
|
||||
(DrawPlace::Push(0), FieldValue::TessellationFactors)
|
||||
)),
|
||||
"{name}: {width} buffers: the factors' address at 0"
|
||||
);
|
||||
widest = widest.max(draws.push_len);
|
||||
spilled |= draws.blocks[crate::render::FRAGMENT].is_some();
|
||||
let mut buffers = Buffers::new(&device);
|
||||
let (points, _, factors) = patch_buffers(&device, &mut buffers);
|
||||
let tints = buffers.of(&device, &[0; 32]);
|
||||
let summed: Vec<Buffer> = (0..*width)
|
||||
.map(|k| {
|
||||
let mut value = [0.0; 4];
|
||||
value[(k % 4) as usize] = f32::from(1u8 << (k / 4)) / 255.0;
|
||||
buffers.of(&device, &floats(&value))
|
||||
let arms: [(&str, Options); 2] = [
|
||||
("draw_patches_full_range", DeviceOptions::default),
|
||||
("draw_patches_full_range_128", push_window_128),
|
||||
];
|
||||
for (test, options) in arms {
|
||||
each_device_with(test, options, |name, _, device| {
|
||||
let window = device.translator().profile().push_window();
|
||||
let widths = fragment_widths(window);
|
||||
println!("{name}: {test}: the push window is {window} bytes");
|
||||
let states: Vec<_> = (fragments.iter())
|
||||
.filter(|(width, _)| widths.contains(width))
|
||||
.map(|(width, library)| {
|
||||
let mut d = patches(&libraries);
|
||||
d.fragment = Some(StageSource::Function(FunctionDescriptor::new(
|
||||
library
|
||||
.function("tess_wide_fragment")
|
||||
.expect("the function"),
|
||||
)));
|
||||
(
|
||||
*width,
|
||||
state(&format!("{name}: {width} buffers"), &device, &d),
|
||||
)
|
||||
})
|
||||
.collect();
|
||||
let color = target(
|
||||
&device,
|
||||
PixelFormat::RGBA8Unorm,
|
||||
TextureUsage::RENDER_TARGET,
|
||||
);
|
||||
let queue = device.new_command_queue(4).expect("a queue");
|
||||
let command_buffer = queue.command_buffer().expect("a command buffer");
|
||||
let mut encoder = (command_buffer.render_command_encoder(&pass(&color, None)))
|
||||
.unwrap_or_else(|error| panic!("{name}: {error}"));
|
||||
let draw =
|
||||
|result: Result<(), Error>| result.unwrap_or_else(|e| panic!("{name}: {e}"));
|
||||
draw(encoder.set_render_pipeline_state(state));
|
||||
draw(encoder.set_vertex_buffer(Some(&points), 0, 0));
|
||||
draw(encoder.set_vertex_buffer(Some(&tints), 0, 1));
|
||||
for (k, buffer) in summed.iter().enumerate() {
|
||||
draw(encoder.set_fragment_buffer(Some(buffer), 0, k as u32));
|
||||
}
|
||||
draw(encoder.set_tessellation_factor_buffer(Some(&factors), 8, 0));
|
||||
draw(encoder.draw_patches(3, 0, 2, None, 1, 0));
|
||||
encoder.end_encoding();
|
||||
run(name, &command_buffer);
|
||||
let mut sums = [0u8; 4];
|
||||
for k in 0..*width {
|
||||
sums[(k % 4) as usize] += 1 << (k / 4);
|
||||
}
|
||||
let black = [0, 0, 0, 255];
|
||||
let want: Vec<u8> = (0..SIDE * SIDE)
|
||||
.flat_map(|at| if at / SIDE < 4 { sums } else { black })
|
||||
.collect();
|
||||
assert_eq!(read(&color, 4), want, "{name}: {width} buffers: the texels");
|
||||
println!(
|
||||
"{name}: {width} fragment buffers, a push range of {} bytes, the fragment \
|
||||
let (mut widest, mut spills) = (0, Vec::new());
|
||||
for (width, state) in &states {
|
||||
let draws = &state.inner.compiled.draws;
|
||||
assert!(
|
||||
(draws.fields.iter()).any(|(place, _, value)| matches!(
|
||||
(place, value),
|
||||
(DrawPlace::Push(0), FieldValue::TessellationFactors)
|
||||
)),
|
||||
"{name}: {width} buffers: the factors' address at 0"
|
||||
);
|
||||
widest = widest.max(draws.push_len);
|
||||
spills.push(draws.blocks[crate::render::FRAGMENT].is_some());
|
||||
let mut buffers = Buffers::new(&device);
|
||||
let (points, _, factors) = patch_buffers(&device, &mut buffers);
|
||||
let tints = buffers.of(&device, &[0; 32]);
|
||||
let summed: Vec<Buffer> = (0..*width)
|
||||
.map(|k| {
|
||||
let mut value = [0.0; 4];
|
||||
value[(k % 4) as usize] = f32::from(1u8 << (k / 4)) / 255.0;
|
||||
buffers.of(&device, &floats(&value))
|
||||
})
|
||||
.collect();
|
||||
let color = target(
|
||||
&device,
|
||||
PixelFormat::RGBA8Unorm,
|
||||
TextureUsage::RENDER_TARGET,
|
||||
);
|
||||
let queue = device.new_command_queue(4).expect("a queue");
|
||||
let command_buffer = queue.command_buffer().expect("a command buffer");
|
||||
let mut encoder = (command_buffer.render_command_encoder(&pass(&color, None)))
|
||||
.unwrap_or_else(|error| panic!("{name}: {error}"));
|
||||
let draw = |result: Result<(), Error>| {
|
||||
result.unwrap_or_else(|e| panic!("{name}: {e}"))
|
||||
};
|
||||
draw(encoder.set_render_pipeline_state(state));
|
||||
draw(encoder.set_vertex_buffer(Some(&points), 0, 0));
|
||||
draw(encoder.set_vertex_buffer(Some(&tints), 0, 1));
|
||||
for (k, buffer) in summed.iter().enumerate() {
|
||||
draw(encoder.set_fragment_buffer(Some(buffer), 0, k as u32));
|
||||
}
|
||||
draw(encoder.set_tessellation_factor_buffer(Some(&factors), 8, 0));
|
||||
draw(encoder.draw_patches(3, 0, 2, None, 1, 0));
|
||||
encoder.end_encoding();
|
||||
run(name, &command_buffer);
|
||||
let mut sums = [0u8; 4];
|
||||
for k in 0..*width {
|
||||
sums[(k % 4) as usize] += 1 << (k / 4);
|
||||
}
|
||||
let black = [0, 0, 0, 255];
|
||||
let want: Vec<u8> = (0..SIDE * SIDE)
|
||||
.flat_map(|at| if at / SIDE < 4 { sums } else { black })
|
||||
.collect();
|
||||
assert_eq!(read(&color, 4), want, "{name}: {width} buffers: the texels");
|
||||
println!(
|
||||
"{name}: {width} fragment buffers, a push range of {} bytes, the fragment \
|
||||
function's block {:?}",
|
||||
draws.push_len,
|
||||
draws.blocks[crate::render::FRAGMENT]
|
||||
);
|
||||
}
|
||||
assert!(
|
||||
widest > 248,
|
||||
"{name}: the widest pair's fields end at {widest}, not past 248"
|
||||
);
|
||||
assert!(spilled, "{name}: no fragment function's fields spill");
|
||||
});
|
||||
draws.push_len,
|
||||
draws.blocks[crate::render::FRAGMENT]
|
||||
);
|
||||
}
|
||||
assert_eq!(spills.first(), Some(&false), "{name}: the narrowest spills");
|
||||
match window {
|
||||
256 => {
|
||||
assert!(
|
||||
widest > 248,
|
||||
"{name}: the widest pair's fields end at {widest}, not past 248"
|
||||
);
|
||||
assert_eq!(spills.last(), Some(&true), "{name}: the widest pushes all");
|
||||
}
|
||||
_ => assert_eq!(
|
||||
spills,
|
||||
widths.map(|width| width > 1).to_vec(),
|
||||
"{name}: the fragment functions whose fields spill, by width"
|
||||
),
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// What Metal refuses is refused, and what the runtime does not build is a gap.
|
||||
|
||||
@@ -1,25 +1,29 @@
|
||||
//! The push window, under a device cfg on every device of the cfg's kind. Each kernel reads its
|
||||
//! grid position and its buffers at a run-time offset, so it pushes a dispatch region, each
|
||||
//! buffer's address, and the containment check's fields: the zero range's address and each
|
||||
//! buffer's bounds (its bytes before the bind offset and its length, 8 bytes), which come last in
|
||||
//! the order, so they are the first to go to a parameter block. A kernel of 12 buffers (232
|
||||
//! bytes) pushes them all and writes nothing into the parameter ring, and its dispatches after
|
||||
//! the first push nothing, their bytes held. One of 24 buffers pushes its block's address, the
|
||||
//! region, 22 buffers' addresses and the zero tail word 24 bytes above them (`docs/API.md` section
|
||||
//! 5), and the other 2 addresses, the zero range's and the 24 bounds go to a block; one of 30
|
||||
//! pushes the same 22 addresses, and the other 8, the zero range's and the 30 bounds go to a
|
||||
//! block. Each of those two writes one block a dispatch, whose new address each dispatch pushes.
|
||||
//! All answer the fold of their inputs.
|
||||
//! The push window, under a device cfg on every device of the cfg's kind, at the device's own
|
||||
//! window (256 bytes on every lab device) and at 128 bytes, Vulkan's least, with the device's
|
||||
//! translator told so (`push_window_128`). Each kernel reads its grid position and its buffers at
|
||||
//! a run-time offset, so it pushes a dispatch region, each buffer's address, and the containment
|
||||
//! check's fields: the zero range's address and each buffer's bounds (its bytes before the bind
|
||||
//! offset and its length, 8 bytes), which come last in the order, so they are the first to go to
|
||||
//! a parameter block. In a window of 256 bytes a kernel of 12 buffers (232 bytes) pushes them all
|
||||
//! and writes nothing into the parameter ring, and its dispatches after the first push nothing,
|
||||
//! their bytes held. One of 24 buffers pushes its block's address, the region, 22 buffers'
|
||||
//! addresses and the zero tail word 24 bytes above them (`docs/API.md` section 5), and the other 2
|
||||
//! addresses, the zero range's and the 24 bounds go to a block; one of 30 pushes the same 22
|
||||
//! addresses, and the other 8, the zero range's and the 30 bounds go to a block. In a window of
|
||||
//! 128 bytes a kernel of 4 buffers (104 bytes) pushes them all; ones of 12 and 30 push 6
|
||||
//! addresses, and the other 6 and 24, the zero range's and the bounds go to a block. Each kernel
|
||||
//! with a block writes one block a dispatch, whose new address each dispatch pushes. All answer
|
||||
//! the fold of their inputs.
|
||||
//!
|
||||
//! `llvm-as` assembles the kernels; without it the test skips visibly.
|
||||
|
||||
#[cfg(any(m2v_gpu, m2v_cpu_icd))]
|
||||
mod on_device {
|
||||
use crate::pipeline::{FieldValue, Place};
|
||||
use crate::tests::command::on_device::{each_device, finished};
|
||||
use crate::tests::command::on_device::{each_device_with, finished, push_window_128, Options};
|
||||
use crate::{
|
||||
ComputePipelineDescriptor, DispatchType, FunctionDescriptor, Library, MemoryClass,
|
||||
StageSource,
|
||||
ComputePipelineDescriptor, DeviceOptions, DispatchType, FunctionDescriptor, Library,
|
||||
MemoryClass, StageSource,
|
||||
};
|
||||
use metal2vulkan_devtools::{llvm_assemble_text, AssembleError};
|
||||
|
||||
@@ -82,133 +86,156 @@ define void @wide({}) {{\nentry:\n{body} %out = getelementptr inbounds i32, ptr
|
||||
(k + 1).wrapping_mul(0x9e37_79b9) ^ gid.wrapping_mul(0x85eb_ca6b)
|
||||
}
|
||||
|
||||
/// The kernel of 12 buffers writes nothing into the ring, and pushes once for its three
|
||||
/// dispatches of the same bindings; the kernels of 24 and 30 push 22 addresses below their
|
||||
/// tail and have the other 2 and 8 in their block with every check field; each of those
|
||||
/// A kernel's buffers, its addresses and check fields in the block, its blocks a dispatch, and
|
||||
/// its pushes over the dispatches.
|
||||
type Case = (u32, (usize, usize), u64, u64);
|
||||
|
||||
/// The cases in a push window of `window` bytes.
|
||||
fn cases(window: u32) -> [Case; 3] {
|
||||
match window {
|
||||
256 => [
|
||||
(12, (0, 0), 0, 1),
|
||||
(24, (2, 25), 1, DISPATCHES),
|
||||
(30, (8, 31), 1, DISPATCHES),
|
||||
],
|
||||
128 => [
|
||||
(4, (0, 0), 0, 1),
|
||||
(12, (6, 13), 1, DISPATCHES),
|
||||
(30, (24, 31), 1, DISPATCHES),
|
||||
],
|
||||
other => panic!("no cases for a push window of {other} bytes"),
|
||||
}
|
||||
}
|
||||
|
||||
/// In a window of 256 bytes the kernel of 12 buffers writes nothing into the ring, and pushes
|
||||
/// once for its three dispatches of the same bindings; the kernels of 24 and 30 push 22
|
||||
/// addresses below their tail and have the other 2 and 8 in their block with every check
|
||||
/// field. In a window of 128 bytes the kernel of 4 buffers does what the 12 do at 256, and the
|
||||
/// kernels of 12 and 30 push 6 and have the other 6 and 24 in their block. Each with a block
|
||||
/// writes one block a dispatch, whose new address each dispatch pushes. Each answers the fold
|
||||
/// of its inputs.
|
||||
#[test]
|
||||
fn every_device_pushes_12_buffers_and_rings_24_and_30() {
|
||||
// Each kernel's buffers, its addresses and check fields in the block, its blocks a
|
||||
// dispatch, and its pushes over the dispatches.
|
||||
for (buffers, (addresses, checks), blocks, pushes) in [
|
||||
(12u32, (0usize, 0usize), 0u64, 1u64),
|
||||
(24, (2, 25), 1, DISPATCHES),
|
||||
(30, (8, 31), 1, DISPATCHES),
|
||||
] {
|
||||
let bitcode = match llvm_assemble_text(&kernel(buffers)) {
|
||||
Ok(bitcode) => bitcode,
|
||||
Err(AssembleError::Missing(why)) => {
|
||||
eprintln!("SKIPPED: {why}");
|
||||
return;
|
||||
fn every_device_pushes_the_buffers_its_window_holds_and_rings_the_rest() {
|
||||
if let Err(AssembleError::Missing(why)) = llvm_assemble_text(&kernel(2)) {
|
||||
eprintln!("SKIPPED: {why}");
|
||||
return;
|
||||
}
|
||||
let arms: [(&str, Options); 2] = [
|
||||
("push_window", DeviceOptions::default),
|
||||
("push_window_128", push_window_128),
|
||||
];
|
||||
for (test, options) in arms {
|
||||
each_device_with(test, options, |name, _, device| {
|
||||
let window = device.translator().profile().push_window();
|
||||
println!("{name}: {test}: the push window is {window} bytes");
|
||||
for case in cases(window) {
|
||||
wide(name, &device, window, case);
|
||||
}
|
||||
Err(error) => panic!("wide: {error:?}"),
|
||||
};
|
||||
let library = Library::from_air(&bitcode).expect("the library");
|
||||
let function = library.function("wide").expect("the kernel");
|
||||
let descriptor = ComputePipelineDescriptor::new(StageSource::Function(
|
||||
FunctionDescriptor::new(function),
|
||||
));
|
||||
let len = u64::from(THREADS * 4);
|
||||
each_device(&format!("push_window_{buffers}"), |name, _, device| {
|
||||
let what = format!("{name}, {buffers} buffers");
|
||||
let state = device
|
||||
.new_compute_pipeline_state(&descriptor, crate::tests::no_constexpr_samplers)
|
||||
.unwrap_or_else(|error| panic!("{what}: {error}"));
|
||||
// The fields in the block: addresses, and the check's (the zero range's address
|
||||
// and the bounds); nothing else goes there.
|
||||
let mut ringed = (0, 0);
|
||||
for field in &state.inner.compiled.whole.interface.fields {
|
||||
match (field.place, &field.value) {
|
||||
(Place::Push(_), _) => {}
|
||||
(Place::Block(_), FieldValue::BufferAddress { .. }) => ringed.0 += 1,
|
||||
(
|
||||
Place::Block(_),
|
||||
FieldValue::BufferBounds(_) | FieldValue::ZeroAddress,
|
||||
) => ringed.1 += 1,
|
||||
(Place::Block(_), _) => panic!("{what}: another field in the block"),
|
||||
}
|
||||
}
|
||||
assert_eq!(
|
||||
ringed,
|
||||
(addresses, checks),
|
||||
"{what}: addresses and check fields in the block"
|
||||
);
|
||||
let block = device
|
||||
.take_block(MemoryClass::Shared, u64::from(buffers) * len)
|
||||
.expect("a Shared block");
|
||||
let bound: Vec<_> = (0..u64::from(buffers))
|
||||
.map(|k| {
|
||||
device
|
||||
.new_buffer(block.id, k * len, len, Some(0))
|
||||
.expect("a buffer")
|
||||
})
|
||||
.collect();
|
||||
for (k, buffer) in bound.iter().enumerate().take(buffers as usize - 1) {
|
||||
let bytes: Vec<u8> = (0..THREADS)
|
||||
.flat_map(|gid| word(k as u32, gid).to_le_bytes())
|
||||
.collect();
|
||||
let contents = buffer.contents().expect("a Shared buffer");
|
||||
// SAFETY: the bytes lie in the buffer, which is alive, and no GPU work uses it.
|
||||
unsafe {
|
||||
std::ptr::copy_nonoverlapping(
|
||||
bytes.as_ptr(),
|
||||
contents.as_ptr(),
|
||||
bytes.len(),
|
||||
)
|
||||
};
|
||||
}
|
||||
let queue = device.new_command_queue(4).expect("a queue");
|
||||
let command_buffer = queue.command_buffer().expect("a command buffer");
|
||||
let before = device.counters().metrics();
|
||||
let mut encoder = command_buffer
|
||||
.compute_command_encoder(DispatchType::Serial)
|
||||
.expect("an encoder");
|
||||
encoder.set_compute_pipeline_state(&state).expect("a state");
|
||||
for (k, buffer) in bound.iter().enumerate() {
|
||||
encoder
|
||||
.set_buffer(Some(buffer), 0, k as u32)
|
||||
.expect("a buffer");
|
||||
}
|
||||
for _ in 0..DISPATCHES {
|
||||
encoder
|
||||
.dispatch_threads([THREADS, 1, 1], [THREADS, 1, 1])
|
||||
.expect("a dispatch");
|
||||
}
|
||||
encoder.end_encoding();
|
||||
command_buffer.commit().expect("a commit");
|
||||
finished(name, &command_buffer);
|
||||
let after = device.counters().metrics();
|
||||
let writes = after.ring_writes - before.ring_writes;
|
||||
assert_eq!(command_buffer.error(), None, "{what}");
|
||||
assert_eq!(writes, blocks * DISPATCHES, "{what}: ring writes");
|
||||
let pushed = after.pushes - before.pushes;
|
||||
let held = after.pushes_held - before.pushes_held;
|
||||
assert_eq!(
|
||||
(pushed, held),
|
||||
(pushes, DISPATCHES - pushes),
|
||||
"{what}: pushes, held"
|
||||
);
|
||||
let inputs = buffers - 1;
|
||||
let contents = bound[inputs as usize].contents().expect("a Shared buffer");
|
||||
for gid in 0..THREADS {
|
||||
let want = (1..inputs).fold(word(0, gid), |s, k| {
|
||||
s.wrapping_mul(3).wrapping_add(word(k, gid))
|
||||
});
|
||||
// SAFETY: the word lies in the buffer, which is alive, and its work completed.
|
||||
let got = unsafe {
|
||||
contents
|
||||
.as_ptr()
|
||||
.cast::<u32>()
|
||||
.add(gid as usize)
|
||||
.read_unaligned()
|
||||
};
|
||||
assert_eq!(got, want, "{what}: thread {gid}");
|
||||
}
|
||||
println!(
|
||||
"{what}: {writes} ring writes and {pushed} pushes over {DISPATCHES} dispatches"
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// Kernel `wide` of `buffers` buffers on `device`, its push window `window` bytes: its
|
||||
/// addresses and check fields in the block, its blocks a dispatch and its pushes over the
|
||||
/// dispatches are as the case gives, and it answers the fold of its inputs.
|
||||
fn wide(name: &str, device: &crate::Device, window: u32, case: Case) {
|
||||
let (buffers, (addresses, checks), blocks, pushes) = case;
|
||||
let bitcode = llvm_assemble_text(&kernel(buffers)).expect("wide");
|
||||
let library = Library::from_air(&bitcode).expect("the library");
|
||||
let function = library.function("wide").expect("the kernel");
|
||||
let descriptor = ComputePipelineDescriptor::new(StageSource::Function(
|
||||
FunctionDescriptor::new(function),
|
||||
));
|
||||
let len = u64::from(THREADS * 4);
|
||||
let what = format!("{name}, window {window}, {buffers} buffers");
|
||||
let state = device
|
||||
.new_compute_pipeline_state(&descriptor, crate::tests::no_constexpr_samplers)
|
||||
.unwrap_or_else(|error| panic!("{what}: {error}"));
|
||||
// The fields in the block: addresses, and the check's (the zero range's address
|
||||
// and the bounds); nothing else goes there.
|
||||
let mut ringed = (0, 0);
|
||||
for field in &state.inner.compiled.whole.interface.fields {
|
||||
match (field.place, &field.value) {
|
||||
(Place::Push(_), _) => {}
|
||||
(Place::Block(_), FieldValue::BufferAddress { .. }) => ringed.0 += 1,
|
||||
(Place::Block(_), FieldValue::BufferBounds(_) | FieldValue::ZeroAddress) => {
|
||||
ringed.1 += 1
|
||||
}
|
||||
(Place::Block(_), _) => panic!("{what}: another field in the block"),
|
||||
}
|
||||
}
|
||||
assert_eq!(
|
||||
ringed,
|
||||
(addresses, checks),
|
||||
"{what}: addresses and check fields in the block"
|
||||
);
|
||||
let block = device
|
||||
.take_block(MemoryClass::Shared, u64::from(buffers) * len)
|
||||
.expect("a Shared block");
|
||||
let bound: Vec<_> = (0..u64::from(buffers))
|
||||
.map(|k| {
|
||||
device
|
||||
.new_buffer(block.id, k * len, len, Some(0))
|
||||
.expect("a buffer")
|
||||
})
|
||||
.collect();
|
||||
for (k, buffer) in bound.iter().enumerate().take(buffers as usize - 1) {
|
||||
let bytes: Vec<u8> = (0..THREADS)
|
||||
.flat_map(|gid| word(k as u32, gid).to_le_bytes())
|
||||
.collect();
|
||||
let contents = buffer.contents().expect("a Shared buffer");
|
||||
// SAFETY: the bytes lie in the buffer, which is alive, and no GPU work uses it.
|
||||
unsafe {
|
||||
std::ptr::copy_nonoverlapping(bytes.as_ptr(), contents.as_ptr(), bytes.len())
|
||||
};
|
||||
}
|
||||
let queue = device.new_command_queue(4).expect("a queue");
|
||||
let command_buffer = queue.command_buffer().expect("a command buffer");
|
||||
let before = device.counters().metrics();
|
||||
let mut encoder = command_buffer
|
||||
.compute_command_encoder(DispatchType::Serial)
|
||||
.expect("an encoder");
|
||||
encoder.set_compute_pipeline_state(&state).expect("a state");
|
||||
for (k, buffer) in bound.iter().enumerate() {
|
||||
encoder
|
||||
.set_buffer(Some(buffer), 0, k as u32)
|
||||
.expect("a buffer");
|
||||
}
|
||||
for _ in 0..DISPATCHES {
|
||||
encoder
|
||||
.dispatch_threads([THREADS, 1, 1], [THREADS, 1, 1])
|
||||
.expect("a dispatch");
|
||||
}
|
||||
encoder.end_encoding();
|
||||
command_buffer.commit().expect("a commit");
|
||||
finished(name, &command_buffer);
|
||||
let after = device.counters().metrics();
|
||||
let writes = after.ring_writes - before.ring_writes;
|
||||
assert_eq!(command_buffer.error(), None, "{what}");
|
||||
assert_eq!(writes, blocks * DISPATCHES, "{what}: ring writes");
|
||||
let pushed = after.pushes - before.pushes;
|
||||
let held = after.pushes_held - before.pushes_held;
|
||||
assert_eq!(
|
||||
(pushed, held),
|
||||
(pushes, DISPATCHES - pushes),
|
||||
"{what}: pushes, held"
|
||||
);
|
||||
let inputs = buffers - 1;
|
||||
let contents = bound[inputs as usize].contents().expect("a Shared buffer");
|
||||
for gid in 0..THREADS {
|
||||
let want = (1..inputs).fold(word(0, gid), |s, k| {
|
||||
s.wrapping_mul(3).wrapping_add(word(k, gid))
|
||||
});
|
||||
// SAFETY: the word lies in the buffer, which is alive, and its work completed.
|
||||
let got = unsafe {
|
||||
contents
|
||||
.as_ptr()
|
||||
.cast::<u32>()
|
||||
.add(gid as usize)
|
||||
.read_unaligned()
|
||||
};
|
||||
assert_eq!(got, want, "{what}: thread {gid}");
|
||||
}
|
||||
println!("{what}: {writes} ring writes and {pushed} pushes over {DISPATCHES} dispatches");
|
||||
}
|
||||
}
|
||||
@@ -2102,12 +2102,14 @@ mod on_device {
|
||||
|
||||
impl ModuleAnswers {
|
||||
/// The answers of `pipeline`, whose lowering declares an imageblock as `imageblock`
|
||||
/// says; Err: what the module reads that the encoder does not supply.
|
||||
/// says, on a device whose push window is `window` bytes; Err: what the module reads
|
||||
/// that the encoder does not supply.
|
||||
fn of(
|
||||
pipeline: &metal2vulkan::pipeline::ComputePipeline,
|
||||
imageblock: Option<bool>,
|
||||
window: u32,
|
||||
) -> Result<ModuleAnswers, crate::KernelInputKind> {
|
||||
let interface = crate::pipeline::interface(pipeline, None)?;
|
||||
let interface = crate::pipeline::interface(pipeline, None, window)?;
|
||||
let mut notes = pipeline.stage.precision_notes.clone();
|
||||
notes.sort_unstable();
|
||||
notes.dedup();
|
||||
@@ -2266,7 +2268,7 @@ mod on_device {
|
||||
}
|
||||
};
|
||||
let of = |(pipeline, imageblock): &(ComputePipeline, Option<bool>)| {
|
||||
ModuleAnswers::of(pipeline, *imageblock)
|
||||
ModuleAnswers::of(pipeline, *imageblock, translator.profile().push_window())
|
||||
};
|
||||
match (of(&plain), of(&variant)) {
|
||||
(Ok(plain), Ok(variant)) => {
|
||||
|
||||
@@ -5,10 +5,10 @@ top-level `provenance` object. Generated by `scripts/regen-device-profiles/`; do
|
||||
(the lint rejects non-canonical files). The translator parses them into a `DeviceDescription`;
|
||||
validation uses them for per-profile checks.
|
||||
|
||||
`below-floor/` holds the descriptions below the translator's floor, which `Device::from_queries`
|
||||
refuses (a `maxPushConstantsSize` of 128, below the 256-byte push window): the input of the
|
||||
floor's refusal test alone, read by no other test, census or venue. The committed profiles are
|
||||
the files of this directory.
|
||||
`below-floor/` holds the Vulkan 1.2 minimum, below the runtime's floor: the input of the
|
||||
translator's push window test alone (`Device::from_queries` derives it at its `maxPushConstantsSize`
|
||||
of 128, the window's least, and refuses it at 64), read by no other test, census or venue. The
|
||||
committed profiles are the files of this directory.
|
||||
|
||||
| File | Source | Device / definition | Driver | API |
|
||||
|---|---|---|---|---|
|
||||
|
||||
@@ -1209,7 +1209,6 @@
|
||||
"VkPhysicalDeviceProperties": {
|
||||
"limits": {
|
||||
"maxSamplerAllocationCount": 4000,
|
||||
"maxPushConstantsSize": 256,
|
||||
"maxComputeWorkGroupInvocations": 1024,
|
||||
"maxComputeWorkGroupSize": [
|
||||
1024,
|
||||
|
||||
@@ -1 +1 @@
|
||||
16944f45b66eb9588332276e2a80cef383a2c941798ab911870a0cf87a89d37f
|
||||
d4a8dbf255778b56f0fc58f50a8556378c56517877849831693afc7ee8721453
|
||||
@@ -136,7 +136,7 @@ fn the_runtime_sources_are_the_committed_ones() {
|
||||
("metal2vulkan/src/lower/arith/ops.rs", "the constant and type emission (`splat`, `ty`, `elem_ty`, `ones`) every compiled pipeline's arithmetic is made through; the runtime's exact division makes its constants with it, so a change to what it emits is a translation change (SEMANTICS_VERSION) that moves the artifact digests"),
|
||||
("metal2vulkan/src/lower/emit.rs", compile),
|
||||
("metal2vulkan/src/lower/mesh/mod.rs", "compile-time translation, reached only from the compile-time part of lower/dispatch.rs (plan_kernel's mesh wrapper builtins) and as the parent of its work-buffer layout (lower/mesh/work.rs, an input); what it produces is in the pipeline the artifact digests"),
|
||||
("metal2vulkan/src/lower/push.rs", "the push window's lowering, reached only from device/derive.rs, which reads `FLOOR_BYTES`, the window's 256 bytes every stage is lowered for, to refuse a description whose maxPushConstantsSize is below it before any pipeline exists; what the lowering makes of the window is in the pipeline the artifact digests"),
|
||||
("metal2vulkan/src/lower/push.rs", "the push window's lowering, reached only from device/derive.rs, which reads `LEAST_BYTES`, Vulkan's least maxPushConstantsSize, to refuse a description below it before any pipeline exists, and from device/profile.rs, whose `push_window` reads `MOST_BYTES` to cap the device's window; what the lowering makes of the window is in the pipeline the artifact digests"),
|
||||
("metal2vulkan/src/lower/select.rs", compile),
|
||||
("metal2vulkan/src/lower/simd/divergent.rs", "compile-time translation (the predicated walk); the runtime reads only VOTE_BYTES, the vote word's size, which the compile also adds to the static threadgroup length the artifact reports, so a change to it moves the artifact digest"),
|
||||
("metal2vulkan/src/lower/simd/workgroup.rs","binding-plan construction; the artifact digests the plan it makes (the workgroup arena size)"),
|
||||
|
||||
@@ -55,9 +55,10 @@ impl Device {
|
||||
/// ([`DeviceDescription::from_khronos_json`]) or built field by field
|
||||
/// ([`DeviceDescription::new`]) makes a device with no `VkDevice` behind it.
|
||||
///
|
||||
/// Refuses a device below Vulkan 1.2 (`Unsupported{VulkanVersion}`), a device whose
|
||||
/// `maxPushConstantsSize` is below the 256 bytes of the push window every stage is lowered for
|
||||
/// (`Unsupported{PushWindow}`, a `Limit` of `MaxPushConstantsSize`), a description that lists
|
||||
/// Refuses a device below Vulkan 1.2 (`Unsupported{VulkanVersion}`), a description whose
|
||||
/// `maxPushConstantsSize` is below 128 bytes, Vulkan's least, the least push window a stage is
|
||||
/// lowered for (`Unsupported{PushWindow}`, a `Limit` of `MaxPushConstantsSize`; the window is
|
||||
/// the limit up to 256 bytes, [`DeviceProfile::push_window`]), a description that lists
|
||||
/// a feature neither its version nor its listed extensions expose or a feature without the
|
||||
/// feature Vulkan requires enabled with it (`InvalidDescriptor`, the invariants
|
||||
/// `device::enables` states), a policy that turns containment off while guest isolation
|
||||
@@ -82,12 +83,12 @@ impl Device {
|
||||
.into());
|
||||
}
|
||||
let push = desc.limits.max_push_constants_size;
|
||||
if push < crate::lower::push::FLOOR_BYTES {
|
||||
if push < crate::lower::push::LEAST_BYTES {
|
||||
return Err(Unsupported::needs(
|
||||
Feature::PushWindow,
|
||||
Capability::Limit {
|
||||
limit: VkLimit::MaxPushConstantsSize,
|
||||
required: u64::from(crate::lower::push::FLOOR_BYTES),
|
||||
required: u64::from(crate::lower::push::LEAST_BYTES),
|
||||
available: u64::from(push),
|
||||
},
|
||||
)
|
||||
|
||||
@@ -106,6 +106,16 @@ impl DeviceProfile {
|
||||
&self.fields.limits
|
||||
}
|
||||
|
||||
/// The bytes of every stage's push window on the device: its `maxPushConstantsSize`, up to
|
||||
/// 256, and at least 128, Vulkan's least, below which `Device::from_queries` refuses the
|
||||
/// description. A function pushes its fields in its window and puts those past it in a
|
||||
/// parameter block whose address the window holds (`docs/API.md` section 5); a consumer's
|
||||
/// pipeline layout holds one push range of this many bytes. The profile's fingerprint holds
|
||||
/// the limit, so devices of two windows share no artifact.
|
||||
pub fn push_window(&self) -> u32 {
|
||||
(self.fields.limits.max_push_constants_size).min(crate::lower::push::MOST_BYTES)
|
||||
}
|
||||
|
||||
/// The fragment-stage and fixed-function capabilities the profile enables.
|
||||
pub fn fragment(&self) -> &FragmentCaps {
|
||||
&self.fields.fragment
|
||||
|
||||
@@ -159,7 +159,8 @@ fn runtime_floor_is_vulkan_1_3_core_and_the_runtime_s_floor() {
|
||||
assert_eq!(d.driver_id, None);
|
||||
assert_eq!(d.limits.max_compute_shared_memory_size, 16384);
|
||||
assert_eq!(d.limits.max_compute_work_group_size, [1024, 1024, 64]);
|
||||
assert_eq!(d.limits.max_push_constants_size, 256);
|
||||
// Vulkan 1.3's least: the runtime's floor asks no push limit.
|
||||
assert_eq!(d.limits.max_push_constants_size, 128);
|
||||
assert_eq!(d.limits.min_storage_buffer_offset_alignment, 256);
|
||||
}
|
||||
|
||||
@@ -196,10 +197,8 @@ fn rgba4_opaque_black_swizzled_follows_exposure() {
|
||||
r#""a""#,
|
||||
&format!(r#""a": {{"extensions": {{"VK_KHR_maintenance10": 1}}, {props}}}"#),
|
||||
);
|
||||
let mut d = DeviceDescription::from_khronos_json(&with, None).unwrap();
|
||||
let d = DeviceDescription::from_khronos_json(&with, None).unwrap();
|
||||
assert!(d.rgba4_opaque_black_swizzled);
|
||||
// The push window the floor needs, which a Vulkan 1.2 document leaves at 128.
|
||||
d.limits.max_push_constants_size = 256;
|
||||
let dev = crate::device::Device::from_queries(d, crate::device::DevicePolicy::RESIDENT_TABLES)
|
||||
.unwrap();
|
||||
assert!(dev
|
||||
|
||||
@@ -134,43 +134,48 @@ entry:
|
||||
!5 = !{i32 2, !"air.thread_position_in_grid", !"air.arg_type_name", !"uint", !"air.arg_name", !"gid"}
|
||||
"#;
|
||||
|
||||
/// A device whose `maxPushConstantsSize` is below the 256 bytes of the push window every stage is
|
||||
/// lowered for is below the floor: `Unsupported{PushWindow}`, needing `MaxPushConstantsSize` 256.
|
||||
/// The descriptions below it are committed apart (`validation/profiles/below-floor/`, this test's
|
||||
/// input alone): `vk12-floor`, the Vulkan 1.2 minimum, with 128. Every committed profile is above
|
||||
/// it.
|
||||
/// The push window is the device's `maxPushConstantsSize` up to 256 bytes
|
||||
/// (`DeviceProfile::push_window`), and at least 128, Vulkan's least: the Vulkan 1.2 minimum
|
||||
/// (`validation/profiles/below-floor/vk12-floor`, this test's input alone) derives at its 128,
|
||||
/// with a window of 128, and the same description at 64, which no Vulkan device reports, is
|
||||
/// refused: `Unsupported{PushWindow}`, needing `MaxPushConstantsSize` 128. Every committed
|
||||
/// profile derives, its window its limit up to 256: `runtime-floor` at Vulkan 1.3's least, 128,
|
||||
/// and every profile of a device at 256 (`moltenvk-m3`'s 4,096 included).
|
||||
#[test]
|
||||
fn a_push_window_below_256_bytes_is_below_the_floor() {
|
||||
let dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
|
||||
.join("../metal2vulkan-validation/profiles/below-floor");
|
||||
let mut below: Vec<String> = std::fs::read_dir(&dir)
|
||||
.unwrap_or_else(|e| panic!("{}: {e}", dir.display()))
|
||||
.map(|e| e.expect("directory entry").path())
|
||||
.filter(|p| p.extension().is_some_and(|x| x == "json"))
|
||||
.map(|p| p.file_stem().unwrap().to_string_lossy().into_owned())
|
||||
.collect();
|
||||
below.sort();
|
||||
assert_eq!(below, ["vk12-floor"]);
|
||||
for stem in &below {
|
||||
let text = std::fs::read_to_string(dir.join(format!("{stem}.json"))).expect("readable");
|
||||
let description = DeviceDescription::from_khronos_json(&text, None).expect("parses");
|
||||
match Device::from_queries(description, DevicePolicy::RESIDENT_TABLES) {
|
||||
Err(Error::Unsupported(u)) => {
|
||||
assert_eq!(u.feature, Feature::PushWindow, "{stem}");
|
||||
let limit = Capability::Limit {
|
||||
limit: VkLimit::MaxPushConstantsSize,
|
||||
required: 256,
|
||||
available: 128,
|
||||
};
|
||||
assert_eq!(u.needs, Needs::AnyOf(vec![vec![limit]]), "{stem}");
|
||||
}
|
||||
other => panic!("{stem}: {other:?}"),
|
||||
fn the_push_window_is_the_device_s_limit_up_to_256_bytes() {
|
||||
let path = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
|
||||
.join("../metal2vulkan-validation/profiles/below-floor/vk12-floor.json");
|
||||
let text = std::fs::read_to_string(&path).unwrap_or_else(|e| panic!("{}: {e}", path.display()));
|
||||
let least = DeviceDescription::from_khronos_json(&text, None).expect("parses");
|
||||
assert_eq!(least.limits.max_push_constants_size, 128);
|
||||
let mut below = least.clone();
|
||||
below.limits.max_push_constants_size = 64;
|
||||
match Device::from_queries(least, DevicePolicy::RESIDENT_TABLES) {
|
||||
Ok(device) => assert_eq!(device.profile().push_window(), 128),
|
||||
Err(e) => panic!("vk12-floor: {e}"),
|
||||
}
|
||||
match Device::from_queries(below, DevicePolicy::RESIDENT_TABLES) {
|
||||
Err(Error::Unsupported(u)) => {
|
||||
assert_eq!(u.feature, Feature::PushWindow);
|
||||
let limit = Capability::Limit {
|
||||
limit: VkLimit::MaxPushConstantsSize,
|
||||
required: 128,
|
||||
available: 64,
|
||||
};
|
||||
assert_eq!(u.needs, Needs::AnyOf(vec![vec![limit]]));
|
||||
}
|
||||
other => panic!("{other:?}"),
|
||||
}
|
||||
for (stem, _) in committed_profiles() {
|
||||
if let Err(e) = Device::from_queries(profile(&stem), DevicePolicy::RESIDENT_TABLES) {
|
||||
panic!("{stem} is committed but below the floor: {e}");
|
||||
}
|
||||
let description = profile(&stem);
|
||||
let limit = description.limits.max_push_constants_size;
|
||||
let device = Device::from_queries(description, DevicePolicy::RESIDENT_TABLES)
|
||||
.unwrap_or_else(|e| panic!("{stem} is committed but refused: {e}"));
|
||||
let window = device.profile().push_window();
|
||||
assert_eq!(window, limit.min(256), "{stem}");
|
||||
let expected = if stem == "runtime-floor" { 128 } else { 256 };
|
||||
assert_eq!(window, expected, "{stem}: limit {limit}");
|
||||
println!("{stem}: maxPushConstantsSize {limit}, push window {window}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -739,9 +739,9 @@ pub enum Feature {
|
||||
// ---- Device ----
|
||||
/// The device's Vulkan version is below the 1.2 floor.
|
||||
VulkanVersion,
|
||||
/// The device's `maxPushConstantsSize` is below the 256 bytes of the push window every stage
|
||||
/// is lowered for: a compute stage's dispatch region and buffer addresses, a render
|
||||
/// pipeline's two stages together.
|
||||
/// The description's `maxPushConstantsSize` is below 128 bytes, Vulkan's least and the least
|
||||
/// push window a stage is lowered for: a compute stage's dispatch region and buffer addresses,
|
||||
/// a render pipeline's two stages together.
|
||||
PushWindow,
|
||||
/// The identity pointer and handle domains (`PointerDomain::Identity`,
|
||||
/// `HandleDomain::Identity`): on a device without `bufferDeviceAddress` and `shaderInt64`,
|
||||
|
||||
@@ -1037,8 +1037,8 @@ struct Census {
|
||||
identity: bool,
|
||||
/// A device-address slot reads its own address ([`slot_address_field`]).
|
||||
own_addresses: bool,
|
||||
/// The stage's push base, which decides where the fields spill.
|
||||
push_base: u32,
|
||||
/// The stage's push base and the device's window bytes, which decide where the fields spill.
|
||||
push_window: (u32, u32),
|
||||
}
|
||||
|
||||
impl Census {
|
||||
@@ -1046,7 +1046,7 @@ impl Census {
|
||||
/// pointer reads the root table.
|
||||
fn new(
|
||||
push: &BTreeSet<PushField>,
|
||||
(dynamic, identity, own_addresses, push_base): (bool, bool, bool, u32),
|
||||
(dynamic, identity, own_addresses, push_window): (bool, bool, bool, (u32, u32)),
|
||||
forms: impl Iterator<Item = (SlotRef, SlotLowering)>,
|
||||
m: &mut Meter,
|
||||
) -> Result<Census, Error> {
|
||||
@@ -1055,7 +1055,7 @@ impl Census {
|
||||
fields: push.clone(),
|
||||
identity,
|
||||
own_addresses,
|
||||
push_base,
|
||||
push_window,
|
||||
};
|
||||
if dynamic {
|
||||
c.fields.insert(PushField::RootTableAddress);
|
||||
@@ -1080,7 +1080,7 @@ impl Census {
|
||||
// Under the identity domains the spilled fields are a parameter block at a pushed
|
||||
// address, no descriptor.
|
||||
uniform_buffers: u32::from(
|
||||
!self.identity && table::spills(stage, self.push_base, &self.fields),
|
||||
!self.identity && table::spills(stage, self.push_window, &self.fields),
|
||||
),
|
||||
storage_buffers: self.storage,
|
||||
..DescriptorCounts::default()
|
||||
@@ -1274,7 +1274,7 @@ fn place_slots(cx: &mut SelectCx<'_>, m: &mut Meter) -> Result<Vec<Option<SlotCh
|
||||
cx.families.access.dynamic.used,
|
||||
identity(p),
|
||||
own_addresses,
|
||||
crate::lower::push::base(cx),
|
||||
(crate::lower::push::base(cx), p.push_window()),
|
||||
),
|
||||
forms,
|
||||
m,
|
||||
@@ -1401,11 +1401,11 @@ fn place_slots(cx: &mut SelectCx<'_>, m: &mut Meter) -> Result<Vec<Option<SlotCh
|
||||
}
|
||||
let counts = census.counts(stage);
|
||||
cx.descriptors = cx.descriptors.plus(&counts);
|
||||
cx.families.access.argument_table =
|
||||
table::spills(stage, crate::lower::push::base(cx), &cx.push);
|
||||
let window = (crate::lower::push::base(cx), p.push_window());
|
||||
cx.families.access.argument_table = table::spills(stage, window, &cx.push);
|
||||
// Under the identity domains a function whose fields spill, of any stage, reads them from a
|
||||
// parameter block whose address its window holds first: a render pipeline's stages too, in
|
||||
// their shares of the floor's one range (`push::VERTEX_FLOOR_END`).
|
||||
// their shares of the device's one range (`push::vertex_end`).
|
||||
if cx.families.access.argument_table && identity(p) {
|
||||
cx.push.insert(PushField::ArgumentTableAddress);
|
||||
}
|
||||
|
||||
@@ -36,9 +36,10 @@ pub struct Table {
|
||||
pub fields: Vec<PushField>,
|
||||
}
|
||||
|
||||
/// Whether `stage`'s placement of `fields` spills into the `ArgumentTable` (`push::spills`).
|
||||
pub fn spills(stage: Stage, base: u32, fields: &BTreeSet<PushField>) -> bool {
|
||||
push::spills(stage, base, fields)
|
||||
/// Whether `stage`'s placement of `fields` spills into the `ArgumentTable` (`push::spills`), from
|
||||
/// its push base in a device window of `bytes`.
|
||||
pub fn spills(stage: Stage, (base, bytes): (u32, u32), fields: &BTreeSet<PushField>) -> bool {
|
||||
push::spills(stage, base, bytes, fields)
|
||||
}
|
||||
|
||||
/// The binding symbol of `stage`'s `ArgumentTable`.
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
//! Push placement: the complete algorithm. Families only contribute fields.
|
||||
//!
|
||||
//! Each stage has a push window on the runtime's floor, which requires
|
||||
//! `maxPushConstantsSize ≥ 256`: a compute window is `[0, 256)` (a dispatch region and 24 buffer
|
||||
//! addresses below its tail), and a render
|
||||
//! pipeline's two stages share one range `[0, 256)`, dense by link: the vertex function's fields
|
||||
//! Each stage has a push window of the device's window bytes, `W`: its `maxPushConstantsSize` up
|
||||
//! to [`MOST_BYTES`] (`DeviceProfile::push_window`), 256 on every device that reports 256 or
|
||||
//! more, and at least [`LEAST_BYTES`]. A compute window is `[0, W)` (a dispatch region and 24
|
||||
//! buffer addresses below its tail at 256 bytes, 8 at 128), and a render
|
||||
//! pipeline's two stages share one range `[0, W)`, dense by link: the vertex function's fields
|
||||
//! from its start ([`base`]), the fragment function's from its `LoweringInputs::push_base`, the
|
||||
//! vertex function's push end, so only the fields the pair places take space (a four-byte field
|
||||
//! the fragment function places before its eight-byte ones takes the four bytes the vertex
|
||||
@@ -11,12 +12,12 @@
|
||||
//! [`TESSELLATION_BASE`], past the push range link places for the pipeline's control stage at 0,
|
||||
//! so the pair's fields never take its bytes: where they pass the range they spill, as any
|
||||
//! function's do, and the pipeline is made on every device.
|
||||
//! The vertex function's window there ends at 248, 8 bytes short of the range's end
|
||||
//! ([`VERTEX_FLOOR_END`]): a vertex function is lowered without knowing its fragment function, and
|
||||
//! The vertex function's window there ends at `W - 8`, 8 bytes short of the range's end
|
||||
//! ([`vertex_end`]): a vertex function is lowered without knowing its fragment function, and
|
||||
//! a fragment function whose fields spill must push its parameter block's address (8 bytes,
|
||||
//! 8-aligned) from the vertex function's end, so the vertex function leaves that room. The
|
||||
//! reserved 8 bytes cost only a vertex function whose own fields pass 248, which spills where it
|
||||
//! would have filled them. `select` places the function's own [`PushField`]s in the fixed kind
|
||||
//! reserved 8 bytes cost only a vertex function whose own fields pass `W - 8`, which spills where
|
||||
//! it would have filled them. `select` places the function's own [`PushField`]s in the fixed kind
|
||||
//! order (the derived `Ord` of [`PushField`]; within a kind, by slot). Fields fill the
|
||||
//! stage window in that order, each at the next offset aligned to the field; from the first field
|
||||
//! that does not fit, every field goes to the stage's `ArgumentTable` uniform buffer
|
||||
@@ -50,22 +51,32 @@ use crate::lower::select::SelectCx;
|
||||
use crate::pipeline::interface::{PlacedField, PushLoc, PushPlacement};
|
||||
use crate::pipeline::sym::{PushField, Stage};
|
||||
|
||||
/// The byte range `[start, end)` of `stage`'s push window; `base` is a fragment function's
|
||||
/// `LoweringInputs::push_base`, or a vertex function's start ([`base`]).
|
||||
pub const fn window(stage: Stage, base: u32) -> (u32, u32) {
|
||||
/// The byte range `[start, end)` of `stage`'s push window on a device of window `bytes`
|
||||
/// (`DeviceProfile::push_window`); `base` is a fragment function's `LoweringInputs::push_base`,
|
||||
/// or a vertex function's start ([`base`]).
|
||||
pub const fn window(stage: Stage, base: u32, bytes: u32) -> (u32, u32) {
|
||||
match stage {
|
||||
Stage::Vertex => (base, VERTEX_FLOOR_END),
|
||||
Stage::Fragment => (base, FLOOR_BYTES),
|
||||
Stage::Kernel => (0, FLOOR_BYTES),
|
||||
Stage::Vertex => (base, vertex_end(bytes)),
|
||||
Stage::Fragment => (base, bytes),
|
||||
Stage::Kernel => (0, bytes),
|
||||
// A mesh render pipeline's object, mesh and fragment functions share the 128 bytes: the
|
||||
// fragment function keeps its window, and the vertex function's is split.
|
||||
Stage::Object => (0, 32),
|
||||
Stage::Mesh => (32, 64),
|
||||
Stage::Mesh => (32, MESH_END),
|
||||
}
|
||||
}
|
||||
|
||||
/// The push bytes of the runtime's floor: its `maxPushConstantsSize`.
|
||||
pub const FLOOR_BYTES: u32 = 256;
|
||||
/// The end of a mesh function's window, where a mesh render pipeline's fragment function's
|
||||
/// fields start.
|
||||
pub const MESH_END: u32 = 64;
|
||||
|
||||
/// The most bytes of a device's push window: a device's window is its `maxPushConstantsSize` up
|
||||
/// to these (`DeviceProfile::push_window`).
|
||||
pub const MOST_BYTES: u32 = 256;
|
||||
|
||||
/// The least bytes of a device's push window: Vulkan's least `maxPushConstantsSize`, below which
|
||||
/// `Device::from_queries` refuses a description.
|
||||
pub const LEAST_BYTES: u32 = 128;
|
||||
|
||||
/// Where a post-tessellation vertex function's window starts: past the most bytes the pipeline's
|
||||
/// control stage pushes in either form (`control::PUSH_BYTES`), whose range link places at 0
|
||||
@@ -95,11 +106,13 @@ pub fn fragment_base(vertex: &PushPlacement, tessellated: bool) -> u32 {
|
||||
(vertex.push_range).map_or(start, |(offset, size)| offset + size)
|
||||
}
|
||||
|
||||
/// The end of a vertex function's window on the floor: the floor's end less one address, so the
|
||||
/// fragment function's window, from the vertex function's end, always holds its parameter block's
|
||||
/// address (`PushField::ArgumentTableAddress`, which the order places first, at the next multiple
|
||||
/// of 8).
|
||||
pub const VERTEX_FLOOR_END: u32 = FLOOR_BYTES - 8;
|
||||
/// The end of a vertex function's window on a device of window `bytes`: the window's end less one
|
||||
/// address, so the fragment function's window, from the vertex function's end, always holds its
|
||||
/// parameter block's address (`PushField::ArgumentTableAddress`, which the order places first, at
|
||||
/// the next multiple of 8).
|
||||
pub const fn vertex_end(bytes: u32) -> u32 {
|
||||
bytes - 8
|
||||
}
|
||||
|
||||
/// The bytes between the end of a floor stage's other pushed fields and its tail ([`tail`]). A
|
||||
/// driver widens a push load past its last byte by at most 28 bytes, so a load from those fields
|
||||
@@ -231,10 +244,10 @@ fn align_up(v: u32, a: u32) -> u32 {
|
||||
v.div_ceil(a).saturating_mul(a)
|
||||
}
|
||||
|
||||
/// Place `fields` for `stage` in its push window, from a fragment function's `base` there
|
||||
/// ([`window`]), with its tail ([`tail`]).
|
||||
pub fn place(stage: Stage, base: u32, fields: &BTreeSet<PushField>) -> PushPlacement {
|
||||
let (start, end) = window(stage, base);
|
||||
/// Place `fields` for `stage` in its push window of a device of window `bytes`, from a fragment
|
||||
/// function's `base` there ([`window`]), with its tail ([`tail`]).
|
||||
pub fn place(stage: Stage, base: u32, bytes: u32, fields: &BTreeSet<PushField>) -> PushPlacement {
|
||||
let (start, end) = window(stage, base, bytes);
|
||||
let (pushed, offsets, word, push_end) = floor(start, end, fields);
|
||||
let mut table = 0u32;
|
||||
let mut placed = Vec::with_capacity(fields.len());
|
||||
@@ -352,8 +365,8 @@ fn tail_layout(start: u32, end: u32, pushed: &[PushField]) -> Option<(Vec<u32>,
|
||||
/// gives it a size. That is the first field with a size that does not fit, so the fields are read
|
||||
/// only up to it, at most the window's worth plus one, however many there are; a step that asks
|
||||
/// once per slot it moves (`access::finish_slots`) then costs no walk of every slot's field.
|
||||
pub fn spills(stage: Stage, base: u32, fields: &BTreeSet<PushField>) -> bool {
|
||||
let (start, end) = window(stage, base);
|
||||
pub fn spills(stage: Stage, base: u32, bytes: u32, fields: &BTreeSet<PushField>) -> bool {
|
||||
let (start, end) = window(stage, base, bytes);
|
||||
let pushed = floor(start, end, fields).0;
|
||||
// Every shape has a size, so any field past the pushed ones gives the table one.
|
||||
pushed < fields.len()
|
||||
@@ -387,9 +400,9 @@ pub fn tail(placement: &PushPlacement) -> Option<PushField> {
|
||||
|
||||
/// The floor's bound on `placement`, a stage's: a stage that pushes more than one field, or one
|
||||
/// of more than two words, ends with its tail ([`tail`]), a field of a tail kind or the tail word,
|
||||
/// of one or two words; its push range ends with its highest pushed byte, by the floor's end.
|
||||
/// `Err` names the placement that passes it.
|
||||
pub fn check_floor(placement: &PushPlacement) -> Result<(), String> {
|
||||
/// of one or two words; its push range ends with its highest pushed byte, by the end of a device
|
||||
/// window of `bytes`. `Err` names the placement that passes it.
|
||||
pub fn check_floor(placement: &PushPlacement, bytes: u32) -> Result<(), String> {
|
||||
let pushed: Vec<(PushField, u32, u32)> = (placement.fields.iter())
|
||||
.filter_map(|f| match f.loc {
|
||||
PushLoc::Push { offset } => Some((f.field, offset, f.size)),
|
||||
@@ -407,9 +420,8 @@ pub fn check_floor(placement: &PushPlacement) -> Result<(), String> {
|
||||
let tailed = tail(placement)
|
||||
.is_some_and(|t| (tail_kind(t) || t == PushField::TailWord) && shape(t).size() <= 8);
|
||||
let range = placement.push_range.map(|(offset, size)| offset + size);
|
||||
let ok = (pushed.is_empty() || single || tailed)
|
||||
&& range == top
|
||||
&& top.is_none_or(|t| t <= FLOOR_BYTES);
|
||||
let ok =
|
||||
(pushed.is_empty() || single || tailed) && range == top && top.is_none_or(|t| t <= bytes);
|
||||
match ok {
|
||||
true => Ok(()),
|
||||
false => Err(format!(
|
||||
@@ -482,20 +494,33 @@ mod tests {
|
||||
/// inside the window without overlap, the prefix property (nothing is pushed after the first
|
||||
/// spill), and a push range and table size that cover their fields. On the floor the tail
|
||||
/// ([`tail`]) lies above every other pushed field and the floor's bound holds
|
||||
/// ([`check_floor`]); the guaranteed window has no tail.
|
||||
/// ([`check_floor`]); the guaranteed window has no tail. In a window of [`MOST_BYTES`].
|
||||
fn check(stage: Stage, fields: &BTreeSet<PushField>) -> PushPlacement {
|
||||
check_at(stage, 0, fields)
|
||||
check_in(stage, 0, MOST_BYTES, fields)
|
||||
}
|
||||
|
||||
/// [`check`] from a fragment function's push `base`.
|
||||
fn check_at(stage: Stage, base: u32, fields: &BTreeSet<PushField>) -> PushPlacement {
|
||||
let p = place(stage, base, fields);
|
||||
assert_eq!(spills(stage, base, fields), p.argument_table_size > 0);
|
||||
let (start, end) = window(stage, base);
|
||||
check_in(stage, base, MOST_BYTES, fields)
|
||||
}
|
||||
|
||||
/// [`check_at`] in a device window of `bytes`.
|
||||
fn check_in(
|
||||
stage: Stage,
|
||||
base: u32,
|
||||
bytes: u32,
|
||||
fields: &BTreeSet<PushField>,
|
||||
) -> PushPlacement {
|
||||
let p = place(stage, base, bytes, fields);
|
||||
assert_eq!(
|
||||
spills(stage, base, bytes, fields),
|
||||
p.argument_table_size > 0
|
||||
);
|
||||
let (start, end) = window(stage, base, bytes);
|
||||
assert_eq!(p.stage, stage);
|
||||
let order: Vec<PushField> = p.fields.iter().map(|f| f.field).collect();
|
||||
assert_eq!(order, fields.iter().copied().collect::<Vec<_>>());
|
||||
assert_eq!(check_floor(&p), Ok(()));
|
||||
assert_eq!(check_floor(&p, bytes), Ok(()));
|
||||
let top = tail(&p);
|
||||
let (mut push_end, mut table_end, mut spilled) = (start, 0u32, false);
|
||||
let mut tail_end = p.tail_word.map(|at| (at, at + 4));
|
||||
@@ -549,13 +574,14 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
/// A kernel's dispatch region and its buffers' addresses: 12 addresses fill the guaranteed
|
||||
/// window. On the floor the addresses hold no tail kind, so the tail word ends the push, 24
|
||||
/// bytes above them: 24 addresses end at 224 and the word at 252, and a 25th spills; with a
|
||||
/// spill, the table's address and the region's alignment take the first 16 bytes, and 22
|
||||
/// addresses stay in the window. The render windows are the same on both.
|
||||
/// A kernel's dispatch region and its buffers' addresses. The addresses hold no tail kind, so
|
||||
/// the tail word ends the push, 24 bytes above them. In a window of 256 bytes 24 addresses end
|
||||
/// at 224 and the word at 248, and a 25th spills; with a spill, the table's address and the
|
||||
/// region's alignment take the first 16 bytes, and 22 addresses stay in the window. In a window
|
||||
/// of 128 bytes, 8 addresses end at 96 and the word at 120, a 9th spills, and with a spill 6
|
||||
/// stay.
|
||||
#[test]
|
||||
fn the_floor_window_holds_a_region_and_twenty_four_addresses_below_its_tail() {
|
||||
fn the_window_holds_a_region_and_24_or_8_addresses_below_its_tail() {
|
||||
let fields = |n: u32| -> BTreeSet<PushField> {
|
||||
let mut f: BTreeSet<PushField> = (0..n)
|
||||
.map(|i| PushField::SlotGuestBase(slot(Stage::Kernel, i)))
|
||||
@@ -569,26 +595,32 @@ mod tests {
|
||||
.filter(|f| matches!(f.loc, PushLoc::Push { .. }))
|
||||
.count()
|
||||
};
|
||||
let floor = check(Stage::Kernel, &fields(24));
|
||||
assert_eq!(
|
||||
(floor.push_range, floor.argument_table_size),
|
||||
(Some((0, 252)), 0)
|
||||
);
|
||||
assert_eq!(pushed(&floor), 25, "the region and 24 addresses");
|
||||
assert_eq!(
|
||||
(tail(&floor), floor.tail_word),
|
||||
(Some(PushField::TailWord), Some(248))
|
||||
);
|
||||
assert!(spills(Stage::Kernel, 0, &fields(25)));
|
||||
let mut spilled = fields(25);
|
||||
spilled.insert(PushField::ArgumentTableAddress);
|
||||
let p = check(Stage::Kernel, &spilled);
|
||||
assert_eq!((p.push_range, p.argument_table_size), (Some((0, 252)), 32));
|
||||
assert_eq!(
|
||||
(pushed(&p), p.tail_word),
|
||||
(24, Some(248)),
|
||||
"the address, the region and 22 buffer addresses"
|
||||
);
|
||||
for (bytes, most, kept) in [(MOST_BYTES, 24, 22), (LEAST_BYTES, 8, 6)] {
|
||||
let floor = check_in(Stage::Kernel, 0, bytes, &fields(most));
|
||||
assert_eq!(
|
||||
(floor.push_range, floor.argument_table_size),
|
||||
(Some((0, bytes - 4)), 0),
|
||||
"{bytes}"
|
||||
);
|
||||
assert_eq!(pushed(&floor), most as usize + 1, "the region and {most}");
|
||||
assert_eq!(
|
||||
(tail(&floor), floor.tail_word),
|
||||
(Some(PushField::TailWord), Some(bytes - 8))
|
||||
);
|
||||
assert!(spills(Stage::Kernel, 0, bytes, &fields(most + 1)));
|
||||
let mut spilled = fields(most + 1);
|
||||
spilled.insert(PushField::ArgumentTableAddress);
|
||||
let p = check_in(Stage::Kernel, 0, bytes, &spilled);
|
||||
assert_eq!(
|
||||
(p.push_range, p.argument_table_size),
|
||||
(Some((0, bytes - 4)), 32)
|
||||
);
|
||||
assert_eq!(
|
||||
(pushed(&p), p.tail_word),
|
||||
(kept as usize + 2, Some(bytes - 8)),
|
||||
"the address, the region and {kept} buffer addresses"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// The floor's tail: a kernel's highest field of a tail kind moves 24 bytes above its other
|
||||
@@ -647,8 +679,8 @@ mod tests {
|
||||
|
||||
/// The floor's bound, which `select` checks on every placement: a stage that pushes more than
|
||||
/// one short field without a tail 24 bytes above the others, a long field on top, a range that
|
||||
/// does not end with the highest pushed byte or passes 256, and the tail word off the floor are
|
||||
/// refused.
|
||||
/// does not end with the highest pushed byte or passes the window, and the tail word off the
|
||||
/// floor are refused.
|
||||
#[test]
|
||||
fn the_floor_refuses_a_placement_without_its_tail() {
|
||||
let a = slot(Stage::Kernel, 0);
|
||||
@@ -658,12 +690,12 @@ mod tests {
|
||||
PushField::SlotBounds(a),
|
||||
]
|
||||
.into();
|
||||
let p = place(Stage::Kernel, 0, &fields);
|
||||
assert_eq!(check_floor(&p), Ok(()));
|
||||
let p = place(Stage::Kernel, 0, MOST_BYTES, &fields);
|
||||
assert_eq!(check_floor(&p, MOST_BYTES), Ok(()));
|
||||
let mut short = p.clone();
|
||||
short.push_range = Some((0, 80));
|
||||
assert!(
|
||||
check_floor(&short).is_err(),
|
||||
check_floor(&short, MOST_BYTES).is_err(),
|
||||
"a range that does not end with the tail"
|
||||
);
|
||||
let mut moved = p.clone();
|
||||
@@ -673,31 +705,56 @@ mod tests {
|
||||
}
|
||||
}
|
||||
moved.push_range = Some((0, 64));
|
||||
assert!(check_floor(&moved).is_err(), "a hole of 16");
|
||||
let region = place(Stage::Kernel, 0, &[PushField::DispatchRegion].into());
|
||||
assert_eq!(check_floor(®ion), Ok(()));
|
||||
assert!(check_floor(&moved, MOST_BYTES).is_err(), "a hole of 16");
|
||||
let region = place(
|
||||
Stage::Kernel,
|
||||
0,
|
||||
MOST_BYTES,
|
||||
&[PushField::DispatchRegion].into(),
|
||||
);
|
||||
assert_eq!(check_floor(®ion, MOST_BYTES), Ok(()));
|
||||
let mut bare = region.clone();
|
||||
bare.tail_word = None;
|
||||
bare.push_range = Some((0, 32));
|
||||
assert!(check_floor(&bare).is_err(), "a long field alone");
|
||||
assert!(
|
||||
check_floor(&bare, MOST_BYTES).is_err(),
|
||||
"a long field alone"
|
||||
);
|
||||
let mut past = region;
|
||||
past.push_range = Some((0, 260));
|
||||
assert!(check_floor(&past).is_err());
|
||||
assert!(check_floor(&past, MOST_BYTES).is_err());
|
||||
// A placement of a 256-byte window that passes 128 bytes is past a 128-byte window.
|
||||
let wide = place(Stage::Kernel, 0, MOST_BYTES, &fields_of(20));
|
||||
assert_eq!(check_floor(&wide, MOST_BYTES), Ok(()));
|
||||
assert!(check_floor(&wide, LEAST_BYTES).is_err());
|
||||
}
|
||||
|
||||
/// The windows a pipeline of each kind pushes, pinned: a compute kernel's `[0, 256)`, and a
|
||||
/// render pipeline's one range `[0, 256)`, the vertex function's from its start (0, or 24 for
|
||||
/// a post-tessellation function) and the fragment function's from its base. A compute
|
||||
/// kernel's window does not move with a render base.
|
||||
/// A kernel's region and `n` buffer addresses.
|
||||
fn fields_of(n: u32) -> BTreeSet<PushField> {
|
||||
(0..n)
|
||||
.map(|i| PushField::SlotGuestBase(slot(Stage::Kernel, i)))
|
||||
.chain([PushField::DispatchRegion])
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// The windows a pipeline of each kind pushes on a device of window `W`, 256 or 128 bytes,
|
||||
/// pinned: a compute kernel's `[0, W)`, and a render pipeline's one range `[0, W)`, the vertex
|
||||
/// function's from its start (0, or 24 for a post-tessellation function) to `W - 8` and the
|
||||
/// fragment function's from its base. A compute kernel's window does not move with a render
|
||||
/// base, and a mesh pipeline's windows do not move with `W`.
|
||||
#[test]
|
||||
fn each_kind_pushes_its_own_window() {
|
||||
for base in [0, 8, 40, 248] {
|
||||
assert_eq!(window(Stage::Kernel, base), (0, 256));
|
||||
assert_eq!(window(Stage::Fragment, base), (base, 256));
|
||||
}
|
||||
assert_eq!(TESSELLATION_BASE, 24);
|
||||
for base in [0, TESSELLATION_BASE] {
|
||||
assert_eq!(window(Stage::Vertex, base), (base, 248));
|
||||
for (bytes, vertex) in [(256, 248), (128, 120)] {
|
||||
for base in [0, 8, 40, vertex] {
|
||||
assert_eq!(window(Stage::Kernel, base, bytes), (0, bytes));
|
||||
assert_eq!(window(Stage::Fragment, base, bytes), (base, bytes));
|
||||
}
|
||||
for base in [0, TESSELLATION_BASE] {
|
||||
assert_eq!(window(Stage::Vertex, base, bytes), (base, vertex));
|
||||
}
|
||||
assert_eq!(window(Stage::Object, 0, bytes), (0, 32));
|
||||
assert_eq!(window(Stage::Mesh, 0, bytes), (32, MESH_END));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -724,22 +781,28 @@ mod tests {
|
||||
}
|
||||
}
|
||||
}
|
||||
let empty = place(Stage::Vertex, TESSELLATION_BASE, &BTreeSet::new());
|
||||
let empty = place(
|
||||
Stage::Vertex,
|
||||
TESSELLATION_BASE,
|
||||
LEAST_BYTES,
|
||||
&BTreeSet::new(),
|
||||
);
|
||||
assert_eq!(empty.push_range, None);
|
||||
assert_eq!(fragment_base(&empty, true), TESSELLATION_BASE);
|
||||
assert_eq!(fragment_base(&empty, false), 0);
|
||||
let one = BTreeSet::from([PushField::ArgumentTableAddress]);
|
||||
let pushed = place(Stage::Vertex, TESSELLATION_BASE, &one);
|
||||
let pushed = place(Stage::Vertex, TESSELLATION_BASE, LEAST_BYTES, &one);
|
||||
assert_eq!(pushed.push_range, Some((TESSELLATION_BASE, 8)));
|
||||
assert_eq!(fragment_base(&pushed, true), TESSELLATION_BASE + 8);
|
||||
}
|
||||
|
||||
/// On the floor a render pipeline's fields are dense by link: a fragment function placed from
|
||||
/// the vertex function's push end starts there, its fields fill the rest of the 256 bytes
|
||||
/// the vertex function's push end starts there, its fields fill the rest of the window `W`
|
||||
/// below its own tail, and from the first that does not fit it spills. Each stage has its own
|
||||
/// tail: here the addresses hold no tail kind, so each ends with the tail word. A vertex
|
||||
/// function's window ends at 248, so a fragment function from its end can always push its
|
||||
/// block's address.
|
||||
/// function's window ends at `W - 8`, so a fragment function from its end can always push its
|
||||
/// block's address. From 24, a fragment function pushes 25 addresses at 256 bytes and 9 at
|
||||
/// 128; a vertex function 27 and 11.
|
||||
#[test]
|
||||
fn the_floor_places_a_fragment_function_from_its_base() {
|
||||
let vertex: BTreeSet<PushField> = (0..3)
|
||||
@@ -758,35 +821,79 @@ mod tests {
|
||||
Some((52, 48)),
|
||||
"two addresses from 56, the word at 96"
|
||||
);
|
||||
let full = check_at(Stage::Fragment, 24, &fragment(25));
|
||||
assert_eq!(full.push_range, Some((24, 228)), "to the word at 248");
|
||||
assert_eq!(full.argument_table_size, 0);
|
||||
assert!(spills(Stage::Fragment, 24, &fragment(26)));
|
||||
// A vertex function's window ends at 248: 27 addresses end at 216 below the word at 240,
|
||||
// and a 28th spills.
|
||||
let wide = |n: u32| -> BTreeSet<PushField> {
|
||||
(0..n)
|
||||
.map(|i| PushField::SlotGuestBase(slot(Stage::Vertex, i)))
|
||||
.collect()
|
||||
};
|
||||
let v = check_at(Stage::Vertex, 0, &wide(27));
|
||||
assert_eq!((v.push_range, v.argument_table_size), (Some((0, 244)), 0));
|
||||
assert!(spills(Stage::Vertex, 0, &wide(28)));
|
||||
// The fragment function from the fullest vertex function's end, 244, pushes its block's
|
||||
// address, 8-aligned, at 248, alone, and spills the rest; from 248 the same.
|
||||
let mut spilled = fragment(2);
|
||||
spilled.insert(PushField::ArgumentTableAddress);
|
||||
for (base, range) in [(248, (248, 8)), (244, (244, 12))] {
|
||||
let f = check_at(Stage::Fragment, base, &spilled);
|
||||
assert_eq!((f.push_range, f.argument_table_size), (Some(range), 16));
|
||||
for (bytes, most, widest) in [(MOST_BYTES, 25, 27), (LEAST_BYTES, 9, 11)] {
|
||||
// From 24, `most` addresses end below the word at `bytes - 8`, and one more spills.
|
||||
let full = check_in(Stage::Fragment, 24, bytes, &fragment(most));
|
||||
assert_eq!(full.push_range, Some((24, 8 * most + 28)), "{bytes}");
|
||||
assert_eq!(full.tail_word, Some(bytes - 8));
|
||||
assert_eq!(full.argument_table_size, 0);
|
||||
assert!(spills(Stage::Fragment, 24, bytes, &fragment(most + 1)));
|
||||
// A vertex function's window ends at `bytes - 8`: `widest` addresses end below the
|
||||
// word at `bytes - 16`, and one more spills.
|
||||
let v = check_in(Stage::Vertex, 0, bytes, &wide(widest));
|
||||
assert_eq!(
|
||||
(f.fields[0].field, f.fields[0].loc),
|
||||
(
|
||||
PushField::ArgumentTableAddress,
|
||||
PushLoc::Push { offset: 248 }
|
||||
),
|
||||
"from {base}"
|
||||
(v.push_range, v.argument_table_size),
|
||||
(Some((0, 8 * widest + 28)), 0)
|
||||
);
|
||||
assert_eq!(v.tail_word, Some(bytes - 16));
|
||||
assert!(spills(Stage::Vertex, 0, bytes, &wide(widest + 1)));
|
||||
// The fragment function from the fullest vertex function's end, `bytes - 12`, pushes
|
||||
// its block's address, 8-aligned, at `bytes - 8`, alone, and spills the rest; from
|
||||
// `bytes - 8` the same.
|
||||
let mut spilled = fragment(2);
|
||||
spilled.insert(PushField::ArgumentTableAddress);
|
||||
let (last, fullest) = (bytes - 8, bytes - 12);
|
||||
for (base, range) in [(last, (last, 8)), (fullest, (fullest, 12))] {
|
||||
let f = check_in(Stage::Fragment, base, bytes, &spilled);
|
||||
assert_eq!((f.push_range, f.argument_table_size), (Some(range), 16));
|
||||
assert_eq!(
|
||||
(f.fields[0].field, f.fields[0].loc),
|
||||
(
|
||||
PushField::ArgumentTableAddress,
|
||||
PushLoc::Push { offset: last }
|
||||
),
|
||||
"from {base} in {bytes}"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The slot words an indirect command buffer's command reaches: a vertex function of an
|
||||
/// indirect draw pushes the execution range's address, its sequence word and its part's first
|
||||
/// command (16 bytes), then its buffer slots' addresses, below the tail word. Its window ends at
|
||||
/// `W - 8`, so it pushes 25 slot addresses at 256 bytes and 9 at 128, and where its fields
|
||||
/// spill (its block's address first) 24 and 8. An execution refuses a command whose slot's
|
||||
/// address is in the block (`IndirectCommandsKind::DrawInput`, in the runtime).
|
||||
#[test]
|
||||
fn an_indirect_draw_s_vertex_function_pushes_25_or_9_slot_words() {
|
||||
let indirect = |n: u32, spilled: bool| -> BTreeSet<PushField> {
|
||||
(0..n)
|
||||
.map(|i| PushField::SlotGuestBase(slot(Stage::Vertex, i)))
|
||||
.chain([
|
||||
PushField::IndirectRange,
|
||||
PushField::IndirectSequence,
|
||||
PushField::IndirectBase,
|
||||
])
|
||||
.chain(spilled.then_some(PushField::ArgumentTableAddress))
|
||||
.collect()
|
||||
};
|
||||
let slots = |p: &PushPlacement| {
|
||||
(p.fields.iter())
|
||||
.filter(|f| matches!(f.field, PushField::SlotGuestBase(_)))
|
||||
.filter(|f| matches!(f.loc, PushLoc::Push { .. }))
|
||||
.count() as u32
|
||||
};
|
||||
for (bytes, most, spilling) in [(MOST_BYTES, 25, 24), (LEAST_BYTES, 9, 8)] {
|
||||
let p = check_in(Stage::Vertex, 0, bytes, &indirect(most, false));
|
||||
assert_eq!((slots(&p), p.argument_table_size), (most, 0), "{bytes}");
|
||||
assert!(spills(Stage::Vertex, 0, bytes, &indirect(most + 1, false)));
|
||||
let p = check_in(Stage::Vertex, 0, bytes, &indirect(31, true));
|
||||
assert_eq!(slots(&p), spilling, "{bytes}, spilled");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -819,7 +926,9 @@ mod tests {
|
||||
let pick = ((state >> (i % 50)) % kinds.len() as u64) as usize;
|
||||
fields.insert(kinds[pick]);
|
||||
}
|
||||
check(stage, &fields);
|
||||
for bytes in [MOST_BYTES, LEAST_BYTES] {
|
||||
check_in(stage, 0, bytes, &fields);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -867,7 +976,7 @@ mod tests {
|
||||
later.insert(PushField::SlotGuestBase(slot(i)));
|
||||
later.insert(PushField::VertexBufferStride(i));
|
||||
}
|
||||
let (start, end) = window(stage, 0);
|
||||
let (start, end) = window(stage, 0, LEAST_BYTES);
|
||||
let firsts = [
|
||||
None,
|
||||
Some(PushField::RootTableAddress),
|
||||
@@ -879,7 +988,7 @@ mod tests {
|
||||
let mut fields = rest;
|
||||
fields.insert(PushField::ExecutionStatusAddress);
|
||||
fields.extend(first);
|
||||
let placement = place(stage, 0, &fields);
|
||||
let placement = place(stage, 0, LEAST_BYTES, &fields);
|
||||
let status = placement
|
||||
.fields
|
||||
.iter()
|
||||
@@ -916,7 +1025,7 @@ mod tests {
|
||||
later.insert(PushField::SlotGuestBase(slot(Stage::Vertex, i)));
|
||||
later.insert(PushField::VertexBufferStride(i));
|
||||
}
|
||||
let (start, end) = window(Stage::Vertex, 0);
|
||||
let (start, end) = window(Stage::Vertex, 0, LEAST_BYTES);
|
||||
for (root, status) in [(false, false), (true, false), (false, true), (true, true)] {
|
||||
let mut fields = later.clone();
|
||||
fields.insert(PushField::CaptureIndexAddress);
|
||||
@@ -926,7 +1035,7 @@ mod tests {
|
||||
if status {
|
||||
fields.insert(PushField::ExecutionStatusAddress);
|
||||
}
|
||||
let placement = check(Stage::Vertex, &fields);
|
||||
let placement = check_in(Stage::Vertex, 0, LEAST_BYTES, &fields);
|
||||
let at = start + 8 * (u32::from(root) + u32::from(status));
|
||||
let index = placement
|
||||
.fields
|
||||
|
||||
@@ -1676,11 +1676,11 @@ fn finish(
|
||||
}
|
||||
|
||||
stage_io::finish_merged(&mut cx)?;
|
||||
let placement = push::place(stage, push::base(&cx), &cx.push);
|
||||
let placement = push::place(stage, push::base(&cx), p.push_window(), &cx.push);
|
||||
access::accept_placement(&cx, &placement)?;
|
||||
// On the floor every stage that pushes more than one short field ends with its tail, a hole
|
||||
// above the others, so every load a driver widens from them stays inside its upload.
|
||||
push::check_floor(&placement)
|
||||
push::check_floor(&placement, p.push_window())
|
||||
.map_err(|detail| Error::Internal(InternalError::new(InternalKind::Invariant, detail)))?;
|
||||
|
||||
// A kernel compiled for dispatches with a partial simdgroup emulates its simdgroups whatever
|
||||
|
||||
@@ -191,7 +191,7 @@ impl<'a> From<&'a MeshPipelineDescriptor> for FragmentPass<'a> {
|
||||
sample_mask: None,
|
||||
alpha_test: None,
|
||||
depth_compare_clamp_mask: 0,
|
||||
push_base: crate::lower::push::window(crate::pipeline::sym::Stage::Mesh, 0).1,
|
||||
push_base: crate::lower::push::MESH_END,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,7 +167,8 @@ fn a_fragment_primitive_id_is_refused() {
|
||||
}
|
||||
|
||||
/// The control stage's push range takes the first 4-aligned gap of its size no stage's range
|
||||
/// covers, within `maxPushConstantsSize`.
|
||||
/// covers, within `maxPushConstantsSize`: on a device of 256 bytes (`lavapipe`) and on one of 128
|
||||
/// (`runtime-floor`), Vulkan's least.
|
||||
#[test]
|
||||
fn the_control_push_range_takes_the_first_free_gap() {
|
||||
let range = |offset, size| PushConstantRange {
|
||||
@@ -175,34 +176,38 @@ fn the_control_push_range_takes_the_first_free_gap() {
|
||||
offset,
|
||||
size,
|
||||
};
|
||||
let p = profile("runtime-floor");
|
||||
let control_offset = |ranges: &[PushConstantRange]| {
|
||||
push_offset(ranges, (control::PUSH_BYTES, 4), Feature::Tessellation, &p)
|
||||
};
|
||||
assert_eq!(control_offset(&[]).expect("empty"), 0);
|
||||
assert_eq!(control_offset(&[range(0, 16)]).expect("after"), 16);
|
||||
assert_eq!(
|
||||
control_offset(&[range(0, 56), range(64, 8)]).expect("after fragment"),
|
||||
72
|
||||
);
|
||||
assert_eq!(
|
||||
control_offset(&[range(0, 40), range(64, 8)]).expect("gap"),
|
||||
40
|
||||
);
|
||||
assert_eq!(
|
||||
control_offset(&[range(0, 48), range(64, 8)]).expect("too small a gap"),
|
||||
72
|
||||
);
|
||||
// 256 bytes: a vertex window of 64 and a fragment range to 248 leave no 24-byte gap.
|
||||
match control_offset(&[range(0, 64), range(64, 184)]) {
|
||||
Err(Error::Unsupported(u)) => assert_eq!(
|
||||
u.needs,
|
||||
Needs::AnyOf(vec![vec![Capability::Limit {
|
||||
limit: VkLimit::MaxPushConstantsSize,
|
||||
required: 272,
|
||||
available: 256,
|
||||
}]])
|
||||
),
|
||||
other => panic!("{other:?}"),
|
||||
for (stem, bytes) in [("lavapipe", 256), ("runtime-floor", 128)] {
|
||||
let p = profile(stem);
|
||||
assert_eq!(p.limits().max_push_constants_size, bytes, "{stem}");
|
||||
let control_offset = |ranges: &[PushConstantRange]| {
|
||||
push_offset(ranges, (control::PUSH_BYTES, 4), Feature::Tessellation, &p)
|
||||
};
|
||||
assert_eq!(control_offset(&[]).expect("empty"), 0);
|
||||
assert_eq!(control_offset(&[range(0, 16)]).expect("after"), 16);
|
||||
assert_eq!(
|
||||
control_offset(&[range(0, 56), range(64, 8)]).expect("after fragment"),
|
||||
72
|
||||
);
|
||||
assert_eq!(
|
||||
control_offset(&[range(0, 40), range(64, 8)]).expect("gap"),
|
||||
40
|
||||
);
|
||||
assert_eq!(
|
||||
control_offset(&[range(0, 48), range(64, 8)]).expect("too small a gap"),
|
||||
72
|
||||
);
|
||||
// A vertex window of 64 and a fragment range to `bytes - 8` leave no 24-byte gap.
|
||||
match control_offset(&[range(0, 64), range(64, bytes - 72)]) {
|
||||
Err(Error::Unsupported(u)) => assert_eq!(
|
||||
u.needs,
|
||||
Needs::AnyOf(vec![vec![Capability::Limit {
|
||||
limit: VkLimit::MaxPushConstantsSize,
|
||||
required: u64::from(bytes) + 16,
|
||||
available: u64::from(bytes),
|
||||
}]]),
|
||||
"{stem}"
|
||||
),
|
||||
other => panic!("{stem}: {other:?}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ use crate::device::derive::vk_stage;
|
||||
use crate::device::subgroup::SubgroupRequirement;
|
||||
use crate::device::DevicePolicy;
|
||||
use crate::library::FunctionCompileKey;
|
||||
use crate::lower::push::MOST_BYTES as MOST;
|
||||
use crate::pipeline::artifact::{Reconvergence, StrategyCensus};
|
||||
use crate::pipeline::interface::{StageDescriptor, StageSpec};
|
||||
use crate::pipeline::stage_io::{
|
||||
@@ -131,7 +132,7 @@ pub(super) fn iface(
|
||||
stage,
|
||||
slots: BTreeMap::new(),
|
||||
threadgroup: Vec::new(),
|
||||
push: crate::lower::push::place(stage, 0, &BTreeSet::new()),
|
||||
push: crate::lower::push::place(stage, 0, MOST, &BTreeSet::new()),
|
||||
descriptors,
|
||||
spec,
|
||||
needs_pointer_translation: false,
|
||||
@@ -606,12 +607,14 @@ fn push_ranges_are_the_stage_windows() {
|
||||
})
|
||||
};
|
||||
let mut vs = iface(Stage::Vertex, Vec::new(), Vec::new());
|
||||
vs.push = crate::lower::push::place(Stage::Vertex, 0, &BTreeSet::from([sb(Stage::Vertex)]));
|
||||
vs.push =
|
||||
crate::lower::push::place(Stage::Vertex, 0, MOST, &BTreeSet::from([sb(Stage::Vertex)]));
|
||||
assert_eq!(vs.push.push_range, Some((0, 4)));
|
||||
let mut fs = iface(Stage::Fragment, Vec::new(), Vec::new());
|
||||
fs.push = crate::lower::push::place(
|
||||
Stage::Fragment,
|
||||
4,
|
||||
MOST,
|
||||
&BTreeSet::from([PushField::RootTableAddress, sb(Stage::Fragment)]),
|
||||
);
|
||||
let (start, size) = fs.push.push_range.expect("fragment fields");
|
||||
|
||||
@@ -782,8 +782,9 @@ pub struct LoweringInputs {
|
||||
/// other stage compiles as without it.
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
pub unit_axes: u8,
|
||||
/// Where a fragment function's push fields start on `Device::from_queries`' profile
|
||||
///, whose render pipeline pushes one range `[0, 256)` for both stages:
|
||||
/// Where a fragment function's push fields start on `Device::from_queries`' profile, whose
|
||||
/// render pipeline pushes one range `[0, W)` for both stages, `W` the device's push window
|
||||
/// ([`DeviceProfile::push_window`](crate::device::DeviceProfile::push_window), 256 or 128):
|
||||
/// its vertex function's fields first, from 0 (from 24 for a post-tessellation function, past
|
||||
/// the control stage's range), then the fragment function's from this offset, the vertex
|
||||
/// function's push end
|
||||
@@ -792,10 +793,10 @@ pub struct LoweringInputs {
|
||||
/// function it compiled, and `Device::render_pipeline_key` hands it out in the fragment
|
||||
/// function's inputs from the vertex function's plan; a fragment compiled on its own for such a
|
||||
/// pipeline compiles under the same offset, and link refuses a fragment whose fields start below the vertex function's push
|
||||
/// end. A fragment function whose fields do not fit in `[push_base, 256)` pushes its parameter
|
||||
/// end. A fragment function whose fields do not fit in `[push_base, W)` pushes its parameter
|
||||
/// block's address at `push_base` rounded up to 8 (the address's alignment) and spills the
|
||||
/// rest into the block, as a kernel spills past its window; the vertex function's window ends
|
||||
/// at 248, so the address always fits. On any other profile, and for any other function, it is
|
||||
/// at `W - 8`, so the address always fits. On any other profile, and for any other function, it is
|
||||
/// 0.
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
pub push_base: u32,
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
//! and an output) pushes all 21 addresses with no block, below its tail word; one of 31 slots,
|
||||
//! Metal's most, pushes its parameter block's address (`ArgumentTableAddress`) and 27 slot
|
||||
//! addresses below the tail word at 248, and reads the other 4 from the block at their placed
|
||||
//! offsets, with no descriptor; each passes L3 and computes its answer on the CPU interpreter.
|
||||
//! offsets, with no descriptor. In the window of 128 bytes (`runtime-floor`) one of 12 slots
|
||||
//! pushes all 12, and ones of 21 and 31 push the block's address and 11 below the word at 120.
|
||||
//! Each passes L3 and computes its answer on the CPU interpreter.
|
||||
//! - A kernel that reads grid builtins (`grid`, generated) declares `MultiRegion`, default 0, and
|
||||
//! reads Metal's grid from its pushed `DispatchRegion` and its base from every region: at 0 a
|
||||
//! whole dispatch, one split in two pieces at a base, and an indirect one (a zero grid, its grid
|
||||
@@ -2512,31 +2514,44 @@ fn many_placed(
|
||||
(first, pushed, spilled, plan.push.argument_table_size)
|
||||
}
|
||||
|
||||
/// On `Device::from_queries`' profile a kernel's push window is 256 bytes:
|
||||
/// the same kernel's 21 slot addresses are all pushed, with no block, below its tail word 24 bytes
|
||||
/// above them (`PushPlacement::tail_word`). A kernel's 31, Metal's most buffer slots, would end
|
||||
/// past the floor with the word: its block's address and 27 slot addresses end at 224, the word is
|
||||
/// at 248, and the other 4 are read from the block. Each computes its answer.
|
||||
/// On `Device::from_queries`' profile a kernel's push window is the device's, 256 bytes on
|
||||
/// `PROFILES`: the same kernel's 21 slot addresses are all pushed, with no block, below its tail
|
||||
/// word 24 bytes above them (`PushPlacement::tail_word`). A kernel's 31, Metal's most buffer slots,
|
||||
/// would end past the window with the word: its block's address and 27 slot addresses end at 224,
|
||||
/// the word is at 248, and the other 4 are read from the block. In `runtime-floor`'s window of 128
|
||||
/// bytes a kernel's 12 are all pushed, and of its 21 and its 31 the block's address and 11 end at
|
||||
/// 96, the word is at 120, and the others are read from the block. Each computes its answer.
|
||||
#[test]
|
||||
fn the_floor_window_pushes_a_kernel_s_slot_addresses_below_its_tail_word() {
|
||||
for (reads, in_window) in [(READS, READS as usize + 1), (30, 27)] {
|
||||
let Some(bc) = assemble_text("many", &many_of(reads)) else {
|
||||
return;
|
||||
};
|
||||
for stem in PROFILES {
|
||||
let desc =
|
||||
crate::pipeline::testing::description(stem).unwrap_or_else(|e| panic!("{e}"));
|
||||
let device = Device::from_queries(desc, identity()).unwrap_or_else(|e| panic!("{e}"));
|
||||
let (first, pushed, spilled, table) = many_placed(stem, device.profile(), &bc, reads);
|
||||
let what = format!("{stem}, {} slots", reads + 1);
|
||||
assert_eq!(pushed.len(), in_window, "{what}");
|
||||
assert_eq!(spilled.len(), (reads + 1) as usize - in_window, "{what}");
|
||||
assert_eq!(table, if spilled.is_empty() { 0 } else { 32 }, "{what}");
|
||||
assert_eq!(
|
||||
first.map(|(f, _)| f) == Some(PushField::ArgumentTableAddress),
|
||||
!spilled.is_empty(),
|
||||
"{what}"
|
||||
);
|
||||
fn the_window_pushes_a_kernel_s_slot_addresses_below_its_tail_word() {
|
||||
let wide: [(u32, usize); 2] = [(READS, READS as usize + 1), (30, 27)];
|
||||
let least: [(u32, usize); 3] = [(11, 12), (READS, 11), (30, 11)];
|
||||
let windows: [(&[&str], u32, &[(u32, usize)]); 2] =
|
||||
[(&PROFILES, 256, &wide), (&["runtime-floor"], 128, &least)];
|
||||
for (stems, window, cases) in windows {
|
||||
for &(reads, in_window) in cases {
|
||||
let Some(bc) = assemble_text("many", &many_of(reads)) else {
|
||||
return;
|
||||
};
|
||||
for &stem in stems {
|
||||
let desc =
|
||||
crate::pipeline::testing::description(stem).unwrap_or_else(|e| panic!("{e}"));
|
||||
let device =
|
||||
Device::from_queries(desc, identity()).unwrap_or_else(|e| panic!("{e}"));
|
||||
assert_eq!(device.profile().push_window(), window, "{stem}");
|
||||
let (first, pushed, spilled, table) =
|
||||
many_placed(stem, device.profile(), &bc, reads);
|
||||
let what = format!("{stem}, window {window}, {} slots", reads + 1);
|
||||
assert_eq!(pushed.len(), in_window, "{what}");
|
||||
assert_eq!(spilled.len(), (reads + 1) as usize - in_window, "{what}");
|
||||
let block = (8 * spilled.len() as u32).next_multiple_of(16);
|
||||
assert_eq!(table, block, "{what}");
|
||||
assert_eq!(
|
||||
first.map(|(f, _)| f) == Some(PushField::ArgumentTableAddress),
|
||||
!spilled.is_empty(),
|
||||
"{what}"
|
||||
);
|
||||
println!("{what}: {in_window} pushed, {} in the block", spilled.len());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +1,25 @@
|
||||
//! A render pipeline's functions spill past their shares of the floor's push range under the
|
||||
//! A render pipeline's functions spill past their shares of the device's push range under the
|
||||
//! identity domains, as a kernel spills past its window.
|
||||
//!
|
||||
//! Owned synthetic functions: the vertex function `vmany` sums word `vid` of each of its 24
|
||||
//! `device` buffers into word `vid` of buffer 24, and the fragment function `fmany` returns the sum
|
||||
//! of word `x` of its two buffers, `x` its position's. Every access is at a run-time offset, so each
|
||||
//! slot pushes its address and its bounds, and each function the zero range's address.
|
||||
//! Owned synthetic functions: the vertex function `vmany` sums word `vid` of each of its `n`
|
||||
//! `device` buffers into word `vid` of buffer `n`, and the fragment function `fmany` returns the
|
||||
//! sum of word `x` of its two buffers, `x` its position's. Every access is at a run-time offset, so
|
||||
//! each slot pushes its address and its bounds, and each function the zero range's address. `n` is
|
||||
//! 24 on a device whose push window is 256 bytes and 9 on one of 128 ([`inputs`]): the most whose
|
||||
//! addresses the vertex function's window holds beside its block's address and the zero range's.
|
||||
//!
|
||||
//! - On every committed profile `Device::from_queries` derives under the identity domains, the
|
||||
//! vertex function's fields pass its window, `[0, 248)`: it pushes its parameter block's address
|
||||
//! first, then every slot's address, and only the check's fields (`ZeroAddress`, the bounds)
|
||||
//! from the first that does not fit go to the block. Its module passes L3.
|
||||
//! - The pair compiles on each such profile: the vertex function's fields end at 248, and the
|
||||
//! vertex function's fields pass its window, `[0, W - 8)` (`W` the device's window): it pushes its
|
||||
//! parameter block's address first, then every slot's address, and only the check's fields
|
||||
//! (`ZeroAddress`, the bounds) from the first that does not fit go to the block. Its module
|
||||
//! passes L3.
|
||||
//! - The pair compiles on each such profile: the vertex function's fields end at `W - 8`, and the
|
||||
//! fragment function, from there, pushes its block's address in the range's last 8 bytes and
|
||||
//! reads the rest, its slots' addresses too, from the block. Both modules pass L3.
|
||||
//! - On the CPU interpreter, four vertices with each buffer four words long sum Metal's words
|
||||
//! where every slot's pushed buffer is 16 bytes long; with the odd slots' pushed as 12 bytes
|
||||
//! long, in the window and in the block alike, vertex 3 reads zero from each of those slots. No access
|
||||
//! traps.
|
||||
//! - On the CPU interpreter, at 256 bytes (`lavapipe`) and at 128 (`runtime-floor`), four vertices
|
||||
//! with each buffer four words long sum Metal's words where every slot's pushed buffer is 16
|
||||
//! bytes long; with the odd slots' pushed as 12 bytes long, in the window and in the block alike,
|
||||
//! vertex 3 reads zero from each of those slots. No access traps.
|
||||
//!
|
||||
//! `llvm-as` assembles the functions; without it the tests skip visibly.
|
||||
|
||||
@@ -36,8 +39,16 @@ use crate::pipeline::testing::{compile_kept, description, link_and_validate, Ass
|
||||
use crate::spirv::interp::{run, Buffer, Config, Resources};
|
||||
use crate::spirv::testing::{check_words_valid, spirv_dis};
|
||||
|
||||
/// The vertex function's input buffers; its output is buffer `INPUTS`.
|
||||
const INPUTS: u32 = 24;
|
||||
/// The vertex function's input buffers on a device whose push window is `bytes`: 24 at 256 and 9
|
||||
/// at 128, so its window holds its block's address and every slot's address, and the check's
|
||||
/// fields spill. Its output is buffer `inputs(bytes)`.
|
||||
fn inputs(bytes: u32) -> u32 {
|
||||
match bytes {
|
||||
256 => 24,
|
||||
128 => 9,
|
||||
other => panic!("no fixture for a push window of {other} bytes"),
|
||||
}
|
||||
}
|
||||
/// Vertices drawn, and words in each buffer.
|
||||
const VERTICES: u32 = 4;
|
||||
/// Where the interpreter holds buffer `i` (`BUFFERS + i * STRIDE`), the parameter block and the
|
||||
@@ -47,8 +58,8 @@ const STRIDE: u64 = 0x1000;
|
||||
const BLOCK: u64 = 0x5_0000_0000;
|
||||
const ZERO: u64 = 0x6_0000_0000;
|
||||
|
||||
fn functions() -> String {
|
||||
let n = INPUTS as usize;
|
||||
fn functions(inputs: u32) -> String {
|
||||
let n = inputs as usize;
|
||||
let mut params: Vec<String> = (0..n)
|
||||
.map(|i| format!("ptr addrspace(1) noundef \"air-buffer-no-alias\" %b{i}"))
|
||||
.collect();
|
||||
@@ -147,8 +158,8 @@ entry:
|
||||
)
|
||||
}
|
||||
|
||||
fn assemble() -> Option<Vec<u8>> {
|
||||
match metal2vulkan_devtools::llvm_assemble_text(&functions()) {
|
||||
fn assemble(inputs: u32) -> Option<Vec<u8>> {
|
||||
match metal2vulkan_devtools::llvm_assemble_text(&functions(inputs)) {
|
||||
Ok(b) => Some(b),
|
||||
Err(AssembleError::Missing(why)) => {
|
||||
eprintln!("SKIPPED: {why}");
|
||||
@@ -203,14 +214,19 @@ fn assert_spills(what: &str, p: &PushPlacement, start: u32, addresses: bool) {
|
||||
|
||||
#[test]
|
||||
fn a_vertex_function_past_its_share_spills_the_checks_fields_into_its_block() {
|
||||
let Some(bc) = assemble() else {
|
||||
return;
|
||||
};
|
||||
for (stem, p) in identity_profiles() {
|
||||
let window = p.push_window();
|
||||
let Some(bc) = assemble(inputs(window)) else {
|
||||
return;
|
||||
};
|
||||
let (a, plan, _) = compile_kept(&bc, "vmany", &p).unwrap_or_else(|e| panic!("{stem}: {e}"));
|
||||
assert_spills(&stem, &plan.push, 0, true);
|
||||
let end = plan.push.push_range.map_or(0, |(o, s)| o + s);
|
||||
assert!(end <= 248, "{stem}: the vertex window ends at {end}");
|
||||
assert!(
|
||||
end <= window - 8,
|
||||
"{stem}: the vertex window of {window} ends at {end}"
|
||||
);
|
||||
println!("{stem}: push window {window}, the vertex function's fields end at {end}");
|
||||
link_and_validate(&a, &p).unwrap_or_else(|e| panic!("{stem}: L3: {e}"));
|
||||
let text = spirv_dis(&a.module.words);
|
||||
if text.starts_with('<') {
|
||||
@@ -323,19 +339,20 @@ fn pointer_lines(text: &str) -> String {
|
||||
|
||||
#[test]
|
||||
fn a_render_pair_past_the_floor_spills_both_functions() {
|
||||
let Some(bc) = assemble() else {
|
||||
return;
|
||||
};
|
||||
let library = Library::from_air(&bc).expect("the library");
|
||||
let function = |name| {
|
||||
StageSource::Function(FunctionDescriptor::new(
|
||||
library.function(name).expect("the function"),
|
||||
))
|
||||
};
|
||||
let mut d = RenderPipelineDescriptor::new(function("vmany"));
|
||||
d.fragment = Some(function("fmany"));
|
||||
d.color_attachments[0] = Some(ColorAttachmentDescriptor::new(PixelFormat::RGBA8Unorm));
|
||||
for (stem, _) in identity_profiles() {
|
||||
for (stem, profile) in identity_profiles() {
|
||||
let window = profile.push_window();
|
||||
let Some(bc) = assemble(inputs(window)) else {
|
||||
return;
|
||||
};
|
||||
let library = Library::from_air(&bc).expect("the library");
|
||||
let function = |name| {
|
||||
StageSource::Function(FunctionDescriptor::new(
|
||||
library.function(name).expect("the function"),
|
||||
))
|
||||
};
|
||||
let mut d = RenderPipelineDescriptor::new(function("vmany"));
|
||||
d.fragment = Some(function("fmany"));
|
||||
d.color_attachments[0] = Some(ColorAttachmentDescriptor::new(PixelFormat::RGBA8Unorm));
|
||||
let desc = description(&stem).unwrap_or_else(|e| panic!("{e}"));
|
||||
let device = Device::from_queries(desc, identity()).unwrap_or_else(|e| panic!("{e}"));
|
||||
let p = (device.compile_render_pipeline(&d, &Budget::standard()))
|
||||
@@ -348,13 +365,16 @@ fn a_render_pair_past_the_floor_spills_both_functions() {
|
||||
(Stage::Vertex, Stage::Fragment)
|
||||
);
|
||||
assert_spills(&format!("{stem} vertex"), vertex, 0, true);
|
||||
// The vertex function fills its window to 248: the fragment function's block address
|
||||
// takes the range's last 8 bytes, and its slots' addresses go to its block too.
|
||||
// The vertex function fills its window to `window - 8`: the fragment function's block
|
||||
// address takes the range's last 8 bytes, and its slots' addresses go to its block too.
|
||||
let base = vertex.push_range.map_or(0, |(o, s)| o + s);
|
||||
assert_eq!(base, 248, "{stem}");
|
||||
assert_eq!(base, window - 8, "{stem}");
|
||||
assert_spills(&format!("{stem} fragment"), fragment, base, false);
|
||||
let end = fragment.push_range.map_or(0, |(o, s)| o + s);
|
||||
assert!(end <= 256, "{stem}: the range ends at {end}");
|
||||
assert!(end <= window, "{stem}: the range ends at {end}");
|
||||
println!(
|
||||
"{stem}: push window {window}, the vertex function ends at {base}, the pair at {end}"
|
||||
);
|
||||
for stage in &p.stages {
|
||||
check_words_valid(&stage.spirv, &p.requirements, device.profile())
|
||||
.unwrap_or_else(|e| panic!("{stem}: {:?}: {e}", stage.stage));
|
||||
@@ -367,16 +387,17 @@ fn word(i: u32, v: u32) -> u32 {
|
||||
(i + 1) * 100 + v
|
||||
}
|
||||
|
||||
/// One draw of `VERTICES` vertices of `vmany` on the lavapipe profile, each input slot's pushed
|
||||
/// buffer `length(i)` bytes long: the output buffer's words.
|
||||
fn draw(length: impl Fn(u32) -> usize) -> Vec<u32> {
|
||||
let Some(bc) = assemble() else {
|
||||
return Vec::new();
|
||||
};
|
||||
/// One draw of `VERTICES` vertices of `vmany` on committed profile `stem`, each input slot's
|
||||
/// pushed buffer `length(i)` bytes long: the output buffer's words.
|
||||
fn draw(stem: &str, length: impl Fn(u32) -> usize) -> Vec<u32> {
|
||||
let (stem, p) = identity_profiles()
|
||||
.into_iter()
|
||||
.find(|(stem, _)| stem == "lavapipe")
|
||||
.expect("lavapipe");
|
||||
.find(|(name, _)| name == stem)
|
||||
.unwrap_or_else(|| panic!("{stem}"));
|
||||
let n = inputs(p.push_window());
|
||||
let Some(bc) = assemble(n) else {
|
||||
return Vec::new();
|
||||
};
|
||||
let (_, plan, module) = compile_kept(&bc, "vmany", &p).unwrap_or_else(|e| panic!("{e}"));
|
||||
let bytes = 4 * VERTICES as usize;
|
||||
let mut push = vec![0u8; plan.push.push_range.map_or(0, |(o, s)| (o + s) as usize)];
|
||||
@@ -392,7 +413,7 @@ fn draw(length: impl Fn(u32) -> usize) -> Vec<u32> {
|
||||
let at = BUFFERS + u64::from(s.index) * STRIDE;
|
||||
to[o..o + 8].copy_from_slice(&slot_word(at).to_le_bytes());
|
||||
}
|
||||
PushField::SlotBounds(s) if s.index < INPUTS => {
|
||||
PushField::SlotBounds(s) if s.index < n => {
|
||||
to[o..o + 8].copy_from_slice(&bounds_word(length(s.index), 0))
|
||||
}
|
||||
PushField::SlotBounds(_) => to[o..o + 8].copy_from_slice(&bounds_word(bytes, 0)),
|
||||
@@ -405,7 +426,7 @@ fn draw(length: impl Fn(u32) -> usize) -> Vec<u32> {
|
||||
address: Some(address),
|
||||
bytes,
|
||||
};
|
||||
let mut buffers: Vec<Buffer> = (0..INPUTS)
|
||||
let mut buffers: Vec<Buffer> = (0..n)
|
||||
.map(|i| {
|
||||
let words = (0..VERTICES)
|
||||
.flat_map(|v| word(i, v).to_le_bytes())
|
||||
@@ -413,7 +434,7 @@ fn draw(length: impl Fn(u32) -> usize) -> Vec<u32> {
|
||||
buffer(BUFFERS + u64::from(i) * STRIDE, words)
|
||||
})
|
||||
.collect();
|
||||
buffers.push(buffer(BUFFERS + u64::from(INPUTS) * STRIDE, vec![0; bytes]));
|
||||
buffers.push(buffer(BUFFERS + u64::from(n) * STRIDE, vec![0; bytes]));
|
||||
buffers.push(buffer(BLOCK, block));
|
||||
buffers.push(buffer(ZERO, vec![0; 16]));
|
||||
let res = Resources {
|
||||
@@ -427,27 +448,31 @@ fn draw(length: impl Fn(u32) -> usize) -> Vec<u32> {
|
||||
};
|
||||
let got = run(&module, &cfg, res).unwrap_or_else(|e| panic!("{stem}: {e}"));
|
||||
assert_eq!(
|
||||
got.buffers[INPUTS as usize + 2],
|
||||
got.buffers[n as usize + 2],
|
||||
vec![0; 16],
|
||||
"{stem}: the zero range"
|
||||
);
|
||||
(got.buffers[INPUTS as usize].chunks(4))
|
||||
(got.buffers[n as usize].chunks(4))
|
||||
.map(|w| u32::from_le_bytes(w.try_into().expect("a word")))
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn spilled_bounds_check_their_slot_as_pushed_ones_do() {
|
||||
let all = |v: u32| (0..INPUTS).map(|i| word(i, v)).sum::<u32>();
|
||||
let whole = draw(|_| 4 * VERTICES as usize);
|
||||
if whole.is_empty() {
|
||||
return;
|
||||
for (stem, window) in [("lavapipe", 256), ("runtime-floor", 128)] {
|
||||
let n = inputs(window);
|
||||
let all = |v: u32| (0..n).map(|i| word(i, v)).sum::<u32>();
|
||||
let whole = draw(stem, |_| 4 * VERTICES as usize);
|
||||
if whole.is_empty() {
|
||||
return;
|
||||
}
|
||||
assert_eq!(whole, (0..VERTICES).map(all).collect::<Vec<_>>(), "{stem}");
|
||||
// The odd slots one word short: vertex 3 reads zero from each of them.
|
||||
let short = draw(stem, |i| 4 * (VERTICES as usize - (i as usize % 2)));
|
||||
let even = |v: u32| (0..n).step_by(2).map(|i| word(i, v)).sum::<u32>();
|
||||
let mut want: Vec<u32> = (0..VERTICES - 1).map(all).collect();
|
||||
want.push(even(VERTICES - 1));
|
||||
assert_eq!(short, want, "{stem}");
|
||||
println!("{stem}: push window {window}, {n} inputs, each vertex's sum");
|
||||
}
|
||||
assert_eq!(whole, (0..VERTICES).map(all).collect::<Vec<_>>());
|
||||
// The odd slots one word short: vertex 3 reads zero from each of them.
|
||||
let short = draw(|i| 4 * (VERTICES as usize - (i as usize % 2)));
|
||||
let even = |v: u32| (0..INPUTS).step_by(2).map(|i| word(i, v)).sum::<u32>();
|
||||
let mut want: Vec<u32> = (0..VERTICES - 1).map(all).collect();
|
||||
want.push(even(VERTICES - 1));
|
||||
assert_eq!(short, want);
|
||||
}
|
||||
@@ -226,7 +226,7 @@ fn reads_body(accesses: u32) -> String {
|
||||
/// once, so the slots are placed in work linear in their number. A table is at most
|
||||
/// [`LARGEST_TABLE`] buffers (Metal's 31 buffer entries), so the moves are bounded by Metal's
|
||||
/// table: tables of 15 and 30 buffers beside `out` on `lavapipe` held to 30 storage buffers per
|
||||
/// stage (`roadmap-2022`'s, whose 128 push bytes are below the floor's 256) translate, pass L3, and
|
||||
/// stage (`roadmap-2022`'s) translate, pass L3, and
|
||||
/// charge under 2.2 times the work units for twice the buffers. Previously
|
||||
/// each move recounted every slot and placed every push field, unmetered, so the units are the same
|
||||
/// there; the measured times (at 2^12 and 2^13 buffers, a table no Metal function binds) were
|
||||
|
||||
@@ -6636,6 +6636,7 @@ method metal2vulkan::device::DeviceProfile::interpolation_function_needs pub fn
|
||||
method metal2vulkan::device::DeviceProfile::limits pub fn limits(&self) -> &Limits
|
||||
method metal2vulkan::device::DeviceProfile::link_standalone pub fn link_standalone(&self, f: &CompiledFunction) -> Result<StandaloneModule, Error>
|
||||
method metal2vulkan::device::DeviceProfile::plan_entry pub fn plan_entry(&self, d: &EntryDescriptor<'_>, inputs: &LoweringInputs, budget: &Budget) -> (Result<EntryPlan, Error>, CompileReport)
|
||||
method metal2vulkan::device::DeviceProfile::push_window pub fn push_window(&self) -> u32
|
||||
method metal2vulkan::device::DeviceProfile::simd_tier pub fn simd_tier(&self, class: &SimdClass, stage: Stage) -> Result<Tier, Unsupported>
|
||||
method metal2vulkan::device::DeviceProfile::specialized_entry pub fn specialized_entry(&self, d: &EntryDescriptor<'_>, inputs: &LoweringInputs, budget: &Budget) -> Result<Entry, Error>
|
||||
method metal2vulkan::device::DeviceProfile::spirv_validation pub fn spirv_validation(&self) -> SpirvValidation
|
||||
|
||||
|
Can't render this file because it is too large.
|
+15
-10
@@ -79,9 +79,10 @@ let device = Device::from_queries(description, DevicePolicy::default())?;
|
||||
|
||||
`Device::from_queries` needs no Vulkan device: it derives the profile from the description's
|
||||
queries alone, reading no vendor, device or driver identity. It refuses a device below Vulkan 1.2,
|
||||
one whose `maxPushConstantsSize` is below the 256-byte push window every stage is lowered for
|
||||
(`Unsupported{PushWindow}`, a `Limit` of `MaxPushConstantsSize`), and an inconsistent description
|
||||
or policy. A
|
||||
a description whose `maxPushConstantsSize` is below 128 bytes, Vulkan's least and the least push
|
||||
window a stage is lowered for (`Unsupported{PushWindow}`, a `Limit` of `MaxPushConstantsSize`),
|
||||
and an inconsistent description or policy. The push window is the device's `maxPushConstantsSize`
|
||||
up to 256 bytes (`DeviceProfile::push_window`, section 5). A
|
||||
`Device` is cheap to clone; every compile and plan takes it.
|
||||
|
||||
The guide's examples are quoted from `examples/api_preview.rs`. Its tour device takes
|
||||
@@ -149,17 +150,21 @@ and so do the command line, the compile worker and every validation tool. It hol
|
||||
`PushField::ArgumentTableAddress`, which the window always holds. The function reads the block
|
||||
16 bytes at a time at multiples of 16 (its size, `argument_table_size`, is a multiple of 16) and
|
||||
never writes it, so the consumer places it at a multiple of 16 and leaves it unchanged while
|
||||
the command reads it. A kernel's window is 256 bytes, as the runtime's floor requires that much
|
||||
`maxPushConstantsSize`: a dispatch region and 24 buffer addresses below its tail. A render
|
||||
pipeline's two functions share one 256-byte range: the vertex function's window is `[0, 248)`,
|
||||
and the fragment function's runs from the vertex function's end to 256. A post-tessellation
|
||||
vertex function's window is `[24, 248)`, and its fragment function's starts at 24 or past: the
|
||||
the command reads it. Every stage's window is `W` bytes, the device's `maxPushConstantsSize` up
|
||||
to 256 (`DeviceProfile::push_window`; at least 128, Vulkan's least), the one value a consumer's
|
||||
pipeline layout holds as its push range; the profile's fingerprint holds the limit, so devices
|
||||
of two windows share no artifact. A kernel's window is `[0, W)`: a dispatch region and 24 buffer
|
||||
addresses below its tail at 256 bytes, 8 at 128. A render
|
||||
pipeline's two functions share one range `[0, W)`: the vertex function's window is
|
||||
`[0, W - 8)`, `[0, 248)` at 256 bytes and `[0, 120)` at 128, and the fragment function's runs
|
||||
from the vertex function's end to `W`. A post-tessellation
|
||||
vertex function's window is `[24, W - 8)`, and its fragment function's starts at 24 or past: the
|
||||
pipeline's control stage pushes its fields (8 to 24 bytes) at 0, so the pair's fields, which
|
||||
spill where they pass their windows, never take its bytes. A
|
||||
vertex function is lowered without knowing its fragment function, so it leaves the last 8
|
||||
bytes, where a fragment function whose fields spill always pushes its block's address; that
|
||||
costs only a vertex function whose own fields pass 248 bytes, which spills where it would have
|
||||
filled them. The fields only a checked access reads
|
||||
costs only a vertex function whose own fields pass `W - 8` bytes, which spills where it would
|
||||
have filled them. The fields only a checked access reads
|
||||
(`PushField::ZeroAddress` and each `PushField::SlotBounds`) come last in the order, so they
|
||||
are the first to move to the block. Each function's push ends with its tail, 24 bytes or more above its other pushed fields: its highest
|
||||
`PushField::SlotBounds` or `PushField::ZeroAddress`, moved there, or where it pushes neither, the
|
||||
|
||||
+1
-1
@@ -137,7 +137,7 @@ Columns:
|
||||
| `RasterizationRateMap` | | devices without VkFeature::MultiViewport; devices without VkFeature::ShaderDrawParameters; devices without VkFeature::ShaderOutputViewportIndex; every device (not implemented) | `ours` | 2: `crates/metal2vulkan/src/lower/stage_io/plan.rs (region_viewport, 2 sites)` | `rare`: rasterization rate maps |
|
||||
| `GpuEncodedIndirectCommands` | | devices short of a Vulkan feature the site names; devices without buffer device addresses (`addressed_needs`); every device (no Vulkan mechanism); every device (not implemented) | `ours` | 14: `crates/metal2vulkan/src/lower/access/icb.rs (needs, 2 sites)`, `crates/metal2vulkan/src/lower/access/icb.rs (select, 2 sites)` (+7) | `rare`: indirect command buffers encoded by a kernel |
|
||||
| `VulkanVersion` | The device's Vulkan version is below the 1.2 floor | devices without ApiVersion::V1_2 | `device` | 2: `crates/metal2vulkan/src/ash_interop/query.rs (query)`, `crates/metal2vulkan/src/device/derive.rs (from_queries)` | `none`: a device below Vulkan 1.2 |
|
||||
| `PushWindow` | The device's `maxPushConstantsSize` is below the 256 bytes of the push window every stage is lowered for | devices without VkLimit::MaxPushConstantsSize | `device` | 1: `crates/metal2vulkan/src/device/derive.rs (from_queries)` | `none`: a device whose maxPushConstantsSize is below 256 bytes |
|
||||
| `PushWindow` | The description's `maxPushConstantsSize` is below 128 bytes, Vulkan's least and the least push window a stage is lowered for | devices without VkLimit::MaxPushConstantsSize | `device` | 1: `crates/metal2vulkan/src/device/derive.rs (from_queries)` | `none`: a description whose maxPushConstantsSize is below 128 bytes, less than Vulkan lets a device report |
|
||||
| `IdentityDomains` | The identity pointer and handle domains (`PointerDomain::Identity`, `HandleDomain::Identity`) | devices without a capability the site computes (`all`); every device (not implemented) | `ours` | 7: `crates/metal2vulkan/src/device/derive.rs (identity_domains)`, `crates/metal2vulkan/src/lower/sampler/anisotropic.rs (select)` (+5) | `none`: the identity domains, which the runtime alone takes and which lower only kernels over buffer slots, textures in slots or argument buffers, and runtime samplers, so far |
|
||||
| `Constant` | A constants-block record LLVM defines that the typed model has no form for (a block address, a `select` and the other constant expressions of... | every device (not implemented) | `ours` | via a helper: 3: `crates/metal2vulkan-air/src/bitcode/constants.rs (record, 2 sites)`, `crates/metal2vulkan/src/error/mod.rs (from)` | `none`: LLVM constant forms AIR does not emit |
|
||||
| `Attribute` | An LLVM attribute kind that changes the calling ABI and that AIR does not use (`inalloca`, `preallocated`, `byref`, `nest`, the `swift*` kinds) | every device (not implemented) | `ours` | via a helper: 2: `crates/metal2vulkan-air/src/bitcode/attrs.rs (known)`, `crates/metal2vulkan/src/error/mod.rs (from)` | `none`: LLVM ABI attributes AIR does not use |
|
||||
|
||||
@@ -85,7 +85,7 @@ feature Tensors rare shader tensors
|
||||
feature RasterizationRateMap rare rasterization rate maps
|
||||
feature GpuEncodedIndirectCommands rare indirect command buffers encoded by a kernel
|
||||
feature VulkanVersion none a device below Vulkan 1.2
|
||||
feature PushWindow none a device whose maxPushConstantsSize is below 256 bytes
|
||||
feature PushWindow none a description whose maxPushConstantsSize is below 128 bytes, less than Vulkan lets a device report
|
||||
feature IdentityDomains none the identity domains, which the runtime alone takes and which lower only kernels over buffer slots, textures in slots or argument buffers, and runtime samplers, so far
|
||||
feature Constant none LLVM constant forms AIR does not emit
|
||||
feature Attribute none LLVM ABI attributes AIR does not use
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 17 and column 65.
|
@@ -150,7 +150,6 @@ RUNTIME_FLOOR = {
|
||||
"properties": {
|
||||
"VkPhysicalDeviceProperties": {"limits": {
|
||||
"maxSamplerAllocationCount": 4000,
|
||||
"maxPushConstantsSize": 256,
|
||||
"maxComputeWorkGroupInvocations": 1024,
|
||||
"maxComputeWorkGroupSize": [1024, 1024, 64],
|
||||
"timestampComputeAndGraphics": True,
|
||||
|
||||
Reference in new issue
Block a user