summaryrefslogtreecommitdiff
path: root/Source/Core/VideoBackends
diff options
context:
space:
mode:
authorTellowKrinkle <tellowkrinkle@gmail.com>2022-07-24 03:32:59 -0500
committerTellowKrinkle <tellowkrinkle@gmail.com>2022-10-22 20:13:24 -0500
commit3a5901d12e1257001f983acdb55448db29befed2 (patch)
treeecc8b974261149fb25356f9baf12337aed47effc /Source/Core/VideoBackends
parent678ee48bfcc169e1d1833a19635153f544613ad5 (diff)
VideoBackends:Vulkan: Add support for vertex shader point and line expansion
Diffstat (limited to 'Source/Core/VideoBackends')
-rw-r--r--Source/Core/VideoBackends/Vulkan/ObjectCache.cpp23
-rw-r--r--Source/Core/VideoBackends/Vulkan/StateTracker.cpp31
-rw-r--r--Source/Core/VideoBackends/Vulkan/VulkanContext.cpp1
3 files changed, 35 insertions, 20 deletions
diff --git a/Source/Core/VideoBackends/Vulkan/ObjectCache.cpp b/Source/Core/VideoBackends/Vulkan/ObjectCache.cpp
index 353cb6da3f..57dbe6f5e3 100644
--- a/Source/Core/VideoBackends/Vulkan/ObjectCache.cpp
+++ b/Source/Core/VideoBackends/Vulkan/ObjectCache.cpp
@@ -156,9 +156,11 @@ bool ObjectCache::CreateDescriptorSetLayouts()
{5, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, 1, VK_SHADER_STAGE_COMPUTE_BIT},
}};
+ std::array<VkDescriptorSetLayoutBinding, 3> ubo_bindings = standard_ubo_bindings;
+
std::array<VkDescriptorSetLayoutCreateInfo, NUM_DESCRIPTOR_SET_LAYOUTS> create_infos{{
{VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO, nullptr, 0,
- static_cast<u32>(standard_ubo_bindings.size()), standard_ubo_bindings.data()},
+ static_cast<u32>(ubo_bindings.size()), ubo_bindings.data()},
{VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO, nullptr, 0,
static_cast<u32>(standard_sampler_bindings.size()), standard_sampler_bindings.data()},
{VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO, nullptr, 0,
@@ -172,8 +174,17 @@ bool ObjectCache::CreateDescriptorSetLayouts()
}};
// Don't set the GS bit if geometry shaders aren't available.
- if (!g_ActiveConfig.backend_info.bSupportsGeometryShaders)
+ if (g_ActiveConfig.UseVSForLinePointExpand())
+ {
+ if (g_ActiveConfig.backend_info.bSupportsGeometryShaders)
+ ubo_bindings[UBO_DESCRIPTOR_SET_BINDING_GS].stageFlags |= VK_SHADER_STAGE_VERTEX_BIT;
+ else
+ ubo_bindings[UBO_DESCRIPTOR_SET_BINDING_GS].stageFlags = VK_SHADER_STAGE_VERTEX_BIT;
+ }
+ else if (!g_ActiveConfig.backend_info.bSupportsGeometryShaders)
+ {
create_infos[DESCRIPTOR_SET_LAYOUT_STANDARD_UNIFORM_BUFFERS].bindingCount--;
+ }
// Remove the dynamic vertex loader's buffer if it'll never be needed
if (!g_ActiveConfig.backend_info.bSupportsDynamicVertexLoader)
@@ -244,12 +255,14 @@ bool ObjectCache::CreatePipelineLayouts()
static_cast<u32>(compute_sets.size()), compute_sets.data(), 0, nullptr},
}};
+ const bool ssbos_in_standard =
+ g_ActiveConfig.backend_info.bSupportsBBox || g_ActiveConfig.UseVSForLinePointExpand();
+
// If bounding box is unsupported, don't bother with the SSBO descriptor set.
- if (!g_ActiveConfig.backend_info.bSupportsBBox)
+ if (!ssbos_in_standard)
pipeline_layout_info[PIPELINE_LAYOUT_STANDARD].setLayoutCount--;
// If neither SSBO-using feature is supported, skip in ubershaders too
- if (!g_ActiveConfig.backend_info.bSupportsBBox &&
- !g_ActiveConfig.backend_info.bSupportsDynamicVertexLoader)
+ if (!ssbos_in_standard && !g_ActiveConfig.backend_info.bSupportsDynamicVertexLoader)
pipeline_layout_info[PIPELINE_LAYOUT_UBER].setLayoutCount--;
for (size_t i = 0; i < pipeline_layout_info.size(); i++)
diff --git a/Source/Core/VideoBackends/Vulkan/StateTracker.cpp b/Source/Core/VideoBackends/Vulkan/StateTracker.cpp
index d9b03940ce..8b01c66ca8 100644
--- a/Source/Core/VideoBackends/Vulkan/StateTracker.cpp
+++ b/Source/Core/VideoBackends/Vulkan/StateTracker.cpp
@@ -458,6 +458,9 @@ void StateTracker::UpdateGXDescriptorSet()
std::array<VkWriteDescriptorSet, MAX_DESCRIPTOR_WRITES> writes;
u32 num_writes = 0;
+ const bool needs_gs_ubo = g_ActiveConfig.backend_info.bSupportsGeometryShaders ||
+ g_ActiveConfig.UseVSForLinePointExpand();
+
if (m_dirty_flags & DIRTY_FLAG_GX_UBOS || m_gx_descriptor_sets[0] == VK_NULL_HANDLE)
{
m_gx_descriptor_sets[0] = g_command_buffer_mgr->AllocateDescriptorSet(
@@ -465,8 +468,7 @@ void StateTracker::UpdateGXDescriptorSet()
for (size_t i = 0; i < NUM_UBO_DESCRIPTOR_SET_BINDINGS; i++)
{
- if (i == UBO_DESCRIPTOR_SET_BINDING_GS &&
- !g_ActiveConfig.backend_info.bSupportsGeometryShaders)
+ if (i == UBO_DESCRIPTOR_SET_BINDING_GS && !needs_gs_ubo)
{
continue;
}
@@ -505,8 +507,9 @@ void StateTracker::UpdateGXDescriptorSet()
}
const bool needs_bbox_ssbo = g_ActiveConfig.backend_info.bSupportsBBox;
- const bool needs_vertex_ssbo = g_ActiveConfig.backend_info.bSupportsDynamicVertexLoader &&
- m_pipeline->GetUsage() == AbstractPipelineUsage::GXUber;
+ const bool needs_vertex_ssbo = (g_ActiveConfig.backend_info.bSupportsDynamicVertexLoader &&
+ m_pipeline->GetUsage() == AbstractPipelineUsage::GXUber) ||
+ g_ActiveConfig.UseVSForLinePointExpand();
const bool needs_ssbo = needs_bbox_ssbo || needs_vertex_ssbo;
if (needs_ssbo &&
@@ -520,7 +523,8 @@ void StateTracker::UpdateGXDescriptorSet()
VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, nullptr, m_gx_descriptor_sets[2], 0, 0, 1,
VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, nullptr, &m_bindings.ssbo, nullptr};
- if (g_ActiveConfig.backend_info.bSupportsDynamicVertexLoader)
+ if (g_ActiveConfig.backend_info.bSupportsDynamicVertexLoader ||
+ g_ActiveConfig.UseVSForLinePointExpand())
{
writes[num_writes++] = {VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
nullptr,
@@ -546,21 +550,18 @@ void StateTracker::UpdateGXDescriptorSet()
VK_PIPELINE_BIND_POINT_GRAPHICS, m_pipeline->GetVkPipelineLayout(), 0,
needs_ssbo ? NUM_GX_DESCRIPTOR_SETS : (NUM_GX_DESCRIPTOR_SETS - 1),
m_gx_descriptor_sets.data(),
- g_ActiveConfig.backend_info.bSupportsGeometryShaders ?
- NUM_UBO_DESCRIPTOR_SET_BINDINGS :
- (NUM_UBO_DESCRIPTOR_SET_BINDINGS - 1),
+ needs_gs_ubo ? NUM_UBO_DESCRIPTOR_SET_BINDINGS :
+ (NUM_UBO_DESCRIPTOR_SET_BINDINGS - 1),
m_bindings.gx_ubo_offsets.data());
m_dirty_flags &= ~(DIRTY_FLAG_DESCRIPTOR_SETS | DIRTY_FLAG_GX_UBO_OFFSETS);
}
else if (m_dirty_flags & DIRTY_FLAG_GX_UBO_OFFSETS)
{
- vkCmdBindDescriptorSets(g_command_buffer_mgr->GetCurrentCommandBuffer(),
- VK_PIPELINE_BIND_POINT_GRAPHICS, m_pipeline->GetVkPipelineLayout(), 0,
- 1, m_gx_descriptor_sets.data(),
- g_ActiveConfig.backend_info.bSupportsGeometryShaders ?
- NUM_UBO_DESCRIPTOR_SET_BINDINGS :
- (NUM_UBO_DESCRIPTOR_SET_BINDINGS - 1),
- m_bindings.gx_ubo_offsets.data());
+ vkCmdBindDescriptorSets(
+ g_command_buffer_mgr->GetCurrentCommandBuffer(), VK_PIPELINE_BIND_POINT_GRAPHICS,
+ m_pipeline->GetVkPipelineLayout(), 0, 1, m_gx_descriptor_sets.data(),
+ needs_gs_ubo ? NUM_UBO_DESCRIPTOR_SET_BINDINGS : (NUM_UBO_DESCRIPTOR_SET_BINDINGS - 1),
+ m_bindings.gx_ubo_offsets.data());
m_dirty_flags &= ~DIRTY_FLAG_GX_UBO_OFFSETS;
}
}
diff --git a/Source/Core/VideoBackends/Vulkan/VulkanContext.cpp b/Source/Core/VideoBackends/Vulkan/VulkanContext.cpp
index bc9cc1169b..a1119cefcb 100644
--- a/Source/Core/VideoBackends/Vulkan/VulkanContext.cpp
+++ b/Source/Core/VideoBackends/Vulkan/VulkanContext.cpp
@@ -299,6 +299,7 @@ void VulkanContext::PopulateBackendInfo(VideoConfig* config)
config->backend_info.bSupportsSettingObjectNames = false; // Dependent on features.
config->backend_info.bSupportsPartialMultisampleResolve = true; // Assumed support.
config->backend_info.bSupportsDynamicVertexLoader = true; // Assumed support.
+ config->backend_info.bSupportsVSLinePointExpand = true; // Assumed support.
}
void VulkanContext::PopulateBackendInfoAdapters(VideoConfig* config, const GPUList& gpu_list)