Fixed crash if no textures were loaded

This commit is contained in:
Kah Wei 2022-09-27 14:11:56 +08:00
parent e9496bead6
commit 65c67c14b7
2 changed files with 27 additions and 20 deletions

View File

@ -259,16 +259,20 @@ namespace SHADE
currentCmdBuffer->BindIndexBuffer(buffer, 0);
}
std::array<uint32_t, 1> texDynamicOffset {0};
// Bind textures
auto textureDescSet = texLibrary.GetTextureDescriptorSetGroup();
if (textureDescSet)
{
std::array<uint32_t, 1> texDynamicOffset {0};
currentCmdBuffer->BindDescriptorSet
(
texLibrary.GetTextureDescriptorSetGroup(),
textureDescSet,
vk::PipelineBindPoint::eGraphics,
0,
std::span<uint32_t, 1>{texDynamicOffset.data(), texDynamicOffset.size()}
);
}
// bind camera data
renderers[renIndex]->UpdateDataAndBind(currentCmdBuffer, frameIndex);

View File

@ -168,7 +168,9 @@ namespace SHADE
}
addJobs.clear();
/* Build Descriptor Set with all the Textures */
/* Build Descriptor Set with all the Textures only if there are textures */
if (!texOrder.empty())
{
if (!texDescriptors)
{
texDescriptors = descPool->Allocate({ descLayout }, { static_cast<uint32_t>(texOrder.size()) });
@ -185,6 +187,7 @@ namespace SHADE
SHGraphicsConstants::DescriptorSetIndex::STATIC_GLOBALS,
SHGraphicsConstants::DescriptorSetBindings::IMAGE_AND_SAMPLERS_DATA
);
}
isDirty = false;
}