From 3df5cfbc02c0ad62a94f8e23d0de18299854f82b Mon Sep 17 00:00:00 2001 From: bailwillharr Date: Mon, 13 Mar 2023 17:35:22 +0000 Subject: [PATCH] Fix code to make clang happy --- src/gfx_device_vulkan.cpp | 39 ++++++++++++++++++++---------------- src/vulkan/device.cpp | 7 +++---- src/vulkan/device.h | 4 ++-- src/vulkan/gpu_allocator.cpp | 6 +++--- src/vulkan/gpu_allocator.h | 4 ++-- src/vulkan/instance.cpp | 13 ++++++------ src/vulkan/instance.h | 4 ++-- src/vulkan/swapchain.h | 4 ++-- 8 files changed, 42 insertions(+), 39 deletions(-) diff --git a/src/gfx_device_vulkan.cpp b/src/gfx_device_vulkan.cpp index 2da2adf..1fde7c1 100644 --- a/src/gfx_device_vulkan.cpp +++ b/src/gfx_device_vulkan.cpp @@ -129,7 +129,7 @@ namespace engine { } } - static VkFilter getTextureFilter(gfx::TextureFilter filter) + [[maybe_unused]] static VkFilter getTextureFilter(gfx::TextureFilter filter) { switch (filter) { case gfx::TextureFilter::LINEAR: @@ -140,7 +140,7 @@ namespace engine { throw std::runtime_error("Unknown texture filter"); } - static VkSampleCountFlags getSampleCountFlags(gfx::MSAALevel level) + [[maybe_unused]] static VkSampleCountFlags getSampleCountFlags(gfx::MSAALevel level) { switch (level) { case gfx::MSAALevel::MSAA_OFF: @@ -622,7 +622,7 @@ namespace engine { /* make synchronisation primitives for rendering and allocate command buffers */ - for (int i = 0; i < FRAMES_IN_FLIGHT; i++) { + for (uint32_t i = 0; i < FRAMES_IN_FLIGHT; i++) { VkFenceCreateInfo fenceInfo{ .sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, .pNext = nullptr, @@ -656,10 +656,9 @@ namespace engine { std::vector poolSizes{}; poolSizes.emplace_back(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 5); // purposely low limit - VkDescriptorPoolCreateInfo descriptorPoolInfo{ - .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO, - .pNext = nullptr, - }; + VkDescriptorPoolCreateInfo descriptorPoolInfo{}; + descriptorPoolInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; + descriptorPoolInfo.pNext = nullptr; descriptorPoolInfo.flags = 0; descriptorPoolInfo.maxSets = 5; // purposely low limit descriptorPoolInfo.poolSizeCount = poolSizes.size(); @@ -672,7 +671,7 @@ namespace engine { { vkDestroyDescriptorPool(pimpl->device.device, pimpl->descriptorPool, nullptr); - for (int i = 0; i < FRAMES_IN_FLIGHT; i++) { + for (uint32_t i = 0; i < FRAMES_IN_FLIGHT; i++) { vkFreeCommandBuffers(pimpl->device.device, pimpl->device.commandPools.draw, 1, &pimpl->frameData[i].drawBuf); vkDestroySemaphore(pimpl->device.device, pimpl->frameData[i].renderSemaphore, nullptr); vkDestroySemaphore(pimpl->device.device, pimpl->frameData[i].presentSemaphore, nullptr); @@ -758,10 +757,9 @@ namespace engine { clearValue.color.float32[2] = 1.0f; clearValue.color.float32[3] = 1.0f; - VkRenderPassBeginInfo passBegin{ - .sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, - .pNext = nullptr - }; + VkRenderPassBeginInfo passBegin{}; + passBegin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; + passBegin.pNext = nullptr; passBegin.renderPass = pimpl->swapchain.renderpass; passBegin.framebuffer = std::get<2>(pimpl->swapchain.images[swapchainImageIndex]); passBegin.renderArea.extent = pimpl->swapchain.extent; @@ -1115,10 +1113,9 @@ namespace engine { bindings[0].descriptorCount = 1; // if > 1, accessible as an array in the shader bindings[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT; // only accessible in vertex - VkDescriptorSetLayoutCreateInfo info{ - .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO, - .pNext = nullptr - }; + VkDescriptorSetLayoutCreateInfo info{}; + info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; + info.pNext = nullptr; info.flags = 0; info.bindingCount = bindings.size(); info.pBindings = bindings.data(); @@ -1344,6 +1341,13 @@ namespace engine { gfx::MipmapSetting mipmapSetting, bool useAnisotropy) { + (void)imageData; + (void)width; + (void)height; + (void)minFilter; + (void)magFilter; + (void)mipmapSetting; + (void)useAnisotropy; auto out = new gfx::Texture; #if 0 @@ -1544,6 +1548,7 @@ namespace engine { void GFXDevice::destroyTexture(const gfx::Texture* texture) { + (void)texture; #if 0 vkDestroyDescriptorPool(pimpl->device, texture->pool, nullptr); vkDestroySampler(pimpl->device, texture->sampler, nullptr); @@ -1562,4 +1567,4 @@ namespace engine { vkDeviceWaitIdle(pimpl->device.device); } -} \ No newline at end of file +} diff --git a/src/vulkan/device.cpp b/src/vulkan/device.cpp index 23e56a2..8868747 100644 --- a/src/vulkan/device.cpp +++ b/src/vulkan/device.cpp @@ -2,10 +2,9 @@ #include #include #include +#include #include -#include - #include "device.h" namespace engine { @@ -210,7 +209,7 @@ namespace engine { for (size_t i = 0; i < queueFamilies.size(); i++) { VkQueueFamilyProperties p = queueFamilies[i]; - if (p.queueCount < 2) break; // need one queue for presenting and one-or-more for rendering + if (p.queueCount < 2) continue; // need one queue for presenting and one-or-more for rendering if (p.queueFlags & VK_QUEUE_GRAPHICS_BIT) { VkBool32 supportsPresent; @@ -330,4 +329,4 @@ namespace engine { vkDestroyDevice(device.device, nullptr); } -} \ No newline at end of file +} diff --git a/src/vulkan/device.h b/src/vulkan/device.h index 3865d12..9e3e025 100644 --- a/src/vulkan/device.h +++ b/src/vulkan/device.h @@ -2,7 +2,7 @@ #include -#include +#include namespace engine { @@ -36,4 +36,4 @@ namespace engine { Device createDevice(VkInstance instance, DeviceRequirements requirements, VkSurfaceKHR surface); void destroyDevice(Device device); -} \ No newline at end of file +} diff --git a/src/vulkan/gpu_allocator.cpp b/src/vulkan/gpu_allocator.cpp index f62cfe4..8ace5de 100644 --- a/src/vulkan/gpu_allocator.cpp +++ b/src/vulkan/gpu_allocator.cpp @@ -1,12 +1,12 @@ #include -#include +#include #define VMA_STATIC_VULKAN_FUNCTIONS 0 #define VMA_DYNAMIC_VULKAN_FUNCTIONS 0 #define VMA_VULKAN_VERSION 1003000 #define VMA_IMPLEMENTATION -#include +#include #include "gpu_allocator.h" @@ -71,4 +71,4 @@ namespace engine { vmaDestroyAllocator(allocator); } -} \ No newline at end of file +} diff --git a/src/vulkan/gpu_allocator.h b/src/vulkan/gpu_allocator.h index a2e6181..e6a673b 100644 --- a/src/vulkan/gpu_allocator.h +++ b/src/vulkan/gpu_allocator.h @@ -1,9 +1,9 @@ #pragma once -#include +#include namespace engine { VmaAllocator createAllocator(VkInstance instance, VkDevice device, VkPhysicalDevice physicalDevice); void destroyAllocator(VmaAllocator allocator); -} \ No newline at end of file +} diff --git a/src/vulkan/instance.cpp b/src/vulkan/instance.cpp index fc7e4a2..45346b5 100644 --- a/src/vulkan/instance.cpp +++ b/src/vulkan/instance.cpp @@ -148,16 +148,15 @@ namespace engine { const char* validationLayer = nullptr; if (useValidation) { - const char* validationLayer = getValidationLayer(); + validationLayer = getValidationLayer(); } VkDebugUtilsMessengerCreateInfoEXT debugMessengerInfo = getDebugMessengerCreateInfo(validationLevel); - VkInstanceCreateInfo instanceInfo{ - .sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, - .pNext = &debugMessengerInfo, - .flags = 0 - }; + VkInstanceCreateInfo instanceInfo{}; + instanceInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; + instanceInfo.pNext = &debugMessengerInfo; + instanceInfo.flags = 0; instanceInfo.pApplicationInfo = &applicationInfo; if (validationLayer) { instanceInfo.enabledLayerCount = 1; @@ -201,4 +200,4 @@ namespace engine { vkDestroyInstance(instance.instance, nullptr); } -} \ No newline at end of file +} diff --git a/src/vulkan/instance.h b/src/vulkan/instance.h index 7ea210e..5091bd7 100644 --- a/src/vulkan/instance.h +++ b/src/vulkan/instance.h @@ -2,7 +2,7 @@ #include -#include +#include namespace engine { @@ -21,4 +21,4 @@ namespace engine { Instance createVulkanInstance(SDL_Window* window, const char* appName, const char* appVersion, bool useValidation, MessageSeverity validationLevel = MessageSeverity::SEV_WARNING); void destroyVulkanInstance(Instance instance); -} \ No newline at end of file +} diff --git a/src/vulkan/swapchain.h b/src/vulkan/swapchain.h index ee40315..1dea4f2 100644 --- a/src/vulkan/swapchain.h +++ b/src/vulkan/swapchain.h @@ -4,7 +4,7 @@ #include -#include +#include namespace engine { @@ -31,4 +31,4 @@ namespace engine { void createSwapchain(Swapchain* sc, const SwapchainInfo& info); void destroySwapchain(const Swapchain& sc); -} \ No newline at end of file +}