mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-26 04:32:35 +01:00
vulkan: Move descriptor sets and layout in VKGSRender class
They're now shared between all programs.
This commit is contained in:
parent
6a1f0aed36
commit
24eb544046
@ -285,6 +285,67 @@ namespace
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
std::tuple<VkPipelineLayout, VkDescriptorSetLayout> get_shared_pipeline_layout(VkDevice dev)
|
||||
{
|
||||
std::array<VkDescriptorSetLayoutBinding, 35> bindings = {};
|
||||
|
||||
size_t idx = 0;
|
||||
// Vertex buffer
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
bindings[idx].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER;
|
||||
bindings[idx].descriptorCount = 1;
|
||||
bindings[idx].stageFlags = VK_SHADER_STAGE_VERTEX_BIT;
|
||||
bindings[idx].binding = VERTEX_BUFFERS_FIRST_BIND_SLOT + i;
|
||||
idx++;
|
||||
}
|
||||
|
||||
bindings[idx].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
|
||||
bindings[idx].descriptorCount = 1;
|
||||
bindings[idx].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT;
|
||||
bindings[idx].binding = FRAGMENT_CONSTANT_BUFFERS_BIND_SLOT;
|
||||
|
||||
idx++;
|
||||
|
||||
bindings[idx].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
|
||||
bindings[idx].descriptorCount = 1;
|
||||
bindings[idx].stageFlags = VK_SHADER_STAGE_VERTEX_BIT;
|
||||
bindings[idx].binding = VERTEX_CONSTANT_BUFFERS_BIND_SLOT;
|
||||
|
||||
idx++;
|
||||
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
bindings[idx].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
|
||||
bindings[idx].descriptorCount = 1;
|
||||
bindings[idx].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT;
|
||||
bindings[idx].binding = TEXTURES_FIRST_BIND_SLOT + i;
|
||||
idx++;
|
||||
}
|
||||
|
||||
bindings[idx].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
|
||||
bindings[idx].descriptorCount = 1;
|
||||
bindings[idx].stageFlags = VK_SHADER_STAGE_ALL_GRAPHICS;
|
||||
bindings[idx].binding = SCALE_OFFSET_BIND_SLOT;
|
||||
|
||||
VkDescriptorSetLayoutCreateInfo infos = {};
|
||||
infos.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
|
||||
infos.pBindings = bindings.data();
|
||||
infos.bindingCount = bindings.size();
|
||||
|
||||
VkDescriptorSetLayout set_layout;
|
||||
CHECK_RESULT(vkCreateDescriptorSetLayout(dev, &infos, nullptr, &set_layout));
|
||||
|
||||
VkPipelineLayoutCreateInfo layout_info = {};
|
||||
layout_info.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
|
||||
layout_info.setLayoutCount = 1;
|
||||
layout_info.pSetLayouts = &set_layout;
|
||||
|
||||
VkPipelineLayout result;
|
||||
CHECK_RESULT(vkCreatePipelineLayout(dev, &layout_info, nullptr, &result));
|
||||
return std::make_tuple(result, set_layout);
|
||||
}
|
||||
}
|
||||
|
||||
VKGSRender::VKGSRender() : GSRender(frame_type::Vulkan)
|
||||
@ -353,6 +414,24 @@ VKGSRender::VKGSRender() : GSRender(frame_type::Vulkan)
|
||||
m_index_buffer.reset(new vk::buffer(*m_device, RING_BUFFER_SIZE, m_memory_type_mapping.host_visible_coherent, VK_BUFFER_USAGE_INDEX_BUFFER_BIT, 0));
|
||||
|
||||
m_render_passes = get_precomputed_render_passes(*m_device, m_optimal_tiling_supported_formats);
|
||||
|
||||
std::tie(pipeline_layout, descriptor_layouts) = get_shared_pipeline_layout(*m_device);
|
||||
|
||||
VkDescriptorPoolSize uniform_buffer_pool = { VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER , 3 };
|
||||
VkDescriptorPoolSize uniform_texel_pool = { VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER , 16 };
|
||||
VkDescriptorPoolSize texture_pool = { VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER , 16 };
|
||||
|
||||
std::vector<VkDescriptorPoolSize> sizes{ uniform_buffer_pool, uniform_texel_pool, texture_pool };
|
||||
|
||||
descriptor_pool.create(*m_device, sizes.data(), sizes.size());
|
||||
|
||||
VkDescriptorSetAllocateInfo alloc_info = {};
|
||||
alloc_info.descriptorPool = descriptor_pool;
|
||||
alloc_info.descriptorSetCount = 1;
|
||||
alloc_info.pSetLayouts = &descriptor_layouts;
|
||||
alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO;
|
||||
|
||||
CHECK_RESULT(vkAllocateDescriptorSets(*m_device, &alloc_info, &descriptor_sets));
|
||||
}
|
||||
|
||||
VKGSRender::~VKGSRender()
|
||||
@ -379,6 +458,12 @@ VKGSRender::~VKGSRender()
|
||||
if (render_pass)
|
||||
vkDestroyRenderPass(*m_device, render_pass, nullptr);
|
||||
|
||||
vkFreeDescriptorSets(*m_device, descriptor_pool, 1, &descriptor_sets);
|
||||
vkDestroyPipelineLayout(*m_device, pipeline_layout, nullptr);
|
||||
vkDestroyDescriptorSetLayout(*m_device, descriptor_layouts, nullptr);
|
||||
|
||||
descriptor_pool.destroy();
|
||||
|
||||
m_command_buffer.destroy();
|
||||
m_command_buffer_pool.destroy();
|
||||
|
||||
@ -540,12 +625,12 @@ void VKGSRender::end()
|
||||
{
|
||||
if (!textures[i].enabled())
|
||||
{
|
||||
m_program->bind_uniform({ vk::null_sampler(), vk::null_image_view(), VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL}, "tex" + std::to_string(i));
|
||||
m_program->bind_uniform({ vk::null_sampler(), vk::null_image_view(), VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL}, "tex" + std::to_string(i), descriptor_sets);
|
||||
continue;
|
||||
}
|
||||
|
||||
vk::texture &tex = (texture0)? (*texture0): m_texture_cache.upload_texture(m_command_buffer, textures[i], m_rtts);
|
||||
m_program->bind_uniform({ tex, tex, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL }, "tex" + std::to_string(i));
|
||||
m_program->bind_uniform({ tex, tex, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL }, "tex" + std::to_string(i), descriptor_sets);
|
||||
texture0 = &tex;
|
||||
}
|
||||
}
|
||||
@ -553,7 +638,7 @@ void VKGSRender::end()
|
||||
auto upload_info = upload_vertex_data();
|
||||
|
||||
m_program->set_primitive_topology(std::get<0>(upload_info));
|
||||
m_program->use(m_command_buffer, current_render_pass, 0);
|
||||
m_program->use(m_command_buffer, current_render_pass, pipeline_layout, descriptor_sets);
|
||||
|
||||
if (!std::get<1>(upload_info))
|
||||
vkCmdDraw(m_command_buffer, vertex_draw_count, 1, 0, 0);
|
||||
@ -809,9 +894,9 @@ bool VKGSRender::load_program()
|
||||
m_prog_buffer.fill_fragment_constans_buffer({ reinterpret_cast<float*>(buf), gsl::narrow<int>(fragment_constants_sz) }, fragment_program);
|
||||
m_uniform_buffer->unmap();
|
||||
|
||||
m_program->bind_uniform({ m_uniform_buffer->value, scale_offset_offset, 256 }, SCALE_OFFSET_BIND_SLOT);
|
||||
m_program->bind_uniform({ m_uniform_buffer->value, vertex_constants_offset, 512 * 4 * sizeof(float) }, VERTEX_CONSTANT_BUFFERS_BIND_SLOT);
|
||||
m_program->bind_uniform({ m_uniform_buffer->value, fragment_constants_offset, fragment_constants_sz }, FRAGMENT_CONSTANT_BUFFERS_BIND_SLOT);
|
||||
m_program->bind_uniform({ m_uniform_buffer->value, scale_offset_offset, 256 }, SCALE_OFFSET_BIND_SLOT, descriptor_sets);
|
||||
m_program->bind_uniform({ m_uniform_buffer->value, vertex_constants_offset, 512 * 4 * sizeof(float) }, VERTEX_CONSTANT_BUFFERS_BIND_SLOT, descriptor_sets);
|
||||
m_program->bind_uniform({ m_uniform_buffer->value, fragment_constants_offset, fragment_constants_sz }, FRAGMENT_CONSTANT_BUFFERS_BIND_SLOT, descriptor_sets);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -141,6 +141,10 @@ private:
|
||||
|
||||
|
||||
std::array<VkRenderPass, 120> m_render_passes;
|
||||
VkDescriptorSetLayout descriptor_layouts;
|
||||
VkDescriptorSet descriptor_sets;
|
||||
VkPipelineLayout pipeline_layout;
|
||||
vk::descriptor_pool descriptor_pool;
|
||||
|
||||
u32 m_draw_calls = 0;
|
||||
|
||||
|
@ -1347,10 +1347,6 @@ namespace vk
|
||||
VkShaderModule vs, fs;
|
||||
VkPipeline pipeline_handle = nullptr;
|
||||
|
||||
VkDescriptorSetLayout descriptor_layouts;
|
||||
VkDescriptorSet descriptor_sets;
|
||||
VkPipelineLayout pipeline_layout;
|
||||
|
||||
int num_targets = 1;
|
||||
|
||||
bool dirty;
|
||||
@ -1362,7 +1358,6 @@ namespace vk
|
||||
|
||||
vk::render_device *device = nullptr;
|
||||
std::vector<program_input> uniforms;
|
||||
vk::descriptor_pool descriptor_pool;
|
||||
|
||||
void init_pipeline();
|
||||
|
||||
@ -1395,14 +1390,11 @@ namespace vk
|
||||
void set_blend_op(int num_targets, u8 * targets, VkBlendOp color_op, VkBlendOp alpha_op);
|
||||
void set_primitive_restart(VkBool32 state);
|
||||
|
||||
void init_descriptor_layout();
|
||||
void destroy_descriptors();
|
||||
|
||||
void set_draw_buffer_count(u8 draw_buffers);
|
||||
|
||||
program& load_uniforms(program_domain domain, std::vector<program_input>& inputs);
|
||||
|
||||
void use(vk::command_buffer& commands, VkRenderPass pass, u32 subpass);
|
||||
void use(vk::command_buffer& commands, VkRenderPass pass, VkPipelineLayout pipeline_layout, VkDescriptorSet descriptor_set);
|
||||
|
||||
bool has_uniform(std::string uniform_name);
|
||||
#define VERTEX_BUFFERS_FIRST_BIND_SLOT 3
|
||||
@ -1410,9 +1402,9 @@ namespace vk
|
||||
#define VERTEX_CONSTANT_BUFFERS_BIND_SLOT 1
|
||||
#define TEXTURES_FIRST_BIND_SLOT 19
|
||||
#define SCALE_OFFSET_BIND_SLOT 0
|
||||
void bind_uniform(VkDescriptorImageInfo image_descriptor, std::string uniform_name);
|
||||
void bind_uniform(VkDescriptorBufferInfo buffer_descriptor, uint32_t binding_point);
|
||||
void bind_uniform(const VkBufferView &buffer_view, const std::string &binding_name);
|
||||
void bind_uniform(VkDescriptorImageInfo image_descriptor, std::string uniform_name, VkDescriptorSet &descriptor_set);
|
||||
void bind_uniform(VkDescriptorBufferInfo buffer_descriptor, uint32_t binding_point, VkDescriptorSet &descriptor_set);
|
||||
void bind_uniform(const VkBufferView &buffer_view, const std::string &binding_name, VkDescriptorSet &descriptor_set);
|
||||
|
||||
program& operator = (const program&) = delete;
|
||||
program& operator = (program&& other);
|
||||
|
@ -31,10 +31,6 @@ namespace vk
|
||||
uniforms = other.uniforms;
|
||||
other.uniforms = tmp_uniforms;
|
||||
|
||||
vk::descriptor_pool tmp_pool;
|
||||
descriptor_pool = other.descriptor_pool;
|
||||
other.descriptor_pool = tmp_pool;
|
||||
|
||||
vk::render_device *tmp_dev = device;
|
||||
device = other.device;
|
||||
other.device = tmp_dev;
|
||||
@ -55,10 +51,6 @@ namespace vk
|
||||
uniforms = other.uniforms;
|
||||
other.uniforms = tmp_uniforms;
|
||||
|
||||
vk::descriptor_pool tmp_pool;
|
||||
descriptor_pool = other.descriptor_pool;
|
||||
other.descriptor_pool = tmp_pool;
|
||||
|
||||
vk::render_device *tmp_dev = device;
|
||||
device = other.device;
|
||||
other.device = tmp_dev;
|
||||
@ -382,108 +374,6 @@ namespace vk
|
||||
}
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
std::tuple<VkPipelineLayout, VkDescriptorSetLayout> get_shared_pipeline_layout(VkDevice dev)
|
||||
{
|
||||
std::array<VkDescriptorSetLayoutBinding, 35> bindings = {};
|
||||
|
||||
size_t idx = 0;
|
||||
// Vertex buffer
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
bindings[idx].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER;
|
||||
bindings[idx].descriptorCount = 1;
|
||||
bindings[idx].stageFlags = VK_SHADER_STAGE_VERTEX_BIT;
|
||||
bindings[idx].binding = VERTEX_BUFFERS_FIRST_BIND_SLOT + i;
|
||||
idx++;
|
||||
}
|
||||
|
||||
bindings[idx].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
|
||||
bindings[idx].descriptorCount = 1;
|
||||
bindings[idx].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT;
|
||||
bindings[idx].binding = FRAGMENT_CONSTANT_BUFFERS_BIND_SLOT;
|
||||
|
||||
idx++;
|
||||
|
||||
bindings[idx].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
|
||||
bindings[idx].descriptorCount = 1;
|
||||
bindings[idx].stageFlags = VK_SHADER_STAGE_VERTEX_BIT;
|
||||
bindings[idx].binding = VERTEX_CONSTANT_BUFFERS_BIND_SLOT;
|
||||
|
||||
idx++;
|
||||
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
bindings[idx].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
|
||||
bindings[idx].descriptorCount = 1;
|
||||
bindings[idx].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT;
|
||||
bindings[idx].binding = TEXTURES_FIRST_BIND_SLOT + i;
|
||||
idx++;
|
||||
}
|
||||
|
||||
bindings[idx].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
|
||||
bindings[idx].descriptorCount = 1;
|
||||
bindings[idx].stageFlags = VK_SHADER_STAGE_ALL_GRAPHICS;
|
||||
bindings[idx].binding = SCALE_OFFSET_BIND_SLOT;
|
||||
|
||||
VkDescriptorSetLayoutCreateInfo infos = {};
|
||||
infos.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
|
||||
infos.pBindings = bindings.data();
|
||||
infos.bindingCount = bindings.size();
|
||||
|
||||
VkDescriptorSetLayout set_layout;
|
||||
CHECK_RESULT(vkCreateDescriptorSetLayout(dev, &infos, nullptr, &set_layout));
|
||||
|
||||
VkPipelineLayoutCreateInfo layout_info = {};
|
||||
layout_info.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
|
||||
layout_info.setLayoutCount = 1;
|
||||
layout_info.pSetLayouts = &set_layout;
|
||||
|
||||
VkPipelineLayout result;
|
||||
CHECK_RESULT(vkCreatePipelineLayout(dev, &layout_info, nullptr, &result));
|
||||
return std::make_tuple(result, set_layout);
|
||||
}
|
||||
}
|
||||
|
||||
void program::init_descriptor_layout()
|
||||
{
|
||||
if (descriptor_pool.valid())
|
||||
descriptor_pool.destroy();
|
||||
|
||||
std::tie(pstate.pipeline_layout, pstate.descriptor_layouts) = get_shared_pipeline_layout(*device);
|
||||
|
||||
VkDescriptorPoolSize uniform_buffer_pool = { VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER , 3};
|
||||
VkDescriptorPoolSize uniform_texel_pool = { VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER , 16};
|
||||
VkDescriptorPoolSize texture_pool = { VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER , 16 };
|
||||
|
||||
std::vector<VkDescriptorPoolSize> sizes{ uniform_buffer_pool, uniform_texel_pool, texture_pool };
|
||||
|
||||
descriptor_pool.create((*device), sizes.data(), sizes.size());
|
||||
|
||||
VkDescriptorSetAllocateInfo alloc_info = {};
|
||||
alloc_info.descriptorPool = descriptor_pool;
|
||||
alloc_info.descriptorSetCount = 1;
|
||||
alloc_info.pSetLayouts = &pstate.descriptor_layouts;
|
||||
alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO;
|
||||
|
||||
CHECK_RESULT(vkAllocateDescriptorSets((*device), &alloc_info, &pstate.descriptor_sets));
|
||||
}
|
||||
|
||||
void program::destroy_descriptors()
|
||||
{
|
||||
if (pstate.descriptor_sets)
|
||||
vkFreeDescriptorSets((*device), descriptor_pool, 1, &pstate.descriptor_sets);
|
||||
|
||||
if (pstate.pipeline_layout)
|
||||
vkDestroyPipelineLayout((*device), pstate.pipeline_layout, nullptr);
|
||||
|
||||
if (pstate.descriptor_layouts)
|
||||
vkDestroyDescriptorSetLayout((*device), pstate.descriptor_layouts, nullptr);
|
||||
|
||||
descriptor_pool.destroy();
|
||||
}
|
||||
|
||||
void program::set_draw_buffer_count(u8 draw_buffers)
|
||||
{
|
||||
if (pstate.num_targets != draw_buffers)
|
||||
@ -509,7 +399,7 @@ namespace vk
|
||||
return *this;
|
||||
}
|
||||
|
||||
void program::use(vk::command_buffer& commands, VkRenderPass pass, u32 subpass)
|
||||
void program::use(vk::command_buffer& commands, VkRenderPass pass, VkPipelineLayout pipeline_layout, VkDescriptorSet descriptor_set)
|
||||
{
|
||||
if (/*uniforms_changed*/true)
|
||||
{
|
||||
@ -535,7 +425,7 @@ namespace vk
|
||||
pstate.pipeline.pDepthStencilState = &pstate.ds;
|
||||
pstate.pipeline.pStages = pstate.shader_stages;
|
||||
pstate.pipeline.pDynamicState = &pstate.dynamic_state;
|
||||
pstate.pipeline.layout = pstate.pipeline_layout;
|
||||
pstate.pipeline.layout = pipeline_layout;
|
||||
pstate.pipeline.basePipelineIndex = -1;
|
||||
pstate.pipeline.basePipelineHandle = VK_NULL_HANDLE;
|
||||
|
||||
@ -546,7 +436,7 @@ namespace vk
|
||||
}
|
||||
|
||||
vkCmdBindPipeline(commands, VK_PIPELINE_BIND_POINT_GRAPHICS, pstate.pipeline_handle);
|
||||
vkCmdBindDescriptorSets(commands, VK_PIPELINE_BIND_POINT_GRAPHICS, pstate.pipeline_layout, 0, 1, &pstate.descriptor_sets, 0, nullptr);
|
||||
vkCmdBindDescriptorSets(commands, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, 1, &descriptor_set, 0, nullptr);
|
||||
}
|
||||
|
||||
bool program::has_uniform(std::string uniform_name)
|
||||
@ -560,17 +450,15 @@ namespace vk
|
||||
return false;
|
||||
}
|
||||
|
||||
void program::bind_uniform(VkDescriptorImageInfo image_descriptor, std::string uniform_name)
|
||||
void program::bind_uniform(VkDescriptorImageInfo image_descriptor, std::string uniform_name, VkDescriptorSet &descriptor_set)
|
||||
{
|
||||
if (!pstate.descriptor_layouts)
|
||||
init_descriptor_layout();
|
||||
for (auto &uniform : uniforms)
|
||||
{
|
||||
if (uniform.name == uniform_name)
|
||||
{
|
||||
VkWriteDescriptorSet descriptor_writer = {};
|
||||
descriptor_writer.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
|
||||
descriptor_writer.dstSet = pstate.descriptor_sets;
|
||||
descriptor_writer.dstSet = descriptor_set;
|
||||
descriptor_writer.descriptorCount = 1;
|
||||
descriptor_writer.pImageInfo = &image_descriptor;
|
||||
descriptor_writer.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
|
||||
@ -585,13 +473,11 @@ namespace vk
|
||||
throw EXCEPTION("texture not found");
|
||||
}
|
||||
|
||||
void program::bind_uniform(VkDescriptorBufferInfo buffer_descriptor, uint32_t binding_point)
|
||||
void program::bind_uniform(VkDescriptorBufferInfo buffer_descriptor, uint32_t binding_point, VkDescriptorSet &descriptor_set)
|
||||
{
|
||||
if (!pstate.descriptor_layouts)
|
||||
init_descriptor_layout();
|
||||
VkWriteDescriptorSet descriptor_writer = {};
|
||||
descriptor_writer.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
|
||||
descriptor_writer.dstSet = pstate.descriptor_sets;
|
||||
descriptor_writer.dstSet = descriptor_set;
|
||||
descriptor_writer.descriptorCount = 1;
|
||||
descriptor_writer.pBufferInfo = &buffer_descriptor;
|
||||
descriptor_writer.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
|
||||
@ -601,18 +487,15 @@ namespace vk
|
||||
vkUpdateDescriptorSets((*device), 1, &descriptor_writer, 0, nullptr);
|
||||
}
|
||||
|
||||
void program::bind_uniform(const VkBufferView &buffer_view, const std::string &binding_name)
|
||||
void program::bind_uniform(const VkBufferView &buffer_view, const std::string &binding_name, VkDescriptorSet &descriptor_set)
|
||||
{
|
||||
if (!pstate.descriptor_layouts)
|
||||
init_descriptor_layout();
|
||||
|
||||
for (auto &uniform : uniforms)
|
||||
{
|
||||
if (uniform.name == binding_name)
|
||||
{
|
||||
VkWriteDescriptorSet descriptor_writer = {};
|
||||
descriptor_writer.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
|
||||
descriptor_writer.dstSet = pstate.descriptor_sets;
|
||||
descriptor_writer.dstSet = descriptor_set;
|
||||
descriptor_writer.descriptorCount = 1;
|
||||
descriptor_writer.pTexelBufferView = &buffer_view;
|
||||
descriptor_writer.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER;
|
||||
@ -630,7 +513,6 @@ namespace vk
|
||||
{
|
||||
if (device)
|
||||
{
|
||||
destroy_descriptors();
|
||||
uniforms.resize(0);
|
||||
|
||||
if (pstate.pipeline_handle)
|
||||
|
@ -333,7 +333,7 @@ VKGSRender::upload_vertex_data()
|
||||
buffer.set_format(format);
|
||||
|
||||
//Link texture to uniform location
|
||||
m_program->bind_uniform(buffer, reg_table[index]);
|
||||
m_program->bind_uniform(buffer, reg_table[index], descriptor_sets);
|
||||
}
|
||||
}
|
||||
|
||||
@ -421,7 +421,7 @@ VKGSRender::upload_vertex_data()
|
||||
|
||||
buffer.sub_data(0, data_size, data_ptr);
|
||||
buffer.set_format(format);
|
||||
m_program->bind_uniform(buffer, reg_table[index]);
|
||||
m_program->bind_uniform(buffer, reg_table[index], descriptor_sets);
|
||||
}
|
||||
else if (register_vertex_info[index].size > 0)
|
||||
{
|
||||
@ -460,7 +460,7 @@ VKGSRender::upload_vertex_data()
|
||||
buffer.sub_data(0, data_size, data_ptr);
|
||||
buffer.set_format(format);
|
||||
|
||||
m_program->bind_uniform(buffer, reg_table[index]);
|
||||
m_program->bind_uniform(buffer, reg_table[index], descriptor_sets);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
Loading…
Reference in New Issue
Block a user