diff --git a/crates/metal2vulkan-rt/README.md b/crates/metal2vulkan-rt/README.md index b2ac81ae0..01b38151c 100644 --- a/crates/metal2vulkan-rt/README.md +++ b/crates/metal2vulkan-rt/README.md @@ -439,10 +439,15 @@ between, `external_writes_done` comes first, as above. offers a non-host-visible type first. - rt caps a buffer at 2 GiB (`MAX_BUFFER_LENGTH`), where the M3's Metal allows 38.88 GiB (`maxBufferLength`, 41,747,087,360 bytes), about twenty times as much: shaders reach a buffer's - bytes by 32-bit offsets from its bind address, which bought 4.3 to 6.6% on AMD cards and more on - the RTX 3090 in a probe of constant reads, where a 64-bit sum without them was 8.9% slower on the - RX 7900 XTX, and lifting the cap would put 64-bit offset arithmetic on every buffer access. A - longer buffer is `Refusal::BufferTooLong`. + bytes by 32-bit offsets from its bind address, and lifting the cap would put 64-bit offset + arithmetic on every buffer access. The word rt pushes for a buffer slot is the slot's address + less 2^31; an access adds its 32-bit offset plus 2^31 to that word, zero-extended, which is the + offset read as signed in one 32-bit add. In a probe of one particle kernel that form was within + 0.7% of a zero-extended offset (inexact below the bind address) on the RX 7900 XTX and two + Radeon 780Ms at the kernel's grid, and on the XTX and one 780M at four times it, where the + sign-extended offset it replaced was 6.8 to 9.5% slower. In an earlier probe of constant reads, + 32-bit offsets bought 4.3 to 6.6% on AMD cards and more on the RTX 3090, where a 64-bit sum was + 8.9% slower on the RX 7900 XTX. A longer buffer is `Refusal::BufferTooLong`. - A dispatch whose indirect arguments, or an indexed draw whose indices, start at a byte of their block that is not a multiple of 4, or of the index size, is refused (`Refusal::ArgumentPlace`). Metal's offset rules keep both at that multiple of the buffer's start, so only a buffer that diff --git a/crates/metal2vulkan-rt/src/encoder.rs b/crates/metal2vulkan-rt/src/encoder.rs index d1789fefa..334f1a355 100644 --- a/crates/metal2vulkan-rt/src/encoder.rs +++ b/crates/metal2vulkan-rt/src/encoder.rs @@ -12,8 +12,8 @@ use crate::kept::{Handle, Lent, Uncounted}; use crate::memory::BlockId; use crate::over; use crate::pipeline::{ - ComputePipelineState, FieldValue, Form, Interface, Kernel, Place, Which, PUSH_BYTES, - PUSH_STAGES, SQUARE, + address_word, ComputePipelineState, FieldValue, Form, Interface, Kernel, Place, Which, + PUSH_BYTES, PUSH_STAGES, SQUARE, }; use crate::record::Reach; use crate::ring::CHUNK; @@ -1292,7 +1292,8 @@ impl Parameters { Some(Slot::Bytes(address)) => *address, Some(Slot::Empty) | None => nil, }; - bytes[at..at + 8].copy_from_slice(&address.to_le_bytes()); + let word = address_word(address); + bytes[at..at + 8].copy_from_slice(&word.to_le_bytes()); } FieldValue::TextureId(slot) => { let id = match textures.get(slot as usize) { diff --git a/crates/metal2vulkan-rt/src/pipeline.rs b/crates/metal2vulkan-rt/src/pipeline.rs index ddb46ddb0..811b8d1d6 100644 --- a/crates/metal2vulkan-rt/src/pipeline.rs +++ b/crates/metal2vulkan-rt/src/pipeline.rs @@ -538,14 +538,23 @@ pub(crate) enum Place { Block(u32), } +/// The word a buffer slot's [`FieldValue::BufferAddress`] parameter holds for `address`: the +/// address less 2^31, as the translator's identity domains read a buffer slot's `SlotGuestBase` +/// (`docs/API.md`, section 5). A module adds an access's 32-bit byte offset plus 2^31 to the word, +/// zero-extended, which is the address plus the offset read as signed, and adds 2^31 back where it +/// reads the address itself. +pub(crate) fn address_word(address: u64) -> u64 { + address.wrapping_sub(1 << 31) +} + /// What a parameter holds. #[derive(Clone, Copy)] pub(crate) enum FieldValue { - /// A `u64`: the address of the buffer bound at the slot plus its offset, the address of the - /// slot's `set_bytes` copy, or 0 where nothing is bound. `mask` is the alignment the module - /// takes that address to have, less 1 (`RuntimeFact::AddressAlignment`), 0 where it takes - /// none: a dispatch whose bound buffer's address it does not divide is refused - /// (`Refusal::BufferOffsetAlignment`). + /// A `u64`: the [`address_word`] of the address of the buffer bound at the slot plus its + /// offset, of the address of the slot's `set_bytes` copy, or of the nil buffer's address where + /// nothing is bound. `mask` is the alignment the module takes that address to have, less 1 + /// (`RuntimeFact::AddressAlignment`), 0 where it takes none: a dispatch whose bound buffer's + /// address it does not divide is refused (`Refusal::BufferOffsetAlignment`). BufferAddress { slot: u32, mask: u64 }, /// A `u64`: the `gpuResourceID` of the texture bound at the slot, 0 where none is. TextureId(u32), diff --git a/crates/metal2vulkan-rt/src/render_encoder.rs b/crates/metal2vulkan-rt/src/render_encoder.rs index 3b3ad7322..ab07337e2 100644 --- a/crates/metal2vulkan-rt/src/render_encoder.rs +++ b/crates/metal2vulkan-rt/src/render_encoder.rs @@ -83,7 +83,7 @@ use crate::hazard::Access; use crate::kept::{Handle, Lent, Uncounted}; use crate::over; use crate::pass::{layout_barrier, ops, LoadAction, Pass, RenderPassDescriptor, StoreAction}; -use crate::pipeline::{FieldValue, PUSH_STAGES}; +use crate::pipeline::{address_word, FieldValue, PUSH_STAGES}; use crate::record::{memory_barrier, Reach}; use crate::render::{Draws, RenderPipelineState, FRAGMENT, VERTEX}; use crate::ring::{Placed, CHUNK}; @@ -2246,8 +2246,8 @@ fn fill_push( match value { // At a multiple of the argument's alignment, which the draw checked first. FieldValue::BufferAddress { slot, .. } => { - let address = tables.address(slot, nil); - push[at..at + 8].copy_from_slice(&address.to_le_bytes()); + let word = address_word(tables.address(slot, nil)); + push[at..at + 8].copy_from_slice(&word.to_le_bytes()); } FieldValue::TextureId(slot) => { let id = (tables.texture(slot)).map_or(0, |t| { diff --git a/crates/metal2vulkan-rt/src/tests/kernels.rs b/crates/metal2vulkan-rt/src/tests/kernels.rs index c1f5a3ad9..1de26cce3 100644 --- a/crates/metal2vulkan-rt/src/tests/kernels.rs +++ b/crates/metal2vulkan-rt/src/tests/kernels.rs @@ -2,7 +2,8 @@ //! doc comment with `glslangValidator -V --target-env vulkan1.2` (whose workgroup size is the //! specialized `WorkgroupSize`: `LocalSizeId` needs `maintenance4`) and checked with `spirv-val`. //! Each reads its parameters as the translator's kernels do: the dispatch region first, then -//! buffer addresses, past the push window through a block in the parameter ring. +//! buffer addresses, each pushed less 2^31 (`pipeline::address_word`), past the push window through +//! a block in the parameter ring. /// A kernel over three buffers: `o[i] = a[i] + b[i]` below the grid, which an indirect /// dispatch (a zero grid) takes from its workgroup count. @@ -14,16 +15,17 @@ /// layout(local_size_x_id = 0, local_size_y_id = 1, local_size_z_id = 2) in; /// layout(buffer_reference, std430, buffer_reference_align = 4) buffer Words { uint w[]; }; /// layout(push_constant, std430) uniform Params { uvec4 region[2]; uint64_t a; uint64_t b; uint64_t o; } p; +/// const uint64_t BIAS = 0x80000000ul; /// void main() { /// uint grid = p.region[1].x != 0u ? p.region[1].x : gl_NumWorkGroups.x * gl_WorkGroupSize.x; /// uint i = gl_GlobalInvocationID.x; /// if (i >= grid) return; -/// Words(p.o).w[i] = Words(p.a).w[i] + Words(p.b).w[i]; +/// Words(p.o + BIAS).w[i] = Words(p.a + BIAS).w[i] + Words(p.b + BIAS).w[i]; /// } /// ``` #[rustfmt::skip] -pub(crate) const ADD: [u32; 535] = [ - 0x07230203, 0x00010500, 0x0008000b, 0x0000004f, 0x00000000, 0x00020011, 0x00000001, 0x00020011, +pub(crate) const ADD: [u32; 555] = [ + 0x07230203, 0x00010500, 0x0008000b, 0x00000053, 0x00000000, 0x00020011, 0x00000001, 0x00020011, 0x0000000b, 0x00020011, 0x000014e3, 0x0006000b, 0x00000001, 0x4c534c47, 0x6474732e, 0x3035342e, 0x00000000, 0x0003000e, 0x000014e4, 0x00000001, 0x0008000f, 0x00000005, 0x00000004, 0x6e69616d, 0x00000000, 0x0000000f, 0x00000021, 0x0000002d, 0x00060010, 0x00000004, 0x00000011, 0x00000001, @@ -36,15 +38,15 @@ pub(crate) const ADD: [u32; 535] = [ 0x00000002, 0x00000062, 0x00040006, 0x0000000d, 0x00000003, 0x0000006f, 0x00030005, 0x0000000f, 0x00000070, 0x00070005, 0x00000021, 0x4e5f6c67, 0x6f576d75, 0x72476b72, 0x7370756f, 0x00000000, 0x00030005, 0x0000002c, 0x00000069, 0x00080005, 0x0000002d, 0x475f6c67, 0x61626f6c, 0x766e496c, - 0x7461636f, 0x496e6f69, 0x00000044, 0x00040005, 0x0000003c, 0x64726f57, 0x00000073, 0x00040006, - 0x0000003c, 0x00000000, 0x00000077, 0x00040047, 0x0000000b, 0x00000006, 0x00000010, 0x00030047, + 0x7461636f, 0x496e6f69, 0x00000044, 0x00040005, 0x0000003e, 0x64726f57, 0x00000073, 0x00040006, + 0x0000003e, 0x00000000, 0x00000077, 0x00040047, 0x0000000b, 0x00000006, 0x00000010, 0x00030047, 0x0000000d, 0x00000002, 0x00050048, 0x0000000d, 0x00000000, 0x00000023, 0x00000000, 0x00050048, 0x0000000d, 0x00000001, 0x00000023, 0x00000020, 0x00050048, 0x0000000d, 0x00000002, 0x00000023, 0x00000028, 0x00050048, 0x0000000d, 0x00000003, 0x00000023, 0x00000030, 0x00040047, 0x00000021, 0x0000000b, 0x00000018, 0x00040047, 0x00000025, 0x00000001, 0x00000000, 0x00040047, 0x00000026, 0x00000001, 0x00000001, 0x00040047, 0x00000027, 0x00000001, 0x00000002, 0x00040047, 0x00000028, - 0x0000000b, 0x00000019, 0x00040047, 0x0000002d, 0x0000000b, 0x0000001c, 0x00040047, 0x0000003b, - 0x00000006, 0x00000004, 0x00030047, 0x0000003c, 0x00000002, 0x00050048, 0x0000003c, 0x00000000, + 0x0000000b, 0x00000019, 0x00040047, 0x0000002d, 0x0000000b, 0x0000001c, 0x00040047, 0x0000003d, + 0x00000006, 0x00000004, 0x00030047, 0x0000003e, 0x00000002, 0x00050048, 0x0000003e, 0x00000000, 0x00000023, 0x00000000, 0x00020013, 0x00000002, 0x00030021, 0x00000003, 0x00000002, 0x00040015, 0x00000006, 0x00000020, 0x00000000, 0x00040020, 0x00000007, 0x00000007, 0x00000006, 0x00040017, 0x00000009, 0x00000006, 0x00000004, 0x0004002b, 0x00000006, 0x0000000a, 0x00000002, 0x0004001c, @@ -59,37 +61,40 @@ pub(crate) const ADD: [u32; 535] = [ 0x00000006, 0x00000026, 0x00000001, 0x00040032, 0x00000006, 0x00000027, 0x00000001, 0x00060033, 0x0000001f, 0x00000028, 0x00000025, 0x00000026, 0x00000027, 0x0004003b, 0x00000020, 0x0000002d, 0x00000001, 0x0004002b, 0x00000010, 0x00000036, 0x00000003, 0x00040020, 0x00000037, 0x00000009, - 0x0000000c, 0x00030027, 0x0000003a, 0x000014e5, 0x0003001d, 0x0000003b, 0x00000006, 0x0003001e, - 0x0000003c, 0x0000003b, 0x00040020, 0x0000003a, 0x000014e5, 0x0000003c, 0x00040020, 0x00000043, - 0x000014e5, 0x00000006, 0x0004002b, 0x00000010, 0x00000046, 0x00000002, 0x00050036, 0x00000002, - 0x00000004, 0x00000000, 0x00000003, 0x000200f8, 0x00000005, 0x0004003b, 0x00000007, 0x00000008, - 0x00000007, 0x0004003b, 0x00000007, 0x00000019, 0x00000007, 0x0004003b, 0x00000007, 0x0000002c, - 0x00000007, 0x00070041, 0x00000014, 0x00000015, 0x0000000f, 0x00000011, 0x00000012, 0x00000013, - 0x0004003d, 0x00000006, 0x00000016, 0x00000015, 0x000500ab, 0x00000017, 0x00000018, 0x00000016, - 0x00000013, 0x000300f7, 0x0000001b, 0x00000000, 0x000400fa, 0x00000018, 0x0000001a, 0x0000001e, - 0x000200f8, 0x0000001a, 0x00070041, 0x00000014, 0x0000001c, 0x0000000f, 0x00000011, 0x00000012, - 0x00000013, 0x0004003d, 0x00000006, 0x0000001d, 0x0000001c, 0x0003003e, 0x00000019, 0x0000001d, - 0x000200f9, 0x0000001b, 0x000200f8, 0x0000001e, 0x00050041, 0x00000022, 0x00000023, 0x00000021, - 0x00000013, 0x0004003d, 0x00000006, 0x00000024, 0x00000023, 0x00050051, 0x00000006, 0x00000029, - 0x00000028, 0x00000000, 0x00050084, 0x00000006, 0x0000002a, 0x00000024, 0x00000029, 0x0003003e, - 0x00000019, 0x0000002a, 0x000200f9, 0x0000001b, 0x000200f8, 0x0000001b, 0x0004003d, 0x00000006, - 0x0000002b, 0x00000019, 0x0003003e, 0x00000008, 0x0000002b, 0x00050041, 0x00000022, 0x0000002e, - 0x0000002d, 0x00000013, 0x0004003d, 0x00000006, 0x0000002f, 0x0000002e, 0x0003003e, 0x0000002c, - 0x0000002f, 0x0004003d, 0x00000006, 0x00000030, 0x0000002c, 0x0004003d, 0x00000006, 0x00000031, - 0x00000008, 0x000500ae, 0x00000017, 0x00000032, 0x00000030, 0x00000031, 0x000300f7, 0x00000034, - 0x00000000, 0x000400fa, 0x00000032, 0x00000033, 0x00000034, 0x000200f8, 0x00000033, 0x000100fd, - 0x000200f8, 0x00000034, 0x00050041, 0x00000037, 0x00000038, 0x0000000f, 0x00000036, 0x0004003d, - 0x0000000c, 0x00000039, 0x00000038, 0x00040078, 0x0000003a, 0x0000003d, 0x00000039, 0x0004003d, - 0x00000006, 0x0000003e, 0x0000002c, 0x00050041, 0x00000037, 0x0000003f, 0x0000000f, 0x00000012, - 0x0004003d, 0x0000000c, 0x00000040, 0x0000003f, 0x00040078, 0x0000003a, 0x00000041, 0x00000040, - 0x0004003d, 0x00000006, 0x00000042, 0x0000002c, 0x00060041, 0x00000043, 0x00000044, 0x00000041, - 0x00000011, 0x00000042, 0x0006003d, 0x00000006, 0x00000045, 0x00000044, 0x00000002, 0x00000004, - 0x00050041, 0x00000037, 0x00000047, 0x0000000f, 0x00000046, 0x0004003d, 0x0000000c, 0x00000048, - 0x00000047, 0x00040078, 0x0000003a, 0x00000049, 0x00000048, 0x0004003d, 0x00000006, 0x0000004a, - 0x0000002c, 0x00060041, 0x00000043, 0x0000004b, 0x00000049, 0x00000011, 0x0000004a, 0x0006003d, - 0x00000006, 0x0000004c, 0x0000004b, 0x00000002, 0x00000004, 0x00050080, 0x00000006, 0x0000004d, - 0x00000045, 0x0000004c, 0x00060041, 0x00000043, 0x0000004e, 0x0000003d, 0x00000011, 0x0000003e, - 0x0005003e, 0x0000004e, 0x0000004d, 0x00000002, 0x00000004, 0x000100fd, 0x00010038, + 0x0000000c, 0x0005002b, 0x0000000c, 0x0000003a, 0x80000000, 0x00000000, 0x00030027, 0x0000003c, + 0x000014e5, 0x0003001d, 0x0000003d, 0x00000006, 0x0003001e, 0x0000003e, 0x0000003d, 0x00040020, + 0x0000003c, 0x000014e5, 0x0000003e, 0x00040020, 0x00000046, 0x000014e5, 0x00000006, 0x0004002b, + 0x00000010, 0x00000049, 0x00000002, 0x00050036, 0x00000002, 0x00000004, 0x00000000, 0x00000003, + 0x000200f8, 0x00000005, 0x0004003b, 0x00000007, 0x00000008, 0x00000007, 0x0004003b, 0x00000007, + 0x00000019, 0x00000007, 0x0004003b, 0x00000007, 0x0000002c, 0x00000007, 0x00070041, 0x00000014, + 0x00000015, 0x0000000f, 0x00000011, 0x00000012, 0x00000013, 0x0004003d, 0x00000006, 0x00000016, + 0x00000015, 0x000500ab, 0x00000017, 0x00000018, 0x00000016, 0x00000013, 0x000300f7, 0x0000001b, + 0x00000000, 0x000400fa, 0x00000018, 0x0000001a, 0x0000001e, 0x000200f8, 0x0000001a, 0x00070041, + 0x00000014, 0x0000001c, 0x0000000f, 0x00000011, 0x00000012, 0x00000013, 0x0004003d, 0x00000006, + 0x0000001d, 0x0000001c, 0x0003003e, 0x00000019, 0x0000001d, 0x000200f9, 0x0000001b, 0x000200f8, + 0x0000001e, 0x00050041, 0x00000022, 0x00000023, 0x00000021, 0x00000013, 0x0004003d, 0x00000006, + 0x00000024, 0x00000023, 0x00050051, 0x00000006, 0x00000029, 0x00000028, 0x00000000, 0x00050084, + 0x00000006, 0x0000002a, 0x00000024, 0x00000029, 0x0003003e, 0x00000019, 0x0000002a, 0x000200f9, + 0x0000001b, 0x000200f8, 0x0000001b, 0x0004003d, 0x00000006, 0x0000002b, 0x00000019, 0x0003003e, + 0x00000008, 0x0000002b, 0x00050041, 0x00000022, 0x0000002e, 0x0000002d, 0x00000013, 0x0004003d, + 0x00000006, 0x0000002f, 0x0000002e, 0x0003003e, 0x0000002c, 0x0000002f, 0x0004003d, 0x00000006, + 0x00000030, 0x0000002c, 0x0004003d, 0x00000006, 0x00000031, 0x00000008, 0x000500ae, 0x00000017, + 0x00000032, 0x00000030, 0x00000031, 0x000300f7, 0x00000034, 0x00000000, 0x000400fa, 0x00000032, + 0x00000033, 0x00000034, 0x000200f8, 0x00000033, 0x000100fd, 0x000200f8, 0x00000034, 0x00050041, + 0x00000037, 0x00000038, 0x0000000f, 0x00000036, 0x0004003d, 0x0000000c, 0x00000039, 0x00000038, + 0x00050080, 0x0000000c, 0x0000003b, 0x00000039, 0x0000003a, 0x00040078, 0x0000003c, 0x0000003f, + 0x0000003b, 0x0004003d, 0x00000006, 0x00000040, 0x0000002c, 0x00050041, 0x00000037, 0x00000041, + 0x0000000f, 0x00000012, 0x0004003d, 0x0000000c, 0x00000042, 0x00000041, 0x00050080, 0x0000000c, + 0x00000043, 0x00000042, 0x0000003a, 0x00040078, 0x0000003c, 0x00000044, 0x00000043, 0x0004003d, + 0x00000006, 0x00000045, 0x0000002c, 0x00060041, 0x00000046, 0x00000047, 0x00000044, 0x00000011, + 0x00000045, 0x0006003d, 0x00000006, 0x00000048, 0x00000047, 0x00000002, 0x00000004, 0x00050041, + 0x00000037, 0x0000004a, 0x0000000f, 0x00000049, 0x0004003d, 0x0000000c, 0x0000004b, 0x0000004a, + 0x00050080, 0x0000000c, 0x0000004c, 0x0000004b, 0x0000003a, 0x00040078, 0x0000003c, 0x0000004d, + 0x0000004c, 0x0004003d, 0x00000006, 0x0000004e, 0x0000002c, 0x00060041, 0x00000046, 0x0000004f, + 0x0000004d, 0x00000011, 0x0000004e, 0x0006003d, 0x00000006, 0x00000050, 0x0000004f, 0x00000002, + 0x00000004, 0x00050080, 0x00000006, 0x00000051, 0x00000048, 0x00000050, 0x00060041, 0x00000046, + 0x00000052, 0x0000003f, 0x00000011, 0x00000040, 0x0005003e, 0x00000052, 0x00000051, 0x00000002, + 0x00000004, 0x000100fd, 0x00010038, ]; /// A kernel that reads and writes one buffer: `x[i] = x[i] * 2 + 1` below the grid. @@ -101,15 +106,16 @@ pub(crate) const ADD: [u32; 535] = [ /// layout(local_size_x_id = 0, local_size_y_id = 1, local_size_z_id = 2) in; /// layout(buffer_reference, std430, buffer_reference_align = 4) buffer Words { uint w[]; }; /// layout(push_constant, std430) uniform Params { uvec4 region[2]; uint64_t x; } p; +/// const uint64_t BIAS = 0x80000000ul; /// void main() { /// uint i = gl_GlobalInvocationID.x; /// if (i >= p.region[1].x) return; -/// Words(p.x).w[i] = Words(p.x).w[i] * 2u + 1u; +/// Words(p.x + BIAS).w[i] = Words(p.x + BIAS).w[i] * 2u + 1u; /// } /// ``` #[rustfmt::skip] -pub(crate) const STEP: [u32; 390] = [ - 0x07230203, 0x00010500, 0x0008000b, 0x0000003a, 0x00000000, 0x00020011, 0x00000001, 0x00020011, +pub(crate) const STEP: [u32; 405] = [ + 0x07230203, 0x00010500, 0x0008000b, 0x0000003d, 0x00000000, 0x00020011, 0x00000001, 0x00020011, 0x0000000b, 0x00020011, 0x000014e3, 0x0006000b, 0x00000001, 0x4c534c47, 0x6474732e, 0x3035342e, 0x00000000, 0x0003000e, 0x000014e4, 0x00000001, 0x0007000f, 0x00000005, 0x00000004, 0x6e69616d, 0x00000000, 0x0000000b, 0x00000017, 0x00060010, 0x00000004, 0x00000011, 0x00000001, 0x00000001, @@ -120,13 +126,13 @@ pub(crate) const STEP: [u32; 390] = [ 0x0000000b, 0x475f6c67, 0x61626f6c, 0x766e496c, 0x7461636f, 0x496e6f69, 0x00000044, 0x00040005, 0x00000015, 0x61726150, 0x0000736d, 0x00050006, 0x00000015, 0x00000000, 0x69676572, 0x00006e6f, 0x00040006, 0x00000015, 0x00000001, 0x00000078, 0x00030005, 0x00000017, 0x00000070, 0x00040005, - 0x00000028, 0x64726f57, 0x00000073, 0x00040006, 0x00000028, 0x00000000, 0x00000077, 0x00040047, + 0x0000002a, 0x64726f57, 0x00000073, 0x00040006, 0x0000002a, 0x00000000, 0x00000077, 0x00040047, 0x0000000b, 0x0000000b, 0x0000001c, 0x00040047, 0x00000013, 0x00000006, 0x00000010, 0x00030047, 0x00000015, 0x00000002, 0x00050048, 0x00000015, 0x00000000, 0x00000023, 0x00000000, 0x00050048, - 0x00000015, 0x00000001, 0x00000023, 0x00000020, 0x00040047, 0x00000027, 0x00000006, 0x00000004, - 0x00030047, 0x00000028, 0x00000002, 0x00050048, 0x00000028, 0x00000000, 0x00000023, 0x00000000, - 0x00040047, 0x00000036, 0x00000001, 0x00000000, 0x00040047, 0x00000037, 0x00000001, 0x00000001, - 0x00040047, 0x00000038, 0x00000001, 0x00000002, 0x00040047, 0x00000039, 0x0000000b, 0x00000019, + 0x00000015, 0x00000001, 0x00000023, 0x00000020, 0x00040047, 0x00000029, 0x00000006, 0x00000004, + 0x00030047, 0x0000002a, 0x00000002, 0x00050048, 0x0000002a, 0x00000000, 0x00000023, 0x00000000, + 0x00040047, 0x00000039, 0x00000001, 0x00000000, 0x00040047, 0x0000003a, 0x00000001, 0x00000001, + 0x00040047, 0x0000003b, 0x00000001, 0x00000002, 0x00040047, 0x0000003c, 0x0000000b, 0x00000019, 0x00020013, 0x00000002, 0x00030021, 0x00000003, 0x00000002, 0x00040015, 0x00000006, 0x00000020, 0x00000000, 0x00040020, 0x00000007, 0x00000007, 0x00000006, 0x00040017, 0x00000009, 0x00000006, 0x00000003, 0x00040020, 0x0000000a, 0x00000001, 0x00000009, 0x0004003b, 0x0000000a, 0x0000000b, @@ -137,27 +143,29 @@ pub(crate) const STEP: [u32; 390] = [ 0x00000015, 0x0004003b, 0x00000016, 0x00000017, 0x00000009, 0x00040015, 0x00000018, 0x00000020, 0x00000001, 0x0004002b, 0x00000018, 0x00000019, 0x00000000, 0x0004002b, 0x00000018, 0x0000001a, 0x00000001, 0x00040020, 0x0000001b, 0x00000009, 0x00000006, 0x00020014, 0x0000001e, 0x00040020, - 0x00000023, 0x00000009, 0x00000014, 0x00030027, 0x00000026, 0x000014e5, 0x0003001d, 0x00000027, - 0x00000006, 0x0003001e, 0x00000028, 0x00000027, 0x00040020, 0x00000026, 0x000014e5, 0x00000028, - 0x00040020, 0x0000002f, 0x000014e5, 0x00000006, 0x0004002b, 0x00000006, 0x00000033, 0x00000001, - 0x00040032, 0x00000006, 0x00000036, 0x00000001, 0x00040032, 0x00000006, 0x00000037, 0x00000001, - 0x00040032, 0x00000006, 0x00000038, 0x00000001, 0x00060033, 0x00000009, 0x00000039, 0x00000036, - 0x00000037, 0x00000038, 0x00050036, 0x00000002, 0x00000004, 0x00000000, 0x00000003, 0x000200f8, - 0x00000005, 0x0004003b, 0x00000007, 0x00000008, 0x00000007, 0x00050041, 0x0000000d, 0x0000000e, - 0x0000000b, 0x0000000c, 0x0004003d, 0x00000006, 0x0000000f, 0x0000000e, 0x0003003e, 0x00000008, - 0x0000000f, 0x0004003d, 0x00000006, 0x00000010, 0x00000008, 0x00070041, 0x0000001b, 0x0000001c, - 0x00000017, 0x00000019, 0x0000001a, 0x0000000c, 0x0004003d, 0x00000006, 0x0000001d, 0x0000001c, - 0x000500ae, 0x0000001e, 0x0000001f, 0x00000010, 0x0000001d, 0x000300f7, 0x00000021, 0x00000000, - 0x000400fa, 0x0000001f, 0x00000020, 0x00000021, 0x000200f8, 0x00000020, 0x000100fd, 0x000200f8, - 0x00000021, 0x00050041, 0x00000023, 0x00000024, 0x00000017, 0x0000001a, 0x0004003d, 0x00000014, - 0x00000025, 0x00000024, 0x00040078, 0x00000026, 0x00000029, 0x00000025, 0x0004003d, 0x00000006, - 0x0000002a, 0x00000008, 0x00050041, 0x00000023, 0x0000002b, 0x00000017, 0x0000001a, 0x0004003d, - 0x00000014, 0x0000002c, 0x0000002b, 0x00040078, 0x00000026, 0x0000002d, 0x0000002c, 0x0004003d, - 0x00000006, 0x0000002e, 0x00000008, 0x00060041, 0x0000002f, 0x00000030, 0x0000002d, 0x00000019, - 0x0000002e, 0x0006003d, 0x00000006, 0x00000031, 0x00000030, 0x00000002, 0x00000004, 0x00050084, - 0x00000006, 0x00000032, 0x00000031, 0x00000012, 0x00050080, 0x00000006, 0x00000034, 0x00000032, - 0x00000033, 0x00060041, 0x0000002f, 0x00000035, 0x00000029, 0x00000019, 0x0000002a, 0x0005003e, - 0x00000035, 0x00000034, 0x00000002, 0x00000004, 0x000100fd, 0x00010038, + 0x00000023, 0x00000009, 0x00000014, 0x0005002b, 0x00000014, 0x00000026, 0x80000000, 0x00000000, + 0x00030027, 0x00000028, 0x000014e5, 0x0003001d, 0x00000029, 0x00000006, 0x0003001e, 0x0000002a, + 0x00000029, 0x00040020, 0x00000028, 0x000014e5, 0x0000002a, 0x00040020, 0x00000032, 0x000014e5, + 0x00000006, 0x0004002b, 0x00000006, 0x00000036, 0x00000001, 0x00040032, 0x00000006, 0x00000039, + 0x00000001, 0x00040032, 0x00000006, 0x0000003a, 0x00000001, 0x00040032, 0x00000006, 0x0000003b, + 0x00000001, 0x00060033, 0x00000009, 0x0000003c, 0x00000039, 0x0000003a, 0x0000003b, 0x00050036, + 0x00000002, 0x00000004, 0x00000000, 0x00000003, 0x000200f8, 0x00000005, 0x0004003b, 0x00000007, + 0x00000008, 0x00000007, 0x00050041, 0x0000000d, 0x0000000e, 0x0000000b, 0x0000000c, 0x0004003d, + 0x00000006, 0x0000000f, 0x0000000e, 0x0003003e, 0x00000008, 0x0000000f, 0x0004003d, 0x00000006, + 0x00000010, 0x00000008, 0x00070041, 0x0000001b, 0x0000001c, 0x00000017, 0x00000019, 0x0000001a, + 0x0000000c, 0x0004003d, 0x00000006, 0x0000001d, 0x0000001c, 0x000500ae, 0x0000001e, 0x0000001f, + 0x00000010, 0x0000001d, 0x000300f7, 0x00000021, 0x00000000, 0x000400fa, 0x0000001f, 0x00000020, + 0x00000021, 0x000200f8, 0x00000020, 0x000100fd, 0x000200f8, 0x00000021, 0x00050041, 0x00000023, + 0x00000024, 0x00000017, 0x0000001a, 0x0004003d, 0x00000014, 0x00000025, 0x00000024, 0x00050080, + 0x00000014, 0x00000027, 0x00000025, 0x00000026, 0x00040078, 0x00000028, 0x0000002b, 0x00000027, + 0x0004003d, 0x00000006, 0x0000002c, 0x00000008, 0x00050041, 0x00000023, 0x0000002d, 0x00000017, + 0x0000001a, 0x0004003d, 0x00000014, 0x0000002e, 0x0000002d, 0x00050080, 0x00000014, 0x0000002f, + 0x0000002e, 0x00000026, 0x00040078, 0x00000028, 0x00000030, 0x0000002f, 0x0004003d, 0x00000006, + 0x00000031, 0x00000008, 0x00060041, 0x00000032, 0x00000033, 0x00000030, 0x00000019, 0x00000031, + 0x0006003d, 0x00000006, 0x00000034, 0x00000033, 0x00000002, 0x00000004, 0x00050084, 0x00000006, + 0x00000035, 0x00000034, 0x00000012, 0x00050080, 0x00000006, 0x00000037, 0x00000035, 0x00000036, + 0x00060041, 0x00000032, 0x00000038, 0x0000002b, 0x00000019, 0x0000002c, 0x0005003e, 0x00000038, + 0x00000037, 0x00000002, 0x00000004, 0x000100fd, 0x00010038, ]; /// A kernel over sixteen buffers, eleven of their addresses in the push window and five in @@ -171,19 +179,20 @@ pub(crate) const STEP: [u32; 390] = [ /// layout(buffer_reference, std430, buffer_reference_align = 4) buffer Words { uint w[]; }; /// layout(buffer_reference, std430, buffer_reference_align = 16) buffer Block { uint64_t s[5]; }; /// layout(push_constant, std430) uniform Params { uvec4 region[2]; uint64_t block; uint64_t s[11]; } p; +/// const uint64_t BIAS = 0x80000000ul; /// void main() { /// uint i = gl_GlobalInvocationID.x; /// if (i >= p.region[1].x) return; /// uint sum = 0u; -/// for (int k = 0; k < 11; k++) sum += Words(p.s[k]).w[i]; +/// for (int k = 0; k < 11; k++) sum += Words(p.s[k] + BIAS).w[i]; /// Block b = Block(p.block); -/// for (int k = 0; k < 4; k++) sum += Words(b.s[k]).w[i]; -/// Words(b.s[4]).w[i] = sum; +/// for (int k = 0; k < 4; k++) sum += Words(b.s[k] + BIAS).w[i]; +/// Words(b.s[4] + BIAS).w[i] = sum; /// } /// ``` #[rustfmt::skip] -pub(crate) const WIDE: [u32; 691] = [ - 0x07230203, 0x00010500, 0x0008000b, 0x0000006b, 0x00000000, 0x00020011, 0x00000001, 0x00020011, +pub(crate) const WIDE: [u32; 711] = [ + 0x07230203, 0x00010500, 0x0008000b, 0x0000006f, 0x00000000, 0x00020011, 0x00000001, 0x00020011, 0x0000000b, 0x00020011, 0x000014e3, 0x0006000b, 0x00000001, 0x4c534c47, 0x6474732e, 0x3035342e, 0x00000000, 0x0003000e, 0x000014e4, 0x00000001, 0x0007000f, 0x00000005, 0x00000004, 0x6e69616d, 0x00000000, 0x0000000b, 0x00000019, 0x00060010, 0x00000004, 0x00000011, 0x00000001, 0x00000001, @@ -195,18 +204,18 @@ pub(crate) const WIDE: [u32; 691] = [ 0x00000017, 0x61726150, 0x0000736d, 0x00050006, 0x00000017, 0x00000000, 0x69676572, 0x00006e6f, 0x00050006, 0x00000017, 0x00000001, 0x636f6c62, 0x0000006b, 0x00040006, 0x00000017, 0x00000002, 0x00000073, 0x00030005, 0x00000019, 0x00000070, 0x00030005, 0x00000025, 0x006d7573, 0x00030005, - 0x00000027, 0x0000006b, 0x00040005, 0x00000037, 0x64726f57, 0x00000073, 0x00040006, 0x00000037, - 0x00000000, 0x00000077, 0x00040005, 0x00000044, 0x636f6c42, 0x0000006b, 0x00040006, 0x00000044, - 0x00000000, 0x00000073, 0x00030005, 0x00000046, 0x00000062, 0x00030005, 0x0000004a, 0x0000006b, + 0x00000027, 0x0000006b, 0x00040005, 0x00000039, 0x64726f57, 0x00000073, 0x00040006, 0x00000039, + 0x00000000, 0x00000077, 0x00040005, 0x00000046, 0x636f6c42, 0x0000006b, 0x00040006, 0x00000046, + 0x00000000, 0x00000073, 0x00030005, 0x00000048, 0x00000062, 0x00030005, 0x0000004c, 0x0000006b, 0x00040047, 0x0000000b, 0x0000000b, 0x0000001c, 0x00040047, 0x00000013, 0x00000006, 0x00000010, 0x00040047, 0x00000016, 0x00000006, 0x00000008, 0x00030047, 0x00000017, 0x00000002, 0x00050048, 0x00000017, 0x00000000, 0x00000023, 0x00000000, 0x00050048, 0x00000017, 0x00000001, 0x00000023, - 0x00000020, 0x00050048, 0x00000017, 0x00000002, 0x00000023, 0x00000028, 0x00040047, 0x00000036, - 0x00000006, 0x00000004, 0x00030047, 0x00000037, 0x00000002, 0x00050048, 0x00000037, 0x00000000, - 0x00000023, 0x00000000, 0x00040047, 0x00000043, 0x00000006, 0x00000008, 0x00030047, 0x00000044, - 0x00000002, 0x00050048, 0x00000044, 0x00000000, 0x00000023, 0x00000000, 0x00030047, 0x00000046, - 0x000014ec, 0x00040047, 0x00000067, 0x00000001, 0x00000000, 0x00040047, 0x00000068, 0x00000001, - 0x00000001, 0x00040047, 0x00000069, 0x00000001, 0x00000002, 0x00040047, 0x0000006a, 0x0000000b, + 0x00000020, 0x00050048, 0x00000017, 0x00000002, 0x00000023, 0x00000028, 0x00040047, 0x00000038, + 0x00000006, 0x00000004, 0x00030047, 0x00000039, 0x00000002, 0x00050048, 0x00000039, 0x00000000, + 0x00000023, 0x00000000, 0x00040047, 0x00000045, 0x00000006, 0x00000008, 0x00030047, 0x00000046, + 0x00000002, 0x00050048, 0x00000046, 0x00000000, 0x00000023, 0x00000000, 0x00030047, 0x00000048, + 0x000014ec, 0x00040047, 0x0000006b, 0x00000001, 0x00000000, 0x00040047, 0x0000006c, 0x00000001, + 0x00000001, 0x00040047, 0x0000006d, 0x00000001, 0x00000002, 0x00040047, 0x0000006e, 0x0000000b, 0x00000019, 0x00020013, 0x00000002, 0x00030021, 0x00000003, 0x00000002, 0x00040015, 0x00000006, 0x00000020, 0x00000000, 0x00040020, 0x00000007, 0x00000007, 0x00000006, 0x00040017, 0x00000009, 0x00000006, 0x00000003, 0x00040020, 0x0000000a, 0x00000001, 0x00000009, 0x0004003b, 0x0000000a, @@ -220,54 +229,56 @@ pub(crate) const WIDE: [u32; 691] = [ 0x0000001a, 0x0000001c, 0x00000001, 0x00040020, 0x0000001d, 0x00000009, 0x00000006, 0x00020014, 0x00000020, 0x00040020, 0x00000026, 0x00000007, 0x0000001a, 0x0004002b, 0x0000001a, 0x0000002e, 0x0000000b, 0x0004002b, 0x0000001a, 0x00000030, 0x00000002, 0x00040020, 0x00000032, 0x00000009, - 0x00000014, 0x00030027, 0x00000035, 0x000014e5, 0x0003001d, 0x00000036, 0x00000006, 0x0003001e, - 0x00000037, 0x00000036, 0x00040020, 0x00000035, 0x000014e5, 0x00000037, 0x00040020, 0x0000003a, - 0x000014e5, 0x00000006, 0x00030027, 0x00000041, 0x000014e5, 0x0004002b, 0x00000006, 0x00000042, - 0x00000005, 0x0004001c, 0x00000043, 0x00000014, 0x00000042, 0x0003001e, 0x00000044, 0x00000043, - 0x00040020, 0x00000041, 0x000014e5, 0x00000044, 0x00040020, 0x00000045, 0x00000007, 0x00000041, - 0x0004002b, 0x0000001a, 0x00000051, 0x00000004, 0x00040020, 0x00000055, 0x000014e5, 0x00000014, - 0x00040032, 0x00000006, 0x00000067, 0x00000001, 0x00040032, 0x00000006, 0x00000068, 0x00000001, - 0x00040032, 0x00000006, 0x00000069, 0x00000001, 0x00060033, 0x00000009, 0x0000006a, 0x00000067, - 0x00000068, 0x00000069, 0x00050036, 0x00000002, 0x00000004, 0x00000000, 0x00000003, 0x000200f8, - 0x00000005, 0x0004003b, 0x00000007, 0x00000008, 0x00000007, 0x0004003b, 0x00000007, 0x00000025, - 0x00000007, 0x0004003b, 0x00000026, 0x00000027, 0x00000007, 0x0004003b, 0x00000045, 0x00000046, - 0x00000007, 0x0004003b, 0x00000026, 0x0000004a, 0x00000007, 0x00050041, 0x0000000d, 0x0000000e, - 0x0000000b, 0x0000000c, 0x0004003d, 0x00000006, 0x0000000f, 0x0000000e, 0x0003003e, 0x00000008, - 0x0000000f, 0x0004003d, 0x00000006, 0x00000010, 0x00000008, 0x00070041, 0x0000001d, 0x0000001e, - 0x00000019, 0x0000001b, 0x0000001c, 0x0000000c, 0x0004003d, 0x00000006, 0x0000001f, 0x0000001e, - 0x000500ae, 0x00000020, 0x00000021, 0x00000010, 0x0000001f, 0x000300f7, 0x00000023, 0x00000000, - 0x000400fa, 0x00000021, 0x00000022, 0x00000023, 0x000200f8, 0x00000022, 0x000100fd, 0x000200f8, - 0x00000023, 0x0003003e, 0x00000025, 0x0000000c, 0x0003003e, 0x00000027, 0x0000001b, 0x000200f9, - 0x00000028, 0x000200f8, 0x00000028, 0x000400f6, 0x0000002a, 0x0000002b, 0x00000000, 0x000200f9, - 0x0000002c, 0x000200f8, 0x0000002c, 0x0004003d, 0x0000001a, 0x0000002d, 0x00000027, 0x000500b1, - 0x00000020, 0x0000002f, 0x0000002d, 0x0000002e, 0x000400fa, 0x0000002f, 0x00000029, 0x0000002a, - 0x000200f8, 0x00000029, 0x0004003d, 0x0000001a, 0x00000031, 0x00000027, 0x00060041, 0x00000032, - 0x00000033, 0x00000019, 0x00000030, 0x00000031, 0x0004003d, 0x00000014, 0x00000034, 0x00000033, - 0x00040078, 0x00000035, 0x00000038, 0x00000034, 0x0004003d, 0x00000006, 0x00000039, 0x00000008, - 0x00060041, 0x0000003a, 0x0000003b, 0x00000038, 0x0000001b, 0x00000039, 0x0006003d, 0x00000006, - 0x0000003c, 0x0000003b, 0x00000002, 0x00000004, 0x0004003d, 0x00000006, 0x0000003d, 0x00000025, - 0x00050080, 0x00000006, 0x0000003e, 0x0000003d, 0x0000003c, 0x0003003e, 0x00000025, 0x0000003e, - 0x000200f9, 0x0000002b, 0x000200f8, 0x0000002b, 0x0004003d, 0x0000001a, 0x0000003f, 0x00000027, - 0x00050080, 0x0000001a, 0x00000040, 0x0000003f, 0x0000001c, 0x0003003e, 0x00000027, 0x00000040, - 0x000200f9, 0x00000028, 0x000200f8, 0x0000002a, 0x00050041, 0x00000032, 0x00000047, 0x00000019, - 0x0000001c, 0x0004003d, 0x00000014, 0x00000048, 0x00000047, 0x00040078, 0x00000041, 0x00000049, - 0x00000048, 0x0003003e, 0x00000046, 0x00000049, 0x0003003e, 0x0000004a, 0x0000001b, 0x000200f9, - 0x0000004b, 0x000200f8, 0x0000004b, 0x000400f6, 0x0000004d, 0x0000004e, 0x00000000, 0x000200f9, - 0x0000004f, 0x000200f8, 0x0000004f, 0x0004003d, 0x0000001a, 0x00000050, 0x0000004a, 0x000500b1, - 0x00000020, 0x00000052, 0x00000050, 0x00000051, 0x000400fa, 0x00000052, 0x0000004c, 0x0000004d, - 0x000200f8, 0x0000004c, 0x0004003d, 0x00000041, 0x00000053, 0x00000046, 0x0004003d, 0x0000001a, - 0x00000054, 0x0000004a, 0x00060041, 0x00000055, 0x00000056, 0x00000053, 0x0000001b, 0x00000054, - 0x0006003d, 0x00000014, 0x00000057, 0x00000056, 0x00000002, 0x00000008, 0x00040078, 0x00000035, - 0x00000058, 0x00000057, 0x0004003d, 0x00000006, 0x00000059, 0x00000008, 0x00060041, 0x0000003a, - 0x0000005a, 0x00000058, 0x0000001b, 0x00000059, 0x0006003d, 0x00000006, 0x0000005b, 0x0000005a, - 0x00000002, 0x00000004, 0x0004003d, 0x00000006, 0x0000005c, 0x00000025, 0x00050080, 0x00000006, - 0x0000005d, 0x0000005c, 0x0000005b, 0x0003003e, 0x00000025, 0x0000005d, 0x000200f9, 0x0000004e, - 0x000200f8, 0x0000004e, 0x0004003d, 0x0000001a, 0x0000005e, 0x0000004a, 0x00050080, 0x0000001a, - 0x0000005f, 0x0000005e, 0x0000001c, 0x0003003e, 0x0000004a, 0x0000005f, 0x000200f9, 0x0000004b, - 0x000200f8, 0x0000004d, 0x0004003d, 0x00000041, 0x00000060, 0x00000046, 0x00060041, 0x00000055, - 0x00000061, 0x00000060, 0x0000001b, 0x00000051, 0x0006003d, 0x00000014, 0x00000062, 0x00000061, - 0x00000002, 0x00000008, 0x00040078, 0x00000035, 0x00000063, 0x00000062, 0x0004003d, 0x00000006, - 0x00000064, 0x00000008, 0x0004003d, 0x00000006, 0x00000065, 0x00000025, 0x00060041, 0x0000003a, - 0x00000066, 0x00000063, 0x0000001b, 0x00000064, 0x0005003e, 0x00000066, 0x00000065, 0x00000002, - 0x00000004, 0x000100fd, 0x00010038, + 0x00000014, 0x0005002b, 0x00000014, 0x00000035, 0x80000000, 0x00000000, 0x00030027, 0x00000037, + 0x000014e5, 0x0003001d, 0x00000038, 0x00000006, 0x0003001e, 0x00000039, 0x00000038, 0x00040020, + 0x00000037, 0x000014e5, 0x00000039, 0x00040020, 0x0000003c, 0x000014e5, 0x00000006, 0x00030027, + 0x00000043, 0x000014e5, 0x0004002b, 0x00000006, 0x00000044, 0x00000005, 0x0004001c, 0x00000045, + 0x00000014, 0x00000044, 0x0003001e, 0x00000046, 0x00000045, 0x00040020, 0x00000043, 0x000014e5, + 0x00000046, 0x00040020, 0x00000047, 0x00000007, 0x00000043, 0x0004002b, 0x0000001a, 0x00000053, + 0x00000004, 0x00040020, 0x00000057, 0x000014e5, 0x00000014, 0x00040032, 0x00000006, 0x0000006b, + 0x00000001, 0x00040032, 0x00000006, 0x0000006c, 0x00000001, 0x00040032, 0x00000006, 0x0000006d, + 0x00000001, 0x00060033, 0x00000009, 0x0000006e, 0x0000006b, 0x0000006c, 0x0000006d, 0x00050036, + 0x00000002, 0x00000004, 0x00000000, 0x00000003, 0x000200f8, 0x00000005, 0x0004003b, 0x00000007, + 0x00000008, 0x00000007, 0x0004003b, 0x00000007, 0x00000025, 0x00000007, 0x0004003b, 0x00000026, + 0x00000027, 0x00000007, 0x0004003b, 0x00000047, 0x00000048, 0x00000007, 0x0004003b, 0x00000026, + 0x0000004c, 0x00000007, 0x00050041, 0x0000000d, 0x0000000e, 0x0000000b, 0x0000000c, 0x0004003d, + 0x00000006, 0x0000000f, 0x0000000e, 0x0003003e, 0x00000008, 0x0000000f, 0x0004003d, 0x00000006, + 0x00000010, 0x00000008, 0x00070041, 0x0000001d, 0x0000001e, 0x00000019, 0x0000001b, 0x0000001c, + 0x0000000c, 0x0004003d, 0x00000006, 0x0000001f, 0x0000001e, 0x000500ae, 0x00000020, 0x00000021, + 0x00000010, 0x0000001f, 0x000300f7, 0x00000023, 0x00000000, 0x000400fa, 0x00000021, 0x00000022, + 0x00000023, 0x000200f8, 0x00000022, 0x000100fd, 0x000200f8, 0x00000023, 0x0003003e, 0x00000025, + 0x0000000c, 0x0003003e, 0x00000027, 0x0000001b, 0x000200f9, 0x00000028, 0x000200f8, 0x00000028, + 0x000400f6, 0x0000002a, 0x0000002b, 0x00000000, 0x000200f9, 0x0000002c, 0x000200f8, 0x0000002c, + 0x0004003d, 0x0000001a, 0x0000002d, 0x00000027, 0x000500b1, 0x00000020, 0x0000002f, 0x0000002d, + 0x0000002e, 0x000400fa, 0x0000002f, 0x00000029, 0x0000002a, 0x000200f8, 0x00000029, 0x0004003d, + 0x0000001a, 0x00000031, 0x00000027, 0x00060041, 0x00000032, 0x00000033, 0x00000019, 0x00000030, + 0x00000031, 0x0004003d, 0x00000014, 0x00000034, 0x00000033, 0x00050080, 0x00000014, 0x00000036, + 0x00000034, 0x00000035, 0x00040078, 0x00000037, 0x0000003a, 0x00000036, 0x0004003d, 0x00000006, + 0x0000003b, 0x00000008, 0x00060041, 0x0000003c, 0x0000003d, 0x0000003a, 0x0000001b, 0x0000003b, + 0x0006003d, 0x00000006, 0x0000003e, 0x0000003d, 0x00000002, 0x00000004, 0x0004003d, 0x00000006, + 0x0000003f, 0x00000025, 0x00050080, 0x00000006, 0x00000040, 0x0000003f, 0x0000003e, 0x0003003e, + 0x00000025, 0x00000040, 0x000200f9, 0x0000002b, 0x000200f8, 0x0000002b, 0x0004003d, 0x0000001a, + 0x00000041, 0x00000027, 0x00050080, 0x0000001a, 0x00000042, 0x00000041, 0x0000001c, 0x0003003e, + 0x00000027, 0x00000042, 0x000200f9, 0x00000028, 0x000200f8, 0x0000002a, 0x00050041, 0x00000032, + 0x00000049, 0x00000019, 0x0000001c, 0x0004003d, 0x00000014, 0x0000004a, 0x00000049, 0x00040078, + 0x00000043, 0x0000004b, 0x0000004a, 0x0003003e, 0x00000048, 0x0000004b, 0x0003003e, 0x0000004c, + 0x0000001b, 0x000200f9, 0x0000004d, 0x000200f8, 0x0000004d, 0x000400f6, 0x0000004f, 0x00000050, + 0x00000000, 0x000200f9, 0x00000051, 0x000200f8, 0x00000051, 0x0004003d, 0x0000001a, 0x00000052, + 0x0000004c, 0x000500b1, 0x00000020, 0x00000054, 0x00000052, 0x00000053, 0x000400fa, 0x00000054, + 0x0000004e, 0x0000004f, 0x000200f8, 0x0000004e, 0x0004003d, 0x00000043, 0x00000055, 0x00000048, + 0x0004003d, 0x0000001a, 0x00000056, 0x0000004c, 0x00060041, 0x00000057, 0x00000058, 0x00000055, + 0x0000001b, 0x00000056, 0x0006003d, 0x00000014, 0x00000059, 0x00000058, 0x00000002, 0x00000008, + 0x00050080, 0x00000014, 0x0000005a, 0x00000059, 0x00000035, 0x00040078, 0x00000037, 0x0000005b, + 0x0000005a, 0x0004003d, 0x00000006, 0x0000005c, 0x00000008, 0x00060041, 0x0000003c, 0x0000005d, + 0x0000005b, 0x0000001b, 0x0000005c, 0x0006003d, 0x00000006, 0x0000005e, 0x0000005d, 0x00000002, + 0x00000004, 0x0004003d, 0x00000006, 0x0000005f, 0x00000025, 0x00050080, 0x00000006, 0x00000060, + 0x0000005f, 0x0000005e, 0x0003003e, 0x00000025, 0x00000060, 0x000200f9, 0x00000050, 0x000200f8, + 0x00000050, 0x0004003d, 0x0000001a, 0x00000061, 0x0000004c, 0x00050080, 0x0000001a, 0x00000062, + 0x00000061, 0x0000001c, 0x0003003e, 0x0000004c, 0x00000062, 0x000200f9, 0x0000004d, 0x000200f8, + 0x0000004f, 0x0004003d, 0x00000043, 0x00000063, 0x00000048, 0x00060041, 0x00000057, 0x00000064, + 0x00000063, 0x0000001b, 0x00000053, 0x0006003d, 0x00000014, 0x00000065, 0x00000064, 0x00000002, + 0x00000008, 0x00050080, 0x00000014, 0x00000066, 0x00000065, 0x00000035, 0x00040078, 0x00000037, + 0x00000067, 0x00000066, 0x0004003d, 0x00000006, 0x00000068, 0x00000008, 0x0004003d, 0x00000006, + 0x00000069, 0x00000025, 0x00060041, 0x0000003c, 0x0000006a, 0x00000067, 0x0000001b, 0x00000068, + 0x0005003e, 0x0000006a, 0x00000069, 0x00000002, 0x00000004, 0x000100fd, 0x00010038, ]; diff --git a/crates/metal2vulkan/src/cache/mod.rs b/crates/metal2vulkan/src/cache/mod.rs index 1bd00ccfe..94fbe224e 100644 --- a/crates/metal2vulkan/src/cache/mod.rs +++ b/crates/metal2vulkan/src/cache/mod.rs @@ -62,7 +62,7 @@ mod tests; /// unchanged version, and its bless records the version. Independent of the crate's version and of /// [`ARTIFACT_FORMAT_VERSION`]. The commit that bumps it says what changed; this comment keeps no /// history. -pub const SEMANTICS_VERSION: u32 = 2186; +pub const SEMANTICS_VERSION: u32 = 2188; /// The byte-layout version of encoded artifacts (`CompiledFunction::to_bytes` and the /// [`PipelineArtifact`] encodings). Every encoded artifact carries it, and a decode under another @@ -72,7 +72,7 @@ pub const SEMANTICS_VERSION: u32 = 2186; /// re-typed in an encoded type, its `codec` body or its `envelope`. A variant removed while its tag /// stays unused needs no bump: an entry holding it fails to decode, which is a miss. The commit that /// bumps it says what changed; this comment keeps no history. -pub const ARTIFACT_FORMAT_VERSION: u32 = 544; +pub const ARTIFACT_FORMAT_VERSION: u32 = 546; /// The version of what this crate's runtime does with a compiled pipeline: instantiating a binding /// plan (`BindingPlan::instantiate_*`: descriptor ranges, push bytes, root, argument, and handle diff --git a/crates/metal2vulkan/src/lower/access/dynamic.rs b/crates/metal2vulkan/src/lower/access/dynamic.rs index a252358ba..7f8bc91d2 100644 --- a/crates/metal2vulkan/src/lower/access/dynamic.rs +++ b/crates/metal2vulkan/src/lower/access/dynamic.rs @@ -1329,8 +1329,7 @@ pub(super) fn static_guest_address( crate::pipeline::interface::Window::Bounded { start, .. } => start, crate::pipeline::interface::Window::Whole => 0, }; - let base = cx.push_field(fb, PushField::SlotGuestBase(choice.slot))?; - let base = super::pointer::slot_guest_base_u64(fb, base)?; + let base = super::pointer::slot_address(cx, fb, choice.slot)?; let disp = super::psb::displacement(fb, m, start)?; let guest = fb.binary(BinOp::IAdd, base, disp)?; let r = k32(fb, t.root)?; diff --git a/crates/metal2vulkan/src/lower/access/emit.rs b/crates/metal2vulkan/src/lower/access/emit.rs index e93810ce6..d76848fb6 100644 --- a/crates/metal2vulkan/src/lower/access/emit.rs +++ b/crates/metal2vulkan/src/lower/access/emit.rs @@ -275,15 +275,20 @@ pub(super) fn prepare( let ops = WordOps::of(crate::lower::sync::memory_model::coherence(cx.plan)); if let Some(SlotLowering::Psb { start }) = lowering { // Under the identity domains a slot whose address the binder holds to its argument's - // alignment is reached from that address as it is, with `uvec2` and `uvec4` units at - // offsets proven multiples of their size; any other from the word below each access. + // alignment is reached from that address as it is (its biased word), with `uvec2` and + // `uvec4` units at offsets proven multiples of their size; any other from the word below + // each access. let aligned = cx.plan.families.access.aligned.contains(&t.slot); let a = if cx.plan.families.access.identity { - let address = cx.push_field(fb, PushField::SlotGuestBase(choice.slot))?; - let address = super::pointer::slot_guest_base_u64(fb, address)?; match aligned { - true => psb::prepare_direct(address, m), - false => psb::prepare_at(fb, address, m, start)?, + true => { + let base = super::pointer::biased_slot_address(cx, fb, choice.slot)?; + psb::prepare_direct(base, m) + } + false => { + let address = super::pointer::slot_address(cx, fb, choice.slot)?; + psb::prepare_at(fb, address, m, start)? + } } } else { let table = cx.push_field(fb, PushField::RootTableAddress)?; diff --git a/crates/metal2vulkan/src/lower/access/mod.rs b/crates/metal2vulkan/src/lower/access/mod.rs index 3fe490848..b3718a746 100644 --- a/crates/metal2vulkan/src/lower/access/mod.rs +++ b/crates/metal2vulkan/src/lower/access/mod.rs @@ -1306,12 +1306,19 @@ impl Census { } /// The field a slot's device address is read from under the identity domains: its Metal address, -/// the bound buffer's `gpuAddress` plus the bind offset, which is its Vulkan device address there -/// (`SlotGuestBase`'s value, a `uvec2`, low word first). +/// the bound buffer's `gpuAddress` plus the bind offset, which is its Vulkan device address there, +/// less [`SLOT_ADDRESS_BIAS`] (`SlotGuestBase`'s value, a `uvec2`, low word first). fn address_field(slot: SlotRef) -> PushField { PushField::SlotGuestBase(slot) } +/// The bias of a buffer slot's `SlotGuestBase` word under the identity domains, 2^31: the runtime +/// pushes the slot's address less it. An access adds its 32-bit byte offset plus the bias to the +/// word, zero-extended ([`psb::prepare_direct`]), which is the address plus the offset read as +/// signed in one 32-bit add, and every other read of the word adds the bias back +/// ([`pointer::slot_address`]). +pub(crate) const SLOT_ADDRESS_BIAS: u64 = 1 << 31; + /// Whether profile `p` takes the identity domains, where a pointer is a device address used /// directly. pub(crate) fn identity(p: &DeviceProfile) -> bool { diff --git a/crates/metal2vulkan/src/lower/access/pointer.rs b/crates/metal2vulkan/src/lower/access/pointer.rs index 6febe4d16..3ddef8b2b 100644 --- a/crates/metal2vulkan/src/lower/access/pointer.rs +++ b/crates/metal2vulkan/src/lower/access/pointer.rs @@ -750,22 +750,39 @@ fn displacement( )?)) } -/// `SlotGuestBase(slot)` (a `uvec2` push field) in the address form. +/// Buffer slot `slot`'s Metal address ([`slot_address`]) in the address form. fn guest_base( cx: &mut EmitCx<'_>, fb: &mut FunctionBuilder<'_>, slot: SlotRef, words: bool, ) -> BResult
{ - let v = cx.push_field(fb, PushField::SlotGuestBase(slot))?; - if words { - return Ok(Address::Words(wide::split(fb, v)?)); + if !words { + return Ok(Address::U64(slot_address(cx, fb, slot)?)); } - Ok(Address::U64(slot_guest_base_u64(fb, v)?)) + let v = cx.push_field(fb, PushField::SlotGuestBase(slot))?; + let word = wide::split(fb, v)?; + if !biased(cx) { + return Ok(Address::Words(word)); + } + let bias = Pair { + lo: k32(fb, super::SLOT_ADDRESS_BIAS as u32)?, + hi: k32(fb, 0)?, + }; + Ok(Address::Words(wide::add(fb, word, bias)?)) } -/// A `SlotGuestBase` field's value (a `uvec2`, low word first) as a `u64` (needs `shaderInt64`). -pub(super) fn slot_guest_base_u64(fb: &mut FunctionBuilder<'_>, v: SValue) -> BResult