vk_graphics_pipeline: Fix texture buffer descriptors

This commit is contained in:
ReinUsesLisp 2021-05-01 00:29:31 -03:00 committed by ameerj
parent fb14820c86
commit f4b82b8dd7
1 changed files with 8 additions and 7 deletions

View File

@ -253,6 +253,7 @@ void GraphicsPipeline::ConfigureImpl(bool is_indexed) {
std::array<ImageId, MAX_IMAGE_ELEMENTS> image_view_ids; std::array<ImageId, MAX_IMAGE_ELEMENTS> image_view_ids;
std::array<u32, MAX_IMAGE_ELEMENTS> image_view_indices; std::array<u32, MAX_IMAGE_ELEMENTS> image_view_indices;
std::array<VkSampler, MAX_IMAGE_ELEMENTS> samplers; std::array<VkSampler, MAX_IMAGE_ELEMENTS> samplers;
size_t sampler_index{};
size_t image_index{}; size_t image_index{};
texture_cache.SynchronizeGraphicsDescriptors(); texture_cache.SynchronizeGraphicsDescriptors();
@ -312,11 +313,10 @@ void GraphicsPipeline::ConfigureImpl(bool is_indexed) {
for (const auto& desc : info.texture_descriptors) { for (const auto& desc : info.texture_descriptors) {
for (u32 index = 0; index < desc.count; ++index) { for (u32 index = 0; index < desc.count; ++index) {
const TextureHandle handle{read_handle(desc, index)}; const TextureHandle handle{read_handle(desc, index)};
image_view_indices[image_index] = handle.image; image_view_indices[image_index++] = handle.image;
Sampler* const sampler{texture_cache.GetGraphicsSampler(handle.sampler)}; Sampler* const sampler{texture_cache.GetGraphicsSampler(handle.sampler)};
samplers[image_index] = sampler->Handle(); samplers[sampler_index++] = sampler->Handle();
++image_index;
} }
} }
if constexpr (Spec::has_images) { if constexpr (Spec::has_images) {
@ -360,10 +360,9 @@ void GraphicsPipeline::ConfigureImpl(bool is_indexed) {
++texture_buffer_index; ++texture_buffer_index;
} }
}}; }};
const Shader::Info& info{stage_infos[stage]};
if constexpr (Spec::has_texture_buffers || Spec::has_image_buffers) {
buffer_cache.UnbindGraphicsTextureBuffers(stage); buffer_cache.UnbindGraphicsTextureBuffers(stage);
}
const Shader::Info& info{stage_infos[stage]};
if constexpr (Spec::has_texture_buffers) { if constexpr (Spec::has_texture_buffers) {
for (const auto& desc : info.texture_buffer_descriptors) { for (const auto& desc : info.texture_buffer_descriptors) {
add_buffer(desc); add_buffer(desc);
@ -443,7 +442,9 @@ void GraphicsPipeline::ConfigureDraw() {
const bool bind_pipeline{scheduler.UpdateGraphicsPipeline(this)}; const bool bind_pipeline{scheduler.UpdateGraphicsPipeline(this)};
const void* const descriptor_data{update_descriptor_queue.UpdateData()}; const void* const descriptor_data{update_descriptor_queue.UpdateData()};
scheduler.Record([this, descriptor_data, bind_pipeline](vk::CommandBuffer cmdbuf) { scheduler.Record([this, descriptor_data, bind_pipeline](vk::CommandBuffer cmdbuf) {
if (bind_pipeline) {
cmdbuf.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, *pipeline); cmdbuf.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, *pipeline);
}
if (!descriptor_set_layout) { if (!descriptor_set_layout) {
return; return;
} }