Make sure *all* bindings are available to compute, not just vertex

* This fixes a problem where dynamic offsets would be wrong because we
  only opted-in to the vertex bindings in the layout, not the fragment
  bindings.
This commit is contained in:
baldurk
2018-02-09 13:06:35 +00:00
parent 360b37b1a7
commit 634c63637f
@@ -246,14 +246,18 @@ bool WrappedVulkan::Serialise_vkCreateDescriptorSetLayout(
VkDescriptorSetLayoutBinding *bindings = (VkDescriptorSetLayoutBinding *)CreateInfo.pBindings;
// ensure any bindings available to the vertex shader are also available to compute. This is
// valid and changes nothing, but means we don't have to create a duplicate parallel 'computer
// friendly' descriptor set layout and pipeline layout.
// ensure any bindings available are also available to compute. This is valid and changes
// nothing, but means we don't have to create a duplicate parallel 'compute friendly' descriptor
// set layout and pipeline layout.
// Note that we apply this to all bindings, even ones that are fragment only, because otherwise
// dynamic buffer offsets could be indexed wrongly. Consider the case where we have binding 0 as
// a fragment UBO, and binding 1 as a vertex UBO. Then there are two dynamic offsets, and the
// second is the one we want to use with ours. If we only add the compute visibility bit to the
// second UBO, then suddenly it's the *first* offset that we must provide. Instead of trying to
// remap offsets to match, we simply make every binding compute visible so the ordering is still
// the same. Since compute and graphics are disjoint this is safe.
for(uint32_t i = 0; i < CreateInfo.bindingCount; i++)
{
if(bindings[i].stageFlags & VK_SHADER_STAGE_VERTEX_BIT)
bindings[i].stageFlags |= VK_SHADER_STAGE_COMPUTE_BIT;
}
bindings[i].stageFlags |= VK_SHADER_STAGE_COMPUTE_BIT;
VkDescriptorSetLayoutCreateInfo unwrapped = UnwrapInfo(&CreateInfo);
VkResult ret =