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())
|
||||
return;
|
||||
|
||||
// Keep as pending and bind later in ActivateShader.
|
||||
pending_descriptor_sets_[/*TODO*/ 0] = std::get<0>(it->second.desc_set);
|
||||
if (active_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(
|
||||
|
@ -773,19 +784,16 @@ void RendererVulkan::ActivateShader(uint64_t resource_id) {
|
|||
if (it == shaders_.end())
|
||||
return;
|
||||
|
||||
if (active_pipeline_ != it->second.pipeline) {
|
||||
active_pipeline_ = it->second.pipeline;
|
||||
if (active_shader_id_ != resource_id) {
|
||||
active_shader_id_ = resource_id;
|
||||
vkCmdBindPipeline(frames_[current_frame_].draw_command_buffer,
|
||||
VK_PIPELINE_BIND_POINT_GRAPHICS, it->second.pipeline);
|
||||
}
|
||||
for (size_t i = 0; i < it->second.desc_set_count; ++i) {
|
||||
if (active_descriptor_sets_[i] != pending_descriptor_sets_[i]) {
|
||||
active_descriptor_sets_[i] = pending_descriptor_sets_[i];
|
||||
if (it->second.desc_set_count > 0 &&
|
||||
active_descriptor_sets_[/*TODO*/ 0] != VK_NULL_HANDLE) {
|
||||
vkCmdBindDescriptorSets(frames_[current_frame_].draw_command_buffer,
|
||||
VK_PIPELINE_BIND_POINT_GRAPHICS,
|
||||
it->second.pipeline_layout, 0, 1,
|
||||
&active_descriptor_sets_[i], 0, nullptr);
|
||||
break;
|
||||
&active_descriptor_sets_[0], 0, nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
pending_descriptor_sets_.resize(shader.desc_set_count);
|
||||
}
|
||||
|
||||
// Parse push constants.
|
||||
auto enumerate_pc = [&](SpvReflectShaderModule& module, uint32_t& pc_count,
|
||||
|
@ -2047,11 +2053,9 @@ void RendererVulkan::SwapBuffers() {
|
|||
context_.SwapBuffers();
|
||||
current_frame_ = (current_frame_ + 1) % frames_.size();
|
||||
|
||||
active_pipeline_ = VK_NULL_HANDLE;
|
||||
active_shader_id_ = 0;
|
||||
for (auto& ds : active_descriptor_sets_)
|
||||
ds = VK_NULL_HANDLE;
|
||||
for (auto& ds : pending_descriptor_sets_)
|
||||
ds = VK_NULL_HANDLE;
|
||||
|
||||
BeginFrame();
|
||||
}
|
||||
|
|
|
@ -179,12 +179,11 @@ class RendererVulkan final : public Renderer {
|
|||
uint64_t max_staging_buffer_size_ = 16 * 1024 * 1024;
|
||||
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_;
|
||||
VkDescriptorSetLayout descriptor_set_layout_ = VK_NULL_HANDLE;
|
||||
std::vector<VkDescriptorSet> active_descriptor_sets_;
|
||||
std::vector<VkDescriptorSet> pending_descriptor_sets_;
|
||||
|
||||
VkSampler sampler_ = VK_NULL_HANDLE;
|
||||
|
||||
|
|
Loading…
Reference in New Issue