Validation Layer Details

DrawState

DrawState Overview

The DrawState layer tracks state leading into Draw cmds. This includes the Pipeline state, dynamic state, and descriptor set state. DrawState validates the consistency and correctness between and within these states.

DrawState Details Table

CheckOverviewENUM DRAWSTATE_*Relevant APITestnameNotes/TODO
Valid Pipeline LayoutsValidates that pipeline layout from bound descriptor set matches the current pipeline layoutPIPELINE_LAYOUT_MISMATCHvkCmdDraw vkCmdDrawIndexed vkCmdDrawIndirect vkCmdDrawIndexedIndirectTBDNone
Validate DbgMarker exensionsValidates that DbgMarker extensions have been enabled before useINVALID_EXTENSIONvkCmdDbgMarkerBegin vkCmdDbgMarkerEndTBDNone
Valid BeginCommandBuffer level-related parametersPrimary command buffers must specify VK_NULL_HANDLE for RenderPass or Framebuffer parameters, while secondary command buffers must provide non-null parametersBEGIN_CB_INVALID_STATEvkBeginCommandBufferPrimaryCmdBufferFramebufferAndRenderpass SecondaryCmdBufferFramebufferAndRenderpassNone
PSO BoundVerify that a properly created and valid pipeline object is bound to the CmdBuffer specified in these callsNO_PIPELINE_BOUNDvkCmdBindDescriptorSets vkCmdBindVertexBuffersPipelineNotBoundThis check is currently more related to DrawState data structures and less about verifying that PSO is bound at all appropriate points in API. For API purposes, need to make sure this is checked at Draw time and any other relevant calls.
Valid DescriptorPoolVerifies that the descriptor set pool object was properly created and is validINVALID_POOLvkResetDescriptorPool vkAllocDescriptorSetsNoneThis is just an internal layer data structure check. ParamChecker or ObjectTracker should really catch bad DSPool
Valid DescriptorSetValidate that descriptor set was properly created and is currently validINVALID_SETvkCmdBindDescriptorSetsNoneIs this needed other places (like Update/Clear descriptors)
Valid DescriptorSetLayoutFlag DescriptorSetLayout object that was not properly createdINVALID_LAYOUTvkAllocDescriptorSetsNoneAnywhere else to check this?
Valid PipelineFlag VkPipeline object that was not properly createdINVALID_PIPELINEvkCmdBindPipelineInvalidPipelineNA
Valid Pipeline Create InfoTests for the following: That compute shaders are not specified for the graphics pipeline, tess evaluation and tess control shaders are included or excluded as a pair, that VK_PRIMITIVE_TOPOLOGY_PATCH is set as IA topology for tessellation pipelines, that VK_PRIMITIVE_TOPOLOGY_PATCH primitive topology is only set for tessellation pipelines, and that Vtx Shader specifiedINVALID_PIPELINE_CREATE_STATEvkCreateGraphicsPipelinesInvalidPipelineCreateStateNA
Valid CmdBufferValidates that the command buffer object was properly created and is currently validINVALID_CMD_BUFFERvkQueueSubmit vkBeginCommandBuffer vkEndCommandBuffer vkCmdBindPipeline vkCmdBindDynamicViewportState vkCmdBindDynamicLineWidthState vkCmdBindDynamicDepthBiasState vkCmdBindDynamicBlendState vkCmdBindDynamicDepthBoundsState vkCmdBindDynamicStencilState vkCmdBindDescriptorSets vkCmdBindIndexBuffer vkCmdBindVertexBuffers vkCmdDraw vkCmdDrawIndexed vkCmdDrawIndirect vkCmdDrawIndexedIndirect vkCmdDispatch vkCmdDispatchIndirect vkCmdCopyBuffer vkCmdCopyImage vkCmdBlitImage vkCmdCopyBufferToImage vkCmdCopyImageToBuffer vkCmdUpdateBuffer vkCmdFillBuffer vkCmdClearColorAttachment vkCmdClearDepthStencilAttachment vkCmdClearColorImage vkCmdClearDepthStencilImage vkCmdResolveImage vkCmdSetEvent vkCmdResetEvent vkCmdWaitEvents vkCmdPipelineBarrier vkCmdBeginQuery vkCmdEndQuery vkCmdResetQueryPool vkCmdWriteTimestamp vkCmdBeginRenderPass vkCmdNextSubpass vkCmdEndRenderPass vkCmdExecuteCommands vkCmdDbgMarkerBegin vkCmdDbgMarkerEnd vkCreateCommandBufferNoneNA
Valid Dynamic StateValidates that each of the 4 DSOs are valid, properly constructed objects of the correct typeINVALID_DYNAMIC_STATE_OBJECTvkCmdBindDynamicViewportState vkCmdBindDynamicLineWidthState vkCmdBindDynamicDepthBiasState vkCmdBindDynamicBlendState vkCmdBindDynamicDepthBoundsState vkCmdBindDynamicStencilStateNoneNA
Vtx Buffer BoundsCheck if VBO index too large for PSO Vtx binding count, and that at least one vertex buffer is attached to pipeline objectVTX_INDEX_OUT_OF_BOUNDSvkCmdBindDescriptorSets vkCmdBindVertexBuffersVtxBufferBadIndexNA
Cmd Buffer EndVerifies that EndCommandBuffer was called for this cmdBuffer at QueueSubmit timeNO_END_CMD_BUFFERvkQueueSubmitNoEndCmdBufferNA
Cmd Buffer BeginCheck that BeginCommandBuffer was called for this command buffer when binding commands or calling endNO_BEGIN_CMD_BUFFERvkEndCommandBuffer vkCmdBindPipeline vkCmdBindDynamicViewportState vkCmdBindDynamicLineWidthState vkCmdBindDynamicDepthBiasState vkCmdBindDynamicBlendState vkCmdBindDynamicDepthBoundsState vkCmdBindDynamicStencilState vkCmdBindDescriptorSets vkCmdBindIndexBuffer vkCmdBindVertexBuffers vkCmdDraw vkCmdDrawIndexed vkCmdDrawIndirect vkCmdDrawIndexedIndirect vkCmdDispatch vkCmdDispatchIndirect vkCmdCopyBuffer vkCmdCopyImage vkCmdBlitImage vkCmdCopyBufferToImage vkCmdCopyImageToBuffer vkCmdUpdateBuffer vkCmdFillBuffer vkCmdClearColorAttachment vkCmdClearDepthStencilAttachment vkCmdClearColorImage vkCmdClearDepthStencilImage vkCmdResolveImage vkCmdSetEvent vkCmdResetEvent vkCmdWaitEvents vkCmdPipelineBarrier vkCmdBeginQuery vkCmdEndQuery vkCmdResetQueryPool vkCmdWriteTimestampNoBeginCmdBufferNA
Cmd Buffer Submit CountVerify that ONE_TIME submit cmdbuffer is not submitted multiple timesCMD_BUFFER_SINGLE_SUBMIT_VIOLATIONvkBeginCommandBuffer, vkQueueSubmitCmdBufferTwoSubmitsNA
Descriptor TypeVerify Descriptor type in bound descriptor set layout matches descriptor type specified in updateDESCRIPTOR_TYPE_MISMATCHvkUpdateDescriptorSetsDSTypeMismatchWith various DS API updates, need to revisit this code
DS Update SizeDS update out of bounds for given layout sectionDESCRIPTOR_UPDATE_OUT_OF_BOUNDSvkUpdateDescriptorSetsDSUpdateOutOfBoundsNA
DS Update IndexDS update binding too large for layout countINVALID_UPDATE_INDEXvkUpdateDescriptorSetsInvalidDSUpdateIndexNA
DS Update TypeVerifies that structs in DS Update tree are properly created, currenly valid, and of the right typeINVALID_UPDATE_STRUCTvkUpdateDescriptorSetsInvalidDSUpdateStructNA
MSAA Sample CountVerifies that Pipeline, RenderPass, and Subpass sample counts are consistentNUM_SAMPLES_MISMATCHvkCmdBindPipeline vkCmdBeginRenderPass vkCmdNextSubpassNumSamplesMismatchNA
Dynamic Viewport State BindingVerify that viewport dynamic state bound to Cmd Buffer at Draw timeVIEWPORT_NOT_BOUNDvkCmdDraw vkCmdDrawIndexed vkCmdDrawIndirect vkCmdDrawIndexedIndirectViewportStateNotBoundNA
Dynamic Line Width State BindingVerify that line width dynamic state bound to Cmd Buffer at when required (TODO : Verify when this is)LINE_WIDTH_NOT_BOUNDvkCmdDraw vkCmdDrawIndexed vkCmdDrawIndirect vkCmdDrawIndexedIndirectTODOVerify this check and Write targeted test
Dynamic Depth Bias State BindingVerify that depth bias dynamic state bound when depth enabledDEPTH_BIAS_NOT_BOUNDvkCmdDraw vkCmdDrawIndexed vkCmdDrawIndirect vkCmdDrawIndexedIndirectTODOVerify this check and Write targeted test
Dynamic Blend State BindingVerify that blend dynamic state bound when color blend enabledBLEND_NOT_BOUNDvkCmdDraw vkCmdDrawIndexed vkCmdDrawIndirect vkCmdDrawIndexedIndirectTODOVerify this check and Write targeted test
Dynamic Depth Bounds State BindingVerify that depth bounds dynamic state bound when depth enabledDEPTH_BOUNDS_NOT_BOUNDvkCmdDraw vkCmdDrawIndexed vkCmdDrawIndirect vkCmdDrawIndexedIndirectTODOVerify this check and Write targeted test
Dynamic Stencil State BindingVerify that stencil dynamic state bound when depth enabledSTENCIL_NOT_BOUNDvkCmdDraw vkCmdDrawIndexed vkCmdDrawIndirect vkCmdDrawIndexedIndirectTODOVerify this check and Write targeted test
RenderPass misuseTests for the following: that BeginRenderPass, ResolveImage, ClearColorImage, ClearDepthStencilImage are not called during an active Renderpass, and that binding compute descriptior sets or pipelines does not take place during an activeINVALID_RENDERPASS_CMDvkCmdBindPipeline vkCmdBindDescriptorSets vkCmdBlitImage vkCmdClearColorImage vkCmdClearDepthStencilImage vkCmdResolveImage vkCmdBeginRenderPassRenderPassWithinRenderPassNA
Correct use of RenderPassValidates that rendering commands are issued inside an active RenderPassNO_ACTIVE_RENDERPASSvkCmdBindPipeline vkCmdBindDynamicViewportState vkCmdBindDynamicLineWidthState vkCmdBindDynamicDepthBiasState vkCmdBindDynamicBlendState vkCmdBindDynamicDepthBoundsState vkCmdBindDynamicStencilState vkCmdBindDescriptorSets vkCmdBindIndexBuffer vkCmdBindVertexBuffers vkCmdClearColorAttachment vkCmdClearDepthStencilAttachment vkCmdNextSubpass vkCmdEndRenderPass vkCmdExecuteCommands vkCmdDraw vkCmdDrawIndexed vkCmdDrawIndirect vkCmdDrawIndexedIndirectBindPipelineNoRenderPass VtxBufferNoRenderPassNA
Valid RenderPassFlag error if attempt made to Begin/End/Continue a NULL or otherwise invalid RenderPass objectINVALID_RENDERPASSvkCmdBeginRenderPass vkCmdEndRenderPass vkBeginCommandBufferNullRenderPassNA
DescriptorSet UpdatedWarn user if DescriptorSet bound that was never updatedDESCRIPTOR_SET_NOT_UPDATEDvkCmdBindDescriptorSetsDescriptorSetNotUpdatedNA
Correct Clear UseWarn user if CmdClear for Color or DepthStencil issued to Cmd Buffer prior to a Draw Cmd. RenderPass LOAD_OP_CLEAR is preferred in this case.CLEAR_CMD_BEFORE_DRAWvkCmdClearColorImage vkCmdClearDepthStencilImageClearCmdNoDrawNA
Index Buffer BindingVerify that an index buffer is bound at the point when an indexed draw is attempted.INDEX_BUFFER_NOT_BOUNDvkCmdDrawIndexed vkCmdDrawIndexedIndirectTODOImplement validation test
NAEnum used for informational messagesNONENANone
NAEnum used for errors in the layer itself. This does not indicate an app issue, but instead a bug in the layer.INTERNAL_ERRORNANone
NAEnum used when Drawstate attempts to allocate memory for its own internal use and is unable to.OUT_OF_MEMORYNANone
NAEnum used when Drawstate attempts to allocate memory for its own internal use and is unable to.OUT_OF_MEMORYNANone

DrawState Pending Work

Additional checks to be added to DrawState

  1. dynamicOffsetCount lists how many entries are present in pDynamicOffsets - account for this (not certain of what needs to be done here but we don't have any test cases for dynamicOffsets, so keeping this task around until we do)
  2. Lifetime validation (See bug 13383) 8. XGL_DESCRIPTOR_SET 9. Cannot be deleted until no longer in use on GPU, or referenced in any pending command. 10. Sets in XGL_DESCRIPTOR_REGION_USAGE_ONE_SHOT regions can never be deleted. Instead the xglClearDescriptorRegion() deletes all sets. 11. Sets in XGL_DESCRIPTOR_REGION_USAGE_DYNAMIC regions can be deleted. 12. XGL_DESCRIPTOR_SET_LAYOUT 13. What do IHVs want here? 14. Option 1 (assuming this one): Must not be deleted until all sets and layout chains referencing the set layout are deleted. 15. Option 2: Can be freely deleted after usage. 19. XGL_DESCRIPTOR_REGION 20. Cannot be deleted until no longer in use on the GPU, or referenced in any pending command. 21. XGL_BUFFER_VIEW, XGL_IMAGE_VIEW, etc 22. Cannot be deleted until the descriptors referencing the objects are deleted. 23. For ClearColorAttachment function, verify that the index of referenced attachment actually exists
  3. GetRenderAreaGranularity - The pname:renderPass parameter must be the same as the one given in the sname:VkRenderPassBeginInfo structure for which the render area is relevant.
  4. vkFreeDescriptorSets must not be called for sets created on top of one-shot pool
  5. If Cmd Buffer one-time submit flag is set, then verify that cmd buffer is only submitted once
  6. Verify that all relevent dynamic state objects are bound (See https://cvs.khronos.org/bugzilla/show_bug.cgi?id=14323)
  7. Flag an error if CmdBuffer has Begin called while it's being constructed - this is not a reset, this is a violation
  8. At PSO creation time, there is no case when NOT including a FS should flag an error since there exist dynamic state configurations that can be set to cause a FS to not be required. Instead, in the case when no FS is in the PSO, validation should detect at runtime if dynamic state will require a FS, and in those case issue a runtime warning about undefined behavior. (see bug https://cvs.khronos.org/bugzilla/show_bug.cgi?id=14429)
  9. Error if a cmdbuffer is submitted on a queue whose family doesn't match the family of the pool from which it was created.

ParamChecker

ParamChecker Overview

The ParamChecker layer validates parameter values and flags errors for any values that are outside of acceptable values for the given parameter.

ParamChecker Details Table

CheckOverviewENUMRelevant APITestnameNotes/TODO
Input ParametersPointers in structures are recursively validated to be non-null. Enumerated types are validated against min and max enum values. Structure Types are verified to be correct.NAvkQueueSubmit vkAllocMemory vkFlushMappedMemoryRanges vkInvalidateMappedMemoryRanges vkQueueBindSparseBufferMemory vkQueueBindSparseImageOpaqueMemory vkQueueBindSparseImageMemory vkCreateFence vkResetFences vkWaitForFences vkCreateSemaphore vkCreateEvent vkCreateQueryPool vkCreateBuffer vkCreateBufferView vkCreateImage vkGetImageSubresourceLayout vkCreateImageView vkCreateShader vkCreatePipelineCache vkMergePipelineCaches vkCreateGraphicsPipelines vkCreateComputePipelines vkCreatePipelineLayout vkCreateSampler vkCreateDescriptorSetLayout( vkCreateDescriptorPool vkAllocDescriptorSets vkFreeDescriptorSets vkUpdateDescriptorSets vkCreateDynamicViewportState vkCreateDynamicLineWidthState vkCreateDynamicDepthBiasState vkCreateDynamicBlendState vkCreateDynamicDepthBoundsState vkCreateDynamicStencilState vkCreateFramebuffer vkCreateRenderPass vkCreateCommandPool vkCreateCommandBuffer vkBeginCommandBuffer vkCmdBindDescriptorSets vkCmdBindVertexBuffers vkCmdCopyBuffer vkCmdCopyImage vkCmdBlitImage vkCmdCopyBufferToImage vkCmdCopyImageToBuffer vkCmdUpdateBuffer vkCmdClearColorImage vkCmdClearDepthStencilImage vkCmdClearColorAttachment vkCmdClearDepthStencilAttachment vkCmdResolveImage vkCmdWaitEvents vkCmdPipelineBarrier vkCmdPushConstants vkCmdBeginRenderPass vkCmdExecuteCommandsTBDNA
Call results, Output ParametersReturn values are checked for VK_SUCCESS, returned pointers are checked to be NON-NULL, enumerated types of return values are checked to be within the defined range.NAvkEnumeratePhysicalDevices vkGetPhysicalDeviceFeatures vkGetPhysicalDeviceFormatProperties vkGetPhysicalDeviceImageFormatProperties vkGetPhysicalDeviceLimits vkGetPhysicalDeviceProperties vkGetPhysicalDeviceQueueFamilyProperties vkGetPhysicalDeviceMemoryProperties vkGetDeviceQueue vkQueueSubmit vkQueueWaitIdle vkDeviceWaitIdle vkAllocMemory vkFreeMemory vkMapMemory vkUnmapMemory vkFlushMappedMemoryRanges vkInvalidateMappedMemoryRanges vkGetDeviceMemoryCommitment vkBindBufferMemory vkBindImageMemory vkGetBufferMemoryRequirements vkGetImageMemoryRequirements vkGetImageSparseMemoryRequirements vkGetPhysicalDeviceSparseImageFormatProperties vkQueueBindSparseBufferMemory vkQueueBindSparseImageOpaqueMemory vkQueueBindSparseImageMemory vkCreateFence vkDestroyFence vkResetFences vkGetFenceStatus vkWaitForFences vkCreateSemaphore vkDestroySemaphore vkQueueSignalSemaphore vkQueueWaitSemaphore vkCreateEvent vkDestroyEvent vkGetEventStatus vkSetEvent vkResetEvent vkCreateQueryPool vkDestroyQueryPool vkGetQueryPoolResults vkCreateBuffer vkDestroyBuffer vkCreateBufferView vkDestroyBufferView vkCreateImage vkDestroyImage vkGetImageSubresourceLayout vkCreateImageView vkDestroyImageView vkDestroyShaderModule vkCreateShader vkDestroyShader vkCreatePipelineCache vkDestroyPipelineCache vkGetPipelineCacheSize vkGetPipelineCacheData vkMergePipelineCaches vkCreateGraphicsPipelines vkCreateComputePipelines vkDestroyPipeline vkCreatePipelineLayout vkDestroyPipelineLayout vkCreateSampler vkDestroySampler vkCreateDescriptorSetLayout vkDestroyDescriptorSetLayout vkCreateDescriptorPool vkDestroyDescriptorPool vkResetDescriptorPool vkAllocDescriptorSets vkFreeDescriptorSets vkUpdateDescriptorSets vkCreateDynamicViewportState vkDestroyDynamicViewportState vkCreateDynamicLineWidthState vkDestroyDynamicLineWidthState vkCreateDynamicDepthBiasState vkDestroyDynamicDepthBiasState vkCreateDynamicBlendState vkDestroyDynamicBlendState vkCreateDynamicDepthBiasState vkDestroyDynamicDepthBiasState vkCreateDynamicStencilState vkDestroyDynamicStencilState vkCreateFramebuffer vkDestroyFramebuffer vkCreateRenderPass vkDestroyRenderPass vkGetRenderAreaGranularity vkCreateCommandPool vkDestroyCommandPool vkResetCommandPool vkCreateCommandBuffer vkDestroyCommandBuffer vkBeginCommandBuffer vkEndCommandBuffer vkResetCommandBuffer vkCmdBindPipeline vkCmdBindDynamicViewportState vkCmdBindDynamicBlendState vkCmdBindDynamicLineWidthState vkCmdBindDynamicDepthBiasState vkCmdBindDynamicDepthBoundsState vkCmdBindDynamicStencilState vkCmdBindDescriptorSets vkCmdBindIndexBuffer vkCmdBindVertexBuffers vkCmdDraw vkCmdDrawIndexed vkCmdDrawIndirect vkCmdDrawIndexedIndirect vkCmdDispatch vkCmdDispatchIndirect vkCmdCopyBuffer vkCmdCopyImage vkCmdBlitImage vkCmdCopyBufferToImage vkCmdCopyImageToBuffer vkCmdUpdateBuffer vkCmdFillBuffer vkCmdClearColorImage vkCmdClearDepthStencilImage vkCmdClearColorAttachment vkCmdClearDepthStencilAttachment vkCmdResolveImage vkCmdSetEvent vkCmdResetEvent vkCmdWaitEvents vkCmdPipelineBarrier vkCmdBeginQuery vkCmdEndQuery vkCmdResetQueryPool vkCmdWriteTimestamp vkCmdCopyQueryPoolResults vkCmdPushConstants vkCmdBeginRenderPass vkCmdNextSubpass vkCmdEndRenderPass vkCmdExecuteCommandsTBDNA
NAEnum used for informational messagesNONENANone

ParamChecker Pending Work

Additional work to be done

  1. Source2 was creating a VK_FORMAT_R8_SRGB texture (and image view) which was not supported by the underlying implementation (rendersystemtest imageformat test). Checking that formats are supported by the implementation is something the validation layer could do using the VK_FORMAT_INFO_TYPE_PROPERTIES query. There are probably a bunch of checks here you could be doing around vkCreateImage formats along with whether image/color/depth attachment views are valid. I’m not sure how much of this is already there.
  2. From AMD: we were using an image view with a swizzle of VK_CHANNEL_FORMAT_A with a BC1_RGB texture, which is not valid because the texture does not have an alpha channel. In general, should validate that the swizzles do not reference components not in the texture format.
  3. When querying VK_PHYSICAL_DEVICE_INFO_TYPE_QUEUE_PROPERTIES must provide enough memory for a all the queues on the device (not just 1 when device has multiple queues).
  4. INT & FLOAT bordercolors. Border color int/float selection must match associated texture format.
  5. Flag error on VkBufferCreateInfo if buffer size is 0
  6. VkImageViewCreateInfo.format must be set

Image

Image Overview

The Image layer is responsible for validating format-related information and enforcing format restrictions.

Image Details Table

DETAILS TABLE PENDING

CheckOverviewENUMRelevant APITestnameNotes/TODO
Image FormatVerifies returned format to ensure that it is a supported Vulkan formatNAvkCreateImage vkCreateRenderPassTBDNA
Image FormatValidates that attachment image layouts, loadOps, and storeOps are valid Vulkan values; Verifies that if there is no depth attachment then the subpass attachment is set to VK_ATTACHMENT_UNUSEDNAvkCreateRenderPassTBDNA

Image Pending Work

Additional work to be done

MemTracker

MemTracker Overview

The MemTracker layer tracks memory objects and references and validates that they are managed correctly by the application. This includes tracking object bindings, memory hazards, and memory object lifetimes.. MemTracker validates several other hazard-related issues related to command buffers, fences, and memory mapping.

MemTracker Details Table

CheckOverviewENUM MEMTRACK_*Relevant APITestnameNotes/TODO
Valid Command BufferVerifies that the command buffer was properly created and is currently validINVALID_CBvkCmdBindPipeline vkCmdBindDynamicViewportState vkCmdBindDynamicLineWidthState vkCmdBindDynamicDepthBiasState vkCmdBindDynamicBlendState vkCmdBindDynamicDepthBoundsState vkCmdBindDynamicStencilState vkBeginCommandBuffer vkResetCommandBuffer vkDestroyDevice vkFreeMemoryNANA
Valid Memory ObjectVerifies that the memory object was properly created and is currently validINVALID_MEM_OBJvkCmdDrawIndirect vkCmdDrawIndexedIndirect vkCmdDispatchIndirect vkCmdCopyBuffer vkCmdCopyImage vkCmdBlitImage vkCmdCopyBufferToImage vkCmdCopyImageToBuffer vkCmdUpdateBuffer vkCmdFillBuffer vkCmdClearColorImage vkCmdClearDepthStencilImage vkCmdResolveImage vkFreeMemory vkBindBufferMemory vkBindImageMemory vkQueueBindSparseImageOpaqueMemory vkQueueBindSparseImageMemory vkQueueBindSparseBufferMemoryNANA
Free Referenced MemoryChecks to see if memory being freed still has current referencesFREED_MEM_REFvmFreeMemoryFreeBoundMemoryNA
Memory Properly BoundValidate that the memory object referenced in the call was properly created, is currently valid, and is properly bound to the objectMISSING_MEM_BINDINGSvkCmdDrawIndirect vkCmdDrawIndexedIndirect vkCmdDispatchIndirect vkCmdCopyBuffer vkCmdCopyImage vkCmdBlitImage vkCmdCopyBufferToImage vkCmdCopyImageToBuffer vkCmdUpdateBuffer vkCmdFillBuffer vkCmdClearColorImage vkCmdClearDepthStencilImage vkCmdResolveImageNANA
Valid ObjectVerifies that the specified Vulkan object was created properly and is currently validINVALID_OBJECTvkCmdBindPipeline vkCmdBindDynamicViewportState vkCmdBindDynamicLineWidthState vkCmdBindDynamicDepthBiasState vkCmdBindDynamicBlendState vkCmdBindDynamicDepthBoundsState vkCmdBindDynamicStencilState vkCmdDrawIndirect vkCmdDrawIndexedIndirect vkCmdDispatchIndirect vkCmdCopyBuffer vkCmdCopyImage vkCmdBlitImage vkCmdCopyBufferToImage vkCmdCopyImageToBuffer vkCmdUpdateBuffer vkCmdFillBuffer vkCmdClearColorImage vkCmdClearDepthStencilImage vkCmdResolveImageNANA
Bind Invalid MemoryValidate that memory object was correctly created, that the command buffer object was correctly created, and that both are currently valid objects.MEMORY_BINDING_ERRORvkQueueBindSparseImageOpaqueMemory vkQueueBindSparseImageMemory vkQueueBindSparseBufferMemory vkCmdDrawIndirect vkCmdDrawIndexedIndirect vkCmdDispatchIndirect vkCmdCopyBuffer vkCmdCopyImage vkCmdBlitImage vkCmdCopyBufferToImage vkCmdCopyImageToBuffer vkCmdUpdateBuffer vkCmdFillBuffer vkCmdClearColorImage vkCmdClearDepthStencilImage vkCmdResolveImageBindInvalidMemory BindMemoryToDestroyedObjectThis is probably redundant, as these checks are performed at a lower level.
Objects Not DestroyedVerify all objects destroyed at DestroyDevice timeMEMORY_LEAKvkDestroyDeviceNANA
Memory Mapping StateVerifies that mapped memory is CPU-visibleINVALID_STATEvkMapMemoryMapMemWithoutHostVisibleBitNA
Command Buffer SynchronizationCommand Buffer must be complete before BeginCommandBuffer or ResetCommandBuffer can be calledRESET_CB_WHILE_IN_FLIGHTvkBeginCommandBuffer vkResetCommandBufferCallBeginCmdBufferBeforeCompletion CallBeginCmdBufferBeforeCompletionNA
Submitted Fence StatusVerifies that: The fence is not submitted in an already signaled state, and that ResetFences is not called with a fence in an unsignaled stateINVALID_FENCE_STATEvkResetFences vkWaitForFences vkQueueSubmitSubmitSignaledFence ResetUnsignaledFenceNA
Immutable Memory BindingValidates that non-sparse memory bindings are immutable, so objects are not re-boundtREBIND_OBJECTvkBindBufferMemory, vkBindImageMemoryRebindMemoryNA
Image/Buffer Usage bitsVerify correct USAGE bits set based on how Images and Buffers are usedINVALID_USAGE_FLAGvkCreateImage, vkCreateBuffer, vkCreateBufferView, vkCmdCopyBuffer, vkCmdCopyImage, vkCmdBlitImage, vkCmdCopyBufferToImage, vkCmdCopyImageToBuffer, vkCmdUpdateBuffer, vkCmdFillBufferInvalidUsageBitsNA
Objects Not Destroyed WarningWarns if any memory objects have not been freed before their objects are destroyedMEM_OBJ_CLEAR_EMPTY_BINDINGSvkDestroyDeviceTBDNA
NAEnum used for informational messagesNONENANone
NAEnum used for errors in the layer itself. This does not indicate an app issue, but instead a bug in the layer.INTERNAL_ERRORNANone

MemTracker Pending Work

MemTracker Enhancements

  1. Flag any memory hazards: Validate that the pipeline barriers for buffers are sufficient to avoid hazards
  2. Make sure that the XGL_IMAGE_VIEW_ATTACH_INFO.layout matches the layout of the image as determined by the last IMAGE_MEMORY_BARRIER
  3. Verify that the XGL_IMAGE_MEMORY_BARRIER.oldLayout matches the actual previous layout (this one was super important for previous work in dealing with out-of-order command buffer generation). Note that these need to be tracked for each subresource.
  4. Update for new Memory Binding Model
  5. Consolidate error messages and make them consistent
  6. Add validation for having mapped objects in a command list - GPU writing to mapped object is warning
  7. Add validation for maximum memory references, maximum object counts, and object leaks
  8. When performing clears on surfaces that have both Depth and Stencil, WARN user if subresource range for depth and stencil are not both set (see blit_tests.cpp VkCmdClearDepthStencilTest test).
  9. Re-enable INFO messages that were disabled during v138 integration
  10. Warn on image/buffer deletion if USAGE bits were set that were not needed
  11. Modify INVALID_FENCE_STATE to be WARNINGs instead of ERROR
  12. Report destroy or modify of resources in use on queues and not cleared by fence or WaitIdle. Could be fence, semaphore, or objects used by submitted CommandBuffers.

ShaderChecker

ShaderChecker Overview

The ShaderChecker layer inspects the SPIR-V shader images and fixed function pipeline stages at PSO creation time. It flags errors when inconsistencies are found across interfaces between shader stages. The exact behavior of the checks depends on the pair of pipeline stages involved.

ShaderChecker Details Table

CheckOverviewENUM SHADER_CHECKER_*Relevant APITestnameNotes/TODO
Not consumedFlag warning if a location is not consumed (useless work)OUTPUT_NOT_CONSUMEDvkCreateGraphicsPipelinesCreatePipeline*NotConsumedNA
Not producedFlag error if a location is not produced (consumer reads garbage)INPUT_NOT_PRODUCEDvkCreateGraphicsPipelinesCreatePipeline*NotProvidedNA
Type mismatchFlag error if a location has inconsistent typesINTERFACE_TYPE_MISMATCHvkCreateGraphicsPipelinesCreatePipeline*TypeMismatchBetween shader stages, an exact structural type match is required. Between VI and VS, or between FS and CB, only the basic component type must match (float for UNORM/SNORM/FLOAT, int for SINT, uint for UINT) as the VI and CB stages perform conversions to the exact format.
Inconsistent shaderFlag error if an inconsistent SPIR-V image is detected. Possible cases include broken type definitions which the layer fails to walk.INCONSISTENT_SPIRVvkCreateGraphicsPipelinesTODOAll current tests use the reference compiler to produce valid SPIRV images from GLSL.
Non-SPIRV shaderFlag warning if a non-SPIR-V shader image is detected. This can occur if early drivers are ingesting GLSL. ShaderChecker cannot analyze non-SPIRV shaders, so this suppresses most other checks.NON_SPIRV_SHADERvkCreateGraphicsPipelinesTODONA
FS mixed broadcastFlag error if the fragment shader writes both the legacy gl_FragCoord (which broadcasts to all CBs) and custom FS outputs.FS_MIXED_BROADCASTvkCreateGraphicsPipelinesTODOReference compiler refuses to compile shaders which do this
VI Binding DescriptionsValidate that there is a single vertex input binding description for each bindingINCONSISTENT_VIvkCreateGraphicsPipelinesCreatePipelineAttribBindingConflictNA
Shader Stage CheckWarns if shader stage is unsupportedUNKNOWN_STAGEvkCreateGraphicsPipelinesTBDNA
NAEnum used for informational messagesNONENANone

ShaderChecker Pending Work

  • Additional test cases for variously broken SPIRV images
  • Validation of a single SPIRV image in isolation (the spec describes many constraints)
  • Validation of SPIRV use of descriptors against the declared descriptor set layout

ObjectTracker

ObjectTracker Overview

The ObjectTracker layer maintains a record of all Vulkan objects. It flags errors when invalid objects are used and at DestroyInstance time it flags any objects that were not properly destroyed.

ObjectTracker Details Table

CheckOverviewENUM OBJTRACK_*Relevant APITestnameNotes/TODO
Valid ObjectValidates that referenced object was properly created and is currently valid.INVALID_OBJECTvkAcquireNextImageKHR vkAllocDescriptorSets vkAllocMemory vkBeginCommandBuffer vkBindBufferMemory vkBindImageMemory vkCmdBeginQuery vkCmdBeginRenderPass vkCmdBindDescriptorSets vkCmdBindDynamicViewportState vkCmdBindDynamicLineWidthState vkCmdBindDynamicDepthBiasState vkCmdBindDynamicBlendState vkCmdBindDynamicDepthBoundsState vkCmdBindDynamicStencilState vkCmdBindIndexBuffer vkCmdBindPipeline vkCmdBindVertexBuffers vkCmdBlitImage vkCmdClearColorAttachment vkCmdClearColorImage vkCmdClearDepthStencilAttachment vkCmdClearDepthStencilImage vkCmdCopyBuffer vkCmdCopyBufferToImage vkCmdCopyImage vkCmdCopyImageToBuffer vkCmdCopyQueryPoolResults vkCmdDispatch vkCmdDispatchIndirect vkCmdDraw vkCmdDrawIndexed vkCmdDrawIndexedIndirect vkCmdDrawIndirect vkCmdEndQuery vkCmdEndRenderPass vkCmdExecuteCommands vkCmdFillBuffer vkCmdNextSubpass vkCmdPipelineBarrier vkCmdPushConstants vkCmdResetEvent vkCmdResetQueryPool vkCmdResolveImage vkCmdSetEvent vkCmdUpdateBuffer vkCmdWaitEvents vkCmdWriteTimestamp vkCreateBuffer vkCreateBufferView vkCreateCommandBuffer vkCreateCommandPool vkCreateComputePipelines vkCreateDescriptorPool vkCreateDescriptorSetLayout vkCreateDynamicViewportState vkCreateDynamicLineWidthState vkCreateDynamicDepthBiasState vkCreateDynamicBlendState vkCreateDynamicDepthBoundsState vkCreateDynamicStencilState vkCreateEvent vkCreateFence vkCreateFramebuffer vkCreateGraphicsPipelines vkCreateImage vkCreateImageView vkCreatePipelineCache vkCreatePipelineLayout vkCreateQueryPool vkCreateRenderPass vkCreateSampler vkCreateSemaphore vkCreateShader vkCreateShaderModule vkCreateSwapchainKHR vkDestroyBuffer vkDestroyBufferView vkDestroyCommandBuffer vkDestroyCommandPool vkDestroyDescriptorPool vkDestroyDescriptorSetLayout vkDestroyDynamicBlendState vkDestroyDynamicLineWidthState vkDestroyDynamicDepthBiasState vkDestroyDynamicDepthBoundsState vkDestroyDynamicStencilState vkDestroyDynamicViewportState vkDestroyEvent vkDestroyFence vkDestroyFramebuffer vkDestroyImage vkDestroyImageView vkDestroyPipeline vkDestroyPipelineCache vkDestroyPipelineLayout vkDestroyQueryPool vkDestroyRenderPass vkDestroySampler vkDestroySemaphore vkDestroyShader vkDestroyShaderModule vkDestroySwapchainKHR vkDeviceWaitIdle vkEndCommandBuffer vkEnumeratePhysicalDevices vkFreeDescriptorSets vkFreeMemory vkFreeMemory vkGetBufferMemoryRequirements vkGetDeviceMemoryCommitment vkGetDeviceQueue vkGetEventStatus vkGetFenceStatus vkGetImageMemoryRequirements vkGetImageSparseMemoryRequirements vkGetImageSubresourceLayout vkGetPhysicalDeviceSurfaceSupportKHR vkGetPipelineCacheData vkGetPipelineCacheSize vkGetQueryPoolResults vkGetRenderAreaGranularity vkInvalidateMappedMemoryRanges vkMapMemory vkMergePipelineCaches vkQueueBindSparseBufferMemory vkQueueSignalSemaphore vkQueueWaitSemaphore vkResetCommandBuffer vkResetCommandPool vkResetDescriptorPool vkResetEvent vkResetFences vkSetEvent vkUnmapMemory vkUpdateDescriptorSets vkWaitForFences?Every VkObject class of parameter will be run through this check. This check may ultimately supersede UNKNOWN_OBJECT
Object CleanupVerify that object properly destroyedDESTROY_OBJECT_FAILEDvkDestroyInstance, vkDestroyDevice, vkFreeMemory?NA
Objects LeakWhen an Instance or Device object is destroyed, validates that all objects belonging to that device/instance have previously been destroyedOBJECT_LEAKvkDestroyDevice vkDestroyInstance?NA
Object CountFlag error if number of objects requested from extenstion functions exceeds max number of actual objectsOBJCOUNT_MAX_EXCEEDEDobjTrackGetObjects objTrackGetObjectsOfType?NA
Valid Fence for WaitFlag error if waiting on unsubmitted fence objectINVALID_FENCEvkGetFenceStatusWaitForUnsubmittedFenceNA
Valid Destroy ObjectValidates that an object pass into a destroy function was properly created and is currently validNONEvkDestroyInstance vkDestroyDevice vkDestroyFence vkDestroySemaphore vkDestroyEvent vkDestroyQueryPool vkDestroyBuffer vkDestroyBufferView vkDestroyImage vkDestroyImageView vkDestroyShaderModule vkDestroyShader vkDestroyPipelineCache vkDestroyPipeline vkDestroyPipelineLayout vkDestroySampler vkDestroyDescriptorSetLayout vkDestroyDescriptorPool vkDestroyDynamicViewportState vkDestroyDynamicBlendState vkDestroyDynamicLineWidthState vkDestroyDynamicDepthBiasState vkDestroyDynamicDepthBoundsState vkDestroyDynamicStencilState vkDestroyCommandPool vkDestroyCommandBuffer vkDestroyFramebuffer vkDestroyRenderPass vkDestroySwapchainKHRTBDThese cases need to be moved to a more appropriate error enum
Unknown objectInternal layer errors when it attempts to update use count for an object that's not in its internal tracking datastructures.UNKNOWN_OBJECTNAThis may be irrelevant due to INVALID_OBJECT error, need to look closely and merge this with that error as appropriate.
NAEnum used for informational messagesNONENANone
NAEnum used for errors in the layer itself. This does not indicate an app issue, but instead a bug in the layer.INTERNAL_ERRORNANone

ObjectTracker Pending Work

  1. Verify images have CmdPipelineBarrier layouts matching new layout parameters to CmdImage functions
  2. For specific object instances that are allowed to be NULL, update object validation to verify that such objects are either NULL or valid
  3. Verify cube array VkImageView objects use subresourceRange.arraySize (or effective arraySize when VK_REMAINING_ARRAY_SLICES is specified) that is a multiple of 6.

Threading

Threading Overview

The Threading layer checks for simultaneous use of objects by calls from multiple threads. Application code is responsible for preventing simultaneous use of the same objects by certain calls that modify objects. See bug 13433 and https://cvs.khronos.org/svn/repos/oglc/trunk/nextgen/vulkan/function_properties.csv for threading rules. Objects that may need a mutex include VkQueue, VkDeviceMemory, VkObject, VkBuffer, VkImage, VkDescriptorSet, VkDescriptorPool, VkCmdBuffer, and VkSemaphore. The most common case is that a VkCmdBuffer passed to VkCmd* calls must be used by only one thread at a time.

In addition to reporting threading rule violations, the layer will enforce a mutex for those calls. That can allow an application to continue running without actually crashing due to the reported threading problem.

The layer can only observe when a mutual exclusion rule is actually violated. It cannot insure that there is no latent race condition needing mutual exclusion.

The layer can also catch reentrant use of the same object by calls from a single thread. That might happen if Vulkan calls are made from a callback function or a signal handler. But the layer cannot prevent such a reentrant use of an object.

The layer can only observe when a mutual exclusion rule is actually violated. It cannot insure that there is no latent race condition.

Threading Details Table

CheckOverviewENUM THREADING_CHECKER_*Relevant APITestnameNotes/TODO
Thread CollisionDetects and notifies user if multiple threads are modifying thes same objectMULTIPLE_THREADSvkQueueSubmit vkFreeMemory vkMapMemory vkUnmapMemory vkFlushMappedMemoryRanges vkInvalidateMappedMemoryRanges vkBindBufferMemory vkBindImageMemory vkQueueBindSparseBufferMemory vkQueueBindSparseImageOpaqueMemory vkQueueBindSparseImageMemory vkDestroySemaphore vkQueueSignalSemaphore vkDestroyBuffer vkDestroyImage vkDestroyDescriptorPool vkResetDescriptorPool vkAllocDescriptorSets vkFreeDescriptorSets vkDestroyCommandBuffer vkBeginCommandBuffer vkEndCommandBuffer vkResetCommandBuffer vkCmdBindPipeline vkCmdBindDynamicViewportState vkCmdBindDynamicBlendState vkCmdBindDynamicLineWidthState vkCmdBindDynamicDepthBiasState vkCmdBindDynamicDepthBoundsState vkCmdBindDynamicStencilState vkCmdBindDescriptorSets vkCmdBindIndexBuffer vkCmdBindVertexBuffers vkCmdDraw vkCmdDrawIndexed vkCmdDrawIndirect vkCmdDrawIndexedIndirect vkCmdDispatch vkCmdDispatchIndirect vkCmdCopyBuffer vkCmdCopyImage vkCmdBlitImage vkCmdCopyBufferToImage vkCmdCopyImageToBuffer vkCmdUpdateBuffer vkCmdFillBuffer vkCmdClearColorImage vkCmdClearDepthStencilImage vkCmdClearColorAttachment vkCmdClearDepthStencilAttachment vkCmdResolveImage vkCmdSetEvent vkCmdResetEvent vkCmdWaitEvents vkCmdPipelineBarrier vkCmdBeginQuery vkCmdEndQuery vkCmdResetQueryPool vkCmdWriteTimestamp vkCmdCopyQueryPoolResults vkCmdBeginRenderPass vkCmdNextSubpass vkCmdPushConstants vkCmdEndRenderPass vkCmdExecuteCommands???NA
Thread ReentrancyDetects cases of a single thread calling Vulkan reentrantlySINGLE_THREAD_REUSEvkQueueSubmit vkFreeMemory vkMapMemory vkUnmapMemory vkFlushMappedMemoryRanges vkInvalidateMappedMemoryRanges vkBindBufferMemory vkBindImageMemory vkQueueBindSparseBufferMemory vkQueueBindSparseImageOpaqueMemory vkQueueBindSparseImageMemory vkDestroySemaphore vkQueueSignalSemaphore vkDestroyBuffer vkDestroyImage vkDestroyDescriptorPool vkResetDescriptorPool vkAllocDescriptorSets vkFreeDescriptorSets vkDestroyCommandBuffer vkBeginCommandBuffer vkEndCommandBuffer vkResetCommandBuffer vkCmdBindPipeline vkCmdBindDynamicViewportState vkCmdBindDynamicBlendState vkCmdBindDynamicLineWidthState vkCmdBindDynamicDepthBiasState vkCmdBindDynamicDepthBoundsState vkCmdBindDynamicStencilState vkCmdBindDescriptorSets vkCmdBindIndexBuffer vkCmdBindVertexBuffers vkCmdDraw vkCmdDrawIndexed vkCmdDrawIndirect vkCmdDrawIndexedIndirect vkCmdDispatch vkCmdDispatchIndirect vkCmdCopyBuffer vkCmdCopyImage vkCmdBlitImage vkCmdCopyBufferToImage vkCmdCopyImageToBuffer vkCmdUpdateBuffer vkCmdFillBuffer vkCmdClearColorImage vkCmdClearDepthStencilImage vkCmdClearColorAttachment vkCmdClearDepthStencilAttachment vkCmdResolveImage vkCmdSetEvent vkCmdResetEvent vkCmdWaitEvents vkCmdPipelineBarrier vkCmdBeginQuery vkCmdEndQuery vkCmdResetQueryPool vkCmdWriteTimestamp vkCmdCopyQueryPoolResults vkCmdBeginRenderPass vkCmdNextSubpass vkCmdPushConstants vkCmdEndRenderPass vkCmdExecuteCommands???NA
NAEnum used for informational messagesNONENANone

Threading Pending Work

Additional work to be done

Device Limitations

Device Limitations Overview

This layer is a work in progress. DeviceLimits layer is intended to capture two broad categories of errors:

  1. Incorrect use of APIs to query device capabilities
  2. Attempt to use API functionality beyond the capability of the underlying device

For the first category, the layer tracks which calls are made and flags errors if calls are excluded that should not be, or if call sequencing is incorrect. An example is an app that assumes attempts to Query and use queues without ever having called vkGetPhysicalDeviceQueueFamilyProperties(). Also, if an app is calling vkGetPhysicalDeviceQueueFamilyProperties() to retrieve properties with some assumed count for array size instead of first calling vkGetPhysicalDeviceQueueFamilyProperties() w/ a NULL pQueueFamilyProperties parameter in order to query the actual count. For the second category of errors, DeviceLimits stores its own internal record of underlying device capabilities and flags errors if requests are made beyond those limits. Most (all?) of the limits are queried via vkGetPhysicalDevice* calls.

Device Limitations Details Table

CheckOverviewENUM DEVLIMITS_*Relevant APITestnameNotes/TODO
Valid instanceIf an invalid instance is used, this error will be flaggedINVALID_INSTANCEvkEnumeratePhysicalDevicesNAObjectTracker should also catch this so if we made sure ObjectTracker was always on top, we could avoid this check
Valid physical deviceEnum used for informational messagesINVALID_PHYSICAL_DEVICEvkEnumeratePhysicalDevicesNAObjectTracker should also catch this so if we made sure ObjectTracker was always on top, we could avoid this check
Querying array countsFor API calls where an array count should be queried with an initial call and a NULL array pointer, verify that such a call was made before making a call with non-null array pointer.MUST_QUERY_COUNTvkEnumeratePhysicalDevices vkGetPhysicalDeviceQueueFamilyPropertiesNACreate focused test
Array count valueFor API calls where an array of details is queried, verify that the size of the requested array matches the size of the array supported by the device.COUNT_MISMATCHvkEnumeratePhysicalDevices vkGetPhysicalDeviceQueueFamilyPropertiesNACreate focused test
Queue CreationWhen creating/requesting queues, make sure that QueueFamilyPropertiesIndex and index/count within that queue family are valid.INVALID_QUEUE_CREATE_REQUESTvkGetDeviceQueue vkCreateDeviceNACreate focused test
NAEnum used for informational messagesNONENANone

Device Limitations Pending Work

  1. For all Formats, call vkGetPhysicalDeviceFormatProperties to pull their properties for the underlying device. After that point, if the app attempts to use any formats in violation of those properties, flag errors.

Non-validation Layer Details

APIDump

APIDump layer is used for dumping a stream of all the Vulkan API calls that are made, along with details of the parameters to those calls.

APIDump Pending Work

  1. vkAllocDescriptorSets does not correctly print out all of the created DescriptorSets (no array printing following main API txt)

General Pending Work

A place to capture general validation work to be done. This includes new checks that don't clearly fit into the above layers.

  1. For Upcoming Dynamic State overhaul (if approved): If dynamic state value that is consumed is never set prior to consumption, flag an error
  2. For Upcoming Dynamic State overhaul (if approved): If dynamic state that was bound as "static" in current PSO is attempted to be set with vkCmdSet* flag an error
  3. Need a WSI validation layer(s) to validate correct usage of WSI API. One issue that has already come up is correct UsageFlags for WSI SwapChains and SurfaceProperties. Tons of other stuff including semaphore and synchronization validation.