vulkan: Depend on vk_pipeline_layout in vk_cmd_enqueue

Now that we have a common pipeline layout with reference counting, we
don't need these driver hooks for reference counting anymore.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17286>
This commit is contained in:
Jason Ekstrand 2022-06-28 14:54:30 -05:00 committed by Marge Bot
parent aa40a04ad9
commit d06335ed76
5 changed files with 5 additions and 77 deletions

View File

@ -1493,22 +1493,6 @@ lvp_queue_finish(struct lvp_queue *queue)
queue->ctx->destroy(queue->ctx);
}
static void
ref_pipeline_layout(struct vk_device *vk_device, VkPipelineLayout _layout)
{
LVP_FROM_HANDLE(lvp_pipeline_layout, layout, _layout);
vk_pipeline_layout_ref(&layout->vk);
}
static void
unref_pipeline_layout(struct vk_device *device, VkPipelineLayout _layout)
{
LVP_FROM_HANDLE(lvp_pipeline_layout, layout, _layout);
vk_pipeline_layout_unref(device, &layout->vk);
}
VKAPI_ATTR VkResult VKAPI_CALL lvp_CreateDevice(
VkPhysicalDevice physicalDevice,
const VkDeviceCreateInfo* pCreateInfo,
@ -1553,9 +1537,6 @@ VKAPI_ATTR VkResult VKAPI_CALL lvp_CreateDevice(
device->instance = (struct lvp_instance *)physical_device->vk.instance;
device->physical_device = physical_device;
device->vk.ref_pipeline_layout = ref_pipeline_layout;
device->vk.unref_pipeline_layout = unref_pipeline_layout;
device->pscreen = physical_device->pscreen;
assert(pCreateInfo->queueCreateInfoCount == 1);

View File

@ -1857,22 +1857,6 @@ dzn_device_create_sync_for_memory(struct vk_device *device,
0, 1, sync_out);
}
static void
dzn_device_ref_pipeline_layout(struct vk_device *dev, VkPipelineLayout layout)
{
VK_FROM_HANDLE(dzn_pipeline_layout, playout, layout);
dzn_pipeline_layout_ref(playout);
}
static void
dzn_device_unref_pipeline_layout(struct vk_device *dev, VkPipelineLayout layout)
{
VK_FROM_HANDLE(dzn_pipeline_layout, playout, layout);
dzn_pipeline_layout_unref(playout);
}
static VkResult
dzn_device_query_init(struct dzn_device *device)
{
@ -2008,8 +1992,6 @@ dzn_device_create(struct dzn_physical_device *pdev,
* whole struct.
*/
device->vk.command_dispatch_table = &device->cmd_dispatch;
device->vk.ref_pipeline_layout = dzn_device_ref_pipeline_layout;
device->vk.unref_pipeline_layout = dzn_device_unref_pipeline_layout;
device->vk.create_sync_for_memory = dzn_device_create_sync_for_memory;
device->vk.check_status = dzn_device_check_status;

View File

@ -932,24 +932,6 @@ panvk_queue_finish(struct panvk_queue *queue)
vk_queue_finish(&queue->vk);
}
static void
panvk_ref_pipeline_layout(struct vk_device *dev,
VkPipelineLayout layout)
{
VK_FROM_HANDLE(vk_pipeline_layout, playout, layout);
vk_pipeline_layout_ref(playout);
}
static void
panvk_unref_pipeline_layout(struct vk_device *dev,
VkPipelineLayout layout)
{
VK_FROM_HANDLE(vk_pipeline_layout, playout, layout);
vk_pipeline_layout_unref(dev, playout);
}
VkResult
panvk_CreateDevice(VkPhysicalDevice physicalDevice,
const VkDeviceCreateInfo *pCreateInfo,
@ -1019,8 +1001,6 @@ panvk_CreateDevice(VkPhysicalDevice physicalDevice,
* whole struct.
*/
device->vk.command_dispatch_table = &device->cmd_dispatch;
device->vk.ref_pipeline_layout = panvk_ref_pipeline_layout;
device->vk.unref_pipeline_layout = panvk_unref_pipeline_layout;
device->instance = physical_device->instance;
device->physical_device = physical_device;

View File

@ -26,6 +26,7 @@
#include "vk_cmd_enqueue_entrypoints.h"
#include "vk_command_buffer.h"
#include "vk_device.h"
#include "vk_pipeline_layout.h"
#include "vk_util.h"
VKAPI_ATTR void VKAPI_CALL
@ -202,11 +203,12 @@ unref_pipeline_layout(struct vk_cmd_queue *queue,
{
struct vk_command_buffer *cmd_buffer =
container_of(queue, struct vk_command_buffer, cmd_queue);
struct vk_device *device = cmd_buffer->base.device;
VK_FROM_HANDLE(vk_pipeline_layout, layout,
cmd->u.bind_descriptor_sets.layout);
assert(cmd->type == VK_CMD_BIND_DESCRIPTOR_SETS);
device->unref_pipeline_layout(device, cmd->u.bind_descriptor_sets.layout);
vk_pipeline_layout_unref(cmd_buffer->base.device, layout);
}
VKAPI_ATTR void VKAPI_CALL
@ -220,7 +222,6 @@ vk_cmd_enqueue_CmdBindDescriptorSets(VkCommandBuffer commandBuffer,
const uint32_t *pDynamicOffsets)
{
VK_FROM_HANDLE(vk_command_buffer, cmd_buffer, commandBuffer);
struct vk_device *device = cmd_buffer->base.device;
struct vk_cmd_queue_entry *cmd =
vk_zalloc(cmd_buffer->cmd_queue.alloc, sizeof(*cmd), 8,
@ -235,7 +236,7 @@ vk_cmd_enqueue_CmdBindDescriptorSets(VkCommandBuffer commandBuffer,
* command is in the queue. Otherwise, it may get deleted out from under
* us before the command is replayed.
*/
device->ref_pipeline_layout(device, layout);
vk_pipeline_layout_ref(vk_pipeline_layout_from_handle(layout));
cmd->u.bind_descriptor_sets.layout = layout;
cmd->driver_free_cb = unref_pipeline_layout;

View File

@ -169,22 +169,6 @@ struct vk_device {
bool signal_memory,
struct vk_sync **sync_out);
/** Increments the reference count on a pipeline layout
*
* This is required for vk_enqueue_CmdBindDescriptorSets() to avoid
* use-after-free problems with pipeline layouts. If you're not using
* the command queue, you can ignore this.
*/
void (*ref_pipeline_layout)(struct vk_device *device,
VkPipelineLayout layout);
/** Decrements the reference count on a pipeline layout
*
* See ref_pipeline_layout above.
*/
void (*unref_pipeline_layout)(struct vk_device *device,
VkPipelineLayout layout);
/* Set by vk_device_set_drm_fd() */
int drm_fd;