From 3ea2774ed27ca451851bdab5ac2a2d3593af119a Mon Sep 17 00:00:00 2001 From: Tobin Ehlis Date: Tue, 6 Dec 2016 08:26:05 -0700 Subject: layers:Refactor GetFenceStatus in core_validation Refactor GetFenceStatus to use Pre/Post pattern. --- layers/core_validation.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'layers/core_validation.cpp') diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp index cf2c6ef1..71e937d9 100644 --- a/layers/core_validation.cpp +++ b/layers/core_validation.cpp @@ -5254,23 +5254,27 @@ WaitForFences(VkDevice device, uint32_t fenceCount, const VkFence *pFences, VkBo return result; } +static bool PreCallValidateGetFenceStatus(layer_data *dev_data, VkFence fence) { + return verifyWaitFenceState(dev_data, fence, "vkGetFenceStatus"); +} + +static bool PostCallRecordGetFenceStatus(layer_data *dev_data, VkFence fence) { return RetireFence(dev_data, fence); } + VKAPI_ATTR VkResult VKAPI_CALL GetFenceStatus(VkDevice device, VkFence fence) { layer_data *dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); - bool skip_call = false; std::unique_lock lock(global_lock); - skip_call = verifyWaitFenceState(dev_data, fence, "vkGetFenceStatus"); + bool skip = PreCallValidateGetFenceStatus(dev_data, fence); lock.unlock(); - - if (skip_call) + if (skip) return VK_ERROR_VALIDATION_FAILED_EXT; VkResult result = dev_data->dispatch_table.GetFenceStatus(device, fence); - lock.lock(); if (result == VK_SUCCESS) { - skip_call |= RetireFence(dev_data, fence); + lock.lock(); + skip |= PostCallRecordGetFenceStatus(dev_data, fence); + lock.unlock(); } - lock.unlock(); - if (skip_call) + if (skip) return VK_ERROR_VALIDATION_FAILED_EXT; return result; } -- cgit v1.2.3