Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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
static const SkScalar X
VkResult

Definition at line 50 of file GrVkUtil.h.

56 {
57 switch (vkFormat) {
94
95 // Compressed texture formats are not expected to have a description.
99
100 // This type only describes color channels.
104
105 default: return GrColorFormatDesc::MakeInvalid();
106 }
107}
108
110 const std::string& shaderString,
112 VkShaderModule* shaderModule,
114 const SkSL::ProgramSettings& settings,
115 std::string* outSPIRV,
116 SkSL::Program::Interface* outInterface);
117
119 const std::string& spirv,
121 VkShaderModule* shaderModule,
123
124#endif
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 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
@ 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

◆ 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)
constexpr SkSLTestFlags GPU
Definition SkSLTest.cpp:952
@ VK_ERROR_DEVICE_LOST
@ VK_SUCCESS

Definition at line 35 of file GrVkUtil.h.

36 { \
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)

◆ 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.

44 { \
45 (RESULT) = GR_VK_CALL(GPU->vkInterface(), X); \
46 GPU->checkVkResult(RESULT); \
47 } while (false)

◆ 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.

29 { \
30 if (RESULT != VK_SUCCESS && !GPU->isDeviceLost()) { \
31 SkDebugf("Failed vulkan call. Error: %d, " X "\n", RESULT, ##__VA_ARGS__); \
32 } \
33 } while (false)

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,
77 settings,
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)

◆ 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
const VkSpecializationInfo * pSpecializationInfo
VkShaderModule const char * pName
VkShaderStageFlagBits stage
VkShaderModuleCreateFlags flags
const uint32_t * pCode
@ VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO
@ VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO

◆ 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}

◆ 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
@ VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM
@ VK_FORMAT_G8_B8R8_2PLANE_420_UNORM