Add a queue type

This commit is contained in:
Bill Currie 2019-07-23 12:37:47 +09:00
parent 411b897f09
commit a165d67dfa
5 changed files with 22 additions and 9 deletions

View file

@ -48,6 +48,7 @@ typedef struct qfv_fenceset_s {
} qfv_fenceset_t; } qfv_fenceset_t;
struct qfv_device_s; struct qfv_device_s;
struct qfv_queue_s;
qfv_cmdpool_t *QFV_CreateCommandPool (struct qfv_device_s *device, qfv_cmdpool_t *QFV_CreateCommandPool (struct qfv_device_s *device,
uint32_t queueFamily, uint32_t queueFamily,
int transient, int reset); int transient, int reset);
@ -70,7 +71,7 @@ qfv_fence_t *QFV_CreateFence (struct qfv_device_s *device, int signaled);
qfv_fenceset_t *QFV_CreateFenceSet (qfv_fence_t **fences, int numFences); qfv_fenceset_t *QFV_CreateFenceSet (qfv_fence_t **fences, int numFences);
int QFV_WaitForFences (qfv_fenceset_t *fences, int all, uint64_t timeout); int QFV_WaitForFences (qfv_fenceset_t *fences, int all, uint64_t timeout);
int QFV_ResetFences (qfv_fenceset_t *fences); int QFV_ResetFences (qfv_fenceset_t *fences);
int QFV_QueueSubmit (struct qfv_device_s *device, int QFV_QueueSubmit (struct qfv_queue_s *queue,
qfv_semaphoreset_t *waitSemaphores, qfv_semaphoreset_t *waitSemaphores,
qfv_cmdbufferset_t *buffers, qfv_cmdbufferset_t *buffers,
qfv_semaphoreset_t *signalSemaphores, qfv_fence_t *fence); qfv_semaphoreset_t *signalSemaphores, qfv_fence_t *fence);

View file

@ -7,13 +7,21 @@ typedef struct qfv_devfuncs_s {
#include "QF/Vulkan/funclist.h" #include "QF/Vulkan/funclist.h"
} qfv_devfuncs_t; } qfv_devfuncs_t;
struct qfv_device_s;
typedef struct qfv_queue_s {
VkDevice dev;
qfv_devfuncs_t *funcs;
int32_t queueFamily;
VkQueue queue;
} qfv_queue_t;
struct qfv_instance_s; struct qfv_instance_s;
typedef struct qfv_device_s { typedef struct qfv_device_s {
VkDevice dev; VkDevice dev;
VkPhysicalDevice physDev; VkPhysicalDevice physDev;
qfv_devfuncs_t *funcs; qfv_devfuncs_t *funcs;
int32_t queueFamily; qfv_queue_t queue;
VkQueue queue;
struct strset_s *enabled_extensions; struct strset_s *enabled_extensions;
int (*extension_enabled) (struct qfv_device_s *inst, int (*extension_enabled) (struct qfv_device_s *inst,
const char *ext); const char *ext);

View file

@ -297,11 +297,11 @@ QFV_ResetFences (qfv_fenceset_t *fences)
} }
int int
QFV_QueueSubmit (qfv_device_t *device, qfv_semaphoreset_t *waitSemaphores, QFV_QueueSubmit (qfv_queue_t *queue, qfv_semaphoreset_t *waitSemaphores,
qfv_cmdbufferset_t *buffers, qfv_cmdbufferset_t *buffers,
qfv_semaphoreset_t *signalSemaphores, qfv_fence_t *fence) qfv_semaphoreset_t *signalSemaphores, qfv_fence_t *fence)
{ {
qfv_devfuncs_t *dfunc = device->funcs; qfv_devfuncs_t *dfunc = queue->funcs;
VkSubmitInfo submitInfo = { VkSubmitInfo submitInfo = {
VK_STRUCTURE_TYPE_SUBMIT_INFO, 0, VK_STRUCTURE_TYPE_SUBMIT_INFO, 0,
waitSemaphores->numSemaphores, waitSemaphores->numSemaphores,
@ -311,6 +311,6 @@ QFV_QueueSubmit (qfv_device_t *device, qfv_semaphoreset_t *waitSemaphores,
signalSemaphores->semaphores signalSemaphores->semaphores
}; };
//FIXME multi-batch //FIXME multi-batch
return dfunc->vkQueueSubmit (device->queue, 1, &submitInfo, return dfunc->vkQueueSubmit (queue->queue, 1, &submitInfo,
fence->fence) == VK_SUCCESS; fence->fence) == VK_SUCCESS;
} }

View file

@ -191,8 +191,11 @@ QFV_CreateDevice (vulkan_ctx_t *ctx, const char **extensions)
device->physDev = physdev; device->physDev = physdev;
load_device_funcs (inst, device); load_device_funcs (inst, device);
device->queueFamily = family; device->queue.dev = device->dev;
dfunc->vkGetDeviceQueue (device->dev, family, 0, &device->queue); device->queue.funcs = dfunc;
device->queue.queueFamily = family;
dfunc->vkGetDeviceQueue (device->dev, family, 0,
&device->queue.queue);
ctx->device = device; ctx->device = device;
return device; return device;
} }

View file

@ -27,10 +27,11 @@ QFV_CreateSwapchain (vulkan_ctx_t *ctx, VkSwapchainKHR old_swapchain)
{ {
qfv_instfuncs_t *ifuncs = ctx->instance->funcs; qfv_instfuncs_t *ifuncs = ctx->instance->funcs;
qfv_devfuncs_t *dfuncs = ctx->device->funcs; qfv_devfuncs_t *dfuncs = ctx->device->funcs;
qfv_queue_t *queue = &ctx->device->queue;
VkBool32 supported; VkBool32 supported;
ifuncs->vkGetPhysicalDeviceSurfaceSupportKHR (ctx->device->physDev, ifuncs->vkGetPhysicalDeviceSurfaceSupportKHR (ctx->device->physDev,
ctx->device->queueFamily, queue->queueFamily,
ctx->surface, ctx->surface,
&supported); &supported);
if (!supported) { if (!supported) {