mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-08 02:00:21 +01:00
panvk: Move the VkEvent logic to panvk_event.{c,h}
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com> Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com> Reviewed-by: Mary Guillemard <mary.guillemard@collabora.com> Reviewed-by: Rebecca Mckeever <rebecca.mckeever@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28170>
This commit is contained in:
parent
adab7d3fcc
commit
4a16aaafb5
7 changed files with 136 additions and 112 deletions
|
|
@ -41,6 +41,7 @@ libpanvk_files = files(
|
|||
'panvk_device.c',
|
||||
'panvk_device_memory.c',
|
||||
'panvk_descriptor_set.c',
|
||||
'panvk_event.c',
|
||||
'panvk_formats.c',
|
||||
'panvk_image.c',
|
||||
'panvk_mempool.c',
|
||||
|
|
|
|||
|
|
@ -1319,112 +1319,6 @@ vk_icdGetInstanceProcAddr(VkInstance instance, const char *pName)
|
|||
return panvk_GetInstanceProcAddr(instance, pName);
|
||||
}
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL
|
||||
panvk_CreateEvent(VkDevice _device, const VkEventCreateInfo *pCreateInfo,
|
||||
const VkAllocationCallbacks *pAllocator, VkEvent *pEvent)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_device, device, _device);
|
||||
struct panvk_event *event = vk_object_zalloc(
|
||||
&device->vk, pAllocator, sizeof(*event), VK_OBJECT_TYPE_EVENT);
|
||||
if (!event)
|
||||
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
|
||||
struct drm_syncobj_create create = {
|
||||
.flags = 0,
|
||||
};
|
||||
|
||||
int ret = drmIoctl(device->vk.drm_fd, DRM_IOCTL_SYNCOBJ_CREATE, &create);
|
||||
if (ret)
|
||||
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
||||
|
||||
event->syncobj = create.handle;
|
||||
*pEvent = panvk_event_to_handle(event);
|
||||
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
VKAPI_ATTR void VKAPI_CALL
|
||||
panvk_DestroyEvent(VkDevice _device, VkEvent _event,
|
||||
const VkAllocationCallbacks *pAllocator)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_device, device, _device);
|
||||
VK_FROM_HANDLE(panvk_event, event, _event);
|
||||
|
||||
if (!event)
|
||||
return;
|
||||
|
||||
struct drm_syncobj_destroy destroy = {.handle = event->syncobj};
|
||||
drmIoctl(device->vk.drm_fd, DRM_IOCTL_SYNCOBJ_DESTROY, &destroy);
|
||||
|
||||
vk_object_free(&device->vk, pAllocator, event);
|
||||
}
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL
|
||||
panvk_GetEventStatus(VkDevice _device, VkEvent _event)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_device, device, _device);
|
||||
VK_FROM_HANDLE(panvk_event, event, _event);
|
||||
bool signaled;
|
||||
|
||||
struct drm_syncobj_wait wait = {
|
||||
.handles = (uintptr_t)&event->syncobj,
|
||||
.count_handles = 1,
|
||||
.timeout_nsec = 0,
|
||||
.flags = DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT,
|
||||
};
|
||||
|
||||
int ret = drmIoctl(device->vk.drm_fd, DRM_IOCTL_SYNCOBJ_WAIT, &wait);
|
||||
if (ret) {
|
||||
if (errno == ETIME)
|
||||
signaled = false;
|
||||
else {
|
||||
assert(0);
|
||||
return VK_ERROR_DEVICE_LOST; /* TODO */
|
||||
}
|
||||
} else
|
||||
signaled = true;
|
||||
|
||||
return signaled ? VK_EVENT_SET : VK_EVENT_RESET;
|
||||
}
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL
|
||||
panvk_SetEvent(VkDevice _device, VkEvent _event)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_device, device, _device);
|
||||
VK_FROM_HANDLE(panvk_event, event, _event);
|
||||
|
||||
struct drm_syncobj_array objs = {
|
||||
.handles = (uint64_t)(uintptr_t)&event->syncobj,
|
||||
.count_handles = 1};
|
||||
|
||||
/* This is going to just replace the fence for this syncobj with one that
|
||||
* is already in signaled state. This won't be a problem because the spec
|
||||
* mandates that the event will have been set before the vkCmdWaitEvents
|
||||
* command executes.
|
||||
* https://www.khronos.org/registry/vulkan/specs/1.2/html/chap6.html#commandbuffers-submission-progress
|
||||
*/
|
||||
if (drmIoctl(device->vk.drm_fd, DRM_IOCTL_SYNCOBJ_SIGNAL, &objs))
|
||||
return VK_ERROR_DEVICE_LOST;
|
||||
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL
|
||||
panvk_ResetEvent(VkDevice _device, VkEvent _event)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_device, device, _device);
|
||||
VK_FROM_HANDLE(panvk_event, event, _event);
|
||||
|
||||
struct drm_syncobj_array objs = {
|
||||
.handles = (uint64_t)(uintptr_t)&event->syncobj,
|
||||
.count_handles = 1};
|
||||
|
||||
if (drmIoctl(device->vk.drm_fd, DRM_IOCTL_SYNCOBJ_RESET, &objs))
|
||||
return VK_ERROR_DEVICE_LOST;
|
||||
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
VKAPI_ATTR void VKAPI_CALL
|
||||
panvk_GetPhysicalDeviceExternalSemaphoreProperties(
|
||||
VkPhysicalDevice physicalDevice,
|
||||
|
|
|
|||
113
src/panfrost/vulkan/panvk_event.c
Normal file
113
src/panfrost/vulkan/panvk_event.c
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
/*
|
||||
* Copyright © 2021 Collabora Ltd.
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include "panvk_event.h"
|
||||
#include "panvk_private.h"
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL
|
||||
panvk_CreateEvent(VkDevice _device, const VkEventCreateInfo *pCreateInfo,
|
||||
const VkAllocationCallbacks *pAllocator, VkEvent *pEvent)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_device, device, _device);
|
||||
struct panvk_event *event = vk_object_zalloc(
|
||||
&device->vk, pAllocator, sizeof(*event), VK_OBJECT_TYPE_EVENT);
|
||||
if (!event)
|
||||
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
|
||||
struct drm_syncobj_create create = {
|
||||
.flags = 0,
|
||||
};
|
||||
|
||||
int ret = drmIoctl(device->vk.drm_fd, DRM_IOCTL_SYNCOBJ_CREATE, &create);
|
||||
if (ret)
|
||||
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
||||
|
||||
event->syncobj = create.handle;
|
||||
*pEvent = panvk_event_to_handle(event);
|
||||
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
VKAPI_ATTR void VKAPI_CALL
|
||||
panvk_DestroyEvent(VkDevice _device, VkEvent _event,
|
||||
const VkAllocationCallbacks *pAllocator)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_device, device, _device);
|
||||
VK_FROM_HANDLE(panvk_event, event, _event);
|
||||
|
||||
if (!event)
|
||||
return;
|
||||
|
||||
struct drm_syncobj_destroy destroy = {.handle = event->syncobj};
|
||||
drmIoctl(device->vk.drm_fd, DRM_IOCTL_SYNCOBJ_DESTROY, &destroy);
|
||||
|
||||
vk_object_free(&device->vk, pAllocator, event);
|
||||
}
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL
|
||||
panvk_GetEventStatus(VkDevice _device, VkEvent _event)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_device, device, _device);
|
||||
VK_FROM_HANDLE(panvk_event, event, _event);
|
||||
bool signaled;
|
||||
|
||||
struct drm_syncobj_wait wait = {
|
||||
.handles = (uintptr_t)&event->syncobj,
|
||||
.count_handles = 1,
|
||||
.timeout_nsec = 0,
|
||||
.flags = DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT,
|
||||
};
|
||||
|
||||
int ret = drmIoctl(device->vk.drm_fd, DRM_IOCTL_SYNCOBJ_WAIT, &wait);
|
||||
if (ret) {
|
||||
if (errno == ETIME)
|
||||
signaled = false;
|
||||
else {
|
||||
assert(0);
|
||||
return VK_ERROR_DEVICE_LOST; /* TODO */
|
||||
}
|
||||
} else
|
||||
signaled = true;
|
||||
|
||||
return signaled ? VK_EVENT_SET : VK_EVENT_RESET;
|
||||
}
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL
|
||||
panvk_SetEvent(VkDevice _device, VkEvent _event)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_device, device, _device);
|
||||
VK_FROM_HANDLE(panvk_event, event, _event);
|
||||
|
||||
struct drm_syncobj_array objs = {
|
||||
.handles = (uint64_t)(uintptr_t)&event->syncobj,
|
||||
.count_handles = 1};
|
||||
|
||||
/* This is going to just replace the fence for this syncobj with one that
|
||||
* is already in signaled state. This won't be a problem because the spec
|
||||
* mandates that the event will have been set before the vkCmdWaitEvents
|
||||
* command executes.
|
||||
* https://www.khronos.org/registry/vulkan/specs/1.2/html/chap6.html#commandbuffers-submission-progress
|
||||
*/
|
||||
if (drmIoctl(device->vk.drm_fd, DRM_IOCTL_SYNCOBJ_SIGNAL, &objs))
|
||||
return VK_ERROR_DEVICE_LOST;
|
||||
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL
|
||||
panvk_ResetEvent(VkDevice _device, VkEvent _event)
|
||||
{
|
||||
VK_FROM_HANDLE(panvk_device, device, _device);
|
||||
VK_FROM_HANDLE(panvk_event, event, _event);
|
||||
|
||||
struct drm_syncobj_array objs = {
|
||||
.handles = (uint64_t)(uintptr_t)&event->syncobj,
|
||||
.count_handles = 1};
|
||||
|
||||
if (drmIoctl(device->vk.drm_fd, DRM_IOCTL_SYNCOBJ_RESET, &objs))
|
||||
return VK_ERROR_DEVICE_LOST;
|
||||
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
20
src/panfrost/vulkan/panvk_event.h
Normal file
20
src/panfrost/vulkan/panvk_event.h
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* Copyright © 2021 Collabora Ltd.
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#ifndef PANVK_EVENT_H
|
||||
#define PANVK_EVENT_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "vk_object.h"
|
||||
|
||||
struct panvk_event {
|
||||
struct vk_object_base base;
|
||||
uint32_t syncobj;
|
||||
};
|
||||
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_event, base, VkEvent, VK_OBJECT_TYPE_EVENT)
|
||||
|
||||
#endif
|
||||
|
|
@ -730,11 +730,6 @@ struct panvk_batch *panvk_cmd_open_batch(struct panvk_cmd_buffer *cmdbuf);
|
|||
|
||||
void panvk_cmd_preload_fb_after_batch_split(struct panvk_cmd_buffer *cmdbuf);
|
||||
|
||||
struct panvk_event {
|
||||
struct vk_object_base base;
|
||||
uint32_t syncobj;
|
||||
};
|
||||
|
||||
struct panvk_shader {
|
||||
struct pan_shader_info info;
|
||||
struct util_dynarray binary;
|
||||
|
|
@ -772,7 +767,6 @@ VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_descriptor_set, base, VkDescriptorSet,
|
|||
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_descriptor_set_layout, vk.base,
|
||||
VkDescriptorSetLayout,
|
||||
VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT)
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_event, base, VkEvent, VK_OBJECT_TYPE_EVENT)
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_pipeline_layout, vk.base, VkPipelineLayout,
|
||||
VK_OBJECT_TYPE_PIPELINE_LAYOUT)
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
|
||||
#include "panvk_buffer.h"
|
||||
#include "panvk_cs.h"
|
||||
#include "panvk_event.h"
|
||||
#include "panvk_image.h"
|
||||
#include "panvk_image_view.h"
|
||||
#include "panvk_pipeline.h"
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
#include "decode.h"
|
||||
|
||||
#include "panvk_cs.h"
|
||||
#include "panvk_event.h"
|
||||
#include "panvk_image.h"
|
||||
#include "panvk_image_view.h"
|
||||
#include "panvk_private.h"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue