layers: Factor out checking of descriptor write members
This will allow us to reuse this check for push descriptors, which are
currently inconsistent.
diff --git a/layers/object_tracker_utils.cpp b/layers/object_tracker_utils.cpp
index c9b2700..6cad036 100644
--- a/layers/object_tracker_utils.cpp
+++ b/layers/object_tracker_utils.cpp
@@ -190,6 +190,50 @@
return skip;
}
+template<typename DispObj>
+static bool ValidateDescriptorWrite(DispObj disp, VkWriteDescriptorSet const *desc, bool isPush) {
+ bool skip = false;
+
+ if (!isPush && desc->dstSet) {
+ skip |= ValidateObject(disp, desc->dstSet, kVulkanObjectTypeDescriptorSet, false,
+ VALIDATION_ERROR_15c00280, VALIDATION_ERROR_15c00009);
+ }
+
+ if ((desc->descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
+ (desc->descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
+ for (uint32_t idx2 = 0; idx2 < desc->descriptorCount; ++idx2) {
+ skip |= ValidateObject(disp, desc->pTexelBufferView[idx2], kVulkanObjectTypeBufferView,
+ false, VALIDATION_ERROR_15c00286, VALIDATION_ERROR_15c00009);
+ }
+ }
+
+ if ((desc->descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
+ (desc->descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
+ (desc->descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
+ (desc->descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
+ for (uint32_t idx3 = 0; idx3 < desc->descriptorCount; ++idx3) {
+ skip |=
+ ValidateObject(disp, desc->pImageInfo[idx3].imageView, kVulkanObjectTypeImageView,
+ false, VALIDATION_ERROR_15c0028c, VALIDATION_ERROR_04600009);
+ }
+ }
+
+ if ((desc->descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
+ (desc->descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
+ (desc->descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
+ (desc->descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
+ for (uint32_t idx4 = 0; idx4 < desc->descriptorCount; ++idx4) {
+ if (desc->pBufferInfo[idx4].buffer) {
+ skip |=
+ ValidateObject(disp, desc->pBufferInfo[idx4].buffer, kVulkanObjectTypeBuffer,
+ false, VALIDATION_ERROR_04401a01, VALIDATION_ERROR_UNDEFINED);
+ }
+ }
+ }
+
+ return skip;
+}
+
VKAPI_ATTR void VKAPI_CALL CmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint,
VkPipelineLayout layout, uint32_t set, uint32_t descriptorWriteCount,
const VkWriteDescriptorSet *pDescriptorWrites) {
@@ -203,6 +247,7 @@
if (pDescriptorWrites) {
for (uint32_t index0 = 0; index0 < descriptorWriteCount; ++index0) {
if (pDescriptorWrites[index0].pImageInfo) {
+
for (uint32_t index1 = 0; index1 < pDescriptorWrites[index0].descriptorCount; ++index1) {
skip |=
ValidateObject(commandBuffer, pDescriptorWrites[index0].pImageInfo[index1].sampler,
@@ -413,39 +458,7 @@
}
if (pDescriptorWrites) {
for (uint32_t idx1 = 0; idx1 < descriptorWriteCount; ++idx1) {
- if (pDescriptorWrites[idx1].dstSet) {
- skip |= ValidateObject(device, pDescriptorWrites[idx1].dstSet, kVulkanObjectTypeDescriptorSet, false,
- VALIDATION_ERROR_15c00280, VALIDATION_ERROR_15c00009);
- }
- if ((pDescriptorWrites[idx1].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
- (pDescriptorWrites[idx1].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
- for (uint32_t idx2 = 0; idx2 < pDescriptorWrites[idx1].descriptorCount; ++idx2) {
- skip |= ValidateObject(device, pDescriptorWrites[idx1].pTexelBufferView[idx2], kVulkanObjectTypeBufferView,
- false, VALIDATION_ERROR_15c00286, VALIDATION_ERROR_15c00009);
- }
- }
- if ((pDescriptorWrites[idx1].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
- (pDescriptorWrites[idx1].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
- (pDescriptorWrites[idx1].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
- (pDescriptorWrites[idx1].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
- for (uint32_t idx3 = 0; idx3 < pDescriptorWrites[idx1].descriptorCount; ++idx3) {
- skip |=
- ValidateObject(device, pDescriptorWrites[idx1].pImageInfo[idx3].imageView, kVulkanObjectTypeImageView,
- false, VALIDATION_ERROR_15c0028c, VALIDATION_ERROR_04600009);
- }
- }
- if ((pDescriptorWrites[idx1].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
- (pDescriptorWrites[idx1].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
- (pDescriptorWrites[idx1].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
- (pDescriptorWrites[idx1].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
- for (uint32_t idx4 = 0; idx4 < pDescriptorWrites[idx1].descriptorCount; ++idx4) {
- if (pDescriptorWrites[idx1].pBufferInfo[idx4].buffer) {
- skip |=
- ValidateObject(device, pDescriptorWrites[idx1].pBufferInfo[idx4].buffer, kVulkanObjectTypeBuffer,
- false, VALIDATION_ERROR_04401a01, VALIDATION_ERROR_UNDEFINED);
- }
- }
- }
+ skip |= ValidateDescriptorWrite(device, &pDescriptorWrites[idx1], false);
}
}
}