From 73cd9fac7dd42249035f9cbcd4cc8a3ce4f6551f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 13 Dec 2022 15:16:11 +0100 Subject: [PATCH] Tiny optimization in PipelineDesc --- Common/GPU/Vulkan/VulkanRenderManager.cpp | 5 ++++- Common/GPU/Vulkan/VulkanRenderManager.h | 3 ++- Common/GPU/Vulkan/thin3d_vulkan.cpp | 2 +- GPU/Vulkan/GPU_Vulkan.cpp | 2 +- GPU/Vulkan/PipelineManagerVulkan.cpp | 7 ++----- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Common/GPU/Vulkan/VulkanRenderManager.cpp b/Common/GPU/Vulkan/VulkanRenderManager.cpp index fab538a0a4..b635ff75da 100644 --- a/Common/GPU/Vulkan/VulkanRenderManager.cpp +++ b/Common/GPU/Vulkan/VulkanRenderManager.cpp @@ -86,12 +86,15 @@ bool VKRGraphicsPipeline::Create(VulkanContext *vulkan, VkRenderPass compatibleR ms.minSampleShading = 1.0f; } + VkPipelineInputAssemblyStateCreateInfo inputAssembly{ VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO }; + inputAssembly.topology = desc->topology; + // We will use dynamic viewport state. pipe.pVertexInputState = &desc->vis; pipe.pViewportState = &desc->views; pipe.pTessellationState = nullptr; pipe.pDynamicState = &desc->ds; - pipe.pInputAssemblyState = &desc->inputAssembly; + pipe.pInputAssemblyState = &inputAssembly; pipe.pMultisampleState = &ms; pipe.layout = desc->pipelineLayout; pipe.basePipelineHandle = VK_NULL_HANDLE; diff --git a/Common/GPU/Vulkan/VulkanRenderManager.h b/Common/GPU/Vulkan/VulkanRenderManager.h index e4845f9924..064f1684c9 100644 --- a/Common/GPU/Vulkan/VulkanRenderManager.h +++ b/Common/GPU/Vulkan/VulkanRenderManager.h @@ -75,6 +75,7 @@ struct BoundingRect { }; // All the data needed to create a graphics pipeline. +// TODO: Compress this down greatly. struct VKRGraphicsPipelineDesc : Draw::RefCountedObject { VkPipelineCache pipelineCache = VK_NULL_HANDLE; VkPipelineColorBlendStateCreateInfo cbs{ VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO }; @@ -95,7 +96,7 @@ struct VKRGraphicsPipelineDesc : Draw::RefCountedObject { std::string fragmentShaderSource; std::string geometryShaderSource; - VkPipelineInputAssemblyStateCreateInfo inputAssembly{ VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO }; + VkPrimitiveTopology topology; VkVertexInputAttributeDescription attrs[8]{}; VkVertexInputBindingDescription ibd{}; VkPipelineVertexInputStateCreateInfo vis{ VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO }; diff --git a/Common/GPU/Vulkan/thin3d_vulkan.cpp b/Common/GPU/Vulkan/thin3d_vulkan.cpp index 422c288083..19277ec94b 100644 --- a/Common/GPU/Vulkan/thin3d_vulkan.cpp +++ b/Common/GPU/Vulkan/thin3d_vulkan.cpp @@ -1216,7 +1216,7 @@ Pipeline *VKContext::CreateGraphicsPipeline(const PipelineDesc &desc, const char raster->ToVulkan(&gDesc.rs); // Copy bindings from input layout. - gDesc.inputAssembly.topology = primToVK[(int)desc.prim]; + gDesc.topology = primToVK[(int)desc.prim]; // We treat the three stencil states as a unit in other places, so let's do that here too. const VkDynamicState dynamics[] = { VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_SCISSOR, VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK, VK_DYNAMIC_STATE_STENCIL_REFERENCE, VK_DYNAMIC_STATE_STENCIL_WRITE_MASK }; diff --git a/GPU/Vulkan/GPU_Vulkan.cpp b/GPU/Vulkan/GPU_Vulkan.cpp index bd4b4f0204..c912bc71a8 100644 --- a/GPU/Vulkan/GPU_Vulkan.cpp +++ b/GPU/Vulkan/GPU_Vulkan.cpp @@ -121,7 +121,7 @@ void GPU_Vulkan::CancelReady() { void GPU_Vulkan::LoadCache(const Path &filename) { if (!g_Config.bShaderCache) { - INFO_LOG(G3D, "Shader cache disabled. Not loading."); + WARN_LOG(G3D, "!!!! Shader cache disabled. Not loading."); return; } diff --git a/GPU/Vulkan/PipelineManagerVulkan.cpp b/GPU/Vulkan/PipelineManagerVulkan.cpp index f5ba269229..cb945fc4f0 100644 --- a/GPU/Vulkan/PipelineManagerVulkan.cpp +++ b/GPU/Vulkan/PipelineManagerVulkan.cpp @@ -266,12 +266,9 @@ static VulkanPipeline *CreateVulkanPipeline(VulkanRenderManager *renderManager, desc->geometryShaderSource = gs->GetShaderString(SHADER_STRING_SOURCE_CODE); } - VkPipelineInputAssemblyStateCreateInfo &inputAssembly = desc->inputAssembly; - inputAssembly.flags = 0; - inputAssembly.topology = (VkPrimitiveTopology)key.topology; - inputAssembly.primitiveRestartEnable = false; - int vertexStride = 0; + desc->topology = (VkPrimitiveTopology)key.topology; + int vertexStride = 0; VkVertexInputAttributeDescription *attrs = &desc->attrs[0]; int attributeCount;