Flutter Engine
The Flutter Engine
GrVkUtil.cpp
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
9
20
22 switch (format) {
50 return true;
51 default:
52 return false;
53 }
54}
55
57 if (VK_SHADER_STAGE_VERTEX_BIT == stage) {
59 }
62}
63
65 const std::string& shaderString,
67 VkShaderModule* shaderModule,
70 std::string* outSPIRV,
71 SkSL::Program::Interface* outInterface) {
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}
86
88 const std::string& spirv,
90 VkShaderModule* shaderModule,
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}
119
bool GrVkFormatIsSupported(VkFormat format)
Definition: GrVkUtil.cpp:21
SkSL::ProgramKind vk_shader_stage_to_skiasl_kind(VkShaderStageFlagBits stage)
Definition: GrVkUtil.cpp:56
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
#define GR_VK_CALL_RESULT(GPU, RESULT, X)
Definition: GrVkUtil.h:35
#define SkASSERT(cond)
Definition: SkAssert.h:116
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
VkDevice device() const
Definition: GrVkGpu.h:71
uint32_t uint32_t * format
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)
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
#define TRACE_EVENT0(category_group, name)
Definition: trace_event.h:131
VkShaderStageFlagBits
Definition: vulkan_core.h:2664
@ VK_SHADER_STAGE_VERTEX_BIT
Definition: vulkan_core.h:2665
@ VK_SHADER_STAGE_FRAGMENT_BIT
Definition: vulkan_core.h:2669
VkResult
Definition: vulkan_core.h:140
VkFormat
Definition: vulkan_core.h:1458
@ 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_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16
Definition: vulkan_core.h:1657
@ 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_G8_B8_R8_3PLANE_420_UNORM
Definition: vulkan_core.h:1646
@ 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_G8_B8R8_2PLANE_420_UNORM
Definition: vulkan_core.h:1647
@ VK_FORMAT_B5G6R5_UNORM_PACK16
Definition: vulkan_core.h:1464
@ VK_FORMAT_D32_SFLOAT_S8_UINT
Definition: vulkan_core.h:1589
@ 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