Hi! I’m facing to a crash I really don’t undestand, everything works fine in debug mode, but once I compile in release mode, it crash. No validation error messages in debug mode, nothing.
Here is the stack trace : (It seems it crash in the thread where I update the descriptor sets, and I don’t use the descriptor sets in several threads at the same time, I first allocate the sets and then I launch the renderer thread)
#0 0x7ffb2573fd45 vkGetInstanceProcAddr() (C:\Windows\System32\DriverStore\FileRepository\nvmdi.inf_amd64_f088ae99b5a2f5fd\nvoglv64.dll:??)
#1 0x7ffb2573f8b9 vkGetInstanceProcAddr() (C:\Windows\System32\DriverStore\FileRepository\nvmdi.inf_amd64_f088ae99b5a2f5fd\nvoglv64.dll:??)
#2 0x7ffb256b1038 vkGetInstanceProcAddr() (C:\Windows\System32\DriverStore\FileRepository\nvmdi.inf_amd64_f088ae99b5a2f5fd\nvoglv64.dll:??)
#3 0x7ff717997bf2 ?? () (??:??)
#4 0x7ff7179ae085 ?? () (??:??)
#5 0x7ff7179bfa2a ?? () (??:??)
#6 0x7ff717bce0ae ?? () (??:??)
#7 0x7ff717bd10f8 ?? () (??:??)
#8 0x7ff7179fbab5 ?? () (??:??)
#9 0x7ff717bbe3ee ?? () (??:??)
#10 0x7ff717c08170 ?? () (??:??)
#11 0x7ff717961340 ?? () (??:??)
#12 0x7ff717961146 ?? () (??:??)
#13 0x7ffb9c977374 KERNEL32!BaseThreadInitThunk() (C:\Windows\System32\kernel32.dll:??)
#14 0x7ffb9d5bcc91 ntdll!RtlUserThreadStart() (C:\Windows\SYSTEM32\ntdll.dll:??)
#15 ?? ?? () (??:??)
Here is where I create the descriptor pool, descriptor set layouts and allocate/update descriptor sets :
}
void LightRenderComponent::createDescriptorPool(unsigned int p, RenderStates states) {
Shader* shader = const_cast<Shader*>(states.shader);
if (shader == &depthBufferGenerator) {
{
std::vector<VkDescriptorPool>& descriptorPool = depthBuffer.getDescriptorPool();
if (shader->getNbShaders() * (Batcher::nbPrimitiveTypes - 1) > descriptorPool.size())
descriptorPool.resize(shader->getNbShaders() * (Batcher::nbPrimitiveTypes - 1));
unsigned int descriptorId = p * shader->getNbShaders() + shader->getId();
std::array<VkDescriptorPoolSize, 4> poolSizes;
std::vector<Texture*> allTextures = Texture::getAllTextures();
poolSizes[0].type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC;
poolSizes[0].descriptorCount = static_cast<uint32_t>(depthBuffer.getMaxFramesInFlight());
poolSizes[1].type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC;
poolSizes[1].descriptorCount = static_cast<uint32_t>(depthBuffer.getMaxFramesInFlight());
poolSizes[2].type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
poolSizes[2].descriptorCount = static_cast<uint32_t>(depthBuffer.getMaxFramesInFlight() * MAX_TEXTURES);
poolSizes[3].type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE;
poolSizes[3].descriptorCount = static_cast<uint32_t>(depthBuffer.getMaxFramesInFlight());
if (descriptorPool[descriptorId] != nullptr) {
vkDestroyDescriptorPool(vkDevice.getDevice(), descriptorPool[descriptorId], nullptr);
}
VkDescriptorPoolCreateInfo poolInfo{};
poolInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
poolInfo.poolSizeCount = static_cast<uint32_t>(poolSizes.size());
poolInfo.pPoolSizes = poolSizes.data();
poolInfo.maxSets = static_cast<uint32_t>(depthBuffer.getMaxFramesInFlight());
if (vkCreateDescriptorPool(vkDevice.getDevice(), &poolInfo, nullptr, &descriptorPool[descriptorId]) != VK_SUCCESS) {
throw std::runtime_error("echec de la creation de la pool de descripteurs!");
}
}
{
std::vector<VkDescriptorPool>& descriptorPool = lightDepthBuffer.getDescriptorPool();
if (shader->getNbShaders() * (Batcher::nbPrimitiveTypes - 1) > descriptorPool.size())
descriptorPool.resize(shader->getNbShaders() * (Batcher::nbPrimitiveTypes - 1));
unsigned int descriptorId = p * shader->getNbShaders() + shader->getId();
std::array<VkDescriptorPoolSize, 4> poolSizes;
std::vector<Texture*> allTextures = Texture::getAllTextures();
poolSizes[0].type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC;
poolSizes[0].descriptorCount = static_cast<uint32_t>(depthBuffer.getMaxFramesInFlight());
poolSizes[1].type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC;
poolSizes[1].descriptorCount = static_cast<uint32_t>(depthBuffer.getMaxFramesInFlight());
poolSizes[2].type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
poolSizes[2].descriptorCount = static_cast<uint32_t>(depthBuffer.getMaxFramesInFlight() * MAX_TEXTURES);
poolSizes[3].type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE;
poolSizes[3].descriptorCount = static_cast<uint32_t>(depthBuffer.getMaxFramesInFlight());
if (descriptorPool[descriptorId] != nullptr) {
vkDestroyDescriptorPool(vkDevice.getDevice(), descriptorPool[descriptorId], nullptr);
}
VkDescriptorPoolCreateInfo poolInfo{};
poolInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
poolInfo.poolSizeCount = static_cast<uint32_t>(poolSizes.size());
poolInfo.pPoolSizes = poolSizes.data();
poolInfo.maxSets = static_cast<uint32_t>(depthBuffer.getMaxFramesInFlight());
if (vkCreateDescriptorPool(vkDevice.getDevice(), &poolInfo, nullptr, &descriptorPool[descriptorId]) != VK_SUCCESS) {
throw std::runtime_error("echec de la creation de la pool de descripteurs!");
}
}
void LightRenderComponent::createDescriptorSetLayout(RenderStates states) {
Shader* shader = const_cast<Shader*>(states.shader);
if (shader == &depthBufferGenerator) {
{
std::vector<VkDescriptorSetLayout>& descriptorSetLayout = depthBuffer.getDescriptorSetLayout();
if (shader->getNbShaders() * (Batcher::nbPrimitiveTypes - 1) > descriptorSetLayout.size())
descriptorSetLayout.resize(shader->getNbShaders() * (Batcher::nbPrimitiveTypes - 1));
unsigned int descriptorId = shader->getId();
std::vector<Texture*> allTextures = Texture::getAllTextures();
VkDescriptorSetLayoutBinding modelDataLayoutBinding{};
modelDataLayoutBinding.binding = 0;
modelDataLayoutBinding.descriptorCount = 1;
modelDataLayoutBinding.descriptorType = (useThread) ? VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC : VK_DESCRIPTOR_TYPE_STORAGE_BUFFER;
modelDataLayoutBinding.pImmutableSamplers = nullptr;
modelDataLayoutBinding.stageFlags = VK_SHADER_STAGE_VERTEX_BIT;
VkDescriptorSetLayoutBinding materialDataLayoutBinding{};
materialDataLayoutBinding.binding = 1;
materialDataLayoutBinding.descriptorCount = 1;
materialDataLayoutBinding.descriptorType = (useThread) ? VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC : VK_DESCRIPTOR_TYPE_STORAGE_BUFFER;
materialDataLayoutBinding.pImmutableSamplers = nullptr;
materialDataLayoutBinding.stageFlags = VK_SHADER_STAGE_VERTEX_BIT;
VkDescriptorSetLayoutBinding headPtrImageLayoutBinding;
headPtrImageLayoutBinding.binding = 2;
headPtrImageLayoutBinding.descriptorCount = 1;
headPtrImageLayoutBinding.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE;
headPtrImageLayoutBinding.pImmutableSamplers = nullptr;
headPtrImageLayoutBinding.stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT;
VkDescriptorSetLayoutBinding samplerLayoutBinding{};
samplerLayoutBinding.binding = 3;
samplerLayoutBinding.descriptorCount = MAX_TEXTURES;
samplerLayoutBinding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
samplerLayoutBinding.pImmutableSamplers = nullptr;
samplerLayoutBinding.stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT;
std::vector<VkDescriptorBindingFlags> bindingFlags(4, 0); // 6 bindings, flags par défaut à 0
bindingFlags[3] = VK_DESCRIPTOR_BINDING_VARIABLE_DESCRIPTOR_COUNT_BIT |
VK_DESCRIPTOR_BINDING_PARTIALLY_BOUND_BIT;
VkDescriptorSetLayoutBindingFlagsCreateInfo bindingFlagsInfo{};
bindingFlagsInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_BINDING_FLAGS_CREATE_INFO;
bindingFlagsInfo.bindingCount = static_cast<uint32_t>(bindingFlags.size());
bindingFlagsInfo.pBindingFlags = bindingFlags.data();
std::array<VkDescriptorSetLayoutBinding, 4> bindings = {modelDataLayoutBinding, materialDataLayoutBinding, headPtrImageLayoutBinding, samplerLayoutBinding};
if (descriptorSetLayout[descriptorId] != nullptr) {
vkDestroyDescriptorSetLayout(vkDevice.getDevice(), descriptorSetLayout[descriptorId], nullptr);
}
VkDescriptorSetLayoutCreateInfo layoutInfo{};
layoutInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
layoutInfo.pNext = &bindingFlagsInfo;
//layoutInfo.flags = VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR;
layoutInfo.bindingCount = static_cast<uint32_t>(bindings.size());;
layoutInfo.pBindings = bindings.data();
if (vkCreateDescriptorSetLayout(vkDevice.getDevice(), &layoutInfo, nullptr, &descriptorSetLayout[descriptorId]) != VK_SUCCESS) {
throw std::runtime_error("failed to create descriptor set layout!");
}
}
{
std::vector<VkDescriptorSetLayout>& descriptorSetLayout = lightDepthBuffer.getDescriptorSetLayout();
if (shader->getNbShaders() * (Batcher::nbPrimitiveTypes - 1) > descriptorSetLayout.size())
descriptorSetLayout.resize(shader->getNbShaders() * (Batcher::nbPrimitiveTypes - 1));
unsigned int descriptorId = shader->getId();
std::vector<Texture*> allTextures = Texture::getAllTextures();
VkDescriptorSetLayoutBinding modelDataLayoutBinding{};
modelDataLayoutBinding.binding = 0;
modelDataLayoutBinding.descriptorCount = 1;
modelDataLayoutBinding.descriptorType = (useThread) ? VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC : VK_DESCRIPTOR_TYPE_STORAGE_BUFFER;
modelDataLayoutBinding.pImmutableSamplers = nullptr;
modelDataLayoutBinding.stageFlags = VK_SHADER_STAGE_VERTEX_BIT;
VkDescriptorSetLayoutBinding materialDataLayoutBinding{};
materialDataLayoutBinding.binding = 1;
materialDataLayoutBinding.descriptorCount = 1;
materialDataLayoutBinding.descriptorType = (useThread) ? VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC : VK_DESCRIPTOR_TYPE_STORAGE_BUFFER;
materialDataLayoutBinding.pImmutableSamplers = nullptr;
materialDataLayoutBinding.stageFlags = VK_SHADER_STAGE_VERTEX_BIT;
VkDescriptorSetLayoutBinding headPtrImageLayoutBinding;
headPtrImageLayoutBinding.binding = 2;
headPtrImageLayoutBinding.descriptorCount = 1;
headPtrImageLayoutBinding.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE;
headPtrImageLayoutBinding.pImmutableSamplers = nullptr;
headPtrImageLayoutBinding.stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT;
VkDescriptorSetLayoutBinding samplerLayoutBinding{};
samplerLayoutBinding.binding = 3;
samplerLayoutBinding.descriptorCount = MAX_TEXTURES;
samplerLayoutBinding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
samplerLayoutBinding.pImmutableSamplers = nullptr;
samplerLayoutBinding.stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT;
std::vector<VkDescriptorBindingFlags> bindingFlags(4, 0); // 6 bindings, flags par défaut à 0
bindingFlags[3] = VK_DESCRIPTOR_BINDING_VARIABLE_DESCRIPTOR_COUNT_BIT |
VK_DESCRIPTOR_BINDING_PARTIALLY_BOUND_BIT;
VkDescriptorSetLayoutBindingFlagsCreateInfo bindingFlagsInfo{};
bindingFlagsInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_BINDING_FLAGS_CREATE_INFO;
bindingFlagsInfo.bindingCount = static_cast<uint32_t>(bindingFlags.size());
bindingFlagsInfo.pBindingFlags = bindingFlags.data();
std::array<VkDescriptorSetLayoutBinding, 4> bindings = { modelDataLayoutBinding, materialDataLayoutBinding, headPtrImageLayoutBinding, samplerLayoutBinding};
if (descriptorSetLayout[descriptorId] != nullptr) {
vkDestroyDescriptorSetLayout(vkDevice.getDevice(), descriptorSetLayout[descriptorId], nullptr);
}
VkDescriptorSetLayoutCreateInfo layoutInfo{};
layoutInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
layoutInfo.pNext = &bindingFlagsInfo;
//layoutInfo.flags = VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR;
layoutInfo.bindingCount = static_cast<uint32_t>(bindings.size());;
layoutInfo.pBindings = bindings.data();
if (vkCreateDescriptorSetLayout(vkDevice.getDevice(), &layoutInfo, nullptr, &descriptorSetLayout[descriptorId]) != VK_SUCCESS) {
throw std::runtime_error("failed to create descriptor set layout!");
}
}
void LightRenderComponent::allocateDescriptorSets(unsigned int p, RenderStates states) {
Shader* shader = const_cast<Shader*>(states.shader);
if (shader == &depthBufferGenerator) {
{
std::vector<std::vector<VkDescriptorSet>>& descriptorSets = depthBuffer.getDescriptorSet();
std::vector<VkDescriptorPool>& descriptorPool = depthBuffer.getDescriptorPool();
std::vector<VkDescriptorSetLayout>& descriptorSetLayout = depthBuffer.getDescriptorSetLayout();
if (shader->getNbShaders() * (Batcher::nbPrimitiveTypes - 1) > descriptorSets.size())
descriptorSets.resize(shader->getNbShaders() * (Batcher::nbPrimitiveTypes - 1));
unsigned int descriptorId = p * shader->getNbShaders() + shader->getId();
for (unsigned int i = 0; i < descriptorSets.size(); i++) {
descriptorSets[i].resize(depthBuffer.getMaxFramesInFlight());
}
std::vector<Texture*> allTextures = Texture::getAllTextures();
std::vector<uint32_t> variableCounts(depthBuffer.getMaxFramesInFlight(), static_cast<uint32_t>(MAX_TEXTURES));
VkDescriptorSetVariableDescriptorCountAllocateInfo variableCountInfo{};
variableCountInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_ALLOCATE_INFO;
variableCountInfo.descriptorSetCount = static_cast<uint32_t>(variableCounts.size());
variableCountInfo.pDescriptorCounts = variableCounts.data();
std::vector<VkDescriptorSetLayout> layouts(depthBuffer.getMaxFramesInFlight(), descriptorSetLayout[shader->getId()]);
VkDescriptorSetAllocateInfo allocInfo{};
allocInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO;
allocInfo.pNext = &variableCountInfo;
allocInfo.descriptorPool = descriptorPool[descriptorId];
allocInfo.descriptorSetCount = static_cast<uint32_t>(depthBuffer.getMaxFramesInFlight());
allocInfo.pSetLayouts = layouts.data();
if (vkAllocateDescriptorSets(vkDevice.getDevice(), &allocInfo, descriptorSets[descriptorId].data()) != VK_SUCCESS) {
throw std::runtime_error("echec de l'allocation d'un set de descripteurs!");
}
}
{
std::vector<std::vector<VkDescriptorSet>>& descriptorSets = lightDepthBuffer.getDescriptorSet();
std::vector<VkDescriptorPool>& descriptorPool = lightDepthBuffer.getDescriptorPool();
std::vector<VkDescriptorSetLayout>& descriptorSetLayout = lightDepthBuffer.getDescriptorSetLayout();
if (shader->getNbShaders() * (Batcher::nbPrimitiveTypes - 1) > descriptorSets.size())
descriptorSets.resize(shader->getNbShaders() * (Batcher::nbPrimitiveTypes - 1));
unsigned int descriptorId = p * shader->getNbShaders() + shader->getId();
for (unsigned int i = 0; i < descriptorSets.size(); i++) {
descriptorSets[i].resize(lightDepthBuffer.getMaxFramesInFlight());
}
std::vector<Texture*> allTextures = Texture::getAllTextures();
std::vector<uint32_t> variableCounts(depthBuffer.getMaxFramesInFlight(), static_cast<uint32_t>(MAX_TEXTURES));
VkDescriptorSetVariableDescriptorCountAllocateInfo variableCountInfo{};
variableCountInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_ALLOCATE_INFO;
variableCountInfo.descriptorSetCount = static_cast<uint32_t>(variableCounts.size());
variableCountInfo.pDescriptorCounts = variableCounts.data();
std::vector<VkDescriptorSetLayout> layouts(depthBuffer.getMaxFramesInFlight(), descriptorSetLayout[shader->getId()]);
VkDescriptorSetAllocateInfo allocInfo{};
allocInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO;
allocInfo.pNext = &variableCountInfo;
allocInfo.descriptorPool = descriptorPool[descriptorId];
allocInfo.descriptorSetCount = static_cast<uint32_t>(depthBuffer.getMaxFramesInFlight());
allocInfo.pSetLayouts = layouts.data();
if (vkAllocateDescriptorSets(vkDevice.getDevice(), &allocInfo, descriptorSets[descriptorId].data()) != VK_SUCCESS) {
throw std::runtime_error("echec de l'allocation d'un set de descripteurs!");
}
}
void LightRenderComponent::updateDescriptorSets(unsigned int currentFrame, unsigned int p, RenderStates states, bool lightDepth) {
Shader* shader = const_cast<Shader*>(states.shader);
if (shader == &depthBufferGenerator) {
std::vector<std::vector<VkDescriptorSet>> descriptorSets = (lightDepth) ? lightDepthBuffer.getDescriptorSet() : depthBuffer.getDescriptorSet();
std::vector<Texture*> allTextures = Texture::getAllTextures();
unsigned int descriptorId = p * shader->getNbShaders() + shader->getId();
std::array<VkWriteDescriptorSet, 4> descriptorWrites{};
VkDescriptorBufferInfo modelDataStorageBufferInfoLastFrame{};
modelDataStorageBufferInfoLastFrame.buffer = modelDataBufferMT[p][currentFrame];
modelDataStorageBufferInfoLastFrame.offset = 0;
modelDataStorageBufferInfoLastFrame.range = maxAlignedSizeModelData[p];
descriptorWrites[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
descriptorWrites[0].dstSet = descriptorSets[descriptorId][currentFrame];
descriptorWrites[0].dstBinding = 0;
descriptorWrites[0].dstArrayElement = 0;
descriptorWrites[0].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC;
descriptorWrites[0].descriptorCount = 1;
descriptorWrites[0].pBufferInfo = &modelDataStorageBufferInfoLastFrame;
VkDescriptorBufferInfo materialDataStorageBufferInfoLastFrame{};
materialDataStorageBufferInfoLastFrame.buffer = materialDataBufferMT[p][currentFrame];
materialDataStorageBufferInfoLastFrame.offset = 0;
materialDataStorageBufferInfoLastFrame.range = maxAlignedSizeMaterialData[p];
descriptorWrites[1].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
descriptorWrites[1].dstSet = descriptorSets[descriptorId][currentFrame];
descriptorWrites[1].dstBinding = 1;
descriptorWrites[1].dstArrayElement = 0;
descriptorWrites[1].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC;
descriptorWrites[1].descriptorCount = 1;
descriptorWrites[1].pBufferInfo = &materialDataStorageBufferInfoLastFrame;
//std::cout<<"light depth ? "<<lightDepth<<std::endl;
if (!lightDepth) {
VkDescriptorImageInfo headPtrDescriptorImageInfo;
headPtrDescriptorImageInfo.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
headPtrDescriptorImageInfo.imageView = depthTextureImageView[currentFrame];
headPtrDescriptorImageInfo.sampler = depthTextureSampler[currentFrame];
descriptorWrites[2].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
descriptorWrites[2].dstSet = descriptorSets[descriptorId][currentFrame];
descriptorWrites[2].dstBinding = 2;
descriptorWrites[2].dstArrayElement = 0;
descriptorWrites[2].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE;
descriptorWrites[2].descriptorCount = 1;
descriptorWrites[2].pImageInfo = &headPtrDescriptorImageInfo;
//std::cout<<"nb ds : "<<descriptorSets[descriptorId].size()<<std::endl;
} else {
VkDescriptorImageInfo headPtrDescriptorImageInfo;
headPtrDescriptorImageInfo.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
headPtrDescriptorImageInfo.imageView = lightDepthTextureImageView[currentFrame];
headPtrDescriptorImageInfo.sampler = lightDepthTextureSampler[currentFrame];
descriptorWrites[2].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
descriptorWrites[2].dstSet = descriptorSets[descriptorId][currentFrame];
descriptorWrites[2].dstBinding = 2;
descriptorWrites[2].dstArrayElement = 0;
descriptorWrites[2].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE;
descriptorWrites[2].descriptorCount = 1;
descriptorWrites[2].pImageInfo = &headPtrDescriptorImageInfo;
//std::cout<<"light nb ds : "<<descriptorSets[descriptorId].size()<<std::endl;
}
std::vector<VkDescriptorImageInfo> descriptorImageInfos;
descriptorImageInfos.resize(allTextures.size());
for (unsigned int j = 0; j < allTextures.size(); j++) {
descriptorImageInfos[j].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
descriptorImageInfos[j].imageView = allTextures[j]->getImageView();
descriptorImageInfos[j].sampler = allTextures[j]->getSampler();
}
descriptorWrites[3].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
descriptorWrites[3].dstSet = descriptorSets[descriptorId][currentFrame];
descriptorWrites[3].dstBinding = 3;
descriptorWrites[3].dstArrayElement = 0;
descriptorWrites[3].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
descriptorWrites[3].descriptorCount = allTextures.size();
descriptorWrites[3].pImageInfo = descriptorImageInfos.data();
//std::cout<<"vk update descriptor sets"<<std::endl;
vkUpdateDescriptorSets(vkDevice.getDevice(), static_cast<uint32_t>(descriptorWrites.size()), descriptorWrites.data(), 0, nullptr);
//std::cout<<"vk descriptor sets updated"<<std::endl;
}
vkUpdateDescriptorSets makes the program crashing why ? Driver issue ?
If you want to see more code here is the repo of my engine : https://github.com/LaurentDuroisin7601/ODFAEG/tree/master/ODFAEG
It crash in the file lightRenderComponent.
Thanks.