From b8d81283e86f91238a166b25ac46281620a3260b Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Tue, 27 Feb 2024 00:15:43 +0100 Subject: [PATCH] Vulkan: Remove unnecessary index buffer for backbuffer drawcall --- .../Latte/Renderer/Vulkan/VulkanRenderer.cpp | 18 +----------------- .../HW/Latte/Renderer/Vulkan/VulkanRenderer.h | 7 ------- 2 files changed, 1 insertion(+), 24 deletions(-) diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp index 631f1d0c..a86d3a1f 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp @@ -540,7 +540,6 @@ VulkanRenderer::VulkanRenderer() QueryMemoryInfo(); QueryAvailableFormats(); - CreateBackbufferIndexBuffer(); CreateCommandPool(); CreateCommandBuffers(); CreateDescriptorPool(); @@ -624,7 +623,6 @@ VulkanRenderer::~VulkanRenderer() DeleteNullObjects(); // delete buffers - memoryManager->DeleteBuffer(m_indexBuffer, m_indexBufferMemory); memoryManager->DeleteBuffer(m_uniformVarBuffer, m_uniformVarBufferMemory); memoryManager->DeleteBuffer(m_textureReadbackBuffer, m_textureReadbackBufferMemory); memoryManager->DeleteBuffer(m_xfbRingBuffer, m_xfbRingBufferMemory); @@ -2836,18 +2834,6 @@ void VulkanRenderer::ClearColorImage(LatteTextureVk* vkTexture, uint32 sliceInde vkTexture->SetImageLayout(subresourceRange, outputLayout); } -void VulkanRenderer::CreateBackbufferIndexBuffer() -{ - const VkDeviceSize bufferSize = sizeof(uint16) * 6; - memoryManager->CreateBuffer(bufferSize, VK_BUFFER_USAGE_INDEX_BUFFER_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, m_indexBuffer, m_indexBufferMemory); - - uint16* data; - vkMapMemory(m_logicalDevice, m_indexBufferMemory, 0, bufferSize, 0, (void**)&data); - const uint16 tmp[] = { 0, 1, 2, 3, 4, 5 }; - std::copy(std::begin(tmp), std::end(tmp), data); - vkUnmapMemory(m_logicalDevice, m_indexBufferMemory); -} - void VulkanRenderer::DrawBackbufferQuad(LatteTextureView* texView, RendererOutputShader* shader, bool useLinearTexFilter, sint32 imageX, sint32 imageY, sint32 imageWidth, sint32 imageHeight, bool padView, bool clearBackground) { if(!AcquireNextSwapchainImage(!padView)) @@ -2906,11 +2892,9 @@ void VulkanRenderer::DrawBackbufferQuad(LatteTextureView* texView, RendererOutpu vkCmdBindPipeline(m_state.currentCommandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); m_state.currentPipeline = pipeline; - vkCmdBindIndexBuffer(m_state.currentCommandBuffer, m_indexBuffer, 0, VK_INDEX_TYPE_UINT16); - vkCmdBindDescriptorSets(m_state.currentCommandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, m_pipelineLayout, 0, 1, &descriptSet, 0, nullptr); - vkCmdDrawIndexed(m_state.currentCommandBuffer, 6, 1, 0, 0, 0); + vkCmdDraw(m_state.currentCommandBuffer, 6, 1, 0, 0); vkCmdEndRenderPass(m_state.currentCommandBuffer); diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h index 7565d260..3e55fc0c 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h @@ -548,15 +548,11 @@ private: void sync_RenderPassStoreTextures(CachedFBOVk* fboVk); // command buffer - VkCommandBuffer getCurrentCommandBuffer() const { return m_state.currentCommandBuffer; } // uniform void uniformData_updateUniformVars(uint32 shaderStageIndex, LatteDecompilerShader* shader); - // indices - void CreateBackbufferIndexBuffer(); - // misc void CreatePipelineCache(); VkPipelineShaderStageCreateInfo CreatePipelineShaderStageCreateInfo(VkShaderStageFlagBits stage, VkShaderModule& module, const char* entryName) const; @@ -580,9 +576,6 @@ private: void occlusionQuery_notifyBeginCommandBuffer(); private: - VkBuffer m_indexBuffer = VK_NULL_HANDLE; - VkDeviceMemory m_indexBufferMemory = VK_NULL_HANDLE; - std::vector m_layerNames; VkInstance m_instance = VK_NULL_HANDLE; VkPhysicalDevice m_physicalDevice = VK_NULL_HANDLE;