host_ab: the compositor stand-in, passes of 300 draws each binding its own buffer and texture
The encode workload's `draw_compositor` variant draws as a window server's frame draws: render passes of 300 draws (the first clearing the target, the rest loading it), before each draw another vertex buffer and offset and another fragment texture bound (as `draw_bind`), and every run of 10 draws drawn by the next of three pipeline states reused every frame: the two textured states (`quad_vertex` + `textured_fragment`, without and with blending) and a solid one (`quad_vertex` + `icb_draw_fragment`, blending, which reads no texture), the Scene's new `solid`. It stands in for the shape a guest compositor's main command buffer takes during a window drag: a few hundred draws a pass whose buffers and textures change between draws, its pipelines the same across frames. Per draw: the encoding thread's wall time and the process's CPU time, as every encode variant. Verified: the example builds (release) on the M3 and runs its variants; its numbers come with the commits that measure against it. (cherry picked from commit 89cd071b0d416127c483900ccbbcabee04dc6fa0) (cherry picked from commit f4d394f7d12a12f937e455f52ec6b5f3ce7b53f0)
This commit is contained in:
1 parent
9ec100ba7c
commit
658e5ced81
2 files changed
+49
-8
No files matched your search
@@ -19,8 +19,10 @@
|
||||
//! 512x512 `BGRA8Unorm` target, `static` (nothing set between draws), `offset` (each draw the
|
||||
//! vertex buffer's offset alone, `setVertexBufferOffset:atIndex:`), `bind` (each draw another
|
||||
//! vertex buffer and offset, and another fragment texture), `pipeline` (as `bind`, and the
|
||||
//! pipeline state switched between two) and `passes` (as `pipeline`, in render passes of three
|
||||
//! draws, as a window server draws), and a compute encoder of as many single-threadgroup
|
||||
//! pipeline state switched between two), `passes` (as `pipeline`, in render passes of three
|
||||
//! draws, as a window server draws) and `compositor` (as `bind`, in render passes of 300 draws,
|
||||
//! each run of 10 draws by the next of three pipeline states, as a window server's frame
|
||||
//! draws), and a compute encoder of as many single-threadgroup
|
||||
//! dispatches, `static`, `offsets` (both buffers' offsets each dispatch) and `churn` (the
|
||||
//! pipeline state and both buffers' offsets each dispatch). Per draw and dispatch: the encoding thread's wall time from the command buffer's
|
||||
//! creation through `endEncoding`, and the whole process's CPU time until the wait returned.
|
||||
@@ -207,11 +209,12 @@
|
||||
//! shader caches; a directory under the OS's temporary directory by default, removed at the end),
|
||||
//! `--metallib PATH` (skip the compile; not with `pipeline`), `--cache DIR` (the runtime's shader
|
||||
//! cache, with `--side`), `--variants a,b,...` (the encode workload's variants alone:
|
||||
//! `draw_static`, `draw_offset`, `draw_bind`, `draw_pipeline`, `draw_passes`, `dispatch_static`,
|
||||
//! `dispatch_offsets`, `dispatch_churn`, `dispatch_resident_0`, `_1`, `_256`, `_4096`,
|
||||
//! `_same_4096`, `dispatch_resident_moving_0`, `_16`, `_256`, `_4096`,
|
||||
//! `dispatch_resident_textures_256`, `_4096`, `dispatch_handles`; for a profile of one; and the memory workload's parts alone: `create`,
|
||||
//! `no_copy`, `held_1m`, `held_64m`, `texture`), `--announce-each a,b,...` (the runtime's device
|
||||
//! `draw_static`, `draw_offset`, `draw_bind`, `draw_pipeline`, `draw_passes`, `draw_compositor`,
|
||||
//! `dispatch_static`, `dispatch_offsets`, `dispatch_churn`, `dispatch_resident_0`, `_1`, `_256`,
|
||||
//! `_4096`, `_same_4096`, `dispatch_resident_moving_0`, `_16`, `_256`, `_4096`,
|
||||
//! `dispatch_resident_textures_256`, `_4096`, `dispatch_handles`; for a profile of one; and the
|
||||
//! memory workload's parts alone: `create`, `no_copy`, `held_1m`, `held_64m`, `texture`),
|
||||
//! `--announce-each a,b,...` (the runtime's device
|
||||
//! announces these degradation kinds, by code with or without its `metal2vulkan-degrade-` prefix,
|
||||
//! or `all` of them, at every occurrence, `DeviceOptions::announce_each`, as a consumer that hears
|
||||
//! some kinds at each call opens it), `--sink-least verbose|info|warning|error` (the runtime's
|
||||
|
||||
@@ -109,6 +109,9 @@ const HEAVY_OUT_BYTES: usize = HEAVY_GROUPS * HEAVY_THREADS * 16;
|
||||
pub struct Scene<G: Gpu> {
|
||||
/// `quad_vertex` + `textured_fragment` into `BGRA8Unorm`, without and with blending.
|
||||
pub textured: [G::RenderPipeline; 2],
|
||||
/// `quad_vertex` + `icb_draw_fragment` (a fill of its own color, no texture) into
|
||||
/// `BGRA8Unorm`, blending.
|
||||
pub solid: G::RenderPipeline,
|
||||
/// `quad_vertex` + `heavy_fragment` into `RGBA16Float`.
|
||||
pub heavy_fragment: G::RenderPipeline,
|
||||
pub heavy_kernel: G::ComputePipeline,
|
||||
@@ -199,6 +202,13 @@ impl<G: Gpu> Scene<G> {
|
||||
true,
|
||||
),
|
||||
];
|
||||
let solid = g.render_pipeline(
|
||||
library,
|
||||
"quad_vertex",
|
||||
"icb_draw_fragment",
|
||||
Format::Bgra8,
|
||||
true,
|
||||
);
|
||||
let heavy_fragment = g.render_pipeline(
|
||||
library,
|
||||
"quad_vertex",
|
||||
@@ -228,6 +238,7 @@ impl<G: Gpu> Scene<G> {
|
||||
.collect();
|
||||
Scene {
|
||||
textured,
|
||||
solid,
|
||||
heavy_fragment,
|
||||
heavy_kernel,
|
||||
features,
|
||||
@@ -270,11 +281,20 @@ enum Churn {
|
||||
/// As `Pipeline`, in render passes of [`PASS_DRAWS`] draws each (the pass loads the target,
|
||||
/// the first clears it): a window server's few draws a pass, each binding its own.
|
||||
Passes,
|
||||
/// As `Bind`, in render passes of [`COMPOSITOR_DRAWS`] draws each, every [`COMPOSITOR_RUN`]
|
||||
/// draws drawn by the next of three pipeline states (the two textured states and the solid
|
||||
/// one): a window server's frame of a few hundred draws a pass, each binding its own buffer
|
||||
/// and texture, its few pipeline states the same every frame.
|
||||
Compositor,
|
||||
}
|
||||
|
||||
/// The draws of each pass of [`Churn::Passes`].
|
||||
const PASS_DRAWS: usize = 3;
|
||||
|
||||
/// The draws of each pass of [`Churn::Compositor`], and of each run of one pipeline state there.
|
||||
const COMPOSITOR_DRAWS: usize = 300;
|
||||
const COMPOSITOR_RUN: usize = 10;
|
||||
|
||||
impl Churn {
|
||||
fn name(self) -> &'static str {
|
||||
match self {
|
||||
@@ -283,6 +303,16 @@ impl Churn {
|
||||
Churn::Bind => "bind",
|
||||
Churn::Pipeline => "pipeline",
|
||||
Churn::Passes => "passes",
|
||||
Churn::Compositor => "compositor",
|
||||
}
|
||||
}
|
||||
|
||||
/// The draws of each of its render passes, where it draws in several.
|
||||
fn pass_draws(self) -> Option<usize> {
|
||||
match self {
|
||||
Churn::Passes => Some(PASS_DRAWS),
|
||||
Churn::Compositor => Some(COMPOSITOR_DRAWS),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -301,11 +331,18 @@ fn encode_draws<G: Gpu>(
|
||||
g.set_vertex_buffer(&mut encoder, &s.rects[0], 0, 0);
|
||||
g.set_fragment_texture(&mut encoder, &s.textures[0], 0);
|
||||
for draw in 0..draws {
|
||||
if matches!(churn, Churn::Passes) && draw > 0 && draw % PASS_DRAWS == 0 {
|
||||
let new_pass = churn
|
||||
.pass_draws()
|
||||
.is_some_and(|per| draw > 0 && draw % per == 0);
|
||||
if new_pass {
|
||||
g.end_render(encoder);
|
||||
encoder = g.render_encoder(command_buffer, &s.target, false);
|
||||
g.set_fragment_sampler(&mut encoder, &s.sampler, 0);
|
||||
}
|
||||
if matches!(churn, Churn::Compositor) && (new_pass || draw % COMPOSITOR_RUN == 0) {
|
||||
let states = [&s.textured[0], &s.textured[1], &s.solid];
|
||||
g.set_render_pipeline(&mut encoder, states[(draw / COMPOSITOR_RUN) % states.len()]);
|
||||
}
|
||||
if matches!(churn, Churn::Offset) {
|
||||
g.set_vertex_buffer_offset(&mut encoder, (draw % RECTS) * RECT_STRIDE, 0);
|
||||
}
|
||||
@@ -517,6 +554,7 @@ pub fn encode<G: Gpu>(
|
||||
Churn::Bind,
|
||||
Churn::Pipeline,
|
||||
Churn::Passes,
|
||||
Churn::Compositor,
|
||||
] {
|
||||
if !runs(format!("draw_{}", churn.name())) {
|
||||
continue;
|
||||
|
||||
Reference in new issue
Block a user