From 44655aa0ce83e9d2e09f76198a96588bc763b3c1 Mon Sep 17 00:00:00 2001 From: Tobin Ehlis Date: Thu, 8 Feb 2018 13:30:56 -0700 Subject: layers:Add sparse mem warning if reqs not checked If vkQueueBindSparse() is called to bind sparse memory to an image, trigger a warning if the user has not queried sparse requirements for that image. --- layers/core_validation.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'layers/core_validation.cpp') diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp index 22c963d6..466007aa 100644 --- a/layers/core_validation.cpp +++ b/layers/core_validation.cpp @@ -9744,6 +9744,33 @@ static bool PreCallValidateQueueBindSparse(layer_data *dev_data, VkQueue queue, } } } + // Store sparse binding image_state and after binding is complete make sure that any requiring metadata have it bound + std::unordered_set sparse_images; + // If we're binding sparse image memory make sure reqs were queried and note if metadata is required and bound + for (uint32_t i = 0; i < bindInfo.imageBindCount; ++i) { + const auto &opaque_bind = bindInfo.pImageOpaqueBinds[i]; + auto image_state = GetImageState(dev_data, opaque_bind.image); + sparse_images.insert(image_state); + if (!image_state->get_sparse_reqs_called || image_state->sparse_requirements.empty()) { + // For now just warning if sparse image binding occurs without calling to get reqs first + return log_msg(dev_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, + HandleToUint64(image_state->image), __LINE__, MEMTRACK_INVALID_STATE, "CV", + "vkQueueBindSparse(): Binding sparse memory to image 0x%" PRIx64 + " without first calling vkGetImageSparseMemoryRequirements[2KHR]() to retrieve requirements.", + HandleToUint64(image_state->image)); + } + } + for (uint32_t i = 0; i < bindInfo.imageOpaqueBindCount; ++i) { + auto image_state = GetImageState(dev_data, bindInfo.pImageOpaqueBinds[i].image); + if (!image_state->get_sparse_reqs_called || image_state->sparse_requirements.empty()) { + // For now just warning if sparse image binding occurs without calling to get reqs first + return log_msg(dev_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, + HandleToUint64(image_state->image), __LINE__, MEMTRACK_INVALID_STATE, "CV", + "vkQueueBindSparse(): Binding opaque sparse memory to image 0x%" PRIx64 + " without first calling vkGetImageSparseMemoryRequirements[2KHR]() to retrieve requirements.", + HandleToUint64(image_state->image)); + } + } } return skip; -- cgit v1.2.3