panvk: Hook up emulated secondary command buffers

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14406>
This commit is contained in:
Jason Ekstrand 2022-03-08 18:04:54 -06:00 committed by Marge Bot
parent 18fced0226
commit 012bfde7f3
5 changed files with 63 additions and 12 deletions

View file

@ -5,6 +5,11 @@ renderer_check = "Mali-G52"
include = [
"dEQP-VK.pipeline.blend.*",
"dEQP-VK.api.buffer_view.*",
"dEQP-VK.api.command_buffers.record_many_draws_secondary_2",
"dEQP-VK.api.command_buffers.record_many_secondary",
"dEQP-VK.api.command_buffers.record_one_time_submit_secondary",
"dEQP-VK.api.command_buffers.render_pass_continue",
"dEQP-VK.api.command_buffers.render_pass_continue_no_fb",
"dEQP-VK.api.copy_and_blit.core.*",
"dEQP-VK.compute.builtin_var.*",
"dEQP-VK.draw.renderpass.instanced.draw_indexed_vk_*",

View file

@ -338,14 +338,6 @@ panvk_CmdSetStencilReference(VkCommandBuffer commandBuffer,
cmdbuf->state.fs_rsd = 0;
}
void
panvk_CmdExecuteCommands(VkCommandBuffer commandBuffer,
uint32_t commandBufferCount,
const VkCommandBuffer *pCmdBuffers)
{
panvk_stub();
}
VkResult
panvk_CreateCommandPool(VkDevice _device,
const VkCommandPoolCreateInfo *pCreateInfo,

View file

@ -31,6 +31,8 @@
#include "pan_bo.h"
#include "pan_encoder.h"
#include "pan_util.h"
#include "vk_common_entrypoints.h"
#include "vk_cmd_enqueue_entrypoints.h"
#include <fcntl.h>
#include <libsync.h>
@ -920,6 +922,25 @@ 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(panvk_pipeline_layout, playout, layout);
panvk_pipeline_layout_ref(playout);
}
static void
panvk_unref_pipeline_layout(struct vk_device *dev,
VkPipelineLayout layout)
{
struct panvk_device *device = container_of(dev, struct panvk_device, vk);
VK_FROM_HANDLE(panvk_pipeline_layout, playout, layout);
panvk_pipeline_layout_unref(device, playout);
}
VkResult
panvk_CreateDevice(VkPhysicalDevice physicalDevice,
const VkDeviceCreateInfo *pCreateInfo,
@ -952,15 +973,35 @@ panvk_CreateDevice(VkPhysicalDevice physicalDevice,
unreachable("Unsupported architecture");
}
/* For secondary command buffer support, overwrite any command entrypoints
* in the main device-level dispatch table with
* vk_cmd_enqueue_unless_primary_Cmd*.
*/
vk_device_dispatch_table_from_entrypoints(&dispatch_table,
&vk_cmd_enqueue_unless_primary_device_entrypoints,
true);
vk_device_dispatch_table_from_entrypoints(&dispatch_table,
dev_entrypoints,
true);
false);
vk_device_dispatch_table_from_entrypoints(&dispatch_table,
&panvk_device_entrypoints,
false);
vk_device_dispatch_table_from_entrypoints(&dispatch_table,
&wsi_device_entrypoints,
false);
/* Populate our primary cmd_dispatch table. */
vk_device_dispatch_table_from_entrypoints(&device->cmd_dispatch,
dev_entrypoints,
true);
vk_device_dispatch_table_from_entrypoints(&device->cmd_dispatch,
&panvk_device_entrypoints,
false);
vk_device_dispatch_table_from_entrypoints(&device->cmd_dispatch,
&vk_common_device_entrypoints,
false);
result = vk_device_init(&device->vk, &physical_device->vk, &dispatch_table,
pCreateInfo, pAllocator);
if (result != VK_SUCCESS) {
@ -968,6 +1009,13 @@ panvk_CreateDevice(VkPhysicalDevice physicalDevice,
return result;
}
/* Must be done after vk_device_init() because this function memset(0) the
* 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

@ -246,6 +246,8 @@ struct panvk_queue {
struct panvk_device {
struct vk_device vk;
struct vk_device_dispatch_table cmd_dispatch;
struct panvk_instance *instance;
struct panvk_queue *queues[PANVK_MAX_QUEUE_FAMILIES];

View file

@ -1071,11 +1071,15 @@ VkResult
panvk_per_arch(EndCommandBuffer)(VkCommandBuffer commandBuffer)
{
VK_FROM_HANDLE(panvk_cmd_buffer, cmdbuf, commandBuffer);
VkResult ret =
cmdbuf->vk.level == VK_COMMAND_BUFFER_LEVEL_SECONDARY ?
cmdbuf->vk.cmd_queue.error : cmdbuf->record_result;
panvk_per_arch(cmd_close_batch)(cmdbuf);
cmdbuf->status = PANVK_CMD_BUFFER_STATUS_EXECUTABLE;
return cmdbuf->record_result;
cmdbuf->status = ret == VK_SUCCESS ?
PANVK_CMD_BUFFER_STATUS_EXECUTABLE :
PANVK_CMD_BUFFER_STATUS_INVALID;
return ret;
}
void