diff options
author | Jason Ekstrand <jason@jlekstrand.net> | 2019-08-09 15:45:26 -0500 |
---|---|---|
committer | Mark Lobodzinski <mark@lunarg.com> | 2019-08-16 10:07:18 -0600 |
commit | 3c18a6857f0bc151bed9844059f2cd62feb04428 (patch) | |
tree | 480a90ed9417c691c8509c23c4755ac2c7a3e23b | |
parent | 00bfb64464ae85057ed9c145a0472e1cec8c3196 (diff) | |
download | vulkan-validation-layers-3c18a6857f0bc151bed9844059f2cd62feb04428.tar.gz |
layers: Validate VK_KHR_pipeline_executable_properties
-rw-r--r-- | layers/core_validation.cpp | 83 | ||||
-rw-r--r-- | layers/core_validation.h | 11 | ||||
-rw-r--r-- | layers/core_validation_types.h | 12 |
3 files changed, 106 insertions, 0 deletions
diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp index 83e82c012..502f4c296 100644 --- a/layers/core_validation.cpp +++ b/layers/core_validation.cpp @@ -2594,6 +2594,12 @@ void ValidationStateTracker::PostCallRecordCreateDevice(VkPhysicalDevice gpu, co state_tracker->enabled_features.imageless_framebuffer_features = *imageless_framebuffer_features; } + const auto *pipeline_exe_props_features = + lvl_find_in_chain<VkPhysicalDevicePipelineExecutablePropertiesFeaturesKHR>(pCreateInfo->pNext); + if (pipeline_exe_props_features) { + state_tracker->enabled_features.pipeline_exe_props_features = *pipeline_exe_props_features; + } + // Store physical device properties and physical device mem limits into CoreChecks structs DispatchGetPhysicalDeviceMemoryProperties(gpu, &state_tracker->phys_dev_mem_props); DispatchGetPhysicalDeviceProperties(gpu, &state_tracker->phys_dev_props); @@ -5282,6 +5288,83 @@ void CoreChecks::PostCallRecordCreateRayTracingPipelinesNV(VkDevice device, VkPi } } +bool CoreChecks::PreCallValidateGetPipelineExecutablePropertiesKHR(VkDevice device, const VkPipelineInfoKHR *pPipelineInfo, + uint32_t *pExecutableCount, + VkPipelineExecutablePropertiesKHR *pProperties) { + bool skip = false; + + if (!enabled_features.pipeline_exe_props_features.pipelineExecutableInfo) { + skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, HandleToUint64(device), + "VUID-vkGetPipelineExecutablePropertiesKHR-pipelineExecutableProperties-03270", + "vkGetPipelineExecutablePropertiesKHR called when pipelineExecutableInfo feature is not enabled."); + } + + return skip; +} + +bool CoreChecks::ValidatePipelineExecutableInfo(VkDevice device, const VkPipelineExecutableInfoKHR *pExecutableInfo) const { + bool skip = false; + + if (!enabled_features.pipeline_exe_props_features.pipelineExecutableInfo) { + skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, HandleToUint64(device), + "VUID-vkGetPipelineExecutableStatisticsKHR-pipelineExecutableInfo-03272", + "vkGetPipelineExecutableStatisticsKHR called when pipelineExecutableInfo feature is not enabled."); + } + + VkPipelineInfoKHR pi = {}; + pi.sType = VK_STRUCTURE_TYPE_PIPELINE_INFO_KHR; + pi.pipeline = pExecutableInfo->pipeline; + + // We could probably cache this instead of fetching it every time + uint32_t executableCount = 0; + DispatchGetPipelineExecutablePropertiesKHR(device, &pi, &executableCount, NULL); + + if (pExecutableInfo->executableIndex >= executableCount) { + skip |= + log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, + HandleToUint64(pExecutableInfo->pipeline), "VUID-VkPipelineExecutableInfoKHR-executableIndex-03275", + "VkPipelineExecutableInfo::executableIndex (%1u) must be less than the number of executables associated with " + "the pipeline (%1u) as returned by vkGetPipelineExecutablePropertiessKHR", + pExecutableInfo->executableIndex, executableCount); + } + + return skip; +} + +bool CoreChecks::PreCallValidateGetPipelineExecutableStatisticsKHR(VkDevice device, + const VkPipelineExecutableInfoKHR *pExecutableInfo, + uint32_t *pStatisticCount, + VkPipelineExecutableStatisticKHR *pStatistics) { + bool skip = ValidatePipelineExecutableInfo(device, pExecutableInfo); + + const PIPELINE_STATE *pipeline_state = GetPipelineState(pExecutableInfo->pipeline); + if (!(pipeline_state->getPipelineCreateFlags() & VK_PIPELINE_CREATE_CAPTURE_STATISTICS_BIT_KHR)) { + skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, + HandleToUint64(pExecutableInfo->pipeline), "VUID-vkGetPipelineExecutableStatisticsKHR-pipeline-03274", + "vkGetPipelineExecutableStatisticsKHR called on a pipeline created without the " + "VK_PIPELINE_CREATE_CAPTURE_STATISTICS_BIT_KHR flag set"); + } + + return skip; +} + +bool CoreChecks::PreCallValidateGetPipelineExecutableInternalRepresentationsKHR( + VkDevice device, const VkPipelineExecutableInfoKHR *pExecutableInfo, uint32_t *pInternalRepresentationCount, + VkPipelineExecutableInternalRepresentationKHR *pStatistics) { + bool skip = ValidatePipelineExecutableInfo(device, pExecutableInfo); + + const PIPELINE_STATE *pipeline_state = GetPipelineState(pExecutableInfo->pipeline); + if (!(pipeline_state->getPipelineCreateFlags() & VK_PIPELINE_CREATE_CAPTURE_INTERNAL_REPRESENTATIONS_BIT_KHR)) { + skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, + HandleToUint64(pExecutableInfo->pipeline), + "VUID-vkGetPipelineExecutableInternalRepresentationsKHR-pipeline-03278", + "vkGetPipelineExecutableInternalRepresentationsKHR called on a pipeline created without the " + "VK_PIPELINE_CREATE_CAPTURE_INTERNAL_REPRESENTATIONS_BIT_KHR flag set"); + } + + return skip; +} + void ValidationStateTracker::PostCallRecordCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSampler *pSampler, VkResult result) { diff --git a/layers/core_validation.h b/layers/core_validation.h index ff97069e4..26f2f9b0e 100644 --- a/layers/core_validation.h +++ b/layers/core_validation.h @@ -1527,6 +1527,17 @@ class CoreChecks : public ValidationStateTracker { const VkComputePipelineCreateInfo* pCreateInfos, const VkAllocationCallbacks* pAllocator, VkPipeline* pPipelines, VkResult result, void* pipe_state); + bool PreCallValidateGetPipelineExecutablePropertiesKHR(VkDevice device, const VkPipelineInfoKHR* pPipelineInfo, + uint32_t* pExecutableCount, + VkPipelineExecutablePropertiesKHR* pProperties); + bool ValidatePipelineExecutableInfo(VkDevice device, const VkPipelineExecutableInfoKHR* pExecutableInfo) const; + bool PreCallValidateGetPipelineExecutableStatisticsKHR(VkDevice device, const VkPipelineExecutableInfoKHR* pExecutableInfo, + uint32_t* pStatisticCount, + VkPipelineExecutableStatisticKHR* pStatistics); + bool PreCallValidateGetPipelineExecutableInternalRepresentationsKHR(VkDevice device, + const VkPipelineExecutableInfoKHR* pExecutableInfo, + uint32_t* pInternalRepresentationCount, + VkPipelineExecutableInternalRepresentationKHR* pStatistics); bool PreCallValidateCreatePipelineLayout(VkDevice device, const VkPipelineLayoutCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkPipelineLayout* pPipelineLayout); void PreCallRecordCreatePipelineLayout(VkDevice device, const VkPipelineLayoutCreateInfo* pCreateInfo, diff --git a/layers/core_validation_types.h b/layers/core_validation_types.h index 46d60abac..266a0af84 100644 --- a/layers/core_validation_types.h +++ b/layers/core_validation_types.h @@ -1199,6 +1199,17 @@ class PIPELINE_STATE : public BASE_NODE { else return VK_PIPELINE_BIND_POINT_MAX_ENUM; } + + inline VkPipelineCreateFlags getPipelineCreateFlags() const { + if (graphicsPipelineCI.sType == VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO) + return graphicsPipelineCI.flags; + else if (computePipelineCI.sType == VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO) + return computePipelineCI.flags; + else if (raytracingPipelineCI.sType == VK_STRUCTURE_TYPE_RAY_TRACING_PIPELINE_CREATE_INFO_NV) + return raytracingPipelineCI.flags; + else + return 0; + } }; // Track last states that are bound per pipeline bind point (Gfx & Compute) @@ -1550,6 +1561,7 @@ struct DeviceFeatures { VkPhysicalDeviceShaderDemoteToHelperInvocationFeaturesEXT demote_to_helper_invocation_features; VkPhysicalDeviceTexelBufferAlignmentFeaturesEXT texel_buffer_alignment_features; VkPhysicalDeviceImagelessFramebufferFeaturesKHR imageless_framebuffer_features; + VkPhysicalDevicePipelineExecutablePropertiesFeaturesKHR pipeline_exe_props_features; }; enum RenderPassCreateVersion { RENDER_PASS_VERSION_1 = 0, RENDER_PASS_VERSION_2 = 1 }; |