Skip to content

Commit

Permalink
vk: use 32 command buffers in queue
Browse files Browse the repository at this point in the history
Workaround for:
 Validation Error: [ VUID-vkAcquireNextImageKHR-semaphore-01779 ] Object 0: handle = 0x90000000009, name = Semaphore: image available #0, type = VK_OBJECT_TYPE_SEMAPHORE; | MessageID = 0x5717e75b | vkAcquireNextImageKHR():  Semaphore must not have any pending operations. The Vulkan spec states: If semaphore is not VK_NULL_HANDLE it must not have any uncompleted signal or wait operations pending (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-vkAcquireNextImageKHR-semaphore-01779) (validation)
  • Loading branch information
0lvin committed Aug 18, 2024
1 parent 3cd735c commit 6d1a911
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/client/refresh/vk/header/qvk.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ typedef enum
} qvkrenderpasstype_t;

// Vulkan constants: command and dynamic buffer count
#define NUM_CMDBUFFERS 2
#define NUM_CMDBUFFERS 32
#define NUM_DYNBUFFERS 2

// Vulkan instance
Expand Down
12 changes: 8 additions & 4 deletions src/client/refresh/vk/vk_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ qvkrenderpass_t vk_renderpasses[RP_COUNT] = {
};

// Vulkan pools
VkCommandPool vk_commandPool[NUM_CMDBUFFERS] = { VK_NULL_HANDLE, VK_NULL_HANDLE };
VkCommandPool vk_commandPool[NUM_CMDBUFFERS] = { 0 };
VkCommandPool vk_transferCommandPool = VK_NULL_HANDLE;
VkDescriptorPool vk_descriptorPool = VK_NULL_HANDLE;
static VkCommandPool vk_stagingCommandPool[NUM_DYNBUFFERS] = { VK_NULL_HANDLE, VK_NULL_HANDLE };
Expand Down Expand Up @@ -1733,6 +1733,8 @@ void QVk_PostInit(void)
*/
qboolean QVk_Init(void)
{
int i;

PFN_vkEnumerateInstanceVersion vkEnumerateInstanceVersion = (PFN_vkEnumerateInstanceVersion)vkGetInstanceProcAddr(NULL, "vkEnumerateInstanceVersion");
uint32_t instanceVersion = VK_API_VERSION_1_0;

Expand Down Expand Up @@ -1817,7 +1819,7 @@ qboolean QVk_Init(void)
#endif

R_Printf(PRINT_ALL, "Enabled extensions: ");
for (int i = 0; i < extCount; i++)
for (i = 0; i < extCount; i++)
{
R_Printf(PRINT_ALL, "%s ", wantedExtensions[i]);
vk_config.extensions[i] = wantedExtensions[i];
Expand Down Expand Up @@ -2019,8 +2021,9 @@ qboolean QVk_Init(void)
.pNext = NULL,
.flags = 0
};
for (int i = 0; i < NUM_CMDBUFFERS; ++i)
for (i = 0; i < NUM_CMDBUFFERS; ++i)
{
vk_commandPool[i] = VK_NULL_HANDLE;
VK_VERIFY(vkCreateFence(vk_device.logical, &fCreateInfo, NULL, &vk_fences[i]));
VK_VERIFY(vkCreateSemaphore(vk_device.logical, &sCreateInfo, NULL, &vk_imageAvailableSemaphores[i]));
VK_VERIFY(vkCreateSemaphore(vk_device.logical, &sCreateInfo, NULL, &vk_renderFinishedSemaphores[i]));
Expand Down Expand Up @@ -2173,7 +2176,8 @@ VkResult QVk_BeginFrame(const VkViewport* viewport, const VkRect2D* scissor)

ReleaseSwapBuffers();

VkResult result = vkAcquireNextImageKHR(vk_device.logical, vk_swapchain.sc, 500000000, vk_imageAvailableSemaphores[vk_activeBufferIdx], VK_NULL_HANDLE, &vk_imageIndex);
VkResult result = vkAcquireNextImageKHR(vk_device.logical, vk_swapchain.sc, 500000000 /* 0.5 sec */,
vk_imageAvailableSemaphores[vk_activeBufferIdx], VK_NULL_HANDLE, &vk_imageIndex);
if (result == VK_ERROR_OUT_OF_DATE_KHR || result == VK_SUBOPTIMAL_KHR || result == VK_ERROR_SURFACE_LOST_KHR || result == VK_TIMEOUT)
{
vk_recreateSwapchainNeeded = true;
Expand Down

0 comments on commit 6d1a911

Please sign in to comment.