diff options
| author | Petr Kraus <petr_kraus@email.cz> | 2017-05-14 23:43:38 +0200 |
|---|---|---|
| committer | Tobin Ehlis <tobine@google.com> | 2017-05-17 09:30:13 -0600 |
| commit | 64510d8e9981171c115f810e55e4f55fa74ad6d4 (patch) | |
| tree | 34d599e8253a47aa10c06cc4fbd963a8aed644c0 | |
| parent | ffaa557aabe1609713062efe79aea8c7aeb1bf76 (diff) | |
| download | usermoji-64510d8e9981171c115f810e55e4f55fa74ad6d4.tar.xz | |
layers: Transition all to HandleToUint64
Mostly automatic (i.e. probably missed some cases)
| -rw-r--r-- | layers/buffer_validation.cpp | 472 | ||||
| -rw-r--r-- | layers/core_validation.cpp | 956 | ||||
| -rw-r--r-- | layers/descriptor_sets.cpp | 35 | ||||
| -rw-r--r-- | layers/object_tracker.cpp | 94 | ||||
| -rw-r--r-- | layers/parameter_validation.cpp | 36 | ||||
| -rw-r--r-- | layers/swapchain.cpp | 25 |
6 files changed, 783 insertions, 835 deletions
diff --git a/layers/buffer_validation.cpp b/layers/buffer_validation.cpp index c24400e2..2156bc99 100644 --- a/layers/buffer_validation.cpp +++ b/layers/buffer_validation.cpp @@ -81,18 +81,18 @@ bool FindLayoutVerifyNode(layer_data const *device_data, GLOBAL_CB_NODE const *p return false; } if (node.layout != VK_IMAGE_LAYOUT_MAX_ENUM && node.layout != imgsubIt->second.layout) { - log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, - reinterpret_cast<uint64_t &>(imgpair.image), __LINE__, DRAWSTATE_INVALID_LAYOUT, "DS", + log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, HandleToUint64(imgpair.image), + __LINE__, DRAWSTATE_INVALID_LAYOUT, "DS", "Cannot query for VkImage 0x%" PRIx64 " layout when combined aspect mask %d has multiple layout types: %s and %s", - reinterpret_cast<uint64_t &>(imgpair.image), oldAspectMask, string_VkImageLayout(node.layout), + HandleToUint64(imgpair.image), oldAspectMask, string_VkImageLayout(node.layout), string_VkImageLayout(imgsubIt->second.layout)); } if (node.initialLayout != VK_IMAGE_LAYOUT_MAX_ENUM && node.initialLayout != imgsubIt->second.initialLayout) { - log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, - reinterpret_cast<uint64_t &>(imgpair.image), __LINE__, DRAWSTATE_INVALID_LAYOUT, "DS", + log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, HandleToUint64(imgpair.image), + __LINE__, DRAWSTATE_INVALID_LAYOUT, "DS", "Cannot query for VkImage 0x%" PRIx64 " layout when combined aspect mask %d has multiple initial layout types: %s and %s", - reinterpret_cast<uint64_t &>(imgpair.image), oldAspectMask, string_VkImageLayout(node.initialLayout), + HandleToUint64(imgpair.image), oldAspectMask, string_VkImageLayout(node.initialLayout), string_VkImageLayout(imgsubIt->second.initialLayout)); } node = imgsubIt->second; @@ -112,10 +112,10 @@ bool FindLayoutVerifyLayout(layer_data const *device_data, ImageSubresourcePair return false; } if (layout != VK_IMAGE_LAYOUT_MAX_ENUM && layout != imgsubIt->second.layout) { - log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, - reinterpret_cast<uint64_t &>(imgpair.image), __LINE__, DRAWSTATE_INVALID_LAYOUT, "DS", + log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, HandleToUint64(imgpair.image), + __LINE__, DRAWSTATE_INVALID_LAYOUT, "DS", "Cannot query for VkImage 0x%" PRIx64 " layout when combined aspect mask %d has multiple layout types: %s and %s", - reinterpret_cast<uint64_t &>(imgpair.image), oldAspectMask, string_VkImageLayout(layout), + HandleToUint64(imgpair.image), oldAspectMask, string_VkImageLayout(layout), string_VkImageLayout(imgsubIt->second.layout)); } layout = imgsubIt->second.layout; @@ -272,7 +272,7 @@ bool VerifyFramebufferAndRenderPassLayouts(layer_data *device_data, GLOBAL_CB_NO const auto report_data = core_validation::GetReportData(device_data); if (pRenderPassInfo->attachmentCount != framebufferInfo.attachmentCount) { skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(pCB->commandBuffer), __LINE__, DRAWSTATE_INVALID_RENDERPASS, "DS", + HandleToUint64(pCB->commandBuffer), __LINE__, DRAWSTATE_INVALID_RENDERPASS, "DS", "You cannot start a render pass using a framebuffer " "with a different number of attachments."); } @@ -352,10 +352,10 @@ bool ValidateImageAspectLayout(layer_data *device_data, GLOBAL_CB_NODE *pCB, con } else if (node.layout != mem_barrier->oldLayout) { skip |= log_msg(core_validation::GetReportData(device_data), VK_DEBUG_REPORT_ERROR_BIT_EXT, - VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, reinterpret_cast<uint64_t>(pCB->commandBuffer), __LINE__, + VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, HandleToUint64(pCB->commandBuffer), __LINE__, DRAWSTATE_INVALID_IMAGE_LAYOUT, "DS", "For image 0x%" PRIxLEAST64 " you cannot transition the layout of aspect %d from %s when current layout is %s.", - reinterpret_cast<const uint64_t &>(mem_barrier->image), aspect, string_VkImageLayout(mem_barrier->oldLayout), + HandleToUint64(mem_barrier->image), aspect, string_VkImageLayout(mem_barrier->oldLayout), string_VkImageLayout(node.layout)); } return skip; @@ -454,10 +454,10 @@ bool ValidateBarrierLayoutToImageUsage(layer_data *device_data, const VkImageMem if (msg_code != VALIDATION_ERROR_UNDEFINED) { skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, - reinterpret_cast<const uint64_t &>(img_barrier->image), __LINE__, msg_code, "DS", + HandleToUint64(img_barrier->image), __LINE__, msg_code, "DS", "%s: Image barrier 0x%p %sLayout=%s is not compatible with image 0x%" PRIx64 " usage flags 0x%" PRIx32 ". %s", func_name, img_barrier, ((new_not_old) ? "new" : "old"), string_VkImageLayout(layout), - reinterpret_cast<const uint64_t &>(img_barrier->image), usage_flags, validation_error_map[msg_code]); + HandleToUint64(img_barrier->image), usage_flags, validation_error_map[msg_code]); } return skip; } @@ -498,13 +498,12 @@ bool ValidateBarriersToImages(layer_data *device_data, VkCommandBuffer cmdBuffer if ((aspect_mask & ds_mask) != (ds_mask)) { skip |= log_msg(core_validation::GetReportData(device_data), VK_DEBUG_REPORT_ERROR_BIT_EXT, - VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, reinterpret_cast<const uint64_t &>(img_barrier->image), __LINE__, - VALIDATION_ERROR_00302, "DS", - "%s: Image barrier 0x%p references image 0x%" PRIx64 - " of format %s that must have the depth and stencil aspects set, but its " - "aspectMask is 0x%" PRIx32 ". %s", - func_name, img_barrier, reinterpret_cast<const uint64_t &>(img_barrier->image), - string_VkFormat(image_create_info->format), aspect_mask, validation_error_map[VALIDATION_ERROR_00302]); + VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, HandleToUint64(img_barrier->image), __LINE__, + VALIDATION_ERROR_00302, "DS", "%s: Image barrier 0x%p references image 0x%" PRIx64 + " of format %s that must have the depth and stencil aspects set, but its " + "aspectMask is 0x%" PRIx32 ". %s", + func_name, img_barrier, HandleToUint64(img_barrier->image), string_VkFormat(image_create_info->format), + aspect_mask, validation_error_map[VALIDATION_ERROR_00302]); } } uint32_t level_count = ResolveRemainingLevels(&img_barrier->subresourceRange, image_create_info->mipLevels); @@ -565,10 +564,10 @@ bool VerifyImageLayout(layer_data const *device_data, GLOBAL_CB_NODE const *cb_n *error = true; // TODO: Improve log message in the next pass 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_INVALID_IMAGE_LAYOUT, "DS", + HandleToUint64(cb_node->commandBuffer), __LINE__, DRAWSTATE_INVALID_IMAGE_LAYOUT, "DS", "%s: Cannot use image 0x%" PRIxLEAST64 " with specific layout %s that doesn't match the actual current layout %s.", - caller, reinterpret_cast<const uint64_t &>(image), string_VkImageLayout(explicit_layout), + caller, HandleToUint64(image), string_VkImageLayout(explicit_layout), string_VkImageLayout(node.layout)); } } @@ -579,10 +578,10 @@ bool VerifyImageLayout(layer_data const *device_data, GLOBAL_CB_NODE const *cb_n if (image_state->createInfo.tiling != VK_IMAGE_TILING_LINEAR) { // LAYOUT_GENERAL is allowed, but may not be performance optimal, flag as perf warning. skip |= log_msg(report_data, VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, - VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, reinterpret_cast<uint64_t>(cb_node->commandBuffer), - __LINE__, DRAWSTATE_INVALID_IMAGE_LAYOUT, "DS", + VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, HandleToUint64(cb_node->commandBuffer), __LINE__, + DRAWSTATE_INVALID_IMAGE_LAYOUT, "DS", "%s: For optimal performance image 0x%" PRIxLEAST64 " layout should be %s instead of GENERAL.", - caller, reinterpret_cast<const uint64_t &>(image), string_VkImageLayout(optimal_layout)); + caller, HandleToUint64(image), string_VkImageLayout(optimal_layout)); } } else if (GetDeviceExtensions(device_data)->khr_shared_presentable_image) { if (image_state->shared_presentable) { @@ -597,9 +596,9 @@ bool VerifyImageLayout(layer_data const *device_data, GLOBAL_CB_NODE const *cb_n } else { *error = true; 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__, msg_code, "DS", + HandleToUint64(cb_node->commandBuffer), __LINE__, msg_code, "DS", "%s: Layout for image 0x%" PRIxLEAST64 " is %s but can only be %s or VK_IMAGE_LAYOUT_GENERAL. %s", - caller, reinterpret_cast<const uint64_t &>(image), string_VkImageLayout(explicit_layout), + caller, HandleToUint64(image), string_VkImageLayout(explicit_layout), string_VkImageLayout(optimal_layout), validation_error_map[msg_code]); } } @@ -801,7 +800,7 @@ void PostCallRecordCreateImage(layer_data *device_data, const VkImageCreateInfo bool PreCallValidateDestroyImage(layer_data *device_data, VkImage image, IMAGE_STATE **image_state, VK_OBJECT *obj_struct) { const CHECK_DISABLED *disabled = core_validation::GetDisables(device_data); *image_state = core_validation::GetImageState(device_data, image); - *obj_struct = {reinterpret_cast<uint64_t &>(image), kVulkanObjectTypeImage}; + *obj_struct = {HandleToUint64(image), kVulkanObjectTypeImage}; if (disabled->destroy_image) return false; bool skip = false; if (*image_state) { @@ -841,25 +840,25 @@ bool ValidateImageAttributes(layer_data *device_data, IMAGE_STATE *image_state, if (range.aspectMask != VK_IMAGE_ASPECT_COLOR_BIT) { char const str[] = "vkCmdClearColorImage aspectMasks for all subresource ranges must be set to VK_IMAGE_ASPECT_COLOR_BIT"; 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__, DRAWSTATE_INVALID_IMAGE_ASPECT, "IMAGE", str); + HandleToUint64(image_state->image), __LINE__, DRAWSTATE_INVALID_IMAGE_ASPECT, "IMAGE", str); } 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, + HandleToUint64(image_state->image), __LINE__, VALIDATION_ERROR_01088, "IMAGE", "%s. %s", str, validation_error_map[VALIDATION_ERROR_01088]); } 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, + HandleToUint64(image_state->image), __LINE__, VALIDATION_ERROR_01088, "IMAGE", "%s. %s", str, validation_error_map[VALIDATION_ERROR_01088]); } if (!(image_state->createInfo.usage & VK_IMAGE_USAGE_TRANSFER_DST_BIT)) { char const str[] = "vkCmdClearColorImage called with image created without VK_IMAGE_USAGE_TRANSFER_DST_BIT."; 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_01084, "IMAGE", "%s. %s", str, + HandleToUint64(image_state->image), __LINE__, VALIDATION_ERROR_01084, "IMAGE", "%s. %s", str, validation_error_map[VALIDATION_ERROR_01084]); } return skip; @@ -896,7 +895,7 @@ bool VerifyClearImageLayout(layer_data *device_data, GLOBAL_CB_NODE *cb_node, IM if (image_state->createInfo.tiling != VK_IMAGE_TILING_LINEAR) { // LAYOUT_GENERAL is allowed, but may not be performance optimal, flag as perf warning. skip |= log_msg(report_data, VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, - reinterpret_cast<uint64_t &>(image_state->image), __LINE__, DRAWSTATE_INVALID_IMAGE_LAYOUT, "DS", + HandleToUint64(image_state->image), __LINE__, DRAWSTATE_INVALID_IMAGE_LAYOUT, "DS", "%s: Layout for cleared image should be TRANSFER_DST_OPTIMAL instead of GENERAL.", func_name); } } else if (VK_IMAGE_LAYOUT_SHARED_PRESENT_KHR == dest_image_layout) { @@ -923,7 +922,7 @@ bool VerifyClearImageLayout(layer_data *device_data, GLOBAL_CB_NODE *cb_node, IM assert(strcmp(func_name, "vkCmdClearColorImage()") == 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__, error_code, "DS", + HandleToUint64(image_state->image), __LINE__, error_code, "DS", "%s: Layout for cleared image is %s but can only be " "TRANSFER_DST_OPTIMAL or GENERAL. %s", func_name, string_VkImageLayout(dest_image_layout), validation_error_map[error_code]); @@ -1041,14 +1040,14 @@ bool PreCallValidateCmdClearDepthStencilImage(layer_data *device_data, VkCommand "vkCmdClearDepthStencilImage aspectMasks for all subresource ranges must be " "set to VK_IMAGE_ASPECT_DEPTH_BIT and/or VK_IMAGE_ASPECT_STENCIL_BIT"; skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - (uint64_t)commandBuffer, __LINE__, DRAWSTATE_INVALID_IMAGE_ASPECT, "IMAGE", str); + HandleToUint64(commandBuffer), __LINE__, DRAWSTATE_INVALID_IMAGE_ASPECT, "IMAGE", str); } } 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, - validation_error_map[VALIDATION_ERROR_01103]); + skip |= + log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, HandleToUint64(image), + __LINE__, VALIDATION_ERROR_01103, "IMAGE", "%s. %s", str, validation_error_map[VALIDATION_ERROR_01103]); } } return skip; @@ -1196,23 +1195,22 @@ static inline bool CheckItgOffset(layer_data *device_data, const GLOBAL_CB_NODE if (IsExtentAllZeroes(granularity)) { // If the queue family image transfer granularity is (0, 0, 0), then the offset must always be (0, 0, 0) if (IsExtentAllZeroes(&offset_extent) == false) { - 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 (x=%d, y=%d, z=%d) must be (x=0, y=0, z=0) " - "when the command buffer's queue family image transfer granularity is (w=0, h=0, d=0).", - function, i, member, offset->x, offset->y, offset->z); + skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, + HandleToUint64(cb_node->commandBuffer), __LINE__, DRAWSTATE_IMAGE_TRANSFER_GRANULARITY, "DS", + "%s: pRegion[%d].%s (x=%d, y=%d, z=%d) must be (x=0, y=0, z=0) " + "when the command buffer's queue family image transfer granularity is (w=0, h=0, d=0).", + function, i, member, offset->x, offset->y, offset->z); } } else { // If the queue family image transfer granularity is not (0, 0, 0), then the offset dimensions must always be even // integer multiples of the image transfer granularity. if (IsExtentAligned(&offset_extent, granularity) == false) { - 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 (x=%d, y=%d, z=%d) dimensions must be even integer " - "multiples of this command buffer's queue family image transfer granularity (w=%d, h=%d, d=%d).", - function, i, member, offset->x, offset->y, offset->z, granularity->width, granularity->height, granularity->depth); + skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, + HandleToUint64(cb_node->commandBuffer), __LINE__, DRAWSTATE_IMAGE_TRANSFER_GRANULARITY, "DS", + "%s: pRegion[%d].%s (x=%d, y=%d, z=%d) dimensions must be even integer " + "multiples of this command buffer's queue family image transfer granularity (w=%d, h=%d, d=%d).", + function, i, member, offset->x, offset->y, offset->z, granularity->width, granularity->height, + granularity->depth); } } return skip; @@ -1228,13 +1226,12 @@ static inline bool CheckItgExtent(layer_data *device_data, const GLOBAL_CB_NODE // If the queue family image transfer granularity is (0, 0, 0), then the extent must always match the image // subresource extent. if (IsExtentEqual(extent, subresource_extent) == false) { - 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 (w=%d, h=%d, d=%d) must match the image subresource extents (w=%d, h=%d, d=%d) " - "when the command buffer's queue family image transfer granularity is (w=0, h=0, d=0).", - function, i, member, extent->width, extent->height, extent->depth, subresource_extent->width, - subresource_extent->height, subresource_extent->depth); + skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, + HandleToUint64(cb_node->commandBuffer), __LINE__, DRAWSTATE_IMAGE_TRANSFER_GRANULARITY, "DS", + "%s: pRegion[%d].%s (w=%d, h=%d, d=%d) must match the image subresource extents (w=%d, h=%d, d=%d) " + "when the command buffer's queue family image transfer granularity is (w=0, h=0, d=0).", + function, i, member, extent->width, extent->height, extent->depth, subresource_extent->width, + subresource_extent->height, subresource_extent->depth); } } else { // If the queue family image transfer granularity is not (0, 0, 0), then the extent dimensions must always be even @@ -1247,7 +1244,7 @@ static inline bool CheckItgExtent(layer_data *device_data, const GLOBAL_CB_NODE if ((IsExtentAligned(extent, granularity) == false) && (IsExtentEqual(&offset_extent_sum, subresource_extent) == false)) { 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", + HandleToUint64(cb_node->commandBuffer), __LINE__, DRAWSTATE_IMAGE_TRANSFER_GRANULARITY, "DS", "%s: pRegion[%d].%s (w=%d, h=%d, d=%d) dimensions must be even integer multiples of this command buffer's " "queue family image transfer granularity (w=%d, h=%d, d=%d) or offset (x=%d, y=%d, z=%d) + " "extent (w=%d, h=%d, d=%d) must match the image subresource extents (w=%d, h=%d, d=%d).", @@ -1267,7 +1264,7 @@ static inline bool CheckItgInt(layer_data *device_data, const GLOBAL_CB_NODE *cb bool skip = false; 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", + HandleToUint64(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 " "transfer granularity width (%d).", function, i, member, value, granularity); @@ -1282,7 +1279,7 @@ static inline bool CheckItgSize(layer_data *device_data, const GLOBAL_CB_NODE *c bool skip = false; 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", + HandleToUint64(cb_node->commandBuffer), __LINE__, DRAWSTATE_IMAGE_TRANSFER_GRANULARITY, "DS", "%s: pRegion[%d].%s (%" PRIdLEAST64 ") must be an even integer multiple of this command buffer's queue family image transfer " "granularity width (%d).", @@ -1347,17 +1344,17 @@ bool PreCallValidateCmdCopyImage(layer_data *device_data, GLOBAL_CB_NODE *cb_nod if (regions[i].srcSubresource.layerCount == 0) { std::stringstream ss; ss << "vkCmdCopyImage: number of layers in pRegions[" << i << "] srcSubresource is zero"; - skip |= log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t &>(command_buffer), __LINE__, DRAWSTATE_INVALID_IMAGE_ASPECT, "IMAGE", "%s", - ss.str().c_str()); + skip |= + log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, + HandleToUint64(command_buffer), __LINE__, DRAWSTATE_INVALID_IMAGE_ASPECT, "IMAGE", "%s", ss.str().c_str()); } if (regions[i].dstSubresource.layerCount == 0) { std::stringstream ss; ss << "vkCmdCopyImage: number of layers in pRegions[" << i << "] dstSubresource is zero"; - skip |= log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t &>(command_buffer), __LINE__, DRAWSTATE_INVALID_IMAGE_ASPECT, "IMAGE", "%s", - ss.str().c_str()); + skip |= + log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, + HandleToUint64(command_buffer), __LINE__, DRAWSTATE_INVALID_IMAGE_ASPECT, "IMAGE", "%s", ss.str().c_str()); } if (!GetDeviceExtensions(device_data)->khr_maintenance1) { @@ -1367,7 +1364,7 @@ bool PreCallValidateCmdCopyImage(layer_data *device_data, GLOBAL_CB_NODE *cb_nod ss << "vkCmdCopyImage: number of layers in source and destination subresources for pRegions[" << i << "] do not match"; skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t &>(command_buffer), __LINE__, VALIDATION_ERROR_01198, "IMAGE", "%s. %s", + HandleToUint64(command_buffer), __LINE__, VALIDATION_ERROR_01198, "IMAGE", "%s. %s", ss.str().c_str(), validation_error_map[VALIDATION_ERROR_01198]); } } @@ -1376,7 +1373,7 @@ bool PreCallValidateCmdCopyImage(layer_data *device_data, GLOBAL_CB_NODE *cb_nod if (regions[i].srcSubresource.aspectMask != regions[i].dstSubresource.aspectMask) { char const str[] = "vkCmdCopyImage: Src and dest aspectMasks for each region must match"; skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t &>(command_buffer), __LINE__, VALIDATION_ERROR_01197, "IMAGE", "%s. %s", str, + HandleToUint64(command_buffer), __LINE__, VALIDATION_ERROR_01197, "IMAGE", "%s. %s", str, validation_error_map[VALIDATION_ERROR_01197]); } @@ -1386,8 +1383,8 @@ bool PreCallValidateCmdCopyImage(layer_data *device_data, GLOBAL_CB_NODE *cb_nod ss << "vkCmdCopyImage: pRegion[" << i << "] srcSubresource.aspectMask cannot specify aspects not present in source image"; skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t &>(command_buffer), __LINE__, VALIDATION_ERROR_01200, "IMAGE", "%s. %s", - ss.str().c_str(), validation_error_map[VALIDATION_ERROR_01200]); + HandleToUint64(command_buffer), __LINE__, VALIDATION_ERROR_01200, "IMAGE", "%s. %s", ss.str().c_str(), + validation_error_map[VALIDATION_ERROR_01200]); } // For each region, the aspectMask member of dstSubresource must be present in the destination image @@ -1395,8 +1392,8 @@ bool PreCallValidateCmdCopyImage(layer_data *device_data, GLOBAL_CB_NODE *cb_nod std::stringstream ss; ss << "vkCmdCopyImage: pRegion[" << i << "] dstSubresource.aspectMask cannot specify aspects not present in dest image"; skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t &>(command_buffer), __LINE__, VALIDATION_ERROR_01201, "IMAGE", "%s. %s", - ss.str().c_str(), validation_error_map[VALIDATION_ERROR_01201]); + HandleToUint64(command_buffer), __LINE__, VALIDATION_ERROR_01201, "IMAGE", "%s. %s", ss.str().c_str(), + validation_error_map[VALIDATION_ERROR_01201]); } // AspectMask must not contain VK_IMAGE_ASPECT_METADATA_BIT @@ -1405,8 +1402,8 @@ bool PreCallValidateCmdCopyImage(layer_data *device_data, GLOBAL_CB_NODE *cb_nod std::stringstream ss; ss << "vkCmdCopyImage: pRegions[" << i << "] may not specify aspectMask containing VK_IMAGE_ASPECT_METADATA_BIT"; skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t &>(command_buffer), __LINE__, VALIDATION_ERROR_01222, "IMAGE", "%s. %s", - ss.str().c_str(), validation_error_map[VALIDATION_ERROR_01222]); + HandleToUint64(command_buffer), __LINE__, VALIDATION_ERROR_01222, "IMAGE", "%s. %s", ss.str().c_str(), + validation_error_map[VALIDATION_ERROR_01222]); } // For each region, if aspectMask contains VK_IMAGE_ASPECT_COLOR_BIT, it must not contain either of @@ -1415,7 +1412,7 @@ bool PreCallValidateCmdCopyImage(layer_data *device_data, GLOBAL_CB_NODE *cb_nod (regions[i].srcSubresource.aspectMask & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT))) { char const str[] = "vkCmdCopyImage aspectMask cannot specify both COLOR and DEPTH/STENCIL aspects"; skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t &>(command_buffer), __LINE__, VALIDATION_ERROR_01221, "IMAGE", "%s. %s", str, + HandleToUint64(command_buffer), __LINE__, VALIDATION_ERROR_01221, "IMAGE", "%s. %s", str, validation_error_map[VALIDATION_ERROR_01221]); } @@ -1430,7 +1427,7 @@ bool PreCallValidateCmdCopyImage(layer_data *device_data, GLOBAL_CB_NODE *cb_nod ss << "vkCmdCopyImage: src or dstImage type was IMAGE_TYPE_3D, but in subRegion[" << i << "] baseArrayLayer was not zero or layerCount was not 1."; skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t &>(command_buffer), __LINE__, VALIDATION_ERROR_01199, "IMAGE", "%s. %s", + HandleToUint64(command_buffer), __LINE__, VALIDATION_ERROR_01199, "IMAGE", "%s. %s", ss.str().c_str(), validation_error_map[VALIDATION_ERROR_01199]); } } @@ -1441,16 +1438,16 @@ bool PreCallValidateCmdCopyImage(layer_data *device_data, GLOBAL_CB_NODE *cb_nod ss << "vkCmdCopyImage: pRegions[" << i << "] specifies a src mipLevel greater than the number specified when the srcImage was created."; skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t &>(command_buffer), __LINE__, VALIDATION_ERROR_01223, "IMAGE", "%s. %s", - ss.str().c_str(), validation_error_map[VALIDATION_ERROR_01223]); + HandleToUint64(command_buffer), __LINE__, VALIDATION_ERROR_01223, "IMAGE", "%s. %s", ss.str().c_str(), + validation_error_map[VALIDATION_ERROR_01223]); } if (regions[i].dstSubresource.mipLevel >= dst_image_state->createInfo.mipLevels) { std::stringstream ss; ss << "vkCmdCopyImage: pRegions[" << i << "] specifies a dst mipLevel greater than the number specified when the dstImage was created."; skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t &>(command_buffer), __LINE__, VALIDATION_ERROR_01223, "IMAGE", "%s. %s", - ss.str().c_str(), validation_error_map[VALIDATION_ERROR_01223]); + HandleToUint64(command_buffer), __LINE__, VALIDATION_ERROR_01223, "IMAGE", "%s. %s", ss.str().c_str(), + validation_error_map[VALIDATION_ERROR_01223]); } // (baseArrayLayer + layerCount) must be less than or equal to the arrayLayers specified in VkImageCreateInfo when the @@ -1462,8 +1459,8 @@ bool PreCallValidateCmdCopyImage(layer_data *device_data, GLOBAL_CB_NODE *cb_nod << "] baseArrayLayer + layerCount is " << (regions[i].srcSubresource.baseArrayLayer + regions[i].srcSubresource.layerCount); skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t &>(command_buffer), __LINE__, VALIDATION_ERROR_01224, "IMAGE", "%s. %s", - ss.str().c_str(), validation_error_map[VALIDATION_ERROR_01224]); + HandleToUint64(command_buffer), __LINE__, VALIDATION_ERROR_01224, "IMAGE", "%s. %s", ss.str().c_str(), + validation_error_map[VALIDATION_ERROR_01224]); } if ((regions[i].dstSubresource.baseArrayLayer + regions[i].dstSubresource.layerCount) > dst_image_state->createInfo.arrayLayers) { @@ -1472,8 +1469,8 @@ bool PreCallValidateCmdCopyImage(layer_data *device_data, GLOBAL_CB_NODE *cb_nod << "] baseArrayLayer + layerCount is " << (regions[i].dstSubresource.baseArrayLayer + regions[i].dstSubresource.layerCount); skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t &>(command_buffer), __LINE__, VALIDATION_ERROR_01224, "IMAGE", "%s. %s", - ss.str().c_str(), validation_error_map[VALIDATION_ERROR_01224]); + HandleToUint64(command_buffer), __LINE__, VALIDATION_ERROR_01224, "IMAGE", "%s. %s", ss.str().c_str(), + validation_error_map[VALIDATION_ERROR_01224]); } // Check region extents for 1D-1D, 2D-2D, and 3D-3D copies @@ -1487,7 +1484,7 @@ bool PreCallValidateCmdCopyImage(layer_data *device_data, GLOBAL_CB_NODE *cb_nod << " ], extent [ " << regions[i].extent.width << ", " << regions[i].extent.height << ", " << regions[i].extent.depth << " ] exceeds the source image dimensions"; skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t &>(command_buffer), __LINE__, VALIDATION_ERROR_01175, "IMAGE", "%s. %s", + HandleToUint64(command_buffer), __LINE__, VALIDATION_ERROR_01175, "IMAGE", "%s. %s", ss.str().c_str(), validation_error_map[VALIDATION_ERROR_01175]); } @@ -1500,7 +1497,7 @@ bool PreCallValidateCmdCopyImage(layer_data *device_data, GLOBAL_CB_NODE *cb_nod << " ], extent [ " << regions[i].extent.width << ", " << regions[i].extent.height << ", " << regions[i].extent.depth << " ] exceeds the destination image dimensions"; skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t &>(command_buffer), __LINE__, VALIDATION_ERROR_01176, "IMAGE", "%s. %s", + HandleToUint64(command_buffer), __LINE__, VALIDATION_ERROR_01176, "IMAGE", "%s. %s", ss.str().c_str(), validation_error_map[VALIDATION_ERROR_01176]); } } @@ -1510,7 +1507,7 @@ bool PreCallValidateCmdCopyImage(layer_data *device_data, GLOBAL_CB_NODE *cb_nod uint32_t extent_check = ExceedsBounds(&(regions[i].srcOffset), ®ions[i].extent, &subresource_extent); if (extent_check & x_bit) { skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t &>(command_buffer), __LINE__, VALIDATION_ERROR_01202, "IMAGE", + HandleToUint64(command_buffer), __LINE__, VALIDATION_ERROR_01202, "IMAGE", "vkCmdCopyImage: Source image pRegion %1d x-dimension offset [%1d] + extent [%1d] exceeds subResource " "width [%1d]. %s", i, regions[i].srcOffset.x, regions[i].extent.width, subresource_extent.width, @@ -1519,7 +1516,7 @@ bool PreCallValidateCmdCopyImage(layer_data *device_data, GLOBAL_CB_NODE *cb_nod if (extent_check & y_bit) { skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t &>(command_buffer), __LINE__, VALIDATION_ERROR_01203, "IMAGE", + HandleToUint64(command_buffer), __LINE__, VALIDATION_ERROR_01203, "IMAGE", "vkCmdCopyImage: Source image pRegion %1d y-dimension offset [%1d] + extent [%1d] exceeds subResource " "height [%1d]. %s", i, regions[i].srcOffset.y, regions[i].extent.height, subresource_extent.height, @@ -1527,7 +1524,7 @@ bool PreCallValidateCmdCopyImage(layer_data *device_data, GLOBAL_CB_NODE *cb_nod } if (extent_check & z_bit) { skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t &>(command_buffer), __LINE__, VALIDATION_ERROR_01204, "IMAGE", + HandleToUint64(command_buffer), __LINE__, VALIDATION_ERROR_01204, "IMAGE", "vkCmdCopyImage: Source image pRegion %1d z-dimension offset [%1d] + extent [%1d] exceeds subResource " "depth [%1d]. %s", i, regions[i].srcOffset.z, regions[i].extent.depth, subresource_extent.depth, @@ -1538,7 +1535,7 @@ bool PreCallValidateCmdCopyImage(layer_data *device_data, GLOBAL_CB_NODE *cb_nod extent_check = ExceedsBounds(&(regions[i].dstOffset), ®ions[i].extent, &subresource_extent); if (extent_check & x_bit) { skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t &>(command_buffer), __LINE__, VALIDATION_ERROR_01205, "IMAGE", + HandleToUint64(command_buffer), __LINE__, VALIDATION_ERROR_01205, "IMAGE", "vkCmdCopyImage: Dest image pRegion %1d x-dimension offset [%1d] + extent [%1d] exceeds subResource " "width [%1d]. %s", i, regions[i].dstOffset.x, regions[i].extent.width, subresource_extent.width, @@ -1546,7 +1543,7 @@ bool PreCallValidateCmdCopyImage(layer_data *device_data, GLOBAL_CB_NODE *cb_nod } if (extent_check & y_bit) { skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t &>(command_buffer), __LINE__, VALIDATION_ERROR_01206, "IMAGE", + HandleToUint64(command_buffer), __LINE__, VALIDATION_ERROR_01206, "IMAGE", "vkCmdCopyImage: Dest image pRegion %1d y-dimension offset [%1d] + extent [%1d] exceeds subResource " "height [%1d]. %s", i, regions[i].dstOffset.y, regions[i].extent.height, subresource_extent.height, @@ -1554,7 +1551,7 @@ bool PreCallValidateCmdCopyImage(layer_data *device_data, GLOBAL_CB_NODE *cb_nod } if (extent_check & z_bit) { skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t &>(command_buffer), __LINE__, VALIDATION_ERROR_01207, "IMAGE", + HandleToUint64(command_buffer), __LINE__, VALIDATION_ERROR_01207, "IMAGE", "vkCmdCopyImage: Dest image pRegion %1d z-dimension offset [%1d] + extent [%1d] exceeds subResource " "depth [%1d]. %s", i, regions[i].dstOffset.z, regions[i].extent.depth, subresource_extent.depth, @@ -1569,8 +1566,8 @@ bool PreCallValidateCmdCopyImage(layer_data *device_data, GLOBAL_CB_NODE *cb_nod std::stringstream ss; ss << "vkCmdCopyImage: pRegions[" << i << "] src overlaps with pRegions[" << j << "]."; skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t &>(command_buffer), __LINE__, VALIDATION_ERROR_01177, "IMAGE", - "%s. %s", ss.str().c_str(), validation_error_map[VALIDATION_ERROR_01177]); + HandleToUint64(command_buffer), __LINE__, VALIDATION_ERROR_01177, "IMAGE", "%s. %s", + ss.str().c_str(), validation_error_map[VALIDATION_ERROR_01177]); } } } @@ -1582,9 +1579,8 @@ bool PreCallValidateCmdCopyImage(layer_data *device_data, GLOBAL_CB_NODE *cb_nod 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 |= - log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t &>(command_buffer), __LINE__, DRAWSTATE_MISMATCHED_IMAGE_FORMAT, "IMAGE", str); + skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, + HandleToUint64(command_buffer), __LINE__, DRAWSTATE_MISMATCHED_IMAGE_FORMAT, "IMAGE", str); } } else { size_t srcSize = FormatSize(src_image_state->createInfo.format); @@ -1592,7 +1588,7 @@ bool PreCallValidateCmdCopyImage(layer_data *device_data, GLOBAL_CB_NODE *cb_nod 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, - reinterpret_cast<uint64_t &>(command_buffer), __LINE__, VALIDATION_ERROR_01184, "IMAGE", "%s. %s", str, + HandleToUint64(command_buffer), __LINE__, VALIDATION_ERROR_01184, "IMAGE", "%s. %s", str, validation_error_map[VALIDATION_ERROR_01184]); } } @@ -1601,7 +1597,7 @@ bool PreCallValidateCmdCopyImage(layer_data *device_data, GLOBAL_CB_NODE *cb_nod if (src_image_state->createInfo.samples != dst_image_state->createInfo.samples) { char const str[] = "vkCmdCopyImage() called on image pair with non-identical sample counts."; skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t &>(command_buffer), __LINE__, VALIDATION_ERROR_01185, "IMAGE", "%s %s", str, + HandleToUint64(command_buffer), __LINE__, VALIDATION_ERROR_01185, "IMAGE", "%s %s", str, validation_error_map[VALIDATION_ERROR_01185]); } @@ -1677,7 +1673,7 @@ bool PreCallValidateCmdClearAttachments(layer_data *device_data, VkCommandBuffer // CmdClearAttachments. skip |= log_msg(report_data, VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t &>(commandBuffer), 0, DRAWSTATE_CLEAR_CMD_BEFORE_DRAW, "DS", + HandleToUint64(commandBuffer), 0, DRAWSTATE_CLEAR_CMD_BEFORE_DRAW, "DS", "vkCmdClearAttachments() issued on command buffer object 0x%p prior to any Draw Cmds." " It is recommended you use RenderPass LOAD_OP_CLEAR on Attachments prior to any Draw.", commandBuffer); @@ -1697,23 +1693,23 @@ bool PreCallValidateCmdClearAttachments(layer_data *device_data, VkCommandBuffer if (0 == clear_desc->aspectMask) { skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(commandBuffer), __LINE__, VALIDATION_ERROR_01128, "IMAGE", "%s", + HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_01128, "IMAGE", "%s", validation_error_map[VALIDATION_ERROR_01128]); } else if (clear_desc->aspectMask & VK_IMAGE_ASPECT_METADATA_BIT) { skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(commandBuffer), __LINE__, VALIDATION_ERROR_01126, "IMAGE", "%s", + HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_01126, "IMAGE", "%s", validation_error_map[VALIDATION_ERROR_01126]); } else if (clear_desc->aspectMask & VK_IMAGE_ASPECT_COLOR_BIT) { if (clear_desc->colorAttachment >= subpass_desc->colorAttachmentCount) { skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(commandBuffer), __LINE__, VALIDATION_ERROR_01114, "DS", + HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_01114, "DS", "vkCmdClearAttachments() color attachment index %d out of range for active subpass %d. %s", clear_desc->colorAttachment, cb_node->activeSubpass, validation_error_map[VALIDATION_ERROR_01114]); } else if (subpass_desc->pColorAttachments[clear_desc->colorAttachment].attachment == VK_ATTACHMENT_UNUSED) { skip |= log_msg(report_data, VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, - VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, reinterpret_cast<uint64_t>(commandBuffer), - __LINE__, DRAWSTATE_MISSING_ATTACHMENT_REFERENCE, "DS", + VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, HandleToUint64(commandBuffer), __LINE__, + DRAWSTATE_MISSING_ATTACHMENT_REFERENCE, "DS", "vkCmdClearAttachments() color attachment index %d is VK_ATTACHMENT_UNUSED; ignored.", clear_desc->colorAttachment); } else { @@ -1725,7 +1721,7 @@ bool PreCallValidateCmdClearAttachments(layer_data *device_data, VkCommandBuffer char const str[] = "vkCmdClearAttachments aspectMask [%d] must set only VK_IMAGE_ASPECT_COLOR_BIT of a color attachment. %s"; skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(commandBuffer), __LINE__, VALIDATION_ERROR_01125, "IMAGE", str, i, + HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_01125, "IMAGE", str, i, validation_error_map[VALIDATION_ERROR_01125]); } } else { // Must be depth and/or stencil @@ -1733,14 +1729,14 @@ bool PreCallValidateCmdClearAttachments(layer_data *device_data, VkCommandBuffer ((clear_desc->aspectMask & VK_IMAGE_ASPECT_STENCIL_BIT) != VK_IMAGE_ASPECT_STENCIL_BIT)) { char const str[] = "vkCmdClearAttachments aspectMask [%d] is not a valid combination of bits. %s"; skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(commandBuffer), __LINE__, VALIDATION_ERROR_01127, "IMAGE", str, i, + HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_01127, "IMAGE", str, i, validation_error_map[VALIDATION_ERROR_01127]); } if (!subpass_desc->pDepthStencilAttachment || (subpass_desc->pDepthStencilAttachment->attachment == VK_ATTACHMENT_UNUSED)) { skip |= log_msg( report_data, VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(commandBuffer), __LINE__, DRAWSTATE_MISSING_ATTACHMENT_REFERENCE, "DS", + HandleToUint64(commandBuffer), __LINE__, DRAWSTATE_MISSING_ATTACHMENT_REFERENCE, "DS", "vkCmdClearAttachments() depth/stencil clear with no depth/stencil attachment in subpass; ignored"); } else { image_view = framebuffer->createInfo.pAttachments[subpass_desc->pDepthStencilAttachment->attachment]; @@ -1755,7 +1751,7 @@ bool PreCallValidateCmdClearAttachments(layer_data *device_data, VkCommandBuffer if ((cb_node->createInfo.level == VK_COMMAND_BUFFER_LEVEL_PRIMARY) && (false == ContainsRect(cb_node->activeRenderPassBeginInfo.renderArea, pRects[j].rect))) { skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(commandBuffer), __LINE__, VALIDATION_ERROR_01115, "DS", + HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_01115, "DS", "vkCmdClearAttachments(): The area defined by pRects[%d] is not contained in the area of " "the current render pass instance. %s", j, validation_error_map[VALIDATION_ERROR_01115]); @@ -1767,7 +1763,7 @@ bool PreCallValidateCmdClearAttachments(layer_data *device_data, VkCommandBuffer if ((pRects[j].baseArrayLayer < attachment_base_array_layer) || pRects[j].layerCount > attachment_layer_count) { skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(commandBuffer), __LINE__, VALIDATION_ERROR_01116, "DS", + HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_01116, "DS", "vkCmdClearAttachments(): The layers defined in pRects[%d] are not contained in the layers of " "pAttachment[%d]. %s", j, i, validation_error_map[VALIDATION_ERROR_01116]); @@ -1796,19 +1792,17 @@ bool PreCallValidateCmdResolveImage(layer_data *device_data, GLOBAL_CB_NODE *cb_ if (pRegions[i].srcSubresource.layerCount == 0) { char const str[] = "vkCmdResolveImage: number of layers in source subresource is zero"; skip |= log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(cb_node->commandBuffer), __LINE__, DRAWSTATE_MISMATCHED_IMAGE_ASPECT, - "IMAGE", str); + HandleToUint64(cb_node->commandBuffer), __LINE__, DRAWSTATE_MISMATCHED_IMAGE_ASPECT, "IMAGE", str); } if (pRegions[i].dstSubresource.layerCount == 0) { char const str[] = "vkCmdResolveImage: number of layers in destination subresource is zero"; skip |= log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(cb_node->commandBuffer), __LINE__, DRAWSTATE_MISMATCHED_IMAGE_ASPECT, - "IMAGE", str); + HandleToUint64(cb_node->commandBuffer), __LINE__, DRAWSTATE_MISMATCHED_IMAGE_ASPECT, "IMAGE", str); } if (pRegions[i].srcSubresource.layerCount != pRegions[i].dstSubresource.layerCount) { 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__, VALIDATION_ERROR_01339, "IMAGE", + HandleToUint64(cb_node->commandBuffer), __LINE__, VALIDATION_ERROR_01339, "IMAGE", "vkCmdResolveImage: layerCount in source and destination subresource of pRegions[%d] does not match. %s", i, validation_error_map[VALIDATION_ERROR_01339]); } @@ -1817,34 +1811,32 @@ bool PreCallValidateCmdResolveImage(layer_data *device_data, GLOBAL_CB_NODE *cb_ char const str[] = "vkCmdResolveImage: src and dest aspectMasks for each region must specify only VK_IMAGE_ASPECT_COLOR_BIT"; 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__, VALIDATION_ERROR_01338, "IMAGE", - "%s. %s", str, validation_error_map[VALIDATION_ERROR_01338]); + HandleToUint64(cb_node->commandBuffer), __LINE__, VALIDATION_ERROR_01338, "IMAGE", "%s. %s", str, + validation_error_map[VALIDATION_ERROR_01338]); } } if (src_image_state->createInfo.format != dst_image_state->createInfo.format) { char const str[] = "vkCmdResolveImage called with unmatched source and dest formats."; skip |= log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(cb_node->commandBuffer), __LINE__, DRAWSTATE_MISMATCHED_IMAGE_FORMAT, - "IMAGE", str); + HandleToUint64(cb_node->commandBuffer), __LINE__, DRAWSTATE_MISMATCHED_IMAGE_FORMAT, "IMAGE", str); } if (src_image_state->createInfo.imageType != dst_image_state->createInfo.imageType) { char const str[] = "vkCmdResolveImage called with unmatched source and dest image types."; skip |= log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(cb_node->commandBuffer), __LINE__, DRAWSTATE_MISMATCHED_IMAGE_TYPE, "IMAGE", - str); + HandleToUint64(cb_node->commandBuffer), __LINE__, DRAWSTATE_MISMATCHED_IMAGE_TYPE, "IMAGE", str); } if (src_image_state->createInfo.samples == VK_SAMPLE_COUNT_1_BIT) { char const str[] = "vkCmdResolveImage called with source sample count less than 2."; 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__, VALIDATION_ERROR_01320, "IMAGE", "%s. %s", - str, validation_error_map[VALIDATION_ERROR_01320]); + HandleToUint64(cb_node->commandBuffer), __LINE__, VALIDATION_ERROR_01320, "IMAGE", "%s. %s", str, + validation_error_map[VALIDATION_ERROR_01320]); } if (dst_image_state->createInfo.samples != VK_SAMPLE_COUNT_1_BIT) { char const str[] = "vkCmdResolveImage called with dest sample count greater than 1."; 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__, VALIDATION_ERROR_01321, "IMAGE", "%s. %s", - str, validation_error_map[VALIDATION_ERROR_01321]); + HandleToUint64(cb_node->commandBuffer), __LINE__, VALIDATION_ERROR_01321, "IMAGE", "%s. %s", str, + validation_error_map[VALIDATION_ERROR_01321]); } // TODO: Need to validate image layouts, which will include layout validation for shared presentable images } else { @@ -1900,8 +1892,8 @@ bool PreCallValidateCmdBlitImage(layer_data *device_data, GLOBAL_CB_NODE *cb_nod std::stringstream ss; ss << "vkCmdBlitImage: pRegions[" << i << "].srcOffsets specify a zero-volume area."; skip |= log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(cb_node->commandBuffer), __LINE__, DRAWSTATE_INVALID_EXTENTS, "IMAGE", - "%s", ss.str().c_str()); + HandleToUint64(cb_node->commandBuffer), __LINE__, DRAWSTATE_INVALID_EXTENTS, "IMAGE", "%s", + ss.str().c_str()); } if ((pRegions[i].dstOffsets[0].x == pRegions[i].dstOffsets[1].x) || (pRegions[i].dstOffsets[0].y == pRegions[i].dstOffsets[1].y) || @@ -1909,34 +1901,32 @@ bool PreCallValidateCmdBlitImage(layer_data *device_data, GLOBAL_CB_NODE *cb_nod std::stringstream ss; ss << "vkCmdBlitImage: pRegions[" << i << "].dstOffsets specify a zero-volume area."; skip |= log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(cb_node->commandBuffer), __LINE__, DRAWSTATE_INVALID_EXTENTS, "IMAGE", - "%s", ss.str().c_str()); + HandleToUint64(cb_node->commandBuffer), __LINE__, DRAWSTATE_INVALID_EXTENTS, "IMAGE", "%s", + ss.str().c_str()); } if (pRegions[i].srcSubresource.layerCount == 0) { char const str[] = "vkCmdBlitImage: number of layers in source subresource is zero"; skip |= log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(cb_node->commandBuffer), __LINE__, DRAWSTATE_MISMATCHED_IMAGE_ASPECT, - "IMAGE", str); + HandleToUint64(cb_node->commandBuffer), __LINE__, DRAWSTATE_MISMATCHED_IMAGE_ASPECT, "IMAGE", str); } if (pRegions[i].dstSubresource.layerCount == 0) { char const str[] = "vkCmdBlitImage: number of layers in destination subresource is zero"; skip |= log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(cb_node->commandBuffer), __LINE__, DRAWSTATE_MISMATCHED_IMAGE_ASPECT, - "IMAGE", str); + HandleToUint64(cb_node->commandBuffer), __LINE__, DRAWSTATE_MISMATCHED_IMAGE_ASPECT, "IMAGE", str); } // Check that src/dst layercounts match if (pRegions[i].srcSubresource.layerCount != pRegions[i].dstSubresource.layerCount) { 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__, VALIDATION_ERROR_01304, "IMAGE", + HandleToUint64(cb_node->commandBuffer), __LINE__, VALIDATION_ERROR_01304, "IMAGE", "vkCmdBlitImage: layerCount in source and destination subresource of pRegions[%d] does not match. %s", i, validation_error_map[VALIDATION_ERROR_01304]); } if (pRegions[i].srcSubresource.aspectMask != pRegions[i].dstSubresource.aspectMask) { 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__, VALIDATION_ERROR_01303, "IMAGE", + HandleToUint64(cb_node->commandBuffer), __LINE__, VALIDATION_ERROR_01303, "IMAGE", "vkCmdBlitImage: aspectMask members for pRegion[%d] do not match. %s", i, validation_error_map[VALIDATION_ERROR_01303]); } @@ -1952,7 +1942,7 @@ bool PreCallValidateCmdBlitImage(layer_data *device_data, GLOBAL_CB_NODE *cb_nod << "the other one must also have unsigned integer format. " << "Source format is " << string_VkFormat(src_format) << " Destination format is " << string_VkFormat(dst_format); 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__, VALIDATION_ERROR_02191, "IMAGE", "%s. %s", + HandleToUint64(cb_node->commandBuffer), __LINE__, VALIDATION_ERROR_02191, "IMAGE", "%s. %s", ss.str().c_str(), validation_error_map[VALIDATION_ERROR_02191]); } @@ -1963,7 +1953,7 @@ bool PreCallValidateCmdBlitImage(layer_data *device_data, GLOBAL_CB_NODE *cb_nod << "the other one must also have signed integer format. " << "Source format is " << string_VkFormat(src_format) << " Destination format is " << string_VkFormat(dst_format); 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__, VALIDATION_ERROR_02190, "IMAGE", "%s. %s", + HandleToUint64(cb_node->commandBuffer), __LINE__, VALIDATION_ERROR_02190, "IMAGE", "%s. %s", ss.str().c_str(), validation_error_map[VALIDATION_ERROR_02190]); } @@ -1976,8 +1966,8 @@ bool PreCallValidateCmdBlitImage(layer_data *device_data, GLOBAL_CB_NODE *cb_nod << "Source format is " << string_VkFormat(src_format) << " Destination format is " << string_VkFormat(dst_format); 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__, VALIDATION_ERROR_02192, "IMAGE", - "%s. %s", ss.str().c_str(), validation_error_map[VALIDATION_ERROR_02192]); + HandleToUint64(cb_node->commandBuffer), __LINE__, VALIDATION_ERROR_02192, "IMAGE", "%s. %s", + ss.str().c_str(), validation_error_map[VALIDATION_ERROR_02192]); } for (uint32_t i = 0; i < regionCount; i++) { @@ -1990,8 +1980,8 @@ bool PreCallValidateCmdBlitImage(layer_data *device_data, GLOBAL_CB_NODE *cb_nod "VK_IMAGE_ASPECT_DEPTH_BIT " << "and VK_IMAGE_ASPECT_STENCIL_BIT set in srcImage and dstImage"; 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_INVALID_IMAGE_ASPECT, "IMAGE", "%s", ss.str().c_str()); + HandleToUint64(cb_node->commandBuffer), __LINE__, DRAWSTATE_INVALID_IMAGE_ASPECT, "IMAGE", + "%s", ss.str().c_str()); } } else if (FormatIsStencilOnly(src_format)) { if (srcAspect != VK_IMAGE_ASPECT_STENCIL_BIT) { @@ -1999,8 +1989,8 @@ bool PreCallValidateCmdBlitImage(layer_data *device_data, GLOBAL_CB_NODE *cb_nod ss << "vkCmdBlitImage: Stencil-only image formats must have only the VK_IMAGE_ASPECT_STENCIL_BIT " << "set in both the srcImage and dstImage"; 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_INVALID_IMAGE_ASPECT, "IMAGE", "%s", ss.str().c_str()); + HandleToUint64(cb_node->commandBuffer), __LINE__, DRAWSTATE_INVALID_IMAGE_ASPECT, "IMAGE", + "%s", ss.str().c_str()); } } else if (FormatIsDepthOnly(src_format)) { if (srcAspect != VK_IMAGE_ASPECT_DEPTH_BIT) { @@ -2008,8 +1998,8 @@ bool PreCallValidateCmdBlitImage(layer_data *device_data, GLOBAL_CB_NODE *cb_nod ss << "vkCmdBlitImage: Depth-only image formats must have only the VK_IMAGE_ASPECT_DEPTH " << "set in both the srcImage and dstImage"; 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_INVALID_IMAGE_ASPECT, "IMAGE", "%s", ss.str().c_str()); + HandleToUint64(cb_node->commandBuffer), __LINE__, DRAWSTATE_INVALID_IMAGE_ASPECT, "IMAGE", + "%s", ss.str().c_str()); } } } @@ -2021,7 +2011,7 @@ bool PreCallValidateCmdBlitImage(layer_data *device_data, GLOBAL_CB_NODE *cb_nod ss << "vkCmdBlitImage: If the format of srcImage is a depth, stencil, or depth stencil " << "then filter must be VK_FILTER_NEAREST."; 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__, VALIDATION_ERROR_02193, "IMAGE", "%s. %s", + HandleToUint64(cb_node->commandBuffer), __LINE__, VALIDATION_ERROR_02193, "IMAGE", "%s. %s", ss.str().c_str(), validation_error_map[VALIDATION_ERROR_02193]); } } else { @@ -2061,24 +2051,22 @@ bool ValidateCmdBufImageLayouts(layer_data *device_data, GLOBAL_CB_NODE *pCB, // TODO: Set memory invalid which is in mem_tracker currently } else if (imageLayout != cb_image_data.second.initialLayout) { if (cb_image_data.first.hasSubresource) { - skip |= log_msg( - report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t &>(pCB->commandBuffer), __LINE__, DRAWSTATE_INVALID_IMAGE_LAYOUT, "DS", - "Cannot submit cmd buffer using image (0x%" PRIx64 - ") [sub-resource: aspectMask 0x%X array layer %u, mip level %u], " - "with layout %s when first use is %s.", - reinterpret_cast<const uint64_t &>(cb_image_data.first.image), cb_image_data.first.subresource.aspectMask, - cb_image_data.first.subresource.arrayLayer, cb_image_data.first.subresource.mipLevel, - string_VkImageLayout(imageLayout), string_VkImageLayout(cb_image_data.second.initialLayout)); + skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, + HandleToUint64(pCB->commandBuffer), __LINE__, DRAWSTATE_INVALID_IMAGE_LAYOUT, "DS", + "Cannot submit cmd buffer using image (0x%" PRIx64 + ") [sub-resource: aspectMask 0x%X array layer %u, mip level %u], " + "with layout %s when first use is %s.", + HandleToUint64(cb_image_data.first.image), cb_image_data.first.subresource.aspectMask, + cb_image_data.first.subresource.arrayLayer, cb_image_data.first.subresource.mipLevel, + string_VkImageLayout(imageLayout), string_VkImageLayout(cb_image_data.second.initialLayout)); } else { - skip |= - log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t &>(pCB->commandBuffer), __LINE__, DRAWSTATE_INVALID_IMAGE_LAYOUT, "DS", - "Cannot submit cmd buffer using image (0x%" PRIx64 - ") with layout %s when " - "first use is %s.", - reinterpret_cast<const uint64_t &>(cb_image_data.first.image), string_VkImageLayout(imageLayout), - string_VkImageLayout(cb_image_data.second.initialLayout)); + skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, + HandleToUint64(pCB->commandBuffer), __LINE__, DRAWSTATE_INVALID_IMAGE_LAYOUT, "DS", + "Cannot submit cmd buffer using image (0x%" PRIx64 + ") with layout %s when " + "first use is %s.", + HandleToUint64(cb_image_data.first.image), string_VkImageLayout(imageLayout), + string_VkImageLayout(cb_image_data.second.initialLayout)); } } SetLayout(imageLayoutMap, cb_image_data.first, cb_image_data.second.layout); @@ -2128,14 +2116,14 @@ static bool ValidateMaskBits(core_validation::layer_data *device_data, VkCommand if (accessMask & ~(required_bit | optional_bits)) { // TODO: Verify against Valid Use skip |= log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(cmdBuffer), __LINE__, DRAWSTATE_INVALID_BARRIER, "DS", + HandleToUint64(cmdBuffer), __LINE__, DRAWSTATE_INVALID_BARRIER, "DS", "Additional bits in %s accessMask 0x%X %s are specified when layout is %s.", type, accessMask, string_VkAccessFlags(accessMask).c_str(), string_VkImageLayout(layout)); } } else { if (!required_bit) { skip |= log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(cmdBuffer), __LINE__, DRAWSTATE_INVALID_BARRIER, "DS", + HandleToUint64(cmdBuffer), __LINE__, DRAWSTATE_INVALID_BARRIER, "DS", "%s AccessMask %d %s must contain at least one of access bits %d " "%s when layout is %s, unless the app has previously added a " "barrier for this transition.", @@ -2149,7 +2137,7 @@ static bool ValidateMaskBits(core_validation::layer_data *device_data, VkCommand opt_bits = "and may have optional bits " + ss.str() + ' ' + string_VkAccessFlags(optional_bits); } skip |= log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(cmdBuffer), __LINE__, DRAWSTATE_INVALID_BARRIER, "DS", + HandleToUint64(cmdBuffer), __LINE__, DRAWSTATE_INVALID_BARRIER, "DS", "%s AccessMask %d %s must have required access bit %d %s %s when " "layout is %s, unless the app has previously added a barrier for " "this transition.", @@ -2200,7 +2188,7 @@ bool ValidateMaskBitsFromLayouts(core_validation::layer_data *device_data, VkCom if (accessMask != 0) { // TODO: Verify against Valid Use section spec skip |= log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(cmdBuffer), __LINE__, DRAWSTATE_INVALID_BARRIER, "DS", + HandleToUint64(cmdBuffer), __LINE__, DRAWSTATE_INVALID_BARRIER, "DS", "Additional bits in %s accessMask 0x%X %s are specified when layout is %s.", type, accessMask, string_VkAccessFlags(accessMask).c_str(), string_VkImageLayout(layout)); } @@ -2403,12 +2391,12 @@ bool ValidateMapImageLayouts(core_validation::layer_data *device_data, VkDevice if (FindLayouts(device_data, VkImage(image_handle), layouts)) { for (auto layout : layouts) { if (layout != VK_IMAGE_LAYOUT_PREINITIALIZED && layout != VK_IMAGE_LAYOUT_GENERAL) { - skip |= log_msg( - report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT, - reinterpret_cast<const uint64_t &>(mem_info->mem), __LINE__, DRAWSTATE_INVALID_IMAGE_LAYOUT, "DS", - "Mapping an image with layout %s can result in undefined behavior if this memory is " - "used by the device. Only GENERAL or PREINITIALIZED should be used.", - string_VkImageLayout(layout)); + skip |= + log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT, + HandleToUint64(mem_info->mem), __LINE__, DRAWSTATE_INVALID_IMAGE_LAYOUT, "DS", + "Mapping an image with layout %s can result in undefined behavior if this memory is " + "used by the device. Only GENERAL or PREINITIALIZED should be used.", + string_VkImageLayout(layout)); } } } @@ -2455,18 +2443,16 @@ static bool validate_usage_flags(layer_data *device_data, VkFlags actual, VkFlag // where an error will be flagged if usage is not correct bool ValidateImageUsageFlags(layer_data *device_data, IMAGE_STATE const *image_state, VkFlags desired, bool strict, int32_t const msgCode, char const *func_name, char const *usage_string) { - return validate_usage_flags(device_data, image_state->createInfo.usage, desired, strict, - reinterpret_cast<const uint64_t &>(image_state->image), kVulkanObjectTypeImage, msgCode, func_name, - usage_string); + return validate_usage_flags(device_data, image_state->createInfo.usage, desired, strict, HandleToUint64(image_state->image), + kVulkanObjectTypeImage, msgCode, func_name, usage_string); } // Helper function to validate usage flags for buffers. For given buffer_state send actual vs. desired usage off to helper above // where an error will be flagged if usage is not correct bool ValidateBufferUsageFlags(layer_data *device_data, BUFFER_STATE const *buffer_state, VkFlags desired, bool strict, int32_t const msgCode, char const *func_name, char const *usage_string) { - return validate_usage_flags(device_data, buffer_state->createInfo.usage, desired, strict, - reinterpret_cast<const uint64_t &>(buffer_state->buffer), kVulkanObjectTypeBuffer, msgCode, - func_name, usage_string); + return validate_usage_flags(device_data, buffer_state->createInfo.usage, desired, strict, HandleToUint64(buffer_state->buffer), + kVulkanObjectTypeBuffer, msgCode, func_name, usage_string); } bool PreCallValidateCreateBuffer(layer_data *device_data, const VkBufferCreateInfo *pCreateInfo) { @@ -2536,52 +2522,52 @@ bool ValidateImageAspectMask(layer_data *device_data, VkImage image, VkFormat fo bool skip = false; 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", + skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, + HandleToUint64(image), __LINE__, VALIDATION_ERROR_00741, "IMAGE", "%s: Color image formats must have the VK_IMAGE_ASPECT_COLOR_BIT set. %s", func_name, validation_error_map[VALIDATION_ERROR_00741]); } else if ((aspect_mask & VK_IMAGE_ASPECT_COLOR_BIT) != aspect_mask) { - 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", + skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, + HandleToUint64(image), __LINE__, VALIDATION_ERROR_00741, "IMAGE", "%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 (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", + skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, + HandleToUint64(image), __LINE__, VALIDATION_ERROR_00741, "IMAGE", "%s: Depth/stencil image formats must have " "at least one of VK_IMAGE_ASPECT_DEPTH_BIT " "and VK_IMAGE_ASPECT_STENCIL_BIT set. %s", func_name, validation_error_map[VALIDATION_ERROR_00741]); } else if ((aspect_mask & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) != aspect_mask) { - 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", + skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, + HandleToUint64(image), __LINE__, VALIDATION_ERROR_00741, "IMAGE", "%s: Combination depth/stencil image formats can have only the VK_IMAGE_ASPECT_DEPTH_BIT and " "VK_IMAGE_ASPECT_STENCIL_BIT set. %s", func_name, validation_error_map[VALIDATION_ERROR_00741]); } } 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", + skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, + HandleToUint64(image), __LINE__, VALIDATION_ERROR_00741, "IMAGE", "%s: Depth-only image formats must have the VK_IMAGE_ASPECT_DEPTH_BIT set. %s", func_name, validation_error_map[VALIDATION_ERROR_00741]); } else if ((aspect_mask & VK_IMAGE_ASPECT_DEPTH_BIT) != aspect_mask) { - 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", + skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, + HandleToUint64(image), __LINE__, VALIDATION_ERROR_00741, "IMAGE", "%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 (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", + skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, + HandleToUint64(image), __LINE__, VALIDATION_ERROR_00741, "IMAGE", "%s: Stencil-only image formats must have the VK_IMAGE_ASPECT_STENCIL_BIT set. %s", func_name, validation_error_map[VALIDATION_ERROR_00741]); } else if ((aspect_mask & VK_IMAGE_ASPECT_STENCIL_BIT) != aspect_mask) { - 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", + skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, + HandleToUint64(image), __LINE__, VALIDATION_ERROR_00741, "IMAGE", "%s: Stencil-only image formats can have only the VK_IMAGE_ASPECT_STENCIL_BIT set. %s", func_name, validation_error_map[VALIDATION_ERROR_00741]); } @@ -2654,8 +2640,9 @@ bool PreCallValidateCreateImageView(layer_data *device_data, const VkImageViewCr 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 " - << string_VkFormat(image_format) << ". Images created with the VK_IMAGE_CREATE_MUTABLE_FORMAT BIT " + << " is not in the same format compatibility class as image (" << HandleToUint64(create_info->image) + << ") format " << string_VkFormat(image_format) + << ". Images created with the VK_IMAGE_CREATE_MUTABLE_FORMAT BIT " << "can support ImageViews with differing formats but they must be in the same compatibility class."; skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, VALIDATION_ERROR_02171, "IMAGE", "%s %s", ss.str().c_str(), @@ -2666,7 +2653,7 @@ bool PreCallValidateCreateImageView(layer_data *device_data, const VkImageViewCr if (image_format != view_format) { std::stringstream ss; ss << "vkCreateImageView() format " << string_VkFormat(view_format) << " differs from image " - << (uint64_t)create_info->image << " format " << string_VkFormat(image_format) + << HandleToUint64(create_info->image) << " format " << string_VkFormat(image_format) << ". Formats MUST be IDENTICAL unless VK_IMAGE_CREATE_MUTABLE_FORMAT BIT was set on image creation."; skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, VALIDATION_ERROR_02172, "IMAGE", "%s %s", ss.str().c_str(), @@ -2730,14 +2717,14 @@ static bool validateIdleBuffer(layer_data *device_data, VkBuffer buffer) { bool skip = false; auto buffer_state = GetBufferState(device_data, buffer); if (!buffer_state) { - skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT, (uint64_t)(buffer), + skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT, HandleToUint64(buffer), __LINE__, DRAWSTATE_DOUBLE_DESTROY, "DS", - "Cannot free buffer 0x%" PRIxLEAST64 " that has not been allocated.", (uint64_t)(buffer)); + "Cannot free buffer 0x%" PRIxLEAST64 " that has not been allocated.", HandleToUint64(buffer)); } else { if (buffer_state->in_use.load()) { - skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT, (uint64_t)(buffer), - __LINE__, VALIDATION_ERROR_00676, "DS", - "Cannot free buffer 0x%" PRIxLEAST64 " that is in use by a command buffer. %s", (uint64_t)(buffer), + skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT, + HandleToUint64(buffer), __LINE__, VALIDATION_ERROR_00676, "DS", + "Cannot free buffer 0x%" PRIxLEAST64 " that is in use by a command buffer. %s", HandleToUint64(buffer), validation_error_map[VALIDATION_ERROR_00676]); } } @@ -2747,7 +2734,7 @@ static bool validateIdleBuffer(layer_data *device_data, VkBuffer buffer) { bool PreCallValidateDestroyImageView(layer_data *device_data, VkImageView image_view, IMAGE_VIEW_STATE **image_view_state, VK_OBJECT *obj_struct) { *image_view_state = GetImageViewState(device_data, image_view); - *obj_struct = {reinterpret_cast<uint64_t &>(image_view), kVulkanObjectTypeImageView}; + *obj_struct = {HandleToUint64(image_view), kVulkanObjectTypeImageView}; if (GetDisables(device_data)->destroy_image_view) return false; bool skip = false; if (*image_view_state) { @@ -2765,7 +2752,7 @@ void PostCallRecordDestroyImageView(layer_data *device_data, VkImageView image_v bool PreCallValidateDestroyBuffer(layer_data *device_data, VkBuffer buffer, BUFFER_STATE **buffer_state, VK_OBJECT *obj_struct) { *buffer_state = GetBufferState(device_data, buffer); - *obj_struct = {reinterpret_cast<uint64_t &>(buffer), kVulkanObjectTypeBuffer}; + *obj_struct = {HandleToUint64(buffer), kVulkanObjectTypeBuffer}; if (GetDisables(device_data)->destroy_buffer) return false; bool skip = false; if (*buffer_state) { @@ -2779,17 +2766,17 @@ void PostCallRecordDestroyBuffer(layer_data *device_data, VkBuffer buffer, BUFFE for (auto mem_binding : buffer_state->GetBoundMemory()) { auto mem_info = GetMemObjInfo(device_data, mem_binding); if (mem_info) { - core_validation::RemoveBufferMemoryRange(reinterpret_cast<uint64_t &>(buffer), mem_info); + core_validation::RemoveBufferMemoryRange(HandleToUint64(buffer), mem_info); } } - ClearMemoryObjectBindings(device_data, reinterpret_cast<uint64_t &>(buffer), kVulkanObjectTypeBuffer); + ClearMemoryObjectBindings(device_data, HandleToUint64(buffer), kVulkanObjectTypeBuffer); GetBufferMap(device_data)->erase(buffer_state->buffer); } bool PreCallValidateDestroyBufferView(layer_data *device_data, VkBufferView buffer_view, BUFFER_VIEW_STATE **buffer_view_state, VK_OBJECT *obj_struct) { *buffer_view_state = GetBufferViewState(device_data, buffer_view); - *obj_struct = {reinterpret_cast<uint64_t &>(buffer_view), kVulkanObjectTypeBufferView}; + *obj_struct = {HandleToUint64(buffer_view), kVulkanObjectTypeBufferView}; if (GetDisables(device_data)->destroy_buffer_view) return false; bool skip = false; if (*buffer_view_state) { @@ -2837,7 +2824,7 @@ bool ValidateBufferImageCopyData(const debug_report_data *report_data, uint32_t if (image_state->createInfo.imageType == VK_IMAGE_TYPE_1D) { if ((pRegions[i].imageOffset.y != 0) || (pRegions[i].imageExtent.height != 1)) { 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_01746, "IMAGE", + HandleToUint64(image_state->image), __LINE__, VALIDATION_ERROR_01746, "IMAGE", "%s(): pRegion[%d] imageOffset.y is %d and imageExtent.height is %d. For 1D images these " "must be 0 and 1, respectively. %s", function, i, pRegions[i].imageOffset.y, pRegions[i].imageExtent.height, @@ -2848,7 +2835,7 @@ bool ValidateBufferImageCopyData(const debug_report_data *report_data, uint32_t if ((image_state->createInfo.imageType == VK_IMAGE_TYPE_1D) || (image_state->createInfo.imageType == VK_IMAGE_TYPE_2D)) { if ((pRegions[i].imageOffset.z != 0) || (pRegions[i].imageExtent.depth != 1)) { 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_01747, "IMAGE", + HandleToUint64(image_state->image), __LINE__, VALIDATION_ERROR_01747, "IMAGE", "%s(): pRegion[%d] imageOffset.z is %d and imageExtent.depth is %d. For 1D and 2D images these " "must be 0 and 1, respectively. %s", function, i, pRegions[i].imageOffset.z, pRegions[i].imageExtent.depth, @@ -2859,7 +2846,7 @@ bool ValidateBufferImageCopyData(const debug_report_data *report_data, uint32_t if (image_state->createInfo.imageType == VK_IMAGE_TYPE_3D) { if ((0 != pRegions[i].imageSubresource.baseArrayLayer) || (1 != pRegions[i].imageSubresource.layerCount)) { 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_01281, "IMAGE", + HandleToUint64(image_state->image), __LINE__, VALIDATION_ERROR_01281, "IMAGE", "%s(): pRegion[%d] imageSubresource.baseArrayLayer is %d and imageSubresource.layerCount is " "%d. For 3D images these must be 0 and 1, respectively. %s", function, i, pRegions[i].imageSubresource.baseArrayLayer, pRegions[i].imageSubresource.layerCount, @@ -2872,7 +2859,7 @@ bool ValidateBufferImageCopyData(const debug_report_data *report_data, uint32_t 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", + HandleToUint64(image_state->image), __LINE__, VALIDATION_ERROR_01263, "IMAGE", "%s(): pRegion[%d] bufferOffset 0x%" PRIxLEAST64 " must be a multiple of this format's texel size (" PRINTF_SIZE_T_SPECIFIER "). %s", function, i, pRegions[i].bufferOffset, texel_size, validation_error_map[VALIDATION_ERROR_01263]); @@ -2881,7 +2868,7 @@ bool ValidateBufferImageCopyData(const debug_report_data *report_data, uint32_t // BufferOffset must be a multiple of 4 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", + HandleToUint64(image_state->image), __LINE__, VALIDATION_ERROR_01264, "IMAGE", "%s(): pRegion[%d] bufferOffset 0x%" PRIxLEAST64 " must be a multiple of 4. %s", function, i, pRegions[i].bufferOffset, validation_error_map[VALIDATION_ERROR_01264]); } @@ -2890,7 +2877,7 @@ bool ValidateBufferImageCopyData(const debug_report_data *report_data, uint32_t if ((pRegions[i].bufferRowLength != 0) && (pRegions[i].bufferRowLength < pRegions[i].imageExtent.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_01265, "IMAGE", + HandleToUint64(image_state->image), __LINE__, VALIDATION_ERROR_01265, "IMAGE", "%s(): pRegion[%d] bufferRowLength (%d) must be zero or greater-than-or-equal-to imageExtent.width (%d). %s", function, i, pRegions[i].bufferRowLength, pRegions[i].imageExtent.width, validation_error_map[VALIDATION_ERROR_01265]); @@ -2900,7 +2887,7 @@ bool ValidateBufferImageCopyData(const debug_report_data *report_data, uint32_t if ((pRegions[i].bufferImageHeight != 0) && (pRegions[i].bufferImageHeight < pRegions[i].imageExtent.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_01266, "IMAGE", + HandleToUint64(image_state->image), __LINE__, VALIDATION_ERROR_01266, "IMAGE", "%s(): pRegion[%d] bufferImageHeight (%d) must be zero or greater-than-or-equal-to imageExtent.height (%d). %s", function, i, pRegions[i].bufferImageHeight, pRegions[i].imageExtent.height, validation_error_map[VALIDATION_ERROR_01266]); @@ -2911,7 +2898,7 @@ bool ValidateBufferImageCopyData(const debug_report_data *report_data, uint32_t std::bitset<num_bits> aspect_mask_bits(pRegions[i].imageSubresource.aspectMask); if (aspect_mask_bits.count() != 1) { 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_01280, "IMAGE", + HandleToUint64(image_state->image), __LINE__, VALIDATION_ERROR_01280, "IMAGE", "%s: aspectMasks for imageSubresource in each region must have only a single bit set. %s", function, validation_error_map[VALIDATION_ERROR_01280]); } @@ -2920,7 +2907,7 @@ bool ValidateBufferImageCopyData(const debug_report_data *report_data, uint32_t if (!VerifyAspectsPresent(pRegions[i].imageSubresource.aspectMask, image_state->createInfo.format)) { 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_01279, "IMAGE", + HandleToUint64(image_state->image), __LINE__, VALIDATION_ERROR_01279, "IMAGE", "%s(): pRegion[%d] subresource aspectMask 0x%x specifies aspects that are not present in image format 0x%x. %s", function, i, pRegions[i].imageSubresource.aspectMask, image_state->createInfo.format, validation_error_map[VALIDATION_ERROR_01279]); @@ -2937,7 +2924,7 @@ bool ValidateBufferImageCopyData(const debug_report_data *report_data, uint32_t 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", + HandleToUint64(image_state->image), __LINE__, VALIDATION_ERROR_01271, "IMAGE", "%s(): pRegion[%d] bufferRowLength (%d) must be a multiple of the compressed image's texel width (%d). %s.", function, i, pRegions[i].bufferRowLength, block_size.width, validation_error_map[VALIDATION_ERROR_01271]); } @@ -2945,7 +2932,7 @@ bool ValidateBufferImageCopyData(const debug_report_data *report_data, uint32_t // BufferRowHeight must be a multiple of block height 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", + HandleToUint64(image_state->image), __LINE__, VALIDATION_ERROR_01272, "IMAGE", "%s(): pRegion[%d] bufferImageHeight (%d) must be a multiple of the compressed image's texel " "height (%d). %s.", function, i, pRegions[i].bufferImageHeight, block_size.height, @@ -2957,7 +2944,7 @@ bool ValidateBufferImageCopyData(const debug_report_data *report_data, uint32_t (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", + HandleToUint64(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 " "width & height (%d, %d). %s.", function, i, pRegions[i].imageOffset.x, pRegions[i].imageOffset.y, block_size.width, @@ -2968,7 +2955,7 @@ bool ValidateBufferImageCopyData(const debug_report_data *report_data, uint32_t 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", + HandleToUint64(image_state->image), __LINE__, VALIDATION_ERROR_01274, "IMAGE", "%s(): pRegion[%d] bufferOffset (0x%" PRIxLEAST64 ") must be a multiple of the compressed image's texel block " "size (" PRINTF_SIZE_T_SPECIFIER "). %s.", @@ -2981,7 +2968,7 @@ bool ValidateBufferImageCopyData(const debug_report_data *report_data, uint32_t 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", + HandleToUint64(image_state->image), __LINE__, VALIDATION_ERROR_01275, "IMAGE", "%s(): pRegion[%d] extent width (%d) must be a multiple of the compressed texture block width " "(%d), or when added to offset.x (%d) must equal the image subresource width (%d). %s.", function, i, pRegions[i].imageExtent.width, block_size.width, pRegions[i].imageOffset.x, @@ -2992,7 +2979,7 @@ bool ValidateBufferImageCopyData(const debug_report_data *report_data, uint32_t 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", + HandleToUint64(image_state->image), __LINE__, VALIDATION_ERROR_01276, "IMAGE", "%s(): pRegion[%d] extent height (%d) must be a multiple of the compressed texture block height " "(%d), or when added to offset.y (%d) must equal the image subresource height (%d). %s.", function, i, pRegions[i].imageExtent.height, block_size.height, pRegions[i].imageOffset.y, @@ -3003,7 +2990,7 @@ bool ValidateBufferImageCopyData(const debug_report_data *report_data, uint32_t 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", + HandleToUint64(image_state->image), __LINE__, VALIDATION_ERROR_01277, "IMAGE", "%s(): pRegion[%d] extent width (%d) must be a multiple of the compressed texture block depth " "(%d), or when added to offset.z (%d) must equal the image subresource depth (%d). %s.", function, i, pRegions[i].imageExtent.depth, block_size.depth, pRegions[i].imageOffset.z, @@ -3135,7 +3122,7 @@ bool PreCallValidateCmdCopyImageToBuffer(layer_data *device_data, VkImageLayout // Validate command buffer state if (CB_RECORDING != cb_node->state) { skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - (uint64_t)cb_node->commandBuffer, __LINE__, VALIDATION_ERROR_01258, "DS", + HandleToUint64(cb_node->commandBuffer), __LINE__, VALIDATION_ERROR_01258, "DS", "Cannot call vkCmdCopyImageToBuffer() on command buffer which is not in recording state. %s.", validation_error_map[VALIDATION_ERROR_01258]); } else { @@ -3148,7 +3135,7 @@ bool PreCallValidateCmdCopyImageToBuffer(layer_data *device_data, VkImageLayout VkQueueFlags queue_flags = GetPhysDevProperties(device_data)->queue_family_properties[pPool->queueFamilyIndex].queueFlags; if (0 == (queue_flags & (VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT | VK_QUEUE_TRANSFER_BIT))) { skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - (uint64_t)cb_node->createInfo.commandPool, __LINE__, VALIDATION_ERROR_01259, "DS", + HandleToUint64(cb_node->createInfo.commandPool), __LINE__, VALIDATION_ERROR_01259, "DS", "Cannot call vkCmdCopyImageToBuffer() on a command buffer allocated from a pool without graphics, compute, " "or transfer capabilities. %s.", validation_error_map[VALIDATION_ERROR_01259]); @@ -3213,7 +3200,7 @@ bool PreCallValidateCmdCopyBufferToImage(layer_data *device_data, VkImageLayout // Validate command buffer state if (CB_RECORDING != cb_node->state) { skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - (uint64_t)cb_node->commandBuffer, __LINE__, VALIDATION_ERROR_01240, "DS", + HandleToUint64(cb_node->commandBuffer), __LINE__, VALIDATION_ERROR_01240, "DS", "Cannot call vkCmdCopyBufferToImage() on command buffer which is not in recording state. %s.", validation_error_map[VALIDATION_ERROR_01240]); } else { @@ -3225,7 +3212,7 @@ bool PreCallValidateCmdCopyBufferToImage(layer_data *device_data, VkImageLayout VkQueueFlags queue_flags = GetPhysDevProperties(device_data)->queue_family_properties[pPool->queueFamilyIndex].queueFlags; if (0 == (queue_flags & (VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT | VK_QUEUE_TRANSFER_BIT))) { skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - (uint64_t)cb_node->createInfo.commandPool, __LINE__, VALIDATION_ERROR_01241, "DS", + HandleToUint64(cb_node->createInfo.commandPool), __LINE__, VALIDATION_ERROR_01241, "DS", "Cannot call vkCmdCopyBufferToImage() on a command buffer allocated from a pool without graphics, compute, " "or transfer capabilities. %s.", validation_error_map[VALIDATION_ERROR_01241]); @@ -3283,8 +3270,8 @@ bool PreCallValidateGetImageSubresourceLayout(layer_data *device_data, VkImage i const int num_bits = sizeof(sub_aspect) * CHAR_BIT; std::bitset<num_bits> aspect_mask_bits(sub_aspect); if (aspect_mask_bits.count() != 1) { - 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_00733, "IMAGE", + skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, HandleToUint64(image), + __LINE__, VALIDATION_ERROR_00733, "IMAGE", "vkGetImageSubresourceLayout(): VkImageSubresource.aspectMask must have exactly 1 bit set. %s", validation_error_map[VALIDATION_ERROR_00733]); } @@ -3296,27 +3283,26 @@ bool PreCallValidateGetImageSubresourceLayout(layer_data *device_data, VkImage i // VU 00732: image must have been created with tiling equal to VK_IMAGE_TILING_LINEAR if (image_entry->createInfo.tiling != VK_IMAGE_TILING_LINEAR) { - 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_00732, "IMAGE", + skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, HandleToUint64(image), + __LINE__, VALIDATION_ERROR_00732, "IMAGE", "vkGetImageSubresourceLayout(): Image must have tiling of VK_IMAGE_TILING_LINEAR. %s", validation_error_map[VALIDATION_ERROR_00732]); } // VU 00739: mipLevel must be less than the mipLevels specified in VkImageCreateInfo when the image was created if (pSubresource->mipLevel >= image_entry->createInfo.mipLevels) { - 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_00739, "IMAGE", + skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, HandleToUint64(image), + __LINE__, VALIDATION_ERROR_00739, "IMAGE", "vkGetImageSubresourceLayout(): pSubresource.mipLevel (%d) must be less than %d. %s", pSubresource->mipLevel, image_entry->createInfo.mipLevels, validation_error_map[VALIDATION_ERROR_00739]); } // VU 00740: arrayLayer must be less than the arrayLayers specified in VkImageCreateInfo when the image was created if (pSubresource->arrayLayer >= image_entry->createInfo.arrayLayers) { - 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_00740, "IMAGE", - "vkGetImageSubresourceLayout(): pSubresource.arrayLayer (%d) must be less than %d. %s", - pSubresource->arrayLayer, image_entry->createInfo.arrayLayers, validation_error_map[VALIDATION_ERROR_00740]); + skip |= log_msg( + report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, HandleToUint64(image), __LINE__, + VALIDATION_ERROR_00740, "IMAGE", "vkGetImageSubresourceLayout(): pSubresource.arrayLayer (%d) must be less than %d. %s", + pSubresource->arrayLayer, image_entry->createInfo.arrayLayers, validation_error_map[VALIDATION_ERROR_00740]); } // VU 00741: subresource's aspect must be compatible with image's format. @@ -3324,15 +3310,15 @@ bool PreCallValidateGetImageSubresourceLayout(layer_data *device_data, VkImage i 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, - reinterpret_cast<uint64_t &>(image), __LINE__, VALIDATION_ERROR_00741, "IMAGE", + report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, HandleToUint64(image), __LINE__, + VALIDATION_ERROR_00741, "IMAGE", "vkGetImageSubresourceLayout(): For color formats, VkImageSubresource.aspectMask must be VK_IMAGE_ASPECT_COLOR. %s", validation_error_map[VALIDATION_ERROR_00741]); } } 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", + HandleToUint64(image), __LINE__, VALIDATION_ERROR_00741, "IMAGE", "vkGetImageSubresourceLayout(): For depth/stencil formats, VkImageSubresource.aspectMask must be " "either VK_IMAGE_ASPECT_DEPTH_BIT or VK_IMAGE_ASPECT_STENCIL_BIT. %s", validation_error_map[VALIDATION_ERROR_00741]); diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp index 5256cb95..16f7172d 100644 --- a/layers/core_validation.cpp +++ b/layers/core_validation.cpp @@ -445,10 +445,10 @@ static bool ValidateMemoryIsValid(layer_data *dev_data, VkDeviceMemory mem, uint if (mem_info) { if (!mem_info->bound_ranges[bound_object_handle].valid) { return log_msg(dev_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT, - reinterpret_cast<uint64_t &>(mem), __LINE__, MEMTRACK_INVALID_MEM_REGION, "MEM", + HandleToUint64(mem), __LINE__, MEMTRACK_INVALID_MEM_REGION, "MEM", "%s: Cannot read invalid region of memory allocation 0x%" PRIx64 " for bound %s object 0x%" PRIx64 ", please fill the memory before using.", - functionName, reinterpret_cast<uint64_t &>(mem), object_string[type], bound_object_handle); + functionName, HandleToUint64(mem), object_string[type], bound_object_handle); } } return false; @@ -460,20 +460,20 @@ bool ValidateImageMemoryIsValid(layer_data *dev_data, IMAGE_STATE *image_state, if (image_state->binding.mem == MEMTRACKER_SWAP_CHAIN_IMAGE_KEY) { if (!image_state->valid) { return log_msg(dev_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT, - reinterpret_cast<uint64_t &>(image_state->binding.mem), __LINE__, MEMTRACK_INVALID_MEM_REGION, "MEM", + HandleToUint64(image_state->binding.mem), __LINE__, MEMTRACK_INVALID_MEM_REGION, "MEM", "%s: Cannot read invalid swapchain image 0x%" PRIx64 ", please fill the memory before using.", - functionName, reinterpret_cast<uint64_t &>(image_state->image)); + functionName, HandleToUint64(image_state->image)); } } else { - return ValidateMemoryIsValid(dev_data, image_state->binding.mem, reinterpret_cast<uint64_t &>(image_state->image), - kVulkanObjectTypeImage, functionName); + return ValidateMemoryIsValid(dev_data, image_state->binding.mem, HandleToUint64(image_state->image), kVulkanObjectTypeImage, + functionName); } return false; } // For given buffer_state, verify that the range it's bound to is valid bool ValidateBufferMemoryIsValid(layer_data *dev_data, BUFFER_STATE *buffer_state, const char *functionName) { - return ValidateMemoryIsValid(dev_data, buffer_state->binding.mem, reinterpret_cast<uint64_t &>(buffer_state->buffer), - kVulkanObjectTypeBuffer, functionName); + return ValidateMemoryIsValid(dev_data, buffer_state->binding.mem, HandleToUint64(buffer_state->buffer), kVulkanObjectTypeBuffer, + functionName); } // For the given memory allocation, set the range bound by the given handle object to the valid param value static void SetMemoryValid(layer_data *dev_data, VkDeviceMemory mem, uint64_t handle, bool valid) { @@ -489,19 +489,18 @@ void SetImageMemoryValid(layer_data *dev_data, IMAGE_STATE *image_state, bool va if (image_state->binding.mem == MEMTRACKER_SWAP_CHAIN_IMAGE_KEY) { image_state->valid = valid; } else { - SetMemoryValid(dev_data, image_state->binding.mem, reinterpret_cast<uint64_t &>(image_state->image), valid); + SetMemoryValid(dev_data, image_state->binding.mem, HandleToUint64(image_state->image), valid); } } // For given buffer node set the buffer's bound memory range to valid param value void SetBufferMemoryValid(layer_data *dev_data, BUFFER_STATE *buffer_state, bool valid) { - SetMemoryValid(dev_data, buffer_state->binding.mem, reinterpret_cast<uint64_t &>(buffer_state->buffer), valid); + SetMemoryValid(dev_data, buffer_state->binding.mem, HandleToUint64(buffer_state->buffer), valid); } // Create binding link between given sampler and command buffer node void AddCommandBufferBindingSampler(GLOBAL_CB_NODE *cb_node, SAMPLER_STATE *sampler_state) { sampler_state->cb_bindings.insert(cb_node); - cb_node->object_bindings.insert( - {reinterpret_cast<uint64_t &>(sampler_state->sampler), kVulkanObjectTypeSampler }); + cb_node->object_bindings.insert({HandleToUint64(sampler_state->sampler), kVulkanObjectTypeSampler}); } // Create binding link between given image node and command buffer node @@ -518,7 +517,7 @@ void AddCommandBufferBindingImage(const layer_data *dev_data, GLOBAL_CB_NODE *cb } } // Now update cb binding for image - cb_node->object_bindings.insert({reinterpret_cast<uint64_t &>(image_state->image), kVulkanObjectTypeImage }); + cb_node->object_bindings.insert({HandleToUint64(image_state->image), kVulkanObjectTypeImage}); image_state->cb_bindings.insert(cb_node); } } @@ -527,8 +526,7 @@ void AddCommandBufferBindingImage(const layer_data *dev_data, GLOBAL_CB_NODE *cb void AddCommandBufferBindingImageView(const layer_data *dev_data, GLOBAL_CB_NODE *cb_node, IMAGE_VIEW_STATE *view_state) { // First add bindings for imageView view_state->cb_bindings.insert(cb_node); - cb_node->object_bindings.insert( - {reinterpret_cast<uint64_t &>(view_state->image_view), kVulkanObjectTypeImageView }); + cb_node->object_bindings.insert({HandleToUint64(view_state->image_view), kVulkanObjectTypeImageView}); auto image_state = GetImageState(dev_data, view_state->create_info.image); // Add bindings for image within imageView if (image_state) { @@ -548,7 +546,7 @@ void AddCommandBufferBindingBuffer(const layer_data *dev_data, GLOBAL_CB_NODE *c } } // Now update cb binding for buffer - cb_node->object_bindings.insert({reinterpret_cast<uint64_t &>(buffer_state->buffer), kVulkanObjectTypeBuffer }); + cb_node->object_bindings.insert({HandleToUint64(buffer_state->buffer), kVulkanObjectTypeBuffer}); buffer_state->cb_bindings.insert(cb_node); } @@ -556,8 +554,7 @@ void AddCommandBufferBindingBuffer(const layer_data *dev_data, GLOBAL_CB_NODE *c void AddCommandBufferBindingBufferView(const layer_data *dev_data, GLOBAL_CB_NODE *cb_node, BUFFER_VIEW_STATE *view_state) { // First add bindings for bufferView view_state->cb_bindings.insert(cb_node); - cb_node->object_bindings.insert( - {reinterpret_cast<uint64_t &>(view_state->buffer_view), kVulkanObjectTypeBufferView }); + cb_node->object_bindings.insert({HandleToUint64(view_state->buffer_view), kVulkanObjectTypeBufferView}); auto buffer_state = GetBufferState(dev_data, view_state->create_info.buffer); // Add bindings for buffer within bufferView if (buffer_state) { @@ -634,8 +631,8 @@ bool ValidateMemoryIsBoundToImage(const layer_data *dev_data, const IMAGE_STATE UNIQUE_VALIDATION_ERROR_CODE error_code) { bool result = false; if (0 == (static_cast<uint32_t>(image_state->createInfo.flags) & VK_IMAGE_CREATE_SPARSE_BINDING_BIT)) { - result = VerifyBoundMemoryIsValid(dev_data, image_state->binding.mem, - reinterpret_cast<const uint64_t &>(image_state->image), api_name, "Image", error_code); + result = VerifyBoundMemoryIsValid(dev_data, image_state->binding.mem, HandleToUint64(image_state->image), api_name, "Image", + error_code); } return result; } @@ -645,8 +642,8 @@ bool ValidateMemoryIsBoundToBuffer(const layer_data *dev_data, const BUFFER_STAT UNIQUE_VALIDATION_ERROR_CODE error_code) { bool result = false; if (0 == (static_cast<uint32_t>(buffer_state->createInfo.flags) & VK_BUFFER_CREATE_SPARSE_BINDING_BIT)) { - result = VerifyBoundMemoryIsValid(dev_data, buffer_state->binding.mem, - reinterpret_cast<const uint64_t &>(buffer_state->buffer), api_name, "Buffer", error_code); + result = VerifyBoundMemoryIsValid(dev_data, buffer_state->binding.mem, HandleToUint64(buffer_state->buffer), api_name, + "Buffer", error_code); } return result; } @@ -700,10 +697,10 @@ static bool ValidateSetMemBinding(layer_data *dev_data, VkDeviceMemory mem, uint assert(strcmp(apiName, "vkBindImageMemory()") == 0); } skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT, - reinterpret_cast<uint64_t &>(mem), __LINE__, error_code, "MEM", + HandleToUint64(mem), __LINE__, error_code, "MEM", "In %s, attempting to bind memory (0x%" PRIxLEAST64 ") to object (0x%" PRIxLEAST64 ") which was created with sparse memory flags (VK_%s_CREATE_SPARSE_*_BIT). %s", - apiName, reinterpret_cast<uint64_t &>(mem), handle, handle_type, validation_error_map[error_code]); + apiName, HandleToUint64(mem), handle, handle_type, validation_error_map[error_code]); } DEVICE_MEM_INFO *mem_info = GetMemObjInfo(dev_data, mem); if (mem_info) { @@ -716,18 +713,18 @@ static bool ValidateSetMemBinding(layer_data *dev_data, VkDeviceMemory mem, uint assert(strcmp(apiName, "vkBindImageMemory()") == 0); } skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT, - reinterpret_cast<uint64_t &>(mem), __LINE__, error_code, "MEM", + HandleToUint64(mem), __LINE__, error_code, "MEM", "In %s, attempting to bind memory (0x%" PRIxLEAST64 ") to object (0x%" PRIxLEAST64 ") which has already been bound to mem object 0x%" PRIxLEAST64 ". %s", - apiName, reinterpret_cast<uint64_t &>(mem), handle, reinterpret_cast<uint64_t &>(prev_binding->mem), + apiName, HandleToUint64(mem), handle, HandleToUint64(prev_binding->mem), validation_error_map[error_code]); } else if (mem_binding->binding.mem == MEMORY_UNBOUND) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT, - reinterpret_cast<uint64_t &>(mem), __LINE__, MEMTRACK_REBIND_OBJECT, "MEM", + HandleToUint64(mem), __LINE__, MEMTRACK_REBIND_OBJECT, "MEM", "In %s, attempting to bind memory (0x%" PRIxLEAST64 ") to object (0x%" PRIxLEAST64 ") which was previous bound to memory that has since been freed. Memory bindings are immutable in " "Vulkan so this attempt to bind to new memory is not allowed.", - apiName, reinterpret_cast<uint64_t &>(mem), handle); + apiName, HandleToUint64(mem), handle); } } } @@ -1813,8 +1810,8 @@ static bool validate_status(layer_data *dev_data, GLOBAL_CB_NODE *pNode, CBStatu if (!(pNode->status & status_mask)) { char const *const message = validation_error_map[msg_code]; return log_msg(dev_data->report_data, msg_flags, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<const uint64_t &>(pNode->commandBuffer), __LINE__, msg_code, "DS", - "command buffer object 0x%p: %s. %s.", pNode->commandBuffer, fail_msg, message); + HandleToUint64(pNode->commandBuffer), __LINE__, msg_code, "DS", "command buffer object 0x%p: %s. %s.", + pNode->commandBuffer, fail_msg, message); } return false; } @@ -2494,22 +2491,22 @@ static bool ValidatePipelineDrawtimeState(layer_data const *dev_data, LAST_BOUND (pCB->currentDrawData.buffers[vertex_binding] == VK_NULL_HANDLE)) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(pCB->commandBuffer), __LINE__, DRAWSTATE_VTX_INDEX_OUT_OF_BOUNDS, "DS", + HandleToUint64(pCB->commandBuffer), __LINE__, DRAWSTATE_VTX_INDEX_OUT_OF_BOUNDS, "DS", "The Pipeline State Object (0x%" PRIxLEAST64 ") expects that this Command Buffer's vertex binding Index %u " "should be set via vkCmdBindVertexBuffers. This is because VkVertexInputBindingDescription struct " "at index " PRINTF_SIZE_T_SPECIFIER " of pVertexBindingDescriptions has a binding value of %u.", - (uint64_t)state.pipeline_state->pipeline, vertex_binding, i, vertex_binding); + HandleToUint64(state.pipeline_state->pipeline), vertex_binding, i, vertex_binding); } } } else { if (!pCB->currentDrawData.buffers.empty() && !pCB->vertex_buffer_used) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, - VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, reinterpret_cast<uint64_t>(pCB->commandBuffer), - __LINE__, DRAWSTATE_VTX_INDEX_OUT_OF_BOUNDS, "DS", + VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, HandleToUint64(pCB->commandBuffer), __LINE__, + DRAWSTATE_VTX_INDEX_OUT_OF_BOUNDS, "DS", "Vertex buffers are bound to command buffer (0x%p" ") but no vertex buffers are attached to this Pipeline State Object (0x%" PRIxLEAST64 ").", - pCB->commandBuffer, (uint64_t)state.pipeline_state->pipeline); + pCB->commandBuffer, HandleToUint64(state.pipeline_state->pipeline)); } } // If Viewport or scissors are dynamic, verify that dynamic count matches PSO count. @@ -2572,17 +2569,17 @@ static bool ValidatePipelineDrawtimeState(layer_data const *dev_data, LAST_BOUND if (subpass_num_samples && static_cast<unsigned>(pso_num_samples) != subpass_num_samples) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, - reinterpret_cast<const uint64_t &>(pPipeline->pipeline), __LINE__, DRAWSTATE_NUM_SAMPLES_MISMATCH, - "DS", "Num samples mismatch! At draw-time in Pipeline (0x%" PRIxLEAST64 - ") with %u samples while current RenderPass (0x%" PRIxLEAST64 ") w/ %u samples!", - reinterpret_cast<const uint64_t &>(pPipeline->pipeline), pso_num_samples, - reinterpret_cast<const uint64_t &>(pCB->activeRenderPass->renderPass), subpass_num_samples); + HandleToUint64(pPipeline->pipeline), __LINE__, DRAWSTATE_NUM_SAMPLES_MISMATCH, "DS", + "Num samples mismatch! At draw-time in Pipeline (0x%" PRIxLEAST64 + ") with %u samples while current RenderPass (0x%" PRIxLEAST64 ") w/ %u samples!", + HandleToUint64(pPipeline->pipeline), pso_num_samples, + HandleToUint64(pCB->activeRenderPass->renderPass), subpass_num_samples); } } else { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, - reinterpret_cast<const uint64_t &>(pPipeline->pipeline), __LINE__, DRAWSTATE_NUM_SAMPLES_MISMATCH, "DS", + HandleToUint64(pPipeline->pipeline), __LINE__, DRAWSTATE_NUM_SAMPLES_MISMATCH, "DS", "No active render pass found at draw-time in Pipeline (0x%" PRIxLEAST64 ")!", - reinterpret_cast<const uint64_t &>(pPipeline->pipeline)); + HandleToUint64(pPipeline->pipeline)); } } // Verify that PSO creation renderPass is compatible with active renderPass @@ -2593,19 +2590,18 @@ static bool ValidatePipelineDrawtimeState(layer_data const *dev_data, LAST_BOUND err_string)) { // renderPass that PSO was created with must be compatible with active renderPass that PSO is being used with skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, - reinterpret_cast<const uint64_t &>(pPipeline->pipeline), __LINE__, DRAWSTATE_RENDERPASS_INCOMPATIBLE, - "DS", "At Draw time the active render pass (0x%" PRIxLEAST64 - ") is incompatible w/ gfx pipeline " - "(0x%" PRIxLEAST64 ") that was created w/ render pass (0x%" PRIxLEAST64 ") due to: %s", - reinterpret_cast<uint64_t &>(pCB->activeRenderPass->renderPass), - reinterpret_cast<uint64_t const &>(pPipeline->pipeline), - reinterpret_cast<const uint64_t &>(pPipeline->graphicsPipelineCI.renderPass), err_string.c_str()); + HandleToUint64(pPipeline->pipeline), __LINE__, DRAWSTATE_RENDERPASS_INCOMPATIBLE, "DS", + "At Draw time the active render pass (0x%" PRIxLEAST64 + ") is incompatible w/ gfx pipeline " + "(0x%" PRIxLEAST64 ") that was created w/ render pass (0x%" PRIxLEAST64 ") due to: %s", + HandleToUint64(pCB->activeRenderPass->renderPass), HandleToUint64(pPipeline->pipeline), + HandleToUint64(pPipeline->graphicsPipelineCI.renderPass), err_string.c_str()); } if (pPipeline->graphicsPipelineCI.subpass != pCB->activeSubpass) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, - reinterpret_cast<uint64_t const &>(pPipeline->pipeline), __LINE__, DRAWSTATE_RENDERPASS_INCOMPATIBLE, - "DS", "Pipeline was built for subpass %u but used in subpass %u", pPipeline->graphicsPipelineCI.subpass, + HandleToUint64(pPipeline->pipeline), __LINE__, DRAWSTATE_RENDERPASS_INCOMPATIBLE, "DS", + "Pipeline was built for subpass %u but used in subpass %u", pPipeline->graphicsPipelineCI.subpass, pCB->activeSubpass); } } @@ -2624,7 +2620,7 @@ static bool ValidateDrawState(layer_data *dev_data, GLOBAL_CB_NODE *cb_node, con if (nullptr == pPipe) { result |= log_msg( dev_data->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_INVALID_PIPELINE, "DS", + HandleToUint64(cb_node->commandBuffer), __LINE__, DRAWSTATE_INVALID_PIPELINE, "DS", "At Draw/Dispatch time no valid VkPipeline is bound! This is illegal. Please bind one with vkCmdBindPipeline()."); // Early return as any further checks below will be busted w/o a pipeline if (result) return true; @@ -2642,21 +2638,21 @@ static bool ValidateDrawState(layer_data *dev_data, GLOBAL_CB_NODE *cb_node, con uint32_t setIndex = set_binding_pair.first; // If valid set is not bound throw an error if ((state.boundDescriptorSets.size() <= setIndex) || (!state.boundDescriptorSets[setIndex])) { - result |= log_msg( - dev_data->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_DESCRIPTOR_SET_NOT_BOUND, "DS", - "VkPipeline 0x%" PRIxLEAST64 " uses set #%u but that set is not bound.", (uint64_t)pPipe->pipeline, setIndex); + result |= + log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, + HandleToUint64(cb_node->commandBuffer), __LINE__, DRAWSTATE_DESCRIPTOR_SET_NOT_BOUND, "DS", + "VkPipeline 0x%" PRIxLEAST64 " uses set #%u but that set is not bound.", + HandleToUint64(pPipe->pipeline), setIndex); } else if (!verify_set_layout_compatibility(state.boundDescriptorSets[setIndex], &pipeline_layout, setIndex, errorString)) { // Set is bound but not compatible w/ overlapping pipeline_layout from PSO VkDescriptorSet setHandle = state.boundDescriptorSets[setIndex]->GetSet(); result |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT, - (uint64_t)setHandle, __LINE__, DRAWSTATE_PIPELINE_LAYOUTS_INCOMPATIBLE, "DS", + HandleToUint64(setHandle), __LINE__, DRAWSTATE_PIPELINE_LAYOUTS_INCOMPATIBLE, "DS", "VkDescriptorSet (0x%" PRIxLEAST64 ") bound as set #%u is not compatible with overlapping VkPipelineLayout 0x%" PRIxLEAST64 " due to: %s", - reinterpret_cast<uint64_t &>(setHandle), setIndex, reinterpret_cast<uint64_t &>(pipeline_layout.layout), - errorString.c_str()); + HandleToUint64(setHandle), setIndex, HandleToUint64(pipeline_layout.layout), errorString.c_str()); } else { // Valid set is bound and layout compatible, validate that it's updated // Pull the set node cvdescriptorset::DescriptorSet *descriptor_set = state.boundDescriptorSets[setIndex]; @@ -2666,10 +2662,10 @@ static bool ValidateDrawState(layer_data *dev_data, GLOBAL_CB_NODE *cb_node, con &err_str)) { auto set = descriptor_set->GetSet(); result |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, - VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT, reinterpret_cast<const uint64_t &>(set), - __LINE__, DRAWSTATE_DESCRIPTOR_SET_NOT_UPDATED, "DS", + VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT, HandleToUint64(set), __LINE__, + DRAWSTATE_DESCRIPTOR_SET_NOT_UPDATED, "DS", "Descriptor set 0x%" PRIxLEAST64 " encountered the following validation error at %s time: %s", - reinterpret_cast<const uint64_t &>(set), function, err_str.c_str()); + HandleToUint64(set), function, err_str.c_str()); } } } @@ -2743,13 +2739,13 @@ static bool verifyPipelineCreateState(layer_data *dev_data, std::vector<PIPELINE (pPipeline->graphicsPipelineCI.basePipelineIndex != -1))) { // This check is a superset of VALIDATION_ERROR_00526 and VALIDATION_ERROR_00528 skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, - reinterpret_cast<uint64_t &>(pPipeline->pipeline), __LINE__, DRAWSTATE_INVALID_PIPELINE_CREATE_STATE, - "DS", "Invalid Pipeline CreateInfo: exactly one of base pipeline index and handle must be specified"); + HandleToUint64(pPipeline->pipeline), __LINE__, DRAWSTATE_INVALID_PIPELINE_CREATE_STATE, "DS", + "Invalid Pipeline CreateInfo: exactly one of base pipeline index and handle must be specified"); } else if (pPipeline->graphicsPipelineCI.basePipelineIndex != -1) { if (pPipeline->graphicsPipelineCI.basePipelineIndex >= pipelineIndex) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, - reinterpret_cast<uint64_t &>(pPipeline->pipeline), __LINE__, VALIDATION_ERROR_00518, "DS", + HandleToUint64(pPipeline->pipeline), __LINE__, VALIDATION_ERROR_00518, "DS", "Invalid Pipeline CreateInfo: base pipeline must occur earlier in array than derivative pipeline. %s", validation_error_map[VALIDATION_ERROR_00518]); } else { @@ -2761,8 +2757,8 @@ static bool verifyPipelineCreateState(layer_data *dev_data, std::vector<PIPELINE if (pBasePipeline && !(pBasePipeline->graphicsPipelineCI.flags & VK_PIPELINE_CREATE_ALLOW_DERIVATIVES_BIT)) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, - reinterpret_cast<uint64_t &>(pPipeline->pipeline), __LINE__, DRAWSTATE_INVALID_PIPELINE_CREATE_STATE, - "DS", "Invalid Pipeline CreateInfo: base pipeline does not allow derivatives."); + HandleToUint64(pPipeline->pipeline), __LINE__, DRAWSTATE_INVALID_PIPELINE_CREATE_STATE, "DS", + "Invalid Pipeline CreateInfo: base pipeline does not allow derivatives."); } } @@ -2773,10 +2769,10 @@ static bool verifyPipelineCreateState(layer_data *dev_data, std::vector<PIPELINE if (color_blend_state->attachmentCount != subpass_desc->colorAttachmentCount) { skip |= log_msg( dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, - reinterpret_cast<const uint64_t &>(pPipeline->pipeline), __LINE__, VALIDATION_ERROR_02109, "DS", + HandleToUint64(pPipeline->pipeline), __LINE__, VALIDATION_ERROR_02109, "DS", "vkCreateGraphicsPipelines(): Render pass (0x%" PRIxLEAST64 ") subpass %u has colorAttachmentCount of %u which doesn't match the pColorBlendState->attachmentCount of %u. %s", - reinterpret_cast<const uint64_t &>(pPipeline->graphicsPipelineCI.renderPass), pPipeline->graphicsPipelineCI.subpass, + HandleToUint64(pPipeline->graphicsPipelineCI.renderPass), pPipeline->graphicsPipelineCI.subpass, subpass_desc->colorAttachmentCount, color_blend_state->attachmentCount, validation_error_map[VALIDATION_ERROR_02109]); } @@ -2791,7 +2787,7 @@ static bool verifyPipelineCreateState(layer_data *dev_data, std::vector<PIPELINE sizeof(pAttachments[0]))) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, - reinterpret_cast<uint64_t &>(pPipeline->pipeline), __LINE__, VALIDATION_ERROR_01532, "DS", + HandleToUint64(pPipeline->pipeline), __LINE__, VALIDATION_ERROR_01532, "DS", "Invalid Pipeline CreateInfo: If independent blend feature not " "enabled, all elements of pAttachments must be identical. %s", validation_error_map[VALIDATION_ERROR_01532]); @@ -2803,7 +2799,7 @@ static bool verifyPipelineCreateState(layer_data *dev_data, std::vector<PIPELINE if (!dev_data->enabled_features.logicOp && (pPipeline->graphicsPipelineCI.pColorBlendState->logicOpEnable != VK_FALSE)) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, - reinterpret_cast<uint64_t &>(pPipeline->pipeline), __LINE__, VALIDATION_ERROR_01533, "DS", + HandleToUint64(pPipeline->pipeline), __LINE__, VALIDATION_ERROR_01533, "DS", "Invalid Pipeline CreateInfo: If logic operations feature not enabled, logicOpEnable must be VK_FALSE. %s", validation_error_map[VALIDATION_ERROR_01533]); } @@ -2815,7 +2811,7 @@ static bool verifyPipelineCreateState(layer_data *dev_data, std::vector<PIPELINE auto renderPass = GetRenderPassState(dev_data, pPipeline->graphicsPipelineCI.renderPass); if (renderPass && pPipeline->graphicsPipelineCI.subpass >= renderPass->createInfo.subpassCount) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, - reinterpret_cast<uint64_t &>(pPipeline->pipeline), __LINE__, VALIDATION_ERROR_02122, "DS", + HandleToUint64(pPipeline->pipeline), __LINE__, VALIDATION_ERROR_02122, "DS", "Invalid Pipeline CreateInfo State: Subpass index %u " "is out of range for this renderpass (0..%u). %s", pPipeline->graphicsPipelineCI.subpass, renderPass->createInfo.subpassCount - 1, @@ -2829,11 +2825,10 @@ static bool verifyPipelineCreateState(layer_data *dev_data, std::vector<PIPELINE if (pPipeline->duplicate_shaders) { for (uint32_t stage = VK_SHADER_STAGE_VERTEX_BIT; stage & VK_SHADER_STAGE_ALL_GRAPHICS; stage <<= 1) { if (pPipeline->duplicate_shaders & stage) { - skip |= - log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, - reinterpret_cast<uint64_t &>(pPipeline->pipeline), __LINE__, DRAWSTATE_INVALID_PIPELINE_CREATE_STATE, - "DS", "Invalid Pipeline CreateInfo State: Multiple shaders provided for stage %s", - string_VkShaderStageFlagBits(VkShaderStageFlagBits(stage))); + skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, + HandleToUint64(pPipeline->pipeline), __LINE__, DRAWSTATE_INVALID_PIPELINE_CREATE_STATE, "DS", + "Invalid Pipeline CreateInfo State: Multiple shaders provided for stage %s", + string_VkShaderStageFlagBits(VkShaderStageFlagBits(stage))); } } } @@ -2841,7 +2836,7 @@ static bool verifyPipelineCreateState(layer_data *dev_data, std::vector<PIPELINE if (!(pPipeline->active_shaders & VK_SHADER_STAGE_VERTEX_BIT)) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, - reinterpret_cast<uint64_t &>(pPipeline->pipeline), __LINE__, VALIDATION_ERROR_00532, "DS", + HandleToUint64(pPipeline->pipeline), __LINE__, VALIDATION_ERROR_00532, "DS", "Invalid Pipeline CreateInfo State: Vertex Shader required. %s", validation_error_map[VALIDATION_ERROR_00532]); } // Either both or neither TC/TE shaders should be defined @@ -2849,20 +2844,20 @@ static bool verifyPipelineCreateState(layer_data *dev_data, std::vector<PIPELINE bool has_eval = (pPipeline->active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) != 0; if (has_control && !has_eval) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, - reinterpret_cast<uint64_t &>(pPipeline->pipeline), __LINE__, VALIDATION_ERROR_00534, "DS", + HandleToUint64(pPipeline->pipeline), __LINE__, VALIDATION_ERROR_00534, "DS", "Invalid Pipeline CreateInfo State: TE and TC shaders must be included or excluded as a pair. %s", validation_error_map[VALIDATION_ERROR_00534]); } if (!has_control && has_eval) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, - reinterpret_cast<uint64_t &>(pPipeline->pipeline), __LINE__, VALIDATION_ERROR_00535, "DS", + HandleToUint64(pPipeline->pipeline), __LINE__, VALIDATION_ERROR_00535, "DS", "Invalid Pipeline CreateInfo State: TE and TC shaders must be included or excluded as a pair. %s", validation_error_map[VALIDATION_ERROR_00535]); } // Compute shaders should be specified independent of Gfx shaders if (pPipeline->active_shaders & VK_SHADER_STAGE_COMPUTE_BIT) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, - reinterpret_cast<uint64_t &>(pPipeline->pipeline), __LINE__, VALIDATION_ERROR_00533, "DS", + HandleToUint64(pPipeline->pipeline), __LINE__, VALIDATION_ERROR_00533, "DS", "Invalid Pipeline CreateInfo State: Do not specify Compute Shader for Gfx Pipeline. %s", validation_error_map[VALIDATION_ERROR_00533]); } @@ -2872,7 +2867,7 @@ static bool verifyPipelineCreateState(layer_data *dev_data, std::vector<PIPELINE (!pPipeline->graphicsPipelineCI.pInputAssemblyState || pPipeline->graphicsPipelineCI.pInputAssemblyState->topology != VK_PRIMITIVE_TOPOLOGY_PATCH_LIST)) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, - reinterpret_cast<uint64_t &>(pPipeline->pipeline), __LINE__, VALIDATION_ERROR_02099, "DS", + HandleToUint64(pPipeline->pipeline), __LINE__, VALIDATION_ERROR_02099, "DS", "Invalid Pipeline CreateInfo State: " "VK_PRIMITIVE_TOPOLOGY_PATCH_LIST must be set as IA " "topology for tessellation pipelines. %s", @@ -2882,7 +2877,7 @@ static bool verifyPipelineCreateState(layer_data *dev_data, std::vector<PIPELINE pPipeline->graphicsPipelineCI.pInputAssemblyState->topology == VK_PRIMITIVE_TOPOLOGY_PATCH_LIST) { if (!has_control || !has_eval) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, - reinterpret_cast<uint64_t &>(pPipeline->pipeline), __LINE__, VALIDATION_ERROR_02100, "DS", + HandleToUint64(pPipeline->pipeline), __LINE__, VALIDATION_ERROR_02100, "DS", "Invalid Pipeline CreateInfo State: " "VK_PRIMITIVE_TOPOLOGY_PATCH_LIST primitive " "topology is only valid for tessellation pipelines. %s", @@ -2894,15 +2889,15 @@ static bool verifyPipelineCreateState(layer_data *dev_data, std::vector<PIPELINE if (pPipeline->graphicsPipelineCI.pRasterizationState) { // Make sure that the line width conforms to the HW. if (!isDynamic(pPipeline, VK_DYNAMIC_STATE_LINE_WIDTH)) { - skip |= verifyLineWidth(dev_data, DRAWSTATE_INVALID_PIPELINE_CREATE_STATE, kVulkanObjectTypePipeline, - reinterpret_cast<uint64_t const &>(pPipeline->pipeline), - pPipeline->graphicsPipelineCI.pRasterizationState->lineWidth); + skip |= + verifyLineWidth(dev_data, DRAWSTATE_INVALID_PIPELINE_CREATE_STATE, kVulkanObjectTypePipeline, + HandleToUint64(pPipeline->pipeline), pPipeline->graphicsPipelineCI.pRasterizationState->lineWidth); } if ((pPipeline->graphicsPipelineCI.pRasterizationState->depthClampEnable == VK_TRUE) && (!dev_data->enabled_features.depthClamp)) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, - reinterpret_cast<uint64_t &>(pPipeline->pipeline), __LINE__, VALIDATION_ERROR_01455, "DS", + HandleToUint64(pPipeline->pipeline), __LINE__, VALIDATION_ERROR_01455, "DS", "vkCreateGraphicsPipelines(): the depthClamp device feature is disabled: the depthClampEnable " "member of the VkPipelineRasterizationStateCreateInfo structure must be set to VK_FALSE. %s", validation_error_map[VALIDATION_ERROR_01455]); @@ -2912,7 +2907,7 @@ static bool verifyPipelineCreateState(layer_data *dev_data, std::vector<PIPELINE (pPipeline->graphicsPipelineCI.pRasterizationState->depthBiasClamp != 0.0) && (!dev_data->enabled_features.depthBiasClamp)) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, - reinterpret_cast<uint64_t &>(pPipeline->pipeline), __LINE__, DRAWSTATE_INVALID_FEATURE, "DS", + HandleToUint64(pPipeline->pipeline), __LINE__, DRAWSTATE_INVALID_FEATURE, "DS", "vkCreateGraphicsPipelines(): the depthBiasClamp device feature is disabled: the depthBiasClamp " "member of the VkPipelineRasterizationStateCreateInfo structure must be set to 0.0 unless the " "VK_DYNAMIC_STATE_DEPTH_BIAS dynamic state is enabled"); @@ -2925,7 +2920,7 @@ static bool verifyPipelineCreateState(layer_data *dev_data, std::vector<PIPELINE if ((pPipeline->graphicsPipelineCI.pMultisampleState->alphaToOneEnable == VK_TRUE) && (!dev_data->enabled_features.alphaToOne)) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, - reinterpret_cast<uint64_t &>(pPipeline->pipeline), __LINE__, VALIDATION_ERROR_01464, "DS", + HandleToUint64(pPipeline->pipeline), __LINE__, VALIDATION_ERROR_01464, "DS", "vkCreateGraphicsPipelines(): the alphaToOne device feature is disabled: the alphaToOneEnable " "member of the VkPipelineMultisampleStateCreateInfo structure must be set to VK_FALSE. %s", validation_error_map[VALIDATION_ERROR_01464]); @@ -2936,7 +2931,7 @@ static bool verifyPipelineCreateState(layer_data *dev_data, std::vector<PIPELINE subpass_desc->pDepthStencilAttachment->attachment != VK_ATTACHMENT_UNUSED) { if (!pPipeline->graphicsPipelineCI.pDepthStencilState) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, - reinterpret_cast<uint64_t &>(pPipeline->pipeline), __LINE__, VALIDATION_ERROR_02115, "DS", + HandleToUint64(pPipeline->pipeline), __LINE__, VALIDATION_ERROR_02115, "DS", "Invalid Pipeline CreateInfo State: pDepthStencilState is NULL when rasterization is " "enabled and subpass uses a depth/stencil attachment. %s", validation_error_map[VALIDATION_ERROR_02115]); @@ -2945,7 +2940,7 @@ static bool verifyPipelineCreateState(layer_data *dev_data, std::vector<PIPELINE (!dev_data->enabled_features.depthBounds)) { skip |= log_msg( dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, - reinterpret_cast<uint64_t &>(pPipeline->pipeline), __LINE__, DRAWSTATE_INVALID_FEATURE, "DS", + HandleToUint64(pPipeline->pipeline), __LINE__, DRAWSTATE_INVALID_FEATURE, "DS", "vkCreateGraphicsPipelines(): the depthBounds device feature is disabled: the depthBoundsTestEnable " "member of the VkPipelineDepthStencilStateCreateInfo structure must be set to VK_FALSE."); } @@ -2961,7 +2956,7 @@ static bool verifyPipelineCreateState(layer_data *dev_data, std::vector<PIPELINE } if (color_attachment_count > 0 && pPipeline->graphicsPipelineCI.pColorBlendState == nullptr) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, - reinterpret_cast<uint64_t &>(pPipeline->pipeline), __LINE__, VALIDATION_ERROR_02116, "DS", + HandleToUint64(pPipeline->pipeline), __LINE__, VALIDATION_ERROR_02116, "DS", "Invalid Pipeline CreateInfo State: pColorBlendState is NULL when rasterization is " "enabled and subpass uses color attachments. %s", validation_error_map[VALIDATION_ERROR_02116]); @@ -3003,16 +2998,16 @@ static bool validateIdleDescriptorSet(const layer_data *dev_data, VkDescriptorSe auto set_node = dev_data->setMap.find(set); if (set_node == dev_data->setMap.end()) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT, - (uint64_t)(set), __LINE__, DRAWSTATE_DOUBLE_DESTROY, "DS", + HandleToUint64(set), __LINE__, DRAWSTATE_DOUBLE_DESTROY, "DS", "Cannot call %s() on descriptor set 0x%" PRIxLEAST64 " that has not been allocated.", func_str.c_str(), - (uint64_t)(set)); + HandleToUint64(set)); } else { // TODO : This covers various error cases so should pass error enum into this function and use passed in enum here if (set_node->second->in_use.load()) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT, - (uint64_t)(set), __LINE__, VALIDATION_ERROR_00919, "DS", + HandleToUint64(set), __LINE__, VALIDATION_ERROR_00919, "DS", "Cannot call %s() on descriptor set 0x%" PRIxLEAST64 " that is in use by a command buffer. %s", - func_str.c_str(), (uint64_t)(set), validation_error_map[VALIDATION_ERROR_00919]); + func_str.c_str(), HandleToUint64(set), validation_error_map[VALIDATION_ERROR_00919]); } } return skip; @@ -3069,11 +3064,11 @@ bool ValidateCmdSubpassState(const layer_data *dev_data, const GLOBAL_CB_NODE *p if (pCB->activeSubpassContents == VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS && (cmd_type != CMD_EXECUTECOMMANDS && cmd_type != CMD_NEXTSUBPASS && cmd_type != CMD_ENDRENDERPASS)) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(pCB->commandBuffer), __LINE__, DRAWSTATE_INVALID_COMMAND_BUFFER, "DS", + HandleToUint64(pCB->commandBuffer), __LINE__, DRAWSTATE_INVALID_COMMAND_BUFFER, "DS", "Commands cannot be called in a subpass using secondary command buffers."); } else if (pCB->activeSubpassContents == VK_SUBPASS_CONTENTS_INLINE && cmd_type == CMD_EXECUTECOMMANDS) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(pCB->commandBuffer), __LINE__, DRAWSTATE_INVALID_COMMAND_BUFFER, "DS", + HandleToUint64(pCB->commandBuffer), __LINE__, DRAWSTATE_INVALID_COMMAND_BUFFER, "DS", "vkCmdExecuteCommands() cannot be called in a subpass using inline commands."); } return skip; @@ -3095,7 +3090,7 @@ bool ValidateCmdQueueFlags(layer_data *dev_data, GLOBAL_CB_NODE *cb_node, const } } return log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(cb_node->commandBuffer), __LINE__, error_code, "DS", + HandleToUint64(cb_node->commandBuffer), __LINE__, error_code, "DS", "Cannot call %s on a command buffer allocated from a pool without %s capabilities. %s.", caller_name, required_flags_string.c_str(), validation_error_map[error_code]); } @@ -3110,7 +3105,7 @@ static bool ReportInvalidCommandBuffer(layer_data *dev_data, GLOBAL_CB_NODE *cb_ // Descriptor sets are a special case that can be either destroyed or updated to invalidate a CB const char *cause_str = (obj.type == kVulkanObjectTypeDescriptorSet) ? "destroyed or updated" : "destroyed"; skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t &>(cb_state->commandBuffer), __LINE__, DRAWSTATE_INVALID_COMMAND_BUFFER, "DS", + HandleToUint64(cb_state->commandBuffer), __LINE__, DRAWSTATE_INVALID_COMMAND_BUFFER, "DS", "You are adding %s to command buffer 0x%p that is invalid because bound %s 0x%" PRIxLEAST64 " was %s.", call_source, cb_state->commandBuffer, type_str, obj.handle, cause_str); } @@ -3129,7 +3124,7 @@ bool ValidateCmd(layer_data *dev_data, GLOBAL_CB_NODE *cb_state, const CMD_TYPE default: return log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t &>(cb_state->commandBuffer), __LINE__, DRAWSTATE_NO_BEGIN_COMMAND_BUFFER, "DS", + HandleToUint64(cb_state->commandBuffer), __LINE__, DRAWSTATE_NO_BEGIN_COMMAND_BUFFER, "DS", "You must call vkBeginCommandBuffer() before this call to %s", caller_name); } } @@ -3334,9 +3329,9 @@ bool insideRenderPass(const layer_data *dev_data, GLOBAL_CB_NODE *pCB, const cha bool inside = false; if (pCB->activeRenderPass) { inside = log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - (uint64_t)pCB->commandBuffer, __LINE__, msgCode, "DS", + HandleToUint64(pCB->commandBuffer), __LINE__, msgCode, "DS", "%s: It is invalid to issue this call inside an active render pass (0x%" PRIxLEAST64 "). %s", apiName, - (uint64_t)pCB->activeRenderPass->renderPass, validation_error_map[msgCode]); + HandleToUint64(pCB->activeRenderPass->renderPass), validation_error_map[msgCode]); } return inside; } @@ -3349,7 +3344,7 @@ bool outsideRenderPass(const layer_data *dev_data, GLOBAL_CB_NODE *pCB, const ch ((pCB->createInfo.level == VK_COMMAND_BUFFER_LEVEL_SECONDARY) && (!pCB->activeRenderPass) && !(pCB->beginInfo.flags & VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT))) { outside = log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - (uint64_t)pCB->commandBuffer, __LINE__, msgCode, "DS", + HandleToUint64(pCB->commandBuffer), __LINE__, msgCode, "DS", "%s: This call must be issued inside an active render pass. %s", apiName, validation_error_map[msgCode]); } return outside; @@ -3449,8 +3444,9 @@ static bool ValidatePhysicalDeviceQueueFamily(instance_layer_data *instance_data if (requested_queue_family >= pd_state->queue_family_count) { skip |= log_msg(instance_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, - reinterpret_cast<uint64_t>(pd_state->phys_device), __LINE__, err_code, "DL", - "%s: %s (= %" PRIu32 ") is not less than any previously obtained pQueueFamilyPropertyCount from " + HandleToUint64(pd_state->phys_device), __LINE__, err_code, "DL", + "%s: %s (= %" PRIu32 + ") is not less than any previously obtained pQueueFamilyPropertyCount from " "vkGetPhysicalDeviceQueueFamilyProperties%s (%s). %s", cmd_name, queue_family_var_name, requested_queue_family, conditional_ext_cmd, count_note.c_str(), vu_note); } @@ -3487,11 +3483,13 @@ static bool ValidateDeviceQueueCreateInfos(instance_layer_data *instance_data, c if (!queue_family_has_props || requested_queue_count > pd_state->queue_family_properties[requested_queue_family].queueCount) { skip |= log_msg(instance_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, - VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, reinterpret_cast<uint64_t>(pd_state->phys_device), - __LINE__, VALIDATION_ERROR_02055, "DL", - "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].queueCount (=%" PRIu32 ") is not " + VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, HandleToUint64(pd_state->phys_device), __LINE__, + VALIDATION_ERROR_02055, "DL", + "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].queueCount (=%" PRIu32 + ") is not " "less than or equal to available queue count for this " - "pCreateInfo->pQueueCreateInfos[%" PRIu32 "].queueFamilyIndex} (=%" PRIu32 ") obtained previously " + "pCreateInfo->pQueueCreateInfos[%" PRIu32 "].queueFamilyIndex} (=%" PRIu32 + ") obtained previously " "from vkGetPhysicalDeviceQueueFamilyProperties%s (%s). %s", i, requested_queue_count, i, requested_queue_family, conditional_ext_cmd, count_note.c_str(), validation_error_map[VALIDATION_ERROR_02055]); @@ -3769,7 +3767,8 @@ static bool VerifyQueueStateToSeq(layer_data *dev_data, QUEUE_STATE *initial_que VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT, 0, 0, DRAWSTATE_INVALID_QUERY, "DS", "Cannot get query results on queryPool 0x%" PRIx64 " with index %d which was guarded by unsignaled event 0x%" PRIx64 ".", - (uint64_t)(queryEventsPair.first.pool), queryEventsPair.first.index, (uint64_t)(event)); + HandleToUint64(queryEventsPair.first.pool), queryEventsPair.first.index, + HandleToUint64(event)); } } } @@ -3923,7 +3922,7 @@ static bool validateCommandBufferState(layer_data *dev_data, GLOBAL_CB_NODE *cb_ skip |= ReportInvalidCommandBuffer(dev_data, cb_state, call_source); } else { // Flag error for using CB w/o vkEndCommandBuffer() called skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - (uint64_t)(cb_state->commandBuffer), __LINE__, DRAWSTATE_NO_END_COMMAND_BUFFER, "DS", + HandleToUint64(cb_state->commandBuffer), __LINE__, DRAWSTATE_NO_END_COMMAND_BUFFER, "DS", "You must call vkEndCommandBuffer() on command buffer 0x%p before this call to %s!", cb_state->commandBuffer, call_source); } @@ -3942,8 +3941,8 @@ static bool validateResources(layer_data *dev_data, GLOBAL_CB_NODE *cb_node) { auto buffer_state = GetBufferState(dev_data, buffer); if (!buffer_state) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT, - (uint64_t)(buffer), __LINE__, DRAWSTATE_INVALID_BUFFER, "DS", - "Cannot submit cmd buffer using deleted buffer 0x%" PRIx64 ".", (uint64_t)(buffer)); + HandleToUint64(buffer), __LINE__, DRAWSTATE_INVALID_BUFFER, "DS", + "Cannot submit cmd buffer using deleted buffer 0x%" PRIx64 ".", HandleToUint64(buffer)); } } } @@ -3965,12 +3964,11 @@ bool ValidImageBufferQueue(layer_data *dev_data, GLOBAL_CB_NODE *cb_node, const } if (!found) { - skip = log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, get_debug_report_enum[object->type], - object->handle, __LINE__, DRAWSTATE_INVALID_QUEUE_FAMILY, "DS", - "vkQueueSubmit: Command buffer 0x%" PRIxLEAST64 " contains %s 0x%" PRIxLEAST64 - " which was not created allowing concurrent access to this queue family %d.", - reinterpret_cast<uint64_t>(cb_node->commandBuffer), object_string[object->type], object->handle, - queue_state->queueFamilyIndex); + skip = log_msg( + dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, get_debug_report_enum[object->type], object->handle, __LINE__, + DRAWSTATE_INVALID_QUEUE_FAMILY, "DS", "vkQueueSubmit: Command buffer 0x%" PRIxLEAST64 " contains %s 0x%" PRIxLEAST64 + " which was not created allowing concurrent access to this queue family %d.", + HandleToUint64(cb_node->commandBuffer), object_string[object->type], object->handle, queue_state->queueFamilyIndex); } } return skip; @@ -3986,7 +3984,7 @@ static bool validateQueueFamilyIndices(layer_data *dev_data, GLOBAL_CB_NODE *pCB if (pPool && queue_state) { if (pPool->queueFamilyIndex != queue_state->queueFamilyIndex) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(pCB->commandBuffer), __LINE__, VALIDATION_ERROR_00139, "DS", + HandleToUint64(pCB->commandBuffer), __LINE__, VALIDATION_ERROR_00139, "DS", "vkQueueSubmit: Primary command buffer 0x%p created in queue family %d is being submitted on queue " "0x%p from queue family %d. %s", pCB->commandBuffer, pPool->queueFamilyIndex, queue, queue_state->queueFamilyIndex, @@ -4053,16 +4051,16 @@ static bool ValidateFenceForSubmit(layer_data *dev_data, FENCE_NODE *pFence) { if (pFence->state == FENCE_INFLIGHT) { // TODO: opportunities for VALIDATION_ERROR_00127, VALIDATION_ERROR_01647, VALIDATION_ERROR_01953 skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT, - (uint64_t)(pFence->fence), __LINE__, DRAWSTATE_INVALID_FENCE, "DS", - "Fence 0x%" PRIx64 " is already in use by another submission.", (uint64_t)(pFence->fence)); + HandleToUint64(pFence->fence), __LINE__, DRAWSTATE_INVALID_FENCE, "DS", + "Fence 0x%" PRIx64 " is already in use by another submission.", HandleToUint64(pFence->fence)); } else if (pFence->state == FENCE_RETIRED) { // TODO: opportunities for VALIDATION_ERROR_00126, VALIDATION_ERROR_01646, VALIDATION_ERROR_01953 skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT, - reinterpret_cast<uint64_t &>(pFence->fence), __LINE__, MEMTRACK_INVALID_FENCE_STATE, "MEM", + HandleToUint64(pFence->fence), __LINE__, MEMTRACK_INVALID_FENCE_STATE, "MEM", "Fence 0x%" PRIxLEAST64 " submitted in SIGNALED state. Fences must be reset before being submitted", - reinterpret_cast<uint64_t &>(pFence->fence)); + HandleToUint64(pFence->fence)); } } @@ -4162,9 +4160,9 @@ static bool PreCallValidateQueueSubmit(layer_data *dev_data, VkQueue queue, uint if (unsignaled_semaphores.count(semaphore) || (!(signaled_semaphores.count(semaphore)) && !(pSemaphore->signaled))) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_SEMAPHORE_EXT, - reinterpret_cast<const uint64_t &>(semaphore), __LINE__, DRAWSTATE_QUEUE_FORWARD_PROGRESS, "DS", + HandleToUint64(semaphore), __LINE__, DRAWSTATE_QUEUE_FORWARD_PROGRESS, "DS", "Queue 0x%p is waiting on semaphore 0x%" PRIx64 " that has no way to be signaled.", queue, - reinterpret_cast<const uint64_t &>(semaphore)); + HandleToUint64(semaphore)); } else { signaled_semaphores.erase(semaphore); unsignaled_semaphores.insert(semaphore); @@ -4177,11 +4175,10 @@ static bool PreCallValidateQueueSubmit(layer_data *dev_data, VkQueue queue, uint if (pSemaphore) { if (signaled_semaphores.count(semaphore) || (!(unsignaled_semaphores.count(semaphore)) && pSemaphore->signaled)) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_SEMAPHORE_EXT, - reinterpret_cast<const uint64_t &>(semaphore), __LINE__, DRAWSTATE_QUEUE_FORWARD_PROGRESS, "DS", + HandleToUint64(semaphore), __LINE__, DRAWSTATE_QUEUE_FORWARD_PROGRESS, "DS", "Queue 0x%p is signaling semaphore 0x%" PRIx64 " that has already been signaled but not waited on by queue 0x%" PRIx64 ".", - queue, reinterpret_cast<const uint64_t &>(semaphore), - reinterpret_cast<uint64_t &>(pSemaphore->signaler.first)); + queue, HandleToUint64(semaphore), HandleToUint64(pSemaphore->signaler.first)); } else { unsignaled_semaphores.erase(semaphore); signaled_semaphores.insert(semaphore); @@ -4239,7 +4236,7 @@ static bool PreCallValidateAllocateMemory(layer_data *dev_data) { bool skip = false; if (dev_data->memObjMap.size() >= dev_data->phys_dev_properties.properties.limits.maxMemoryAllocationCount) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, - reinterpret_cast<const uint64_t &>(dev_data->device), __LINE__, VALIDATION_ERROR_00611, "MEM", + HandleToUint64(dev_data->device), __LINE__, VALIDATION_ERROR_00611, "MEM", "Number of currently valid memory objects is not less than the maximum allowed (%u). %s", dev_data->phys_dev_properties.properties.limits.maxMemoryAllocationCount, validation_error_map[VALIDATION_ERROR_00611]); @@ -4285,7 +4282,7 @@ bool ValidateObjectNotInUse(const layer_data *dev_data, BASE_NODE *obj_node, VK_ static bool PreCallValidateFreeMemory(layer_data *dev_data, VkDeviceMemory mem, DEVICE_MEM_INFO **mem_info, VK_OBJECT *obj_struct) { *mem_info = GetMemObjInfo(dev_data, mem); - *obj_struct = {reinterpret_cast<uint64_t &>(mem), kVulkanObjectTypeDeviceMemory}; + *obj_struct = {HandleToUint64(mem), kVulkanObjectTypeDeviceMemory}; if (dev_data->instance_data->disabled.free_memory) return false; bool skip = false; if (*mem_info) { @@ -4299,7 +4296,7 @@ static void PostCallRecordFreeMemory(layer_data *dev_data, VkDeviceMemory mem, D for (auto obj : mem_info->obj_bindings) { log_msg(dev_data->report_data, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, get_debug_report_enum[obj.type], obj.handle, __LINE__, MEMTRACK_FREED_MEM_REF, "MEM", "VK Object 0x%" PRIxLEAST64 " still has a reference to mem obj 0x%" PRIxLEAST64, - obj.handle, (uint64_t)mem_info->mem); + obj.handle, HandleToUint64(mem_info->mem)); switch (obj.type) { case kVulkanObjectTypeImage: { auto image_state = GetImageState(dev_data, reinterpret_cast<VkImage &>(obj.handle)); @@ -4348,7 +4345,7 @@ static bool ValidateMapMemRange(layer_data *dev_data, VkDeviceMemory mem, VkDevi if (size == 0) { skip = log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT, - (uint64_t)mem, __LINE__, MEMTRACK_INVALID_MAP, "MEM", + HandleToUint64(mem), __LINE__, MEMTRACK_INVALID_MAP, "MEM", "VkMapMemory: Attempting to map memory range of size zero"); } @@ -4357,16 +4354,17 @@ static bool ValidateMapMemRange(layer_data *dev_data, VkDeviceMemory mem, VkDevi auto mem_info = mem_element->second.get(); // It is an application error to call VkMapMemory on an object that is already mapped if (mem_info->mem_range.size != 0) { - skip = log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT, - (uint64_t)mem, __LINE__, MEMTRACK_INVALID_MAP, "MEM", - "VkMapMemory: Attempting to map memory on an already-mapped object 0x%" PRIxLEAST64, (uint64_t)mem); + skip = + log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT, + HandleToUint64(mem), __LINE__, MEMTRACK_INVALID_MAP, "MEM", + "VkMapMemory: Attempting to map memory on an already-mapped object 0x%" PRIxLEAST64, HandleToUint64(mem)); } // Validate that offset + size is within object's allocationSize if (size == VK_WHOLE_SIZE) { if (offset >= mem_info->alloc_info.allocationSize) { skip = log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT, - (uint64_t)mem, __LINE__, MEMTRACK_INVALID_MAP, "MEM", + HandleToUint64(mem), __LINE__, MEMTRACK_INVALID_MAP, "MEM", "Mapping Memory from 0x%" PRIx64 " to 0x%" PRIx64 " with size of VK_WHOLE_SIZE oversteps total array size 0x%" PRIx64, offset, mem_info->alloc_info.allocationSize, mem_info->alloc_info.allocationSize); @@ -4374,7 +4372,7 @@ static bool ValidateMapMemRange(layer_data *dev_data, VkDeviceMemory mem, VkDevi } else { if ((offset + size) > mem_info->alloc_info.allocationSize) { skip = log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT, - (uint64_t)mem, __LINE__, VALIDATION_ERROR_00628, "MEM", + HandleToUint64(mem), __LINE__, VALIDATION_ERROR_00628, "MEM", "Mapping Memory from 0x%" PRIx64 " to 0x%" PRIx64 " oversteps total array size 0x%" PRIx64 ". %s", offset, size + offset, mem_info->alloc_info.allocationSize, validation_error_map[VALIDATION_ERROR_00628]); @@ -4399,8 +4397,8 @@ static bool deleteMemRanges(layer_data *dev_data, VkDeviceMemory mem) { if (!mem_info->mem_range.size) { // Valid Usage: memory must currently be mapped skip = log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT, - (uint64_t)mem, __LINE__, VALIDATION_ERROR_00649, "MEM", - "Unmapping Memory without memory being mapped: mem obj 0x%" PRIxLEAST64 ". %s", (uint64_t)mem, + HandleToUint64(mem), __LINE__, VALIDATION_ERROR_00649, "MEM", + "Unmapping Memory without memory being mapped: mem obj 0x%" PRIxLEAST64 ". %s", HandleToUint64(mem), validation_error_map[VALIDATION_ERROR_00649]); } mem_info->mem_range.size = 0; @@ -4463,11 +4461,11 @@ static inline bool verifyWaitFenceState(layer_data *dev_data, VkFence fence, con if (pFence) { if (pFence->state == FENCE_UNSIGNALED) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT, - reinterpret_cast<uint64_t &>(fence), __LINE__, MEMTRACK_INVALID_FENCE_STATE, "MEM", + HandleToUint64(fence), __LINE__, MEMTRACK_INVALID_FENCE_STATE, "MEM", "%s called for fence 0x%" PRIxLEAST64 " which has not been submitted on a Queue or during " "acquire next image.", - apiCall, reinterpret_cast<uint64_t &>(fence)); + apiCall, HandleToUint64(fence)); } } return skip; @@ -4626,14 +4624,14 @@ VKAPI_ATTR VkResult VKAPI_CALL DeviceWaitIdle(VkDevice device) { static bool PreCallValidateDestroyFence(layer_data *dev_data, VkFence fence, FENCE_NODE **fence_node, VK_OBJECT *obj_struct) { *fence_node = GetFenceNode(dev_data, fence); - *obj_struct = {reinterpret_cast<uint64_t &>(fence), kVulkanObjectTypeFence}; + *obj_struct = {HandleToUint64(fence), kVulkanObjectTypeFence}; if (dev_data->instance_data->disabled.destroy_fence) return false; bool skip = false; if (*fence_node) { if ((*fence_node)->state == FENCE_INFLIGHT) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT, - (uint64_t)(fence), __LINE__, VALIDATION_ERROR_00173, "DS", "Fence 0x%" PRIx64 " is in use. %s", - (uint64_t)(fence), validation_error_map[VALIDATION_ERROR_00173]); + HandleToUint64(fence), __LINE__, VALIDATION_ERROR_00173, "DS", "Fence 0x%" PRIx64 " is in use. %s", + HandleToUint64(fence), validation_error_map[VALIDATION_ERROR_00173]); } } return skip; @@ -4660,7 +4658,7 @@ VKAPI_ATTR void VKAPI_CALL DestroyFence(VkDevice device, VkFence fence, const Vk static bool PreCallValidateDestroySemaphore(layer_data *dev_data, VkSemaphore semaphore, SEMAPHORE_NODE **sema_node, VK_OBJECT *obj_struct) { *sema_node = GetSemaphoreNode(dev_data, semaphore); - *obj_struct = {reinterpret_cast<uint64_t &>(semaphore), kVulkanObjectTypeSemaphore}; + *obj_struct = {HandleToUint64(semaphore), kVulkanObjectTypeSemaphore}; if (dev_data->instance_data->disabled.destroy_semaphore) return false; bool skip = false; if (*sema_node) { @@ -4687,7 +4685,7 @@ VKAPI_ATTR void VKAPI_CALL DestroySemaphore(VkDevice device, VkSemaphore semapho static bool PreCallValidateDestroyEvent(layer_data *dev_data, VkEvent event, EVENT_STATE **event_state, VK_OBJECT *obj_struct) { *event_state = GetEventNode(dev_data, event); - *obj_struct = {reinterpret_cast<uint64_t &>(event), kVulkanObjectTypeEvent}; + *obj_struct = {HandleToUint64(event), kVulkanObjectTypeEvent}; if (dev_data->instance_data->disabled.destroy_event) return false; bool skip = false; if (*event_state) { @@ -4720,7 +4718,7 @@ VKAPI_ATTR void VKAPI_CALL DestroyEvent(VkDevice device, VkEvent event, const Vk static bool PreCallValidateDestroyQueryPool(layer_data *dev_data, VkQueryPool query_pool, QUERY_POOL_NODE **qp_state, VK_OBJECT *obj_struct) { *qp_state = GetQueryPoolNode(dev_data, query_pool); - *obj_struct = {reinterpret_cast<uint64_t &>(query_pool), kVulkanObjectTypeQueryPool}; + *obj_struct = {HandleToUint64(query_pool), kVulkanObjectTypeQueryPool}; if (dev_data->instance_data->disabled.destroy_query_pool) return false; bool skip = false; if (*qp_state) { @@ -4776,7 +4774,7 @@ static bool PreCallValidateGetQueryPoolResults(layer_data *dev_data, VkQueryPool skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT, 0, __LINE__, DRAWSTATE_INVALID_QUERY, "DS", "Cannot get query results on queryPool 0x%" PRIx64 " with index %d which is in flight.", - (uint64_t)(query_pool), first_query + i); + HandleToUint64(query_pool), first_query + i); } } // Unavailable and in flight @@ -4792,21 +4790,21 @@ static bool PreCallValidateGetQueryPoolResults(layer_data *dev_data, VkQueryPool skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT, 0, __LINE__, DRAWSTATE_INVALID_QUERY, "DS", "Cannot get query results on queryPool 0x%" PRIx64 " with index %d which is unavailable.", - (uint64_t)(query_pool), first_query + i); + HandleToUint64(query_pool), first_query + i); } // Unavailable } else if (query_state_pair != dev_data->queryToStateMap.end() && !query_state_pair->second) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT, 0, __LINE__, DRAWSTATE_INVALID_QUERY, "DS", "Cannot get query results on queryPool 0x%" PRIx64 " with index %d which is unavailable.", - (uint64_t)(query_pool), first_query + i); + HandleToUint64(query_pool), first_query + i); // Uninitialized } else if (query_state_pair == dev_data->queryToStateMap.end()) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT, 0, __LINE__, DRAWSTATE_INVALID_QUERY, "DS", "Cannot get query results on queryPool 0x%" PRIx64 " with index %d as data has not been collected for this index.", - (uint64_t)(query_pool), first_query + i); + HandleToUint64(query_pool), first_query + i); } } } @@ -4949,11 +4947,11 @@ static bool ValidateInsertMemoryRange(layer_data const *dev_data, uint64_t handl if (memoryOffset >= mem_info->alloc_info.allocationSize) { UNIQUE_VALIDATION_ERROR_CODE error_code = is_image ? VALIDATION_ERROR_00805 : VALIDATION_ERROR_00793; skip = log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT, - reinterpret_cast<uint64_t &>(mem_info->mem), __LINE__, error_code, "MEM", + HandleToUint64(mem_info->mem), __LINE__, error_code, "MEM", "In %s, attempting to bind memory (0x%" PRIxLEAST64 ") to object (0x%" PRIxLEAST64 "), memoryOffset=0x%" PRIxLEAST64 " must be less than the memory allocation size 0x%" PRIxLEAST64 ". %s", - api_name, reinterpret_cast<uint64_t &>(mem_info->mem), handle, memoryOffset, - mem_info->alloc_info.allocationSize, validation_error_map[error_code]); + api_name, HandleToUint64(mem_info->mem), handle, memoryOffset, mem_info->alloc_info.allocationSize, + validation_error_map[error_code]); } return skip; @@ -5004,22 +5002,20 @@ static void InsertMemoryRange(layer_data const *dev_data, uint64_t handle, DEVIC static bool ValidateInsertImageMemoryRange(layer_data const *dev_data, VkImage image, DEVICE_MEM_INFO *mem_info, VkDeviceSize mem_offset, VkMemoryRequirements mem_reqs, bool is_linear, const char *api_name) { - return ValidateInsertMemoryRange(dev_data, reinterpret_cast<uint64_t &>(image), mem_info, mem_offset, mem_reqs, true, is_linear, - api_name); + return ValidateInsertMemoryRange(dev_data, HandleToUint64(image), mem_info, mem_offset, mem_reqs, true, is_linear, api_name); } static void InsertImageMemoryRange(layer_data const *dev_data, VkImage image, DEVICE_MEM_INFO *mem_info, VkDeviceSize mem_offset, VkMemoryRequirements mem_reqs, bool is_linear) { - InsertMemoryRange(dev_data, reinterpret_cast<uint64_t &>(image), mem_info, mem_offset, mem_reqs, true, is_linear); + InsertMemoryRange(dev_data, HandleToUint64(image), mem_info, mem_offset, mem_reqs, true, is_linear); } static bool ValidateInsertBufferMemoryRange(layer_data const *dev_data, VkBuffer buffer, DEVICE_MEM_INFO *mem_info, VkDeviceSize mem_offset, VkMemoryRequirements mem_reqs, const char *api_name) { - return ValidateInsertMemoryRange(dev_data, reinterpret_cast<uint64_t &>(buffer), mem_info, mem_offset, mem_reqs, false, true, - api_name); + return ValidateInsertMemoryRange(dev_data, HandleToUint64(buffer), mem_info, mem_offset, mem_reqs, false, true, api_name); } static void InsertBufferMemoryRange(layer_data const *dev_data, VkBuffer buffer, DEVICE_MEM_INFO *mem_info, VkDeviceSize mem_offset, VkMemoryRequirements mem_reqs) { - InsertMemoryRange(dev_data, reinterpret_cast<uint64_t &>(buffer), mem_info, mem_offset, mem_reqs, false, true); + InsertMemoryRange(dev_data, HandleToUint64(buffer), mem_info, mem_offset, mem_reqs, false, true); } // Remove MEMORY_RANGE struct for give handle from bound_ranges of mem_info @@ -5099,11 +5095,11 @@ static bool ValidateMemoryTypes(const layer_data *dev_data, const DEVICE_MEM_INF bool skip = false; if (((1 << mem_info->alloc_info.memoryTypeIndex) & memory_type_bits) == 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_info->mem), __LINE__, msgCode, "MT", + HandleToUint64(mem_info->mem), __LINE__, msgCode, "MT", "%s(): MemoryRequirements->memoryTypeBits (0x%X) for this object type are not compatible with the memory " "type (0x%X) of this memory object 0x%" PRIx64 ". %s", - funcName, memory_type_bits, mem_info->alloc_info.memoryTypeIndex, - reinterpret_cast<const uint64_t &>(mem_info->mem), validation_error_map[msgCode]); + funcName, memory_type_bits, mem_info->alloc_info.memoryTypeIndex, HandleToUint64(mem_info->mem), + validation_error_map[msgCode]); } return skip; } @@ -5114,7 +5110,7 @@ static bool PreCallValidateBindBufferMemory(layer_data *dev_data, VkBuffer buffe if (buffer_state) { std::unique_lock<std::mutex> lock(global_lock); // Track objects tied to memory - uint64_t buffer_handle = reinterpret_cast<uint64_t &>(buffer); + uint64_t buffer_handle = HandleToUint64(buffer); skip = ValidateSetMemBinding(dev_data, mem, buffer_handle, kVulkanObjectTypeBuffer, "vkBindBufferMemory()"); if (!buffer_state->memory_requirements_checked) { // There's not an explicit requirement in the spec to call vkGetBufferMemoryRequirements() prior to calling @@ -5211,7 +5207,7 @@ static void PostCallRecordBindBufferMemory(layer_data *dev_data, VkBuffer buffer } // Track objects tied to memory - uint64_t buffer_handle = reinterpret_cast<uint64_t &>(buffer); + uint64_t buffer_handle = HandleToUint64(buffer); SetMemBinding(dev_data, mem, buffer_handle, kVulkanObjectTypeBuffer, "vkBindBufferMemory()"); buffer_state->binding.mem = mem; @@ -5286,7 +5282,7 @@ VKAPI_ATTR void VKAPI_CALL DestroyShaderModule(VkDevice device, VkShaderModule s static bool PreCallValidateDestroyPipeline(layer_data *dev_data, VkPipeline pipeline, PIPELINE_STATE **pipeline_state, VK_OBJECT *obj_struct) { *pipeline_state = getPipelineState(dev_data, pipeline); - *obj_struct = {reinterpret_cast<uint64_t &>(pipeline), kVulkanObjectTypePipeline}; + *obj_struct = {HandleToUint64(pipeline), kVulkanObjectTypePipeline}; if (dev_data->instance_data->disabled.destroy_pipeline) return false; bool skip = false; if (*pipeline_state) { @@ -5331,7 +5327,7 @@ VKAPI_ATTR void VKAPI_CALL DestroyPipelineLayout(VkDevice device, VkPipelineLayo static bool PreCallValidateDestroySampler(layer_data *dev_data, VkSampler sampler, SAMPLER_STATE **sampler_state, VK_OBJECT *obj_struct) { *sampler_state = GetSamplerState(dev_data, sampler); - *obj_struct = {reinterpret_cast<uint64_t &>(sampler), kVulkanObjectTypeSampler}; + *obj_struct = {HandleToUint64(sampler), kVulkanObjectTypeSampler}; if (dev_data->instance_data->disabled.destroy_sampler) return false; bool skip = false; if (*sampler_state) { @@ -5378,7 +5374,7 @@ VKAPI_ATTR void VKAPI_CALL DestroyDescriptorSetLayout(VkDevice device, VkDescrip static bool PreCallValidateDestroyDescriptorPool(layer_data *dev_data, VkDescriptorPool pool, DESCRIPTOR_POOL_STATE **desc_pool_state, VK_OBJECT *obj_struct) { *desc_pool_state = GetDescriptorPoolState(dev_data, pool); - *obj_struct = {reinterpret_cast<uint64_t &>(pool), kVulkanObjectTypeDescriptorPool}; + *obj_struct = {HandleToUint64(pool), kVulkanObjectTypeDescriptorPool}; if (dev_data->instance_data->disabled.destroy_descriptor_pool) return false; bool skip = false; if (*desc_pool_state) { @@ -5426,7 +5422,7 @@ static bool checkCommandBufferInFlight(layer_data *dev_data, const GLOBAL_CB_NOD if ((cb_node->createInfo.level != VK_COMMAND_BUFFER_LEVEL_SECONDARY) || (dev_data->globalInFlightCmdBuffers.count(cb_node->primaryCommandBuffer))) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<const uint64_t &>(cb_node->commandBuffer), __LINE__, error_code, "DS", + HandleToUint64(cb_node->commandBuffer), __LINE__, error_code, "DS", "Attempt to %s command buffer (0x%p) which is in use. %s", action, cb_node->commandBuffer, validation_error_map[error_code]); } @@ -5609,9 +5605,8 @@ VKAPI_ATTR VkResult VKAPI_CALL ResetFences(VkDevice device, uint32_t fenceCount, auto pFence = GetFenceNode(dev_data, pFences[i]); if (pFence && pFence->state == FENCE_INFLIGHT) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT, - reinterpret_cast<const uint64_t &>(pFences[i]), __LINE__, VALIDATION_ERROR_00183, "DS", - "Fence 0x%" PRIx64 " is in use. %s", reinterpret_cast<const uint64_t &>(pFences[i]), - validation_error_map[VALIDATION_ERROR_00183]); + HandleToUint64(pFences[i]), __LINE__, VALIDATION_ERROR_00183, "DS", "Fence 0x%" PRIx64 " is in use. %s", + HandleToUint64(pFences[i]), validation_error_map[VALIDATION_ERROR_00183]); } } lock.unlock(); @@ -5639,7 +5634,7 @@ void invalidateCommandBuffers(const layer_data *dev_data, std::unordered_set<GLO for (auto cb_node : cb_nodes) { if (cb_node->state == CB_RECORDING) { log_msg(dev_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - (uint64_t)(cb_node->commandBuffer), __LINE__, DRAWSTATE_INVALID_COMMAND_BUFFER, "DS", + HandleToUint64(cb_node->commandBuffer), __LINE__, DRAWSTATE_INVALID_COMMAND_BUFFER, "DS", "Invalidating a command buffer that's currently being recorded: 0x%p.", cb_node->commandBuffer); } cb_node->state = CB_INVALID; @@ -5650,7 +5645,7 @@ void invalidateCommandBuffers(const layer_data *dev_data, std::unordered_set<GLO static bool PreCallValidateDestroyFramebuffer(layer_data *dev_data, VkFramebuffer framebuffer, FRAMEBUFFER_STATE **framebuffer_state, VK_OBJECT *obj_struct) { *framebuffer_state = GetFramebufferState(dev_data, framebuffer); - *obj_struct = {reinterpret_cast<uint64_t &>(framebuffer), kVulkanObjectTypeFramebuffer}; + *obj_struct = {HandleToUint64(framebuffer), kVulkanObjectTypeFramebuffer}; if (dev_data->instance_data->disabled.destroy_framebuffer) return false; bool skip = false; if (*framebuffer_state) { @@ -5684,7 +5679,7 @@ VKAPI_ATTR void VKAPI_CALL DestroyFramebuffer(VkDevice device, VkFramebuffer fra static bool PreCallValidateDestroyRenderPass(layer_data *dev_data, VkRenderPass render_pass, RENDER_PASS_STATE **rp_state, VK_OBJECT *obj_struct) { *rp_state = GetRenderPassState(dev_data, render_pass); - *obj_struct = {reinterpret_cast<uint64_t &>(render_pass), kVulkanObjectTypeRenderPass}; + *obj_struct = {HandleToUint64(render_pass), kVulkanObjectTypeRenderPass}; if (dev_data->instance_data->disabled.destroy_renderpass) return false; bool skip = false; if (*rp_state) { @@ -5925,10 +5920,10 @@ bool validate_dual_src_blend_feature(layer_data *device_data, PIPELINE_STATE *pi (pipe_state->attachments[i].srcAlphaBlendFactor == VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA)) { skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, - reinterpret_cast<uint64_t &>(pipe_state->pipeline), __LINE__, DRAWSTATE_INVALID_FEATURE, "DS", + HandleToUint64(pipe_state->pipeline), __LINE__, DRAWSTATE_INVALID_FEATURE, "DS", "CmdBindPipeline: vkPipeline (0x%" PRIxLEAST64 ") attachment[" PRINTF_SIZE_T_SPECIFIER "] has a dual-source blend factor but this device feature is not enabled.", - reinterpret_cast<uint64_t &>(pipe_state->pipeline), i); + HandleToUint64(pipe_state->pipeline), i); } } } @@ -6263,7 +6258,7 @@ VKAPI_ATTR VkResult VKAPI_CALL CreateDescriptorPool(VkDevice device, const VkDes DESCRIPTOR_POOL_STATE *pNewNode = new DESCRIPTOR_POOL_STATE(*pDescriptorPool, pCreateInfo); if (NULL == pNewNode) { if (log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT, - (uint64_t)*pDescriptorPool, __LINE__, DRAWSTATE_OUT_OF_MEMORY, "DS", + HandleToUint64(*pDescriptorPool), __LINE__, DRAWSTATE_OUT_OF_MEMORY, "DS", "Out of memory while attempting to allocate DESCRIPTOR_POOL_STATE in vkCreateDescriptorPool()")) return VK_ERROR_VALIDATION_FAILED_EXT; } else { @@ -6342,7 +6337,7 @@ static bool PreCallValidateFreeDescriptorSets(const layer_data *dev_data, VkDesc if (pool_state && !(VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT & pool_state->createInfo.flags)) { // Can't Free from a NON_FREE pool skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT, - reinterpret_cast<uint64_t &>(pool), __LINE__, VALIDATION_ERROR_00922, "DS", + HandleToUint64(pool), __LINE__, VALIDATION_ERROR_00922, "DS", "It is invalid to call vkFreeDescriptorSets() with a pool created without setting " "VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT. %s", validation_error_map[VALIDATION_ERROR_00922]); @@ -6461,8 +6456,7 @@ VKAPI_ATTR VkResult VKAPI_CALL AllocateCommandBuffers(VkDevice device, const VkC // Add bindings between the given cmd buffer & framebuffer and the framebuffer's children static void AddFramebufferBinding(layer_data *dev_data, GLOBAL_CB_NODE *cb_state, FRAMEBUFFER_STATE *fb_state) { - addCommandBufferBinding(&fb_state->cb_bindings, - {reinterpret_cast<uint64_t &>(fb_state->framebuffer), kVulkanObjectTypeFramebuffer}, + addCommandBufferBinding(&fb_state->cb_bindings, {HandleToUint64(fb_state->framebuffer), kVulkanObjectTypeFramebuffer}, cb_state); for (auto attachment : fb_state->attachments) { auto view_state = attachment.view_state; @@ -6471,9 +6465,8 @@ static void AddFramebufferBinding(layer_data *dev_data, GLOBAL_CB_NODE *cb_state } auto rp_state = GetRenderPassState(dev_data, fb_state->createInfo.renderPass); if (rp_state) { - addCommandBufferBinding( - &rp_state->cb_bindings, - {reinterpret_cast<uint64_t &>(rp_state->renderPass), kVulkanObjectTypeRenderPass}, cb_state); + addCommandBufferBinding(&rp_state->cb_bindings, {HandleToUint64(rp_state->renderPass), kVulkanObjectTypeRenderPass}, + cb_state); } } } @@ -6488,7 +6481,7 @@ VKAPI_ATTR VkResult VKAPI_CALL BeginCommandBuffer(VkCommandBuffer commandBuffer, // This implicitly resets the Cmd Buffer so make sure any fence is done and then clear memory references if (dev_data->globalInFlightCmdBuffers.count(commandBuffer)) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - (uint64_t)commandBuffer, __LINE__, VALIDATION_ERROR_00103, "MEM", + HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_00103, "MEM", "Calling vkBeginCommandBuffer() on active command buffer 0x%p before it has completed. " "You must check command buffer fence before this call. %s", commandBuffer, validation_error_map[VALIDATION_ERROR_00103]); @@ -6500,7 +6493,7 @@ VKAPI_ATTR VkResult VKAPI_CALL BeginCommandBuffer(VkCommandBuffer commandBuffer, if (!pInfo) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(commandBuffer), __LINE__, VALIDATION_ERROR_00106, "DS", + HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_00106, "DS", "vkBeginCommandBuffer(): Secondary Command Buffer (0x%p) must have inheritance info. %s", commandBuffer, validation_error_map[VALIDATION_ERROR_00106]); } else { @@ -6517,15 +6510,14 @@ VKAPI_ATTR VkResult VKAPI_CALL BeginCommandBuffer(VkCommandBuffer commandBuffer, errorString)) { // renderPass that framebuffer was created with must be compatible with local renderPass skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, - VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(commandBuffer), __LINE__, VALIDATION_ERROR_00112, "DS", + VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, HandleToUint64(commandBuffer), __LINE__, + VALIDATION_ERROR_00112, "DS", "vkBeginCommandBuffer(): Secondary Command " "Buffer (0x%p) renderPass (0x%" PRIxLEAST64 ") is incompatible w/ framebuffer " "(0x%" PRIxLEAST64 ") w/ render pass (0x%" PRIxLEAST64 ") due to: %s. %s", - commandBuffer, reinterpret_cast<const uint64_t &>(pInfo->renderPass), - reinterpret_cast<const uint64_t &>(pInfo->framebuffer), - reinterpret_cast<uint64_t &>(framebuffer->createInfo.renderPass), errorString.c_str(), + commandBuffer, HandleToUint64(pInfo->renderPass), HandleToUint64(pInfo->framebuffer), + HandleToUint64(framebuffer->createInfo.renderPass), errorString.c_str(), validation_error_map[VALIDATION_ERROR_00112]); } // Connect this framebuffer and its children to this cmdBuffer @@ -6535,8 +6527,8 @@ VKAPI_ATTR VkResult VKAPI_CALL BeginCommandBuffer(VkCommandBuffer commandBuffer, if ((pInfo->occlusionQueryEnable == VK_FALSE || dev_data->enabled_features.occlusionQueryPrecise == VK_FALSE) && (pInfo->queryFlags & VK_QUERY_CONTROL_PRECISE_BIT)) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, - VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, reinterpret_cast<uint64_t>(commandBuffer), - __LINE__, VALIDATION_ERROR_00107, "DS", + VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, HandleToUint64(commandBuffer), __LINE__, + VALIDATION_ERROR_00107, "DS", "vkBeginCommandBuffer(): Secondary Command Buffer (0x%p) must not have " "VK_QUERY_CONTROL_PRECISE_BIT if occulusionQuery is disabled or the device does not " "support precise occlusion queries. %s", @@ -6548,7 +6540,7 @@ VKAPI_ATTR VkResult VKAPI_CALL BeginCommandBuffer(VkCommandBuffer commandBuffer, if (renderPass) { if (pInfo->subpass >= renderPass->createInfo.subpassCount) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, - VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, (uint64_t)commandBuffer, __LINE__, + VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_00111, "DS", "vkBeginCommandBuffer(): Secondary Command Buffers (0x%p) must have a subpass index (%d) " "that is less than the number of subpasses (%d). %s", @@ -6560,7 +6552,7 @@ VKAPI_ATTR VkResult VKAPI_CALL BeginCommandBuffer(VkCommandBuffer commandBuffer, } if (CB_RECORDING == cb_node->state) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - (uint64_t)commandBuffer, __LINE__, VALIDATION_ERROR_00103, "DS", + HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_00103, "DS", "vkBeginCommandBuffer(): Cannot call Begin on command buffer (0x%p" ") in the RECORDING state. Must first call vkEndCommandBuffer(). %s", commandBuffer, validation_error_map[VALIDATION_ERROR_00103]); @@ -6570,11 +6562,11 @@ VKAPI_ATTR VkResult VKAPI_CALL BeginCommandBuffer(VkCommandBuffer commandBuffer, if (!(VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT & pPool->createFlags)) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - (uint64_t)commandBuffer, __LINE__, VALIDATION_ERROR_00105, "DS", + HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_00105, "DS", "Call to vkBeginCommandBuffer() on command buffer (0x%p" ") attempts to implicitly reset cmdBuffer created from command pool (0x%" PRIxLEAST64 ") that does NOT have the VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT bit set. %s", - commandBuffer, (uint64_t)cmdPool, validation_error_map[VALIDATION_ERROR_00105]); + commandBuffer, HandleToUint64(cmdPool), validation_error_map[VALIDATION_ERROR_00105]); } resetCB(dev_data, commandBuffer); } @@ -6619,9 +6611,9 @@ VKAPI_ATTR VkResult VKAPI_CALL EndCommandBuffer(VkCommandBuffer commandBuffer) { UpdateCmdBufferLastCmd(pCB, CMD_END); for (auto query : pCB->activeQueries) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(commandBuffer), __LINE__, VALIDATION_ERROR_00124, "DS", + HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_00124, "DS", "Ending command buffer with in progress query: queryPool 0x%" PRIx64 ", index %d. %s", - (uint64_t)(query.pool), query.index, validation_error_map[VALIDATION_ERROR_00124]); + HandleToUint64(query.pool), query.index, validation_error_map[VALIDATION_ERROR_00124]); } } if (!skip) { @@ -6646,10 +6638,10 @@ VKAPI_ATTR VkResult VKAPI_CALL ResetCommandBuffer(VkCommandBuffer commandBuffer, auto pPool = GetCommandPoolNode(dev_data, cmdPool); if (!(VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT & pPool->createFlags)) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - (uint64_t)commandBuffer, __LINE__, VALIDATION_ERROR_00093, "DS", + HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_00093, "DS", "Attempt to reset command buffer (0x%p) created from command pool (0x%" PRIxLEAST64 ") that does NOT have the VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT bit set. %s", - commandBuffer, (uint64_t)cmdPool, validation_error_map[VALIDATION_ERROR_00093]); + commandBuffer, HandleToUint64(cmdPool), validation_error_map[VALIDATION_ERROR_00093]); } skip |= checkCommandBufferInFlight(dev_data, pCB, "reset", VALIDATION_ERROR_00092); lock.unlock(); @@ -6678,9 +6670,9 @@ VKAPI_ATTR void VKAPI_CALL CmdBindPipeline(VkCommandBuffer commandBuffer, VkPipe if ((VK_PIPELINE_BIND_POINT_COMPUTE == pipelineBindPoint) && (cb_state->activeRenderPass)) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, - (uint64_t)pipeline, __LINE__, DRAWSTATE_INVALID_RENDERPASS_CMD, "DS", + HandleToUint64(pipeline), __LINE__, DRAWSTATE_INVALID_RENDERPASS_CMD, "DS", "Incorrectly binding compute pipeline (0x%" PRIxLEAST64 ") during active RenderPass (0x%" PRIxLEAST64 ")", - (uint64_t)pipeline, (uint64_t)cb_state->activeRenderPass->renderPass); + HandleToUint64(pipeline), HandleToUint64(cb_state->activeRenderPass->renderPass)); } // TODO: VALIDATION_ERROR_00594 VALIDATION_ERROR_00596 @@ -6692,19 +6684,17 @@ VKAPI_ATTR void VKAPI_CALL CmdBindPipeline(VkCommandBuffer commandBuffer, VkPipe skip |= validate_dual_src_blend_feature(dev_data, pipe_state); } else { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, - (uint64_t)pipeline, __LINE__, VALIDATION_ERROR_00600, "DS", - "Attempt to bind Pipeline 0x%" PRIxLEAST64 " that doesn't exist! %s", (uint64_t)(pipeline), + HandleToUint64(pipeline), __LINE__, VALIDATION_ERROR_00600, "DS", + "Attempt to bind Pipeline 0x%" PRIxLEAST64 " that doesn't exist! %s", HandleToUint64(pipeline), validation_error_map[VALIDATION_ERROR_00600]); } - addCommandBufferBinding(&pipe_state->cb_bindings, - {reinterpret_cast<uint64_t &>(pipeline), kVulkanObjectTypePipeline}, cb_state); + addCommandBufferBinding(&pipe_state->cb_bindings, {HandleToUint64(pipeline), kVulkanObjectTypePipeline}, cb_state); if (VK_PIPELINE_BIND_POINT_GRAPHICS == pipelineBindPoint) { // Add binding for child renderpass auto rp_state = GetRenderPassState(dev_data, pipe_state->graphicsPipelineCI.renderPass); if (rp_state) { - addCommandBufferBinding( - &rp_state->cb_bindings, - {reinterpret_cast<uint64_t &>(rp_state->renderPass), kVulkanObjectTypeRenderPass}, cb_state); + addCommandBufferBinding(&rp_state->cb_bindings, {HandleToUint64(rp_state->renderPass), kVulkanObjectTypeRenderPass}, + cb_state); } } } @@ -6758,13 +6748,13 @@ VKAPI_ATTR void VKAPI_CALL CmdSetLineWidth(VkCommandBuffer commandBuffer, float PIPELINE_STATE *pPipeTrav = pCB->lastBound[VK_PIPELINE_BIND_POINT_GRAPHICS].pipeline_state; if (pPipeTrav != NULL && !isDynamic(pPipeTrav, VK_DYNAMIC_STATE_LINE_WIDTH)) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(commandBuffer), __LINE__, VALIDATION_ERROR_01476, "DS", + HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_01476, "DS", "vkCmdSetLineWidth called but pipeline was created without VK_DYNAMIC_STATE_LINE_WIDTH " "flag. This is undefined behavior and could be ignored. %s", validation_error_map[VALIDATION_ERROR_01476]); } else { - skip |= verifyLineWidth(dev_data, DRAWSTATE_INVALID_SET, kVulkanObjectTypeCommandBuffer, - reinterpret_cast<uint64_t &>(commandBuffer), lineWidth); + skip |= verifyLineWidth(dev_data, DRAWSTATE_INVALID_SET, kVulkanObjectTypeCommandBuffer, HandleToUint64(commandBuffer), + lineWidth); } } lock.unlock(); @@ -6782,7 +6772,7 @@ VKAPI_ATTR void VKAPI_CALL CmdSetDepthBias(VkCommandBuffer commandBuffer, float skip |= ValidateCmd(dev_data, pCB, CMD_SETDEPTHBIASSTATE, "vkCmdSetDepthBias()"); if ((depthBiasClamp != 0.0) && (!dev_data->enabled_features.depthBiasClamp)) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(commandBuffer), __LINE__, VALIDATION_ERROR_01482, "DS", + HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_01482, "DS", "vkCmdSetDepthBias(): the depthBiasClamp device feature is disabled: the depthBiasClamp " "parameter must be set to 0.0. %s", validation_error_map[VALIDATION_ERROR_01482]); @@ -6901,25 +6891,25 @@ VKAPI_ATTR void VKAPI_CALL CmdBindDescriptorSets(VkCommandBuffer commandBuffer, cb_state->lastBound[pipelineBindPoint].pipeline_layout = *pipeline_layout; cb_state->lastBound[pipelineBindPoint].boundDescriptorSets[set_idx + firstSet] = descriptor_set; skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, - VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT, (uint64_t)pDescriptorSets[set_idx], __LINE__, + VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT, HandleToUint64(pDescriptorSets[set_idx]), __LINE__, DRAWSTATE_NONE, "DS", "Descriptor Set 0x%" PRIxLEAST64 " bound on pipeline %s", - (uint64_t)pDescriptorSets[set_idx], string_VkPipelineBindPoint(pipelineBindPoint)); + HandleToUint64(pDescriptorSets[set_idx]), string_VkPipelineBindPoint(pipelineBindPoint)); if (!descriptor_set->IsUpdated() && (descriptor_set->GetTotalDescriptorCount() != 0)) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, - VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT, (uint64_t)pDescriptorSets[set_idx], __LINE__, - DRAWSTATE_DESCRIPTOR_SET_NOT_UPDATED, "DS", + VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT, HandleToUint64(pDescriptorSets[set_idx]), + __LINE__, DRAWSTATE_DESCRIPTOR_SET_NOT_UPDATED, "DS", "Descriptor Set 0x%" PRIxLEAST64 " bound but it was never updated. You may want to either update it or not bind it.", - (uint64_t)pDescriptorSets[set_idx]); + HandleToUint64(pDescriptorSets[set_idx])); } // Verify that set being bound is compatible with overlapping setLayout of pipelineLayout if (!verify_set_layout_compatibility(descriptor_set, pipeline_layout, set_idx + firstSet, error_string)) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, - VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT, (uint64_t)pDescriptorSets[set_idx], __LINE__, - VALIDATION_ERROR_00974, "DS", + VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT, HandleToUint64(pDescriptorSets[set_idx]), + __LINE__, VALIDATION_ERROR_00974, "DS", "descriptorSet #%u being bound is not compatible with overlapping descriptorSetLayout " "at index %u of pipelineLayout 0x%" PRIxLEAST64 " due to: %s. %s", - set_idx, set_idx + firstSet, reinterpret_cast<uint64_t &>(layout), error_string.c_str(), + set_idx, set_idx + firstSet, HandleToUint64(layout), error_string.c_str(), validation_error_map[VALIDATION_ERROR_00974]); } @@ -6930,14 +6920,14 @@ VKAPI_ATTR void VKAPI_CALL CmdBindDescriptorSets(VkCommandBuffer commandBuffer, if (set_dynamic_descriptor_count) { // First make sure we won't overstep bounds of pDynamicOffsets array if ((total_dynamic_descriptors + set_dynamic_descriptor_count) > dynamicOffsetCount) { - skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, - VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT, (uint64_t)pDescriptorSets[set_idx], - __LINE__, DRAWSTATE_INVALID_DYNAMIC_OFFSET_COUNT, "DS", - "descriptorSet #%u (0x%" PRIxLEAST64 - ") requires %u dynamicOffsets, but only %u dynamicOffsets are left in pDynamicOffsets " - "array. There must be one dynamic offset for each dynamic descriptor being bound.", - set_idx, (uint64_t)pDescriptorSets[set_idx], descriptor_set->GetDynamicDescriptorCount(), - (dynamicOffsetCount - total_dynamic_descriptors)); + skip |= log_msg( + dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT, + HandleToUint64(pDescriptorSets[set_idx]), __LINE__, DRAWSTATE_INVALID_DYNAMIC_OFFSET_COUNT, "DS", + "descriptorSet #%u (0x%" PRIxLEAST64 + ") requires %u dynamicOffsets, but only %u dynamicOffsets are left in pDynamicOffsets " + "array. There must be one dynamic offset for each dynamic descriptor being bound.", + set_idx, HandleToUint64(pDescriptorSets[set_idx]), descriptor_set->GetDynamicDescriptorCount(), + (dynamicOffsetCount - total_dynamic_descriptors)); } else { // Validate and store dynamic offsets with the set // Validate Dynamic Offset Minimums uint32_t cur_dyn_offset = total_dynamic_descriptors; @@ -6981,10 +6971,11 @@ VKAPI_ATTR void VKAPI_CALL CmdBindDescriptorSets(VkCommandBuffer commandBuffer, } } } else { - skip |= log_msg( - dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT, - (uint64_t)pDescriptorSets[set_idx], __LINE__, DRAWSTATE_INVALID_SET, "DS", - "Attempt to bind descriptor set 0x%" PRIxLEAST64 " that doesn't exist!", (uint64_t)pDescriptorSets[set_idx]); + skip |= + log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT, + HandleToUint64(pDescriptorSets[set_idx]), __LINE__, DRAWSTATE_INVALID_SET, "DS", + "Attempt to bind descriptor set 0x%" PRIxLEAST64 " that doesn't exist!", + HandleToUint64(pDescriptorSets[set_idx])); } UpdateCmdBufferLastCmd(cb_state, CMD_BINDDESCRIPTORSETS); // For any previously bound sets, need to set them to "invalid" if they were disturbed by this update @@ -6996,10 +6987,11 @@ VKAPI_ATTR void VKAPI_CALL CmdBindDescriptorSets(VkCommandBuffer commandBuffer, skip |= log_msg( dev_data->report_data, VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT, - (uint64_t)cb_state->lastBound[pipelineBindPoint].boundDescriptorSets[i], __LINE__, DRAWSTATE_NONE, "DS", - "DescriptorSet 0x%" PRIxLEAST64 - " previously bound as set #%u was disturbed by newly bound pipelineLayout (0x%" PRIxLEAST64 ")", - (uint64_t)cb_state->lastBound[pipelineBindPoint].boundDescriptorSets[i], i, (uint64_t)layout); + HandleToUint64(cb_state->lastBound[pipelineBindPoint].boundDescriptorSets[i]), __LINE__, DRAWSTATE_NONE, + "DS", "DescriptorSet 0x%" PRIxLEAST64 + " previously bound as set #%u was disturbed by newly bound pipelineLayout (0x%" PRIxLEAST64 ")", + HandleToUint64(cb_state->lastBound[pipelineBindPoint].boundDescriptorSets[i]), i, + HandleToUint64(layout)); cb_state->lastBound[pipelineBindPoint].boundDescriptorSets[i] = VK_NULL_HANDLE; } } @@ -7010,14 +7002,14 @@ VKAPI_ATTR void VKAPI_CALL CmdBindDescriptorSets(VkCommandBuffer commandBuffer, !verify_set_layout_compatibility(old_final_bound_set, pipeline_layout, last_set_index, error_string)) { auto old_set = old_final_bound_set->GetSet(); skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, - VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT, reinterpret_cast<uint64_t &>(old_set), __LINE__, + VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT, HandleToUint64(old_set), __LINE__, DRAWSTATE_NONE, "DS", "DescriptorSet 0x%" PRIxLEAST64 " previously bound as set #%u is incompatible with set 0x%" PRIxLEAST64 " newly bound as set #%u so set #%u and any subsequent sets were " "disturbed by newly bound pipelineLayout (0x%" PRIxLEAST64 ")", - reinterpret_cast<uint64_t &>(old_set), last_set_index, - (uint64_t)cb_state->lastBound[pipelineBindPoint].boundDescriptorSets[last_set_index], - last_set_index, last_set_index + 1, (uint64_t)layout); + HandleToUint64(old_set), last_set_index, + HandleToUint64(cb_state->lastBound[pipelineBindPoint].boundDescriptorSets[last_set_index]), + last_set_index, last_set_index + 1, HandleToUint64(layout)); cb_state->lastBound[pipelineBindPoint].boundDescriptorSets.resize(last_set_index + 1); } } @@ -7025,7 +7017,7 @@ VKAPI_ATTR void VKAPI_CALL CmdBindDescriptorSets(VkCommandBuffer commandBuffer, // dynamicOffsetCount must equal the total number of dynamic descriptors in the sets being bound if (total_dynamic_descriptors != dynamicOffsetCount) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - (uint64_t)commandBuffer, __LINE__, VALIDATION_ERROR_00975, "DS", + HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_00975, "DS", "Attempting to bind %u descriptorSets with %u dynamic descriptors, but dynamicOffsetCount " "is %u. It should exactly match the number of dynamic descriptors. %s", setCount, total_dynamic_descriptors, dynamicOffsetCount, validation_error_map[VALIDATION_ERROR_00975]); @@ -7069,7 +7061,7 @@ VKAPI_ATTR void VKAPI_CALL CmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkB } if (!offset_align || (offset % offset_align)) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(commandBuffer), __LINE__, DRAWSTATE_VTX_INDEX_ALIGNMENT_ERROR, "DS", + HandleToUint64(commandBuffer), __LINE__, DRAWSTATE_VTX_INDEX_ALIGNMENT_ERROR, "DS", "vkCmdBindIndexBuffer() offset (0x%" PRIxLEAST64 ") does not fall on alignment (%s) boundary.", offset, string_VkIndexType(indexType)); } @@ -7114,7 +7106,7 @@ VKAPI_ATTR void VKAPI_CALL CmdBindVertexBuffers(VkCommandBuffer commandBuffer, u cb_node->validate_functions.push_back(function); if (pOffsets[i] >= buffer_state->createInfo.size) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT, - reinterpret_cast<uint64_t &>(buffer_state->buffer), __LINE__, VALIDATION_ERROR_01417, "DS", + HandleToUint64(buffer_state->buffer), __LINE__, VALIDATION_ERROR_01417, "DS", "vkCmdBindVertexBuffers() offset (0x%" PRIxLEAST64 ") is beyond the end of the buffer. %s", pOffsets[i], validation_error_map[VALIDATION_ERROR_01417]); } @@ -7419,12 +7411,11 @@ bool ValidateImageSampleCount(layer_data *dev_data, IMAGE_STATE *image_state, Vk const char *location, UNIQUE_VALIDATION_ERROR_CODE msgCode) { bool skip = false; if (image_state->createInfo.samples != sample_count) { - skip = - log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, - reinterpret_cast<uint64_t &>(image_state->image), 0, msgCode, "DS", - "%s for image 0x%" PRIxLEAST64 " was created with a sample count of %s but must be %s. %s", location, - reinterpret_cast<uint64_t &>(image_state->image), string_VkSampleCountFlagBits(image_state->createInfo.samples), - string_VkSampleCountFlagBits(sample_count), validation_error_map[msgCode]); + skip = log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, + HandleToUint64(image_state->image), 0, msgCode, "DS", + "%s for image 0x%" PRIxLEAST64 " was created with a sample count of %s but must be %s. %s", location, + HandleToUint64(image_state->image), string_VkSampleCountFlagBits(image_state->createInfo.samples), + string_VkSampleCountFlagBits(sample_count), validation_error_map[msgCode]); } return skip; } @@ -7650,8 +7641,7 @@ VKAPI_ATTR void VKAPI_CALL CmdSetEvent(VkCommandBuffer commandBuffer, VkEvent ev ValidateStageMaskGsTsEnables(dev_data, stageMask, "vkCmdSetEvent()", VALIDATION_ERROR_00230, VALIDATION_ERROR_00231); auto event_state = GetEventNode(dev_data, event); if (event_state) { - addCommandBufferBinding(&event_state->cb_bindings, - {reinterpret_cast<uint64_t &>(event), kVulkanObjectTypeEvent}, pCB); + addCommandBufferBinding(&event_state->cb_bindings, {HandleToUint64(event), kVulkanObjectTypeEvent}, pCB); event_state->cb_bindings.insert(pCB); } pCB->events.push_back(event); @@ -7681,8 +7671,7 @@ VKAPI_ATTR void VKAPI_CALL CmdResetEvent(VkCommandBuffer commandBuffer, VkEvent ValidateStageMaskGsTsEnables(dev_data, stageMask, "vkCmdResetEvent()", VALIDATION_ERROR_00240, VALIDATION_ERROR_00241); auto event_state = GetEventNode(dev_data, event); if (event_state) { - addCommandBufferBinding(&event_state->cb_bindings, - {reinterpret_cast<uint64_t &>(event), kVulkanObjectTypeEvent}, pCB); + addCommandBufferBinding(&event_state->cb_bindings, {HandleToUint64(event), kVulkanObjectTypeEvent}, pCB); event_state->cb_bindings.insert(pCB); } pCB->events.push_back(event); @@ -7708,7 +7697,7 @@ static bool ValidateBarriers(const char *funcName, VkCommandBuffer cmdBuffer, ui if (pCB->activeRenderPass && memBarrierCount) { if (!pCB->activeRenderPass->hasSelfDependency[pCB->activeSubpass]) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(cmdBuffer), __LINE__, DRAWSTATE_INVALID_BARRIER, "DS", + HandleToUint64(cmdBuffer), __LINE__, DRAWSTATE_INVALID_BARRIER, "DS", "%s: Barriers cannot be set during subpass %d " "with no self dependency specified.", funcName, pCB->activeSubpass); @@ -7725,13 +7714,12 @@ static bool ValidateBarriers(const char *funcName, VkCommandBuffer cmdBuffer, ui // be VK_QUEUE_FAMILY_IGNORED if ((src_q_f_index != VK_QUEUE_FAMILY_IGNORED) || (dst_q_f_index != VK_QUEUE_FAMILY_IGNORED)) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, - VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, reinterpret_cast<uint64_t>(cmdBuffer), __LINE__, - DRAWSTATE_INVALID_QUEUE_INDEX, "DS", - "%s: Image Barrier for image 0x%" PRIx64 - " was created with sharingMode of " - "VK_SHARING_MODE_CONCURRENT. Src and dst " - "queueFamilyIndices must be VK_QUEUE_FAMILY_IGNORED.", - funcName, reinterpret_cast<const uint64_t &>(mem_barrier->image)); + VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, HandleToUint64(cmdBuffer), __LINE__, + DRAWSTATE_INVALID_QUEUE_INDEX, "DS", "%s: Image Barrier for image 0x%" PRIx64 + " was created with sharingMode of " + "VK_SHARING_MODE_CONCURRENT. Src and dst " + "queueFamilyIndices must be VK_QUEUE_FAMILY_IGNORED.", + funcName, HandleToUint64(mem_barrier->image)); } } else { // Sharing mode is VK_SHARING_MODE_EXCLUSIVE. srcQueueFamilyIndex and @@ -7740,26 +7728,25 @@ static bool ValidateBarriers(const char *funcName, VkCommandBuffer cmdBuffer, ui if (((src_q_f_index == VK_QUEUE_FAMILY_IGNORED) || (dst_q_f_index == VK_QUEUE_FAMILY_IGNORED)) && (src_q_f_index != dst_q_f_index)) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, - VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, reinterpret_cast<uint64_t>(cmdBuffer), __LINE__, - DRAWSTATE_INVALID_QUEUE_INDEX, "DS", - "%s: Image 0x%" PRIx64 - " was created with sharingMode " - "of VK_SHARING_MODE_EXCLUSIVE. If one of src- or " - "dstQueueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, both " - "must be.", - funcName, reinterpret_cast<const uint64_t &>(mem_barrier->image)); + VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, HandleToUint64(cmdBuffer), __LINE__, + DRAWSTATE_INVALID_QUEUE_INDEX, "DS", "%s: Image 0x%" PRIx64 + " was created with sharingMode " + "of VK_SHARING_MODE_EXCLUSIVE. If one of src- or " + "dstQueueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, both " + "must be.", + funcName, HandleToUint64(mem_barrier->image)); } else if (((src_q_f_index != VK_QUEUE_FAMILY_IGNORED) && (dst_q_f_index != VK_QUEUE_FAMILY_IGNORED)) && ((src_q_f_index >= dev_data->phys_dev_properties.queue_family_properties.size()) || (dst_q_f_index >= dev_data->phys_dev_properties.queue_family_properties.size()))) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, - VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, reinterpret_cast<uint64_t>(cmdBuffer), __LINE__, + VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, HandleToUint64(cmdBuffer), __LINE__, DRAWSTATE_INVALID_QUEUE_INDEX, "DS", "%s: Image 0x%" PRIx64 " was created with sharingMode " "of VK_SHARING_MODE_EXCLUSIVE, but srcQueueFamilyIndex %d" " or dstQueueFamilyIndex %d is greater than " PRINTF_SIZE_T_SPECIFIER "queueFamilies crated for this device.", - funcName, reinterpret_cast<const uint64_t &>(mem_barrier->image), src_q_f_index, dst_q_f_index, + funcName, HandleToUint64(mem_barrier->image), src_q_f_index, dst_q_f_index, dev_data->phys_dev_properties.queue_family_properties.size()); } } @@ -7767,21 +7754,21 @@ static bool ValidateBarriers(const char *funcName, VkCommandBuffer cmdBuffer, ui if (mem_barrier->oldLayout != mem_barrier->newLayout) { if (pCB->activeRenderPass) { - skip |= log_msg( - dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(cmdBuffer), __LINE__, VALIDATION_ERROR_02080, "DS", - "%s: As the Image Barrier for image 0x%" PRIx64 - " is being executed within a render pass instance, oldLayout must equal newLayout yet they are " - "%s and %s. %s", - funcName, reinterpret_cast<const uint64_t &>(mem_barrier->image), string_VkImageLayout(mem_barrier->oldLayout), - string_VkImageLayout(mem_barrier->newLayout), validation_error_map[VALIDATION_ERROR_02080]); + skip |= + log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, + HandleToUint64(cmdBuffer), __LINE__, VALIDATION_ERROR_02080, "DS", + "%s: As the Image Barrier for image 0x%" PRIx64 + " is being executed within a render pass instance, oldLayout must equal newLayout yet they are " + "%s and %s. %s", + funcName, HandleToUint64(mem_barrier->image), string_VkImageLayout(mem_barrier->oldLayout), + string_VkImageLayout(mem_barrier->newLayout), validation_error_map[VALIDATION_ERROR_02080]); } skip |= ValidateMaskBitsFromLayouts(dev_data, cmdBuffer, mem_barrier->srcAccessMask, mem_barrier->oldLayout, "Source"); skip |= ValidateMaskBitsFromLayouts(dev_data, cmdBuffer, mem_barrier->dstAccessMask, mem_barrier->newLayout, "Dest"); } if (mem_barrier->newLayout == VK_IMAGE_LAYOUT_UNDEFINED || mem_barrier->newLayout == VK_IMAGE_LAYOUT_PREINITIALIZED) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(cmdBuffer), __LINE__, DRAWSTATE_INVALID_BARRIER, "DS", + HandleToUint64(cmdBuffer), __LINE__, DRAWSTATE_INVALID_BARRIER, "DS", "%s: Image Layout cannot be transitioned to UNDEFINED or " "PREINITIALIZED.", funcName); @@ -7795,7 +7782,7 @@ static bool ValidateBarriers(const char *funcName, VkCommandBuffer cmdBuffer, ui if ((mem_barrier->subresourceRange.baseArrayLayer + layer_count) > image_data->createInfo.arrayLayers) { skip |= log_msg( dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(cmdBuffer), __LINE__, DRAWSTATE_INVALID_BARRIER, "DS", + HandleToUint64(cmdBuffer), __LINE__, DRAWSTATE_INVALID_BARRIER, "DS", "%s: Subresource must have the sum of the baseArrayLayer (%d) and layerCount (%d) be less " "than or equal to the total number of layers (%d).", funcName, mem_barrier->subresourceRange.baseArrayLayer, layer_count, image_data->createInfo.arrayLayers); @@ -7805,7 +7792,7 @@ static bool ValidateBarriers(const char *funcName, VkCommandBuffer cmdBuffer, ui if ((mem_barrier->subresourceRange.baseMipLevel + level_count) > image_data->createInfo.mipLevels) { skip |= log_msg( dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(cmdBuffer), __LINE__, DRAWSTATE_INVALID_BARRIER, "DS", + HandleToUint64(cmdBuffer), __LINE__, DRAWSTATE_INVALID_BARRIER, "DS", "%s: Subresource must have the sum of the baseMipLevel (%d) and levelCount (%d) be less than or equal to " "the total number of levels (%d).", funcName, mem_barrier->subresourceRange.baseMipLevel, level_count, image_data->createInfo.mipLevels); @@ -7817,7 +7804,7 @@ static bool ValidateBarriers(const char *funcName, VkCommandBuffer cmdBuffer, ui auto mem_barrier = &pBufferMemBarriers[i]; if (pCB->activeRenderPass) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(cmdBuffer), __LINE__, DRAWSTATE_INVALID_BARRIER, "DS", + HandleToUint64(cmdBuffer), __LINE__, DRAWSTATE_INVALID_BARRIER, "DS", "%s: Buffer Barriers cannot be used during a render pass.", funcName); } if (!mem_barrier) continue; @@ -7828,11 +7815,11 @@ static bool ValidateBarriers(const char *funcName, VkCommandBuffer cmdBuffer, ui (mem_barrier->dstQueueFamilyIndex != VK_QUEUE_FAMILY_IGNORED && mem_barrier->dstQueueFamilyIndex >= dev_data->phys_dev_properties.queue_family_properties.size())) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(cmdBuffer), __LINE__, DRAWSTATE_INVALID_QUEUE_INDEX, "DS", + HandleToUint64(cmdBuffer), __LINE__, DRAWSTATE_INVALID_QUEUE_INDEX, "DS", "%s: Buffer Barrier 0x%" PRIx64 " has QueueFamilyIndex greater " "than the number of QueueFamilies (" PRINTF_SIZE_T_SPECIFIER ") for this device.", - funcName, reinterpret_cast<const uint64_t &>(mem_barrier->buffer), + funcName, HandleToUint64(mem_barrier->buffer), dev_data->phys_dev_properties.queue_family_properties.size()); } @@ -7840,21 +7827,20 @@ static bool ValidateBarriers(const char *funcName, VkCommandBuffer cmdBuffer, ui if (buffer_state) { auto buffer_size = buffer_state->requirements.size; if (mem_barrier->offset >= buffer_size) { - skip |= log_msg( - dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(cmdBuffer), __LINE__, DRAWSTATE_INVALID_BARRIER, "DS", - "%s: Buffer Barrier 0x%" PRIx64 " has offset 0x%" PRIx64 " which is not less than total size 0x%" PRIx64 ".", - funcName, reinterpret_cast<const uint64_t &>(mem_barrier->buffer), - reinterpret_cast<const uint64_t &>(mem_barrier->offset), reinterpret_cast<const uint64_t &>(buffer_size)); + skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, + VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, HandleToUint64(cmdBuffer), __LINE__, + DRAWSTATE_INVALID_BARRIER, "DS", "%s: Buffer Barrier 0x%" PRIx64 " has offset 0x%" PRIx64 + " which is not less than total size 0x%" PRIx64 ".", + funcName, HandleToUint64(mem_barrier->buffer), HandleToUint64(mem_barrier->offset), + HandleToUint64(buffer_size)); } else if (mem_barrier->size != VK_WHOLE_SIZE && (mem_barrier->offset + mem_barrier->size > buffer_size)) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(cmdBuffer), __LINE__, DRAWSTATE_INVALID_BARRIER, "DS", + HandleToUint64(cmdBuffer), __LINE__, DRAWSTATE_INVALID_BARRIER, "DS", "%s: Buffer Barrier 0x%" PRIx64 " has offset 0x%" PRIx64 " and size 0x%" PRIx64 " whose sum is greater than total size 0x%" PRIx64 ".", - funcName, reinterpret_cast<const uint64_t &>(mem_barrier->buffer), - reinterpret_cast<const uint64_t &>(mem_barrier->offset), - reinterpret_cast<const uint64_t &>(mem_barrier->size), reinterpret_cast<const uint64_t &>(buffer_size)); + funcName, HandleToUint64(mem_barrier->buffer), HandleToUint64(mem_barrier->offset), + HandleToUint64(mem_barrier->size), HandleToUint64(buffer_size)); } } } @@ -7877,9 +7863,8 @@ bool validateEventStageMask(VkQueue queue, GLOBAL_CB_NODE *pCB, uint32_t eventCo auto global_event_data = GetEventNode(dev_data, event); if (!global_event_data) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_EVENT_EXT, - reinterpret_cast<const uint64_t &>(event), __LINE__, DRAWSTATE_INVALID_EVENT, "DS", - "Event 0x%" PRIx64 " cannot be waited on if it has never been set.", - reinterpret_cast<const uint64_t &>(event)); + HandleToUint64(event), __LINE__, DRAWSTATE_INVALID_EVENT, "DS", + "Event 0x%" PRIx64 " cannot be waited on if it has never been set.", HandleToUint64(event)); } else { stageMask |= global_event_data->stageMask; } @@ -7889,7 +7874,7 @@ bool validateEventStageMask(VkQueue queue, GLOBAL_CB_NODE *pCB, uint32_t eventCo // but set event can be called at any time. if (sourceStageMask != stageMask && sourceStageMask != (stageMask | VK_PIPELINE_STAGE_HOST_BIT)) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(pCB->commandBuffer), __LINE__, VALIDATION_ERROR_00254, "DS", + HandleToUint64(pCB->commandBuffer), __LINE__, VALIDATION_ERROR_00254, "DS", "Submitting cmdbuffer with call to VkCmdWaitEvents " "using srcStageMask 0x%X which must be the bitwise " "OR of the stageMask parameters used in calls to " @@ -7942,7 +7927,7 @@ bool CheckStageMaskQueueCompatibility(layer_data *dev_data, VkCommandBuffer comm if ((supported_pipeline_stages_table[item] & queue_flags) == 0) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t &>(command_buffer), __LINE__, error_code, "DL", + HandleToUint64(command_buffer), __LINE__, error_code, "DL", "%s(): %s flag %s is not compatible with the queue family properties of this " "command buffer. %s", function, src_or_dest, string_VkPipelineStageFlagBits(static_cast<VkPipelineStageFlagBits>(item)), @@ -8000,9 +7985,7 @@ VKAPI_ATTR void VKAPI_CALL CmdWaitEvents(VkCommandBuffer commandBuffer, uint32_t for (uint32_t i = 0; i < eventCount; ++i) { auto event_state = GetEventNode(dev_data, pEvents[i]); if (event_state) { - addCommandBufferBinding(&event_state->cb_bindings, - {reinterpret_cast<const uint64_t &>(pEvents[i]), kVulkanObjectTypeEvent}, - cb_state); + addCommandBufferBinding(&event_state->cb_bindings, {HandleToUint64(pEvents[i]), kVulkanObjectTypeEvent}, cb_state); event_state->cb_bindings.insert(cb_state); } cb_state->waitedEvents.insert(pEvents[i]); @@ -8115,7 +8098,7 @@ VKAPI_ATTR void VKAPI_CALL CmdBeginQuery(VkCommandBuffer commandBuffer, VkQueryP skip |= ValidateCmd(dev_data, pCB, CMD_BEGINQUERY, "vkCmdBeginQuery()"); UpdateCmdBufferLastCmd(pCB, CMD_BEGINQUERY); addCommandBufferBinding(&GetQueryPoolNode(dev_data, queryPool)->cb_bindings, - {reinterpret_cast<uint64_t &>(queryPool), kVulkanObjectTypeQueryPool}, pCB); + {HandleToUint64(queryPool), kVulkanObjectTypeQueryPool}, pCB); } lock.unlock(); if (!skip) dev_data->dispatch_table.CmdBeginQuery(commandBuffer, queryPool, slot, flags); @@ -8130,9 +8113,9 @@ VKAPI_ATTR void VKAPI_CALL CmdEndQuery(VkCommandBuffer commandBuffer, VkQueryPoo QueryObject query = {queryPool, slot}; if (!cb_state->activeQueries.count(query)) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(commandBuffer), __LINE__, VALIDATION_ERROR_01041, "DS", - "Ending a query before it was started: queryPool 0x%" PRIx64 ", index %d. %s", (uint64_t)(queryPool), - slot, validation_error_map[VALIDATION_ERROR_01041]); + HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_01041, "DS", + "Ending a query before it was started: queryPool 0x%" PRIx64 ", index %d. %s", + HandleToUint64(queryPool), slot, validation_error_map[VALIDATION_ERROR_01041]); } else { cb_state->activeQueries.erase(query); } @@ -8143,7 +8126,7 @@ VKAPI_ATTR void VKAPI_CALL CmdEndQuery(VkCommandBuffer commandBuffer, VkQueryPoo skip |= ValidateCmd(dev_data, cb_state, CMD_ENDQUERY, "VkCmdEndQuery()"); UpdateCmdBufferLastCmd(cb_state, CMD_ENDQUERY); addCommandBufferBinding(&GetQueryPoolNode(dev_data, queryPool)->cb_bindings, - {reinterpret_cast<uint64_t &>(queryPool), kVulkanObjectTypeQueryPool}, cb_state); + {HandleToUint64(queryPool), kVulkanObjectTypeQueryPool}, cb_state); } lock.unlock(); if (!skip) dev_data->dispatch_table.CmdEndQuery(commandBuffer, queryPool, slot); @@ -8169,7 +8152,7 @@ VKAPI_ATTR void VKAPI_CALL CmdResetQueryPool(VkCommandBuffer commandBuffer, VkQu UpdateCmdBufferLastCmd(cb_state, CMD_RESETQUERYPOOL); skip |= insideRenderPass(dev_data, cb_state, "vkCmdResetQueryPool()", VALIDATION_ERROR_01025); addCommandBufferBinding(&GetQueryPoolNode(dev_data, queryPool)->cb_bindings, - {reinterpret_cast<uint64_t &>(queryPool), kVulkanObjectTypeQueryPool}, cb_state); + {HandleToUint64(queryPool), kVulkanObjectTypeQueryPool}, cb_state); } lock.unlock(); if (!skip) dev_data->dispatch_table.CmdResetQueryPool(commandBuffer, queryPool, firstQuery, queryCount); @@ -8200,9 +8183,9 @@ bool validateQuery(VkQueue queue, GLOBAL_CB_NODE *pCB, VkQueryPool queryPool, ui } if (fail) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(pCB->commandBuffer), __LINE__, DRAWSTATE_INVALID_QUERY, "DS", + HandleToUint64(pCB->commandBuffer), __LINE__, DRAWSTATE_INVALID_QUERY, "DS", "Requesting a copy from query to buffer with invalid query: queryPool 0x%" PRIx64 ", index %d", - reinterpret_cast<uint64_t &>(queryPool), firstQuery + i); + HandleToUint64(queryPool), firstQuery + i); } } return skip; @@ -8238,7 +8221,7 @@ VKAPI_ATTR void VKAPI_CALL CmdCopyQueryPoolResults(VkCommandBuffer commandBuffer UpdateCmdBufferLastCmd(cb_node, CMD_COPYQUERYPOOLRESULTS); skip |= insideRenderPass(dev_data, cb_node, "vkCmdCopyQueryPoolResults()", VALIDATION_ERROR_01074); addCommandBufferBinding(&GetQueryPoolNode(dev_data, queryPool)->cb_bindings, - {reinterpret_cast<uint64_t &>(queryPool), kVulkanObjectTypeQueryPool}, cb_node); + {HandleToUint64(queryPool), kVulkanObjectTypeQueryPool}, cb_node); } else { assert(0); } @@ -8263,7 +8246,7 @@ VKAPI_ATTR void VKAPI_CALL CmdPushConstants(VkCommandBuffer commandBuffer, VkPip skip |= validatePushConstantRange(dev_data, offset, size, "vkCmdPushConstants()"); if (0 == stageFlags) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(commandBuffer), __LINE__, VALIDATION_ERROR_00996, "DS", + HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_00996, "DS", "vkCmdPushConstants() call has no stageFlags set. %s", validation_error_map[VALIDATION_ERROR_00996]); } @@ -8281,12 +8264,13 @@ VKAPI_ATTR void VKAPI_CALL CmdPushConstants(VkCommandBuffer commandBuffer, VkPip } } if (!found_matching_range) { - skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(commandBuffer), __LINE__, VALIDATION_ERROR_00988, "DS", - "vkCmdPushConstants() stageFlags = 0x%" PRIx32 - " do not match the stageFlags in any of the ranges with" - " offset = %d and size = %d in pipeline layout 0x%" PRIx64 ". %s", - (uint32_t)stageFlags, offset, size, (uint64_t)layout, validation_error_map[VALIDATION_ERROR_00988]); + skip |= + log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, + HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_00988, "DS", + "vkCmdPushConstants() stageFlags = 0x%" PRIx32 + " do not match the stageFlags in any of the ranges with" + " offset = %d and size = %d in pipeline layout 0x%" PRIx64 ". %s", + (uint32_t)stageFlags, offset, size, HandleToUint64(layout), validation_error_map[VALIDATION_ERROR_00988]); } } lock.unlock(); @@ -8360,10 +8344,10 @@ static bool ValidateFramebufferCreateInfo(layer_data *dev_data, const VkFramebuf if (rpci->attachmentCount != pCreateInfo->attachmentCount) { skip |= log_msg( dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_RENDER_PASS_EXT, - reinterpret_cast<const uint64_t &>(pCreateInfo->renderPass), __LINE__, VALIDATION_ERROR_00404, "DS", + HandleToUint64(pCreateInfo->renderPass), __LINE__, VALIDATION_ERROR_00404, "DS", "vkCreateFramebuffer(): VkFramebufferCreateInfo attachmentCount of %u does not match attachmentCount of %u of " "renderPass (0x%" PRIxLEAST64 ") being used to create Framebuffer. %s", - pCreateInfo->attachmentCount, rpci->attachmentCount, reinterpret_cast<const uint64_t &>(pCreateInfo->renderPass), + pCreateInfo->attachmentCount, rpci->attachmentCount, HandleToUint64(pCreateInfo->renderPass), validation_error_map[VALIDATION_ERROR_00404]); } else { // attachmentCounts match, so make sure corresponding attachment details line up @@ -8374,22 +8358,22 @@ static bool ValidateFramebufferCreateInfo(layer_data *dev_data, const VkFramebuf if (ivci.format != rpci->pAttachments[i].format) { skip |= log_msg( dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_RENDER_PASS_EXT, - reinterpret_cast<const uint64_t &>(pCreateInfo->renderPass), __LINE__, VALIDATION_ERROR_00408, "DS", + HandleToUint64(pCreateInfo->renderPass), __LINE__, VALIDATION_ERROR_00408, "DS", "vkCreateFramebuffer(): VkFramebufferCreateInfo attachment #%u has format of %s that does not match " "the format of " "%s used by the corresponding attachment for renderPass (0x%" PRIxLEAST64 "). %s", i, string_VkFormat(ivci.format), string_VkFormat(rpci->pAttachments[i].format), - reinterpret_cast<const uint64_t &>(pCreateInfo->renderPass), validation_error_map[VALIDATION_ERROR_00408]); + HandleToUint64(pCreateInfo->renderPass), validation_error_map[VALIDATION_ERROR_00408]); } const VkImageCreateInfo *ici = &GetImageState(dev_data, ivci.image)->createInfo; if (ici->samples != rpci->pAttachments[i].samples) { skip |= log_msg( dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_RENDER_PASS_EXT, - reinterpret_cast<const uint64_t &>(pCreateInfo->renderPass), __LINE__, VALIDATION_ERROR_00409, "DS", + HandleToUint64(pCreateInfo->renderPass), __LINE__, VALIDATION_ERROR_00409, "DS", "vkCreateFramebuffer(): VkFramebufferCreateInfo attachment #%u has %s samples that do not match " "the %s samples used by the corresponding attachment for renderPass (0x%" PRIxLEAST64 "). %s", i, string_VkSampleCountFlagBits(ici->samples), string_VkSampleCountFlagBits(rpci->pAttachments[i].samples), - reinterpret_cast<const uint64_t &>(pCreateInfo->renderPass), validation_error_map[VALIDATION_ERROR_00409]); + HandleToUint64(pCreateInfo->renderPass), validation_error_map[VALIDATION_ERROR_00409]); } // Verify that view only has a single mip level if (ivci.subresourceRange.levelCount != 1) { @@ -8693,20 +8677,18 @@ static bool ValidateDependencies(const layer_data *dev_data, FRAMEBUFFER_STATE c uint32_t attachment = i; for (auto other_attachment : overlapping_attachments[i]) { if (!(pCreateInfo->pAttachments[attachment].flags & VK_ATTACHMENT_DESCRIPTION_MAY_ALIAS_BIT)) { - skip |= - log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_FRAMEBUFFER_EXT, - reinterpret_cast<const uint64_t &>(framebuffer->framebuffer), __LINE__, VALIDATION_ERROR_00324, "DS", - "Attachment %d aliases attachment %d but doesn't " - "set VK_ATTACHMENT_DESCRIPTION_MAY_ALIAS_BIT. %s", - attachment, other_attachment, validation_error_map[VALIDATION_ERROR_00324]); + skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_FRAMEBUFFER_EXT, + HandleToUint64(framebuffer->framebuffer), __LINE__, VALIDATION_ERROR_00324, "DS", + "Attachment %d aliases attachment %d but doesn't " + "set VK_ATTACHMENT_DESCRIPTION_MAY_ALIAS_BIT. %s", + attachment, other_attachment, validation_error_map[VALIDATION_ERROR_00324]); } if (!(pCreateInfo->pAttachments[other_attachment].flags & VK_ATTACHMENT_DESCRIPTION_MAY_ALIAS_BIT)) { - skip |= - log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_FRAMEBUFFER_EXT, - reinterpret_cast<const uint64_t &>(framebuffer->framebuffer), __LINE__, VALIDATION_ERROR_00324, "DS", - "Attachment %d aliases attachment %d but doesn't " - "set VK_ATTACHMENT_DESCRIPTION_MAY_ALIAS_BIT. %s", - other_attachment, attachment, validation_error_map[VALIDATION_ERROR_00324]); + skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_FRAMEBUFFER_EXT, + HandleToUint64(framebuffer->framebuffer), __LINE__, VALIDATION_ERROR_00324, "DS", + "Attachment %d aliases attachment %d but doesn't " + "set VK_ATTACHMENT_DESCRIPTION_MAY_ALIAS_BIT. %s", + other_attachment, attachment, validation_error_map[VALIDATION_ERROR_00324]); } } } @@ -9069,9 +9051,8 @@ static bool validatePrimaryCommandBuffer(const layer_data *dev_data, const GLOBA bool skip = false; if (pCB->createInfo.level != VK_COMMAND_BUFFER_LEVEL_PRIMARY) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(pCB->commandBuffer), __LINE__, error_code, "DS", - "Cannot execute command %s on a secondary command buffer. %s", cmd_name, - validation_error_map[error_code]); + HandleToUint64(pCB->commandBuffer), __LINE__, error_code, "DS", + "Cannot execute command %s on a secondary command buffer. %s", cmd_name, validation_error_map[error_code]); } return skip; } @@ -9160,25 +9141,24 @@ VKAPI_ATTR void VKAPI_CALL CmdBeginRenderPass(VkCommandBuffer commandBuffer, con if (clear_op_size > pRenderPassBegin->clearValueCount) { skip |= log_msg( dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_RENDER_PASS_EXT, - reinterpret_cast<uint64_t &>(render_pass_state->renderPass), __LINE__, VALIDATION_ERROR_00442, "DS", + HandleToUint64(render_pass_state->renderPass), __LINE__, VALIDATION_ERROR_00442, "DS", "In vkCmdBeginRenderPass() the VkRenderPassBeginInfo struct has a clearValueCount of %u but there must " "be at least %u entries in pClearValues array to account for the highest index attachment in renderPass " "0x%" PRIx64 " that uses VK_ATTACHMENT_LOAD_OP_CLEAR is %u. Note that the pClearValues array " "is indexed by attachment number so even if some pClearValues entries between 0 and %u correspond to " "attachments that aren't cleared they will be ignored. %s", - pRenderPassBegin->clearValueCount, clear_op_size, reinterpret_cast<uint64_t &>(render_pass_state->renderPass), - clear_op_size, clear_op_size - 1, validation_error_map[VALIDATION_ERROR_00442]); + pRenderPassBegin->clearValueCount, clear_op_size, HandleToUint64(render_pass_state->renderPass), clear_op_size, + clear_op_size - 1, validation_error_map[VALIDATION_ERROR_00442]); } if (clear_op_size < pRenderPassBegin->clearValueCount) { skip |= log_msg( dev_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_RENDER_PASS_EXT, - reinterpret_cast<uint64_t &>(render_pass_state->renderPass), __LINE__, - DRAWSTATE_RENDERPASS_TOO_MANY_CLEAR_VALUES, "DS", + HandleToUint64(render_pass_state->renderPass), __LINE__, DRAWSTATE_RENDERPASS_TOO_MANY_CLEAR_VALUES, "DS", "In vkCmdBeginRenderPass() the VkRenderPassBeginInfo struct has a clearValueCount of %u but only first %u " "entries in pClearValues array are used. The highest index of any attachment in renderPass 0x%" PRIx64 " that uses VK_ATTACHMENT_LOAD_OP_CLEAR is %u - other pClearValues are ignored.", - pRenderPassBegin->clearValueCount, clear_op_size, reinterpret_cast<uint64_t &>(render_pass_state->renderPass), + pRenderPassBegin->clearValueCount, clear_op_size, HandleToUint64(render_pass_state->renderPass), clear_op_size - 1); } skip |= VerifyRenderAreaBounds(dev_data, pRenderPassBegin); @@ -9224,7 +9204,7 @@ VKAPI_ATTR void VKAPI_CALL CmdNextSubpass(VkCommandBuffer commandBuffer, VkSubpa auto subpassCount = pCB->activeRenderPass->createInfo.subpassCount; if (pCB->activeSubpass == subpassCount - 1) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(commandBuffer), __LINE__, VALIDATION_ERROR_00453, "DS", + HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_00453, "DS", "vkCmdNextSubpass(): Attempted to advance beyond final subpass. %s", validation_error_map[VALIDATION_ERROR_00453]); } @@ -9256,7 +9236,7 @@ VKAPI_ATTR void VKAPI_CALL CmdEndRenderPass(VkCommandBuffer commandBuffer) { if (rp_state) { if (pCB->activeSubpass != rp_state->createInfo.subpassCount - 1) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, - VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, reinterpret_cast<uint64_t>(commandBuffer), __LINE__, + VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_00460, "DS", "vkCmdEndRenderPass(): Called before reaching final subpass. %s", validation_error_map[VALIDATION_ERROR_00460]); } @@ -9305,12 +9285,12 @@ VKAPI_ATTR void VKAPI_CALL CmdEndRenderPass(VkCommandBuffer commandBuffer) { static bool logInvalidAttachmentMessage(layer_data *dev_data, VkCommandBuffer secondaryBuffer, uint32_t primaryAttach, uint32_t secondaryAttach, const char *msg) { return log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(secondaryBuffer), __LINE__, VALIDATION_ERROR_02059, "DS", + HandleToUint64(secondaryBuffer), __LINE__, VALIDATION_ERROR_02059, "DS", "vkCmdExecuteCommands() called w/ invalid Secondary Cmd Buffer 0x%" PRIx64 " which has a render pass " "that is not compatible with the Primary Cmd Buffer current render pass. " "Attachment %u is not compatible with %u: %s. %s", - reinterpret_cast<uint64_t &>(secondaryBuffer), primaryAttach, secondaryAttach, msg, + HandleToUint64(secondaryBuffer), primaryAttach, secondaryAttach, msg, validation_error_map[VALIDATION_ERROR_02059]); } @@ -9414,12 +9394,12 @@ static bool validateRenderPassCompatibility(layer_data *dev_data, VkCommandBuffe if (primaryPassCI->subpassCount != secondaryPassCI->subpassCount) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(primaryBuffer), __LINE__, DRAWSTATE_INVALID_SECONDARY_COMMAND_BUFFER, "DS", + HandleToUint64(primaryBuffer), __LINE__, DRAWSTATE_INVALID_SECONDARY_COMMAND_BUFFER, "DS", "vkCmdExecuteCommands() called w/ invalid secondary Cmd Buffer 0x%" PRIx64 " that has a subpassCount of %u that is incompatible with the primary Cmd Buffer 0x%" PRIx64 " that has a subpassCount of %u.", - reinterpret_cast<uint64_t &>(secondaryBuffer), secondaryPassCI->subpassCount, - reinterpret_cast<uint64_t &>(primaryBuffer), primaryPassCI->subpassCount); + HandleToUint64(secondaryBuffer), secondaryPassCI->subpassCount, HandleToUint64(primaryBuffer), + primaryPassCI->subpassCount); } else { for (uint32_t i = 0; i < primaryPassCI->subpassCount; ++i) { skip |= validateSubpassCompatibility(dev_data, primaryBuffer, primaryPassCI, secondaryBuffer, secondaryPassCI, i, @@ -9440,20 +9420,20 @@ static bool validateFramebuffer(layer_data *dev_data, VkCommandBuffer primaryBuf if (secondary_fb != VK_NULL_HANDLE) { if (primary_fb != secondary_fb) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(primaryBuffer), __LINE__, VALIDATION_ERROR_02060, "DS", + HandleToUint64(primaryBuffer), __LINE__, VALIDATION_ERROR_02060, "DS", "vkCmdExecuteCommands() called w/ invalid secondary command buffer 0x%" PRIx64 " which has a framebuffer 0x%" PRIx64 " that is not the same as the primary command buffer's current active framebuffer 0x%" PRIx64 ". %s", - reinterpret_cast<uint64_t &>(secondaryBuffer), reinterpret_cast<uint64_t &>(secondary_fb), - reinterpret_cast<uint64_t &>(primary_fb), validation_error_map[VALIDATION_ERROR_02060]); + HandleToUint64(secondaryBuffer), HandleToUint64(secondary_fb), HandleToUint64(primary_fb), + validation_error_map[VALIDATION_ERROR_02060]); } auto fb = GetFramebufferState(dev_data, secondary_fb); if (!fb) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(primaryBuffer), __LINE__, DRAWSTATE_INVALID_SECONDARY_COMMAND_BUFFER, "DS", + HandleToUint64(primaryBuffer), __LINE__, DRAWSTATE_INVALID_SECONDARY_COMMAND_BUFFER, "DS", "vkCmdExecuteCommands() called w/ invalid Cmd Buffer 0x%p " "which has invalid framebuffer 0x%" PRIx64 ".", - (void *)secondaryBuffer, (uint64_t)(secondary_fb)); + (void *)secondaryBuffer, HandleToUint64(secondary_fb)); return skip; } auto cb_renderpass = GetRenderPassState(dev_data, pSubCB->beginInfo.pInheritanceInfo->renderPass); @@ -9475,15 +9455,14 @@ static bool validateSecondaryCommandBufferState(layer_data *dev_data, GLOBAL_CB_ pSubCB->beginInfo.pInheritanceInfo) { VkQueryPipelineStatisticFlags cmdBufStatistics = pSubCB->beginInfo.pInheritanceInfo->pipelineStatistics; if ((cmdBufStatistics & queryPoolData->second.createInfo.pipelineStatistics) != cmdBufStatistics) { - skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, - VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, reinterpret_cast<uint64_t>(pCB->commandBuffer), - __LINE__, VALIDATION_ERROR_02065, "DS", - "vkCmdExecuteCommands() called w/ invalid Cmd Buffer 0x%p " - "which has invalid active query pool 0x%" PRIx64 - ". Pipeline statistics is being queried so the command " - "buffer must have all bits set on the queryPool. %s", - pCB->commandBuffer, reinterpret_cast<const uint64_t &>(queryPoolData->first), - validation_error_map[VALIDATION_ERROR_02065]); + skip |= log_msg( + dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, + HandleToUint64(pCB->commandBuffer), __LINE__, VALIDATION_ERROR_02065, "DS", + "vkCmdExecuteCommands() called w/ invalid Cmd Buffer 0x%p " + "which has invalid active query pool 0x%" PRIx64 + ". Pipeline statistics is being queried so the command " + "buffer must have all bits set on the queryPool. %s", + pCB->commandBuffer, HandleToUint64(queryPoolData->first), validation_error_map[VALIDATION_ERROR_02065]); } } activeTypes.insert(queryPoolData->second.createInfo.queryType); @@ -9492,15 +9471,14 @@ static bool validateSecondaryCommandBufferState(layer_data *dev_data, GLOBAL_CB_ for (auto queryObject : pSubCB->startedQueries) { auto queryPoolData = dev_data->queryPoolMap.find(queryObject.pool); if (queryPoolData != dev_data->queryPoolMap.end() && activeTypes.count(queryPoolData->second.createInfo.queryType)) { - skip |= - log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(pCB->commandBuffer), __LINE__, DRAWSTATE_INVALID_SECONDARY_COMMAND_BUFFER, "DS", - "vkCmdExecuteCommands() called w/ invalid Cmd Buffer 0x%p " - "which has invalid active query pool 0x%" PRIx64 - "of type %d but a query of that type has been started on " - "secondary Cmd Buffer 0x%p.", - pCB->commandBuffer, reinterpret_cast<const uint64_t &>(queryPoolData->first), - queryPoolData->second.createInfo.queryType, pSubCB->commandBuffer); + skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, + HandleToUint64(pCB->commandBuffer), __LINE__, DRAWSTATE_INVALID_SECONDARY_COMMAND_BUFFER, "DS", + "vkCmdExecuteCommands() called w/ invalid Cmd Buffer 0x%p " + "which has invalid active query pool 0x%" PRIx64 + "of type %d but a query of that type has been started on " + "secondary Cmd Buffer 0x%p.", + pCB->commandBuffer, HandleToUint64(queryPoolData->first), queryPoolData->second.createInfo.queryType, + pSubCB->commandBuffer); } } @@ -9509,7 +9487,7 @@ static bool validateSecondaryCommandBufferState(layer_data *dev_data, GLOBAL_CB_ if (primary_pool && secondary_pool && (primary_pool->queueFamilyIndex != secondary_pool->queueFamilyIndex)) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(pSubCB->commandBuffer), __LINE__, DRAWSTATE_INVALID_QUEUE_FAMILY, "DS", + HandleToUint64(pSubCB->commandBuffer), __LINE__, DRAWSTATE_INVALID_QUEUE_FAMILY, "DS", "vkCmdExecuteCommands(): Primary command buffer 0x%p" " created in queue family %d has secondary command buffer 0x%p created in queue family %d.", pCB->commandBuffer, primary_pool->queueFamilyIndex, pSubCB->commandBuffer, secondary_pool->queueFamilyIndex); @@ -9532,7 +9510,7 @@ VKAPI_ATTR void VKAPI_CALL CmdExecuteCommands(VkCommandBuffer commandBuffer, uin if (VK_COMMAND_BUFFER_LEVEL_PRIMARY == pSubCB->createInfo.level) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(pCommandBuffers[i]), __LINE__, VALIDATION_ERROR_00156, "DS", + HandleToUint64(pCommandBuffers[i]), __LINE__, VALIDATION_ERROR_00156, "DS", "vkCmdExecuteCommands() called w/ Primary Cmd Buffer 0x%p in element %u of pCommandBuffers " "array. All cmd buffers in pCommandBuffers array must be secondary. %s", pCommandBuffers[i], i, validation_error_map[VALIDATION_ERROR_00156]); @@ -9541,10 +9519,10 @@ VKAPI_ATTR void VKAPI_CALL CmdExecuteCommands(VkCommandBuffer commandBuffer, uin if (!(pSubCB->beginInfo.flags & VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT)) { skip |= log_msg( dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(pCommandBuffers[i]), __LINE__, VALIDATION_ERROR_02057, "DS", + HandleToUint64(pCommandBuffers[i]), __LINE__, VALIDATION_ERROR_02057, "DS", "vkCmdExecuteCommands(): Secondary Command Buffer (0x%p) executed within render pass (0x%" PRIxLEAST64 ") must have had vkBeginCommandBuffer() called w/ VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT set. %s", - pCommandBuffers[i], (uint64_t)pCB->activeRenderPass->renderPass, + pCommandBuffers[i], HandleToUint64(pCB->activeRenderPass->renderPass), validation_error_map[VALIDATION_ERROR_02057]); } else { // Make sure render pass is compatible with parent command buffer pass if has continue @@ -9562,11 +9540,11 @@ VKAPI_ATTR void VKAPI_CALL CmdExecuteCommands(VkCommandBuffer commandBuffer, uin secondary_rp_state->createInfo.ptr(), errorString)) { skip |= log_msg( dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(pCommandBuffers[i]), __LINE__, DRAWSTATE_RENDERPASS_INCOMPATIBLE, "DS", + HandleToUint64(pCommandBuffers[i]), __LINE__, DRAWSTATE_RENDERPASS_INCOMPATIBLE, "DS", "vkCmdExecuteCommands(): Secondary Command Buffer (0x%p) w/ render pass (0x%" PRIxLEAST64 ") is incompatible w/ primary command buffer (0x%p) w/ render pass (0x%" PRIxLEAST64 ") due to: %s", - pCommandBuffers[i], (uint64_t)pSubCB->beginInfo.pInheritanceInfo->renderPass, commandBuffer, - (uint64_t)pCB->activeRenderPass->renderPass, errorString.c_str()); + pCommandBuffers[i], HandleToUint64(pSubCB->beginInfo.pInheritanceInfo->renderPass), commandBuffer, + HandleToUint64(pCB->activeRenderPass->renderPass), errorString.c_str()); } } // TODO(mlentine): Move more logic into this method @@ -9577,8 +9555,8 @@ VKAPI_ATTR void VKAPI_CALL CmdExecuteCommands(VkCommandBuffer commandBuffer, uin if (!(pSubCB->beginInfo.flags & VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT)) { if (dev_data->globalInFlightCmdBuffers.find(pSubCB->commandBuffer) != dev_data->globalInFlightCmdBuffers.end()) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, - VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, reinterpret_cast<uint64_t>(pCB->commandBuffer), - __LINE__, VALIDATION_ERROR_00154, "DS", + VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, HandleToUint64(pCB->commandBuffer), __LINE__, + VALIDATION_ERROR_00154, "DS", "Attempt to simultaneously execute command buffer 0x%p" " without VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT set! %s", pCB->commandBuffer, validation_error_map[VALIDATION_ERROR_00154]); @@ -9587,7 +9565,7 @@ VKAPI_ATTR void VKAPI_CALL CmdExecuteCommands(VkCommandBuffer commandBuffer, uin // Warn that non-simultaneous secondary cmd buffer renders primary non-simultaneous skip |= log_msg( dev_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(pCommandBuffers[i]), __LINE__, DRAWSTATE_INVALID_CB_SIMULTANEOUS_USE, "DS", + HandleToUint64(pCommandBuffers[i]), __LINE__, DRAWSTATE_INVALID_CB_SIMULTANEOUS_USE, "DS", "vkCmdExecuteCommands(): Secondary Command Buffer (0x%p) " "does not have VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT set and will cause primary command buffer " "(0x%p) to be treated as if it does not have VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT " @@ -9599,7 +9577,7 @@ VKAPI_ATTR void VKAPI_CALL CmdExecuteCommands(VkCommandBuffer commandBuffer, uin if (!pCB->activeQueries.empty() && !dev_data->enabled_features.inheritedQueries) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(pCommandBuffers[i]), __LINE__, VALIDATION_ERROR_02062, "DS", + HandleToUint64(pCommandBuffers[i]), __LINE__, VALIDATION_ERROR_02062, "DS", "vkCmdExecuteCommands(): Secondary Command Buffer " "(0x%p) cannot be submitted with a query in " "flight and inherited queries not " @@ -9645,9 +9623,9 @@ VKAPI_ATTR VkResult VKAPI_CALL MapMemory(VkDevice device, VkDeviceMemory mem, Vk if ((dev_data->phys_dev_mem_props.memoryTypes[mem_info->alloc_info.memoryTypeIndex].propertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) == 0) { skip = log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT, - (uint64_t)mem, __LINE__, VALIDATION_ERROR_00629, "MEM", + HandleToUint64(mem), __LINE__, VALIDATION_ERROR_00629, "MEM", "Mapping Memory without VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT set: mem obj 0x%" PRIxLEAST64 ". %s", - (uint64_t)mem, validation_error_map[VALIDATION_ERROR_00629]); + HandleToUint64(mem), validation_error_map[VALIDATION_ERROR_00629]); } } skip |= ValidateMapMemRange(dev_data, mem, offset, size); @@ -9687,7 +9665,7 @@ static bool validateMemoryIsMapped(layer_data *dev_data, const char *funcName, u if (pMemRanges[i].size == VK_WHOLE_SIZE) { if (mem_info->mem_range.offset > pMemRanges[i].offset) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, - VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT, (uint64_t)pMemRanges[i].memory, __LINE__, + VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT, HandleToUint64(pMemRanges[i].memory), __LINE__, VALIDATION_ERROR_00643, "MEM", "%s: Flush/Invalidate offset (" PRINTF_SIZE_T_SPECIFIER ") is less than Memory Object's offset " "(" PRINTF_SIZE_T_SPECIFIER "). %s", @@ -9702,7 +9680,7 @@ static bool validateMemoryIsMapped(layer_data *dev_data, const char *funcName, u (data_end < (pMemRanges[i].offset + pMemRanges[i].size))) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT, - (uint64_t)pMemRanges[i].memory, __LINE__, VALIDATION_ERROR_00642, "MEM", + HandleToUint64(pMemRanges[i].memory), __LINE__, VALIDATION_ERROR_00642, "MEM", "%s: Flush/Invalidate size or offset (" PRINTF_SIZE_T_SPECIFIER ", " PRINTF_SIZE_T_SPECIFIER ") exceed the Memory Object's upper-bound " "(" PRINTF_SIZE_T_SPECIFIER "). %s", @@ -9729,18 +9707,18 @@ static bool ValidateAndCopyNoncoherentMemoryToDriver(layer_data *dev_data, uint3 char *data = static_cast<char *>(mem_info->shadow_copy); for (uint64_t j = 0; j < mem_info->shadow_pad_size; ++j) { if (data[j] != NoncoherentMemoryFillValue) { - skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, - VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT, (uint64_t)mem_ranges[i].memory, __LINE__, - MEMTRACK_INVALID_MAP, "MEM", "Memory underflow was detected on mem obj 0x%" PRIxLEAST64, - (uint64_t)mem_ranges[i].memory); + skip |= log_msg( + dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT, + HandleToUint64(mem_ranges[i].memory), __LINE__, MEMTRACK_INVALID_MAP, "MEM", + "Memory underflow was detected on mem obj 0x%" PRIxLEAST64, HandleToUint64(mem_ranges[i].memory)); } } for (uint64_t j = (size + mem_info->shadow_pad_size); j < (2 * mem_info->shadow_pad_size + size); ++j) { if (data[j] != NoncoherentMemoryFillValue) { - skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, - VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT, (uint64_t)mem_ranges[i].memory, __LINE__, - MEMTRACK_INVALID_MAP, "MEM", "Memory overflow was detected on mem obj 0x%" PRIxLEAST64, - (uint64_t)mem_ranges[i].memory); + skip |= log_msg( + dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT, + HandleToUint64(mem_ranges[i].memory), __LINE__, MEMTRACK_INVALID_MAP, "MEM", + "Memory overflow was detected on mem obj 0x%" PRIxLEAST64, HandleToUint64(mem_ranges[i].memory)); } } memcpy(mem_info->p_driver_data, static_cast<void *>(data + mem_info->shadow_pad_size), (size_t)(size)); @@ -9770,14 +9748,14 @@ static bool ValidateMappedMemoryRangeDeviceLimits(layer_data *dev_data, const ch uint64_t atom_size = dev_data->phys_dev_properties.properties.limits.nonCoherentAtomSize; 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", + HandleToUint64(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) && (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", + HandleToUint64(mem_ranges->memory), __LINE__, VALIDATION_ERROR_00645, "MEM", "%s: Size in pMemRanges[%d] is 0x%" PRIxLEAST64 ", which is not a multiple of VkPhysicalDeviceLimits::nonCoherentAtomSize (0x%" PRIxLEAST64 "). %s", func_name, i, mem_ranges[i].size, atom_size, validation_error_map[VALIDATION_ERROR_00645]); @@ -9841,7 +9819,7 @@ static bool PreCallValidateBindImageMemory(layer_data *dev_data, VkImage image, if (image_state) { std::unique_lock<std::mutex> lock(global_lock); // Track objects tied to memory - uint64_t image_handle = reinterpret_cast<uint64_t &>(image); + uint64_t image_handle = HandleToUint64(image); skip = ValidateSetMemBinding(dev_data, mem, image_handle, kVulkanObjectTypeImage, "vkBindImageMemory()"); if (!image_state->memory_requirements_checked) { // There's not an explicit requirement in the spec to call vkGetImageMemoryRequirements() prior to calling @@ -9905,7 +9883,7 @@ static void PostCallRecordBindImageMemory(layer_data *dev_data, VkImage image, I } // Track objects tied to memory - uint64_t image_handle = reinterpret_cast<uint64_t &>(image); + uint64_t image_handle = HandleToUint64(image); SetMemBinding(dev_data, mem, image_handle, kVulkanObjectTypeImage, "vkBindImageMemory()"); image_state->binding.mem = mem; @@ -9939,9 +9917,9 @@ VKAPI_ATTR VkResult VKAPI_CALL SetEvent(VkDevice device, VkEvent event) { event_state->stageMask = VK_PIPELINE_STAGE_HOST_BIT; if (event_state->write_in_use) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_EVENT_EXT, - reinterpret_cast<const uint64_t &>(event), __LINE__, DRAWSTATE_QUEUE_FORWARD_PROGRESS, "DS", + HandleToUint64(event), __LINE__, DRAWSTATE_QUEUE_FORWARD_PROGRESS, "DS", "Cannot call vkSetEvent() on event 0x%" PRIxLEAST64 " that is already in use by a command buffer.", - reinterpret_cast<const uint64_t &>(event)); + HandleToUint64(event)); } } lock.unlock(); @@ -9981,7 +9959,7 @@ VKAPI_ATTR VkResult VKAPI_CALL QueueBindSparse(VkQueue queue, uint32_t bindInfoC for (uint32_t k = 0; k < bindInfo.pBufferBinds[j].bindCount; k++) { auto sparse_binding = bindInfo.pBufferBinds[j].pBinds[k]; if (SetSparseMemBinding(dev_data, {sparse_binding.memory, sparse_binding.memoryOffset, sparse_binding.size}, - (uint64_t)bindInfo.pBufferBinds[j].buffer, kVulkanObjectTypeBuffer)) + HandleToUint64(bindInfo.pBufferBinds[j].buffer), kVulkanObjectTypeBuffer)) skip = true; } } @@ -9989,7 +9967,7 @@ VKAPI_ATTR VkResult VKAPI_CALL QueueBindSparse(VkQueue queue, uint32_t bindInfoC for (uint32_t k = 0; k < bindInfo.pImageOpaqueBinds[j].bindCount; k++) { auto sparse_binding = bindInfo.pImageOpaqueBinds[j].pBinds[k]; if (SetSparseMemBinding(dev_data, {sparse_binding.memory, sparse_binding.memoryOffset, sparse_binding.size}, - (uint64_t)bindInfo.pImageOpaqueBinds[j].image, kVulkanObjectTypeImage)) + HandleToUint64(bindInfo.pImageOpaqueBinds[j].image), kVulkanObjectTypeImage)) skip = true; } } @@ -9999,7 +9977,7 @@ VKAPI_ATTR VkResult VKAPI_CALL QueueBindSparse(VkQueue queue, uint32_t bindInfoC // TODO: This size is broken for non-opaque bindings, need to update to comprehend full sparse binding data VkDeviceSize size = sparse_binding.extent.depth * sparse_binding.extent.height * sparse_binding.extent.width * 4; if (SetSparseMemBinding(dev_data, {sparse_binding.memory, sparse_binding.memoryOffset, size}, - (uint64_t)bindInfo.pImageBinds[j].image, kVulkanObjectTypeImage)) + HandleToUint64(bindInfo.pImageBinds[j].image), kVulkanObjectTypeImage)) skip = true; } } @@ -10019,10 +9997,10 @@ VKAPI_ATTR VkResult VKAPI_CALL QueueBindSparse(VkQueue queue, uint32_t bindInfoC pSemaphore->signaled = false; } else { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_SEMAPHORE_EXT, - reinterpret_cast<const uint64_t &>(semaphore), __LINE__, DRAWSTATE_QUEUE_FORWARD_PROGRESS, "DS", + HandleToUint64(semaphore), __LINE__, DRAWSTATE_QUEUE_FORWARD_PROGRESS, "DS", "vkQueueBindSparse: Queue 0x%p is waiting on semaphore 0x%" PRIx64 " that has no way to be signaled.", - queue, reinterpret_cast<const uint64_t &>(semaphore)); + queue, HandleToUint64(semaphore)); } } } @@ -10032,10 +10010,10 @@ VKAPI_ATTR VkResult VKAPI_CALL QueueBindSparse(VkQueue queue, uint32_t bindInfoC if (pSemaphore) { if (pSemaphore->signaled) { skip = log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_SEMAPHORE_EXT, - reinterpret_cast<const uint64_t &>(semaphore), __LINE__, DRAWSTATE_QUEUE_FORWARD_PROGRESS, "DS", + HandleToUint64(semaphore), __LINE__, DRAWSTATE_QUEUE_FORWARD_PROGRESS, "DS", "vkQueueBindSparse: Queue 0x%p is signaling semaphore 0x%" PRIx64 ", but that semaphore is already signaled.", - queue, reinterpret_cast<const uint64_t &>(semaphore)); + queue, HandleToUint64(semaphore)); } else { pSemaphore->signaler.first = queue; pSemaphore->signaler.second = pQueue->seq + pQueue->submissions.size() + 1; @@ -10110,31 +10088,31 @@ static bool PreCallValidateCreateSwapchainKHR(layer_data *dev_data, const char * if (!is_supported) { if (log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, - reinterpret_cast<uint64_t>(dev_data->device), __LINE__, VALIDATION_ERROR_01922, "DS", + HandleToUint64(dev_data->device), __LINE__, VALIDATION_ERROR_01922, "DS", "%s: pCreateInfo->surface is not known at this time to be supported for presentation by this device. " "The vkGetPhysicalDeviceSurfaceSupportKHR() must be called beforehand, and it must return VK_TRUE support " "with this surface for at least one queue family of this device. %s", - func_name, validation_error_map[VALIDATION_ERROR_01922])) + func_name, validation_error_map[VALIDATION_ERROR_01922])) return true; } } if (most_recent_swapchain != old_swapchain_state || (surface_state->old_swapchain && surface_state->swapchain)) { if (log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, - reinterpret_cast<uint64_t>(dev_data->device), __LINE__, DRAWSTATE_SWAPCHAIN_ALREADY_EXISTS, "DS", + HandleToUint64(dev_data->device), __LINE__, DRAWSTATE_SWAPCHAIN_ALREADY_EXISTS, "DS", "%s: surface has an existing swapchain other than oldSwapchain", func_name)) return true; } if (old_swapchain_state && old_swapchain_state->createInfo.surface != pCreateInfo->surface) { if (log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT, - reinterpret_cast<uint64_t const &>(pCreateInfo->oldSwapchain), __LINE__, DRAWSTATE_SWAPCHAIN_WRONG_SURFACE, - "DS", "%s: pCreateInfo->oldSwapchain's surface is not pCreateInfo->surface", func_name)) + HandleToUint64(pCreateInfo->oldSwapchain), __LINE__, DRAWSTATE_SWAPCHAIN_WRONG_SURFACE, "DS", + "%s: pCreateInfo->oldSwapchain's surface is not pCreateInfo->surface", func_name)) return true; } auto physical_device_state = GetPhysicalDeviceState(dev_data->instance_data, dev_data->physical_device); if (physical_device_state->vkGetPhysicalDeviceSurfaceCapabilitiesKHRState == UNCALLED) { if (log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, - reinterpret_cast<uint64_t>(dev_data->physical_device), __LINE__, DRAWSTATE_SWAPCHAIN_CREATE_BEFORE_QUERY, "DS", + HandleToUint64(dev_data->physical_device), __LINE__, DRAWSTATE_SWAPCHAIN_CREATE_BEFORE_QUERY, "DS", "%s: surface capabilities not retrieved for this physical device", func_name)) return true; } else { // have valid capabilities @@ -10142,7 +10120,7 @@ static bool PreCallValidateCreateSwapchainKHR(layer_data *dev_data, const char * // Validate pCreateInfo->minImageCount against VkSurfaceCapabilitiesKHR::{min|max}ImageCount: if (pCreateInfo->minImageCount < capabilities.minImageCount) { if (log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, - reinterpret_cast<uint64_t>(dev_data->device), __LINE__, VALIDATION_ERROR_02331, "DS", + HandleToUint64(dev_data->device), __LINE__, VALIDATION_ERROR_02331, "DS", "%s called with minImageCount = %d, which is outside the bounds returned " "by vkGetPhysicalDeviceSurfaceCapabilitiesKHR() (i.e. minImageCount = %d, maxImageCount = %d). %s", func_name, pCreateInfo->minImageCount, capabilities.minImageCount, capabilities.maxImageCount, @@ -10152,7 +10130,7 @@ static bool PreCallValidateCreateSwapchainKHR(layer_data *dev_data, const char * if ((capabilities.maxImageCount > 0) && (pCreateInfo->minImageCount > capabilities.maxImageCount)) { if (log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, - reinterpret_cast<uint64_t>(dev_data->device), __LINE__, VALIDATION_ERROR_02332, "DS", + HandleToUint64(dev_data->device), __LINE__, VALIDATION_ERROR_02332, "DS", "%s called with minImageCount = %d, which is outside the bounds returned " "by vkGetPhysicalDeviceSurfaceCapabilitiesKHR() (i.e. minImageCount = %d, maxImageCount = %d). %s", func_name, pCreateInfo->minImageCount, capabilities.minImageCount, capabilities.maxImageCount, @@ -10167,7 +10145,7 @@ static bool PreCallValidateCreateSwapchainKHR(layer_data *dev_data, const char * (pCreateInfo->imageExtent.height < capabilities.minImageExtent.height) || (pCreateInfo->imageExtent.height > capabilities.maxImageExtent.height))) { if (log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, - reinterpret_cast<uint64_t>(dev_data->device), __LINE__, VALIDATION_ERROR_02334, "DS", + HandleToUint64(dev_data->device), __LINE__, VALIDATION_ERROR_02334, "DS", "%s called with imageExtent = (%d,%d), which is outside the bounds returned by " "vkGetPhysicalDeviceSurfaceCapabilitiesKHR(): currentExtent = (%d,%d), minImageExtent = (%d,%d), " "maxImageExtent = (%d,%d). %s", @@ -10199,8 +10177,8 @@ static bool PreCallValidateCreateSwapchainKHR(layer_data *dev_data, const char * } // Log the message that we've built up: if (log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, - reinterpret_cast<uint64_t &>(dev_data->device), __LINE__, VALIDATION_ERROR_02339, "DS", "%s. %s", - errorString.c_str(), validation_error_map[VALIDATION_ERROR_02339])) + HandleToUint64(dev_data->device), __LINE__, VALIDATION_ERROR_02339, "DS", "%s. %s", errorString.c_str(), + validation_error_map[VALIDATION_ERROR_02339])) return true; } @@ -10226,14 +10204,14 @@ static bool PreCallValidateCreateSwapchainKHR(layer_data *dev_data, const char * } // Log the message that we've built up: if (log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, - reinterpret_cast<uint64_t &>(dev_data->device), __LINE__, VALIDATION_ERROR_02340, "DS", "%s. %s", - errorString.c_str(), validation_error_map[VALIDATION_ERROR_02340])) + HandleToUint64(dev_data->device), __LINE__, VALIDATION_ERROR_02340, "DS", "%s. %s", errorString.c_str(), + validation_error_map[VALIDATION_ERROR_02340])) return true; } // Validate pCreateInfo->imageArrayLayers against VkSurfaceCapabilitiesKHR::maxImageArrayLayers: if ((pCreateInfo->imageArrayLayers < 1) || (pCreateInfo->imageArrayLayers > capabilities.maxImageArrayLayers)) { if (log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, - reinterpret_cast<uint64_t>(dev_data->device), __LINE__, VALIDATION_ERROR_02335, "DS", + HandleToUint64(dev_data->device), __LINE__, VALIDATION_ERROR_02335, "DS", "%s called with a non-supported imageArrayLayers (i.e. %d). Minimum value is 1, maximum value is %d. %s", func_name, pCreateInfo->imageArrayLayers, capabilities.maxImageArrayLayers, validation_error_map[VALIDATION_ERROR_02335])) @@ -10242,7 +10220,7 @@ static bool PreCallValidateCreateSwapchainKHR(layer_data *dev_data, const char * // Validate pCreateInfo->imageUsage against VkSurfaceCapabilitiesKHR::supportedUsageFlags: if (pCreateInfo->imageUsage != (pCreateInfo->imageUsage & capabilities.supportedUsageFlags)) { if (log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, - reinterpret_cast<uint64_t>(dev_data->device), __LINE__, VALIDATION_ERROR_02336, "DS", + HandleToUint64(dev_data->device), __LINE__, VALIDATION_ERROR_02336, "DS", "%s called with a non-supported pCreateInfo->imageUsage (i.e. 0x%08x). Supported flag bits are 0x%08x. %s", func_name, pCreateInfo->imageUsage, capabilities.supportedUsageFlags, validation_error_map[VALIDATION_ERROR_02336])) @@ -10253,7 +10231,7 @@ static bool PreCallValidateCreateSwapchainKHR(layer_data *dev_data, const char * // Validate pCreateInfo values with the results of vkGetPhysicalDeviceSurfaceFormatsKHR(): if (physical_device_state->vkGetPhysicalDeviceSurfaceFormatsKHRState != QUERY_DETAILS) { if (log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, - reinterpret_cast<uint64_t>(dev_data->device), __LINE__, DRAWSTATE_SWAPCHAIN_CREATE_BEFORE_QUERY, "DS", + HandleToUint64(dev_data->device), __LINE__, DRAWSTATE_SWAPCHAIN_CREATE_BEFORE_QUERY, "DS", "%s called before calling vkGetPhysicalDeviceSurfaceFormatsKHR().", func_name)) return true; } else { @@ -10278,14 +10256,14 @@ static bool PreCallValidateCreateSwapchainKHR(layer_data *dev_data, const char * if (!foundMatch) { if (!foundFormat) { if (log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, - reinterpret_cast<uint64_t>(dev_data->device), __LINE__, VALIDATION_ERROR_02333, "DS", + HandleToUint64(dev_data->device), __LINE__, VALIDATION_ERROR_02333, "DS", "%s called with a non-supported pCreateInfo->imageFormat (i.e. %d). %s", func_name, pCreateInfo->imageFormat, validation_error_map[VALIDATION_ERROR_02333])) return true; } if (!foundColorSpace) { if (log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, - reinterpret_cast<uint64_t>(dev_data->device), __LINE__, VALIDATION_ERROR_02333, "DS", + HandleToUint64(dev_data->device), __LINE__, VALIDATION_ERROR_02333, "DS", "%s called with a non-supported pCreateInfo->imageColorSpace (i.e. %d). %s", func_name, pCreateInfo->imageColorSpace, validation_error_map[VALIDATION_ERROR_02333])) return true; @@ -10298,7 +10276,7 @@ static bool PreCallValidateCreateSwapchainKHR(layer_data *dev_data, const char * // FIFO is required to always be supported if (pCreateInfo->presentMode != VK_PRESENT_MODE_FIFO_KHR) { if (log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, - reinterpret_cast<uint64_t>(dev_data->device), __LINE__, DRAWSTATE_SWAPCHAIN_CREATE_BEFORE_QUERY, "DS", + HandleToUint64(dev_data->device), __LINE__, DRAWSTATE_SWAPCHAIN_CREATE_BEFORE_QUERY, "DS", "%s called before calling vkGetPhysicalDeviceSurfacePresentModesKHR().", func_name)) return true; } @@ -10308,7 +10286,7 @@ static bool PreCallValidateCreateSwapchainKHR(layer_data *dev_data, const char * pCreateInfo->presentMode) != physical_device_state->present_modes.end(); if (!foundMatch) { if (log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, - reinterpret_cast<uint64_t>(dev_data->device), __LINE__, VALIDATION_ERROR_02341, "DS", + HandleToUint64(dev_data->device), __LINE__, VALIDATION_ERROR_02341, "DS", "%s called with a non-supported presentMode (i.e. %s). %s", func_name, string_VkPresentModeKHR(pCreateInfo->presentMode), validation_error_map[VALIDATION_ERROR_02341])) return true; @@ -10397,7 +10375,7 @@ VKAPI_ATTR void VKAPI_CALL DestroySwapchainKHR(VkDevice device, VkSwapchainKHR s } dev_data->imageSubresourceMap.erase(image_sub); } - skip = ClearMemoryObjectBindings(dev_data, (uint64_t)swapchain_image, kVulkanObjectTypeSwapchainKHR); + skip = ClearMemoryObjectBindings(dev_data, HandleToUint64(swapchain_image), kVulkanObjectTypeSwapchainKHR); dev_data->imageMap.erase(swapchain_image); } } @@ -10432,10 +10410,10 @@ VKAPI_ATTR VkResult VKAPI_CALL GetSwapchainImagesKHR(VkDevice device, VkSwapchai if (mismatch) { // TODO: Verify against Valid Usage section of extension log_msg(dev_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT, - (uint64_t)swapchain, __LINE__, MEMTRACK_NONE, "SWAP_CHAIN", + HandleToUint64(swapchain), __LINE__, MEMTRACK_NONE, "SWAP_CHAIN", "vkGetSwapchainInfoKHR(0x%" PRIx64 ", VK_SWAP_CHAIN_INFO_TYPE_PERSISTENT_IMAGES_KHR) returned mismatching data", - (uint64_t)(swapchain)); + HandleToUint64(swapchain)); } } for (uint32_t i = 0; i < *pCount; ++i) { @@ -10482,7 +10460,7 @@ VKAPI_ATTR VkResult VKAPI_CALL QueuePresentKHR(VkQueue queue, const VkPresentInf skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, 0, __LINE__, DRAWSTATE_QUEUE_FORWARD_PROGRESS, "DS", "Queue 0x%p is waiting on semaphore 0x%" PRIx64 " that has no way to be signaled.", queue, - reinterpret_cast<const uint64_t &>(pPresentInfo->pWaitSemaphores[i])); + HandleToUint64(pPresentInfo->pWaitSemaphores[i])); } } @@ -10490,11 +10468,11 @@ VKAPI_ATTR VkResult VKAPI_CALL QueuePresentKHR(VkQueue queue, const VkPresentInf auto swapchain_data = GetSwapchainNode(dev_data, pPresentInfo->pSwapchains[i]); if (swapchain_data) { if (pPresentInfo->pImageIndices[i] >= swapchain_data->images.size()) { - skip |= log_msg( - dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT, - reinterpret_cast<uint64_t const &>(pPresentInfo->pSwapchains[i]), __LINE__, DRAWSTATE_SWAPCHAIN_INVALID_IMAGE, - "DS", "vkQueuePresentKHR: Swapchain image index too large (%u). There are only %u images in this swapchain.", - pPresentInfo->pImageIndices[i], (uint32_t)swapchain_data->images.size()); + skip |= + log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT, + HandleToUint64(pPresentInfo->pSwapchains[i]), __LINE__, DRAWSTATE_SWAPCHAIN_INVALID_IMAGE, "DS", + "vkQueuePresentKHR: Swapchain image index too large (%u). There are only %u images in this swapchain.", + pPresentInfo->pImageIndices[i], (uint32_t)swapchain_data->images.size()); } else { auto image = swapchain_data->images[pPresentInfo->pImageIndices[i]]; auto image_state = GetImageState(dev_data, image); @@ -10508,8 +10486,7 @@ VKAPI_ATTR VkResult VKAPI_CALL QueuePresentKHR(VkQueue queue, const VkPresentInf if (!image_state->acquired) { skip |= log_msg( dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT, - reinterpret_cast<uint64_t const &>(pPresentInfo->pSwapchains[i]), __LINE__, - DRAWSTATE_SWAPCHAIN_IMAGE_NOT_ACQUIRED, "DS", + HandleToUint64(pPresentInfo->pSwapchains[i]), __LINE__, DRAWSTATE_SWAPCHAIN_IMAGE_NOT_ACQUIRED, "DS", "vkQueuePresentKHR: Swapchain image index %u has not been acquired.", pPresentInfo->pImageIndices[i]); } @@ -10521,7 +10498,7 @@ VKAPI_ATTR VkResult VKAPI_CALL QueuePresentKHR(VkQueue queue, const VkPresentInf (layout != VK_IMAGE_LAYOUT_SHARED_PRESENT_KHR))) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_QUEUE_EXT, - reinterpret_cast<uint64_t &>(queue), __LINE__, VALIDATION_ERROR_01964, "DS", + HandleToUint64(queue), __LINE__, VALIDATION_ERROR_01964, "DS", "Images passed to present must be in layout " "VK_IMAGE_LAYOUT_PRESENT_SRC_KHR or VK_IMAGE_LAYOUT_SHARED_PRESENT_KHR but is in %s. %s", string_VkImageLayout(layout), validation_error_map[VALIDATION_ERROR_01964]); @@ -10540,17 +10517,16 @@ VKAPI_ATTR VkResult VKAPI_CALL QueuePresentKHR(VkQueue queue, const VkPresentInf if (support_it == surface_state->gpu_queue_support.end()) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT, - reinterpret_cast<uint64_t const &>(pPresentInfo->pSwapchains[i]), __LINE__, - DRAWSTATE_SWAPCHAIN_UNSUPPORTED_QUEUE, "DS", + HandleToUint64(pPresentInfo->pSwapchains[i]), __LINE__, DRAWSTATE_SWAPCHAIN_UNSUPPORTED_QUEUE, "DS", "vkQueuePresentKHR: Presenting image without calling " "vkGetPhysicalDeviceSurfaceSupportKHR"); } else if (!support_it->second) { - skip |= log_msg( - dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT, - reinterpret_cast<uint64_t const &>(pPresentInfo->pSwapchains[i]), __LINE__, VALIDATION_ERROR_01961, "DS", - "vkQueuePresentKHR: Presenting image on queue that cannot " - "present to this surface. %s", - validation_error_map[VALIDATION_ERROR_01961]); + skip |= + log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT, + HandleToUint64(pPresentInfo->pSwapchains[i]), __LINE__, VALIDATION_ERROR_01961, "DS", + "vkQueuePresentKHR: Presenting image on queue that cannot " + "present to this surface. %s", + validation_error_map[VALIDATION_ERROR_01961]); } } } @@ -10573,32 +10549,29 @@ VKAPI_ATTR VkResult VKAPI_CALL QueuePresentKHR(VkQueue queue, const VkPresentInf VkRectLayerKHR rect = region.pRectangles[j]; // TODO: Need to update these errors to their unique error ids when available if ((rect.offset.x + rect.extent.width) > swapchain_data->createInfo.imageExtent.width) { - skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, - VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT, - reinterpret_cast<uint64_t const &>(pPresentInfo->pSwapchains[i]), __LINE__, - DRAWSTATE_SWAPCHAIN_INVALID_IMAGE, "DS", - "vkQueuePresentKHR(): For VkPresentRegionKHR down pNext " - "chain, pRegion[%i].pRectangles[%i], the sum of offset.x " - "(%i) and extent.width (%i) is greater than the " - "corresponding swapchain's imageExtent.width (%i).", - i, j, rect.offset.x, rect.extent.width, swapchain_data->createInfo.imageExtent.width); + skip |= log_msg( + dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT, + HandleToUint64(pPresentInfo->pSwapchains[i]), __LINE__, DRAWSTATE_SWAPCHAIN_INVALID_IMAGE, "DS", + "vkQueuePresentKHR(): For VkPresentRegionKHR down pNext " + "chain, pRegion[%i].pRectangles[%i], the sum of offset.x " + "(%i) and extent.width (%i) is greater than the " + "corresponding swapchain's imageExtent.width (%i).", + i, j, rect.offset.x, rect.extent.width, swapchain_data->createInfo.imageExtent.width); } if ((rect.offset.y + rect.extent.height) > swapchain_data->createInfo.imageExtent.height) { - skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, - VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT, - reinterpret_cast<uint64_t const &>(pPresentInfo->pSwapchains[i]), __LINE__, - DRAWSTATE_SWAPCHAIN_INVALID_IMAGE, "DS", - "vkQueuePresentKHR(): For VkPresentRegionKHR down pNext " - "chain, pRegion[%i].pRectangles[%i], the sum of offset.y " - "(%i) and extent.height (%i) is greater than the " - "corresponding swapchain's imageExtent.height (%i).", - i, j, rect.offset.y, rect.extent.height, swapchain_data->createInfo.imageExtent.height); + skip |= log_msg( + dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT, + HandleToUint64(pPresentInfo->pSwapchains[i]), __LINE__, DRAWSTATE_SWAPCHAIN_INVALID_IMAGE, "DS", + "vkQueuePresentKHR(): For VkPresentRegionKHR down pNext " + "chain, pRegion[%i].pRectangles[%i], the sum of offset.y " + "(%i) and extent.height (%i) is greater than the " + "corresponding swapchain's imageExtent.height (%i).", + i, j, rect.offset.y, rect.extent.height, swapchain_data->createInfo.imageExtent.height); } if (rect.layer > swapchain_data->createInfo.imageArrayLayers) { skip |= log_msg( dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT, - reinterpret_cast<uint64_t const &>(pPresentInfo->pSwapchains[i]), __LINE__, - DRAWSTATE_SWAPCHAIN_INVALID_IMAGE, "DS", + HandleToUint64(pPresentInfo->pSwapchains[i]), __LINE__, DRAWSTATE_SWAPCHAIN_INVALID_IMAGE, "DS", "vkQueuePresentKHR(): For VkPresentRegionKHR down pNext chain, pRegion[%i].pRectangles[%i], the " "layer (%i) is greater than the corresponding swapchain's imageArrayLayers (%i).", i, j, rect.layer, swapchain_data->createInfo.imageArrayLayers); @@ -10610,7 +10583,7 @@ VKAPI_ATTR VkResult VKAPI_CALL QueuePresentKHR(VkQueue queue, const VkPresentInf if (pPresentInfo->swapchainCount != present_times_info->swapchainCount) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT, - reinterpret_cast<uint64_t const &>(pPresentInfo->pSwapchains[0]), __LINE__, + HandleToUint64(pPresentInfo->pSwapchains[0]), __LINE__, VALIDATION_ERROR_03214, "DS", "vkQueuePresentKHR(): VkPresentTimesInfoGOOGLE.swapchainCount is %i but " @@ -10743,7 +10716,7 @@ VKAPI_ATTR VkResult VKAPI_CALL AcquireNextImageKHR(VkDevice device, VkSwapchainK if (fence == VK_NULL_HANDLE && semaphore == VK_NULL_HANDLE) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, - reinterpret_cast<uint64_t &>(device), __LINE__, DRAWSTATE_SWAPCHAIN_NO_SYNC_FOR_ACQUIRE, "DS", + HandleToUint64(device), __LINE__, DRAWSTATE_SWAPCHAIN_NO_SYNC_FOR_ACQUIRE, "DS", "vkAcquireNextImageKHR: Semaphore and fence cannot both be VK_NULL_HANDLE. There would be no way " "to determine the completion of this operation."); } @@ -10751,7 +10724,7 @@ VKAPI_ATTR VkResult VKAPI_CALL AcquireNextImageKHR(VkDevice device, VkSwapchainK auto pSemaphore = GetSemaphoreNode(dev_data, semaphore); if (pSemaphore && pSemaphore->signaled) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_SEMAPHORE_EXT, - reinterpret_cast<const uint64_t &>(semaphore), __LINE__, VALIDATION_ERROR_01952, "DS", + HandleToUint64(semaphore), __LINE__, VALIDATION_ERROR_01952, "DS", "vkAcquireNextImageKHR: Semaphore must not be currently signaled or in a wait state. %s", validation_error_map[VALIDATION_ERROR_01952]); } @@ -10765,7 +10738,7 @@ VKAPI_ATTR VkResult VKAPI_CALL AcquireNextImageKHR(VkDevice device, VkSwapchainK if (swapchain_data->replaced) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT, - reinterpret_cast<uint64_t &>(swapchain), __LINE__, DRAWSTATE_SWAPCHAIN_REPLACED, "DS", + HandleToUint64(swapchain), __LINE__, DRAWSTATE_SWAPCHAIN_REPLACED, "DS", "vkAcquireNextImageKHR: This swapchain has been replaced. The application can still " "present any images it has acquired, but cannot acquire any more."); } @@ -10777,7 +10750,7 @@ VKAPI_ATTR VkResult VKAPI_CALL AcquireNextImageKHR(VkDevice device, VkSwapchainK if (acquired_images > swapchain_data->images.size() - physical_device_state->surfaceCapabilities.minImageCount) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT, - reinterpret_cast<uint64_t const &>(swapchain), __LINE__, DRAWSTATE_SWAPCHAIN_TOO_MANY_IMAGES, "DS", + HandleToUint64(swapchain), __LINE__, DRAWSTATE_SWAPCHAIN_TOO_MANY_IMAGES, "DS", "vkAcquireNextImageKHR: Application has already acquired the maximum number of images (0x%" PRIxLEAST64 ")", acquired_images); } @@ -10785,7 +10758,7 @@ VKAPI_ATTR VkResult VKAPI_CALL AcquireNextImageKHR(VkDevice device, VkSwapchainK if (swapchain_data->images.size() == 0) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT, - reinterpret_cast<uint64_t const &>(swapchain), __LINE__, DRAWSTATE_SWAPCHAIN_IMAGES_NOT_FOUND, "DS", + HandleToUint64(swapchain), __LINE__, DRAWSTATE_SWAPCHAIN_IMAGES_NOT_FOUND, "DS", "vkAcquireNextImageKHR: No images found to acquire from. Application probably did not call " "vkGetSwapchainImagesKHR after swapchain creation."); } @@ -10876,7 +10849,7 @@ static bool ValidateCommonGetPhysicalDeviceQueueFamilyProperties(instance_layer_ if (UNCALLED == pd_state->vkGetPhysicalDeviceQueueFamilyPropertiesState) { skip |= log_msg( instance_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, - reinterpret_cast<uint64_t>(pd_state->phys_device), __LINE__, DEVLIMITS_MISSING_QUERY_COUNT, "DL", + HandleToUint64(pd_state->phys_device), __LINE__, DEVLIMITS_MISSING_QUERY_COUNT, "DL", "%s is called with non-NULL pQueueFamilyProperties before obtaining pQueueFamilyPropertyCount. It is recommended " "to first call %s with NULL pQueueFamilyProperties in order to obtain the maximal pQueueFamilyPropertyCount.", caller_name, caller_name); @@ -10884,7 +10857,7 @@ static bool ValidateCommonGetPhysicalDeviceQueueFamilyProperties(instance_layer_ } else if (pd_state->queue_family_count != requested_queue_family_property_count) { skip |= log_msg( instance_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, - reinterpret_cast<uint64_t>(pd_state->phys_device), __LINE__, DEVLIMITS_COUNT_MISMATCH, "DL", + HandleToUint64(pd_state->phys_device), __LINE__, DEVLIMITS_COUNT_MISMATCH, "DL", "%s is called with non-NULL pQueueFamilyProperties and pQueueFamilyPropertyCount value %" PRIu32 ", but the largest previously returned pQueueFamilyPropertyCount for this physicalDevice is %" PRIu32 ". It is recommended to instead receive all the properties by calling %s with pQueueFamilyPropertyCount that was " @@ -11255,7 +11228,7 @@ VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceSurfacePresentModesKHR(VkPhysica case UNCALLED: skip |= log_msg( instance_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, - reinterpret_cast<uint64_t>(physicalDevice), __LINE__, DEVLIMITS_MUST_QUERY_COUNT, "DL", + HandleToUint64(physicalDevice), __LINE__, DEVLIMITS_MUST_QUERY_COUNT, "DL", "vkGetPhysicalDeviceSurfacePresentModesKHR() called with non-NULL pPresentModeCount; but no prior positive " "value has been seen for pPresentModeCount."); break; @@ -11263,8 +11236,8 @@ VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceSurfacePresentModesKHR(VkPhysica // both query count and query details if (*pPresentModeCount != prev_mode_count) { skip |= log_msg(instance_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, - VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, reinterpret_cast<uint64_t>(physicalDevice), - __LINE__, DEVLIMITS_COUNT_MISMATCH, "DL", + VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, HandleToUint64(physicalDevice), __LINE__, + DEVLIMITS_COUNT_MISMATCH, "DL", "vkGetPhysicalDeviceSurfacePresentModesKHR() called with *pPresentModeCount (%u) that " "differs from the value " "(%u) that was returned when pPresentModes was NULL.", @@ -11318,7 +11291,7 @@ VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevi // previously call this function with a NULL value of pSurfaceFormats: skip |= log_msg( instance_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, - reinterpret_cast<uint64_t>(physicalDevice), __LINE__, DEVLIMITS_MUST_QUERY_COUNT, "DL", + HandleToUint64(physicalDevice), __LINE__, DEVLIMITS_MUST_QUERY_COUNT, "DL", "vkGetPhysicalDeviceSurfaceFormatsKHR() called with non-NULL pSurfaceFormatCount; but no prior positive " "value has been seen for pSurfaceFormats."); break; @@ -11326,7 +11299,7 @@ VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevi if (prev_format_count != *pSurfaceFormatCount) { skip |= log_msg( instance_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, - VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, reinterpret_cast<uint64_t>(physicalDevice), __LINE__, + VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, HandleToUint64(physicalDevice), __LINE__, DEVLIMITS_COUNT_MISMATCH, "DL", "vkGetPhysicalDeviceSurfaceFormatsKHR() called with non-NULL pSurfaceFormatCount, and with pSurfaceFormats " "set " @@ -11470,8 +11443,9 @@ VKAPI_ATTR VkResult VKAPI_CALL EnumeratePhysicalDeviceGroupsKHX( return result; } else { log_msg(instance_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, 0, __LINE__, - DEVLIMITS_INVALID_INSTANCE, "DL", - "Invalid instance (0x%" PRIxLEAST64 ") passed into vkEnumeratePhysicalDeviceGroupsKHX().", (uint64_t)instance); + DEVLIMITS_INVALID_INSTANCE, "DL", + "Invalid instance (0x%" PRIxLEAST64 ") passed into vkEnumeratePhysicalDeviceGroupsKHX().", + HandleToUint64(instance)); } return VK_ERROR_VALIDATION_FAILED_EXT; } diff --git a/layers/descriptor_sets.cpp b/layers/descriptor_sets.cpp index 88d44e67..0627c67f 100644 --- a/layers/descriptor_sets.cpp +++ b/layers/descriptor_sets.cpp @@ -589,8 +589,7 @@ uint32_t cvdescriptorset::DescriptorSet::GetStorageUpdates(const std::map<uint32 } // Set is being deleted or updates so invalidate all bound cmd buffers void cvdescriptorset::DescriptorSet::InvalidateBoundCmdBuffers() { - core_validation::invalidateCommandBuffers(device_data_, cb_bindings, - {reinterpret_cast<uint64_t &>(set_), kVulkanObjectTypeDescriptorSet }); + core_validation::invalidateCommandBuffers(device_data_, cb_bindings, {HandleToUint64(set_), kVulkanObjectTypeDescriptorSet}); } // Perform write update in given update struct void cvdescriptorset::DescriptorSet::PerformWriteUpdate(const VkWriteDescriptorSet *update) { @@ -726,10 +725,9 @@ void cvdescriptorset::DescriptorSet::BindCommandBuffer(GLOBAL_CB_NODE *cb_node, // bind cb to this descriptor set cb_bindings.insert(cb_node); // Add bindings for descriptor set, the set's pool, and individual objects in the set - cb_node->object_bindings.insert({reinterpret_cast<uint64_t &>(set_), kVulkanObjectTypeDescriptorSet }); + cb_node->object_bindings.insert({HandleToUint64(set_), kVulkanObjectTypeDescriptorSet}); pool_state_->cb_bindings.insert(cb_node); - cb_node->object_bindings.insert( - {reinterpret_cast<uint64_t &>(pool_state_->pool), kVulkanObjectTypeDescriptorPool }); + cb_node->object_bindings.insert({HandleToUint64(pool_state_->pool), kVulkanObjectTypeDescriptorPool}); // For the active slots, use set# to look up descriptorSet from boundDescriptorSets, and bind all of that descriptor set's // resources for (auto binding_req_pair : binding_req_map) { @@ -1098,18 +1096,18 @@ bool cvdescriptorset::ValidateUpdateDescriptorSets(const debug_report_data *repo if (!set_node) { skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT, - reinterpret_cast<uint64_t &>(dest_set), __LINE__, DRAWSTATE_INVALID_DESCRIPTOR_SET, "DS", + HandleToUint64(dest_set), __LINE__, DRAWSTATE_INVALID_DESCRIPTOR_SET, "DS", "Cannot call vkUpdateDescriptorSets() on descriptor set 0x%" PRIxLEAST64 " that has not been allocated.", - reinterpret_cast<uint64_t &>(dest_set)); + HandleToUint64(dest_set)); } else { UNIQUE_VALIDATION_ERROR_CODE error_code; std::string error_str; if (!set_node->ValidateWriteUpdate(report_data, &p_wds[i], &error_code, &error_str)) { skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT, - reinterpret_cast<uint64_t &>(dest_set), __LINE__, error_code, "DS", + HandleToUint64(dest_set), __LINE__, error_code, "DS", "vkUpdateDescriptorsSets() failed write update validation for Descriptor Set 0x%" PRIx64 " with error: %s. %s", - reinterpret_cast<uint64_t &>(dest_set), error_str.c_str(), validation_error_map[error_code]); + HandleToUint64(dest_set), error_str.c_str(), validation_error_map[error_code]); } } } @@ -1126,11 +1124,10 @@ bool cvdescriptorset::ValidateUpdateDescriptorSets(const debug_report_data *repo std::string error_str; if (!dst_node->ValidateCopyUpdate(report_data, &p_cds[i], src_node, &error_code, &error_str)) { skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT, - reinterpret_cast<uint64_t &>(dst_set), __LINE__, error_code, "DS", + HandleToUint64(dst_set), __LINE__, error_code, "DS", "vkUpdateDescriptorsSets() failed copy update from Descriptor Set 0x%" PRIx64 " to Descriptor Set 0x%" PRIx64 " with error: %s. %s", - reinterpret_cast<uint64_t &>(src_set), reinterpret_cast<uint64_t &>(dst_set), error_str.c_str(), - validation_error_map[error_code]); + HandleToUint64(src_set), HandleToUint64(dst_set), error_str.c_str(), validation_error_map[error_code]); } } return skip; @@ -1657,9 +1654,9 @@ bool cvdescriptorset::ValidateAllocateDescriptorSets(const core_validation::laye if (!layout) { skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT_EXT, - reinterpret_cast<const uint64_t &>(p_alloc_info->pSetLayouts[i]), __LINE__, DRAWSTATE_INVALID_LAYOUT, "DS", + HandleToUint64(p_alloc_info->pSetLayouts[i]), __LINE__, DRAWSTATE_INVALID_LAYOUT, "DS", "Unable to find set layout node for layout 0x%" PRIxLEAST64 " specified in vkAllocateDescriptorSets() call", - reinterpret_cast<const uint64_t &>(p_alloc_info->pSetLayouts[i])); + HandleToUint64(p_alloc_info->pSetLayouts[i])); } } if (!GetDeviceExtensions(dev_data)->khr_maintenance1) { @@ -1667,21 +1664,21 @@ bool cvdescriptorset::ValidateAllocateDescriptorSets(const core_validation::laye // Track number of descriptorSets allowable in this pool if (pool_state->availableSets < p_alloc_info->descriptorSetCount) { skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT, - reinterpret_cast<uint64_t &>(pool_state->pool), __LINE__, VALIDATION_ERROR_00911, "DS", + HandleToUint64(pool_state->pool), __LINE__, VALIDATION_ERROR_00911, "DS", "Unable to allocate %u descriptorSets from pool 0x%" PRIxLEAST64 ". This pool only has %d descriptorSets remaining. %s", - p_alloc_info->descriptorSetCount, reinterpret_cast<uint64_t &>(pool_state->pool), - pool_state->availableSets, validation_error_map[VALIDATION_ERROR_00911]); + p_alloc_info->descriptorSetCount, HandleToUint64(pool_state->pool), pool_state->availableSets, + validation_error_map[VALIDATION_ERROR_00911]); } // Determine whether descriptor counts are satisfiable for (uint32_t i = 0; i < VK_DESCRIPTOR_TYPE_RANGE_SIZE; i++) { if (ds_data->required_descriptors_by_type[i] > pool_state->availableDescriptorTypeCount[i]) { skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT, - reinterpret_cast<const uint64_t &>(pool_state->pool), __LINE__, VALIDATION_ERROR_00912, "DS", + HandleToUint64(pool_state->pool), __LINE__, VALIDATION_ERROR_00912, "DS", "Unable to allocate %u descriptors of type %s from pool 0x%" PRIxLEAST64 ". This pool only has %d descriptors of this type remaining. %s", ds_data->required_descriptors_by_type[i], string_VkDescriptorType(VkDescriptorType(i)), - reinterpret_cast<uint64_t &>(pool_state->pool), pool_state->availableDescriptorTypeCount[i], + HandleToUint64(pool_state->pool), pool_state->availableDescriptorTypeCount[i], validation_error_map[VALIDATION_ERROR_00912]); } } diff --git a/layers/object_tracker.cpp b/layers/object_tracker.cpp index 87ca7c7d..4da181c0 100644 --- a/layers/object_tracker.cpp +++ b/layers/object_tracker.cpp @@ -66,7 +66,7 @@ static void AddQueueInfo(VkDevice device, uint32_t queue_node_index, VkQueue que device_data->queue_info_map[queue] = p_queue_info; } else { log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_QUEUE_EXT, - reinterpret_cast<uint64_t>(queue), __LINE__, OBJTRACK_INTERNAL_ERROR, LayerName, + HandleToUint64(queue), __LINE__, OBJTRACK_INTERNAL_ERROR, LayerName, "ERROR: VK_ERROR_OUT_OF_HOST_MEMORY -- could not allocate memory for Queue Information"); } } @@ -109,7 +109,7 @@ static void ValidateQueueFlags(VkQueue queue, const char *function) { if ((instance_data->queue_family_properties[pQueueInfo->queue_node_index].queueFlags & VK_QUEUE_SPARSE_BINDING_BIT) == 0) { log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_QUEUE_EXT, - reinterpret_cast<uint64_t>(queue), __LINE__, VALIDATION_ERROR_01651, LayerName, + HandleToUint64(queue), __LINE__, VALIDATION_ERROR_01651, LayerName, "Attempting %s on a non-memory-management capable queue -- VK_QUEUE_SPARSE_BINDING_BIT not set. %s", function, validation_error_map[VALIDATION_ERROR_01651]); } @@ -122,20 +122,20 @@ static void AllocateCommandBuffer(VkDevice device, const VkCommandPool command_p layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); log_msg(device_data->report_data, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<const uint64_t>(command_buffer), __LINE__, OBJTRACK_NONE, LayerName, + HandleToUint64(command_buffer), __LINE__, OBJTRACK_NONE, LayerName, "OBJ[0x%" PRIxLEAST64 "] : CREATE %s object 0x%" PRIxLEAST64, object_track_index++, - "VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT", reinterpret_cast<const uint64_t>(command_buffer)); + "VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT", HandleToUint64(command_buffer)); OBJTRACK_NODE *pNewObjNode = new OBJTRACK_NODE; pNewObjNode->object_type = kVulkanObjectTypeCommandBuffer; - pNewObjNode->handle = reinterpret_cast<const uint64_t>(command_buffer); - pNewObjNode->parent_object = reinterpret_cast<const uint64_t &>(command_pool); + pNewObjNode->handle = HandleToUint64(command_buffer); + pNewObjNode->parent_object = HandleToUint64(command_pool); if (level == VK_COMMAND_BUFFER_LEVEL_SECONDARY) { pNewObjNode->status = OBJSTATUS_COMMAND_BUFFER_SECONDARY; } else { pNewObjNode->status = OBJSTATUS_NONE; } - device_data->object_map[kVulkanObjectTypeCommandBuffer][reinterpret_cast<const uint64_t>(command_buffer)] = pNewObjNode; + device_data->object_map[kVulkanObjectTypeCommandBuffer][HandleToUint64(command_buffer)] = pNewObjNode; device_data->num_objects[kVulkanObjectTypeCommandBuffer]++; device_data->num_total_objects++; } @@ -143,18 +143,18 @@ static void AllocateCommandBuffer(VkDevice device, const VkCommandPool command_p static bool ValidateCommandBuffer(VkDevice device, VkCommandPool command_pool, VkCommandBuffer command_buffer) { layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); bool skip = false; - uint64_t object_handle = reinterpret_cast<uint64_t>(command_buffer); + uint64_t object_handle = HandleToUint64(command_buffer); if (device_data->object_map[kVulkanObjectTypeCommandBuffer].find(object_handle) != device_data->object_map[kVulkanObjectTypeCommandBuffer].end()) { - OBJTRACK_NODE *pNode = device_data->object_map[kVulkanObjectTypeCommandBuffer][reinterpret_cast<uint64_t>(command_buffer)]; + OBJTRACK_NODE *pNode = device_data->object_map[kVulkanObjectTypeCommandBuffer][HandleToUint64(command_buffer)]; - if (pNode->parent_object != reinterpret_cast<uint64_t &>(command_pool)) { + if (pNode->parent_object != HandleToUint64(command_pool)) { skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, object_handle, __LINE__, VALIDATION_ERROR_00102, LayerName, "FreeCommandBuffers is attempting to free Command Buffer 0x%" PRIxLEAST64 " belonging to Command Pool 0x%" PRIxLEAST64 " from pool 0x%" PRIxLEAST64 "). %s", - reinterpret_cast<uint64_t>(command_buffer), pNode->parent_object, - reinterpret_cast<uint64_t &>(command_pool), validation_error_map[VALIDATION_ERROR_00102]); + HandleToUint64(command_buffer), pNode->parent_object, HandleToUint64(command_pool), + validation_error_map[VALIDATION_ERROR_00102]); } } else { skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, @@ -168,16 +168,16 @@ static void AllocateDescriptorSet(VkDevice device, VkDescriptorPool descriptor_p layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); log_msg(device_data->report_data, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT, - reinterpret_cast<uint64_t &>(descriptor_set), __LINE__, OBJTRACK_NONE, LayerName, + HandleToUint64(descriptor_set), __LINE__, OBJTRACK_NONE, LayerName, "OBJ[0x%" PRIxLEAST64 "] : CREATE %s object 0x%" PRIxLEAST64, object_track_index++, - "VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT", reinterpret_cast<uint64_t &>(descriptor_set)); + "VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT", HandleToUint64(descriptor_set)); OBJTRACK_NODE *pNewObjNode = new OBJTRACK_NODE; pNewObjNode->object_type = kVulkanObjectTypeDescriptorSet; pNewObjNode->status = OBJSTATUS_NONE; - pNewObjNode->handle = reinterpret_cast<uint64_t &>(descriptor_set); - pNewObjNode->parent_object = reinterpret_cast<uint64_t &>(descriptor_pool); - device_data->object_map[kVulkanObjectTypeDescriptorSet][reinterpret_cast<uint64_t &>(descriptor_set)] = pNewObjNode; + pNewObjNode->handle = HandleToUint64(descriptor_set); + pNewObjNode->parent_object = HandleToUint64(descriptor_pool); + device_data->object_map[kVulkanObjectTypeDescriptorSet][HandleToUint64(descriptor_set)] = pNewObjNode; device_data->num_objects[kVulkanObjectTypeDescriptorSet]++; device_data->num_total_objects++; } @@ -185,18 +185,18 @@ static void AllocateDescriptorSet(VkDevice device, VkDescriptorPool descriptor_p static bool ValidateDescriptorSet(VkDevice device, VkDescriptorPool descriptor_pool, VkDescriptorSet descriptor_set) { layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); bool skip = false; - uint64_t object_handle = reinterpret_cast<uint64_t &>(descriptor_set); + uint64_t object_handle = HandleToUint64(descriptor_set); auto dsItem = device_data->object_map[kVulkanObjectTypeDescriptorSet].find(object_handle); if (dsItem != device_data->object_map[kVulkanObjectTypeDescriptorSet].end()) { OBJTRACK_NODE *pNode = dsItem->second; - if (pNode->parent_object != reinterpret_cast<uint64_t &>(descriptor_pool)) { + if (pNode->parent_object != HandleToUint64(descriptor_pool)) { skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT, object_handle, __LINE__, VALIDATION_ERROR_00927, LayerName, "FreeDescriptorSets is attempting to free descriptorSet 0x%" PRIxLEAST64 " belonging to Descriptor Pool 0x%" PRIxLEAST64 " from pool 0x%" PRIxLEAST64 "). %s", - reinterpret_cast<uint64_t &>(descriptor_set), pNode->parent_object, - reinterpret_cast<uint64_t &>(descriptor_pool), validation_error_map[VALIDATION_ERROR_00927]); + HandleToUint64(descriptor_set), pNode->parent_object, HandleToUint64(descriptor_pool), + validation_error_map[VALIDATION_ERROR_00927]); } } else { skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT, @@ -210,15 +210,14 @@ static void CreateQueue(VkDevice device, VkQueue vkObj) { layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); log_msg(device_data->report_data, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_QUEUE_EXT, - reinterpret_cast<uint64_t>(vkObj), __LINE__, OBJTRACK_NONE, LayerName, - "OBJ[0x%" PRIxLEAST64 "] : CREATE %s object 0x%" PRIxLEAST64, object_track_index++, - "VK_DEBUG_REPORT_OBJECT_TYPE_QUEUE_EXT", reinterpret_cast<uint64_t>(vkObj)); + HandleToUint64(vkObj), __LINE__, OBJTRACK_NONE, LayerName, "OBJ[0x%" PRIxLEAST64 "] : CREATE %s object 0x%" PRIxLEAST64, + object_track_index++, "VK_DEBUG_REPORT_OBJECT_TYPE_QUEUE_EXT", HandleToUint64(vkObj)); OBJTRACK_NODE *p_obj_node = NULL; - auto queue_item = device_data->object_map[kVulkanObjectTypeQueue].find(reinterpret_cast<uint64_t>(vkObj)); + auto queue_item = device_data->object_map[kVulkanObjectTypeQueue].find(HandleToUint64(vkObj)); if (queue_item == device_data->object_map[kVulkanObjectTypeQueue].end()) { p_obj_node = new OBJTRACK_NODE; - device_data->object_map[kVulkanObjectTypeQueue][reinterpret_cast<uint64_t>(vkObj)] = p_obj_node; + device_data->object_map[kVulkanObjectTypeQueue][HandleToUint64(vkObj)] = p_obj_node; device_data->num_objects[kVulkanObjectTypeQueue]++; device_data->num_total_objects++; } else { @@ -226,38 +225,29 @@ static void CreateQueue(VkDevice device, VkQueue vkObj) { } p_obj_node->object_type = kVulkanObjectTypeQueue; p_obj_node->status = OBJSTATUS_NONE; - p_obj_node->handle = reinterpret_cast<uint64_t>(vkObj); + p_obj_node->handle = HandleToUint64(vkObj); } static void CreateSwapchainImageObject(VkDevice dispatchable_object, VkImage swapchain_image, VkSwapchainKHR swapchain) { layer_data *device_data = GetLayerDataPtr(get_dispatch_key(dispatchable_object), layer_data_map); log_msg(device_data->report_data, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, - reinterpret_cast<uint64_t &>(swapchain_image), __LINE__, OBJTRACK_NONE, LayerName, + HandleToUint64(swapchain_image), __LINE__, OBJTRACK_NONE, LayerName, "OBJ[0x%" PRIxLEAST64 "] : CREATE %s object 0x%" PRIxLEAST64, object_track_index++, "SwapchainImage", - reinterpret_cast<uint64_t &>(swapchain_image)); + HandleToUint64(swapchain_image)); OBJTRACK_NODE *pNewObjNode = new OBJTRACK_NODE; pNewObjNode->object_type = kVulkanObjectTypeImage; pNewObjNode->status = OBJSTATUS_NONE; - pNewObjNode->handle = reinterpret_cast<uint64_t &>(swapchain_image); - pNewObjNode->parent_object = reinterpret_cast<uint64_t &>(swapchain); - device_data->swapchainImageMap[reinterpret_cast<uint64_t &>(swapchain_image)] = pNewObjNode; -} - -template <typename T> -uint64_t handle_value(T handle) { - return reinterpret_cast<uint64_t &>(handle); -} -template <typename T> -uint64_t handle_value(T *handle) { - return reinterpret_cast<uint64_t>(handle); + pNewObjNode->handle = HandleToUint64(swapchain_image); + pNewObjNode->parent_object = HandleToUint64(swapchain); + device_data->swapchainImageMap[HandleToUint64(swapchain_image)] = pNewObjNode; } template <typename T1, typename T2> static void CreateObject(T1 dispatchable_object, T2 object, VulkanObjectType object_type, const VkAllocationCallbacks *pAllocator) { layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(dispatchable_object), layer_data_map); - auto object_handle = handle_value(object); + auto object_handle = HandleToUint64(object); bool custom_allocator = pAllocator != nullptr; if (!instance_data->object_map[object_type].count(object_handle)) { @@ -283,7 +273,7 @@ static void DestroyObject(T1 dispatchable_object, T2 object, VulkanObjectType ob enum UNIQUE_VALIDATION_ERROR_CODE expected_default_allocator_code) { layer_data *device_data = GetLayerDataPtr(get_dispatch_key(dispatchable_object), layer_data_map); - auto object_handle = handle_value(object); + auto object_handle = HandleToUint64(object); bool custom_allocator = pAllocator != nullptr; VkDebugReportObjectTypeEXT debug_object_type = get_debug_report_enum[object_type]; @@ -299,7 +289,7 @@ static void DestroyObject(T1 dispatchable_object, T2 object, VulkanObjectType ob log_msg(device_data->report_data, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, debug_object_type, object_handle, __LINE__, OBJTRACK_NONE, LayerName, "OBJ_STAT Destroy %s obj 0x%" PRIxLEAST64 " (%" PRIu64 " total objs remain & %" PRIu64 " %s objs).", - object_string[object_type], reinterpret_cast<uint64_t &>(object), device_data->num_total_objects, + object_string[object_type], HandleToUint64(object), device_data->num_total_objects, device_data->num_objects[pNode->object_type], object_string[object_type]); auto allocated_with_custom = (pNode->status & OBJSTATUS_CUSTOM_ALLOCATOR) ? true : false; @@ -336,7 +326,7 @@ static bool ValidateObject(T1 dispatchable_object, T2 object, VulkanObjectType o if (null_allowed && (object == VK_NULL_HANDLE)) { return false; } - auto object_handle = handle_value(object); + auto object_handle = HandleToUint64(object); VkDebugReportObjectTypeEXT debug_object_type = get_debug_report_enum[object_type]; layer_data *device_data = GetLayerDataPtr(get_dispatch_key(dispatchable_object), layer_data_map); @@ -382,8 +372,7 @@ static void DeviceReportUndestroyedObjects(VkDevice device, VulkanObjectType obj log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, get_debug_report_enum[object_type], object_info->handle, __LINE__, error_code, LayerName, "OBJ ERROR : For device 0x%" PRIxLEAST64 ", %s object 0x%" PRIxLEAST64 " has not been destroyed. %s", - reinterpret_cast<uint64_t>(device), object_string[object_type], object_info->handle, - validation_error_map[error_code]); + HandleToUint64(device), object_string[object_type], object_info->handle, validation_error_map[error_code]); item = device_data->object_map[object_type].erase(item); } } @@ -1603,7 +1592,7 @@ VKAPI_ATTR VkResult VKAPI_CALL ResetDescriptorPool(VkDevice device, VkDescriptor while (itr != device_data->object_map[kVulkanObjectTypeDescriptorSet].end()) { OBJTRACK_NODE *pNode = (*itr).second; auto del_itr = itr++; - if (pNode->parent_object == reinterpret_cast<uint64_t &>(descriptorPool)) { + if (pNode->parent_object == HandleToUint64(descriptorPool)) { DestroyObject(device, (VkDescriptorSet)((*del_itr).first), kVulkanObjectTypeDescriptorSet, nullptr, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); } @@ -1825,8 +1814,7 @@ VKAPI_ATTR VkResult VKAPI_CALL BeginCommandBuffer(VkCommandBuffer command_buffer skip |= ValidateObject(command_buffer, command_buffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_00108, VALIDATION_ERROR_UNDEFINED); if (begin_info) { - OBJTRACK_NODE *pNode = - device_data->object_map[kVulkanObjectTypeCommandBuffer][reinterpret_cast<const uint64_t>(command_buffer)]; + OBJTRACK_NODE *pNode = device_data->object_map[kVulkanObjectTypeCommandBuffer][HandleToUint64(command_buffer)]; if ((begin_info->pInheritanceInfo) && (pNode->status & OBJSTATUS_COMMAND_BUFFER_SECONDARY) && (begin_info->flags & VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT)) { skip |= ValidateObject(command_buffer, begin_info->pInheritanceInfo->framebuffer, kVulkanObjectTypeFramebuffer, @@ -3664,7 +3652,7 @@ VKAPI_ATTR void VKAPI_CALL DestroySwapchainKHR(VkDevice device, VkSwapchainKHR s std::unordered_map<uint64_t, OBJTRACK_NODE *>::iterator itr = device_data->swapchainImageMap.begin(); while (itr != device_data->swapchainImageMap.end()) { OBJTRACK_NODE *pNode = (*itr).second; - if (pNode->parent_object == reinterpret_cast<uint64_t &>(swapchain)) { + if (pNode->parent_object == HandleToUint64(swapchain)) { delete pNode; auto delete_item = itr++; device_data->swapchainImageMap.erase(delete_item); @@ -3724,7 +3712,7 @@ VKAPI_ATTR void VKAPI_CALL DestroyDescriptorPool(VkDevice device, VkDescriptorPo while (itr != device_data->object_map[kVulkanObjectTypeDescriptorSet].end()) { OBJTRACK_NODE *pNode = (*itr).second; auto del_itr = itr++; - if (pNode->parent_object == reinterpret_cast<uint64_t &>(descriptorPool)) { + if (pNode->parent_object == HandleToUint64(descriptorPool)) { DestroyObject(device, (VkDescriptorSet)((*del_itr).first), kVulkanObjectTypeDescriptorSet, nullptr, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); } @@ -3753,7 +3741,7 @@ VKAPI_ATTR void VKAPI_CALL DestroyCommandPool(VkDevice device, VkCommandPool com while (itr != device_data->object_map[kVulkanObjectTypeCommandBuffer].end()) { OBJTRACK_NODE *pNode = (*itr).second; del_itr = itr++; - if (pNode->parent_object == reinterpret_cast<uint64_t &>(commandPool)) { + if (pNode->parent_object == HandleToUint64(commandPool)) { skip |= ValidateCommandBuffer(device, commandPool, reinterpret_cast<VkCommandBuffer>((*del_itr).first)); DestroyObject(device, reinterpret_cast<VkCommandBuffer>((*del_itr).first), kVulkanObjectTypeCommandBuffer, nullptr, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); diff --git a/layers/parameter_validation.cpp b/layers/parameter_validation.cpp index 65ead972..fecdbbc8 100644 --- a/layers/parameter_validation.cpp +++ b/layers/parameter_validation.cpp @@ -1252,13 +1252,14 @@ static bool ValidateDeviceQueueFamily(layer_data *device_data, uint32_t queue_fa if (!optional && queue_family == VK_QUEUE_FAMILY_IGNORED) { skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, - reinterpret_cast<uint64_t>(device_data->device), __LINE__, error_code, LayerName, + HandleToUint64(device_data->device), __LINE__, error_code, LayerName, "%s: %s is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family index value. %s", cmd_name, parameter_name, vu_note); } else if (device_data->queueFamilyIndexMap.find(queue_family) == device_data->queueFamilyIndexMap.end()) { skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, - reinterpret_cast<uint64_t>(device_data->device), __LINE__, error_code, LayerName, - "%s: %s (= %" PRIu32 ") is not one of the queue families given via VkDeviceQueueCreateInfo structures when " + HandleToUint64(device_data->device), __LINE__, error_code, LayerName, + "%s: %s (= %" PRIu32 + ") is not one of the queue families given via VkDeviceQueueCreateInfo structures when " "the device was created. %s", cmd_name, parameter_name, queue_family, vu_note); } @@ -1283,7 +1284,7 @@ static bool ValidateQueueFamilies(layer_data *device_data, uint32_t queue_family if (set.count(queue_families[i])) { skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, - reinterpret_cast<uint64_t>(device_data->device), __LINE__, VALIDATION_ERROR_00035, LayerName, + HandleToUint64(device_data->device), __LINE__, VALIDATION_ERROR_00035, LayerName, "%s: %s (=%" PRIu32 ") is not unique within %s array. %s", cmd_name, parameter_name.c_str(), queue_families[i], array_parameter_name, unique_vu_note); } else { @@ -1584,16 +1585,18 @@ static bool ValidateDeviceCreateInfo(instance_layer_data *instance_data, VkPhysi const uint32_t requested_queue_family = pCreateInfo->pQueueCreateInfos[i].queueFamilyIndex; if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) { skip |= log_msg(instance_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, - VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, reinterpret_cast<uint64_t>(physicalDevice), - __LINE__, VALIDATION_ERROR_00054, LayerName, - "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].queueFamilyIndex is " + VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, HandleToUint64(physicalDevice), __LINE__, + VALIDATION_ERROR_00054, LayerName, + "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 + "].queueFamilyIndex is " "VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family index value. %s", i, validation_error_map[VALIDATION_ERROR_00054]); } else if (set.count(requested_queue_family)) { skip |= log_msg(instance_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, - VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, reinterpret_cast<uint64_t>(physicalDevice), - __LINE__, VALIDATION_ERROR_00035, LayerName, - "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].queueFamilyIndex (=%" PRIu32 ") is " + VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, HandleToUint64(physicalDevice), __LINE__, + VALIDATION_ERROR_00035, LayerName, + "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].queueFamilyIndex (=%" PRIu32 + ") is " "not unique within pCreateInfo->pQueueCreateInfos array. %s", i, requested_queue_family, validation_error_map[VALIDATION_ERROR_00035]); } else { @@ -1605,8 +1608,8 @@ static bool ValidateDeviceCreateInfo(instance_layer_data *instance_data, VkPhysi const float queue_priority = pCreateInfo->pQueueCreateInfos[i].pQueuePriorities[j]; if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) { skip |= log_msg(instance_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, - VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, reinterpret_cast<uint64_t>(physicalDevice), - __LINE__, VALIDATION_ERROR_02056, LayerName, + VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, HandleToUint64(physicalDevice), __LINE__, + VALIDATION_ERROR_02056, LayerName, "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32 "] (=%f) is not between 0 and 1 (inclusive). %s", i, j, queue_priority, validation_error_map[VALIDATION_ERROR_02056]); @@ -1732,8 +1735,9 @@ static bool PreGetDeviceQueue(VkDevice device, uint32_t queueFamilyIndex, uint32 const auto &queue_data = my_device_data->queueFamilyIndexMap.find(queueFamilyIndex); if (queue_data != my_device_data->queueFamilyIndexMap.end() && queue_data->second <= queueIndex) { skip |= log_msg(my_device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, - reinterpret_cast<uint64_t>(device), __LINE__, VALIDATION_ERROR_00061, LayerName, - "vkGetDeviceQueue: queueIndex (=%" PRIu32 ") is not less than the number of queues requested from " + HandleToUint64(device), __LINE__, VALIDATION_ERROR_00061, LayerName, + "vkGetDeviceQueue: queueIndex (=%" PRIu32 + ") is not less than the number of queues requested from " "queueFamilyIndex (=%" PRIu32 ") when the device was created (i.e. is not less than %" PRIu32 "). %s", queueIndex, queueFamilyIndex, queue_data->second, validation_error_map[VALIDATION_ERROR_00061]); } @@ -4086,7 +4090,7 @@ static bool PreBeginCommandBuffer(layer_data *dev_data, VkCommandBuffer commandB if (pInfo != NULL) { if ((dev_data->physical_device_features.inheritedQueries == VK_FALSE) && (pInfo->occlusionQueryEnable != VK_FALSE)) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<uint64_t>(commandBuffer), __LINE__, VALIDATION_ERROR_00116, LayerName, + HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_00116, LayerName, "Cannot set inherited occlusionQueryEnable in vkBeginCommandBuffer() when device does not support " "inheritedQueries. %s", validation_error_map[VALIDATION_ERROR_00116]); @@ -5286,7 +5290,7 @@ static bool require_instance_extension(void *instance, bool InstanceExtensions:: auto my_data = GetLayerDataPtr(get_dispatch_key(instance), instance_layer_data_map); if (!(my_data->extensions.*flag)) { return log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, - reinterpret_cast<uint64_t>(instance), __LINE__, EXTENSION_NOT_ENABLED, LayerName, + HandleToUint64(instance), __LINE__, EXTENSION_NOT_ENABLED, LayerName, "%s() called even though the %s extension was not enabled for this VkInstance.", function_name, extension_name); } diff --git a/layers/swapchain.cpp b/layers/swapchain.cpp index 77fd1633..61db1182 100644 --- a/layers/swapchain.cpp +++ b/layers/swapchain.cpp @@ -63,7 +63,7 @@ static void checkDeviceRegisterExtensions(VkPhysicalDevice physicalDevice, const // TBD: Should we leave error in (since Swapchain really needs this // link)? log_msg(my_instance_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, - reinterpret_cast<uint64_t>(physicalDevice), __LINE__, VALIDATION_ERROR_00031, "Swapchain", + HandleToUint64(physicalDevice), __LINE__, VALIDATION_ERROR_00031, "Swapchain", "vkCreateDevice() called with a non-valid VkPhysicalDevice. %s", validation_error_map[VALIDATION_ERROR_00031]); } my_device_data->deviceMap[device].device = device; @@ -174,7 +174,7 @@ VKAPI_ATTR void VKAPI_CALL DestroyInstance(VkInstance instance, const VkAllocati if (pPhysicalDevice) { if (pPhysicalDevice->pDevice) { log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, - reinterpret_cast<uint64_t>(pPhysicalDevice->pDevice->device), __LINE__, VALIDATION_ERROR_00018, + HandleToUint64(pPhysicalDevice->pDevice->device), __LINE__, VALIDATION_ERROR_00018, swapchain_layer_name, "VkDestroyInstance() called before all of its associated VkDevices were destroyed. %s", validation_error_map[VALIDATION_ERROR_00018]); @@ -190,7 +190,7 @@ VKAPI_ATTR void VKAPI_CALL DestroyInstance(VkInstance instance, const VkAllocati SwpSurface *pSurface = it->second; if (pSurface) { log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, - reinterpret_cast<uint64_t>(pInstance->instance), __LINE__, VALIDATION_ERROR_00018, swapchain_layer_name, + HandleToUint64(pInstance->instance), __LINE__, VALIDATION_ERROR_00018, swapchain_layer_name, "VkDestroyInstance() called before all of its associated VkSurfaceKHRs were destroyed. %s", validation_error_map[VALIDATION_ERROR_00018]); } @@ -503,7 +503,7 @@ VKAPI_ATTR VkResult VKAPI_CALL GetDisplayPlaneSupportedDisplaysKHR(VkPhysicalDev if (!pPhysicalDevice->gotDisplayPlanePropertyCount) { skip_call |= log_msg(my_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, - reinterpret_cast<uint64_t>(pPhysicalDevice->pInstance->instance), __LINE__, + HandleToUint64(pPhysicalDevice->pInstance->instance), __LINE__, SWAPCHAIN_GET_SUPPORTED_DISPLAYS_WITHOUT_QUERY, swapchain_layer_name, "Potential problem with calling vkGetDisplayPlaneSupportedDisplaysKHR() without first " "querying vkGetPhysicalDeviceDisplayPlanePropertiesKHR."); @@ -512,8 +512,7 @@ VKAPI_ATTR VkResult VKAPI_CALL GetDisplayPlaneSupportedDisplaysKHR(VkPhysicalDev if (pPhysicalDevice->gotDisplayPlanePropertyCount && planeIndex >= pPhysicalDevice->displayPlanePropertyCount) { skip_call |= log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, - reinterpret_cast<uint64_t>(pPhysicalDevice->pInstance->instance), __LINE__, VALIDATION_ERROR_01857, - swapchain_layer_name, + HandleToUint64(pPhysicalDevice->pInstance->instance), __LINE__, VALIDATION_ERROR_01857, swapchain_layer_name, "vkGetDisplayPlaneSupportedDisplaysKHR(): planeIndex must be in the range [0, %d] that was returned by " "vkGetPhysicalDeviceDisplayPlanePropertiesKHR. Do you have the plane index hardcoded? %s", pPhysicalDevice->displayPlanePropertyCount - 1, validation_error_map[VALIDATION_ERROR_01857]); @@ -544,7 +543,7 @@ VKAPI_ATTR VkResult VKAPI_CALL GetDisplayPlaneCapabilitiesKHR(VkPhysicalDevice p if (!pPhysicalDevice->gotDisplayPlanePropertyCount) { skip_call |= log_msg(my_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, - reinterpret_cast<uint64_t>(pPhysicalDevice->pInstance->instance), __LINE__, + HandleToUint64(pPhysicalDevice->pInstance->instance), __LINE__, SWAPCHAIN_GET_SUPPORTED_DISPLAYS_WITHOUT_QUERY, swapchain_layer_name, "Potential problem with calling vkGetDisplayPlaneCapabilitiesKHR() without first " "querying vkGetPhysicalDeviceDisplayPlanePropertiesKHR."); @@ -552,8 +551,8 @@ VKAPI_ATTR VkResult VKAPI_CALL GetDisplayPlaneCapabilitiesKHR(VkPhysicalDevice p if (pPhysicalDevice->gotDisplayPlanePropertyCount && planeIndex >= pPhysicalDevice->displayPlanePropertyCount) { skip_call |= log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, - reinterpret_cast<uint64_t>(pPhysicalDevice->pInstance->instance), __LINE__, - SWAPCHAIN_PLANE_INDEX_TOO_LARGE, swapchain_layer_name, + HandleToUint64(pPhysicalDevice->pInstance->instance), __LINE__, SWAPCHAIN_PLANE_INDEX_TOO_LARGE, + swapchain_layer_name, "vkGetDisplayPlaneCapabilitiesKHR(): planeIndex must be in the range [0, %d] that was returned by " "vkGetPhysicalDeviceDisplayPlanePropertiesKHR. Do you have the plane index hardcoded?", pPhysicalDevice->displayPlanePropertyCount - 1); @@ -617,7 +616,7 @@ VKAPI_ATTR void VKAPI_CALL DestroySurfaceKHR(VkInstance instance, VkSurfaceKHR s } if (!pSurface->swapchains.empty()) { skip_call |= log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, - reinterpret_cast<uint64_t>(instance), __LINE__, VALIDATION_ERROR_01844, swapchain_layer_name, + HandleToUint64(instance), __LINE__, VALIDATION_ERROR_01844, swapchain_layer_name, "vkDestroySurfaceKHR() called before all of its associated VkSwapchainKHRs were destroyed. %s", validation_error_map[VALIDATION_ERROR_01844]); @@ -728,7 +727,7 @@ VKAPI_ATTR void VKAPI_CALL DestroyDevice(VkDevice device, const VkAllocationCall } if (!pDevice->swapchains.empty()) { log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, - reinterpret_cast<uint64_t>(device), __LINE__, VALIDATION_ERROR_00049, swapchain_layer_name, + HandleToUint64(device), __LINE__, VALIDATION_ERROR_00049, swapchain_layer_name, "vkDestroyDevice() called before all of its associated VkSwapchainKHRs were destroyed. %s", validation_error_map[VALIDATION_ERROR_00049]); @@ -841,12 +840,12 @@ VKAPI_ATTR VkResult VKAPI_CALL GetSwapchainImagesKHR(VkDevice device, VkSwapchai // Since we haven't recorded a preliminary value of *pSwapchainImageCount, that likely means that the application didn't // previously call this function with a NULL value of pSwapchainImages: skip_call |= log_msg(my_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, - reinterpret_cast<uint64_t>(device), __LINE__, SWAPCHAIN_PRIOR_COUNT, swapchain_layer_name, + HandleToUint64(device), __LINE__, SWAPCHAIN_PRIOR_COUNT, swapchain_layer_name, "vkGetSwapchainImagesKHR() called with non-NULL pSwapchainImageCount; but no prior positive " "value has been seen for pSwapchainImages."); } else if (*pSwapchainImageCount > pSwapchain->imageCount) { skip_call |= log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, - reinterpret_cast<uint64_t>(device), __LINE__, SWAPCHAIN_INVALID_COUNT, swapchain_layer_name, + HandleToUint64(device), __LINE__, SWAPCHAIN_INVALID_COUNT, swapchain_layer_name, "vkGetSwapchainImagesKHR() called with non-NULL pSwapchainImageCount, and with " "pSwapchainImages set to a value (%d) that is greater than the value (%d) that was returned when " "pSwapchainImageCount was NULL.", |
