refactor(metal): name the render resolve kernel for draws

This commit is contained in:
Tyler Smith committed 2026-10-29 21:58:15 +00:00
1 parent 6c03a70644
commit ff1ea30b81
9 files changed
+21 -21

No files matched your search

@@ -548,11 +548,11 @@ static void resolve_vertex_buffers(nir_builder *b, nir_def *arguments, nir_def *
pop_count(b, counter, index);
}
nir_shader *stela_metal_resolve_kernel(const nir_shader_compiler_options *options)
nir_shader *stela_metal_resolve_draws_kernel(const nir_shader_compiler_options *options)
{
nir_def *arguments, *thread;
nir_builder b = kernel(options, "stela_metal_resolve", STELA_METAL_RESOLVE_COUNT, &arguments,
&thread);
nir_builder b = kernel(options, "stela_metal_resolve_draws", STELA_METAL_RESOLVE_COUNT,
&arguments, &thread);
nir_variable *counter = nir_local_variable_create(b.impl, glsl_uint_type(), "counter");
nir_def *header = load(&b, arguments, STELA_METAL_RESOLVE_HEADER, 64);
nir_def *command = nir_iadd(&b, thread, load(&b, arguments, STELA_METAL_RESOLVE_FIRST, 32));
@@ -261,7 +261,7 @@ nir_shader *stela_metal_select_kernel(const nir_shader_compiler_options *options
* slot is the command's pipeline class, action and primitive type, else 0.
* Commands of a buffer that inherits pipeline state are class 0; others
* are their pipeline handle's. */
nir_shader *stela_metal_resolve_kernel(const nir_shader_compiler_options *options);
nir_shader *stela_metal_resolve_draws_kernel(const nir_shader_compiler_options *options);
/* MTLTessellationPartitionMode, MTLTessellationFactorStepFunction and
* MTLWinding, in their raw values. */
@@ -272,7 +272,7 @@ static void select_flags_each_command(void)
static void resolve_writes_each_command_sequence(void)
{
nir_shader *shader = stela_metal_resolve_kernel(NULL);
nir_shader *shader = stela_metal_resolve_draws_kernel(NULL);
check_kernel(shader);
struct census census = count(shader);
assert(census.push_constants == 1 && census.push_base == STELA_METAL_PUSH_ARGUMENTS);
@@ -335,7 +335,7 @@ impl SelectArguments {
}
/// What the backend's internal resolve kernel reads at the push constants'
/// `arguments` (`stela_metal_resolve_kernel`): it turns each command of a
/// `arguments` (`stela_metal_resolve_draws_kernel`): it turns each command of a
/// GPU-resident render indirect command buffer into a [`GeneratedSequence`]
/// and its counts per [`ResolveSlot`].
#[derive(Clone, Debug, Default, PartialEq)]
@@ -369,7 +369,7 @@ impl CommandBuffer {
PipelineStages::COMPUTE_SHADER,
Access::SHADER_READ | Access::SHADER_WRITE,
));
recorder.push(Command::ResolveCommands {
recorder.push(Command::ResolveDraws {
arguments: upload.address,
count,
});
@@ -2231,9 +2231,9 @@ fn resident_draws_execute_one_generated_sequence_per_slot() {
let resolve = commands
.iter()
.position(|command| matches!(command, Command::ResolveCommands { count: 2, .. }))
.position(|command| matches!(command, Command::ResolveDraws { count: 2, .. }))
.unwrap();
let Command::ResolveCommands { arguments, .. } = commands[resolve] else {
let Command::ResolveDraws { arguments, .. } = commands[resolve] else {
unreachable!()
};
let arguments = uploaded(&recording, arguments);
@@ -2345,7 +2345,7 @@ fn resident_draws_switch_pipelines_through_execution_sets() {
let arguments = commands
.iter()
.find_map(|command| match command {
Command::ResolveCommands { arguments, .. } => Some(*arguments),
Command::ResolveDraws { arguments, .. } => Some(*arguments),
_ => None,
})
.unwrap();
+7 -7
View File
@@ -50,7 +50,7 @@ pub struct Loader {
}
/// The backend's own kernels: the NIR of `stela_metal_accumulate_kernel`,
/// `stela_metal_select_kernel` and `stela_metal_resolve_kernel`
/// `stela_metal_select_kernel` and `stela_metal_resolve_draws_kernel`
/// (`compiler/metal_abi.h`).
#[derive(Clone, Copy, Debug)]
pub struct InternalKernels {
@@ -62,10 +62,10 @@ pub struct InternalKernels {
/// [`SelectArguments`](super::binding::SelectArguments), one thread per
/// command in workgroups of `WORKGROUP_SIZE`.
pub select: ShaderCode,
/// Resolves GPU-resident indirect commands per
/// Resolves GPU-resident render indirect commands per
/// [`ResolveArguments`](super::binding::ResolveArguments), one thread
/// per command in workgroups of `WORKGROUP_SIZE`.
pub resolve: ShaderCode,
pub resolve_draws: ShaderCode,
}
/// A host mapping of a `VkDeviceMemory`.
@@ -128,7 +128,7 @@ pub struct NativeBackend {
bind_value: u64,
accumulate: vk::Pipeline,
select: vk::Pipeline,
resolve: vk::Pipeline,
resolve_draws: vk::Pipeline,
}
impl NativeBackend {
@@ -260,7 +260,7 @@ impl NativeBackend {
bind_value: 0,
accumulate: vk::Pipeline::null(),
select: vk::Pipeline::null(),
resolve: vk::Pipeline::null(),
resolve_draws: vk::Pipeline::null(),
};
// Dropping a partly built backend destroys what was created.
backend.create_layout(family)?;
@@ -273,7 +273,7 @@ impl NativeBackend {
};
backend.accumulate = backend.create_compute(&kernel(kernels.accumulate))?;
backend.select = backend.create_compute(&kernel(kernels.select))?;
backend.resolve = backend.create_compute(&kernel(kernels.resolve))?;
backend.resolve_draws = backend.create_compute(&kernel(kernels.resolve_draws))?;
Ok(backend)
}
@@ -568,7 +568,7 @@ impl Drop for NativeBackend {
unsafe {
let _ = self.device.device_wait_idle();
self.device.destroy_pipeline(self.accumulate, None);
self.device.destroy_pipeline(self.resolve, None);
self.device.destroy_pipeline(self.resolve_draws, None);
self.device.destroy_pipeline(self.select, None);
self.device.destroy_command_pool(self.command_pool, None);
self.device.destroy_pipeline_layout(self.layout, None);
@@ -607,8 +607,8 @@ impl Recorder<'_> {
count,
SelectArguments::WORKGROUP_SIZE,
),
&Command::ResolveCommands { arguments, count } => self.internal(
self.backend.resolve,
&Command::ResolveDraws { arguments, count } => self.internal(
self.backend.resolve_draws,
arguments,
count,
ResolveArguments::WORKGROUP_SIZE,
@@ -340,11 +340,11 @@ pub enum Command {
arguments: u64,
count: u32,
},
/// The backend's resolve kernel over `count` commands, with a
/// The backend's draw resolve kernel over `count` commands, with a
/// [`ResolveArguments`](crate::gpu::metal::binding::ResolveArguments)
/// upload's address in the push constants, like
/// [`AccumulateResults`](Self::AccumulateResults).
ResolveCommands {
ResolveDraws {
arguments: u64,
count: u32,
},