From e30daa802779b7b24170d69fa5d63473df6835c4 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Tue, 5 Feb 2019 13:10:05 +0100 Subject: [PATCH] Remove unused API, assorted cleanup. No longer enable the geometry shader feature, no plans to use it. --- Common/Vulkan/VulkanContext.cpp | 18 +++++++----------- GPU/Vulkan/DrawEngineVulkan.cpp | 1 - GPU/Vulkan/PipelineManagerVulkan.cpp | 1 - GPU/Vulkan/VulkanUtil.cpp | 7 +++---- ext/native/thin3d/thin3d.h | 7 ------- ext/native/thin3d/thin3d_vulkan.cpp | 17 ++++------------- 6 files changed, 14 insertions(+), 37 deletions(-) diff --git a/Common/Vulkan/VulkanContext.cpp b/Common/Vulkan/VulkanContext.cpp index ac64e2716f..63ef9abd45 100644 --- a/Common/Vulkan/VulkanContext.cpp +++ b/Common/Vulkan/VulkanContext.cpp @@ -77,6 +77,8 @@ const char *PresentModeString(VkPresentModeKHR presentMode) { case VK_PRESENT_MODE_MAILBOX_KHR: return "MAILBOX"; case VK_PRESENT_MODE_FIFO_KHR: return "FIFO"; case VK_PRESENT_MODE_FIFO_RELAXED_KHR: return "FIFO_RELAXED"; + case VK_PRESENT_MODE_SHARED_DEMAND_REFRESH_KHR: return "SHARED_DEMAND_REFRESH_KHR"; + case VK_PRESENT_MODE_SHARED_CONTINUOUS_REFRESH_KHR: return "SHARED_CONTINUOUS_REFRESH_KHR"; default: return "UNKNOWN"; } } @@ -548,7 +550,6 @@ void VulkanContext::ChooseDevice(int physical_device) { } // Optional features - if (extensionsLookup_.KHR_get_physical_device_properties2) { VkPhysicalDeviceFeatures2 features2{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2_KHR}; vkGetPhysicalDeviceFeatures2KHR(physical_devices_[physical_device_], &features2); @@ -569,9 +570,6 @@ void VulkanContext::ChooseDevice(int physical_device) { if (deviceFeatures_.available.wideLines) { deviceFeatures_.enabled.wideLines = true; } - if (deviceFeatures_.available.geometryShader) { - deviceFeatures_.enabled.geometryShader = true; - } if (deviceFeatures_.available.logicOp) { deviceFeatures_.enabled.logicOp = true; } @@ -674,9 +672,7 @@ VkResult VulkanContext::InitDebugMsgCallback(PFN_vkDebugReportCallbackEXT dbgFun } ILOG("Registering debug report callback"); - VkDebugReportCallbackCreateInfoEXT cb = {}; - cb.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT; - cb.pNext = nullptr; + VkDebugReportCallbackCreateInfoEXT cb{VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT}; cb.flags = bits; cb.pfnCallback = dbgFunc; cb.pUserData = userdata; @@ -769,7 +765,7 @@ VkResult VulkanContext::ReinitSurface() { #if defined(VK_USE_PLATFORM_XLIB_KHR) case WINDOWSYSTEM_XLIB: { - VkXlibSurfaceCreateInfoKHR xlib = { VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR }; + VkXlibSurfaceCreateInfoKHR xlib{ VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR }; xlib.flags = 0; xlib.dpy = (Display *)winsysData1_; xlib.window = (Window)winsysData2_; @@ -779,7 +775,7 @@ VkResult VulkanContext::ReinitSurface() { #if defined(VK_USE_PLATFORM_XCB_KHR) case WINDOWSYSTEM_XCB: { - VkXCBSurfaceCreateInfoKHR xcb = { VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR }; + VkXCBSurfaceCreateInfoKHR xcb{ VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR }; xcb.flags = 0; xcb.connection = (Connection *)winsysData1_; xcb.window = (Window)(uintptr_t)winsysData2_; @@ -789,7 +785,7 @@ VkResult VulkanContext::ReinitSurface() { #if defined(VK_USE_PLATFORM_WAYLAND_KHR) case WINDOWSYSTEM_WAYLAND: { - VkWaylandSurfaceCreateInfoKHR wayland = { VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR }; + VkWaylandSurfaceCreateInfoKHR wayland{ VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR }; wayland.flags = 0; wayland.display = (wl_display *)winsysData1_; wayland.surface = (wl_surface *)winsysData2_; @@ -973,7 +969,7 @@ bool VulkanContext::InitSwapchain() { preTransform = surfCapabilities_.currentTransform; } - VkSwapchainCreateInfoKHR swap_chain_info = { VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR }; + VkSwapchainCreateInfoKHR swap_chain_info{ VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR }; swap_chain_info.surface = surface_; swap_chain_info.minImageCount = desiredNumberOfSwapChainImages; swap_chain_info.imageFormat = swapchainFormat_; diff --git a/GPU/Vulkan/DrawEngineVulkan.cpp b/GPU/Vulkan/DrawEngineVulkan.cpp index 4d9de9b4eb..daeef502dc 100644 --- a/GPU/Vulkan/DrawEngineVulkan.cpp +++ b/GPU/Vulkan/DrawEngineVulkan.cpp @@ -401,7 +401,6 @@ VkDescriptorSet DrawEngineVulkan::GetOrCreateDescriptorSet(VkImageView imageView VkDescriptorSet desc; VkDescriptorSetAllocateInfo descAlloc{ VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO }; - descAlloc.pNext = nullptr; descAlloc.pSetLayouts = &descriptorSetLayout_; descAlloc.descriptorPool = frame.descPool; descAlloc.descriptorSetCount = 1; diff --git a/GPU/Vulkan/PipelineManagerVulkan.cpp b/GPU/Vulkan/PipelineManagerVulkan.cpp index 8f803d563d..27d513aa2c 100644 --- a/GPU/Vulkan/PipelineManagerVulkan.cpp +++ b/GPU/Vulkan/PipelineManagerVulkan.cpp @@ -237,7 +237,6 @@ static VulkanPipeline *CreateVulkanPipeline(VkDevice device, VkPipelineCache pip inputAssembly.flags = 0; inputAssembly.topology = (VkPrimitiveTopology)key.topology; inputAssembly.primitiveRestartEnable = false; - int vertexStride = 0; int offset = 0; diff --git a/GPU/Vulkan/VulkanUtil.cpp b/GPU/Vulkan/VulkanUtil.cpp index d7d6223fc8..424594d641 100644 --- a/GPU/Vulkan/VulkanUtil.cpp +++ b/GPU/Vulkan/VulkanUtil.cpp @@ -160,12 +160,11 @@ VkDescriptorSet Vulkan2D::GetDescriptorSet(VkImageView tex1, VkSampler sampler1, assert(result == VK_SUCCESS); // We just don't write to the slots we don't care about. - VkWriteDescriptorSet writes[2]; - memset(writes, 0, sizeof(writes)); + VkWriteDescriptorSet writes[2]{}; // Main and sub textures int n = 0; - VkDescriptorImageInfo image1 = {}; - VkDescriptorImageInfo image2 = {}; + VkDescriptorImageInfo image1{}; + VkDescriptorImageInfo image2{}; if (tex1) { #ifdef VULKAN_USE_GENERAL_LAYOUT_FOR_COLOR image1.imageLayout = VK_IMAGE_LAYOUT_GENERAL; diff --git a/ext/native/thin3d/thin3d.h b/ext/native/thin3d/thin3d.h index 20b96d5f0b..6365d9d9c6 100644 --- a/ext/native/thin3d/thin3d.h +++ b/ext/native/thin3d/thin3d.h @@ -655,13 +655,6 @@ public: virtual void HandleEvent(Event ev, int width, int height, void *param1 = nullptr, void *param2 = nullptr) = 0; - // This flushes command buffers and waits for execution at the point of the end of the last - // renderpass that wrote to the requested framebuffer. This is needed before trying to read it back - // on modern APIs like Vulkan. Ifr the framebuffer is currently being rendered to, we'll just end the render pass. - // The next draw call will automatically start up a new one. - // APIs like OpenGL won't need to implement this one. - virtual void WaitRenderCompletion(Framebuffer *fbo) {} - // Flush state like scissors etc so the caller can do its own custom drawing. virtual void FlushState() {} diff --git a/ext/native/thin3d/thin3d_vulkan.cpp b/ext/native/thin3d/thin3d_vulkan.cpp index 6885e1bc84..7277647eb2 100644 --- a/ext/native/thin3d/thin3d_vulkan.cpp +++ b/ext/native/thin3d/thin3d_vulkan.cpp @@ -427,9 +427,7 @@ public: void EndFrame() override; void WipeQueue() override; - void FlushState() override { - } - void WaitRenderCompletion(Framebuffer *fbo) override; + void FlushState() override {} // From Sascha's code static std::string FormatDriverVersion(const VkPhysicalDeviceProperties &props) { @@ -894,10 +892,6 @@ void VKContext::BeginFrame() { _assert_(result == VK_SUCCESS); } -void VKContext::WaitRenderCompletion(Framebuffer *fbo) { - // TODO -} - void VKContext::EndFrame() { // Stop collecting data in the frame's data pushbuffer. push_->End(); @@ -1014,13 +1008,11 @@ Pipeline *VKContext::CreateGraphicsPipeline(const PipelineDesc &desc) { dynamicInfo.dynamicStateCount = depth->info.stencilTestEnable ? ARRAY_SIZE(dynamics) : 2; dynamicInfo.pDynamicStates = dynamics; - VkPipelineMultisampleStateCreateInfo ms = { VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO }; - ms.pNext = nullptr; + VkPipelineMultisampleStateCreateInfo ms{ VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO }; ms.pSampleMask = nullptr; ms.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; - VkPipelineViewportStateCreateInfo vs = { VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO }; - vs.pNext = nullptr; + VkPipelineViewportStateCreateInfo vs{ VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO }; vs.viewportCount = 1; vs.scissorCount = 1; vs.pViewports = nullptr; // dynamic @@ -1029,8 +1021,7 @@ Pipeline *VKContext::CreateGraphicsPipeline(const PipelineDesc &desc) { VkPipelineRasterizationStateCreateInfo rs{ VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO }; raster->ToVulkan(&rs); - VkGraphicsPipelineCreateInfo info = { VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO }; - info.pNext = nullptr; + VkGraphicsPipelineCreateInfo info{ VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO }; info.flags = 0; info.stageCount = (uint32_t)stages.size(); info.pStages = stages.data();