Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
VulkanGraphiteUtilsPriv.h
Go to the documentation of this file.
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/core/SkSpan.h"
16
17#include <string>
18
19// Helper macros to call functions on the VulkanInterface without checking for errors. Note: This
20// cannot require a VulkanSharedContext because driver calls are needed before the shared context
21// has been initialized.
22#define VULKAN_CALL(IFACE, X) (IFACE)->fFunctions.f##X
23
24// Must be called before checkVkResult, since this does not log if the VulkanSharedContext is
25// already considering the device to be lost.
26#define VULKAN_LOG_IF_NOT_SUCCESS(SHARED_CONTEXT, RESULT, X, ...) \
27 do { \
28 if (RESULT != VK_SUCCESS && !(SHARED_CONTEXT)->isDeviceLost()) { \
29 SkDebugf("Failed vulkan call. Error: %d, " X "\n", RESULT, ##__VA_ARGS__); \
30 } \
31 } while (false)
32
33#define VULKAN_CALL_RESULT(SHARED_CONTEXT, RESULT, X) \
34 do { \
35 (RESULT) = VULKAN_CALL((SHARED_CONTEXT)->interface(), X); \
36 SkASSERT(VK_SUCCESS == RESULT || VK_ERROR_DEVICE_LOST == RESULT); \
37 VULKAN_LOG_IF_NOT_SUCCESS(SHARED_CONTEXT, RESULT, #X); \
38 (SHARED_CONTEXT)->checkVkResult(RESULT); \
39 } while (false)
40
41// same as VULKAN_CALL but checks for success
42#define VULKAN_CALL_ERRCHECK(SHARED_CONTEXT, X) \
43 VkResult SK_MACRO_APPEND_LINE(ret); \
44 VULKAN_CALL_RESULT(SHARED_CONTEXT, SK_MACRO_APPEND_LINE(ret), X)
45
46#define VULKAN_CALL_RESULT_NOCHECK(IFACE, RESULT, X) \
47 do { \
48 (RESULT) = VULKAN_CALL(IFACE, X); \
49 } while (false)
50namespace skgpu::graphite {
51
52class VulkanSharedContext;
53
54VkShaderModule createVulkanShaderModule(const VulkanSharedContext*,
55 const std::string& spirv,
57
59void DescriptorDataToVkDescSetLayout(const VulkanSharedContext*,
61 VkDescriptorSetLayout*);
62
64
66
67} // namespace skgpu::graphite
68
69#endif // skgpu_graphite_VulkanGraphiteUtilsPriv_DEFINED
VkShaderModule createVulkanShaderModule(const VulkanSharedContext *context, const std::string &spirv, VkShaderStageFlagBits stage)
VkDescriptorType DsTypeEnumToVkDs(DescriptorType type)
bool vkFormatIsSupported(VkFormat format)
void DescriptorDataToVkDescSetLayout(const VulkanSharedContext *ctxt, const SkSpan< DescriptorData > &requestedDescriptors, VkDescriptorSetLayout *outLayout)
VkShaderStageFlags PipelineStageFlagsToVkShaderStageFlags(SkEnumBitMask< PipelineStageFlags > stageFlags)
VkShaderStageFlagBits
VkFlags VkShaderStageFlags
VkDescriptorType
VkFormat