Addresses of ray-tracing structures: views of a structure have no buffer
A shader that walks a structure takes its address out of the structure's descriptor. The view has no resource, so the address came out 0 and every ray missed. Also: only programs that store by raw address declare the copies they reach that way as written. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
6bdb85106c
commit
7a2b0b0099
3 files changed
+75
-11
No files matched your search
@@ -126,6 +126,8 @@ pub(crate) struct Translated {
|
||||
/// Whether the shader's code can store to buffer memory ([`stores`]);
|
||||
/// true when its code is not known.
|
||||
pub(crate) stores: bool,
|
||||
/// Whether it can store through raw addresses ([`stores_by_address`]).
|
||||
pub(crate) stores_by_address: bool,
|
||||
/// Whether it stores through a view it picks from the heap by an index,
|
||||
/// once asked (`crate::picked`).
|
||||
pub(crate) picks: std::sync::atomic::AtomicU8,
|
||||
@@ -198,6 +200,7 @@ fn translate(container: &[u8]) -> Result<Translated, String> {
|
||||
};
|
||||
let host = crate::shader_cache::host_shader(container)?;
|
||||
let stores = programs.is_empty() || programs.iter().any(stores);
|
||||
let stores_by_address = programs.is_empty() || programs.iter().any(stores_by_address);
|
||||
let used = programs
|
||||
.into_iter()
|
||||
.find(|p| {
|
||||
@@ -212,6 +215,7 @@ fn translate(container: &[u8]) -> Result<Translated, String> {
|
||||
host,
|
||||
used,
|
||||
stores,
|
||||
stores_by_address,
|
||||
picks: Default::default(),
|
||||
})
|
||||
}
|
||||
@@ -360,6 +364,23 @@ fn stores(program: &victory_shader::NativeProgram) -> bool {
|
||||
})
|
||||
}
|
||||
|
||||
/// Whether a console program can store to memory through raw addresses
|
||||
/// (`crate::memory`): a flat or global store or atomic, or code that does
|
||||
/// not decode. The programs that only walk ray-tracing structures do not,
|
||||
/// whatever they store through views.
|
||||
#[cfg(windows)]
|
||||
fn stores_by_address(program: &victory_shader::NativeProgram) -> bool {
|
||||
use victory_shader::gfx10::{Encoding, decode};
|
||||
let Ok(code) = decode(&program.code) else {
|
||||
return true;
|
||||
};
|
||||
code.iter().any(|i| {
|
||||
matches!(i.encoding, Encoding::Flat | Encoding::Global)
|
||||
&& i.name()
|
||||
.is_none_or(|n| (n.contains("store") || n.contains("atomic")) && !n.contains("scratch"))
|
||||
})
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
struct Pipeline {
|
||||
object: Object,
|
||||
|
||||
Reference in new issue
Block a user