rt test: a render state's sRGB variant is kept in the bounded map of contents

The draw-side sRGB form keeps each render state's sRGB variant in the device's map of contents
beside its content, under the descriptor's key with its slots. The kernel's variant had a
fill-past-capacity test and the render variant had none, so this adds it: at a cap of 2, the float
fragment writer's content and its variant fill the map, a reuse onto the other twin or an
RGBA8Unorm texture makes nothing, the half writer's content and variant push both out, and the
float writer's next draw onto a twin makes its variant again (translations_at_encode 1, 1, 2, 3;
kernel_entries 2 throughout). each_device's settle then waits for every gauge, render_contents and
kernel_entries among them, to read zero once the device drops. The runtime README's paragraph on
makes at encode is re-wrapped, its words unchanged.
This commit is contained in:
Anees Iqbal committed 2026-12-02 22:44:30 -08:00
1 parent ee6911e100
commit fd93d1695f
2 files changed
+79 -7

No files matched your search

+6 -6
View File
@@ -4504,12 +4504,12 @@ cache is answered compile-required on both.
variant on emulated SIMD groups that no `prepare_dispatch` call lowered first; a compute
state's content for a dispatch's buffers bound at a multiple of 4 below their alignment, or for
its 8-bit sRGB textures' UNORM twins; a render state's content for a draw's buffers bound so,
or for its 8-bit sRGB textures' UNORM twins; and a render state's content for a pass it does not render into as made (a colour attachment
the pass lacks, or a fetched colour in a 2D array). Each is made once and kept, with its content
or in the device's map of contents, so a reuse makes nothing; a content the map forgot is made
again. `Metrics::translations_at_encode` counts these makes, made or refused, and
`translation_at_encode_max_nanos` holds the longest one. Only the first kind has a pre-pass
that moves it off the encoding thread.
or for its 8-bit sRGB textures' UNORM twins; and a render state's content for a pass it does
not render into as made (a colour attachment the pass lacks, or a fetched colour in a 2D
array). Each is made once and kept, with its content or in the device's map of contents, so a
reuse makes nothing; a content the map forgot is made again. `Metrics::translations_at_encode`
counts these makes, made or refused, and `translation_at_encode_max_nanos` holds the longest
one. Only the first kind has a pre-pass that moves it off the encoding thread.
- On Intel's Windows driver (101.2145) for the UHD 630, the driver's compile of a tiling kernel's
`VkPipeline`, the state's main one, took medians of 6,680 to 6,853 µs for the harness's
`create_state` kernel, in three processes of 40 compiles each with no driver cache hit. The
@@ -28,7 +28,13 @@
//! (`Metrics::translations_at_encode` rises by one), the draw onto the other format's twin and
//! one onto an `RGBA8Unorm` texture lowering nothing; where the texture has no twin's storage
//! view the draw is `Gap::StorageElement` of slot 0, `StorageElementCase::Absent`. It prints,
//! per device and function, the variant's make and the largest distance from the MSL encode.
//! per device and function, the variant's make and the largest distance from the MSL encode;
//! - a render state's sRGB variant is kept in the device's map of contents beside its content:
//! filled past a cap of 2 by another state's content and variant, the map holds 2, and a variant
//! it forgot is lowered again at its state's next draw onto a twin (on a device whose textures
//! have their twins' storage views); with the device dropped every render content is gone (the
//! gauges' settle in `each_device`). It prints the translation time of the float fragment
//! writer's state and of its variant.
//!
//! `llvm-as` assembles the fixture; without it the tests skip visibly.
@@ -546,4 +552,70 @@ mod on_device {
}
});
}
#[test]
fn every_device_keeps_a_render_states_srgb_variant_in_the_bounded_map_of_contents() {
let Some(library) = fixture("fpv_srgb_draw_storage") else {
return;
};
each_device("sRGB draw variants", |name, _, device| {
let _grant = (device.grant_indices(IndexClass::Texture, 1, 3))
.unwrap_or_else(|error| panic!("{name}: {error}"));
let [rgba, bgra] =
[0, 1].map(|at| texture(name, &device, FORMATS[at].0, 1 + at as u32));
if !(rgba.encodes() && bgra.encodes()) {
println!("{name}: a texture without its twin's storage view; nothing to keep");
return;
}
let unorm = texture(name, &device, PixelFormat::RGBA8Unorm, 3);
device.core().kernels.set_cap(2);
let counters = device.counters();
let entries = || counters.gauges().kernel_entries;
let at_encode = || counters.metrics().translations_at_encode;
let nanos = || counters.metrics().translation_nanos;
let mut buffers = Buffers::new(&device);
let width = buffers.of(&device, &WIDTH.to_le_bytes());
let values = buffers.of(&device, &written("fpv_srgb_fragment_write").0);
let fragment = |writer| ("fpv_srgb_cover", Some(writer));
let begun = nanos();
let float = render_state(name, &device, &library, fragment("fpv_srgb_fragment_write"));
let plain = nanos() - begun;
let run = |state: &RenderPipelineState, texture: &Texture| {
(draw(&device, (state, true), texture, &values, &width))
.unwrap_or_else(|error| panic!("{name}: {error}"));
};
let (begun, encoded) = (nanos(), at_encode());
run(&float, &rgba);
let variant = nanos() - begun;
assert_eq!(at_encode() - encoded, 1, "{name}: one make at encode");
run(&float, &bgra);
run(&float, &unorm);
assert_eq!(at_encode() - encoded, 1, "{name}: a reuse makes nothing");
assert_eq!(entries(), 2, "{name}: the state's content and its variant");
// The half writer's content and its variant fill the map past its cap: the float
// writer's content goes, then its variant.
let half = render_state(
name,
&device,
&library,
fragment("fpv_srgb_fragment_write_half"),
);
run(&half, &rgba);
assert_eq!(at_encode() - encoded, 2, "{name}: the half variant made");
assert_eq!(entries(), 2, "{name}: the map holds its cap");
run(&float, &rgba);
assert_eq!(
at_encode() - encoded,
3,
"{name}: a forgotten variant made again"
);
assert_eq!(entries(), 2, "{name}: the map holds its cap");
drop((float, half, rgba, bgra, unorm));
println!(
"{name}: one sRGB variant a render state, kept in a map of 2 filled past its cap, \
a forgotten one made again at its next draw; fpv_srgb_fragment_write's state \
took {plain} ns of translation, its sRGB variant {variant} ns"
);
});
}
}