summaryrefslogtreecommitdiff
path: root/src/renderer
diff options
context:
space:
mode:
Diffstat (limited to 'src/renderer')
-rw-r--r--src/renderer/backends/backend_vulkan.c41
-rw-r--r--src/renderer/backends/backend_vulkan.h4
2 files changed, 36 insertions, 9 deletions
diff --git a/src/renderer/backends/backend_vulkan.c b/src/renderer/backends/backend_vulkan.c
index a9746aa..0616a53 100644
--- a/src/renderer/backends/backend_vulkan.c
+++ b/src/renderer/backends/backend_vulkan.c
@@ -14,6 +14,7 @@
#include "log.h"
#include "ral.h"
#include "utils.h"
+#include "utils.h"
// TEMP
#define SCREEN_WIDTH 1000
@@ -223,6 +224,8 @@ bool gpu_swapchain_create(gpu_swapchain* out_swapchain) {
swapchain_create_info.clipped = VK_TRUE;
swapchain_create_info.oldSwapchain = VK_NULL_HANDLE;
+ out_swapchain->extent = swapchain_support.capabilities.currentExtent;
+
VK_CHECK(vkCreateSwapchainKHR(context.device->logical_device, &swapchain_create_info,
context.allocator, &out_swapchain->handle));
TRACE("Vulkan Swapchain created");
@@ -233,6 +236,28 @@ bool gpu_swapchain_create(gpu_swapchain* out_swapchain) {
VK_CHECK(vkGetSwapchainImagesKHR(context.device->logical_device, out_swapchain->handle,
&image_count, out_swapchain->images));
+ // Create ImageViews
+ // TODO: Move this to a separate function
+ out_swapchain->image_views =
+ arena_alloc(&out_swapchain->swapchain_arena, image_count * sizeof(VkImageView));
+ for (u32 i = 0; i < image_count; i++) {
+ VkImageViewCreateInfo view_create_info = { VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO };
+ view_create_info.image = out_swapchain->images[i];
+ view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D;
+ view_create_info.format = image_format.format;
+ view_create_info.components.r = VK_COMPONENT_SWIZZLE_IDENTITY;
+ view_create_info.components.g = VK_COMPONENT_SWIZZLE_IDENTITY;
+ view_create_info.components.b = VK_COMPONENT_SWIZZLE_IDENTITY;
+ view_create_info.components.a = VK_COMPONENT_SWIZZLE_IDENTITY;
+ view_create_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
+ view_create_info.subresourceRange.baseMipLevel = 0;
+ view_create_info.subresourceRange.levelCount = 1;
+ view_create_info.subresourceRange.baseArrayLayer = 0;
+ view_create_info.subresourceRange.layerCount = 1;
+ vkCreateImageView(context.device->logical_device, &view_create_info, context.allocator,
+ &out_swapchain->image_views[i]);
+ }
+
return true;
}
@@ -503,7 +528,7 @@ bool create_logical_device(gpu_device* out_device) {
// Queues
f32 prio_one = 1.0;
- VkDeviceQueueCreateInfo queue_create_infos[2] = { 0 };
+ VkDeviceQueueCreateInfo queue_create_infos[1] = { 0 };
queue_create_infos[0].sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
queue_create_infos[0].queueFamilyIndex = indices.graphics_family_index;
queue_create_infos[0].queueCount = 1;
@@ -511,12 +536,12 @@ bool create_logical_device(gpu_device* out_device) {
queue_create_infos[0].flags = 0;
queue_create_infos[0].pNext = 0;
- queue_create_infos[1].sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
- queue_create_infos[1].queueFamilyIndex = indices.present_family_index;
- queue_create_infos[1].queueCount = 1;
- queue_create_infos[1].pQueuePriorities = &prio_one;
- queue_create_infos[1].flags = 0;
- queue_create_infos[1].pNext = 0;
+ // queue_create_infos[1].sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
+ // queue_create_infos[1].queueFamilyIndex = indices.present_family_index;
+ // queue_create_infos[1].queueCount = 1;
+ // queue_create_infos[1].pQueuePriorities = &prio_one;
+ // queue_create_infos[1].flags = 0;
+ // queue_create_infos[1].pNext = 0;
// Features
VkPhysicalDeviceFeatures device_features = { 0 };
@@ -524,7 +549,7 @@ bool create_logical_device(gpu_device* out_device) {
// Device itself
VkDeviceCreateInfo device_create_info = { VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO };
- device_create_info.queueCreateInfoCount = 2;
+ device_create_info.queueCreateInfoCount = 1;
device_create_info.pQueueCreateInfos = queue_create_infos;
device_create_info.pEnabledFeatures = &device_features;
device_create_info.enabledExtensionCount = 1;
diff --git a/src/renderer/backends/backend_vulkan.h b/src/renderer/backends/backend_vulkan.h
index 1a64e84..9c85683 100644
--- a/src/renderer/backends/backend_vulkan.h
+++ b/src/renderer/backends/backend_vulkan.h
@@ -29,10 +29,12 @@ typedef struct queue_family_indices {
typedef struct gpu_swapchain {
VkSwapchainKHR handle;
arena swapchain_arena;
+ VkExtent2D extent;
VkSurfaceFormatKHR image_format;
VkPresentModeKHR present_mode;
- VkImage* images;
u32 image_count;
+ VkImage* images;
+ VkImageView* image_views;
} gpu_swapchain;
typedef struct gpu_device {