From e91efb6dc2c6d0d0c360ea079d75ce26ac4bc8dc Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Thu, 18 Jul 2019 18:41:09 +0200 Subject: [PATCH] [dxvk] Use new fullscreen shaders for meta resolve operations --- src/dxvk/dxvk_context.cpp | 2 +- src/dxvk/dxvk_meta_resolve.cpp | 44 ++++++++++++++++++++-------------- src/dxvk/dxvk_meta_resolve.h | 12 +++++----- 3 files changed, 33 insertions(+), 25 deletions(-) diff --git a/src/dxvk/dxvk_context.cpp b/src/dxvk/dxvk_context.cpp index 19409bf47..8f430ec4b 100644 --- a/src/dxvk/dxvk_context.cpp +++ b/src/dxvk/dxvk_context.cpp @@ -3054,7 +3054,7 @@ namespace dxvk { m_cmd->cmdPushConstants(pipeInfo.pipeLayout, VK_SHADER_STAGE_FRAGMENT_BIT, 0, sizeof(srcOffset), &srcOffset); - m_cmd->cmdDraw(1, region.dstSubresource.layerCount, 0, 0); + m_cmd->cmdDraw(3, region.dstSubresource.layerCount, 0, 0); m_cmd->cmdEndRenderPass(); m_execBarriers.accessImage( diff --git a/src/dxvk/dxvk_meta_resolve.cpp b/src/dxvk/dxvk_meta_resolve.cpp index bb133b3f9..e7e071f2b 100644 --- a/src/dxvk/dxvk_meta_resolve.cpp +++ b/src/dxvk/dxvk_meta_resolve.cpp @@ -1,8 +1,10 @@ #include "dxvk_device.h" #include "dxvk_meta_resolve.h" -#include -#include +#include +#include +#include + #include #include #include @@ -103,17 +105,20 @@ namespace dxvk { - DxvkMetaResolveObjects::DxvkMetaResolveObjects(DxvkDevice* device) + DxvkMetaResolveObjects::DxvkMetaResolveObjects(const DxvkDevice* device) : m_vkd (device->vkd()), m_sampler (createSampler()), - m_shaderVert (createShaderModule(dxvk_copy_vert)), - m_shaderGeom (createShaderModule(dxvk_copy_geom)), m_shaderFragF (device->extensions().amdShaderFragmentMask ? createShaderModule(dxvk_resolve_frag_f_amd) : createShaderModule(dxvk_resolve_frag_f)), m_shaderFragU (createShaderModule(dxvk_resolve_frag_u)), m_shaderFragI (createShaderModule(dxvk_resolve_frag_i)) { - + if (device->extensions().extShaderViewportIndexLayer) { + m_shaderVert = createShaderModule(dxvk_fullscreen_layer_vert); + } else { + m_shaderVert = createShaderModule(dxvk_fullscreen_vert); + m_shaderGeom = createShaderModule(dxvk_fullscreen_geom); + } } @@ -308,6 +313,7 @@ namespace dxvk { auto formatInfo = imageFormatInfo(key.format); std::array stages; + uint32_t stageCount = 0; VkSpecializationMapEntry specEntry; specEntry.constantID = 0; @@ -320,7 +326,7 @@ namespace dxvk { specInfo.dataSize = sizeof(VkSampleCountFlagBits); specInfo.pData = &key.samples; - VkPipelineShaderStageCreateInfo& vsStage = stages[0]; + VkPipelineShaderStageCreateInfo& vsStage = stages[stageCount++]; vsStage.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; vsStage.pNext = nullptr; vsStage.flags = 0; @@ -329,16 +335,18 @@ namespace dxvk { vsStage.pName = "main"; vsStage.pSpecializationInfo = nullptr; - VkPipelineShaderStageCreateInfo& gsStage = stages[1]; - gsStage.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; - gsStage.pNext = nullptr; - gsStage.flags = 0; - gsStage.stage = VK_SHADER_STAGE_GEOMETRY_BIT; - gsStage.module = m_shaderGeom; - gsStage.pName = "main"; - gsStage.pSpecializationInfo = nullptr; + if (m_shaderGeom) { + VkPipelineShaderStageCreateInfo& gsStage = stages[stageCount++]; + gsStage.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; + gsStage.pNext = nullptr; + gsStage.flags = 0; + gsStage.stage = VK_SHADER_STAGE_GEOMETRY_BIT; + gsStage.module = m_shaderGeom; + gsStage.pName = "main"; + gsStage.pSpecializationInfo = nullptr; + } - VkPipelineShaderStageCreateInfo& psStage = stages[2]; + VkPipelineShaderStageCreateInfo& psStage = stages[stageCount++]; psStage.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; psStage.pNext = nullptr; psStage.flags = 0; @@ -377,7 +385,7 @@ namespace dxvk { iaState.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; iaState.pNext = nullptr; iaState.flags = 0; - iaState.topology = VK_PRIMITIVE_TOPOLOGY_POINT_LIST; + iaState.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; iaState.primitiveRestartEnable = VK_FALSE; VkPipelineViewportStateCreateInfo vpState; @@ -444,7 +452,7 @@ namespace dxvk { info.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; info.pNext = nullptr; info.flags = 0; - info.stageCount = stages.size(); + info.stageCount = stageCount; info.pStages = stages.data(); info.pVertexInputState = &viState; info.pInputAssemblyState = &iaState; diff --git a/src/dxvk/dxvk_meta_resolve.h b/src/dxvk/dxvk_meta_resolve.h index 2fd3499bd..a100041a0 100644 --- a/src/dxvk/dxvk_meta_resolve.h +++ b/src/dxvk/dxvk_meta_resolve.h @@ -98,7 +98,7 @@ namespace dxvk { public: - DxvkMetaResolveObjects(DxvkDevice* device); + DxvkMetaResolveObjects(const DxvkDevice* device); ~DxvkMetaResolveObjects(); /** @@ -118,11 +118,11 @@ namespace dxvk { VkSampler m_sampler; - VkShaderModule m_shaderVert; - VkShaderModule m_shaderGeom; - VkShaderModule m_shaderFragF; - VkShaderModule m_shaderFragU; - VkShaderModule m_shaderFragI; + VkShaderModule m_shaderVert = VK_NULL_HANDLE; + VkShaderModule m_shaderGeom = VK_NULL_HANDLE; + VkShaderModule m_shaderFragF = VK_NULL_HANDLE; + VkShaderModule m_shaderFragU = VK_NULL_HANDLE; + VkShaderModule m_shaderFragI = VK_NULL_HANDLE; std::mutex m_mutex;