Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
GrVkUtil.h
Go to the documentation of this file.
1/*
2 * Copyright 2015 Google Inc.
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 GrVkUtil_DEFINED
9#define GrVkUtil_DEFINED
10
11#include "include/gpu/GrTypes.h"
19
20namespace SkSL { struct ProgramSettings; }
21class GrVkGpu;
22
23// makes a Vk call on the interface
24#define GR_VK_CALL(IFACE, X) (IFACE)->fFunctions.f##X
25
26// Note: must be called before checkVkResult, since this does not log if the GPU is already
27// considering the device to be lost.
28#define GR_VK_LOG_IF_NOT_SUCCESS(GPU, RESULT, X, ...) \
29 do { \
30 if (RESULT != VK_SUCCESS && !GPU->isDeviceLost()) { \
31 SkDebugf("Failed vulkan call. Error: %d, " X "\n", RESULT, ##__VA_ARGS__); \
32 } \
33 } while (false)
34
35#define GR_VK_CALL_RESULT(GPU, RESULT, X) \
36 do { \
37 (RESULT) = GR_VK_CALL(GPU->vkInterface(), X); \
38 SkASSERT(VK_SUCCESS == RESULT || VK_ERROR_DEVICE_LOST == RESULT); \
39 GR_VK_LOG_IF_NOT_SUCCESS(GPU, RESULT, #X); \
40 GPU->checkVkResult(RESULT); \
41 } while (false)
42
43#define GR_VK_CALL_RESULT_NOCHECK(GPU, RESULT, X) \
44 do { \
45 (RESULT) = GR_VK_CALL(GPU->vkInterface(), X); \
46 GPU->checkVkResult(RESULT); \
47 } while (false)
48
49// same as GR_VK_CALL but checks for success
50#define GR_VK_CALL_ERRCHECK(GPU, X) \
51 VkResult SK_MACRO_APPEND_LINE(ret); \
52 GR_VK_CALL_RESULT(GPU, SK_MACRO_APPEND_LINE(ret), X) \
53
54
56
57static constexpr GrColorFormatDesc GrVkFormatDesc(VkFormat vkFormat) {
58 switch (vkFormat) {
95
96 // Compressed texture formats are not expected to have a description.
100
101 // This type only describes color channels.
105
106 default: return GrColorFormatDesc::MakeInvalid();
107 }
108}
109
111 const std::string& shaderString,
113 VkShaderModule* shaderModule,
115 const SkSL::ProgramSettings& settings,
116 std::string* outSPIRV,
117 SkSL::Program::Interface* outInterface);
118
120 const std::string& spirv,
122 VkShaderModule* shaderModule,
124
125#endif
bool GrVkFormatIsSupported(VkFormat)
Definition GrVkUtil.cpp:21
bool GrCompileVkShaderModule(GrVkGpu *gpu, const std::string &shaderString, VkShaderStageFlagBits stage, VkShaderModule *shaderModule, VkPipelineShaderStageCreateInfo *stageInfo, const SkSL::ProgramSettings &settings, std::string *outSPIRV, SkSL::Program::Interface *outInterface)
Definition GrVkUtil.cpp:64
bool GrInstallVkShaderModule(GrVkGpu *gpu, const std::string &spirv, VkShaderStageFlagBits stage, VkShaderModule *shaderModule, VkPipelineShaderStageCreateInfo *stageInfo)
Definition GrVkUtil.cpp:87
static constexpr GrColorFormatDesc GrVkFormatDesc(VkFormat vkFormat)
Definition GrVkUtil.h:57
static constexpr GrColorFormatDesc MakeInvalid()
static constexpr GrColorFormatDesc MakeRGBA(int rgba, GrColorTypeEncoding e)
static constexpr GrColorFormatDesc MakeRG(int rg, GrColorTypeEncoding e)
static constexpr GrColorFormatDesc MakeRGB(int rgb, GrColorTypeEncoding e)
static constexpr GrColorFormatDesc MakeR(int r, GrColorTypeEncoding e)
VkShaderStageFlagBits
VkFormat
@ VK_FORMAT_R16G16B16A16_UNORM
@ VK_FORMAT_R8G8B8A8_SRGB
@ VK_FORMAT_R8G8B8_UNORM
@ VK_FORMAT_D24_UNORM_S8_UINT
@ VK_FORMAT_B8G8R8A8_UNORM
@ VK_FORMAT_R16G16_SFLOAT
@ VK_FORMAT_B4G4R4A4_UNORM_PACK16
@ VK_FORMAT_R16_SFLOAT
@ VK_FORMAT_R8G8_UNORM
@ VK_FORMAT_S8_UINT
@ VK_FORMAT_R8_UNORM
@ VK_FORMAT_R5G6B5_UNORM_PACK16
@ VK_FORMAT_R4G4B4A4_UNORM_PACK16
@ VK_FORMAT_A2B10G10R10_UNORM_PACK32
@ VK_FORMAT_R8G8B8A8_UNORM
@ VK_FORMAT_BC1_RGB_UNORM_BLOCK
@ VK_FORMAT_R16_UNORM
@ VK_FORMAT_R16G16B16A16_SFLOAT
@ VK_FORMAT_R16G16_UNORM
@ VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK
@ VK_FORMAT_A2R10G10B10_UNORM_PACK32
@ VK_FORMAT_BC1_RGBA_UNORM_BLOCK
@ VK_FORMAT_B5G6R5_UNORM_PACK16
@ VK_FORMAT_D32_SFLOAT_S8_UINT