Skip to content
This repository was archived by the owner on Jul 19, 2018. It is now read-only.

Commit ee33d96

Browse files
committed
layers: Check that indirect buffers have the correct usage flag
1 parent b4549ff commit ee33d96

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

layers/core_validation.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6694,6 +6694,8 @@ static bool PreCallValidateCmdDrawIndirect(layer_data *dev_data, VkCommandBuffer
66946694
ValidateCmdDrawType(dev_data, cmd_buffer, indexed, bind_point, CMD_DRAWINDIRECT, cb_state, caller, VK_QUEUE_GRAPHICS_BIT,
66956695
VALIDATION_ERROR_1aa02415, VALIDATION_ERROR_1aa00017, VALIDATION_ERROR_1aa003cc);
66966696
*buffer_state = GetBufferState(dev_data, buffer);
6697+
skip |= ValidateBufferUsageFlags(dev_data, *buffer_state, VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT, true, VALIDATION_ERROR_1aa00cf8,
6698+
"vkCmdDrawIndirect()", "VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT");
66976699
skip |= ValidateMemoryIsBoundToBuffer(dev_data, *buffer_state, caller, VALIDATION_ERROR_1aa003b4);
66986700
// TODO: If the drawIndirectFirstInstance feature is not enabled, all the firstInstance members of the
66996701
// VkDrawIndirectCommand structures accessed by this command must be 0, which will require access to the contents of 'buffer'.
@@ -6730,6 +6732,8 @@ static bool PreCallValidateCmdDrawIndexedIndirect(layer_data *dev_data, VkComman
67306732
ValidateCmdDrawType(dev_data, cmd_buffer, indexed, bind_point, CMD_DRAWINDEXEDINDIRECT, cb_state, caller,
67316733
VK_QUEUE_GRAPHICS_BIT, VALIDATION_ERROR_1a602415, VALIDATION_ERROR_1a600017, VALIDATION_ERROR_1a600434);
67326734
*buffer_state = GetBufferState(dev_data, buffer);
6735+
skip |= ValidateBufferUsageFlags(dev_data, *buffer_state, VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT, true, VALIDATION_ERROR_1a600d02,
6736+
"vkCmdDrawIndexedIndirect()", "VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT");
67336737
skip |= ValidateMemoryIsBoundToBuffer(dev_data, *buffer_state, caller, VALIDATION_ERROR_1a60041c);
67346738
// TODO: If the drawIndirectFirstInstance feature is not enabled, all the firstInstance members of the
67356739
// VkDrawIndexedIndirectCommand structures accessed by this command must be 0, which will require access to the contents of
@@ -6792,6 +6796,8 @@ static bool PreCallValidateCmdDispatchIndirect(layer_data *dev_data, VkCommandBu
67926796
ValidateCmdDrawType(dev_data, cmd_buffer, indexed, bind_point, CMD_DISPATCHINDIRECT, cb_state, caller, VK_QUEUE_COMPUTE_BIT,
67936797
VALIDATION_ERROR_1a002415, VALIDATION_ERROR_1a000017, VALIDATION_ERROR_UNDEFINED);
67946798
*buffer_state = GetBufferState(dev_data, buffer);
6799+
skip |= ValidateBufferUsageFlags(dev_data, *buffer_state, VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT, true, VALIDATION_ERROR_1a00032a,
6800+
"vkCmdDispatchIndirect()", "VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT");
67956801
skip |= ValidateMemoryIsBoundToBuffer(dev_data, *buffer_state, caller, VALIDATION_ERROR_1a000322);
67966802
return skip;
67976803
}

layers/vk_validation_error_database.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2047,7 +2047,7 @@ VALIDATION_ERROR_1a000322~^~Y~^~Unknown~^~vkCmdDispatchIndirect~^~VUID-vkCmdDisp
20472047
VALIDATION_ERROR_1a000324~^~N~^~Unknown~^~vkCmdDispatchIndirect~^~VUID-vkCmdDispatchIndirect-None-00402~^~core~^~The spec valid usage text states 'For each set n that is statically used by the VkPipeline bound to VK_PIPELINE_BIND_POINT_COMPUTE, a descriptor set must have been bound to n at VK_PIPELINE_BIND_POINT_COMPUTE, with a VkPipelineLayout that is compatible for set n, with the VkPipelineLayout used to create the current VkPipeline, as described in descriptorsets-compatibility' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdDispatchIndirect-None-00402)~^~
20482048
VALIDATION_ERROR_1a000326~^~N~^~Unknown~^~vkCmdDispatchIndirect~^~VUID-vkCmdDispatchIndirect-None-00403~^~core~^~The spec valid usage text states 'Descriptors in each bound descriptor set, specified via vkCmdBindDescriptorSets, must be valid if they are statically used by the bound VkPipeline object, specified via vkCmdBindPipeline' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdDispatchIndirect-None-00403)~^~
20492049
VALIDATION_ERROR_1a000328~^~N~^~Unknown~^~vkCmdDispatchIndirect~^~VUID-vkCmdDispatchIndirect-None-00404~^~core~^~The spec valid usage text states 'A valid compute pipeline must be bound to the current command buffer with VK_PIPELINE_BIND_POINT_COMPUTE' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdDispatchIndirect-None-00404)~^~
2050-
VALIDATION_ERROR_1a00032a~^~N~^~Unknown~^~vkCmdDispatchIndirect~^~VUID-vkCmdDispatchIndirect-buffer-00405~^~core~^~The spec valid usage text states 'buffer must have been created with the VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT bit set' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdDispatchIndirect-buffer-00405)~^~
2050+
VALIDATION_ERROR_1a00032a~^~Y~^~Unknown~^~vkCmdDispatchIndirect~^~VUID-vkCmdDispatchIndirect-buffer-00405~^~core~^~The spec valid usage text states 'buffer must have been created with the VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT bit set' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdDispatchIndirect-buffer-00405)~^~
20512051
VALIDATION_ERROR_1a00032c~^~N~^~Unknown~^~vkCmdDispatchIndirect~^~VUID-vkCmdDispatchIndirect-offset-00406~^~core~^~The spec valid usage text states 'offset must be a multiple of 4' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdDispatchIndirect-offset-00406)~^~
20522052
VALIDATION_ERROR_1a00032e~^~N~^~Unknown~^~vkCmdDispatchIndirect~^~VUID-vkCmdDispatchIndirect-offset-00407~^~core~^~The spec valid usage text states 'The sum of offset and the size of VkDispatchIndirectCommand must be less than or equal to the size of buffer' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdDispatchIndirect-offset-00407)~^~
20532053
VALIDATION_ERROR_1a000330~^~N~^~Unknown~^~vkCmdDispatchIndirect~^~VUID-vkCmdDispatchIndirect-None-00408~^~core~^~The spec valid usage text states 'For each push constant that is statically used by the VkPipeline bound to VK_PIPELINE_BIND_POINT_COMPUTE, a push constant value must have been set for VK_PIPELINE_BIND_POINT_COMPUTE, with a VkPipelineLayout that is compatible for push constants with the one used to create the current VkPipeline, as described in descriptorsets-compatibility' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdDispatchIndirect-None-00408)~^~
@@ -2153,7 +2153,7 @@ VALIDATION_ERROR_1a60044c~^~N~^~Unknown~^~vkCmdDrawIndexedIndirect~^~VUID-vkCmdD
21532153
VALIDATION_ERROR_1a60044e~^~N~^~Unknown~^~vkCmdDrawIndexedIndirect~^~VUID-vkCmdDrawIndexedIndirect-maxMultiviewInstanceIndex-00551~^~(VK_VERSION_1_1,VK_KHR_multiview)~^~The spec valid usage text states 'If the draw is recorded in a render pass instance with multiview enabled, the maximum instance index must be less than or equal to VkPhysicalDeviceMultiviewProperties::maxMultiviewInstanceIndex.' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-vkCmdDrawIndexedIndirect-maxMultiviewInstanceIndex-00551)~^~
21542154
VALIDATION_ERROR_1a600bbe~^~N~^~None~^~vkCmdDrawIndexedIndirect~^~VUID-vkCmdDrawIndexedIndirect-None-01503~^~core~^~The spec valid usage text states 'Image subresources used as attachments in the current render pass must not be accessed in any way other than as an attachment by this command.' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdDrawIndexedIndirect-None-01503)~^~
21552155
VALIDATION_ERROR_1a600bd8~^~N~^~None~^~vkCmdDrawIndexedIndirect~^~VUID-vkCmdDrawIndexedIndirect-sampleLocationsEnable-01516~^~(VK_EXT_sample_locations)~^~The spec valid usage text states 'If the bound graphics pipeline was created with VkPipelineSampleLocationsStateCreateInfoEXT::sampleLocationsEnable set to VK_TRUE and the current subpass has a depth/stencil attachment, then that attachment must have been created with the VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT bit set' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-vkCmdDrawIndexedIndirect-sampleLocationsEnable-01516)~^~
2156-
VALIDATION_ERROR_1a600d02~^~N~^~None~^~vkCmdDrawIndexedIndirect~^~VUID-vkCmdDrawIndexedIndirect-buffer-01665~^~core~^~The spec valid usage text states 'buffer must have been created with the VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT bit set' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdDrawIndexedIndirect-buffer-01665)~^~
2156+
VALIDATION_ERROR_1a600d02~^~Y~^~None~^~vkCmdDrawIndexedIndirect~^~VUID-vkCmdDrawIndexedIndirect-buffer-01665~^~core~^~The spec valid usage text states 'buffer must have been created with the VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT bit set' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdDrawIndexedIndirect-buffer-01665)~^~
21572157
VALIDATION_ERROR_1a600e8c~^~N~^~None~^~vkCmdDrawIndexedIndirect~^~VUID-vkCmdDrawIndexedIndirect-commandBuffer-01862~^~(VK_VERSION_1_1)~^~The spec valid usage text states 'If commandBuffer is an unprotected command buffer, and any pipeline stage in the VkPipeline object bound to VK_PIPELINE_BIND_POINT_GRAPHICS reads from or writes to any image or buffer, that image or buffer must not be a protected image or protected buffer.' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-vkCmdDrawIndexedIndirect-commandBuffer-01862)~^~
21582158
VALIDATION_ERROR_1a600e8e~^~N~^~None~^~vkCmdDrawIndexedIndirect~^~VUID-vkCmdDrawIndexedIndirect-commandBuffer-01863~^~(VK_VERSION_1_1)~^~The spec valid usage text states 'If commandBuffer is a protected command buffer, and any pipeline stage in the VkPipeline object bound to VK_PIPELINE_BIND_POINT_GRAPHICS writes to any image or buffer, that image or buffer must not be an unprotected image or unprotected buffer.' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-vkCmdDrawIndexedIndirect-commandBuffer-01863)~^~
21592159
VALIDATION_ERROR_1a600e90~^~N~^~None~^~vkCmdDrawIndexedIndirect~^~VUID-vkCmdDrawIndexedIndirect-commandBuffer-01864~^~(VK_VERSION_1_1)~^~The spec valid usage text states 'If commandBuffer is a protected command buffer, and any pipeline stage other than the framebuffer-space pipeline stages in the VkPipeline object bound to VK_PIPELINE_BIND_POINT_GRAPHICS reads from or writes to any image or buffer, the image or buffer must not be a protected image or protected buffer.' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-vkCmdDrawIndexedIndirect-commandBuffer-01864)~^~
@@ -2231,7 +2231,7 @@ VALIDATION_ERROR_1aa003e4~^~N~^~Unknown~^~vkCmdDrawIndirect~^~VUID-vkCmdDrawIndi
22312231
VALIDATION_ERROR_1aa003e6~^~N~^~Unknown~^~vkCmdDrawIndirect~^~VUID-vkCmdDrawIndirect-maxMultiviewInstanceIndex-00499~^~(VK_VERSION_1_1,VK_KHR_multiview)~^~The spec valid usage text states 'If the draw is recorded in a render pass instance with multiview enabled, the maximum instance index must be less than or equal to VkPhysicalDeviceMultiviewProperties::maxMultiviewInstanceIndex.' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-vkCmdDrawIndirect-maxMultiviewInstanceIndex-00499)~^~
22322232
VALIDATION_ERROR_1aa00bba~^~N~^~None~^~vkCmdDrawIndirect~^~VUID-vkCmdDrawIndirect-None-01501~^~core~^~The spec valid usage text states 'Image subresources used as attachments in the current render pass must not be accessed in any way other than as an attachment by this command.' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdDrawIndirect-None-01501)~^~
22332233
VALIDATION_ERROR_1aa00bd4~^~N~^~None~^~vkCmdDrawIndirect~^~VUID-vkCmdDrawIndirect-sampleLocationsEnable-01514~^~(VK_EXT_sample_locations)~^~The spec valid usage text states 'If the bound graphics pipeline was created with VkPipelineSampleLocationsStateCreateInfoEXT::sampleLocationsEnable set to VK_TRUE and the current subpass has a depth/stencil attachment, then that attachment must have been created with the VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT bit set' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-vkCmdDrawIndirect-sampleLocationsEnable-01514)~^~
2234-
VALIDATION_ERROR_1aa00cf8~^~N~^~None~^~vkCmdDrawIndirect~^~VUID-vkCmdDrawIndirect-buffer-01660~^~core~^~The spec valid usage text states 'buffer must have been created with the VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT bit set' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdDrawIndirect-buffer-01660)~^~
2234+
VALIDATION_ERROR_1aa00cf8~^~Y~^~None~^~vkCmdDrawIndirect~^~VUID-vkCmdDrawIndirect-buffer-01660~^~core~^~The spec valid usage text states 'buffer must have been created with the VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT bit set' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdDrawIndirect-buffer-01660)~^~
22352235
VALIDATION_ERROR_1aa00e80~^~N~^~None~^~vkCmdDrawIndirect~^~VUID-vkCmdDrawIndirect-commandBuffer-01856~^~(VK_VERSION_1_1)~^~The spec valid usage text states 'If commandBuffer is an unprotected command buffer, and any pipeline stage in the VkPipeline object bound to VK_PIPELINE_BIND_POINT_GRAPHICS reads from or writes to any image or buffer, that image or buffer must not be a protected image or protected buffer.' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-vkCmdDrawIndirect-commandBuffer-01856)~^~
22362236
VALIDATION_ERROR_1aa00e82~^~N~^~None~^~vkCmdDrawIndirect~^~VUID-vkCmdDrawIndirect-commandBuffer-01857~^~(VK_VERSION_1_1)~^~The spec valid usage text states 'If commandBuffer is a protected command buffer, and any pipeline stage in the VkPipeline object bound to VK_PIPELINE_BIND_POINT_GRAPHICS writes to any image or buffer, that image or buffer must not be an unprotected image or unprotected buffer.' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-vkCmdDrawIndirect-commandBuffer-01857)~^~
22372237
VALIDATION_ERROR_1aa00e84~^~N~^~None~^~vkCmdDrawIndirect~^~VUID-vkCmdDrawIndirect-commandBuffer-01858~^~(VK_VERSION_1_1)~^~The spec valid usage text states 'If commandBuffer is a protected command buffer, and any pipeline stage other than the framebuffer-space pipeline stages in the VkPipeline object bound to VK_PIPELINE_BIND_POINT_GRAPHICS reads from or writes to any image or buffer, the image or buffer must not be a protected image or protected buffer.' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-vkCmdDrawIndirect-commandBuffer-01858)~^~

0 commit comments

Comments
 (0)