mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-30 03:30:10 +01:00
vulkan: Add a vk_pipeline base struct
We need to be able to thunk through a destroy callback if we want to have different kinds of pipelines implemented in different parts of the stack. Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27024>
This commit is contained in:
parent
5e71e6f3f6
commit
e2cb395a1f
2 changed files with 158 additions and 1 deletions
|
|
@ -23,6 +23,8 @@
|
|||
|
||||
#include "vk_pipeline.h"
|
||||
|
||||
#include "vk_common_entrypoints.h"
|
||||
#include "vk_command_buffer.h"
|
||||
#include "vk_device.h"
|
||||
#include "vk_log.h"
|
||||
#include "vk_nir.h"
|
||||
|
|
@ -315,3 +317,105 @@ vk_pipeline_robustness_state_fill(const struct vk_device *device,
|
|||
if (rs->images == VK_PIPELINE_ROBUSTNESS_IMAGE_BEHAVIOR_DEVICE_DEFAULT_EXT)
|
||||
rs->images = vk_device_default_robust_image_behavior(device);
|
||||
}
|
||||
|
||||
void *
|
||||
vk_pipeline_zalloc(struct vk_device *device,
|
||||
const struct vk_pipeline_ops *ops,
|
||||
VkPipelineBindPoint bind_point,
|
||||
VkPipelineCreateFlags2KHR flags,
|
||||
const VkAllocationCallbacks *alloc,
|
||||
size_t size)
|
||||
{
|
||||
struct vk_pipeline *pipeline;
|
||||
|
||||
pipeline = vk_object_zalloc(device, alloc, size, VK_OBJECT_TYPE_PIPELINE);
|
||||
if (pipeline == NULL)
|
||||
return NULL;
|
||||
|
||||
pipeline->ops = ops;
|
||||
pipeline->bind_point = bind_point;
|
||||
pipeline->flags = flags;
|
||||
|
||||
return pipeline;
|
||||
}
|
||||
|
||||
void
|
||||
vk_pipeline_free(struct vk_device *device,
|
||||
const VkAllocationCallbacks *alloc,
|
||||
struct vk_pipeline *pipeline)
|
||||
{
|
||||
vk_object_free(device, alloc, &pipeline->base);
|
||||
}
|
||||
|
||||
VKAPI_ATTR void VKAPI_CALL
|
||||
vk_common_DestroyPipeline(VkDevice _device,
|
||||
VkPipeline _pipeline,
|
||||
const VkAllocationCallbacks *pAllocator)
|
||||
{
|
||||
VK_FROM_HANDLE(vk_device, device, _device);
|
||||
VK_FROM_HANDLE(vk_pipeline, pipeline, _pipeline);
|
||||
|
||||
if (pipeline == NULL)
|
||||
return;
|
||||
|
||||
pipeline->ops->destroy(device, pipeline, pAllocator);
|
||||
}
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL
|
||||
vk_common_GetPipelineExecutablePropertiesKHR(
|
||||
VkDevice _device,
|
||||
const VkPipelineInfoKHR *pPipelineInfo,
|
||||
uint32_t *pExecutableCount,
|
||||
VkPipelineExecutablePropertiesKHR *pProperties)
|
||||
{
|
||||
VK_FROM_HANDLE(vk_device, device, _device);
|
||||
VK_FROM_HANDLE(vk_pipeline, pipeline, pPipelineInfo->pipeline);
|
||||
|
||||
return pipeline->ops->get_executable_properties(device, pipeline,
|
||||
pExecutableCount,
|
||||
pProperties);
|
||||
}
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL
|
||||
vk_common_GetPipelineExecutableStatisticsKHR(
|
||||
VkDevice _device,
|
||||
const VkPipelineExecutableInfoKHR *pExecutableInfo,
|
||||
uint32_t *pStatisticCount,
|
||||
VkPipelineExecutableStatisticKHR *pStatistics)
|
||||
{
|
||||
VK_FROM_HANDLE(vk_device, device, _device);
|
||||
VK_FROM_HANDLE(vk_pipeline, pipeline, pExecutableInfo->pipeline);
|
||||
|
||||
return pipeline->ops->get_executable_statistics(device, pipeline,
|
||||
pExecutableInfo->executableIndex,
|
||||
pStatisticCount, pStatistics);
|
||||
}
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL
|
||||
vk_common_GetPipelineExecutableInternalRepresentationsKHR(
|
||||
VkDevice _device,
|
||||
const VkPipelineExecutableInfoKHR *pExecutableInfo,
|
||||
uint32_t *pInternalRepresentationCount,
|
||||
VkPipelineExecutableInternalRepresentationKHR* pInternalRepresentations)
|
||||
{
|
||||
VK_FROM_HANDLE(vk_device, device, _device);
|
||||
VK_FROM_HANDLE(vk_pipeline, pipeline, pExecutableInfo->pipeline);
|
||||
|
||||
return pipeline->ops->get_internal_representations(device, pipeline,
|
||||
pExecutableInfo->executableIndex,
|
||||
pInternalRepresentationCount,
|
||||
pInternalRepresentations);
|
||||
}
|
||||
|
||||
VKAPI_ATTR void VKAPI_CALL
|
||||
vk_common_CmdBindPipeline(VkCommandBuffer commandBuffer,
|
||||
VkPipelineBindPoint pipelineBindPoint,
|
||||
VkPipeline _pipeline)
|
||||
{
|
||||
VK_FROM_HANDLE(vk_command_buffer, cmd_buffer, commandBuffer);
|
||||
VK_FROM_HANDLE(vk_pipeline, pipeline, _pipeline);
|
||||
|
||||
assert(pipeline->bind_point == pipelineBindPoint);
|
||||
|
||||
pipeline->ops->cmd_bind(cmd_buffer, pipeline);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
#ifndef VK_PIPELINE_H
|
||||
#define VK_PIPELINE_H
|
||||
|
||||
#include "vulkan/vulkan_core.h"
|
||||
#include "vk_object.h"
|
||||
#include "vk_util.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
|
|
@ -32,6 +32,7 @@
|
|||
struct nir_shader;
|
||||
struct nir_shader_compiler_options;
|
||||
struct spirv_to_nir_options;
|
||||
struct vk_command_buffer;
|
||||
struct vk_device;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
@ -146,6 +147,58 @@ vk_graph_pipeline_create_flags(const VkExecutionGraphPipelineCreateInfoAMDX *inf
|
|||
}
|
||||
#endif
|
||||
|
||||
struct vk_pipeline_ops;
|
||||
|
||||
struct vk_pipeline {
|
||||
struct vk_object_base base;
|
||||
|
||||
const struct vk_pipeline_ops *ops;
|
||||
|
||||
VkPipelineBindPoint bind_point;
|
||||
VkPipelineCreateFlags2KHR flags;
|
||||
};
|
||||
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(vk_pipeline, base, VkPipeline,
|
||||
VK_OBJECT_TYPE_PIPELINE);
|
||||
|
||||
struct vk_pipeline_ops {
|
||||
void (*destroy)(struct vk_device *device,
|
||||
struct vk_pipeline *pipeline,
|
||||
const VkAllocationCallbacks *pAllocator);
|
||||
|
||||
VkResult (*get_executable_properties)(struct vk_device *device,
|
||||
struct vk_pipeline *pipeline,
|
||||
uint32_t *executable_count,
|
||||
VkPipelineExecutablePropertiesKHR *properties);
|
||||
|
||||
VkResult (*get_executable_statistics)(struct vk_device *device,
|
||||
struct vk_pipeline *pipeline,
|
||||
uint32_t executable_index,
|
||||
uint32_t *statistic_count,
|
||||
VkPipelineExecutableStatisticKHR *statistics);
|
||||
|
||||
VkResult (*get_internal_representations)(
|
||||
struct vk_device *device,
|
||||
struct vk_pipeline *pipeline,
|
||||
uint32_t executable_index,
|
||||
uint32_t *internal_representation_count,
|
||||
VkPipelineExecutableInternalRepresentationKHR* internal_representations);
|
||||
|
||||
void (*cmd_bind)(struct vk_command_buffer *cmd_buffer,
|
||||
struct vk_pipeline *pipeline);
|
||||
};
|
||||
|
||||
void *vk_pipeline_zalloc(struct vk_device *device,
|
||||
const struct vk_pipeline_ops *ops,
|
||||
VkPipelineBindPoint bind_point,
|
||||
VkPipelineCreateFlags2KHR flags,
|
||||
const VkAllocationCallbacks *alloc,
|
||||
size_t size);
|
||||
|
||||
void vk_pipeline_free(struct vk_device *device,
|
||||
const VkAllocationCallbacks *alloc,
|
||||
struct vk_pipeline *pipeline);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue