@@ -1071,6 +1071,7 @@ class CVulkanCommandBuffer : public IGPUCommandBuffer
1071
1071
return false ;
1072
1072
1073
1073
constexpr uint32_t MAX_DESCRIPTOR_SET_COUNT = 4u ;
1074
+ assert (descriptorSetCount <= MAX_DESCRIPTOR_SET_COUNT);
1074
1075
1075
1076
VkPipelineLayout vk_pipelineLayout = IBackendObject::compatibility_cast<const CVulkanPipelineLayout*>(layout, this )->getInternalObject ();
1076
1077
@@ -1097,9 +1098,10 @@ class CVulkanCommandBuffer : public IGPUCommandBuffer
1097
1098
1098
1099
const auto * vk = static_cast <const CVulkanLogicalDevice*>(getOriginDevice ())->getFunctionTable ();
1099
1100
1101
+ // We allow null descriptor sets in our bind function to skip a certain set number we don't use
1100
1102
// Will bind [first, last) with one call
1101
1103
uint32_t dynamicOffsetsBindOffset = 0u ;
1102
- uint32_t bindCount = 0u ;
1104
+ uint32_t bindCallsCount = 0u ;
1103
1105
uint32_t first = ~0u ;
1104
1106
uint32_t last = ~0u ;
1105
1107
for (uint32_t i = 0u ; i < descriptorSetCount; ++i)
@@ -1115,7 +1117,7 @@ class CVulkanCommandBuffer : public IGPUCommandBuffer
1115
1117
++last;
1116
1118
1117
1119
// Do a look ahead
1118
- if ((i + 1 > descriptorSetCount - 1 ) || !pDescriptorSets[i + 1 ])
1120
+ if ((i + 1 >= descriptorSetCount) || !pDescriptorSets[i + 1 ])
1119
1121
{
1120
1122
if (dynamicOffsets)
1121
1123
{
@@ -1129,7 +1131,7 @@ class CVulkanCommandBuffer : public IGPUCommandBuffer
1129
1131
vk_pipelineLayout,
1130
1132
// firstSet + first, last - first, vk_descriptorSets + first, vk_dynamicOffsetCount, vk_dynamicOffsets);
1131
1133
firstSet + first, last - first, vk_descriptorSets + first,
1132
- dynamicOffsetCount, dynamicOffsets-> begin () + dynamicOffsetsBindOffset);
1134
+ dynamicOffsetCount, dynamicOffsets + dynamicOffsetsBindOffset);
1133
1135
1134
1136
dynamicOffsetsBindOffset += dynamicOffsetCount;
1135
1137
}
@@ -1144,11 +1146,13 @@ class CVulkanCommandBuffer : public IGPUCommandBuffer
1144
1146
1145
1147
first = ~0u ;
1146
1148
last = ~0u ;
1147
- ++bindCount ;
1149
+ ++bindCallsCount ;
1148
1150
}
1149
1151
}
1150
1152
}
1151
- assert (bindCount <= core::ceil (MAX_DESCRIPTOR_SET_COUNT / 2 .f ));
1153
+
1154
+ // with K slots you need at most (K+1)/2 calls
1155
+ assert (bindCallsCount <= (MAX_DESCRIPTOR_SET_COUNT + 1 ) / 2 );
1152
1156
1153
1157
return true ;
1154
1158
}
0 commit comments