1 /* 2 * Copyright 2022 Google LLC 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 #ifndef skgpu_graphite_VulkanGraphiteUtilsPriv_DEFINED 9 #define skgpu_graphite_VulkanGraphiteUtilsPriv_DEFINED 10 11 #include "include/gpu/vk/VulkanTypes.h" 12 #include "src/gpu/graphite/Log.h" 13 #include "src/gpu/vk/VulkanInterface.h" 14 15 // Helper macros to call functions on the VulkanInterface 16 #define VULKAN_CALL(IFACE, X) (IFACE)->fFunctions.f##X 17 18 // TODO: This needs to add checks for device lost on calls. See Ganesh version 19 #define VULKAN_CALL_RESULT(IFACE, RESULT, X) \ 20 do { \ 21 (RESULT) = VULKAN_CALL(IFACE, X); \ 22 SkASSERT(VK_SUCCESS == RESULT || VK_ERROR_DEVICE_LOST == RESULT); \ 23 if (RESULT != VK_SUCCESS) { \ 24 SKGPU_LOG_E("Failed vulkan call. Error: %d," #X "\n", RESULT); \ 25 } \ 26 } while (false) 27 28 // same as VULKAN_CALL but checks for success 29 #define VULKAN_CALL_ERRCHECK(IFACE, X) \ 30 VkResult SK_MACRO_APPEND_LINE(ret); \ 31 VULKAN_CALL_RESULT(IFACE, SK_MACRO_APPEND_LINE(ret), X) 32 33 #define VULKAN_CALL_RESULT_NOCHECK(IFACE, RESULT, X) \ 34 do { \ 35 (RESULT) = VULKAN_CALL(IFACE, X); \ 36 } while (false) 37 38 39 #endif // skgpu_graphite_VulkanGraphiteUtilsPriv_DEFINED 40