mirror of https://github.com/auygun/kaliber.git
Vulkan: Fix for activate-texture
This commit is contained in:
parent
06e42ead57
commit
4cc2c03afe
|
@ -564,8 +564,19 @@ void RendererVulkan::ActivateTexture(uint64_t resource_id) {
|
||||||
if (it == textures_.end())
|
if (it == textures_.end())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Keep as pending and bind later in ActivateShader.
|
if (active_descriptor_sets_[/*TODO*/ 0] != std::get<0>(it->second.desc_set)) {
|
||||||
pending_descriptor_sets_[/*TODO*/ 0] = std::get<0>(it->second.desc_set);
|
active_descriptor_sets_[/*TODO*/ 0] = std::get<0>(it->second.desc_set);
|
||||||
|
if (active_shader_id_ != 0) {
|
||||||
|
auto active_shader = shaders_.find(active_shader_id_);
|
||||||
|
if (active_shader != shaders_.end() &&
|
||||||
|
active_shader->second.desc_set_count > 0) {
|
||||||
|
vkCmdBindDescriptorSets(frames_[current_frame_].draw_command_buffer,
|
||||||
|
VK_PIPELINE_BIND_POINT_GRAPHICS,
|
||||||
|
active_shader->second.pipeline_layout, 0, 1,
|
||||||
|
&active_descriptor_sets_[0], 0, nullptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t RendererVulkan::CreateShader(
|
uint64_t RendererVulkan::CreateShader(
|
||||||
|
@ -773,19 +784,16 @@ void RendererVulkan::ActivateShader(uint64_t resource_id) {
|
||||||
if (it == shaders_.end())
|
if (it == shaders_.end())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (active_pipeline_ != it->second.pipeline) {
|
if (active_shader_id_ != resource_id) {
|
||||||
active_pipeline_ = it->second.pipeline;
|
active_shader_id_ = resource_id;
|
||||||
vkCmdBindPipeline(frames_[current_frame_].draw_command_buffer,
|
vkCmdBindPipeline(frames_[current_frame_].draw_command_buffer,
|
||||||
VK_PIPELINE_BIND_POINT_GRAPHICS, it->second.pipeline);
|
VK_PIPELINE_BIND_POINT_GRAPHICS, it->second.pipeline);
|
||||||
}
|
if (it->second.desc_set_count > 0 &&
|
||||||
for (size_t i = 0; i < it->second.desc_set_count; ++i) {
|
active_descriptor_sets_[/*TODO*/ 0] != VK_NULL_HANDLE) {
|
||||||
if (active_descriptor_sets_[i] != pending_descriptor_sets_[i]) {
|
|
||||||
active_descriptor_sets_[i] = pending_descriptor_sets_[i];
|
|
||||||
vkCmdBindDescriptorSets(frames_[current_frame_].draw_command_buffer,
|
vkCmdBindDescriptorSets(frames_[current_frame_].draw_command_buffer,
|
||||||
VK_PIPELINE_BIND_POINT_GRAPHICS,
|
VK_PIPELINE_BIND_POINT_GRAPHICS,
|
||||||
it->second.pipeline_layout, 0, 1,
|
it->second.pipeline_layout, 0, 1,
|
||||||
&active_descriptor_sets_[i], 0, nullptr);
|
&active_descriptor_sets_[0], 0, nullptr);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1832,10 +1840,8 @@ bool RendererVulkan::CreatePipelineLayout(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (active_descriptor_sets_.size() < shader.desc_set_count) {
|
if (active_descriptor_sets_.size() < shader.desc_set_count)
|
||||||
active_descriptor_sets_.resize(shader.desc_set_count);
|
active_descriptor_sets_.resize(shader.desc_set_count);
|
||||||
pending_descriptor_sets_.resize(shader.desc_set_count);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parse push constants.
|
// Parse push constants.
|
||||||
auto enumerate_pc = [&](SpvReflectShaderModule& module, uint32_t& pc_count,
|
auto enumerate_pc = [&](SpvReflectShaderModule& module, uint32_t& pc_count,
|
||||||
|
@ -2047,11 +2053,9 @@ void RendererVulkan::SwapBuffers() {
|
||||||
context_.SwapBuffers();
|
context_.SwapBuffers();
|
||||||
current_frame_ = (current_frame_ + 1) % frames_.size();
|
current_frame_ = (current_frame_ + 1) % frames_.size();
|
||||||
|
|
||||||
active_pipeline_ = VK_NULL_HANDLE;
|
active_shader_id_ = 0;
|
||||||
for (auto& ds : active_descriptor_sets_)
|
for (auto& ds : active_descriptor_sets_)
|
||||||
ds = VK_NULL_HANDLE;
|
ds = VK_NULL_HANDLE;
|
||||||
for (auto& ds : pending_descriptor_sets_)
|
|
||||||
ds = VK_NULL_HANDLE;
|
|
||||||
|
|
||||||
BeginFrame();
|
BeginFrame();
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,12 +179,11 @@ class RendererVulkan final : public Renderer {
|
||||||
uint64_t max_staging_buffer_size_ = 16 * 1024 * 1024;
|
uint64_t max_staging_buffer_size_ = 16 * 1024 * 1024;
|
||||||
bool staging_buffer_used_ = false;
|
bool staging_buffer_used_ = false;
|
||||||
|
|
||||||
VkPipeline active_pipeline_ = VK_NULL_HANDLE;
|
uint64_t active_shader_id_ = 0;
|
||||||
|
|
||||||
std::vector<std::unique_ptr<DescPool>> desc_pools_;
|
std::vector<std::unique_ptr<DescPool>> desc_pools_;
|
||||||
VkDescriptorSetLayout descriptor_set_layout_ = VK_NULL_HANDLE;
|
VkDescriptorSetLayout descriptor_set_layout_ = VK_NULL_HANDLE;
|
||||||
std::vector<VkDescriptorSet> active_descriptor_sets_;
|
std::vector<VkDescriptorSet> active_descriptor_sets_;
|
||||||
std::vector<VkDescriptorSet> pending_descriptor_sets_;
|
|
||||||
|
|
||||||
VkSampler sampler_ = VK_NULL_HANDLE;
|
VkSampler sampler_ = VK_NULL_HANDLE;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue