[vulkan] Split out the push constants helper

It proved to work well in the sprite pipeline, and should be useful for
cleaning up the magic numbers in bsp and alias.
This commit is contained in:
Bill Currie 2021-12-17 14:54:02 +09:00
parent 0b99ff104d
commit b9bc3fa132
3 changed files with 26 additions and 12 deletions

View file

@ -44,4 +44,15 @@ int QFV_QueueSubmit (struct qfv_queue_s *queue,
qfv_semaphoreset_t *signalSemaphores, VkFence fence); qfv_semaphoreset_t *signalSemaphores, VkFence fence);
int QFV_QueueWaitIdle (struct qfv_queue_s *queue); int QFV_QueueWaitIdle (struct qfv_queue_s *queue);
typedef struct {
VkShaderStageFlags stageFlags;
uint32_t offset;
uint32_t size;
const void *data;
} qfv_push_constants_t;
void QFV_PushConstants (struct qfv_device_s *device, VkCommandBuffer cmd,
VkPipelineLayout layout, uint32_t numPC,
const qfv_push_constants_t *constants);
#endif//__QF_Vulkan_command_h #endif//__QF_Vulkan_command_h

View file

@ -162,3 +162,17 @@ QFV_QueueWaitIdle (qfv_queue_t *queue)
qfv_devfuncs_t *dfunc = device->funcs; qfv_devfuncs_t *dfunc = device->funcs;
return dfunc->vkQueueWaitIdle (queue->queue) == VK_SUCCESS; return dfunc->vkQueueWaitIdle (queue->queue) == VK_SUCCESS;
} }
void
QFV_PushConstants (qfv_device_t *device, VkCommandBuffer cmd,
VkPipelineLayout layout, uint32_t numPC,
const qfv_push_constants_t *constants)
{
qfv_devfuncs_t *dfunc = device->funcs;
for (uint32_t i = 0; i < numPC; i++) {
dfunc->vkCmdPushConstants (cmd, layout, constants[i].stageFlags,
constants[i].offset, constants[i].size,
constants[i].data);
}
}

View file

@ -67,13 +67,6 @@
#include "r_internal.h" #include "r_internal.h"
#include "vid_vulkan.h" #include "vid_vulkan.h"
typedef struct {
VkShaderStageFlags stageFlags;
uint32_t offset;
uint32_t size;
const void *data;
} qfv_push_constants_t;
static const char * __attribute__((used)) sprite_pass_names[] = { static const char * __attribute__((used)) sprite_pass_names[] = {
"depth", "depth",
"g-buffer", "g-buffer",
@ -96,11 +89,7 @@ emit_commands (VkCommandBuffer cmd, qfv_sprite_t *sprite,
qfv_devfuncs_t *dfunc = device->funcs; qfv_devfuncs_t *dfunc = device->funcs;
spritectx_t *sctx = ctx->sprite_context; spritectx_t *sctx = ctx->sprite_context;
for (int i = 0; i < numPC; i++) { QFV_PushConstants (device, cmd, sctx->layout, numPC, constants);
dfunc->vkCmdPushConstants (cmd, sctx->layout, constants[i].stageFlags,
constants[i].offset, constants[i].size,
constants[i].data);
}
VkDescriptorSet sets[] = { VkDescriptorSet sets[] = {
sprite->descriptors, sprite->descriptors,
}; };