Stores by address are bounded: title buffers take the builder's only where it was given them to write
A directory entry says whether stores by address reach its page (translator and host). Faults take at most 128 pages a frame and 8,192 in all; every slot of the copies' run holds a null view until its copy is there; a page is looked at once a frame. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
5b2af05e9a
commit
fbe8ecc617
6 files changed
+136
-46
No files matched your search
@@ -244,7 +244,7 @@ impl<'a> Lower<'a> {
|
||||
let at = self.s.m.select(c, inside, at, outside);
|
||||
return (handle, at);
|
||||
}
|
||||
self.memory(low, high, guard)
|
||||
self.memory(low, high, guard, false)
|
||||
}
|
||||
|
||||
/// `count` dwords of the node from its byte `base` + `offset` (`base`
|
||||
|
||||
@@ -1783,7 +1783,7 @@ impl<'a> Lower<'a> {
|
||||
if let Some(bias) = self.root_bias(a.param) {
|
||||
off = self.s.m.bin(c, Bin::Add, off, bias);
|
||||
}
|
||||
match self.root_memory(&src, off, guard) {
|
||||
match self.root_memory(&src, off, guard, false) {
|
||||
Some((h, byte)) => {
|
||||
off = byte;
|
||||
Some(h)
|
||||
@@ -3013,8 +3013,10 @@ impl<'a> Lower<'a> {
|
||||
/// (and drops writes) through the null view at the first slot, and its
|
||||
/// number is left for the host, for lanes that run (`guard`). Goes on in
|
||||
/// another block.
|
||||
fn memory(&mut self, lo: V, hi: V, guard: Option<V>) -> (V, V) {
|
||||
use super::shader::{MEMORY_FAULTS, MEMORY_PAGES, SLOT_FAULTS, SLOT_MEMORY, USER_MEMORY_BASE};
|
||||
/// With `store`, a page that is not to be written ([`super::shader::MEMORY_READ_ONLY`])
|
||||
/// is the null view.
|
||||
fn memory(&mut self, lo: V, hi: V, guard: Option<V>, store: bool) -> (V, V) {
|
||||
use super::shader::{MEMORY_FAULTS, MEMORY_PAGES, MEMORY_READ_ONLY, SLOT_FAULTS, SLOT_MEMORY, USER_MEMORY_BASE};
|
||||
let c = self.cur;
|
||||
let (i32t, res) = (self.s.t.i32, self.s.t.res_ret);
|
||||
let k = |l: &mut Self, v: u32| l.s.m.i32(v);
|
||||
@@ -3043,7 +3045,9 @@ impl<'a> Lower<'a> {
|
||||
&[directory, at, iu, both, align],
|
||||
);
|
||||
let (copy, start) = (self.s.m.extract(c, entry, 0), self.s.m.extract(c, entry, 1));
|
||||
let (copy, start) = (self.as_int(copy), self.as_int(start));
|
||||
let (number, start) = (self.as_int(copy), self.as_int(start));
|
||||
let mask = k(self, !MEMORY_READ_ONLY);
|
||||
let copy = self.s.m.bin(c, Bin::And, number, mask);
|
||||
// A page without a copy: its number, at a place by the number. In a
|
||||
// branch: the notes lie in the PC's memory, and a store there with
|
||||
// every node of every ray would be most of what a trace does.
|
||||
@@ -3073,6 +3077,12 @@ impl<'a> Lower<'a> {
|
||||
);
|
||||
self.end_guarded(noting, &[]);
|
||||
let c = self.cur;
|
||||
let copy = if store {
|
||||
let closed = self.s.m.cmp(c, pred::SLT, number, zero);
|
||||
self.s.m.select(c, closed, zero, copy)
|
||||
} else {
|
||||
copy
|
||||
};
|
||||
let base = self.host_word(RootType::Other(USER_MEMORY_BASE), 0, 0);
|
||||
let slot = self.s.m.bin(c, Bin::Add, base, copy);
|
||||
// The builder's threads read what others of the dispatch wrote (a
|
||||
@@ -3112,7 +3122,7 @@ impl<'a> Lower<'a> {
|
||||
/// another block.
|
||||
/// shortcut: an access of several dwords is taken not to cross the end
|
||||
/// of a host copy (the builder's records lie on their size).
|
||||
fn root_memory(&mut self, src: &Source, off: V, guard: Option<V>) -> Option<(V, V)> {
|
||||
fn root_memory(&mut self, src: &Source, off: V, guard: Option<V>, store: bool) -> Option<(V, V)> {
|
||||
let (lo, hi) = self.root_address(src)?;
|
||||
let c = self.cur;
|
||||
let i32t = self.s.t.i32;
|
||||
@@ -3123,7 +3133,7 @@ impl<'a> Lower<'a> {
|
||||
let sign = self.s.m.bin(c, Bin::AShr, off, k31);
|
||||
let hi = self.s.m.bin(c, Bin::Add, hi, carry);
|
||||
let hi = self.s.m.bin(c, Bin::Add, hi, sign);
|
||||
let (h, byte) = self.memory(sum, hi, guard);
|
||||
let (h, byte) = self.memory(sum, hi, guard, store);
|
||||
self.root_copy = Some(h);
|
||||
Some((h, byte))
|
||||
}
|
||||
@@ -3173,7 +3183,7 @@ impl<'a> Lower<'a> {
|
||||
let Some(Operand::Vector { reg, .. }) = *dst else {
|
||||
return Err("a global load result");
|
||||
};
|
||||
let (h, byte) = self.memory(lo, hi, guard);
|
||||
let (h, byte) = self.memory(lo, hi, guard, false);
|
||||
let c = self.cur;
|
||||
let mask = self.s.m.i8((1u8 << n) - 1);
|
||||
let r = self.s.op(
|
||||
@@ -3195,7 +3205,7 @@ impl<'a> Lower<'a> {
|
||||
let n = count(rest)?;
|
||||
let d = data.as_ref().ok_or("global store data")?;
|
||||
let vals = self.vgprs(inst, d, n)?;
|
||||
let (h, byte) = self.memory(lo, hi, guard);
|
||||
let (h, byte) = self.memory(lo, hi, guard, true);
|
||||
let mut args = vec![h, byte, iu];
|
||||
args.extend(&vals);
|
||||
args.resize(3 + 4, iu);
|
||||
@@ -3222,7 +3232,7 @@ impl<'a> Lower<'a> {
|
||||
Some(x) => self.i32_of(x)?,
|
||||
None => self.s.m.i32(0),
|
||||
};
|
||||
let (h, byte) = self.memory(lo, hi, guard);
|
||||
let (h, byte) = self.memory(lo, hi, guard, true);
|
||||
let c = self.cur;
|
||||
// DXIL's atomic operations: add 0, and 1, or 2, xor 3, signed
|
||||
// minimum 4 and maximum 5, unsigned 6 and 7, exchange 8.
|
||||
@@ -3357,7 +3367,7 @@ impl<'a> Lower<'a> {
|
||||
for first in (0..count).step_by(4) {
|
||||
let n = (count - first).min(4);
|
||||
let (lo, hi) = self.address_plus(lo, hi, offset + 4 * i32::from(first));
|
||||
let (h, byte) = self.memory(lo, hi, None);
|
||||
let (h, byte) = self.memory(lo, hi, None, false);
|
||||
let c = self.cur;
|
||||
let mask = self.s.m.i8((1u8 << n) - 1);
|
||||
let r = self.s.op(
|
||||
@@ -6004,7 +6014,7 @@ impl<'a> Lower<'a> {
|
||||
return Ok(());
|
||||
}
|
||||
if matches!(kind, Some(u) if u.kind == ResourceType::Srv) {
|
||||
let h = match self.root_memory(src, addr, None) {
|
||||
let h = match self.root_memory(src, addr, None, false) {
|
||||
Some((h, byte)) => {
|
||||
addr = byte;
|
||||
h
|
||||
@@ -11279,7 +11289,7 @@ impl<'a> Lower<'a> {
|
||||
off = self.s.m.bin(c, Bin::Add, element, off);
|
||||
index = None;
|
||||
}
|
||||
if let Some((_, byte)) = self.root_memory(src, off, guard) {
|
||||
if let Some((_, byte)) = self.root_memory(src, off, guard, store || atomic.is_some()) {
|
||||
off = byte;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ pub use sampler::StaticSampler;
|
||||
pub use lower::{host_settings, set_host_max_wave};
|
||||
pub use rect::rect_list_gs;
|
||||
pub use shader::{
|
||||
MEMORY_FAULTS, MEMORY_PAGES, ROOT_CBV_SPACE, SAMPLER_SPACE, SLOT_FAULTS, SLOT_MEMORY, SLOT_STRIDES,
|
||||
MEMORY_FAULTS, MEMORY_PAGES, MEMORY_READ_ONLY, ROOT_CBV_SPACE, SAMPLER_SPACE, SLOT_FAULTS, SLOT_MEMORY, SLOT_STRIDES,
|
||||
SLOT_STRIDES_COUNT, USER_DATA_SPACE, USER_MEMORY_BASE, USER_ROOT_ADDRESS, USER_VIEW_ADDRESS, USER_VIEW_BIAS,
|
||||
raw_views, set_raw_views, set_view_heap_limit, view_heap_limit,
|
||||
};
|
||||
|
||||
@@ -37,7 +37,8 @@ pub const SLOT_STRIDES_COUNT: u32 = 1 << 21;
|
||||
/// - the root SRV `t<SLOT_MEMORY>` in [`ROOT_CBV_SPACE`] is a directory of
|
||||
/// [`MEMORY_PAGES`] entries of two dwords, one per 64 KiB of title
|
||||
/// address space: the number of the host copy holding that page (0: none
|
||||
/// yet) and the page's byte offset in that copy;
|
||||
/// yet; with [`MEMORY_READ_ONLY`]: stores there are dropped) and the page's
|
||||
/// byte offset in that copy;
|
||||
/// - copy `n` is the raw buffer view at view-heap slot `base + n`, `base`
|
||||
/// the user-data dword of kind [`USER_MEMORY_BASE`]; slot `base` itself
|
||||
/// reads zeros and drops writes;
|
||||
@@ -49,6 +50,9 @@ pub const SLOT_MEMORY: u8 = 254;
|
||||
pub const SLOT_FAULTS: u8 = 253;
|
||||
/// Entries of the [`SLOT_MEMORY`] directory: title addresses below 128 GiB.
|
||||
pub const MEMORY_PAGES: u32 = 1 << 21;
|
||||
/// In a directory entry's first dword: shaders do not store there by address
|
||||
/// (a title buffer the structure builder has not been given to write).
|
||||
pub const MEMORY_READ_ONLY: u32 = 1 << 31;
|
||||
/// Dwords of the [`SLOT_FAULTS`] buffer.
|
||||
pub const MEMORY_FAULTS: u32 = 4096;
|
||||
/// `RootType::Other` code of a user-data dword the host computes: the view
|
||||
|
||||
Reference in new issue
Block a user