tu: Start tracking shaders independently of pipeline

We will gradually transition over users of cmd->state.pipeline and
TU_CMD_DIRTY_PIPELINE to shaders and derived state from shaders. This
just puts in place the framework to start doing that.

When importing a library with all of the shader state, we now have to
import the shaders in addition to the program, so that they are
available when we bind the pipeline.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25276>
This commit is contained in:
Connor Abbott 2023-09-04 19:58:36 +02:00 committed by Marge Bot
parent 0f022c3076
commit df007dcfe7
3 changed files with 44 additions and 0 deletions

View file

@ -2947,6 +2947,36 @@ tu_EndCommandBuffer(VkCommandBuffer commandBuffer)
}
TU_GENX(tu_EndCommandBuffer);
static void
tu_bind_vs(struct tu_cmd_buffer *cmd, struct tu_shader *vs)
{
cmd->state.shaders[MESA_SHADER_VERTEX] = vs;
}
static void
tu_bind_tcs(struct tu_cmd_buffer *cmd, struct tu_shader *tcs)
{
cmd->state.shaders[MESA_SHADER_TESS_CTRL] = tcs;
}
static void
tu_bind_tes(struct tu_cmd_buffer *cmd, struct tu_shader *tes)
{
cmd->state.shaders[MESA_SHADER_TESS_EVAL] = tes;
}
static void
tu_bind_gs(struct tu_cmd_buffer *cmd, struct tu_shader *gs)
{
cmd->state.shaders[MESA_SHADER_GEOMETRY] = gs;
}
static void
tu_bind_fs(struct tu_cmd_buffer *cmd, struct tu_shader *fs)
{
cmd->state.shaders[MESA_SHADER_FRAGMENT] = fs;
}
VKAPI_ATTR void VKAPI_CALL
tu_CmdBindPipeline(VkCommandBuffer commandBuffer,
VkPipelineBindPoint pipelineBindPoint,
@ -2969,6 +2999,12 @@ tu_CmdBindPipeline(VkCommandBuffer commandBuffer,
TU_CMD_DIRTY_VS_PARAMS | TU_CMD_DIRTY_LRZ |
TU_CMD_DIRTY_PIPELINE;
tu_bind_vs(cmd, pipeline->shaders[MESA_SHADER_VERTEX]);
tu_bind_tcs(cmd, pipeline->shaders[MESA_SHADER_TESS_CTRL]);
tu_bind_tes(cmd, pipeline->shaders[MESA_SHADER_TESS_EVAL]);
tu_bind_gs(cmd, pipeline->shaders[MESA_SHADER_GEOMETRY]);
tu_bind_fs(cmd, pipeline->shaders[MESA_SHADER_FRAGMENT]);
vk_cmd_set_dynamic_graphics_state(&cmd->vk,
&cmd->state.pipeline->dynamic_state);

View file

@ -387,6 +387,8 @@ struct tu_cmd_state
struct tu_graphics_pipeline *pipeline;
struct tu_compute_pipeline *compute_pipeline;
struct tu_shader *shaders[MESA_SHADER_STAGES];
struct tu_render_pass_state rp;
struct vk_render_pass_state vk_rp;

View file

@ -2208,6 +2208,12 @@ tu_pipeline_builder_parse_libraries(struct tu_pipeline_builder *builder,
if (contains_all_shader_state(library->state)) {
pipeline->program = library->base.program;
pipeline->load_state = library->base.load_state;
for (unsigned i = 0; i < ARRAY_SIZE(pipeline->shaders); i++) {
if (library->base.shaders[i]) {
pipeline->shaders[i] = library->base.shaders[i];
vk_pipeline_cache_object_ref(&pipeline->shaders[i]->base);
}
}
}
vk_graphics_pipeline_state_merge(&builder->graphics_state,