Merge fork main a26859f (the first room renders right)
Descriptor records the title copies as bytes are mirrored before each submission. Views off their copy's elements: our rule (raw views too, and now typed views on 16 bytes), the fork's copies. Wave sums of halves: ours (the fork's test passes with it). Sizes of descriptors nothing uses: ours, then the fork's for 2D images. The fork's count of cut indirect groups is left out: up to WIDEST groups run as asked here. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
commit
f1650b7e45
13 files changed
+964
-109
No files matched your search
@@ -1087,6 +1087,26 @@ pub fn host_settings() -> [u32; 2] {
|
||||
[host_max_wave(), super::shader::view_heap_limit()]
|
||||
}
|
||||
|
||||
/// The refusal of a first half of an interpolation whose result is read
|
||||
/// as data ([`Lower::interp`]).
|
||||
pub(super) const FIRST_HALF: &str = "the first half of an interpolation";
|
||||
|
||||
thread_local! {
|
||||
/// Whether first halves of interpolations are evaluated as the pair
|
||||
/// they start ([`with_first_half_pairs`]).
|
||||
static FIRST_HALF_PAIRS: std::cell::Cell<bool> = const { std::cell::Cell::new(false) };
|
||||
}
|
||||
|
||||
/// Runs `translate` with first halves of interpolations evaluated as the
|
||||
/// pair they start: the translation of a program refused with
|
||||
/// [`FIRST_HALF`] (`VICTORY_FIRST_HALF=0`: refused again, as before).
|
||||
pub(super) fn with_first_half_pairs<R>(translate: impl FnOnce() -> R) -> R {
|
||||
let before = FIRST_HALF_PAIRS.replace(true);
|
||||
let result = translate();
|
||||
FIRST_HALF_PAIRS.set(before);
|
||||
result
|
||||
}
|
||||
|
||||
pub(super) fn host_max_wave() -> u32 {
|
||||
#[cfg(test)]
|
||||
if let Some(lanes) = TEST_HOST_WAVE.get() {
|
||||
@@ -1575,7 +1595,9 @@ impl<'a> Lower<'a> {
|
||||
// the other half of its dst, PS_DeferredTextured): evaluated as the pair it
|
||||
// starts. Approximate for those other bits (P0 + i P10 on the console); a
|
||||
// first half only the second half reads is gone before lowering.
|
||||
if std::env::var_os("VICTORY_FIRST_HALF").is_none_or(|v| v != "0") {
|
||||
// Only in the second translation of a program the first
|
||||
// one refused for it ([`with_first_half_pairs`]).
|
||||
if FIRST_HALF_PAIRS.get() && std::env::var_os("VICTORY_FIRST_HALF").is_none_or(|v| v != "0") {
|
||||
for (_, i) in &x.io.interps {
|
||||
if let Interp::Interpolated { first, .. } = i {
|
||||
for s in first {
|
||||
@@ -5978,6 +6000,21 @@ impl<'a> Lower<'a> {
|
||||
Some(_) => None,
|
||||
None => self.sized_view(inst, site, code, count),
|
||||
};
|
||||
// A descriptor nothing uses as one, whose size the code reads all the same (a
|
||||
// texture picked from the heap by an index in a constant buffer, its width and
|
||||
// height turned into a texel size): the kind from its dwords and its used-resource
|
||||
// entry. Only an image whose layers or depth (dword 4) are not read: those are no 2D
|
||||
// texture's; and no buffer `sized_view` did not take (a stride of 4 or less may be a
|
||||
// typed view's component count, and the address is `view_address`'s below).
|
||||
let layers = inst.write(Reg::S(code + 4)).is_some_and(|v| self.read_as_number(v));
|
||||
let unused = if use_at.is_none() && sized.is_none() && count == 8 && !layers {
|
||||
self.unused_descriptor_kind(inst, site, code, count)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let (first, props, image, uav, used) = if let Some(kind) = unused {
|
||||
kind
|
||||
} else {
|
||||
let Some((at, first)) = use_at.or(sized.map(|_| (site, 0))) else {
|
||||
// A descriptor kept per lane in VGPRs (`Resources::lane_copied`): the code only
|
||||
// copies its dwords and compares them, lane against first lane, and every load
|
||||
@@ -6101,6 +6138,9 @@ impl<'a> Lower<'a> {
|
||||
}
|
||||
_ => return Err("a scalar memory read as data"),
|
||||
};
|
||||
(first, props, image, uav, used)
|
||||
};
|
||||
let src = Source::Loaded { load: site, first };
|
||||
let h = self.handle(site, &src, false, props)?;
|
||||
let c = self.cur;
|
||||
let i32t = self.s.t.i32;
|
||||
@@ -6179,8 +6219,10 @@ impl<'a> Lower<'a> {
|
||||
inst.write(Reg::S(code + first + k))
|
||||
.is_some_and(|v| self.computed_with(v, 6))
|
||||
});
|
||||
// (A descriptor nothing uses as one gets it whenever the host can tell it, as
|
||||
// a buffer whose address alone is read does.)
|
||||
if first == 0
|
||||
&& computed
|
||||
&& (computed || unused.is_some())
|
||||
&& let Some((lo, hi)) = self.view_address(site)
|
||||
{
|
||||
words.extend([(0, lo), (1, hi)]);
|
||||
@@ -6203,6 +6245,67 @@ impl<'a> Lower<'a> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// What [`Self::descriptor_data`] makes of a descriptor load that nothing uses as a
|
||||
/// descriptor but whose dwords the code reads: the first dword, the handle properties,
|
||||
/// the image kind (none for a buffer), whether it is an unordered view, and its
|
||||
/// used-resource entry. An image's eight dwords read as a 2D texture's, a buffer's four
|
||||
/// as a raw view's where the code reads its record count (dword 2); none for anything
|
||||
/// else (a constant buffer, a sampler, a buffer whose address alone is read).
|
||||
// shortcut: an image whose kind nothing tells is taken for a 2D texture (the title's
|
||||
// reads are texel sizes of 2D textures: puddle masks, shadow masks); a host view of
|
||||
// another kind would answer its own sizes.
|
||||
#[allow(clippy::type_complexity)]
|
||||
fn unused_descriptor_kind(
|
||||
&self,
|
||||
inst: &Inst,
|
||||
site: Site,
|
||||
code: u8,
|
||||
count: u32,
|
||||
) -> Option<(u8, (u32, u32), Option<u32>, bool, Option<&'a UsedResource>)> {
|
||||
// Kept per lane and compared (`Resources::lane_copied`), or a sampler's: the cases
|
||||
// `descriptor_data` handles on their own.
|
||||
if self.x.res.lane_copied.contains(&site)
|
||||
|| self.x.res.descriptors.iter().any(|d| {
|
||||
d.role == Role::Sampler
|
||||
&& d.source.leaves().into_iter().any(
|
||||
|l| matches!(*l, Source::Loaded { load, .. } if load == site),
|
||||
)
|
||||
})
|
||||
{
|
||||
return None;
|
||||
}
|
||||
let used = self.used_kind(&Source::Loaded {
|
||||
load: site,
|
||||
first: 0,
|
||||
});
|
||||
if used.is_some_and(|u| !matches!(u.kind, ResourceType::Srv | ResourceType::Uav)) {
|
||||
return None;
|
||||
}
|
||||
let read = |k: u32| {
|
||||
inst.write(Reg::S(code + k as u8)).is_some_and(|v| {
|
||||
self.x
|
||||
.p
|
||||
.blocks
|
||||
.iter()
|
||||
.flat_map(|b| &b.insts)
|
||||
.any(|i| i.reads.iter().any(|r| r.1 == v))
|
||||
})
|
||||
};
|
||||
let uav = used.is_some_and(|u| u.kind == ResourceType::Uav);
|
||||
let u = if uav { 0x1000 } else { 0 };
|
||||
match count {
|
||||
// width (dwords 1-2), height (2), levels (3), depth (4)
|
||||
8 if (1..5).any(read) && used.is_none_or(|u| u.dwords == 8) => {
|
||||
Some((0, (2 | u, 0x409), Some(2), uav, used))
|
||||
}
|
||||
// the record count
|
||||
4 if read(2) && used.is_none_or(|u| u.dwords == 4) => {
|
||||
Some((0, (11 | u, 0), None, uav, used))
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// `s_load_dword*` from the program's constant table.
|
||||
fn code_smem(&mut self, inst: &Inst, a: Address) -> Result<(), Why> {
|
||||
let Fields::Smem {
|
||||
@@ -9649,7 +9752,26 @@ impl<'a> Lower<'a> {
|
||||
|
||||
fn interp(&mut self, inst: &Inst, site: Site) -> Result<(), Why> {
|
||||
let Some(&interp) = self.interps.get(&site) else {
|
||||
return Err("the first half of an interpolation");
|
||||
// The first half of a pair: its second half interpolates the
|
||||
// attribute itself, so nothing needs this half's partial sum.
|
||||
// But an f16 second half that writes the high half of the
|
||||
// register this one wrote keeps the low half as it was (the
|
||||
// console compiler reuses the register; the low half is not
|
||||
// read), so the register needs a value: 0.
|
||||
let name = inst.name();
|
||||
if name == "v_interp_p1_f32" || name == "v_interp_p1ll_f16" {
|
||||
let dst = match &inst.fields {
|
||||
Fields::Vintrp { dst, .. } => Some(*dst),
|
||||
Fields::Valu(v) => v.dst,
|
||||
_ => None,
|
||||
};
|
||||
if let Some(Operand::Vector { reg, .. }) = dst {
|
||||
let zero = self.s.m.i32(0);
|
||||
self.write(inst, Reg::V(reg), zero, None);
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
return Err(FIRST_HALF);
|
||||
};
|
||||
let name = inst.name();
|
||||
let (dst, src) = match &inst.fields {
|
||||
|
||||
Reference in new issue
Block a user