Cleaned up the code but had to add -Wno-sign-conversion to get glm to shut up.
This commit is contained in:
parent
8a7ef61c78
commit
55e38788b4
4 changed files with 30 additions and 21 deletions
|
|
@ -1,8 +1,4 @@
|
|||
/*
|
||||
* Stopped at https://vkguide.dev/docs/new_chapter_1/vulkan_mainloop_code/
|
||||
*/
|
||||
|
||||
#include "vk_engine.h"
|
||||
#include "vk_engine.h"
|
||||
#include "vk_images.h"
|
||||
#include <print>
|
||||
|
||||
|
|
@ -56,7 +52,7 @@ void VulkanEngine::cleanup()
|
|||
if (_isInitialized) {
|
||||
vkDeviceWaitIdle(_device);
|
||||
|
||||
for(int i = 0; i < FRAME_OVERLAP; i++) {
|
||||
for(size_t i = 0; i < FRAME_OVERLAP; i++) {
|
||||
vkDestroyCommandPool(_device, _frames[i]._commandPool, nullptr);
|
||||
|
||||
//destroy sync objects
|
||||
|
|
@ -96,7 +92,7 @@ void VulkanEngine::draw()
|
|||
vkutil::transition_image(cmd, _swapchainImages[swapchainImageIndex], VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_GENERAL);
|
||||
|
||||
VkClearColorValue clearValue;
|
||||
float flash = std::abs(std::sin(_frameNumber / 120.0f));
|
||||
float flash = std::abs(std::sin(float(_frameNumber) / 120.0f));
|
||||
clearValue = { { 0.0f, 0.0f, flash, 1.0f} };
|
||||
|
||||
VkImageSubresourceRange clearRange = vkinit::image_subresource_range(VK_IMAGE_ASPECT_COLOR_BIT);
|
||||
|
|
@ -199,12 +195,15 @@ void VulkanEngine::init_vulkan() {
|
|||
SDL_Vulkan_CreateSurface(_window, _instance, &_surface);
|
||||
|
||||
//vulkan 1.3 features
|
||||
VkPhysicalDeviceVulkan13Features features{ .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES };
|
||||
VkPhysicalDeviceVulkan13Features features{};
|
||||
|
||||
features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES;
|
||||
features.dynamicRendering = true;
|
||||
features.synchronization2 = true;
|
||||
|
||||
//vulkan 1.2 features
|
||||
VkPhysicalDeviceVulkan12Features features12{ .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES };
|
||||
VkPhysicalDeviceVulkan12Features features12{};
|
||||
features12.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES;
|
||||
features12.bufferDeviceAddress = true;
|
||||
features12.descriptorIndexing = true;
|
||||
|
||||
|
|
@ -231,12 +230,14 @@ void VulkanEngine::init_vulkan() {
|
|||
|
||||
void VulkanEngine::create_swapchain(uint32_t width, uint32_t height) {
|
||||
vkb::SwapchainBuilder swapchainBuilder{ _chosenGPU, _device, _surface};
|
||||
|
||||
|
||||
_swapchainImageFormat = VK_FORMAT_B8G8R8A8_UNORM;
|
||||
VkSurfaceFormatKHR surfaceFormat{};
|
||||
surfaceFormat.format=_swapchainImageFormat;
|
||||
|
||||
vkb::Swapchain vkbSwapchain = swapchainBuilder
|
||||
//.use_default_format_selection()
|
||||
.set_desired_format(VkSurfaceFormatKHR{.format=_swapchainImageFormat})
|
||||
.set_desired_format(surfaceFormat)
|
||||
// use vsync present mode
|
||||
.set_desired_present_mode(VK_PRESENT_MODE_FIFO_KHR)
|
||||
.set_desired_extent(width, height)
|
||||
|
|
@ -267,7 +268,7 @@ void VulkanEngine::init_commands() {
|
|||
//we also want the pool to allow for resetting of individual command buffers
|
||||
VkCommandPoolCreateInfo commandPoolInfo = vkinit::command_pool_create_info(_graphicsQueueFamily, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT);
|
||||
|
||||
for (int i = 0; i < FRAME_OVERLAP; i++) {
|
||||
for (size_t i = 0; i < FRAME_OVERLAP; i++) {
|
||||
|
||||
VK_CHECK(vkCreateCommandPool(_device, &commandPoolInfo, nullptr, &_frames[i]._commandPool));
|
||||
|
||||
|
|
@ -282,7 +283,7 @@ void VulkanEngine::init_sync_structures() {
|
|||
VkFenceCreateInfo fenceCreateInfo = vkinit::fence_create_info(VK_FENCE_CREATE_SIGNALED_BIT);
|
||||
VkSemaphoreCreateInfo semaphoreCreateInfo = vkinit::semaphore_create_info();
|
||||
|
||||
for (int i = 0; i < FRAME_OVERLAP; i++) {
|
||||
for (size_t i = 0; i < FRAME_OVERLAP; i++) {
|
||||
VK_CHECK(vkCreateFence(_device, &fenceCreateInfo, nullptr, &_frames[i]._renderFence));
|
||||
|
||||
VK_CHECK(vkCreateSemaphore(_device, &semaphoreCreateInfo, nullptr, &_frames[i]._swapchainSemaphore));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue