kk: Move gfx pipeline data to the info struct within kk_shader

Makes it easier to serialize and add data specific to the gfx pipeline.

Signed-off-by: Aitor Camacho <aitor@lunarg.com>
(cherry picked from commit 99d8246d1c)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40092>
This commit is contained in:
Aitor Camacho 2026-01-19 12:14:49 +09:00 committed by Eric Engestrom
parent 6152bf1cfb
commit 358c8f257a
3 changed files with 17 additions and 14 deletions

View file

@ -15964,7 +15964,7 @@
"description": "kk: Move gfx pipeline data to the info struct within kk_shader",
"nominated": false,
"nomination_type": 0,
"resolution": 4,
"resolution": 1,
"main_sha": null,
"because_sha": null,
"notes": null

View file

@ -971,7 +971,7 @@ kk_compile_graphics_pipeline(struct kk_device *device,
pipeline_descriptor, max_amplification);
}
vertex_shader->pipeline.gfx.sample_count = 1u;
vertex_shader->info.vs.sample_count = 1u;
if (state->ms) {
mtl_render_pipeline_descriptor_set_raster_sample_count(
pipeline_descriptor, state->ms->rasterization_samples);
@ -979,15 +979,14 @@ kk_compile_graphics_pipeline(struct kk_device *device,
pipeline_descriptor, state->ms->alpha_to_coverage_enable);
mtl_render_pipeline_descriptor_set_alpha_to_one(
pipeline_descriptor, state->ms->alpha_to_one_enable);
vertex_shader->pipeline.gfx.sample_count =
state->ms->rasterization_samples;
vertex_shader->info.vs.sample_count = state->ms->rasterization_samples;
}
vertex_shader->pipeline.gfx.handle =
mtl_new_render_pipeline(device->mtl_handle, pipeline_descriptor);
if (vertex_shader->pipeline.gfx.handle == NULL)
result = VK_ERROR_INVALID_SHADER_NV;
vertex_shader->pipeline.gfx.primitive_type =
vertex_shader->info.vs.primitive_type =
vk_primitive_topology_to_mtl_primitive_type(
state->ia->primitive_topology);
@ -1214,7 +1213,7 @@ kk_cmd_bind_graphics_shader(struct kk_cmd_buffer *cmd,
if (stage != MESA_SHADER_VERTEX)
return;
cmd->state.gfx.primitive_type = shader->pipeline.gfx.primitive_type;
cmd->state.gfx.primitive_type = shader->info.vs.primitive_type;
cmd->state.gfx.pipeline_state = shader->pipeline.gfx.handle;
cmd->state.gfx.vb.attribs_read = shader->info.vs.attribs_read;
@ -1237,7 +1236,7 @@ kk_cmd_bind_graphics_shader(struct kk_cmd_buffer *cmd,
cmd->state.gfx.dirty |= KK_DIRTY_PIPELINE;
cmd->state.gfx.dirty |= KK_DIRTY_VB;
cmd->state.gfx.sample_count = shader->pipeline.gfx.sample_count;
cmd->state.gfx.sample_count = shader->info.vs.sample_count;
}
static void

View file

@ -18,8 +18,14 @@
struct kk_shader_info {
mesa_shader_stage stage;
union {
/* Vertex shader is the pipeline, store all relevant data here. */
struct {
/* Data needed to start render pass and bind pipeline. */
uint32_t attribs_read;
uint32_t sample_count;
enum mtl_primitive_type primitive_type;
/* Data needed for serialization. */
} vs;
struct {
@ -30,23 +36,21 @@ struct kk_shader_info {
struct kk_shader {
struct vk_shader vk;
const char *entrypoint_name;
const char *msl_code;
struct kk_shader_info info;
/* Pipeline resources. Only stored in compute or vertex shaders */
/* Metal handles for binding. */
struct {
union {
struct {
mtl_render_pipeline_state *handle;
mtl_depth_stencil_state *mtl_depth_stencil_state_handle;
enum mtl_primitive_type primitive_type;
uint32_t sample_count;
} gfx;
mtl_compute_pipeline_state *cs;
};
} pipeline;
struct kk_shader_info info;
const char *entrypoint_name;
const char *msl_code;
};
VK_DEFINE_NONDISP_HANDLE_CASTS(kk_shader, vk.base, VkShaderEXT,