diff --git a/projects/apis/vulkan/src/commands/command_buffer/vulkan_command_buffer.c b/projects/apis/vulkan/src/commands/command_buffer/vulkan_command_buffer.c index 8232bd9..1e0d02a 100644 --- a/projects/apis/vulkan/src/commands/command_buffer/vulkan_command_buffer.c +++ b/projects/apis/vulkan/src/commands/command_buffer/vulkan_command_buffer.c @@ -13,15 +13,14 @@ gnReturnCode allocateCommandBuffers(gnCommandBufferHandle* commandBuffers, uint3 VkCommandBuffer* buffers = malloc(sizeof(VkCommandBuffer) * count); - if (vkAllocateCommandBuffers(pool->device->outputDevice->device, &allocInfo, buffers) != VK_SUCCESS) - return GN_FAILED_TO_ALLOCATE_OBJECT; + VkResult allocationResult = vkAllocateCommandBuffers(pool->device->outputDevice->device, &allocInfo, buffers); + if (allocationResult == VK_SUCCESS) + for (int i = 0; i < count; i++) { + commandBuffers[i]->commandBuffer = malloc(sizeof(gnPlatformCommandBuffer)); + commandBuffers[i]->commandBuffer->buffer = buffers[i]; + } - for (int i = 0; i < count; i++) { - commandBuffers[i]->commandBuffer = malloc(sizeof(gnPlatformCommandBuffer)); - commandBuffers[i]->commandBuffer->buffer = buffers[i]; - } - - return GN_SUCCESS; + return VkResultToGnReturnCode(allocationResult); } void resetCommandBuffer(gnCommandBufferHandle commandBuffer) { diff --git a/projects/apis/vulkan/src/commands/command_pool/vulkan_command_pool.c b/projects/apis/vulkan/src/commands/command_pool/vulkan_command_pool.c index 2ee9c37..cb3c619 100644 --- a/projects/apis/vulkan/src/commands/command_pool/vulkan_command_pool.c +++ b/projects/apis/vulkan/src/commands/command_pool/vulkan_command_pool.c @@ -1,6 +1,7 @@ #include "vulkan_command_pool.h" #include "output_device/vulkan_output_devices.h" #include "instance/gryphn_instance.h" +#include "vulkan_result_converter.h" gnReturnCode createCommandPool(gnCommandPool commandPool, gnDevice device, gnCommandPoolInfo info) { commandPool->commandPool = malloc(sizeof(gnPlatformCommandPool)); @@ -11,11 +12,7 @@ gnReturnCode createCommandPool(gnCommandPool commandPool, gnDevice device, gnCom .queueFamilyIndex = info.queueFamilyIndex, }; if (!device->instance->enabledExtensions[GN_EXT_QUEUES]) poolInfo.queueFamilyIndex = device->outputDevice->queues[device->outputDevice->graphicsQueueIndex].queueInfo.queueIndex; - - if (vkCreateCommandPool(device->outputDevice->device, &poolInfo, NULL, &commandPool->commandPool->commandPool) != VK_SUCCESS) - return GN_FAILED_TO_CREATE_COMMAND_POOL; - - return GN_SUCCESS; + return VkResultToGnReturnCode(vkCreateCommandPool(device->outputDevice->device, &poolInfo, NULL, &commandPool->commandPool->commandPool)); } void destroyCommandPool(gnCommandPool commandPool) { diff --git a/projects/apis/vulkan/src/vulkan_result_converter.h b/projects/apis/vulkan/src/vulkan_result_converter.h index 25f9c7f..ca2653b 100644 --- a/projects/apis/vulkan/src/vulkan_result_converter.h +++ b/projects/apis/vulkan/src/vulkan_result_converter.h @@ -2,7 +2,7 @@ #include #include -gnReturnCode VkResultToGnReturnCode(VkResult result) { +static inline gnReturnCode VkResultToGnReturnCode(VkResult result) { switch (result) { case VK_SUCCESS: return GN_SUCCESS; // case VK_NOT_READY: return ;