diff options
Diffstat (limited to 'layers/buffer_validation.cpp')
| -rw-r--r-- | layers/buffer_validation.cpp | 63 |
1 files changed, 30 insertions, 33 deletions
diff --git a/layers/buffer_validation.cpp b/layers/buffer_validation.cpp index bb13fe8a..1966faf5 100644 --- a/layers/buffer_validation.cpp +++ b/layers/buffer_validation.cpp @@ -442,15 +442,12 @@ void TransitionFinalSubpassLayouts(layer_data *device_data, GLOBAL_CB_NODE *pCB, bool PreCallValidateCreateImage(layer_data *device_data, const VkImageCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkImage *pImage) { bool skip_call = false; - VkImageFormatProperties ImageFormatProperties; - const VkPhysicalDevice physical_device = core_validation::GetPhysicalDevice(device_data); const debug_report_data *report_data = core_validation::GetReportData(device_data); if (pCreateInfo->format != VK_FORMAT_UNDEFINED) { - VkFormatProperties properties; - core_validation::GetFormatPropertiesPointer(device_data)(physical_device, pCreateInfo->format, &properties); + const VkFormatProperties *properties = GetFormatProperties(device_data, pCreateInfo->format); - if ((pCreateInfo->tiling == VK_IMAGE_TILING_LINEAR) && (properties.linearTilingFeatures == 0)) { + if ((pCreateInfo->tiling == VK_IMAGE_TILING_LINEAR) && (properties->linearTilingFeatures == 0)) { std::stringstream ss; ss << "vkCreateImage format parameter (" << string_VkFormat(pCreateInfo->format) << ") is an unsupported format"; skip_call |= @@ -458,7 +455,7 @@ bool PreCallValidateCreateImage(layer_data *device_data, const VkImageCreateInfo VALIDATION_ERROR_02150, "IMAGE", "%s. %s", ss.str().c_str(), validation_error_map[VALIDATION_ERROR_02150]); } - if ((pCreateInfo->tiling == VK_IMAGE_TILING_OPTIMAL) && (properties.optimalTilingFeatures == 0)) { + if ((pCreateInfo->tiling == VK_IMAGE_TILING_OPTIMAL) && (properties->optimalTilingFeatures == 0)) { std::stringstream ss; ss << "vkCreateImage format parameter (" << string_VkFormat(pCreateInfo->format) << ") is an unsupported format"; skip_call |= @@ -469,7 +466,7 @@ bool PreCallValidateCreateImage(layer_data *device_data, const VkImageCreateInfo // Validate that format supports usage as color attachment if (pCreateInfo->usage & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT) { if ((pCreateInfo->tiling == VK_IMAGE_TILING_OPTIMAL) && - ((properties.optimalTilingFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT) == 0)) { + ((properties->optimalTilingFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT) == 0)) { std::stringstream ss; ss << "vkCreateImage: VkFormat for TILING_OPTIMAL image (" << string_VkFormat(pCreateInfo->format) << ") does not support requested Image usage type VK_IMAGE_USAGE_COLOR_ATTACHMENT"; @@ -478,7 +475,7 @@ bool PreCallValidateCreateImage(layer_data *device_data, const VkImageCreateInfo validation_error_map[VALIDATION_ERROR_02158]); } if ((pCreateInfo->tiling == VK_IMAGE_TILING_LINEAR) && - ((properties.linearTilingFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT) == 0)) { + ((properties->linearTilingFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT) == 0)) { std::stringstream ss; ss << "vkCreateImage: VkFormat for TILING_LINEAR image (" << string_VkFormat(pCreateInfo->format) << ") does not support requested Image usage type VK_IMAGE_USAGE_COLOR_ATTACHMENT"; @@ -490,7 +487,7 @@ bool PreCallValidateCreateImage(layer_data *device_data, const VkImageCreateInfo // Validate that format supports usage as depth/stencil attachment if (pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) { if ((pCreateInfo->tiling == VK_IMAGE_TILING_OPTIMAL) && - ((properties.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) { + ((properties->optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) { std::stringstream ss; ss << "vkCreateImage: VkFormat for TILING_OPTIMAL image (" << string_VkFormat(pCreateInfo->format) << ") does not support requested Image usage type VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT"; @@ -499,7 +496,7 @@ bool PreCallValidateCreateImage(layer_data *device_data, const VkImageCreateInfo validation_error_map[VALIDATION_ERROR_02159]); } if ((pCreateInfo->tiling == VK_IMAGE_TILING_LINEAR) && - ((properties.linearTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) { + ((properties->linearTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) { std::stringstream ss; ss << "vkCreateImage: VkFormat for TILING_LINEAR image (" << string_VkFormat(pCreateInfo->format) << ") does not support requested Image usage type VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT"; @@ -515,12 +512,10 @@ bool PreCallValidateCreateImage(layer_data *device_data, const VkImageCreateInfo validation_error_map[VALIDATION_ERROR_00715]); } - // Internal call to get format info. Still goes through layers, could potentially go directly to ICD. - core_validation::GetImageFormatPropertiesPointer(device_data)(physical_device, pCreateInfo->format, pCreateInfo->imageType, - pCreateInfo->tiling, pCreateInfo->usage, pCreateInfo->flags, - &ImageFormatProperties); + const VkImageFormatProperties *ImageFormatProperties = GetImageFormatProperties( + device_data, pCreateInfo->format, pCreateInfo->imageType, pCreateInfo->tiling, pCreateInfo->usage, pCreateInfo->flags); - VkDeviceSize imageGranularity = core_validation::GetPhysicalDeviceProperties(device_data)->limits.bufferImageGranularity; + VkDeviceSize imageGranularity = GetPhysicalDeviceProperties(device_data)->limits.bufferImageGranularity; imageGranularity = imageGranularity == 1 ? 0 : imageGranularity; if ((pCreateInfo->extent.width <= 0) || (pCreateInfo->extent.height <= 0) || (pCreateInfo->extent.depth <= 0)) { @@ -534,16 +529,16 @@ bool PreCallValidateCreateImage(layer_data *device_data, const VkImageCreateInfo // TODO: VALIDATION_ERROR_02125 VALIDATION_ERROR_02126 VALIDATION_ERROR_02128 VALIDATION_ERROR_00720 // All these extent-related VUs should be checked here - if ((pCreateInfo->extent.depth > ImageFormatProperties.maxExtent.depth) || - (pCreateInfo->extent.width > ImageFormatProperties.maxExtent.width) || - (pCreateInfo->extent.height > ImageFormatProperties.maxExtent.height)) { + if ((pCreateInfo->extent.depth > ImageFormatProperties->maxExtent.depth) || + (pCreateInfo->extent.width > ImageFormatProperties->maxExtent.width) || + (pCreateInfo->extent.height > ImageFormatProperties->maxExtent.height)) { skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, 0, __LINE__, IMAGE_INVALID_FORMAT_LIMITS_VIOLATION, "Image", "CreateImage extents exceed allowable limits for format: " "Width = %d Height = %d Depth = %d: Limits for Width = %d Height = %d Depth = %d for format %s.", pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth, - ImageFormatProperties.maxExtent.width, ImageFormatProperties.maxExtent.height, - ImageFormatProperties.maxExtent.depth, string_VkFormat(pCreateInfo->format)); + ImageFormatProperties->maxExtent.width, ImageFormatProperties->maxExtent.height, + ImageFormatProperties->maxExtent.depth, string_VkFormat(pCreateInfo->format)); } uint64_t totalSize = ((uint64_t)pCreateInfo->extent.width * (uint64_t)pCreateInfo->extent.height * @@ -552,33 +547,33 @@ bool PreCallValidateCreateImage(layer_data *device_data, const VkImageCreateInfo (uint64_t)imageGranularity) & ~(uint64_t)imageGranularity; - if (totalSize > ImageFormatProperties.maxResourceSize) { + if (totalSize > ImageFormatProperties->maxResourceSize) { skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, 0, __LINE__, IMAGE_INVALID_FORMAT_LIMITS_VIOLATION, "Image", "CreateImage resource size exceeds allowable maximum " "Image resource size = 0x%" PRIxLEAST64 ", maximum resource size = 0x%" PRIxLEAST64 " ", - totalSize, ImageFormatProperties.maxResourceSize); + totalSize, ImageFormatProperties->maxResourceSize); } // TODO: VALIDATION_ERROR_02132 - if (pCreateInfo->mipLevels > ImageFormatProperties.maxMipLevels) { + if (pCreateInfo->mipLevels > ImageFormatProperties->maxMipLevels) { skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, 0, __LINE__, IMAGE_INVALID_FORMAT_LIMITS_VIOLATION, "Image", "CreateImage mipLevels=%d exceeds allowable maximum supported by format of %d", pCreateInfo->mipLevels, - ImageFormatProperties.maxMipLevels); + ImageFormatProperties->maxMipLevels); } - if (pCreateInfo->arrayLayers > ImageFormatProperties.maxArrayLayers) { + if (pCreateInfo->arrayLayers > ImageFormatProperties->maxArrayLayers) { skip_call |= log_msg( report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, 0, __LINE__, VALIDATION_ERROR_02133, "Image", "CreateImage arrayLayers=%d exceeds allowable maximum supported by format of %d. %s", pCreateInfo->arrayLayers, - ImageFormatProperties.maxArrayLayers, validation_error_map[VALIDATION_ERROR_02133]); + ImageFormatProperties->maxArrayLayers, validation_error_map[VALIDATION_ERROR_02133]); } - if ((pCreateInfo->samples & ImageFormatProperties.sampleCounts) == 0) { + if ((pCreateInfo->samples & ImageFormatProperties->sampleCounts) == 0) { skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, 0, __LINE__, VALIDATION_ERROR_02138, "Image", "CreateImage samples %s is not supported by format 0x%.8X. %s", - string_VkSampleCountFlagBits(pCreateInfo->samples), ImageFormatProperties.sampleCounts, + string_VkSampleCountFlagBits(pCreateInfo->samples), ImageFormatProperties->sampleCounts, validation_error_map[VALIDATION_ERROR_02138]); } @@ -2268,11 +2263,13 @@ bool PreCallValidateCreateImageView(layer_data *device_data, const VkImageViewCr return skip; } -void PostCallRecordCreateImageView(layer_data *device_data, const VkImageViewCreateInfo *create_info, - VkImageView view) { - (*GetImageViewMap(device_data))[view] = std::unique_ptr<IMAGE_VIEW_STATE>(new IMAGE_VIEW_STATE(view, create_info)); - ResolveRemainingLevelsLayers(device_data, &(*GetImageViewMap(device_data))[view].get()->create_info.subresourceRange, - GetImageState(device_data, create_info->image)); +void PostCallRecordCreateImageView(layer_data *device_data, const VkImageViewCreateInfo *create_info, VkImageView view) { + auto image_view_map = GetImageViewMap(device_data); + (*image_view_map)[view] = std::unique_ptr<IMAGE_VIEW_STATE>(new IMAGE_VIEW_STATE(view, create_info)); + + auto image_state = GetImageState(device_data, create_info->image); + auto sub_res_range = (*image_view_map)[view].get()->create_info.subresourceRange; + ResolveRemainingLevelsLayers(device_data, &sub_res_range, image_state); } bool PreCallValidateCmdCopyBuffer(layer_data *device_data, GLOBAL_CB_NODE *cb_node, BUFFER_STATE *src_buffer_state, |
