Suppose I have several cells that I want to display using different materials. I know that I can use for this example push constants, but this question is more for understanding how vkDescriptorset works.
struct Material {
vec4 color;
vkDescriptorset descriptorSet;
VkDescriptorBufferInfo descriptorBufferInfo;
};
I only call vkUpdateDescriptorSetsfor _descriptorBufferInfoafter the data buffer has been created. Everything is working fine.
I checked another solution. Instead of having one vkDescriptorsetper material, I only have one for all of them. And inside rendepassI call vkUpdateDescriptorSetsfor each of the materials VkDescriptorBufferInfo.
vkDescriptorset globalDescriptorSet;
struct Material {
vec4 color;
VkDescriptorBufferInfo descriptorBufferInfo;
};
beginCommandBuffer
beginRenderPass
for (auto &mesh : meshes) {
...
writeDescriptorSets.dstSet = globalDescriptorSet;
writeDescriptorSets.pBufferInfo = &mesh.material.descriptorBufferInfo;
....
vkUpdateDescriptorSets(device, 1, &writeDescriptorSets, 0, nullptr);
renderMesh(mesh);
}
endRenderPass
endCommandBuffer
, . , beginCommandBuffer vkCmdBindDescriptorSets, vkCmdBindPipeline .. .
? vkDescriptorset VkDescriptorBufferInfo renderPass?