aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Elliott <ianelliott@google.com>2016-03-23 08:28:54 -0600
committerIan Elliott <ianelliott@google.com>2016-03-23 08:53:00 -0600
commit2a4a6e609cee2c5f10d0020e3e8a56e877a7b87d (patch)
treef9df1f31fe14b1927c300e5b80863f3dd719b7e8
parent51940e40346835ebbf3a3fb8c06c07a3eb518e7b (diff)
downloadvulkan-validation-layers-2a4a6e609cee2c5f10d0020e3e8a56e877a7b87d.tar.gz
layers: GH117: swapchain layer warns if app uses neither semaphore nor fence.
This addresses github issue #117. Applications should call vkAcquireNextImageKHR with either a valid semaphore and/or fence. Issue a warning if both are set to VK_NULL_HANDLE.
-rw-r--r--layers/swapchain.cpp5
-rw-r--r--layers/swapchain.h5
-rw-r--r--layers/vk_validation_layer_details.md1
3 files changed, 11 insertions, 0 deletions
diff --git a/layers/swapchain.cpp b/layers/swapchain.cpp
index d513208f5..84bcaad1e 100644
--- a/layers/swapchain.cpp
+++ b/layers/swapchain.cpp
@@ -1743,6 +1743,11 @@ VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkAcquireNextImageKHR(VkDevice de
"%s() called even though the %s extension was not enabled for this VkDevice.", __FUNCTION__,
VK_KHR_SWAPCHAIN_EXTENSION_NAME);
}
+ if ((semaphore == VK_NULL_HANDLE) && (fence == VK_NULL_HANDLE)) {
+ skipCall |= LOG_WARNING(VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, device, "VkDevice", SWAPCHAIN_NO_SYNC_FOR_ACQUIRE,
+ "%s() called with both the semaphore and fence parameters set to "
+ "VK_NULL_HANDLE (at least one should be used).", __FUNCTION__);
+ }
SwpSwapchain *pSwapchain = &my_data->swapchainMap[swapchain];
if (pSwapchain) {
// Look to see if the application is trying to own too many images at
diff --git a/layers/swapchain.h b/layers/swapchain.h
index ed86b0fad..e6c1f4a13 100644
--- a/layers/swapchain.h
+++ b/layers/swapchain.h
@@ -79,6 +79,7 @@ typedef enum _SWAPCHAIN_ERROR {
// vkGetPhysicalDeviceQueueFamilyProperties()
SWAPCHAIN_SURFACE_NOT_SUPPORTED_WITH_QUEUE, // A surface is not supported by a given queueFamilyIndex, as seen by
// vkGetPhysicalDeviceSurfaceSupportKHR()
+ SWAPCHAIN_NO_SYNC_FOR_ACQUIRE, // vkAcquireNextImageKHR should be called with a valid semaphore and/or fence
} SWAPCHAIN_ERROR;
// The following is for logging error messages:
@@ -124,6 +125,10 @@ typedef enum _SWAPCHAIN_ERROR {
(my_data) ? log_msg(my_data->report_data, VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, (objType), (uint64_t)(obj), __LINE__, \
(enm), LAYER_NAME, (fmt), __VA_ARGS__) \
: VK_FALSE
+#define LOG_WARNING(objType, type, obj, enm, fmt, ...) \
+ (my_data) ? log_msg(my_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, (objType), (uint64_t)(obj), __LINE__, (enm), \
+ LAYER_NAME, (fmt), __VA_ARGS__) \
+ : VK_FALSE
#define LOG_INFO_WRONG_NEXT(objType, type, obj) \
(my_data) ? log_msg(my_data->report_data, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, (objType), (uint64_t)(obj), 0, \
SWAPCHAIN_WRONG_NEXT, LAYER_NAME, "%s() called with non-NULL value for %s->pNext.", __FUNCTION__, (obj)) \
diff --git a/layers/vk_validation_layer_details.md b/layers/vk_validation_layer_details.md
index 7754e2b34..7042cf165 100644
--- a/layers/vk_validation_layer_details.md
+++ b/layers/vk_validation_layer_details.md
@@ -385,6 +385,7 @@ This layer is a work in progress. VK_LAYER_LUNARG_swapchain layer is intended to
| Valid use of queueFamilyIndex | Validates that a queueFamilyIndex not used before vkGetPhysicalDeviceQueueFamilyProperties() was called | DID_NOT_QUERY_QUEUE_FAMILIES | vkGetPhysicalDeviceSurfaceSupportKHR | NA | None |
| Valid queueFamilyIndex value | Validates that a queueFamilyIndex value is less-than pQueueFamilyPropertyCount returned by vkGetPhysicalDeviceQueueFamilyProperties | QUEUE_FAMILY_INDEX_TOO_LARGE | vkGetPhysicalDeviceSurfaceSupportKHR | NA | None |
| Supported combination of queue and surface | Validates that the surface associated with a swapchain was seen to support the queueFamilyIndex of a given queue | SURFACE_NOT_SUPPORTED_WITH_QUEUE | vkQueuePresentKHR | NA | None |
+| Proper synchronization of acquired images | vkAcquireNextImageKHR should be called with a valid semaphore and/or fence | NO_SYNC_FOR_ACQUIRE | vkAcquireNextImageKHR | NA | None |
Note: The following platform-specific functions are not mentioned above, because they are protected by ifdefs, which cause test failures: