vkQuake2 doxygen  1.0 dev
vk_cmd.c File Reference
#include "vk_local.h"

Go to the source code of this file.

Functions

VkResult QVk_BeginCommand (const VkCommandBuffer *commandBuffer)
 
void QVk_SubmitCommand (const VkCommandBuffer *commandBuffer, const VkQueue *queue)
 
VkResult QVk_CreateCommandPool (VkCommandPool *commandPool, uint32_t queueFamilyIndex)
 
VkCommandBuffer QVk_CreateCommandBuffer (const VkCommandPool *commandPool, VkCommandBufferLevel level)
 

Function Documentation

◆ QVk_BeginCommand()

VkResult QVk_BeginCommand ( const VkCommandBuffer *  commandBuffer)

Definition at line 23 of file vk_cmd.c.

24 {
25  VkCommandBufferBeginInfo cmdInfo = {
26  .sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,
27  .pNext = NULL,
28  .flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT,
29  .pInheritanceInfo = NULL
30  };
31 
32  return vkBeginCommandBuffer(*commandBuffer, &cmdInfo);
33 }

Referenced by copyBuffer(), CreateStagingBuffers(), and QVk_ReadPixels().

◆ QVk_CreateCommandBuffer()

VkCommandBuffer QVk_CreateCommandBuffer ( const VkCommandPool *  commandPool,
VkCommandBufferLevel  level 
)

Definition at line 78 of file vk_cmd.c.

79 {
80  VkCommandBuffer commandBuffer = VK_NULL_HANDLE;
81  VkCommandBufferAllocateInfo allocInfo = {
82  .sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO,
83  .pNext = NULL,
84  .commandPool = *commandPool,
85  .level = level,
86  .commandBufferCount = 1
87  };
88 
89  VK_VERIFY(vkAllocateCommandBuffers(vk_device.logical, &allocInfo, &commandBuffer));
90  return commandBuffer;
91 }

Referenced by copyBuffer(), CreateStagingBuffers(), and QVk_ReadPixels().

◆ QVk_CreateCommandPool()

VkResult QVk_CreateCommandPool ( VkCommandPool *  commandPool,
uint32_t  queueFamilyIndex 
)

Definition at line 65 of file vk_cmd.c.

66 {
67  VkCommandPoolCreateInfo cpCreateInfo = {
68  .sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,
69  .pNext = NULL,
70  // allow the command pool to be explicitly reset without reallocating it manually during recording each frame
71  .flags = VK_COMMAND_POOL_CREATE_TRANSIENT_BIT | VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT,
72  .queueFamilyIndex = queueFamilyIndex
73  };
74 
75  return vkCreateCommandPool(vk_device.logical, &cpCreateInfo, NULL, commandPool);
76 }

Referenced by CreateStagingBuffers(), and QVk_Init().

◆ QVk_SubmitCommand()

void QVk_SubmitCommand ( const VkCommandBuffer *  commandBuffer,
const VkQueue *  queue 
)

Definition at line 35 of file vk_cmd.c.

36 {
37  VK_VERIFY(vkEndCommandBuffer(*commandBuffer));
38 
39  VkSubmitInfo submitInfo = {
40  .sType = VK_STRUCTURE_TYPE_SUBMIT_INFO,
41  .pNext = NULL,
42  .waitSemaphoreCount = 0,
43  .pWaitSemaphores = NULL,
44  .pWaitDstStageMask = NULL,
45  .commandBufferCount = 1,
46  .pCommandBuffers = commandBuffer,
47  .signalSemaphoreCount = 0,
48  .pSignalSemaphores = NULL
49  };
50 
51  VkFenceCreateInfo fCreateInfo = {
52  .sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO,
53  .pNext = NULL,
54  .flags = 0
55  };
56 
57  VkFence queueFence;
58  VK_VERIFY(vkCreateFence(vk_device.logical, &fCreateInfo, NULL, &queueFence));
59  VK_VERIFY(vkQueueSubmit(*queue, 1, &submitInfo, queueFence));
60  VK_VERIFY(vkWaitForFences(vk_device.logical, 1, &queueFence, VK_TRUE, UINT64_MAX));
61 
62  vkDestroyFence(vk_device.logical, queueFence, NULL);
63 }

Referenced by copyBuffer(), and QVk_ReadPixels().

qvkdevice_t::logical
VkDevice logical
Definition: qvk.h:40
vk_device
qvkdevice_t vk_device
Definition: vk_common.c:51
NULL
#define NULL
Definition: q_shared.h:67
VK_VERIFY
#define VK_VERIFY(x)
Definition: vk_local.h:59
level
GLint level
Definition: qgl_win.c:116