mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-04 20:38:06 +02:00
vulkan: Add a vk_pipeline_ops::get_shader method
Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31394>
This commit is contained in:
parent
4a9a4721fe
commit
4ae2882bc1
2 changed files with 41 additions and 0 deletions
|
|
@ -1545,12 +1545,28 @@ vk_graphics_pipeline_get_internal_representations(
|
|||
internal_representation_count, internal_representations);
|
||||
}
|
||||
|
||||
static struct vk_shader *
|
||||
vk_graphics_pipeline_get_shader(struct vk_pipeline *pipeline,
|
||||
gl_shader_stage stage)
|
||||
{
|
||||
struct vk_graphics_pipeline *gfx_pipeline =
|
||||
container_of(pipeline, struct vk_graphics_pipeline, base);
|
||||
|
||||
for (uint32_t i = 0; i < gfx_pipeline->stage_count; i++) {
|
||||
if (gfx_pipeline->stages[i].stage == stage)
|
||||
return gfx_pipeline->stages[i].shader;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const struct vk_pipeline_ops vk_graphics_pipeline_ops = {
|
||||
.destroy = vk_graphics_pipeline_destroy,
|
||||
.get_executable_statistics = vk_graphics_pipeline_get_executable_statistics,
|
||||
.get_executable_properties = vk_graphics_pipeline_get_executable_properties,
|
||||
.get_internal_representations = vk_graphics_pipeline_get_internal_representations,
|
||||
.cmd_bind = vk_graphics_pipeline_cmd_bind,
|
||||
.get_shader = vk_graphics_pipeline_get_shader,
|
||||
};
|
||||
|
||||
static VkResult
|
||||
|
|
@ -2061,12 +2077,24 @@ vk_compute_pipeline_get_internal_representations(
|
|||
internal_representation_count, internal_representations);
|
||||
}
|
||||
|
||||
static struct vk_shader *
|
||||
vk_compute_pipeline_get_shader(struct vk_pipeline *pipeline,
|
||||
gl_shader_stage stage)
|
||||
{
|
||||
struct vk_compute_pipeline *comp_pipeline =
|
||||
container_of(pipeline, struct vk_compute_pipeline, base);
|
||||
|
||||
assert(stage == MESA_SHADER_COMPUTE);
|
||||
return comp_pipeline->shader;
|
||||
}
|
||||
|
||||
static const struct vk_pipeline_ops vk_compute_pipeline_ops = {
|
||||
.destroy = vk_compute_pipeline_destroy,
|
||||
.get_executable_statistics = vk_compute_pipeline_get_executable_statistics,
|
||||
.get_executable_properties = vk_compute_pipeline_get_executable_properties,
|
||||
.get_internal_representations = vk_compute_pipeline_get_internal_representations,
|
||||
.cmd_bind = vk_compute_pipeline_cmd_bind,
|
||||
.get_shader = vk_compute_pipeline_get_shader,
|
||||
};
|
||||
|
||||
static VkResult
|
||||
|
|
|
|||
|
|
@ -194,6 +194,9 @@ struct vk_pipeline_ops {
|
|||
|
||||
void (*cmd_bind)(struct vk_command_buffer *cmd_buffer,
|
||||
struct vk_pipeline *pipeline);
|
||||
|
||||
struct vk_shader *(*get_shader)(struct vk_pipeline *pipeline,
|
||||
gl_shader_stage stage);
|
||||
};
|
||||
|
||||
void *vk_pipeline_zalloc(struct vk_device *device,
|
||||
|
|
@ -207,6 +210,16 @@ void vk_pipeline_free(struct vk_device *device,
|
|||
const VkAllocationCallbacks *alloc,
|
||||
struct vk_pipeline *pipeline);
|
||||
|
||||
static inline struct vk_shader *
|
||||
vk_pipeline_get_shader(struct vk_pipeline *pipeline,
|
||||
gl_shader_stage stage)
|
||||
{
|
||||
if (pipeline->ops->get_shader == NULL)
|
||||
return NULL;
|
||||
|
||||
return pipeline->ops->get_shader(pipeline, stage);
|
||||
}
|
||||
|
||||
void
|
||||
vk_cmd_unbind_pipelines_for_stages(struct vk_command_buffer *cmd_buffer,
|
||||
VkShaderStageFlags stages);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue