Flutter Engine
The Flutter Engine
Namespaces | Macros | Functions
GrVkUtil.h File Reference
#include "include/gpu/GrTypes.h"
#include "include/gpu/vk/GrVkTypes.h"
#include "include/private/base/SkMacros.h"
#include "include/private/gpu/ganesh/GrTypesPriv.h"
#include "src/gpu/ganesh/GrColor.h"
#include "src/gpu/ganesh/GrDataUtils.h"
#include "src/gpu/vk/VulkanInterface.h"
#include "src/sksl/ir/SkSLProgram.h"

Go to the source code of this file.

Namespaces

namespace  SkSL
 

Macros

#define GR_VK_CALL(IFACE, X)   (IFACE)->fFunctions.f##X
 
#define GR_VK_LOG_IF_NOT_SUCCESS(GPU, RESULT, X, ...)
 
#define GR_VK_CALL_RESULT(GPU, RESULT, X)
 
#define GR_VK_CALL_RESULT_NOCHECK(GPU, RESULT, X)
 
#define GR_VK_CALL_ERRCHECK(GPU, X)
 

Functions

bool GrVkFormatIsSupported (VkFormat)
 
static constexpr GrColorFormatDesc GrVkFormatDesc (VkFormat vkFormat)
 
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)
 
bool GrInstallVkShaderModule (GrVkGpu *gpu, const std::string &spirv, VkShaderStageFlagBits stage, VkShaderModule *shaderModule, VkPipelineShaderStageCreateInfo *stageInfo)
 

Macro Definition Documentation

◆ GR_VK_CALL

#define GR_VK_CALL (   IFACE,
  X 
)    (IFACE)->fFunctions.f##X

Definition at line 24 of file GrVkUtil.h.

◆ GR_VK_CALL_ERRCHECK

#define GR_VK_CALL_ERRCHECK (   GPU,
  X 
)
Value:
GR_VK_CALL_RESULT(GPU, SK_MACRO_APPEND_LINE(ret), X) \
#define SK_MACRO_APPEND_LINE(name)
Definition: SkMacros.h:25
constexpr SkSLTestFlags GPU
Definition: SkSLTest.cpp:957
static const SkScalar X
Definition: StrokeBench.cpp:54
VkResult
Definition: vulkan_core.h:140

Definition at line 50 of file GrVkUtil.h.

◆ GR_VK_CALL_RESULT

#define GR_VK_CALL_RESULT (   GPU,
  RESULT,
  X 
)
Value:
do { \
(RESULT) = GR_VK_CALL(GPU->vkInterface(), X); \
GR_VK_LOG_IF_NOT_SUCCESS(GPU, RESULT, #X); \
GPU->checkVkResult(RESULT); \
} while (false)
#define GR_VK_CALL(IFACE, X)
Definition: GrVkUtil.h:24
#define RESULT(Op)
@ VK_ERROR_DEVICE_LOST
Definition: vulkan_core.h:150
@ VK_SUCCESS
Definition: vulkan_core.h:141

Definition at line 35 of file GrVkUtil.h.

◆ GR_VK_CALL_RESULT_NOCHECK

#define GR_VK_CALL_RESULT_NOCHECK (   GPU,
  RESULT,
  X 
)
Value:
do { \
(RESULT) = GR_VK_CALL(GPU->vkInterface(), X); \
GPU->checkVkResult(RESULT); \
} while (false)

Definition at line 43 of file GrVkUtil.h.

◆ GR_VK_LOG_IF_NOT_SUCCESS

#define GR_VK_LOG_IF_NOT_SUCCESS (   GPU,
  RESULT,
  X,
  ... 
)
Value:
do { \
if (RESULT != VK_SUCCESS && !GPU->isDeviceLost()) { \
SkDebugf("Failed vulkan call. Error: %d, " X "\n", RESULT, ##__VA_ARGS__); \
} \
} while (false)

Definition at line 28 of file GrVkUtil.h.

Function Documentation

◆ GrCompileVkShaderModule()

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 at line 64 of file GrVkUtil.cpp.

71 {
72 TRACE_EVENT0("skia.shaders", "CompileVkShaderModule");
75 shaderString,
78 outSPIRV,
79 outInterface,
80 errorHandler)) {
81 return false;
82 }
83
84 return GrInstallVkShaderModule(gpu, *outSPIRV, stage, shaderModule, stageInfo);
85}
SkSL::ProgramKind vk_shader_stage_to_skiasl_kind(VkShaderStageFlagBits stage)
Definition: GrVkUtil.cpp:56
bool GrInstallVkShaderModule(GrVkGpu *gpu, const std::string &spirv, VkShaderStageFlagBits stage, VkShaderModule *shaderModule, VkPipelineShaderStageCreateInfo *stageInfo)
Definition: GrVkUtil.cpp:87
GrContextOptions::ShaderErrorHandler * getShaderErrorHandler() const
const GrShaderCaps * shaderCaps() const
Definition: GrCaps.h:63
GrDirectContextPriv priv()
GrDirectContext * getContext()
Definition: GrGpu.h:67
const GrVkCaps & vkCaps() const
Definition: GrVkGpu.h:61
bool SkSLToSPIRV(const SkSL::ShaderCaps *caps, const std::string &sksl, SkSL::ProgramKind programKind, const SkSL::ProgramSettings &settings, std::string *spirv, SkSL::ProgramInterface *outInterface, ShaderErrorHandler *errorHandler)
#define TRACE_EVENT0(category_group, name)
Definition: trace_event.h:131

◆ GrInstallVkShaderModule()

bool GrInstallVkShaderModule ( GrVkGpu gpu,
const std::string &  spirv,
VkShaderStageFlagBits  stage,
VkShaderModule *  shaderModule,
VkPipelineShaderStageCreateInfo stageInfo 
)

Definition at line 87 of file GrVkUtil.cpp.

91 {
92 TRACE_EVENT0("skia.shaders", "InstallVkShaderModule");
93 VkShaderModuleCreateInfo moduleCreateInfo;
94 memset(&moduleCreateInfo, 0, sizeof(VkShaderModuleCreateInfo));
96 moduleCreateInfo.pNext = nullptr;
97 moduleCreateInfo.flags = 0;
98 moduleCreateInfo.codeSize = spirv.size();
99 moduleCreateInfo.pCode = (const uint32_t*)spirv.c_str();
100
101 VkResult err;
102 GR_VK_CALL_RESULT(gpu, err, CreateShaderModule(gpu->device(), &moduleCreateInfo, nullptr,
103 shaderModule));
104 if (err) {
105 return false;
106 }
107
108 memset(stageInfo, 0, sizeof(VkPipelineShaderStageCreateInfo));
110 stageInfo->pNext = nullptr;
111 stageInfo->flags = 0;
112 stageInfo->stage = stage;
113 stageInfo->module = *shaderModule;
114 stageInfo->pName = "main";
115 stageInfo->pSpecializationInfo = nullptr;
116
117 return true;
118}
#define GR_VK_CALL_RESULT(GPU, RESULT, X)
Definition: GrVkUtil.h:35
VkDevice device() const
Definition: GrVkGpu.h:71
VkPipelineShaderStageCreateFlags flags
Definition: vulkan_core.h:3509
const VkSpecializationInfo * pSpecializationInfo
Definition: vulkan_core.h:3513
VkShaderStageFlagBits stage
Definition: vulkan_core.h:3510
VkShaderModuleCreateFlags flags
Definition: vulkan_core.h:3480
const uint32_t * pCode
Definition: vulkan_core.h:3482
VkStructureType sType
Definition: vulkan_core.h:3478
@ VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO
Definition: vulkan_core.h:218
@ VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO
Definition: vulkan_core.h:220

◆ GrVkFormatDesc()

static constexpr GrColorFormatDesc GrVkFormatDesc ( VkFormat  vkFormat)
staticconstexpr

Definition at line 57 of file GrVkUtil.h.

57 {
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}
static constexpr GrColorFormatDesc MakeInvalid()
Definition: GrTypesPriv.h:756
static constexpr GrColorFormatDesc MakeRGBA(int rgba, GrColorTypeEncoding e)
Definition: GrTypesPriv.h:720
static constexpr GrColorFormatDesc MakeRG(int rg, GrColorTypeEncoding e)
Definition: GrTypesPriv.h:744
static constexpr GrColorFormatDesc MakeRGB(int rgb, GrColorTypeEncoding e)
Definition: GrTypesPriv.h:728
static constexpr GrColorFormatDesc MakeR(int r, GrColorTypeEncoding e)
Definition: GrTypesPriv.h:740
@ VK_FORMAT_R16G16B16A16_UNORM
Definition: vulkan_core.h:1550
@ VK_FORMAT_R8G8B8A8_SRGB
Definition: vulkan_core.h:1502
@ VK_FORMAT_R8G8B8_UNORM
Definition: vulkan_core.h:1482
@ VK_FORMAT_D24_UNORM_S8_UINT
Definition: vulkan_core.h:1588
@ VK_FORMAT_B8G8R8A8_UNORM
Definition: vulkan_core.h:1503
@ VK_FORMAT_R16G16_SFLOAT
Definition: vulkan_core.h:1542
@ VK_FORMAT_B4G4R4A4_UNORM_PACK16
Definition: vulkan_core.h:1462
@ VK_FORMAT_R16_SFLOAT
Definition: vulkan_core.h:1535
@ VK_FORMAT_R8G8_UNORM
Definition: vulkan_core.h:1475
@ VK_FORMAT_S8_UINT
Definition: vulkan_core.h:1586
@ VK_FORMAT_R8_UNORM
Definition: vulkan_core.h:1468
@ VK_FORMAT_R5G6B5_UNORM_PACK16
Definition: vulkan_core.h:1463
@ VK_FORMAT_R4G4B4A4_UNORM_PACK16
Definition: vulkan_core.h:1461
@ VK_FORMAT_A2B10G10R10_UNORM_PACK32
Definition: vulkan_core.h:1523
@ VK_FORMAT_R8G8B8A8_UNORM
Definition: vulkan_core.h:1496
@ VK_FORMAT_BC1_RGB_UNORM_BLOCK
Definition: vulkan_core.h:1590
@ VK_FORMAT_R16_UNORM
Definition: vulkan_core.h:1529
@ VK_FORMAT_R16G16B16A16_SFLOAT
Definition: vulkan_core.h:1556
@ VK_FORMAT_R16G16_UNORM
Definition: vulkan_core.h:1536
@ VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK
Definition: vulkan_core.h:1606
@ VK_FORMAT_A2R10G10B10_UNORM_PACK32
Definition: vulkan_core.h:1517
@ VK_FORMAT_BC1_RGBA_UNORM_BLOCK
Definition: vulkan_core.h:1592
@ VK_FORMAT_B5G6R5_UNORM_PACK16
Definition: vulkan_core.h:1464
@ VK_FORMAT_D32_SFLOAT_S8_UINT
Definition: vulkan_core.h:1589

◆ GrVkFormatIsSupported()

bool GrVkFormatIsSupported ( VkFormat  format)

Definition at line 21 of file GrVkUtil.cpp.

21 {
22 switch (format) {
50 return true;
51 default:
52 return false;
53 }
54}
uint32_t uint32_t * format
@ VK_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16
Definition: vulkan_core.h:1657
@ VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM
Definition: vulkan_core.h:1646
@ VK_FORMAT_G8_B8R8_2PLANE_420_UNORM
Definition: vulkan_core.h:1647