Shaders: normalized buffer codes give the nearest float, cube gradients take DXIL's base-2 logarithm, d16 data of integer views keeps its bits, unordered views of vertex programs are declared
- VIctory da82e444: the host's division was a step off for some codes, and a material index cut from one was the code below. - DexNom/VIctory 921d8d3b (its cube part, with its test): the level was taken from a natural logarithm DXIL does not have, 1.44 times too high; the instruction's least level was lost. - VIctory 4243a96a, for buffers a program picks from the heap. - VIctory a1a2077a. Every shader is translated anew. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
350c686481
commit
9a6c829d68
9 files changed
+501
-36
No files matched your search
@@ -1005,6 +1005,17 @@ fn view_stride(view: &View) -> Option<u32> {
|
||||
})
|
||||
}
|
||||
|
||||
/// What else the table of strides says of a typed buffer view of an integer
|
||||
/// format (`victory_shader::emit::VIEW_INTEGER`); 0 for any other view.
|
||||
fn view_kind(view: &View) -> u32 {
|
||||
use victory_shader::emit::{VIEW_INTEGER, VIEW_SIGNED};
|
||||
match view_elements(view) {
|
||||
Some((0, false, 3 | 7 | 12 | 17 | 25 | 30 | 36 | 42 | 50 | 57 | 62)) => VIEW_INTEGER,
|
||||
Some((0, false, 4 | 8 | 14 | 18 | 32 | 38 | 43 | 52 | 59 | 64)) => VIEW_INTEGER | VIEW_SIGNED,
|
||||
_ => 0,
|
||||
}
|
||||
}
|
||||
|
||||
/// A buffer view's structure stride, whether it is raw, and its format;
|
||||
/// `None` if `view` is not a buffer view.
|
||||
fn view_elements(view: &View) -> Option<(u32, bool, u32)> {
|
||||
@@ -2366,12 +2377,13 @@ impl HostHeap {
|
||||
}
|
||||
}
|
||||
let stride = view.and_then(view_stride);
|
||||
let kind = view.map_or(0, view_kind);
|
||||
if let Some((_, _, data)) = &self.strides
|
||||
&& index < victory_shader::emit::SLOT_STRIDES_COUNT
|
||||
{
|
||||
// SAFETY: inside the mapping; shaders read it while we write (a
|
||||
// dword, either value is one the slot had).
|
||||
unsafe { (*data as *mut u32).add(index as usize).write_volatile(stride.unwrap_or(0)) };
|
||||
unsafe { (*data as *mut u32).add(index as usize).write_volatile(stride.unwrap_or(0) | kind) };
|
||||
}
|
||||
let mut buffers = self.buffers.lock().unwrap_or_else(|e| e.into_inner());
|
||||
let was = if stride.is_some() {
|
||||
@@ -4580,6 +4592,22 @@ mod tests {
|
||||
assert!(!same_placed_texture(&low, &View::Shader(0, None)));
|
||||
}
|
||||
|
||||
/// Typed buffer views of integer formats are marked in the table of
|
||||
/// strides; float, normalized, raw and structured ones are not.
|
||||
#[test]
|
||||
fn integer_typed_buffer_views_are_marked_in_the_table_of_strides() {
|
||||
use victory_shader::emit::{VIEW_INTEGER, VIEW_SIGNED};
|
||||
// Format, dimension (buffer), first element, count, stride, counter, flags.
|
||||
let uav = |format, stride, flags| View::Unordered(0, 0, Some([format, 1, 0, 0, 64, stride, 0, 0, flags, 0]));
|
||||
assert_eq!(view_kind(&uav(12, 0, 0)), VIEW_INTEGER, "R16G16B16A16_UINT");
|
||||
assert_eq!(view_kind(&uav(59, 0, 0)), VIEW_INTEGER | VIEW_SIGNED, "R16_SINT");
|
||||
assert_eq!(view_kind(&uav(10, 0, 0)), 0, "R16G16B16A16_FLOAT");
|
||||
assert_eq!(view_kind(&uav(58, 0, 0)), 0, "R16_SNORM");
|
||||
assert_eq!(view_kind(&uav(39, 0, 1)), 0, "raw");
|
||||
assert_eq!(view_kind(&uav(0, 16, 0)), 0, "structured");
|
||||
assert_eq!(view_stride(&uav(12, 0, 0)), Some(8));
|
||||
}
|
||||
|
||||
/// What may stand for a texture that is not there yet: one of its kind in
|
||||
/// another place or size; another one only if asked; nothing a shader
|
||||
/// cannot read in its place.
|
||||
|
||||
Reference in new issue
Block a user