Skip to content

Commit

Permalink
update vulkan example
Browse files Browse the repository at this point in the history
  • Loading branch information
ColleagueRiley committed Jan 18, 2025
1 parent cace531 commit c5f8698
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions examples/vk10/RGFW_vulkan.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ int RGFW_deviceInitialization(RGFW_window* win, RGFW_window_vulkanInfo* vulkWin)

u32 deviceCount = 0;
vkEnumeratePhysicalDevices(RGFW_vulkan_info.instance, &deviceCount, NULL);
VkPhysicalDevice* devices = (VkPhysicalDevice*) RGFW_alloc(sizeof(VkPhysicalDevice) * deviceCount);
VkPhysicalDevice* devices = (VkPhysicalDevice*) malloc(sizeof(VkPhysicalDevice) * deviceCount);
vkEnumeratePhysicalDevices(RGFW_vulkan_info.instance, &deviceCount, devices);

RGFW_vulkan_info.physical_device = devices[0];
Expand All @@ -192,7 +192,7 @@ int RGFW_deviceInitialization(RGFW_window* win, RGFW_window_vulkanInfo* vulkWin)

if (RGFW_vulkan_info.physical_device != NULL && deviceCount) {
vkGetPhysicalDeviceQueueFamilyProperties(RGFW_vulkan_info.physical_device, &queue_family_count, NULL);
VkQueueFamilyProperties* queueFamilies = (VkQueueFamilyProperties*) RGFW_alloc(sizeof(VkQueueFamilyProperties) * queue_family_count);
VkQueueFamilyProperties* queueFamilies = (VkQueueFamilyProperties*) malloc(sizeof(VkQueueFamilyProperties) * queue_family_count);

vkGetPhysicalDeviceQueueFamilyProperties(RGFW_vulkan_info.physical_device, &queue_family_count, queueFamilies);
}
Expand Down Expand Up @@ -271,10 +271,10 @@ int RGFW_createSwapchain(RGFW_window* win, RGFW_window_vulkanInfo* vulkWin) {

u32 imageCount;
vkGetSwapchainImagesKHR(RGFW_vulkan_info.device, vulkWin->swapchain, &imageCount, NULL);
vulkWin->swapchain_images = (VkImage*) RGFW_alloc(sizeof(VkImage) * imageCount);
vulkWin->swapchain_images = (VkImage*) malloc(sizeof(VkImage) * imageCount);
vkGetSwapchainImagesKHR(RGFW_vulkan_info.device, vulkWin->swapchain, &imageCount, vulkWin->swapchain_images);

vulkWin->swapchain_image_views = (VkImageView*) RGFW_alloc(sizeof(VkImageView) * imageCount);
vulkWin->swapchain_image_views = (VkImageView*) malloc(sizeof(VkImageView) * imageCount);
for (u32 i = 0; i < imageCount; i++) {
VkImageViewCreateInfo image_view_cre_infos = { 0 };
image_view_cre_infos.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
Expand Down Expand Up @@ -358,7 +358,7 @@ int RGFW_createCommandPool(void) {
int RGFW_createCommandBuffers(RGFW_window_vulkanInfo* vulkWin) {
assert(vulkWin != NULL);

RGFW_vulkan_info.command_buffers = (VkCommandBuffer*) RGFW_alloc(sizeof(VkCommandBuffer) * vulkWin->image_count);
RGFW_vulkan_info.command_buffers = (VkCommandBuffer*) malloc(sizeof(VkCommandBuffer) * vulkWin->image_count);

VkCommandBufferAllocateInfo allocInfo = { 0 };
allocInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
Expand All @@ -376,10 +376,10 @@ int RGFW_createCommandBuffers(RGFW_window_vulkanInfo* vulkWin) {
int RGFW_createSyncObjects(RGFW_window_vulkanInfo* vulkWin) {
assert(vulkWin != NULL);

RGFW_vulkan_info.available_semaphores = (VkSemaphore*) RGFW_alloc(sizeof(VkSemaphore) * RGFW_MAX_FRAMES_IN_FLIGHT);
RGFW_vulkan_info.finished_semaphore = (VkSemaphore*) RGFW_alloc(sizeof(VkSemaphore) * RGFW_MAX_FRAMES_IN_FLIGHT);
RGFW_vulkan_info.in_flight_fences = (VkFence*) RGFW_alloc(sizeof(VkFence) * RGFW_MAX_FRAMES_IN_FLIGHT);
RGFW_vulkan_info.image_in_flight = (VkFence*) RGFW_alloc(sizeof(VkFence) * vulkWin->image_count);
RGFW_vulkan_info.available_semaphores = (VkSemaphore*) malloc(sizeof(VkSemaphore) * RGFW_MAX_FRAMES_IN_FLIGHT);
RGFW_vulkan_info.finished_semaphore = (VkSemaphore*) malloc(sizeof(VkSemaphore) * RGFW_MAX_FRAMES_IN_FLIGHT);
RGFW_vulkan_info.in_flight_fences = (VkFence*) malloc(sizeof(VkFence) * RGFW_MAX_FRAMES_IN_FLIGHT);
RGFW_vulkan_info.image_in_flight = (VkFence*) malloc(sizeof(VkFence) * vulkWin->image_count);

VkSemaphoreCreateInfo semaphore_info = { 0 };
semaphore_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO;
Expand Down Expand Up @@ -407,7 +407,7 @@ int RGFW_createSyncObjects(RGFW_window_vulkanInfo* vulkWin) {
int RGFW_createFramebuffers(RGFW_window* win, RGFW_window_vulkanInfo* vulkWin) {
assert(vulkWin != NULL);

RGFW_vulkan_info.framebuffers = (VkFramebuffer*) RGFW_alloc(sizeof(VkFramebuffer) * vulkWin->image_count);
RGFW_vulkan_info.framebuffers = (VkFramebuffer*) malloc(sizeof(VkFramebuffer) * vulkWin->image_count);

for (size_t i = 0; i < vulkWin->image_count; i++) {
VkImageView attachments[] = { vulkWin->swapchain_image_views[i] };
Expand Down Expand Up @@ -439,8 +439,8 @@ void RGFW_freeVulkan(RGFW_window_vulkanInfo* vulkWin) {

vkDestroySwapchainKHR(RGFW_vulkan_info.device, vulkWin->swapchain, NULL);
vkDestroySurfaceKHR(RGFW_vulkan_info.instance, vulkWin->rSurf, NULL);
RGFW_free(vulkWin->swapchain_image_views);
RGFW_free(vulkWin->swapchain_images);
free(vulkWin->swapchain_image_views);
free(vulkWin->swapchain_images);

vkDeviceWaitIdle(RGFW_vulkan_info.device);

Expand All @@ -466,12 +466,12 @@ void RGFW_freeVulkan(RGFW_window_vulkanInfo* vulkWin) {
vkDestroyDevice(RGFW_vulkan_info.device, NULL);
vkDestroyInstance(RGFW_vulkan_info.instance, NULL);

RGFW_free(RGFW_vulkan_info.framebuffers);
RGFW_free(RGFW_vulkan_info.command_buffers);
RGFW_free(RGFW_vulkan_info.available_semaphores);
RGFW_free(RGFW_vulkan_info.finished_semaphore);
RGFW_free(RGFW_vulkan_info.in_flight_fences);
RGFW_free(RGFW_vulkan_info.image_in_flight);
free(RGFW_vulkan_info.framebuffers);
free(RGFW_vulkan_info.command_buffers);
free(RGFW_vulkan_info.available_semaphores);
free(RGFW_vulkan_info.finished_semaphore);
free(RGFW_vulkan_info.in_flight_fences);
free(RGFW_vulkan_info.image_in_flight);
}

VkShaderModule RGFW_createShaderModule(const u32* code, size_t code_size) {
Expand Down

0 comments on commit c5f8698

Please sign in to comment.