summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorStenzek <stenzek@gmail.com>2016-11-13 15:38:32 +1000
committerStenzek <stenzek@gmail.com>2016-12-04 20:10:13 +1000
commitcd3481fbc7c82e8a1a44bff7239928a8faabbb42 (patch)
treed380e1055ed4b66dc4b0ba6c1fac47006e09e5c2 /Source/Core
parentd1c89db8c809a89d5576dc9ea524629cfc4d29a6 (diff)
Vulkan: Differentiate between descriptor set layouts and bind points
This also moves the pipeline and descriptor set layouts used for texture conversion (texel buffers) to ObjectCache, and shares a binding location with the SSBO set.
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/VideoBackends/Vulkan/Constants.h22
-rw-r--r--Source/Core/VideoBackends/Vulkan/ObjectCache.cpp41
-rw-r--r--Source/Core/VideoBackends/Vulkan/ObjectCache.h11
-rw-r--r--Source/Core/VideoBackends/Vulkan/PaletteTextureConverter.cpp69
-rw-r--r--Source/Core/VideoBackends/Vulkan/PaletteTextureConverter.h4
-rw-r--r--Source/Core/VideoBackends/Vulkan/StateTracker.cpp29
-rw-r--r--Source/Core/VideoBackends/Vulkan/StateTracker.h9
-rw-r--r--Source/Core/VideoBackends/Vulkan/Util.cpp30
8 files changed, 106 insertions, 109 deletions
diff --git a/Source/Core/VideoBackends/Vulkan/Constants.h b/Source/Core/VideoBackends/Vulkan/Constants.h
index a135c76180..ed38cf47d1 100644
--- a/Source/Core/VideoBackends/Vulkan/Constants.h
+++ b/Source/Core/VideoBackends/Vulkan/Constants.h
@@ -23,13 +23,23 @@ enum STAGING_BUFFER_TYPE
STAGING_BUFFER_TYPE_READBACK
};
-// Descriptor sets
-enum DESCRIPTOR_SET
+// Descriptor set layouts
+enum DESCRIPTOR_SET_LAYOUT
{
- DESCRIPTOR_SET_UNIFORM_BUFFERS,
- DESCRIPTOR_SET_PIXEL_SHADER_SAMPLERS,
- DESCRIPTOR_SET_SHADER_STORAGE_BUFFERS,
- NUM_DESCRIPTOR_SETS
+ DESCRIPTOR_SET_LAYOUT_UNIFORM_BUFFERS,
+ DESCRIPTOR_SET_LAYOUT_PIXEL_SHADER_SAMPLERS,
+ DESCRIPTOR_SET_LAYOUT_SHADER_STORAGE_BUFFERS,
+ DESCRIPTOR_SET_LAYOUT_TEXEL_BUFFERS,
+ NUM_DESCRIPTOR_SET_LAYOUTS
+};
+
+// Descriptor set bind points
+enum DESCRIPTOR_SET_BIND_POINT
+{
+ DESCRIPTOR_SET_BIND_POINT_UNIFORM_BUFFERS,
+ DESCRIPTOR_SET_BIND_POINT_PIXEL_SHADER_SAMPLERS,
+ DESCRIPTOR_SET_BIND_POINT_STORAGE_OR_TEXEL_BUFFER,
+ NUM_DESCRIPTOR_SET_BIND_POINTS
};
// Uniform buffer bindings within the first descriptor set
diff --git a/Source/Core/VideoBackends/Vulkan/ObjectCache.cpp b/Source/Core/VideoBackends/Vulkan/ObjectCache.cpp
index 761402e478..56baa687ef 100644
--- a/Source/Core/VideoBackends/Vulkan/ObjectCache.cpp
+++ b/Source/Core/VideoBackends/Vulkan/ObjectCache.cpp
@@ -695,15 +695,21 @@ bool ObjectCache::CreateDescriptorSetLayouts()
static const VkDescriptorSetLayoutBinding ssbo_set_bindings[] = {
{0, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1, VK_SHADER_STAGE_FRAGMENT_BIT}};
- static const VkDescriptorSetLayoutCreateInfo create_infos[NUM_DESCRIPTOR_SETS] = {
+ static const VkDescriptorSetLayoutBinding texel_buffer_set_bindings[] = {
+ {0, VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER, 1, VK_SHADER_STAGE_FRAGMENT_BIT},
+ };
+
+ static const VkDescriptorSetLayoutCreateInfo create_infos[NUM_DESCRIPTOR_SET_LAYOUTS] = {
{VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO, nullptr, 0,
static_cast<u32>(ArraySize(ubo_set_bindings)), ubo_set_bindings},
{VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO, nullptr, 0,
static_cast<u32>(ArraySize(sampler_set_bindings)), sampler_set_bindings},
{VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO, nullptr, 0,
- static_cast<u32>(ArraySize(ssbo_set_bindings)), ssbo_set_bindings}};
+ static_cast<u32>(ArraySize(ssbo_set_bindings)), ssbo_set_bindings},
+ {VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO, nullptr, 0,
+ static_cast<u32>(ArraySize(texel_buffer_set_bindings)), texel_buffer_set_bindings}};
- for (size_t i = 0; i < NUM_DESCRIPTOR_SETS; i++)
+ for (size_t i = 0; i < NUM_DESCRIPTOR_SET_LAYOUTS; i++)
{
VkResult res = vkCreateDescriptorSetLayout(g_vulkan_context->GetDevice(), &create_infos[i],
nullptr, &m_descriptor_set_layouts[i]);
@@ -732,12 +738,16 @@ bool ObjectCache::CreatePipelineLayouts()
// Descriptor sets for each pipeline layout
VkDescriptorSetLayout standard_sets[] = {
- m_descriptor_set_layouts[DESCRIPTOR_SET_UNIFORM_BUFFERS],
- m_descriptor_set_layouts[DESCRIPTOR_SET_PIXEL_SHADER_SAMPLERS]};
+ m_descriptor_set_layouts[DESCRIPTOR_SET_LAYOUT_UNIFORM_BUFFERS],
+ m_descriptor_set_layouts[DESCRIPTOR_SET_LAYOUT_PIXEL_SHADER_SAMPLERS]};
VkDescriptorSetLayout bbox_sets[] = {
- m_descriptor_set_layouts[DESCRIPTOR_SET_UNIFORM_BUFFERS],
- m_descriptor_set_layouts[DESCRIPTOR_SET_PIXEL_SHADER_SAMPLERS],
- m_descriptor_set_layouts[DESCRIPTOR_SET_SHADER_STORAGE_BUFFERS]};
+ m_descriptor_set_layouts[DESCRIPTOR_SET_LAYOUT_UNIFORM_BUFFERS],
+ m_descriptor_set_layouts[DESCRIPTOR_SET_LAYOUT_PIXEL_SHADER_SAMPLERS],
+ m_descriptor_set_layouts[DESCRIPTOR_SET_LAYOUT_SHADER_STORAGE_BUFFERS]};
+ VkDescriptorSetLayout texture_conversion_sets[] = {
+ m_descriptor_set_layouts[DESCRIPTOR_SET_LAYOUT_UNIFORM_BUFFERS],
+ m_descriptor_set_layouts[DESCRIPTOR_SET_LAYOUT_PIXEL_SHADER_SAMPLERS],
+ m_descriptor_set_layouts[DESCRIPTOR_SET_LAYOUT_TEXEL_BUFFERS]};
VkPushConstantRange push_constant_range = {
VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, 0, PUSH_CONSTANT_BUFFER_SIZE};
@@ -763,13 +773,23 @@ bool ObjectCache::CreatePipelineLayouts()
standard_sets,
1,
&push_constant_range};
+ VkPipelineLayoutCreateInfo texture_conversion_info = {
+ VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,
+ nullptr,
+ 0,
+ static_cast<u32>(ArraySize(texture_conversion_sets)),
+ texture_conversion_sets,
+ 1,
+ &push_constant_range};
if ((res = vkCreatePipelineLayout(g_vulkan_context->GetDevice(), &standard_info, nullptr,
&m_standard_pipeline_layout)) != VK_SUCCESS ||
(res = vkCreatePipelineLayout(g_vulkan_context->GetDevice(), &bbox_info, nullptr,
&m_bbox_pipeline_layout)) != VK_SUCCESS ||
(res = vkCreatePipelineLayout(g_vulkan_context->GetDevice(), &push_constant_info, nullptr,
- &m_push_constant_pipeline_layout)))
+ &m_push_constant_pipeline_layout)) != VK_SUCCESS ||
+ (res = vkCreatePipelineLayout(g_vulkan_context->GetDevice(), &texture_conversion_info,
+ nullptr, &m_texture_conversion_pipeline_layout)) != VK_SUCCESS)
{
LOG_VULKAN_ERROR(res, "vkCreatePipelineLayout failed: ");
return false;
@@ -787,6 +807,9 @@ void ObjectCache::DestroyPipelineLayouts()
if (m_push_constant_pipeline_layout != VK_NULL_HANDLE)
vkDestroyPipelineLayout(g_vulkan_context->GetDevice(), m_push_constant_pipeline_layout,
nullptr);
+ if (m_texture_conversion_pipeline_layout != VK_NULL_HANDLE)
+ vkDestroyPipelineLayout(g_vulkan_context->GetDevice(), m_texture_conversion_pipeline_layout,
+ nullptr);
}
bool ObjectCache::CreateUtilityShaderVertexFormat()
diff --git a/Source/Core/VideoBackends/Vulkan/ObjectCache.h b/Source/Core/VideoBackends/Vulkan/ObjectCache.h
index 26593d139d..76ed886ecd 100644
--- a/Source/Core/VideoBackends/Vulkan/ObjectCache.h
+++ b/Source/Core/VideoBackends/Vulkan/ObjectCache.h
@@ -70,17 +70,23 @@ public:
// - Same as standard, plus a single SSBO accessible from PS
// - Push Constant
// - Same as standard, plus 128 bytes of push constants, accessible from all stages.
+ // - Texture Conversion
+ // - Same as push constant, plus a single texel buffer accessible from PS.
//
// All three pipeline layouts use the same descriptor set layouts, but the final descriptor set
// (SSBO) is only required when using the BBox Enabled pipeline layout.
//
- VkDescriptorSetLayout GetDescriptorSetLayout(DESCRIPTOR_SET set) const
+ VkDescriptorSetLayout GetDescriptorSetLayout(DESCRIPTOR_SET_LAYOUT set) const
{
return m_descriptor_set_layouts[set];
}
VkPipelineLayout GetStandardPipelineLayout() const { return m_standard_pipeline_layout; }
VkPipelineLayout GetBBoxPipelineLayout() const { return m_bbox_pipeline_layout; }
VkPipelineLayout GetPushConstantPipelineLayout() const { return m_push_constant_pipeline_layout; }
+ VkPipelineLayout GetTextureConversionPipelineLayout() const
+ {
+ return m_texture_conversion_pipeline_layout;
+ }
// Shared utility shader resources
VertexFormat* GetUtilityShaderVertexFormat() const
{
@@ -157,11 +163,12 @@ private:
void DestroySharedShaders();
void DestroySamplers();
- std::array<VkDescriptorSetLayout, NUM_DESCRIPTOR_SETS> m_descriptor_set_layouts = {};
+ std::array<VkDescriptorSetLayout, NUM_DESCRIPTOR_SET_LAYOUTS> m_descriptor_set_layouts = {};
VkPipelineLayout m_standard_pipeline_layout = VK_NULL_HANDLE;
VkPipelineLayout m_bbox_pipeline_layout = VK_NULL_HANDLE;
VkPipelineLayout m_push_constant_pipeline_layout = VK_NULL_HANDLE;
+ VkPipelineLayout m_texture_conversion_pipeline_layout = VK_NULL_HANDLE;
std::unique_ptr<VertexFormat> m_utility_shader_vertex_format;
std::unique_ptr<StreamBuffer> m_utility_shader_vertex_buffer;
diff --git a/Source/Core/VideoBackends/Vulkan/PaletteTextureConverter.cpp b/Source/Core/VideoBackends/Vulkan/PaletteTextureConverter.cpp
index 3e992d4944..1234f5d5dd 100644
--- a/Source/Core/VideoBackends/Vulkan/PaletteTextureConverter.cpp
+++ b/Source/Core/VideoBackends/Vulkan/PaletteTextureConverter.cpp
@@ -40,12 +40,6 @@ PaletteTextureConverter::~PaletteTextureConverter()
if (m_palette_buffer_view != VK_NULL_HANDLE)
vkDestroyBufferView(g_vulkan_context->GetDevice(), m_palette_buffer_view, nullptr);
-
- if (m_pipeline_layout != VK_NULL_HANDLE)
- vkDestroyPipelineLayout(g_vulkan_context->GetDevice(), m_pipeline_layout, nullptr);
-
- if (m_palette_set_layout != VK_NULL_HANDLE)
- vkDestroyDescriptorSetLayout(g_vulkan_context->GetDevice(), m_palette_set_layout, nullptr);
}
bool PaletteTextureConverter::Initialize()
@@ -56,9 +50,6 @@ bool PaletteTextureConverter::Initialize()
if (!CompileShaders())
return false;
- if (!CreateDescriptorLayout())
- return false;
-
return true;
}
@@ -84,16 +75,18 @@ void PaletteTextureConverter::ConvertTexture(VkCommandBuffer command_buffer,
// If any of these fail, execute a command buffer, and try again.
if (!m_palette_stream_buffer->ReserveMemory(palette_size,
g_vulkan_context->GetTexelBufferAlignment()) ||
- (texel_buffer_descriptor_set =
- g_command_buffer_mgr->AllocateDescriptorSet(m_palette_set_layout)) == VK_NULL_HANDLE)
+ (texel_buffer_descriptor_set = g_command_buffer_mgr->AllocateDescriptorSet(
+ g_object_cache->GetDescriptorSetLayout(DESCRIPTOR_SET_LAYOUT_TEXEL_BUFFERS))) ==
+ VK_NULL_HANDLE)
{
WARN_LOG(VIDEO, "Executing command list while waiting for space in palette buffer");
Util::ExecuteCurrentCommandsAndRestoreState(false);
if (!m_palette_stream_buffer->ReserveMemory(palette_size,
g_vulkan_context->GetTexelBufferAlignment()) ||
- (texel_buffer_descriptor_set =
- g_command_buffer_mgr->AllocateDescriptorSet(m_palette_set_layout)) == VK_NULL_HANDLE)
+ (texel_buffer_descriptor_set = g_command_buffer_mgr->AllocateDescriptorSet(
+ g_object_cache->GetDescriptorSetLayout(DESCRIPTOR_SET_LAYOUT_TEXEL_BUFFERS))) ==
+ VK_NULL_HANDLE)
{
PanicAlert("Failed to allocate space for texture conversion");
return;
@@ -120,8 +113,8 @@ void PaletteTextureConverter::ConvertTexture(VkCommandBuffer command_buffer,
VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
// Set up draw
- UtilityShaderDraw draw(command_buffer, m_pipeline_layout, render_pass,
- g_object_cache->GetScreenQuadVertexShader(), VK_NULL_HANDLE,
+ UtilityShaderDraw draw(command_buffer, g_object_cache->GetTextureConversionPipelineLayout(),
+ render_pass, g_object_cache->GetScreenQuadVertexShader(), VK_NULL_HANDLE,
m_shaders[format]);
VkRect2D region = {{0, 0}, {width, height}};
@@ -139,7 +132,9 @@ void PaletteTextureConverter::ConvertTexture(VkCommandBuffer command_buffer,
draw.SetPSSampler(0, src_texture->GetView(), g_object_cache->GetPointSampler());
// We have to bind the texel buffer descriptor set separately.
- vkCmdBindDescriptorSets(command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, m_pipeline_layout, 0, 1,
+ vkCmdBindDescriptorSets(command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS,
+ g_object_cache->GetTextureConversionPipelineLayout(),
+ DESCRIPTOR_SET_BIND_POINT_STORAGE_OR_TEXEL_BUFFER, 1,
&texel_buffer_descriptor_set, 0, nullptr);
// Draw
@@ -274,46 +269,4 @@ bool PaletteTextureConverter::CompileShaders()
m_shaders[GX_TL_RGB5A3] != VK_NULL_HANDLE);
}
-bool PaletteTextureConverter::CreateDescriptorLayout()
-{
- static const VkDescriptorSetLayoutBinding set_bindings[] = {
- {0, VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER, 1, VK_SHADER_STAGE_FRAGMENT_BIT},
- };
- static const VkDescriptorSetLayoutCreateInfo set_info = {
- VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO, nullptr, 0,
- static_cast<u32>(ArraySize(set_bindings)), set_bindings};
-
- VkResult res = vkCreateDescriptorSetLayout(g_vulkan_context->GetDevice(), &set_info, nullptr,
- &m_palette_set_layout);
- if (res != VK_SUCCESS)
- {
- LOG_VULKAN_ERROR(res, "vkCreateDescriptorSetLayout failed: ");
- return false;
- }
-
- VkDescriptorSetLayout sets[] = {m_palette_set_layout, g_object_cache->GetDescriptorSetLayout(
- DESCRIPTOR_SET_PIXEL_SHADER_SAMPLERS)};
-
- VkPushConstantRange push_constant_range = {
- VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, 0, PUSH_CONSTANT_BUFFER_SIZE};
-
- VkPipelineLayoutCreateInfo pipeline_layout_info = {VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,
- nullptr,
- 0,
- static_cast<u32>(ArraySize(sets)),
- sets,
- 1,
- &push_constant_range};
-
- res = vkCreatePipelineLayout(g_vulkan_context->GetDevice(), &pipeline_layout_info, nullptr,
- &m_pipeline_layout);
- if (res != VK_SUCCESS)
- {
- LOG_VULKAN_ERROR(res, "vkCreatePipelineLayout failed: ");
- return false;
- }
-
- return true;
-}
-
} // namespace Vulkan
diff --git a/Source/Core/VideoBackends/Vulkan/PaletteTextureConverter.h b/Source/Core/VideoBackends/Vulkan/PaletteTextureConverter.h
index 2540b5affa..668e35eae6 100644
--- a/Source/Core/VideoBackends/Vulkan/PaletteTextureConverter.h
+++ b/Source/Core/VideoBackends/Vulkan/PaletteTextureConverter.h
@@ -34,10 +34,6 @@ private:
bool CreateBuffers();
bool CompileShaders();
- bool CreateDescriptorLayout();
-
- VkDescriptorSetLayout m_palette_set_layout = VK_NULL_HANDLE;
- VkPipelineLayout m_pipeline_layout = VK_NULL_HANDLE;
std::array<VkShaderModule, NUM_PALETTE_CONVERSION_SHADERS> m_shaders = {};
diff --git a/Source/Core/VideoBackends/Vulkan/StateTracker.cpp b/Source/Core/VideoBackends/Vulkan/StateTracker.cpp
index 081036ed8e..ae45ce857f 100644
--- a/Source/Core/VideoBackends/Vulkan/StateTracker.cpp
+++ b/Source/Core/VideoBackends/Vulkan/StateTracker.cpp
@@ -76,7 +76,7 @@ bool StateTracker::Initialize()
// BBox is disabled by default.
m_pipeline_state.pipeline_layout = g_object_cache->GetStandardPipelineLayout();
- m_num_active_descriptor_sets = NUM_DESCRIPTOR_SETS - 1;
+ m_num_active_descriptor_sets = NUM_GX_DRAW_DESCRIPTOR_SETS;
m_bbox_enabled = false;
// Initialize all samplers to point by default
@@ -545,16 +545,16 @@ void StateTracker::SetBBoxEnable(bool enable)
if (enable)
{
m_pipeline_state.pipeline_layout = g_object_cache->GetBBoxPipelineLayout();
- m_num_active_descriptor_sets = NUM_DESCRIPTOR_SETS;
+ m_num_active_descriptor_sets = NUM_GX_DRAW_WITH_BBOX_DESCRIPTOR_SETS;
// The bbox buffer never changes, so we defer descriptor updates until it is enabled.
- if (m_descriptor_sets[DESCRIPTOR_SET_SHADER_STORAGE_BUFFERS] == VK_NULL_HANDLE)
+ if (m_descriptor_sets[DESCRIPTOR_SET_BIND_POINT_STORAGE_OR_TEXEL_BUFFER] == VK_NULL_HANDLE)
m_dirty_flags |= DIRTY_FLAG_PS_SSBO;
}
else
{
m_pipeline_state.pipeline_layout = g_object_cache->GetStandardPipelineLayout();
- m_num_active_descriptor_sets = NUM_DESCRIPTOR_SETS - 1;
+ m_num_active_descriptor_sets = NUM_GX_DRAW_DESCRIPTOR_SETS;
}
m_dirty_flags |= DIRTY_FLAG_PIPELINE | DIRTY_FLAG_DESCRIPTOR_SET_BINDING;
@@ -731,7 +731,8 @@ bool StateTracker::Bind(bool rebind_all /*= false*/)
{
vkCmdBindDescriptorSets(
command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, m_pipeline_state.pipeline_layout,
- DESCRIPTOR_SET_UNIFORM_BUFFERS, 1, &m_descriptor_sets[DESCRIPTOR_SET_UNIFORM_BUFFERS],
+ DESCRIPTOR_SET_BIND_POINT_UNIFORM_BUFFERS, 1,
+ &m_descriptor_sets[DESCRIPTOR_SET_BIND_POINT_UNIFORM_BUFFERS],
NUM_UBO_DESCRIPTOR_SET_BINDINGS, m_bindings.uniform_buffer_offsets.data());
}
@@ -921,10 +922,10 @@ bool StateTracker::UpdateDescriptorSet()
u32 num_writes = 0;
if (m_dirty_flags & (DIRTY_FLAG_VS_UBO | DIRTY_FLAG_GS_UBO | DIRTY_FLAG_PS_UBO) ||
- m_descriptor_sets[DESCRIPTOR_SET_UNIFORM_BUFFERS] == VK_NULL_HANDLE)
+ m_descriptor_sets[DESCRIPTOR_SET_BIND_POINT_UNIFORM_BUFFERS] == VK_NULL_HANDLE)
{
VkDescriptorSetLayout layout =
- g_object_cache->GetDescriptorSetLayout(DESCRIPTOR_SET_UNIFORM_BUFFERS);
+ g_object_cache->GetDescriptorSetLayout(DESCRIPTOR_SET_LAYOUT_UNIFORM_BUFFERS);
VkDescriptorSet set = g_command_buffer_mgr->AllocateDescriptorSet(layout);
if (set == VK_NULL_HANDLE)
return false;
@@ -943,15 +944,15 @@ bool StateTracker::UpdateDescriptorSet()
nullptr};
}
- m_descriptor_sets[DESCRIPTOR_SET_UNIFORM_BUFFERS] = set;
+ m_descriptor_sets[DESCRIPTOR_SET_BIND_POINT_UNIFORM_BUFFERS] = set;
m_dirty_flags |= DIRTY_FLAG_DESCRIPTOR_SET_BINDING;
}
if (m_dirty_flags & DIRTY_FLAG_PS_SAMPLERS ||
- m_descriptor_sets[DESCRIPTOR_SET_PIXEL_SHADER_SAMPLERS] == VK_NULL_HANDLE)
+ m_descriptor_sets[DESCRIPTOR_SET_BIND_POINT_PIXEL_SHADER_SAMPLERS] == VK_NULL_HANDLE)
{
VkDescriptorSetLayout layout =
- g_object_cache->GetDescriptorSetLayout(DESCRIPTOR_SET_PIXEL_SHADER_SAMPLERS);
+ g_object_cache->GetDescriptorSetLayout(DESCRIPTOR_SET_LAYOUT_PIXEL_SHADER_SAMPLERS);
VkDescriptorSet set = g_command_buffer_mgr->AllocateDescriptorSet(layout);
if (set == VK_NULL_HANDLE)
return false;
@@ -974,16 +975,16 @@ bool StateTracker::UpdateDescriptorSet()
}
}
- m_descriptor_sets[DESCRIPTOR_SET_PIXEL_SHADER_SAMPLERS] = set;
+ m_descriptor_sets[DESCRIPTOR_SET_BIND_POINT_PIXEL_SHADER_SAMPLERS] = set;
m_dirty_flags |= DIRTY_FLAG_DESCRIPTOR_SET_BINDING;
}
if (m_bbox_enabled &&
(m_dirty_flags & DIRTY_FLAG_PS_SSBO ||
- m_descriptor_sets[DESCRIPTOR_SET_SHADER_STORAGE_BUFFERS] == VK_NULL_HANDLE))
+ m_descriptor_sets[DESCRIPTOR_SET_BIND_POINT_STORAGE_OR_TEXEL_BUFFER] == VK_NULL_HANDLE))
{
VkDescriptorSetLayout layout =
- g_object_cache->GetDescriptorSetLayout(DESCRIPTOR_SET_SHADER_STORAGE_BUFFERS);
+ g_object_cache->GetDescriptorSetLayout(DESCRIPTOR_SET_LAYOUT_SHADER_STORAGE_BUFFERS);
VkDescriptorSet set = g_command_buffer_mgr->AllocateDescriptorSet(layout);
if (set == VK_NULL_HANDLE)
return false;
@@ -999,7 +1000,7 @@ bool StateTracker::UpdateDescriptorSet()
&m_bindings.ps_ssbo,
nullptr};
- m_descriptor_sets[DESCRIPTOR_SET_SHADER_STORAGE_BUFFERS] = set;
+ m_descriptor_sets[DESCRIPTOR_SET_BIND_POINT_STORAGE_OR_TEXEL_BUFFER] = set;
m_dirty_flags |= DIRTY_FLAG_DESCRIPTOR_SET_BINDING;
}
diff --git a/Source/Core/VideoBackends/Vulkan/StateTracker.h b/Source/Core/VideoBackends/Vulkan/StateTracker.h
index 126041e9bc..97bcdd2cc0 100644
--- a/Source/Core/VideoBackends/Vulkan/StateTracker.h
+++ b/Source/Core/VideoBackends/Vulkan/StateTracker.h
@@ -132,6 +132,13 @@ private:
VkPrimitiveTopology primitive_topology;
};
+ // Number of descriptor sets for game draws.
+ enum
+ {
+ NUM_GX_DRAW_DESCRIPTOR_SETS = DESCRIPTOR_SET_BIND_POINT_PIXEL_SHADER_SAMPLERS + 1,
+ NUM_GX_DRAW_WITH_BBOX_DESCRIPTOR_SETS = DESCRIPTOR_SET_BIND_POINT_STORAGE_OR_TEXEL_BUFFER + 1
+ };
+
enum DITRY_FLAG : u32
{
DIRTY_FLAG_VS_UBO = (1 << 0),
@@ -202,7 +209,7 @@ private:
VkPipeline m_pipeline_object = VK_NULL_HANDLE;
// shader bindings
- std::array<VkDescriptorSet, NUM_DESCRIPTOR_SETS> m_descriptor_sets = {};
+ std::array<VkDescriptorSet, NUM_DESCRIPTOR_SET_BIND_POINTS> m_descriptor_sets = {};
struct
{
std::array<VkDescriptorBufferInfo, NUM_UBO_DESCRIPTOR_SET_BINDINGS> uniform_buffer_bindings =
diff --git a/Source/Core/VideoBackends/Vulkan/Util.cpp b/Source/Core/VideoBackends/Vulkan/Util.cpp
index e92c070fc8..f2b23a25ee 100644
--- a/Source/Core/VideoBackends/Vulkan/Util.cpp
+++ b/Source/Core/VideoBackends/Vulkan/Util.cpp
@@ -511,7 +511,7 @@ void UtilityShaderDraw::BindVertexBuffer()
void UtilityShaderDraw::BindDescriptors()
{
// TODO: This method is a mess, clean it up
- std::array<VkDescriptorSet, NUM_DESCRIPTOR_SETS> bind_descriptor_sets = {};
+ std::array<VkDescriptorSet, NUM_DESCRIPTOR_SET_BIND_POINTS> bind_descriptor_sets = {};
std::array<VkWriteDescriptorSet, NUM_UBO_DESCRIPTOR_SET_BINDINGS + NUM_PIXEL_SHADER_SAMPLERS>
set_writes = {};
uint32_t num_set_writes = 0;
@@ -523,7 +523,7 @@ void UtilityShaderDraw::BindDescriptors()
if (m_vs_uniform_buffer.buffer != VK_NULL_HANDLE || m_ps_uniform_buffer.buffer != VK_NULL_HANDLE)
{
VkDescriptorSet set = g_command_buffer_mgr->AllocateDescriptorSet(
- g_object_cache->GetDescriptorSetLayout(DESCRIPTOR_SET_UNIFORM_BUFFERS));
+ g_object_cache->GetDescriptorSetLayout(DESCRIPTOR_SET_LAYOUT_UNIFORM_BUFFERS));
if (set == VK_NULL_HANDLE)
PanicAlert("Failed to allocate descriptor set for utility draw");
@@ -552,7 +552,7 @@ void UtilityShaderDraw::BindDescriptors()
&dummy_uniform_buffer,
nullptr};
- bind_descriptor_sets[DESCRIPTOR_SET_UNIFORM_BUFFERS] = set;
+ bind_descriptor_sets[DESCRIPTOR_SET_LAYOUT_UNIFORM_BUFFERS] = set;
}
// PS samplers
@@ -572,7 +572,7 @@ void UtilityShaderDraw::BindDescriptors()
{
// Allocate a new descriptor set
VkDescriptorSet set = g_command_buffer_mgr->AllocateDescriptorSet(
- g_object_cache->GetDescriptorSetLayout(DESCRIPTOR_SET_PIXEL_SHADER_SAMPLERS));
+ g_object_cache->GetDescriptorSetLayout(DESCRIPTOR_SET_LAYOUT_PIXEL_SHADER_SAMPLERS));
if (set == VK_NULL_HANDLE)
PanicAlert("Failed to allocate descriptor set for utility draw");
@@ -594,7 +594,7 @@ void UtilityShaderDraw::BindDescriptors()
}
}
- bind_descriptor_sets[DESCRIPTOR_SET_PIXEL_SHADER_SAMPLERS] = set;
+ bind_descriptor_sets[DESCRIPTOR_SET_BIND_POINT_PIXEL_SHADER_SAMPLERS] = set;
}
vkUpdateDescriptorSets(g_vulkan_context->GetDevice(), num_set_writes, set_writes.data(), 0,
@@ -605,24 +605,24 @@ void UtilityShaderDraw::BindDescriptors()
{
// UBO only
vkCmdBindDescriptorSets(m_command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS,
- m_pipeline_info.pipeline_layout, DESCRIPTOR_SET_UNIFORM_BUFFERS, 1,
- &bind_descriptor_sets[0], NUM_UBO_DESCRIPTOR_SET_BINDINGS,
- m_ubo_offsets.data());
+ m_pipeline_info.pipeline_layout,
+ DESCRIPTOR_SET_BIND_POINT_UNIFORM_BUFFERS, 1, &bind_descriptor_sets[0],
+ NUM_UBO_DESCRIPTOR_SET_BINDINGS, m_ubo_offsets.data());
}
else if (bind_descriptor_sets[0] == VK_NULL_HANDLE && bind_descriptor_sets[1] != VK_NULL_HANDLE)
{
// Samplers only
- vkCmdBindDescriptorSets(m_command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS,
- m_pipeline_info.pipeline_layout, DESCRIPTOR_SET_PIXEL_SHADER_SAMPLERS,
- 1, &bind_descriptor_sets[1], 0, nullptr);
+ vkCmdBindDescriptorSets(
+ m_command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, m_pipeline_info.pipeline_layout,
+ DESCRIPTOR_SET_BIND_POINT_PIXEL_SHADER_SAMPLERS, 1, &bind_descriptor_sets[1], 0, nullptr);
}
else if (bind_descriptor_sets[0] != VK_NULL_HANDLE && bind_descriptor_sets[1] != VK_NULL_HANDLE)
{
// Both
- vkCmdBindDescriptorSets(m_command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS,
- m_pipeline_info.pipeline_layout, DESCRIPTOR_SET_UNIFORM_BUFFERS, 2,
- bind_descriptor_sets.data(), NUM_UBO_DESCRIPTOR_SET_BINDINGS,
- m_ubo_offsets.data());
+ vkCmdBindDescriptorSets(
+ m_command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, m_pipeline_info.pipeline_layout,
+ DESCRIPTOR_SET_BIND_POINT_UNIFORM_BUFFERS, 2, bind_descriptor_sets.data(),
+ NUM_UBO_DESCRIPTOR_SET_BINDINGS, m_ubo_offsets.data());
}
}