v3dv: implement vk{Create,Destroy}Semaphore
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
This commit is contained in:
parent
0b08f83817
commit
d24dbd87ad
|
@ -519,6 +519,11 @@ void v3dv_cmd_buffer_finish_job(struct v3dv_cmd_buffer *cmd_buffer);
|
|||
void v3dv_cmd_buffer_start_frame(struct v3dv_cmd_buffer *cmd_buffer,
|
||||
const struct v3dv_framebuffer *framebuffer);
|
||||
|
||||
struct v3dv_semaphore {
|
||||
/* A syncobject handle associated with this semaphore */
|
||||
uint32_t sync;
|
||||
};
|
||||
|
||||
struct v3dv_shader_module {
|
||||
unsigned char sha1[20];
|
||||
uint32_t size;
|
||||
|
@ -728,6 +733,7 @@ V3DV_DEFINE_NONDISP_HANDLE_CASTS(v3dv_image, VkImage)
|
|||
V3DV_DEFINE_NONDISP_HANDLE_CASTS(v3dv_image_view, VkImageView)
|
||||
V3DV_DEFINE_NONDISP_HANDLE_CASTS(v3dv_pipeline, VkPipeline)
|
||||
V3DV_DEFINE_NONDISP_HANDLE_CASTS(v3dv_render_pass, VkRenderPass)
|
||||
V3DV_DEFINE_NONDISP_HANDLE_CASTS(v3dv_semaphore, VkSemaphore)
|
||||
V3DV_DEFINE_NONDISP_HANDLE_CASTS(v3dv_shader_module, VkShaderModule)
|
||||
|
||||
/* This is defined as a macro so that it works for both
|
||||
|
|
|
@ -157,3 +157,45 @@ v3dv_QueueSubmit(VkQueue _queue,
|
|||
|
||||
return result;
|
||||
}
|
||||
|
||||
VkResult
|
||||
v3dv_CreateSemaphore(VkDevice _device,
|
||||
const VkSemaphoreCreateInfo *pCreateInfo,
|
||||
const VkAllocationCallbacks *pAllocator,
|
||||
VkSemaphore *pSemaphore)
|
||||
{
|
||||
V3DV_FROM_HANDLE(v3dv_device, device, _device);
|
||||
|
||||
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO);
|
||||
|
||||
struct v3dv_semaphore *sem =
|
||||
vk_alloc2(&device->alloc, pAllocator, sizeof(struct v3dv_semaphore), 8,
|
||||
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
|
||||
if (sem == NULL)
|
||||
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
|
||||
int ret = drmSyncobjCreate(device->fd, 0, &sem->sync);
|
||||
if (ret) {
|
||||
vk_free2(&device->alloc, pAllocator, sem);
|
||||
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
}
|
||||
|
||||
*pSemaphore = v3dv_semaphore_to_handle(sem);
|
||||
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
void
|
||||
v3dv_DestroySemaphore(VkDevice _device,
|
||||
VkSemaphore semaphore,
|
||||
const VkAllocationCallbacks *pAllocator)
|
||||
{
|
||||
V3DV_FROM_HANDLE(v3dv_device, device, _device);
|
||||
V3DV_FROM_HANDLE(v3dv_semaphore, sem, semaphore);
|
||||
|
||||
if (sem == NULL)
|
||||
return;
|
||||
|
||||
drmSyncobjDestroy(device->fd, sem->sync);
|
||||
vk_free2(&device->alloc, pAllocator, sem);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue