diff --git a/layers/buffer_validation.cpp b/layers/buffer_validation.cpp index 5386ed7d3c5991611efa35ae1c186f57235d14f5..2b99bda67929b4925b039be7a211a2aa63cc0a44 100644 --- a/layers/buffer_validation.cpp +++ b/layers/buffer_validation.cpp @@ -240,7 +240,7 @@ void SetImageLayout(layer_data *device_data, GLOBAL_CB_NODE *cb_node, const IMAG // TODO: If ImageView was created with depth or stencil, transition both layouts as the aspectMask is ignored and both // are used. Verify that the extra implicit layout is OK for descriptor set layout validation if (image_subresource_range.aspectMask & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) { - if (VkFormatIsDepthAndStencil(image_state->createInfo.format)) { + if (FormatIsDepthAndStencil(image_state->createInfo.format)) { sub.aspectMask |= (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT); } } @@ -301,7 +301,7 @@ bool VerifyFramebufferAndRenderPassLayouts(layer_data *device_data, GLOBAL_CB_NO if (!FindCmdBufLayout(device_data, pCB, image, sub, node)) { // If ImageView was created with depth or stencil, transition both aspects if it's a DS image if (subRange.aspectMask & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) { - if (VkFormatIsDepthAndStencil(view_state->create_info.format)) { + if (FormatIsDepthAndStencil(view_state->create_info.format)) { sub.aspectMask |= (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT); } } @@ -397,13 +397,13 @@ void TransitionImageAspectLayout(layer_data *device_data, GLOBAL_CB_NODE *pCB, c bool VerifyAspectsPresent(VkImageAspectFlags aspect_mask, VkFormat format) { if ((aspect_mask & VK_IMAGE_ASPECT_COLOR_BIT) != 0) { - if (!VkFormatIsColor(format)) return false; + if (!FormatIsColor(format)) return false; } if ((aspect_mask & VK_IMAGE_ASPECT_DEPTH_BIT) != 0) { - if (!VkFormatHasDepth(format)) return false; + if (!FormatHasDepth(format)) return false; } if ((aspect_mask & VK_IMAGE_ASPECT_STENCIL_BIT) != 0) { - if (!VkFormatHasStencil(format)) return false; + if (!FormatHasStencil(format)) return false; } return true; } @@ -694,7 +694,7 @@ bool PreCallValidateCreateImage(layer_data *device_data, const VkImageCreateInfo uint64_t totalSize = ((uint64_t)pCreateInfo->extent.width * (uint64_t)pCreateInfo->extent.height * (uint64_t)pCreateInfo->extent.depth * (uint64_t)pCreateInfo->arrayLayers * - (uint64_t)pCreateInfo->samples * (uint64_t)VkFormatGetSize(pCreateInfo->format) + + (uint64_t)pCreateInfo->samples * (uint64_t)FormatSize(pCreateInfo->format) + (uint64_t)imageGranularity) & ~(uint64_t)imageGranularity; @@ -811,12 +811,12 @@ bool ValidateImageAttributes(layer_data *device_data, IMAGE_STATE *image_state, reinterpret_cast<uint64_t &>(image_state->image), __LINE__, DRAWSTATE_INVALID_IMAGE_ASPECT, "IMAGE", str); } - if (VkFormatIsDepthOrStencil(image_state->createInfo.format)) { + if (FormatIsDepthOrStencil(image_state->createInfo.format)) { char const str[] = "vkCmdClearColorImage called with depth/stencil image."; skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, reinterpret_cast<uint64_t &>(image_state->image), __LINE__, VALIDATION_ERROR_01088, "IMAGE", "%s. %s", str, validation_error_map[VALIDATION_ERROR_01088]); - } else if (VkFormatIsCompressed(image_state->createInfo.format)) { + } else if (FormatIsCompressed(image_state->createInfo.format)) { char const str[] = "vkCmdClearColorImage called with compressed image."; skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, reinterpret_cast<uint64_t &>(image_state->image), __LINE__, VALIDATION_ERROR_01088, "IMAGE", "%s. %s", str, @@ -995,7 +995,7 @@ bool PreCallValidateCmdClearDepthStencilImage(layer_data *device_data, VkCommand (uint64_t)commandBuffer, __LINE__, DRAWSTATE_INVALID_IMAGE_ASPECT, "IMAGE", str); } } - if (image_state && !VkFormatIsDepthOrStencil(image_state->createInfo.format)) { + if (image_state && !FormatIsDepthOrStencil(image_state->createInfo.format)) { char const str[] = "vkCmdClearDepthStencilImage called without a depth/stencil image."; skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, reinterpret_cast<uint64_t &>(image), __LINE__, VALIDATION_ERROR_01103, "IMAGE", "%s. %s", str, @@ -1100,8 +1100,8 @@ static inline VkExtent3D GetScaledItg(layer_data *device_data, const GLOBAL_CB_N if (pPool) { granularity = GetPhysDevProperties(device_data)->queue_family_properties[pPool->queueFamilyIndex].minImageTransferGranularity; - if (VkFormatIsCompressed(img->createInfo.format)) { - auto block_size = VkFormatCompressedTexelBlockExtent(img->createInfo.format); + if (FormatIsCompressed(img->createInfo.format)) { + auto block_size = FormatCompressedTexelBlockExtent(img->createInfo.format); granularity.width *= block_size.width; granularity.height *= block_size.height; } @@ -1112,8 +1112,8 @@ static inline VkExtent3D GetScaledItg(layer_data *device_data, const GLOBAL_CB_N // Test elements of a VkExtent3D structure against alignment constraints contained in another VkExtent3D structure static inline bool IsExtentAligned(const VkExtent3D *extent, const VkExtent3D *granularity) { bool valid = true; - if ((VkSafeModulo(extent->depth, granularity->depth) != 0) || (VkSafeModulo(extent->width, granularity->width) != 0) || - (VkSafeModulo(extent->height, granularity->height) != 0)) { + if ((SafeModulo(extent->depth, granularity->depth) != 0) || (SafeModulo(extent->width, granularity->width) != 0) || + (SafeModulo(extent->height, granularity->height) != 0)) { valid = false; } return valid; @@ -1200,7 +1200,7 @@ static inline bool CheckItgInt(layer_data *device_data, const GLOBAL_CB_NODE *cb const debug_report_data *report_data = core_validation::GetReportData(device_data); bool skip = false; - if (VkSafeModulo(value, granularity) != 0) { + if (SafeModulo(value, granularity) != 0) { skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, reinterpret_cast<uint64_t>(cb_node->commandBuffer), __LINE__, DRAWSTATE_IMAGE_TRANSFER_GRANULARITY, "DS", "%s: pRegion[%d].%s (%d) must be an even integer multiple of this command buffer's queue family image " @@ -1215,7 +1215,7 @@ static inline bool CheckItgSize(layer_data *device_data, const GLOBAL_CB_NODE *c const uint32_t granularity, const uint32_t i, const char *function, const char *member) { const debug_report_data *report_data = core_validation::GetReportData(device_data); bool skip = false; - if (VkSafeModulo(value, granularity) != 0) { + if (SafeModulo(value, granularity) != 0) { skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, reinterpret_cast<uint64_t>(cb_node->commandBuffer), __LINE__, DRAWSTATE_IMAGE_TRANSFER_GRANULARITY, "DS", "%s: pRegion[%d].%s (%" PRIdLEAST64 @@ -1231,7 +1231,7 @@ bool ValidateCopyBufferImageTransferGranularityRequirements(layer_data *device_d const IMAGE_STATE *img, const VkBufferImageCopy *region, const uint32_t i, const char *function) { bool skip = false; - if (VkFormatIsCompressed(img->createInfo.format) == true) { + if (FormatIsCompressed(img->createInfo.format) == true) { // TODO: Add granularity checking for compressed formats // bufferRowLength must be a multiple of the compressed texel block width @@ -1450,8 +1450,8 @@ bool PreCallValidateCmdCopyImage(layer_data *device_data, GLOBAL_CB_NODE *cb_nod // The formats of src_image and dst_image must be compatible. Formats are considered compatible if their texel size in bytes // is the same between both formats. For example, VK_FORMAT_R8G8B8A8_UNORM is compatible with VK_FORMAT_R32_UINT because // because both texels are 4 bytes in size. Depth/stencil formats must match exactly. - if (VkFormatIsDepthOrStencil(src_image_state->createInfo.format) || - VkFormatIsDepthOrStencil(dst_image_state->createInfo.format)) { + if (FormatIsDepthOrStencil(src_image_state->createInfo.format) || + FormatIsDepthOrStencil(dst_image_state->createInfo.format)) { if (src_image_state->createInfo.format != dst_image_state->createInfo.format) { char const str[] = "vkCmdCopyImage called with unmatched source and dest image depth/stencil formats."; skip |= @@ -1459,8 +1459,8 @@ bool PreCallValidateCmdCopyImage(layer_data *device_data, GLOBAL_CB_NODE *cb_nod reinterpret_cast<uint64_t &>(command_buffer), __LINE__, DRAWSTATE_MISMATCHED_IMAGE_FORMAT, "IMAGE", str); } } else { - size_t srcSize = VkFormatGetSize(src_image_state->createInfo.format); - size_t destSize = VkFormatGetSize(dst_image_state->createInfo.format); + size_t srcSize = FormatSize(src_image_state->createInfo.format); + size_t destSize = FormatSize(dst_image_state->createInfo.format); if (srcSize != destSize) { char const str[] = "vkCmdCopyImage called with unmatched source and dest image format sizes."; skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, @@ -1826,7 +1826,7 @@ bool PreCallValidateCmdBlitImage(layer_data *device_data, GLOBAL_CB_NODE *cb_nod VkFormat dst_format = dst_image_state->createInfo.format; // Validate consistency for unsigned formats - if (VkFormatIsUInt(src_format) != VkFormatIsUInt(dst_format)) { + if (FormatIsUInt(src_format) != FormatIsUInt(dst_format)) { std::stringstream ss; ss << "vkCmdBlitImage: If one of srcImage and dstImage images has unsigned integer format, " << "the other one must also have unsigned integer format. " @@ -1837,7 +1837,7 @@ bool PreCallValidateCmdBlitImage(layer_data *device_data, GLOBAL_CB_NODE *cb_nod } // Validate consistency for signed formats - if (VkFormatIsSInt(src_format) != VkFormatIsSInt(dst_format)) { + if (FormatIsSInt(src_format) != FormatIsSInt(dst_format)) { std::stringstream ss; ss << "vkCmdBlitImage: If one of srcImage and dstImage images has signed integer format, " << "the other one must also have signed integer format. " @@ -1848,7 +1848,7 @@ bool PreCallValidateCmdBlitImage(layer_data *device_data, GLOBAL_CB_NODE *cb_nod } // Validate aspect bits and formats for depth/stencil images - if (VkFormatIsDepthOrStencil(src_format) || VkFormatIsDepthOrStencil(dst_format)) { + if (FormatIsDepthOrStencil(src_format) || FormatIsDepthOrStencil(dst_format)) { if (src_format != dst_format) { std::stringstream ss; ss << "vkCmdBlitImage: If one of srcImage and dstImage images has a format of depth, stencil or depth " @@ -1863,7 +1863,7 @@ bool PreCallValidateCmdBlitImage(layer_data *device_data, GLOBAL_CB_NODE *cb_nod for (uint32_t i = 0; i < regionCount; i++) { VkImageAspectFlags srcAspect = pRegions[i].srcSubresource.aspectMask; - if (VkFormatIsDepthAndStencil(src_format)) { + if (FormatIsDepthAndStencil(src_format)) { if ((srcAspect != VK_IMAGE_ASPECT_DEPTH_BIT) && (srcAspect != VK_IMAGE_ASPECT_STENCIL_BIT)) { std::stringstream ss; ss << "vkCmdBlitImage: Combination depth/stencil image formats must have only one of " @@ -1873,7 +1873,7 @@ bool PreCallValidateCmdBlitImage(layer_data *device_data, GLOBAL_CB_NODE *cb_nod reinterpret_cast<uint64_t>(cb_node->commandBuffer), __LINE__, DRAWSTATE_INVALID_IMAGE_ASPECT, "IMAGE", "%s", ss.str().c_str()); } - } else if (VkFormatIsStencilOnly(src_format)) { + } else if (FormatIsStencilOnly(src_format)) { if (srcAspect != VK_IMAGE_ASPECT_STENCIL_BIT) { std::stringstream ss; ss << "vkCmdBlitImage: Stencil-only image formats must have only the VK_IMAGE_ASPECT_STENCIL_BIT " @@ -1882,7 +1882,7 @@ bool PreCallValidateCmdBlitImage(layer_data *device_data, GLOBAL_CB_NODE *cb_nod reinterpret_cast<uint64_t>(cb_node->commandBuffer), __LINE__, DRAWSTATE_INVALID_IMAGE_ASPECT, "IMAGE", "%s", ss.str().c_str()); } - } else if (VkFormatIsDepthOnly(src_format)) { + } else if (FormatIsDepthOnly(src_format)) { if (srcAspect != VK_IMAGE_ASPECT_DEPTH_BIT) { std::stringstream ss; ss << "vkCmdBlitImage: Depth-only image formats must have only the VK_IMAGE_ASPECT_DEPTH " @@ -1896,7 +1896,7 @@ bool PreCallValidateCmdBlitImage(layer_data *device_data, GLOBAL_CB_NODE *cb_nod } // Validate filter - if (VkFormatIsDepthOrStencil(src_format) && (filter != VK_FILTER_NEAREST)) { + if (FormatIsDepthOrStencil(src_format) && (filter != VK_FILTER_NEAREST)) { std::stringstream ss; ss << "vkCmdBlitImage: If the format of srcImage is a depth, stencil, or depth stencil " << "then filter must be VK_FILTER_NEAREST."; @@ -2364,7 +2364,7 @@ bool ValidateImageAspectMask(layer_data *device_data, VkImage image, VkFormat fo const char *func_name) { const debug_report_data *report_data = core_validation::GetReportData(device_data); bool skip = false; - if (VkFormatIsColor(format)) { + if (FormatIsColor(format)) { if ((aspect_mask & VK_IMAGE_ASPECT_COLOR_BIT) != VK_IMAGE_ASPECT_COLOR_BIT) { skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, (uint64_t)image, __LINE__, VALIDATION_ERROR_00741, "IMAGE", @@ -2376,7 +2376,7 @@ bool ValidateImageAspectMask(layer_data *device_data, VkImage image, VkFormat fo "%s: Color image formats must have ONLY the VK_IMAGE_ASPECT_COLOR_BIT set. %s", func_name, validation_error_map[VALIDATION_ERROR_00741]); } - } else if (VkFormatIsDepthAndStencil(format)) { + } else if (FormatIsDepthAndStencil(format)) { if ((aspect_mask & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) == 0) { skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, (uint64_t)image, __LINE__, VALIDATION_ERROR_00741, "IMAGE", @@ -2391,7 +2391,7 @@ bool ValidateImageAspectMask(layer_data *device_data, VkImage image, VkFormat fo "VK_IMAGE_ASPECT_STENCIL_BIT set. %s", func_name, validation_error_map[VALIDATION_ERROR_00741]); } - } else if (VkFormatIsDepthOnly(format)) { + } else if (FormatIsDepthOnly(format)) { if ((aspect_mask & VK_IMAGE_ASPECT_DEPTH_BIT) != VK_IMAGE_ASPECT_DEPTH_BIT) { skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, (uint64_t)image, __LINE__, VALIDATION_ERROR_00741, "IMAGE", @@ -2403,7 +2403,7 @@ bool ValidateImageAspectMask(layer_data *device_data, VkImage image, VkFormat fo "%s: Depth-only image formats can have only the VK_IMAGE_ASPECT_DEPTH_BIT set. %s", func_name, validation_error_map[VALIDATION_ERROR_00741]); } - } else if (VkFormatIsStencilOnly(format)) { + } else if (FormatIsStencilOnly(format)) { if ((aspect_mask & VK_IMAGE_ASPECT_STENCIL_BIT) != VK_IMAGE_ASPECT_STENCIL_BIT) { skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, (uint64_t)image, __LINE__, VALIDATION_ERROR_00741, "IMAGE", @@ -2480,7 +2480,7 @@ bool PreCallValidateCreateImageView(layer_data *device_data, const VkImageViewCr // Validate VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT state if (image_flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT) { // Format MUST be compatible (in the same format compatibility class) as the format the image was created with - if (VkFormatGetCompatibilityClass(image_format) != VkFormatGetCompatibilityClass(view_format)) { + if (FormatCompatibilityClass(image_format) != FormatCompatibilityClass(view_format)) { std::stringstream ss; ss << "vkCreateImageView(): ImageView format " << string_VkFormat(view_format) << " is not in the same format compatibility class as image (" << (uint64_t)create_info->image << ") format " @@ -2698,9 +2698,9 @@ bool ValidateBufferImageCopyData(const debug_report_data *report_data, uint32_t // If the the calling command's VkImage parameter's format is not a depth/stencil format, // then bufferOffset must be a multiple of the calling command's VkImage parameter's texel size - auto texel_size = VkFormatGetSize(image_state->createInfo.format); - if (!VkFormatIsDepthAndStencil(image_state->createInfo.format) && - VkSafeModulo(pRegions[i].bufferOffset, texel_size) != 0) { + auto texel_size = FormatSize(image_state->createInfo.format); + if (!FormatIsDepthAndStencil(image_state->createInfo.format) && + SafeModulo(pRegions[i].bufferOffset, texel_size) != 0) { skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, reinterpret_cast<uint64_t &>(image_state->image), __LINE__, VALIDATION_ERROR_01263, "IMAGE", "%s(): pRegion[%d] bufferOffset 0x%" PRIxLEAST64 @@ -2709,7 +2709,7 @@ bool ValidateBufferImageCopyData(const debug_report_data *report_data, uint32_t } // BufferOffset must be a multiple of 4 - if (VkSafeModulo(pRegions[i].bufferOffset, 4) != 0) { + if (SafeModulo(pRegions[i].bufferOffset, 4) != 0) { skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, reinterpret_cast<uint64_t &>(image_state->image), __LINE__, VALIDATION_ERROR_01264, "IMAGE", "%s(): pRegion[%d] bufferOffset 0x%" PRIxLEAST64 " must be a multiple of 4. %s", function, i, @@ -2760,11 +2760,11 @@ bool ValidateBufferImageCopyData(const debug_report_data *report_data, uint32_t // TODO: there is a comment in ValidateCopyBufferImageTransferGranularityRequirements() in core_validation.cpp that // reserves a place for these compressed image checks. This block of code could move there once the image // stuff is moved into core validation. - if (VkFormatIsCompressed(image_state->createInfo.format)) { - auto block_size = VkFormatCompressedTexelBlockExtent(image_state->createInfo.format); + if (FormatIsCompressed(image_state->createInfo.format)) { + auto block_size = FormatCompressedTexelBlockExtent(image_state->createInfo.format); // BufferRowLength must be a multiple of block width - if (VkSafeModulo(pRegions[i].bufferRowLength, block_size.width) != 0) { + if (SafeModulo(pRegions[i].bufferRowLength, block_size.width) != 0) { skip |= log_msg( report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, reinterpret_cast<uint64_t &>(image_state->image), __LINE__, VALIDATION_ERROR_01271, "IMAGE", @@ -2773,7 +2773,7 @@ bool ValidateBufferImageCopyData(const debug_report_data *report_data, uint32_t } // BufferRowHeight must be a multiple of block height - if (VkSafeModulo(pRegions[i].bufferImageHeight, block_size.height) != 0) { + if (SafeModulo(pRegions[i].bufferImageHeight, block_size.height) != 0) { skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, reinterpret_cast<uint64_t &>(image_state->image), __LINE__, VALIDATION_ERROR_01272, "IMAGE", "%s(): pRegion[%d] bufferImageHeight (%d) must be a multiple of the compressed image's texel " @@ -2783,9 +2783,9 @@ bool ValidateBufferImageCopyData(const debug_report_data *report_data, uint32_t } // image offsets must be multiples of block dimensions - if ((VkSafeModulo(pRegions[i].imageOffset.x, block_size.width) != 0) || - (VkSafeModulo(pRegions[i].imageOffset.y, block_size.height) != 0) || - (VkSafeModulo(pRegions[i].imageOffset.z, block_size.depth) != 0)) { + if ((SafeModulo(pRegions[i].imageOffset.x, block_size.width) != 0) || + (SafeModulo(pRegions[i].imageOffset.y, block_size.height) != 0) || + (SafeModulo(pRegions[i].imageOffset.z, block_size.depth) != 0)) { skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, reinterpret_cast<uint64_t &>(image_state->image), __LINE__, VALIDATION_ERROR_01273, "IMAGE", "%s(): pRegion[%d] imageOffset(x,y) (%d, %d) must be multiples of the compressed image's texel " @@ -2795,8 +2795,8 @@ bool ValidateBufferImageCopyData(const debug_report_data *report_data, uint32_t } // bufferOffset must be a multiple of block size (linear bytes) - size_t block_size_in_bytes = VkFormatGetSize(image_state->createInfo.format); - if (VkSafeModulo(pRegions[i].bufferOffset, block_size_in_bytes) != 0) { + size_t block_size_in_bytes = FormatSize(image_state->createInfo.format); + if (SafeModulo(pRegions[i].bufferOffset, block_size_in_bytes) != 0) { skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, reinterpret_cast<uint64_t &>(image_state->image), __LINE__, VALIDATION_ERROR_01274, "IMAGE", "%s(): pRegion[%d] bufferOffset (0x%" PRIxLEAST64 @@ -2808,7 +2808,7 @@ bool ValidateBufferImageCopyData(const debug_report_data *report_data, uint32_t // imageExtent width must be a multiple of block width, or extent+offset width must equal subresource width VkExtent3D mip_extent = GetImageSubresourceExtent(image_state, &(pRegions[i].imageSubresource)); - if ((VkSafeModulo(pRegions[i].imageExtent.width, block_size.width) != 0) && + if ((SafeModulo(pRegions[i].imageExtent.width, block_size.width) != 0) && (pRegions[i].imageExtent.width + pRegions[i].imageOffset.x != mip_extent.width)) { skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, reinterpret_cast<uint64_t &>(image_state->image), __LINE__, VALIDATION_ERROR_01275, "IMAGE", @@ -2819,7 +2819,7 @@ bool ValidateBufferImageCopyData(const debug_report_data *report_data, uint32_t } // imageExtent height must be a multiple of block height, or extent+offset height must equal subresource height - if ((VkSafeModulo(pRegions[i].imageExtent.height, block_size.height) != 0) && + if ((SafeModulo(pRegions[i].imageExtent.height, block_size.height) != 0) && (pRegions[i].imageExtent.height + pRegions[i].imageOffset.y != mip_extent.height)) { skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, reinterpret_cast<uint64_t &>(image_state->image), __LINE__, VALIDATION_ERROR_01276, "IMAGE", @@ -2830,7 +2830,7 @@ bool ValidateBufferImageCopyData(const debug_report_data *report_data, uint32_t } // imageExtent depth must be a multiple of block depth, or extent+offset depth must equal subresource depth - if ((VkSafeModulo(pRegions[i].imageExtent.depth, block_size.depth) != 0) && + if ((SafeModulo(pRegions[i].imageExtent.depth, block_size.depth) != 0) && (pRegions[i].imageExtent.depth + pRegions[i].imageOffset.z != mip_extent.depth)) { skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, reinterpret_cast<uint64_t &>(image_state->image), __LINE__, VALIDATION_ERROR_01277, "IMAGE", @@ -2865,8 +2865,8 @@ static bool ValidateImageBounds(const debug_report_data *report_data, const IMAG VkExtent3D image_extent = GetImageSubresourceExtent(image_state, &(pRegions[i].imageSubresource)); // If we're using a compressed format, valid extent is rounded up to multiple of block size (per 18.1) - if (VkFormatIsCompressed(image_info->format)) { - auto block_extent = VkFormatCompressedTexelBlockExtent(image_info->format); + if (FormatIsCompressed(image_info->format)) { + auto block_extent = FormatCompressedTexelBlockExtent(image_info->format); if (image_extent.width % block_extent.width) { image_extent.width += (block_extent.width - (image_extent.width % block_extent.width)); } @@ -2900,18 +2900,18 @@ static inline bool ValidtateBufferBounds(const debug_report_data *report_data, I VkDeviceSize buffer_width = (0 == pRegions[i].bufferRowLength ? copy_extent.width : pRegions[i].bufferRowLength); VkDeviceSize buffer_height = (0 == pRegions[i].bufferImageHeight ? copy_extent.height : pRegions[i].bufferImageHeight); - VkDeviceSize unit_size = VkFormatGetSize(image_state->createInfo.format); // size (bytes) of texel or block + VkDeviceSize unit_size = FormatSize(image_state->createInfo.format); // size (bytes) of texel or block // Handle special buffer packing rules for specific depth/stencil formats if (pRegions[i].imageSubresource.aspectMask & VK_IMAGE_ASPECT_STENCIL_BIT) { - unit_size = VkFormatGetSize(VK_FORMAT_S8_UINT); + unit_size = FormatSize(VK_FORMAT_S8_UINT); } else if (pRegions[i].imageSubresource.aspectMask & VK_IMAGE_ASPECT_DEPTH_BIT) { switch (image_state->createInfo.format) { case VK_FORMAT_D16_UNORM_S8_UINT: - unit_size = VkFormatGetSize(VK_FORMAT_D16_UNORM); + unit_size = FormatSize(VK_FORMAT_D16_UNORM); break; case VK_FORMAT_D32_SFLOAT_S8_UINT: - unit_size = VkFormatGetSize(VK_FORMAT_D32_SFLOAT); + unit_size = FormatSize(VK_FORMAT_D32_SFLOAT); break; case VK_FORMAT_X8_D24_UNORM_PACK32: // Fall through case VK_FORMAT_D24_UNORM_S8_UINT: @@ -2922,9 +2922,9 @@ static inline bool ValidtateBufferBounds(const debug_report_data *report_data, I } } - if (VkFormatIsCompressed(image_state->createInfo.format)) { + if (FormatIsCompressed(image_state->createInfo.format)) { // Switch to texel block units, rounding up for any partially-used blocks - auto block_dim = VkFormatCompressedTexelBlockExtent(image_state->createInfo.format); + auto block_dim = FormatCompressedTexelBlockExtent(image_state->createInfo.format); buffer_width = (buffer_width + block_dim.width - 1) / block_dim.width; buffer_height = (buffer_height + block_dim.height - 1) / block_dim.height; @@ -3147,7 +3147,7 @@ bool PreCallValidateGetImageSubresourceLayout(layer_data *device_data, VkImage i // VU 00741: subresource's aspect must be compatible with image's format. const VkFormat img_format = image_entry->createInfo.format; - if (VkFormatIsColor(img_format)) { + if (FormatIsColor(img_format)) { if (sub_aspect != VK_IMAGE_ASPECT_COLOR_BIT) { skip |= log_msg( report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, @@ -3155,7 +3155,7 @@ bool PreCallValidateGetImageSubresourceLayout(layer_data *device_data, VkImage i "vkGetImageSubresourceLayout(): For color formats, VkImageSubresource.aspectMask must be VK_IMAGE_ASPECT_COLOR. %s", validation_error_map[VALIDATION_ERROR_00741]); } - } else if (VkFormatIsDepthOrStencil(img_format)) { + } else if (FormatIsDepthOrStencil(img_format)) { if ((sub_aspect != VK_IMAGE_ASPECT_DEPTH_BIT) && (sub_aspect != VK_IMAGE_ASPECT_STENCIL_BIT)) { skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, reinterpret_cast<uint64_t &>(image), __LINE__, VALIDATION_ERROR_00741, "IMAGE", diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp index 954f7edd05e85f34ab968e501397ef90595b2cce..dfed7ebd4fbd38d4fa7369e79a26a8ae952fc015 100644 --- a/layers/core_validation.cpp +++ b/layers/core_validation.cpp @@ -4845,7 +4845,7 @@ static void initializeAndTrackMemory(layer_data *dev_data, VkDeviceMemory mem, V size = mem_info->alloc_info.allocationSize - offset; } mem_info->shadow_pad_size = dev_data->phys_dev_properties.properties.limits.minMemoryMapAlignment; - assert(VkSafeModulo(mem_info->shadow_pad_size, + assert(SafeModulo(mem_info->shadow_pad_size, dev_data->phys_dev_properties.properties.limits.minMemoryMapAlignment) == 0); // Ensure start of mapped region reflects hardware alignment constraints uint64_t map_alignment = dev_data->phys_dev_properties.properties.limits.minMemoryMapAlignment; @@ -4860,7 +4860,7 @@ static void initializeAndTrackMemory(layer_data *dev_data, VkDeviceMemory mem, V reinterpret_cast<char *>((reinterpret_cast<uintptr_t>(mem_info->shadow_copy_base) + map_alignment) & ~(map_alignment - 1)) + start_offset; - assert(VkSafeModulo(reinterpret_cast<uintptr_t>(mem_info->shadow_copy) + mem_info->shadow_pad_size - start_offset, + assert(SafeModulo(reinterpret_cast<uintptr_t>(mem_info->shadow_copy) + mem_info->shadow_pad_size - start_offset, map_alignment) == 0); memset(mem_info->shadow_copy, NoncoherentMemoryFillValue, static_cast<size_t>(2 * mem_info->shadow_pad_size + size)); @@ -5558,7 +5558,7 @@ static bool PreCallValidateBindBufferMemory(layer_data *dev_data, VkBuffer buffe } // Validate memory requirements alignment - if (VkSafeModulo(memoryOffset, buffer_state->requirements.alignment) != 0) { + if (SafeModulo(memoryOffset, buffer_state->requirements.alignment) != 0) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT, buffer_handle, __LINE__, VALIDATION_ERROR_02174, "DS", "vkBindBufferMemory(): memoryOffset is 0x%" PRIxLEAST64 @@ -5603,7 +5603,7 @@ static bool PreCallValidateBindBufferMemory(layer_data *dev_data, VkBuffer buffe for (int i = 0; i < 3; i++) { if (usage & usage_list[i]) { - if (VkSafeModulo(memoryOffset, offset_requirement[i]) != 0) { + if (SafeModulo(memoryOffset, offset_requirement[i]) != 0) { skip |= log_msg( dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT, buffer_handle, __LINE__, msgCode[i], "DS", "vkBindBufferMemory(): %s memoryOffset is 0x%" PRIxLEAST64 @@ -7376,7 +7376,7 @@ VKAPI_ATTR void VKAPI_CALL CmdBindDescriptorSets(VkCommandBuffer commandBuffer, uint32_t cur_dyn_offset = total_dynamic_descriptors; for (uint32_t d = 0; d < descriptor_set->GetTotalDescriptorCount(); d++) { if (descriptor_set->GetTypeFromGlobalIndex(d) == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) { - if (VkSafeModulo( + if (SafeModulo( pDynamicOffsets[cur_dyn_offset], dev_data->phys_dev_properties.properties.limits.minUniformBufferOffsetAlignment) != 0) { skip |= log_msg( @@ -7390,7 +7390,7 @@ VKAPI_ATTR void VKAPI_CALL CmdBindDescriptorSets(VkCommandBuffer commandBuffer, } cur_dyn_offset++; } else if (descriptor_set->GetTypeFromGlobalIndex(d) == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC) { - if (VkSafeModulo( + if (SafeModulo( pDynamicOffsets[cur_dyn_offset], dev_data->phys_dev_properties.properties.limits.minStorageBufferOffsetAlignment) != 0) { skip |= log_msg( @@ -9486,8 +9486,8 @@ static bool FormatSpecificLoadAndStoreOpSettings(VkFormat format, T color_depth_ if (color_depth_op != op && stencil_op != op) { return false; } - bool check_color_depth_load_op = !VkFormatIsStencilOnly(format); - bool check_stencil_load_op = VkFormatIsDepthAndStencil(format) || !check_color_depth_load_op; + bool check_color_depth_load_op = !FormatIsStencilOnly(format); + bool check_stencil_load_op = FormatIsDepthAndStencil(format) || !check_color_depth_load_op; return (((check_color_depth_load_op == true) && (color_depth_op == op)) || ((check_stencil_load_op == true) && (stencil_op == op))); @@ -10153,14 +10153,14 @@ static bool ValidateMappedMemoryRangeDeviceLimits(layer_data *dev_data, const ch bool skip = false; for (uint32_t i = 0; i < mem_range_count; ++i) { uint64_t atom_size = dev_data->phys_dev_properties.properties.limits.nonCoherentAtomSize; - if (VkSafeModulo(mem_ranges[i].offset, atom_size) != 0) { + if (SafeModulo(mem_ranges[i].offset, atom_size) != 0) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT, reinterpret_cast<const uint64_t &>(mem_ranges->memory), __LINE__, VALIDATION_ERROR_00644, "MEM", "%s: Offset in pMemRanges[%d] is 0x%" PRIxLEAST64 ", which is not a multiple of VkPhysicalDeviceLimits::nonCoherentAtomSize (0x%" PRIxLEAST64 "). %s", func_name, i, mem_ranges[i].offset, atom_size, validation_error_map[VALIDATION_ERROR_00644]); } - if ((mem_ranges[i].size != VK_WHOLE_SIZE) && (VkSafeModulo(mem_ranges[i].size, atom_size) != 0)) { + if ((mem_ranges[i].size != VK_WHOLE_SIZE) && (SafeModulo(mem_ranges[i].size, atom_size) != 0)) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT, reinterpret_cast<const uint64_t &>(mem_ranges->memory), __LINE__, VALIDATION_ERROR_00645, "MEM", "%s: Size in pMemRanges[%d] is 0x%" PRIxLEAST64 @@ -10253,7 +10253,7 @@ static bool PreCallValidateBindImageMemory(layer_data *dev_data, VkImage image, } // Validate memory requirements alignment - if (VkSafeModulo(memoryOffset, image_state->requirements.alignment) != 0) { + if (SafeModulo(memoryOffset, image_state->requirements.alignment) != 0) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, image_handle, __LINE__, VALIDATION_ERROR_02178, "DS", "vkBindImageMemory(): memoryOffset is 0x%" PRIxLEAST64 diff --git a/layers/descriptor_sets.cpp b/layers/descriptor_sets.cpp index fbaa2dc02293f578181247912207dbf8e3a9f9ec..84663c4b18bef298bf227577d0f61df9b2b6cba9 100644 --- a/layers/descriptor_sets.cpp +++ b/layers/descriptor_sets.cpp @@ -785,7 +785,7 @@ bool cvdescriptorset::ValidateImageUpdate(VkImageView image_view, VkImageLayout } // TODO : The various image aspect and format checks here are based on general spec language in 11.5 Image Views section under // vkCreateImageView(). What's the best way to create unique id for these cases? - bool ds = VkFormatIsDepthOrStencil(format); + bool ds = FormatIsDepthOrStencil(format); switch (image_layout) { case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL: // Only Color bit must be set diff --git a/layers/parameter_validation.cpp b/layers/parameter_validation.cpp index a11c3d45004253653bbc93bc3b5ad5b29e2e52b5..bc41f125577f9c9a25fbc685b47d99cb3185cc70 100644 --- a/layers/parameter_validation.cpp +++ b/layers/parameter_validation.cpp @@ -2543,7 +2543,7 @@ VKAPI_ATTR VkResult VKAPI_CALL CreateImage(VkDevice device, const VkImageCreateI if (pCreateInfo != nullptr) { if ((device_data->physical_device_features.textureCompressionETC2 == false) && - VkFormatIsCompressed_ETC2_EAC(pCreateInfo->format)) { + FormatIsCompressed_ETC2_EAC(pCreateInfo->format)) { skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, DEVICE_FEATURE, LayerName, "vkCreateImage(): Attempting to create VkImage with format %s. The textureCompressionETC2 feature is " @@ -2552,7 +2552,7 @@ VKAPI_ATTR VkResult VKAPI_CALL CreateImage(VkDevice device, const VkImageCreateI } if ((device_data->physical_device_features.textureCompressionASTC_LDR == false) && - VkFormatIsCompressed_ASTC_LDR(pCreateInfo->format)) { + FormatIsCompressed_ASTC_LDR(pCreateInfo->format)) { skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, DEVICE_FEATURE, LayerName, @@ -2562,7 +2562,7 @@ VKAPI_ATTR VkResult VKAPI_CALL CreateImage(VkDevice device, const VkImageCreateI } if ((device_data->physical_device_features.textureCompressionBC == false) && - VkFormatIsCompressed_BC(pCreateInfo->format)) { + FormatIsCompressed_BC(pCreateInfo->format)) { skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, DEVICE_FEATURE, LayerName, "vkCreateImage(): Attempting to create VkImage with format %s. The textureCompressionBC feature is " @@ -3875,7 +3875,7 @@ VKAPI_ATTR void VKAPI_CALL UpdateDescriptorSets(VkDevice device, uint32_t descri VkDeviceSize uniformAlignment = device_data->device_limits.minUniformBufferOffsetAlignment; for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) { if (pDescriptorWrites[i].pBufferInfo != NULL) { - if (VkSafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment) != 0) { + if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment) != 0) { skip |= log_msg( device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, 0, __LINE__, VALIDATION_ERROR_00944, LayerName, @@ -3891,7 +3891,7 @@ VKAPI_ATTR void VKAPI_CALL UpdateDescriptorSets(VkDevice device, uint32_t descri VkDeviceSize storageAlignment = device_data->device_limits.minStorageBufferOffsetAlignment; for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) { if (pDescriptorWrites[i].pBufferInfo != NULL) { - if (VkSafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment) != 0) { + if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment) != 0) { skip |= log_msg( device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, 0, __LINE__, VALIDATION_ERROR_00945, LayerName, diff --git a/layers/vk_format_utils.cpp b/layers/vk_format_utils.cpp index d5b133174e5a640f9b52b64f9f565d37298b6909..ee6233fb7b8c76a93ce0aa8b02e4b413d2759f49 100644 --- a/layers/vk_format_utils.cpp +++ b/layers/vk_format_utils.cpp @@ -236,7 +236,7 @@ const std::map<VkFormat, VULKAN_FORMAT_INFO> vk_format_table = { // clang-format on // Return true if format is an ETC2 or EAC compressed texture format -VK_LAYER_EXPORT bool VkFormatIsCompressed_ETC2_EAC(VkFormat format) { +VK_LAYER_EXPORT bool FormatIsCompressed_ETC2_EAC(VkFormat format) { bool found = false; switch (format) { @@ -259,7 +259,7 @@ VK_LAYER_EXPORT bool VkFormatIsCompressed_ETC2_EAC(VkFormat format) { } // Return true if format is an ETC2 or EAC compressed texture format -VK_LAYER_EXPORT bool VkFormatIsCompressed_ASTC_LDR(VkFormat format) { +VK_LAYER_EXPORT bool FormatIsCompressed_ASTC_LDR(VkFormat format) { bool found = false; switch (format) { @@ -300,7 +300,7 @@ VK_LAYER_EXPORT bool VkFormatIsCompressed_ASTC_LDR(VkFormat format) { } // Return true if format is a BC compressed texture format -VK_LAYER_EXPORT bool VkFormatIsCompressed_BC(VkFormat format) { +VK_LAYER_EXPORT bool FormatIsCompressed_BC(VkFormat format) { bool found = false; switch (format) { @@ -329,12 +329,12 @@ VK_LAYER_EXPORT bool VkFormatIsCompressed_BC(VkFormat format) { } // Return true if format is a depth or stencil format -VK_LAYER_EXPORT bool VkFormatIsDepthOrStencil(VkFormat format) { - return (VkFormatIsDepthAndStencil(format) || VkFormatIsDepthOnly(format) || VkFormatIsStencilOnly(format)); +VK_LAYER_EXPORT bool FormatIsDepthOrStencil(VkFormat format) { + return (FormatIsDepthAndStencil(format) || FormatIsDepthOnly(format) || FormatIsStencilOnly(format)); } // Return true if format contains depth and stencil information -VK_LAYER_EXPORT bool VkFormatIsDepthAndStencil(VkFormat format) { +VK_LAYER_EXPORT bool FormatIsDepthAndStencil(VkFormat format) { bool is_ds = false; switch (format) { @@ -350,10 +350,10 @@ VK_LAYER_EXPORT bool VkFormatIsDepthAndStencil(VkFormat format) { } // Return true if format is a stencil-only format -VK_LAYER_EXPORT bool VkFormatIsStencilOnly(VkFormat format) { return (format == VK_FORMAT_S8_UINT); } +VK_LAYER_EXPORT bool FormatIsStencilOnly(VkFormat format) { return (format == VK_FORMAT_S8_UINT); } // Return true if format is a depth-only format -VK_LAYER_EXPORT bool VkFormatIsDepthOnly(VkFormat format) { +VK_LAYER_EXPORT bool FormatIsDepthOnly(VkFormat format) { bool is_depth = false; switch (format) { @@ -370,7 +370,7 @@ VK_LAYER_EXPORT bool VkFormatIsDepthOnly(VkFormat format) { } // Return true if format is of type NORM -VK_LAYER_EXPORT bool VkFormatIsNorm(VkFormat format) { +VK_LAYER_EXPORT bool FormatIsNorm(VkFormat format) { bool is_norm = false; switch (format) { @@ -445,7 +445,7 @@ VK_LAYER_EXPORT bool VkFormatIsNorm(VkFormat format) { }; // Return true if format is of type UNORM -VK_LAYER_EXPORT bool VkFormatIsUNorm(VkFormat format) { +VK_LAYER_EXPORT bool FormatIsUNorm(VkFormat format) { bool is_unorm = false; switch (format) { @@ -503,7 +503,7 @@ VK_LAYER_EXPORT bool VkFormatIsUNorm(VkFormat format) { }; // Return true if format is of type SNORM -VK_LAYER_EXPORT bool VkFormatIsSNorm(VkFormat format) { +VK_LAYER_EXPORT bool FormatIsSNorm(VkFormat format) { bool is_snorm = false; switch (format) { @@ -534,10 +534,10 @@ VK_LAYER_EXPORT bool VkFormatIsSNorm(VkFormat format) { }; // Return true if format is an integer format -VK_LAYER_EXPORT bool VkFormatIsInt(VkFormat format) { return (VkFormatIsSInt(format) || VkFormatIsUInt(format)); } +VK_LAYER_EXPORT bool FormatIsInt(VkFormat format) { return (FormatIsSInt(format) || FormatIsUInt(format)); } // Return true if format is an unsigned integer format -VK_LAYER_EXPORT bool VkFormatIsUInt(VkFormat format) { +VK_LAYER_EXPORT bool FormatIsUInt(VkFormat format) { bool is_uint = false; switch (format) { @@ -572,7 +572,7 @@ VK_LAYER_EXPORT bool VkFormatIsUInt(VkFormat format) { } // Return true if format is a signed integer format -VK_LAYER_EXPORT bool VkFormatIsSInt(VkFormat format) { +VK_LAYER_EXPORT bool FormatIsSInt(VkFormat format) { bool is_sint = false; switch (format) { @@ -607,7 +607,7 @@ VK_LAYER_EXPORT bool VkFormatIsSInt(VkFormat format) { } // Return true if format is a floating-point format -VK_LAYER_EXPORT bool VkFormatIsFloat(VkFormat format) { +VK_LAYER_EXPORT bool FormatIsFloat(VkFormat format) { bool is_float = false; switch (format) { @@ -637,7 +637,7 @@ VK_LAYER_EXPORT bool VkFormatIsFloat(VkFormat format) { } // Return true if format is in the SRGB colorspace -VK_LAYER_EXPORT bool VkFormatIsSRGB(VkFormat format) { +VK_LAYER_EXPORT bool FormatIsSRGB(VkFormat format) { bool is_srgb = false; switch (format) { @@ -679,7 +679,7 @@ VK_LAYER_EXPORT bool VkFormatIsSRGB(VkFormat format) { } // Return true if format is in the USCALED colorspace -VK_LAYER_EXPORT bool VkFormatIsUScaled(VkFormat format) { +VK_LAYER_EXPORT bool FormatIsUScaled(VkFormat format) { bool is_uscaled = false; switch (format) { @@ -706,7 +706,7 @@ VK_LAYER_EXPORT bool VkFormatIsUScaled(VkFormat format) { } // Return true if format is in the SSCALED colorspace -VK_LAYER_EXPORT bool VkFormatIsSScaled(VkFormat format) { +VK_LAYER_EXPORT bool FormatIsSScaled(VkFormat format) { bool is_sscaled = false; switch (format) { @@ -733,7 +733,7 @@ VK_LAYER_EXPORT bool VkFormatIsSScaled(VkFormat format) { } // Return true if format is compressed -VK_LAYER_EXPORT bool VkFormatIsCompressed(VkFormat format) { +VK_LAYER_EXPORT bool FormatIsCompressed(VkFormat format) { switch (format) { case VK_FORMAT_BC1_RGB_UNORM_BLOCK: case VK_FORMAT_BC1_RGB_SRGB_BLOCK: @@ -796,7 +796,7 @@ VK_LAYER_EXPORT bool VkFormatIsCompressed(VkFormat format) { } // Return compressed texel block sizes for block compressed formats -VK_LAYER_EXPORT VkExtent3D VkFormatCompressedTexelBlockExtent(VkFormat format) { +VK_LAYER_EXPORT VkExtent3D FormatCompressedTexelBlockExtent(VkFormat format) { VkExtent3D block_size = {1, 1, 1}; switch (format) { case VK_FORMAT_BC1_RGB_UNORM_BLOCK: @@ -888,7 +888,7 @@ VK_LAYER_EXPORT VkExtent3D VkFormatCompressedTexelBlockExtent(VkFormat format) { } // Return format class of the specified format -VK_LAYER_EXPORT VkFormatCompatibilityClass VkFormatGetCompatibilityClass(VkFormat format) { +VK_LAYER_EXPORT VkFormatCompatibilityClass FormatCompatibilityClass(VkFormat format) { auto item = vk_format_table.find(format); if (item != vk_format_table.end()) { return item->second.format_class; @@ -897,7 +897,7 @@ VK_LAYER_EXPORT VkFormatCompatibilityClass VkFormatGetCompatibilityClass(VkForma } // Return size, in bytes, of a pixel of the specified format -VK_LAYER_EXPORT size_t VkFormatGetSize(VkFormat format) { +VK_LAYER_EXPORT size_t FormatSize(VkFormat format) { auto item = vk_format_table.find(format); if (item != vk_format_table.end()) { return item->second.size; @@ -906,7 +906,7 @@ VK_LAYER_EXPORT size_t VkFormatGetSize(VkFormat format) { } // Return the number of channels for a given format -unsigned int VkFormatGetChannelCount(VkFormat format) { +unsigned int FormatChannelCount(VkFormat format) { auto item = vk_format_table.find(format); if (item != vk_format_table.end()) { return item->second.channel_count; @@ -915,7 +915,7 @@ unsigned int VkFormatGetChannelCount(VkFormat format) { } // Perform a zero-tolerant modulo operation -VK_LAYER_EXPORT VkDeviceSize VkSafeModulo(VkDeviceSize dividend, VkDeviceSize divisor) { +VK_LAYER_EXPORT VkDeviceSize SafeModulo(VkDeviceSize dividend, VkDeviceSize divisor) { VkDeviceSize result = 0; if (divisor != 0) { result = dividend % divisor; diff --git a/layers/vk_format_utils.h b/layers/vk_format_utils.h index a87ae0de92ddeb060843e1566f8dc1a82cac936e..ea393ae3412365367abeeb94ba0810a25c8ec01a 100644 --- a/layers/vk_format_utils.h +++ b/layers/vk_format_utils.h @@ -87,45 +87,35 @@ typedef enum VkFormatCompatibilityClass { VK_FORMAT_COMPATIBILITY_CLASS_MAX_ENUM = 45 } VkFormatCompatibilityClass; -static inline bool VkFormatIsUndef(VkFormat format) { return (format == VK_FORMAT_UNDEFINED); } +VK_LAYER_EXPORT bool FormatIsDepthOrStencil(VkFormat format); +VK_LAYER_EXPORT bool FormatIsDepthAndStencil(VkFormat format); +VK_LAYER_EXPORT bool FormatIsDepthOnly(VkFormat format); +VK_LAYER_EXPORT bool FormatIsStencilOnly(VkFormat format); +VK_LAYER_EXPORT bool FormatIsCompressed_ETC2_EAC(VkFormat format); +VK_LAYER_EXPORT bool FormatIsCompressed_ASTC_LDR(VkFormat format); +VK_LAYER_EXPORT bool FormatIsCompressed_BC(VkFormat format); +VK_LAYER_EXPORT bool FormatIsNorm(VkFormat format); +VK_LAYER_EXPORT bool FormatIsUNorm(VkFormat format); +VK_LAYER_EXPORT bool FormatIsSNorm(VkFormat format); +VK_LAYER_EXPORT bool FormatIsInt(VkFormat format); +VK_LAYER_EXPORT bool FormatIsSInt(VkFormat format); +VK_LAYER_EXPORT bool FormatIsUInt(VkFormat format); +VK_LAYER_EXPORT bool FormatIsFloat(VkFormat format); +VK_LAYER_EXPORT bool FormatIsSRGB(VkFormat format); +VK_LAYER_EXPORT bool FormatIsUScaled(VkFormat format); +VK_LAYER_EXPORT bool FormatIsSScaled(VkFormat format); +VK_LAYER_EXPORT bool FormatIsCompressed(VkFormat format); -VK_LAYER_EXPORT bool VkFormatIsDepthOrStencil(VkFormat format); -VK_LAYER_EXPORT bool VkFormatIsDepthAndStencil(VkFormat format); -VK_LAYER_EXPORT bool VkFormatIsDepthOnly(VkFormat format); -VK_LAYER_EXPORT bool VkFormatIsStencilOnly(VkFormat format); -VK_LAYER_EXPORT bool VkFormatIsCompressed_ETC2_EAC(VkFormat format); -VK_LAYER_EXPORT bool VkFormatIsCompressed_ASTC_LDR(VkFormat format); -VK_LAYER_EXPORT bool VkFormatIsCompressed_BC(VkFormat format); -VK_LAYER_EXPORT bool VkFormatIsNorm(VkFormat format); -VK_LAYER_EXPORT bool VkFormatIsUNorm(VkFormat format); -VK_LAYER_EXPORT bool VkFormatIsSNorm(VkFormat format); -VK_LAYER_EXPORT bool VkFormatIsInt(VkFormat format); -VK_LAYER_EXPORT bool VkFormatIsSInt(VkFormat format); -VK_LAYER_EXPORT bool VkFormatIsUInt(VkFormat format); -VK_LAYER_EXPORT bool VkFormatIsFloat(VkFormat format); -VK_LAYER_EXPORT bool VkFormatIsSRGB(VkFormat format); -VK_LAYER_EXPORT bool VkFormatIsUScaled(VkFormat format); -VK_LAYER_EXPORT bool VkFormatIsSScaled(VkFormat format); -VK_LAYER_EXPORT bool VkFormatIsCompressed(VkFormat format); +static inline bool FormatIsUndef(VkFormat format) { return (format == VK_FORMAT_UNDEFINED); } +static inline bool FormatIsColor(VkFormat format) { return !(FormatIsUndef(format) || FormatIsDepthOrStencil(format)); } +static inline bool FormatHasDepth(VkFormat format) { return (FormatIsDepthOnly(format) || FormatIsDepthAndStencil(format)); } +static inline bool FormatHasStencil(VkFormat format) { return (FormatIsStencilOnly(format) || FormatIsDepthAndStencil(format)); } -static inline bool VkFormatIsColor(VkFormat format) { - return !(VkFormatIsUndef(format) || VkFormatIsDepthOrStencil(format)); -} - -static inline bool VkFormatHasDepth(VkFormat format) { - return (VkFormatIsDepthOnly(format) || VkFormatIsDepthAndStencil(format)); -} - -static inline bool VkFormatHasStencil(VkFormat format) { - return (VkFormatIsStencilOnly(format) || VkFormatIsDepthAndStencil(format)); -} - -VK_LAYER_EXPORT VkExtent3D VkFormatCompressedTexelBlockExtent(VkFormat format); -VK_LAYER_EXPORT size_t VkFormatGetSize(VkFormat format); -VK_LAYER_EXPORT unsigned int VkFormatGetChannelCount(VkFormat format); -VK_LAYER_EXPORT VkFormatCompatibilityClass VkFormatGetCompatibilityClass(VkFormat format); - -VK_LAYER_EXPORT VkDeviceSize VkSafeModulo(VkDeviceSize dividend, VkDeviceSize divisor); +VK_LAYER_EXPORT VkExtent3D FormatCompressedTexelBlockExtent(VkFormat format); +VK_LAYER_EXPORT size_t FormatSize(VkFormat format); +VK_LAYER_EXPORT unsigned int FormatChannelCount(VkFormat format); +VK_LAYER_EXPORT VkFormatCompatibilityClass FormatCompatibilityClass(VkFormat format); +VK_LAYER_EXPORT VkDeviceSize SafeModulo(VkDeviceSize dividend, VkDeviceSize divisor); #ifdef __cplusplus } diff --git a/tests/layer_validation_tests.cpp b/tests/layer_validation_tests.cpp index b4ea72e9e432f33e01f905fbc30d1e66d49414d3..99e184f1fd30a1c34163322f74b1f2e1552849de 100644 --- a/tests/layer_validation_tests.cpp +++ b/tests/layer_validation_tests.cpp @@ -100,6 +100,21 @@ static const char bindStateFragShaderText[] = " uFragColor = vec4(0,1,0,1);\n" "}\n"; +// Format search helper +VkFormat FindSupportedDepthStencilFormat(VkPhysicalDevice phy) { + VkFormat ds_formats[] = { VK_FORMAT_D16_UNORM_S8_UINT, VK_FORMAT_D24_UNORM_S8_UINT, VK_FORMAT_D32_SFLOAT_S8_UINT }; + for (uint32_t i = 0; i < sizeof(ds_formats); i++) { + VkFormatProperties format_props; + vkGetPhysicalDeviceFormatProperties(phy, ds_formats[i], &format_props); + + if (format_props.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) { + return ds_formats[i]; + } + } + return (VkFormat)0; +} + +// Validation report callback prototype static VKAPI_ATTR VkBool32 VKAPI_CALL myDbgFunc(VkFlags msgFlags, VkDebugReportObjectTypeEXT objType, uint64_t srcObject, size_t location, int32_t msgCode, const char *pLayerPrefix, const char *pMsg, void *pUserData); @@ -2169,7 +2184,7 @@ TEST_F(VkLayerTest, InvalidUsageBits) { m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "Invalid usage flag for image "); ASSERT_NO_FATAL_FAILURE(Init()); - auto format = FindDepthStencilFormat(gpu()); + auto format = FindSupportedDepthStencilFormat(gpu()); if (!format) { printf(" No Depth + Stencil format found. Skipped.\n"); return; @@ -8758,7 +8773,7 @@ TEST_F(VkLayerTest, ClearDepthStencilImageWithinRenderPass) { ASSERT_NO_FATAL_FAILURE(Init()); ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); - auto depth_format = FindDepthStencilFormat(gpu()); + auto depth_format = FindSupportedDepthStencilFormat(gpu()); if (!depth_format) { printf(" No Depth + Stencil format found. Skipped.\n"); return; @@ -8909,7 +8924,7 @@ TEST_F(VkLayerTest, InvalidBarriers) { m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "Barriers cannot be set during subpass"); ASSERT_NO_FATAL_FAILURE(Init()); - auto depth_format = FindDepthStencilFormat(gpu()); + auto depth_format = FindSupportedDepthStencilFormat(gpu()); if (!depth_format) { printf(" No Depth + Stencil format found. Skipped.\n"); return; @@ -9985,7 +10000,7 @@ TEST_F(VkLayerTest, DSAspectBitsErrors) { VkResult err; ASSERT_NO_FATAL_FAILURE(Init()); - auto depth_format = FindDepthStencilFormat(gpu()); + auto depth_format = FindSupportedDepthStencilFormat(gpu()); if (!depth_format) { printf(" No Depth + Stencil format found. Skipped.\n"); return; @@ -11721,7 +11736,7 @@ TEST_F(VkLayerTest, InvalidImageLayout) { // * -3 Cmd buf submit of image w/ layout not matching first use w/o subresource ASSERT_NO_FATAL_FAILURE(Init()); - auto depth_format = FindDepthStencilFormat(gpu()); + auto depth_format = FindSupportedDepthStencilFormat(gpu()); if (!depth_format) { printf(" No Depth + Stencil format found. Skipped.\n"); return; @@ -15954,7 +15969,7 @@ TEST_F(VkLayerTest, ImageLayerViewTests) { TEST_DESCRIPTION("Passing bad parameters to CreateImageView"); ASSERT_NO_FATAL_FAILURE(Init()); - auto depth_format = FindDepthStencilFormat(gpu()); + auto depth_format = FindSupportedDepthStencilFormat(gpu()); if (!depth_format) { return; } @@ -17055,7 +17070,7 @@ TEST_F(VkLayerTest, CopyImageDepthStencilFormatMismatch) { "vkCmdCopyImage called with unmatched source and dest image depth"); ASSERT_NO_FATAL_FAILURE(Init()); - auto depth_format = FindDepthStencilFormat(gpu()); + auto depth_format = FindSupportedDepthStencilFormat(gpu()); if (!depth_format) { return; } @@ -17241,7 +17256,7 @@ TEST_F(VkLayerTest, CopyImageSampleCountMismatch) { TEST_F(VkLayerTest, CopyImageAspectMismatch) { TEST_DESCRIPTION("Image copies with aspect mask errors"); ASSERT_NO_FATAL_FAILURE(Init()); - auto ds_format = FindDepthStencilFormat(gpu()); + auto ds_format = FindSupportedDepthStencilFormat(gpu()); if (!ds_format) { return; } @@ -17749,7 +17764,7 @@ TEST_F(VkLayerTest, DepthStencilImageViewWithColorAspectBitError) { "Combination depth/stencil image formats can have only the "); ASSERT_NO_FATAL_FAILURE(Init()); - auto depth_format = FindDepthStencilFormat(gpu()); + auto depth_format = FindSupportedDepthStencilFormat(gpu()); if (!depth_format) { return; } @@ -17872,7 +17887,7 @@ TEST_F(VkLayerTest, ClearImageErrors) { "ClearDepthStencilImage with a color image."); ASSERT_NO_FATAL_FAILURE(Init()); - auto depth_format = FindDepthStencilFormat(gpu()); + auto depth_format = FindSupportedDepthStencilFormat(gpu()); if (!depth_format) { return; } @@ -18363,7 +18378,7 @@ TEST_F(VkPositiveLayerTest, SecondaryCommandBufferImageLayoutTransitions) { VkResult err; m_errorMonitor->ExpectSuccess(); ASSERT_NO_FATAL_FAILURE(Init()); - auto depth_format = FindDepthStencilFormat(gpu()); + auto depth_format = FindSupportedDepthStencilFormat(gpu()); if (!depth_format) { return; } @@ -20310,7 +20325,7 @@ TEST_F(VkPositiveLayerTest, StencilLoadOp) { "CLEAR. stencil[Load|Store]Op used to be ignored."); VkResult result = VK_SUCCESS; ASSERT_NO_FATAL_FAILURE(Init()); - auto depth_format = FindDepthStencilFormat(gpu()); + auto depth_format = FindSupportedDepthStencilFormat(gpu()); if (!depth_format) { printf(" No Depth + Stencil format found. Skipped.\n"); return; @@ -20484,7 +20499,7 @@ TEST_F(VkPositiveLayerTest, BarrierLayoutToImageUsage) { m_errorMonitor->ExpectSuccess(); ASSERT_NO_FATAL_FAILURE(Init()); - auto depth_format = FindDepthStencilFormat(gpu()); + auto depth_format = FindSupportedDepthStencilFormat(gpu()); if (!depth_format) { printf(" No Depth + Stencil format found. Skipped.\n"); return; @@ -21891,7 +21906,7 @@ TEST_F(VkPositiveLayerTest, ValidRenderPassAttachmentLayoutWithLoadOp) { "valid *READ_ONLY* layout."); m_errorMonitor->ExpectSuccess(); ASSERT_NO_FATAL_FAILURE(Init()); - auto depth_format = FindDepthStencilFormat(gpu()); + auto depth_format = FindSupportedDepthStencilFormat(gpu()); if (!depth_format) { printf(" No Depth + Stencil format found. Skipped.\n"); return; @@ -21939,7 +21954,7 @@ TEST_F(VkPositiveLayerTest, RenderPassDepthStencilLayoutTransition) { "transition has correctly occurred at queue submit time with no validation errors."); ASSERT_NO_FATAL_FAILURE(Init()); - auto depth_format = FindDepthStencilFormat(gpu()); + auto depth_format = FindSupportedDepthStencilFormat(gpu()); if (!depth_format) { printf(" No Depth + Stencil format found. Skipped.\n"); return; diff --git a/tests/vkrenderframework.cpp b/tests/vkrenderframework.cpp index ff7b50c0f7038e8a753ff4361b0011152823da31..548d935819e8b051fab5d16df9bbea69077739fe 100644 --- a/tests/vkrenderframework.cpp +++ b/tests/vkrenderframework.cpp @@ -30,20 +30,6 @@ assert(fp##entrypoint != NULL); \ } -// Format search helpers -VkFormat FindDepthStencilFormat(VkPhysicalDevice phy) { - VkFormat ds_formats[] = {VK_FORMAT_D16_UNORM_S8_UINT, VK_FORMAT_D24_UNORM_S8_UINT, VK_FORMAT_D32_SFLOAT_S8_UINT}; - for (uint32_t i = 0; i < sizeof(ds_formats); i++) { - VkFormatProperties format_props; - vkGetPhysicalDeviceFormatProperties(phy, ds_formats[i], &format_props); - - if (format_props.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) { - return ds_formats[i]; - } - } - return (VkFormat)0; -} - VkRenderFramework::VkRenderFramework() : inst(VK_NULL_HANDLE), m_device(NULL), @@ -724,11 +710,11 @@ void VkImageObj::init(uint32_t w, uint32_t h, VkFormat fmt, VkFlags usage, VkIma newLayout = m_descriptorImageInfo.imageLayout; VkImageAspectFlags image_aspect = 0; - if (VkFormatIsDepthAndStencil(fmt)) { + if (FormatIsDepthAndStencil(fmt)) { image_aspect = VK_IMAGE_ASPECT_STENCIL_BIT | VK_IMAGE_ASPECT_DEPTH_BIT; - } else if (VkFormatIsDepthOnly(fmt)) { + } else if (FormatIsDepthOnly(fmt)) { image_aspect = VK_IMAGE_ASPECT_DEPTH_BIT; - } else if (VkFormatIsStencilOnly(fmt)) { + } else if (FormatIsStencilOnly(fmt)) { image_aspect = VK_IMAGE_ASPECT_STENCIL_BIT; } else { // color image_aspect = VK_IMAGE_ASPECT_COLOR_BIT; @@ -759,11 +745,11 @@ void VkImageObj::init(const VkImageCreateInfo *create_info) { vk_testing::Image::init(*m_device, *create_info, 0); VkImageAspectFlags image_aspect = 0; - if (VkFormatIsDepthAndStencil(create_info->format)) { + if (FormatIsDepthAndStencil(create_info->format)) { image_aspect = VK_IMAGE_ASPECT_STENCIL_BIT | VK_IMAGE_ASPECT_DEPTH_BIT; - } else if (VkFormatIsDepthOnly(create_info->format)) { + } else if (FormatIsDepthOnly(create_info->format)) { image_aspect = VK_IMAGE_ASPECT_DEPTH_BIT; - } else if (VkFormatIsStencilOnly(create_info->format)) { + } else if (FormatIsStencilOnly(create_info->format)) { image_aspect = VK_IMAGE_ASPECT_STENCIL_BIT; } else { // color image_aspect = VK_IMAGE_ASPECT_COLOR_BIT; @@ -1596,9 +1582,9 @@ void VkDepthStencilObj::Init(VkDeviceObj *device, int32_t width, int32_t height, init(width, height, m_depth_stencil_fmt, usage, VK_IMAGE_TILING_OPTIMAL); VkImageAspectFlags aspect = VK_IMAGE_ASPECT_STENCIL_BIT | VK_IMAGE_ASPECT_DEPTH_BIT; - if (VkFormatIsDepthOnly(format)) + if (FormatIsDepthOnly(format)) aspect = VK_IMAGE_ASPECT_DEPTH_BIT; - else if (VkFormatIsStencilOnly(format)) + else if (FormatIsStencilOnly(format)) aspect = VK_IMAGE_ASPECT_STENCIL_BIT; SetLayout(aspect, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL); diff --git a/tests/vkrenderframework.h b/tests/vkrenderframework.h index f15d19b1726e487c7dec3f8904ff5e122e7d1d07..9d0b2e627fac5ffd0408c0f8b8ae34d5f1d390eb 100644 --- a/tests/vkrenderframework.h +++ b/tests/vkrenderframework.h @@ -446,6 +446,4 @@ class VkPipelineObj : public vk_testing::Pipeline { int m_vertexBufferCount; }; -VkFormat FindDepthStencilFormat(VkPhysicalDevice); - #endif // VKRENDERFRAMEWORK_H