nvk: Split pipeline binding into helpers

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
This commit is contained in:
Faith Ekstrand 2023-01-30 20:11:52 -06:00 committed by Marge Bot
parent db2cf498ce
commit 65b1cc3adf
4 changed files with 30 additions and 12 deletions

View file

@ -371,23 +371,22 @@ nvk_CmdBindPipeline(VkCommandBuffer commandBuffer,
VK_FROM_HANDLE(nvk_cmd_buffer, cmd, commandBuffer);
VK_FROM_HANDLE(nvk_pipeline, pipeline, _pipeline);
for (unsigned s = 0; s < ARRAY_SIZE(pipeline->shaders); s++) {
if (!pipeline->shaders[s].bo)
continue;
nouveau_ws_push_ref(cmd->push, pipeline->shaders[s].bo,
NOUVEAU_WS_BO_RD);
}
switch (pipelineBindPoint) {
case VK_PIPELINE_BIND_POINT_GRAPHICS:
for (unsigned s = 0; s < ARRAY_SIZE(pipeline->shaders); s++) {
if (!pipeline->shaders[s].bo)
continue;
nouveau_ws_push_ref(cmd->push, pipeline->shaders[s].bo,
NOUVEAU_WS_BO_RD);
}
cmd->state.gfx.pipeline = (struct nvk_graphics_pipeline *)pipeline;
assert(pipeline->type == NVK_PIPELINE_GRAPHICS);
nvk_cmd_bind_graphics_pipeline(cmd, (void *)pipeline);
break;
case VK_PIPELINE_BIND_POINT_COMPUTE:
assert(pipeline->type == NVK_PIPELINE_COMPUTE);
nouveau_ws_push_ref(cmd->push,
pipeline->shaders[MESA_SHADER_COMPUTE].bo,
NOUVEAU_WS_BO_RD);
cmd->state.cs.pipeline = (struct nvk_compute_pipeline *)pipeline;
nvk_cmd_bind_compute_pipeline(cmd, (void *)pipeline);
break;
default:
unreachable("Unhandled bind point");

View file

@ -100,6 +100,11 @@ void nvk_cmd_buffer_begin_graphics(struct nvk_cmd_buffer *cmd,
void nvk_cmd_buffer_begin_compute(struct nvk_cmd_buffer *cmd,
const VkCommandBufferBeginInfo *pBeginInfo);
void nvk_cmd_bind_graphics_pipeline(struct nvk_cmd_buffer *cmd,
struct nvk_graphics_pipeline *pipeline);
void nvk_cmd_bind_compute_pipeline(struct nvk_cmd_buffer *cmd,
struct nvk_compute_pipeline *pipeline);
static inline struct nvk_descriptor_state *
nvk_get_descriptors_state(struct nvk_cmd_buffer *cmd,
VkPipelineBindPoint bind_point)

View file

@ -72,6 +72,13 @@ gp100_cp_launch_desc_set_cb(uint32_t *qmd, unsigned index,
NVC0C0_QMDV02_01_DEF_SET(qmd, CONSTANT_BUFFER_VALID, index, TRUE);
}
void
nvk_cmd_bind_compute_pipeline(struct nvk_cmd_buffer *cmd,
struct nvk_compute_pipeline *pipeline)
{
cmd->state.cs.pipeline = pipeline;
}
VKAPI_ATTR void VKAPI_CALL
nvk_CmdDispatch(VkCommandBuffer commandBuffer,
uint32_t groupCountX,

View file

@ -5,3 +5,10 @@ nvk_cmd_buffer_begin_graphics(struct nvk_cmd_buffer *cmd,
const VkCommandBufferBeginInfo *pBeginInfo)
{
}
void
nvk_cmd_bind_graphics_pipeline(struct nvk_cmd_buffer *cmd,
struct nvk_graphics_pipeline *pipeline)
{
cmd->state.gfx.pipeline = pipeline;
}