mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-18 15:01:41 +00:00
Implement the rest of the command stuff
This commit is contained in:
parent
a165d67dfa
commit
4957c4f31a
5 changed files with 96 additions and 1 deletions
|
@ -10,6 +10,7 @@ typedef struct qfv_cmdpool_s {
|
|||
typedef struct qfv_cmdbuffer_s {
|
||||
VkDevice dev;
|
||||
struct qfv_devfuncs_s *funcs;
|
||||
VkCommandPool cmdpool;
|
||||
VkCommandBuffer buffer;
|
||||
} qfv_cmdbuffer_t;
|
||||
|
||||
|
@ -53,10 +54,14 @@ qfv_cmdpool_t *QFV_CreateCommandPool (struct qfv_device_s *device,
|
|||
uint32_t queueFamily,
|
||||
int transient, int reset);
|
||||
int QFV_ResetCommandPool (qfv_cmdpool_t *pool, int release);
|
||||
void QFV_DestroyCommandPool (qfv_cmdpool_t *pool);
|
||||
qfv_cmdbuffer_t *QFV_AllocateCommandBuffers (qfv_cmdpool_t *pool,
|
||||
int secondary, int count);
|
||||
qfv_cmdbufferset_t *QFV_CreateCommandBufferSet (qfv_cmdbuffer_t **buffers,
|
||||
int numBuffers);
|
||||
void QFV_FreeCommandBuffers (qfv_cmdbuffer_t *buffer, int count);
|
||||
// NOTE: does not destroy buffers
|
||||
void QFV_DestroyCommandBufferSet (qfv_cmdbufferset_t *buffers);
|
||||
int QFV_BeginCommandBuffer (qfv_cmdbuffer_t *buffer, int oneTime,
|
||||
int rpContinue, int simultaneous,
|
||||
VkCommandBufferInheritanceInfo *inheritanceInfo);
|
||||
|
@ -66,15 +71,21 @@ int QFV_ResetCommandBuffer (qfv_cmdbuffer_t *buffer, int release);
|
|||
qfv_semaphore_t *QFV_CreateSemaphore (struct qfv_device_s *device);
|
||||
qfv_semaphoreset_t *QFV_CreateSemaphoreSet (qfv_semaphore_t **semaphores,
|
||||
int numSemaphores);
|
||||
|
||||
void QFV_DestroySemaphore (qfv_semaphore_t *semaphore);
|
||||
// NOTE: does not destroy semaphores
|
||||
void QFV_DestroySemaphoreSet (qfv_semaphoreset_t *semaphores);
|
||||
qfv_fence_t *QFV_CreateFence (struct qfv_device_s *device, int signaled);
|
||||
qfv_fenceset_t *QFV_CreateFenceSet (qfv_fence_t **fences, int numFences);
|
||||
void QFV_DestroyFence (qfv_fence_t *fence);
|
||||
// NOTE: does not destroy fences
|
||||
void QFV_DestroyFenceSet (qfv_fenceset_t *fences);
|
||||
int QFV_WaitForFences (qfv_fenceset_t *fences, int all, uint64_t timeout);
|
||||
int QFV_ResetFences (qfv_fenceset_t *fences);
|
||||
int QFV_QueueSubmit (struct qfv_queue_s *queue,
|
||||
qfv_semaphoreset_t *waitSemaphores,
|
||||
qfv_cmdbufferset_t *buffers,
|
||||
qfv_semaphoreset_t *signalSemaphores, qfv_fence_t *fence);
|
||||
int QFV_QueueWaitIdle (struct qfv_queue_s *queue);
|
||||
|
||||
|
||||
#endif//__QF_Vulkan_command_h
|
||||
|
|
|
@ -31,5 +31,6 @@ struct vulkan_ctx_s;
|
|||
qfv_device_t *QFV_CreateDevice (struct vulkan_ctx_s *ctx,
|
||||
const char **extensions);
|
||||
void QFV_DestroyDevice (qfv_device_t *device);
|
||||
int QFV_DeviceWaitIdle (qfv_device_t *device);
|
||||
|
||||
#endif//__QF_Vulkan_device_h
|
||||
|
|
|
@ -101,6 +101,12 @@ DEVICE_LEVEL_VULKAN_FUNCTION (vkCreateFence)
|
|||
DEVICE_LEVEL_VULKAN_FUNCTION (vkWaitForFences)
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION (vkResetFences)
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION (vkQueueSubmit)
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION (vkQueueWaitIdle)
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION (vkDeviceWaitIdle)
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION (vkDestroyFence)
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION (vkDestroySemaphore)
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION (vkFreeCommandBuffers)
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION (vkDestroyCommandPool)
|
||||
|
||||
#undef DEVICE_LEVEL_VULKAN_FUNCTION
|
||||
|
||||
|
|
|
@ -100,6 +100,16 @@ QFV_ResetCommandPool (qfv_cmdpool_t *pool, int release)
|
|||
return dfunc->vkResetCommandPool (dev, cmdpool, release_flag) == VK_SUCCESS;
|
||||
}
|
||||
|
||||
void
|
||||
QFV_DestroyCommandPool (qfv_cmdpool_t *pool)
|
||||
{
|
||||
VkDevice dev = pool->dev;
|
||||
qfv_devfuncs_t *dfunc = pool->funcs;
|
||||
|
||||
dfunc->vkDestroyCommandPool (dev, pool->cmdpool, 0);
|
||||
free (pool);
|
||||
}
|
||||
|
||||
qfv_cmdbuffer_t *
|
||||
QFV_AllocateCommandBuffers (qfv_cmdpool_t *pool, int secondary, int count)
|
||||
{
|
||||
|
@ -119,6 +129,7 @@ QFV_AllocateCommandBuffers (qfv_cmdpool_t *pool, int secondary, int count)
|
|||
for (int i = 0; i < count; i++) {
|
||||
cmdbuffers[i].dev = dev;
|
||||
cmdbuffers[i].funcs = dfunc;
|
||||
cmdbuffers[i].cmdpool = pool->cmdpool;
|
||||
cmdbuffers[i].buffer = buffers[i];
|
||||
}
|
||||
return cmdbuffers;
|
||||
|
@ -144,6 +155,26 @@ QFV_CreateCommandBufferSet (qfv_cmdbuffer_t **buffers, int numBuffers)
|
|||
return bufferset;
|
||||
}
|
||||
|
||||
void QFV_FreeCommandBuffers (qfv_cmdbuffer_t *buffer, int count)
|
||||
{
|
||||
VkDevice dev = buffer->dev;
|
||||
qfv_devfuncs_t *dfunc = buffer->funcs;
|
||||
VkCommandBuffer *buffers = alloca (sizeof (*buffers) * count);
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
buffers[i] = buffer[i].buffer;
|
||||
}
|
||||
|
||||
dfunc->vkFreeCommandBuffers (dev, buffer->cmdpool, count, buffers);
|
||||
free (buffer);
|
||||
}
|
||||
|
||||
void
|
||||
QFV_DestroyCommandBufferSet (qfv_cmdbufferset_t *buffers)
|
||||
{
|
||||
free (buffers);
|
||||
}
|
||||
|
||||
int
|
||||
QFV_BeginCommandBuffer (qfv_cmdbuffer_t *buffer, int oneTime, int rpContinue,
|
||||
int simultaneous,
|
||||
|
@ -237,6 +268,22 @@ QFV_CreateSemaphoreSet (qfv_semaphore_t **semaphores, int numSemaphores)
|
|||
return semaphoreset;
|
||||
}
|
||||
|
||||
void
|
||||
QFV_DestroySemaphore (qfv_semaphore_t *semaphore)
|
||||
{
|
||||
VkDevice dev = semaphore->dev;
|
||||
qfv_devfuncs_t *dfunc = semaphore->funcs;
|
||||
|
||||
dfunc->vkDestroySemaphore (dev, semaphore->semaphore, 0);
|
||||
free (semaphore);
|
||||
}
|
||||
|
||||
void
|
||||
QFV_DestroySemaphoreSet (qfv_semaphoreset_t *semaphores)
|
||||
{
|
||||
free (semaphores);
|
||||
}
|
||||
|
||||
qfv_fence_t *
|
||||
QFV_CreateFence (qfv_device_t *device, int signaled)
|
||||
{
|
||||
|
@ -275,6 +322,22 @@ QFV_CreateFenceSet (qfv_fence_t **fences, int numFences)
|
|||
return fenceset;
|
||||
}
|
||||
|
||||
void
|
||||
QFV_DestroyFence (qfv_fence_t *fence)
|
||||
{
|
||||
VkDevice dev = fence->dev;
|
||||
qfv_devfuncs_t *dfunc = fence->funcs;
|
||||
|
||||
dfunc->vkDestroyFence (dev, fence->fence, 0);
|
||||
free (fence);
|
||||
}
|
||||
|
||||
void
|
||||
QFV_DestroyFenceSet (qfv_fenceset_t *fences)
|
||||
{
|
||||
free (fences);
|
||||
}
|
||||
|
||||
int
|
||||
QFV_WaitForFences (qfv_fenceset_t *fences, int all, uint64_t timeout)
|
||||
{
|
||||
|
@ -314,3 +377,10 @@ QFV_QueueSubmit (qfv_queue_t *queue, qfv_semaphoreset_t *waitSemaphores,
|
|||
return dfunc->vkQueueSubmit (queue->queue, 1, &submitInfo,
|
||||
fence->fence) == VK_SUCCESS;
|
||||
}
|
||||
|
||||
int
|
||||
QFV_QueueWaitIdle (qfv_queue_t *queue)
|
||||
{
|
||||
qfv_devfuncs_t *dfunc = queue->funcs;
|
||||
return dfunc->vkQueueWaitIdle (queue->queue) == VK_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -211,3 +211,10 @@ QFV_DestroyDevice (qfv_device_t *device)
|
|||
del_strset (device->enabled_extensions);
|
||||
free (device);
|
||||
}
|
||||
|
||||
int
|
||||
QFV_DeviceWaitIdle (qfv_device_t *device)
|
||||
{
|
||||
qfv_devfuncs_t *dfunc = device->funcs;
|
||||
return dfunc->vkDeviceWaitIdle (device->dev) == VK_SUCCESS;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue