89 SK_ABORT(
"Unknown vertex attrib type");
100 size_t vertexAttributeOffset = 0;
101 for (
auto attrib : vertexAttrs) {
106 vkAttrib.
offset = vertexAttributeOffset;
107 vertexAttributeOffset += attrib.sizeAlign4();
111 size_t instanceAttributeOffset = 0;
112 for (
auto attrib : instanceAttrs) {
117 vkAttrib.
offset = instanceAttributeOffset;
118 instanceAttributeOffset += attrib.sizeAlign4();
122 if (bindingDescs && !vertexAttrs.
empty()) {
125 (uint32_t) vertexAttributeOffset,
129 if (bindingDescs && !instanceAttrs.
empty()) {
132 (uint32_t) instanceAttributeOffset,
139 vertexInputInfo->
pNext =
nullptr;
140 vertexInputInfo->
flags = 0;
150 switch (primitiveType) {
165 inputAssemblyInfo->
pNext =
nullptr;
166 inputAssemblyInfo->
flags = 0;
192 return gTable[(
int)op];
217 return gTable[(
int)op];
222 uint32_t referenceValue) {
239 stencilInfo->
pNext =
nullptr;
240 stencilInfo->
flags = 0;
261 viewportInfo->
pNext =
nullptr;
262 viewportInfo->
flags = 0;
277 multisampleInfo->
pNext =
nullptr;
278 multisampleInfo->
flags = 0;
376 return gTable[(
int)equation];
407 colorBlendInfo->
pNext =
nullptr;
408 colorBlendInfo->
flags = 0;
419 rasterInfo->
pNext =
nullptr;
420 rasterInfo->
flags = 0;
434 VkShaderModule shaderModule,
438 shaderStageInfo->
pNext =
nullptr;
439 shaderStageInfo->
flags = 0;
440 shaderStageInfo->
stage = stage;
441 shaderStageInfo->
module = shaderModule;
442 shaderStageInfo->
pName =
"main";
451 VkDescriptorSetLayout setLayout;
454 SKGPU_LOG_E(
"Failed to create descriptor set layout; pipeline creation will fail.\n");
462 for (
int i = 0;
i < setLayouts.
size();
i++) {
465 DestroyDescriptorSetLayout(sharedContext->
device(),
473 bool usesIntrinsicConstantUbo,
474 bool hasStepUniforms,
475 int numPaintUniforms,
476 int numTextureSamplers,
477 int numInputAttachments) {
484 if (usesIntrinsicConstantUbo) {
487 if (hasStepUniforms) {
490 if (numPaintUniforms > 0) {
494 if (!uniformDescriptors.
empty()) {
495 VkDescriptorSetLayout uniformSetLayout =
502 if (numInputAttachments > 0) {
506 SkASSERT(numInputAttachments == 1 && uniformDescriptors.
empty());
510 VkDescriptorSetLayout inputAttachmentDescSetLayout =
517 setLayouts.
push_back(inputAttachmentDescSetLayout);
521 if (numTextureSamplers > 0) {
523 for (
int i = 0;
i < numTextureSamplers;
i++) {
529 VkDescriptorSetLayout textureSamplerDescSetLayout =
536 setLayouts.
push_back(textureSamplerDescSetLayout);
543 layoutCreateInfo.
pNext =
nullptr;
544 layoutCreateInfo.
flags = 0;
552 VkPipelineLayout layout;
555 CreatePipelineLayout(sharedContext->
device(),
567 VkShaderModule vsModule,
568 VkShaderModule fsModule) {
571 DestroyShaderModule(sharedContext->
device(), vsModule,
nullptr));
575 DestroyShaderModule(sharedContext->
device(), fsModule,
nullptr));
584 dynamicInfo->
flags = 0;
598 VkPipelineCache pipelineCache) {
608 if (
step->vertexAttributes().size() +
step->instanceAttributes().size() >
610 SKGPU_LOG_W(
"Requested more than the supported number of vertex attributes");
621 std::string& fsSkSL = fsSkSLInfo.
fSkSL;
624 bool hasFragmentSkSL = !fsSkSL.empty();
625 std::string vsSPIRV, fsSPIRV;
628 if (hasFragmentSkSL) {
649 const std::string& vsSkSL = vsSkSLInfo.
fSkSL;
671 step->instanceAttributes(),
701 &pipelineShaderStages[0]);
702 if (hasFragmentSkSL) {
705 &pipelineShaderStages[1]);
715 !
step->uniforms().empty(),
734 pipelineCreateInfo.
pNext =
nullptr;
735 pipelineCreateInfo.
flags = 0;
736 pipelineCreateInfo.
stageCount = hasFragmentSkSL ? 2 : 1;
737 pipelineCreateInfo.
pStages = &pipelineShaderStages[0];
747 pipelineCreateInfo.
layout = pipelineLayout;
748 pipelineCreateInfo.
renderPass = compatibleRenderPass->renderPass();
749 pipelineCreateInfo.
subpass = loadMsaaFromResolve ? 1 : 0;
753 VkPipeline vkPipeline;
774#if defined(GRAPHITE_TEST_UTILS)
775 GraphicsPipeline::PipelineInfo pipelineInfo = {pipelineDesc.
renderStepID(),
779 "SPIR-V disassembly not available",
780 "SPIR-V disassembly not available"};
781 GraphicsPipeline::PipelineInfo* pipelineInfoPtr = &pipelineInfo;
783 GraphicsPipeline::PipelineInfo* pipelineInfoPtr =
nullptr;
792 !
step->uniforms().empty(),
799 VkShaderModule* outVertexShaderModule,
800 VkShaderModule* outFragShaderModule,
802 VkPipelineLayout* outPipelineLayout) {
806 std::string vsSPIRV, fsSPIRV;
809 std::string vertShaderText;
810 vertShaderText.append(
811 "// MSAA Load Program VS\n"
812 "layout(vulkan, location=0) in float2 ndc_position;"
815 "sk_Position.xy = ndc_position;"
816 "sk_Position.zw = half2(0, 1);"
819 std::string fragShaderText;
820 fragShaderText.append(
821 "layout(vulkan, input_attachment_index=0, set=0, binding=0) subpassInput uInput;"
823 "// MSAA Load Program FS\n"
825 "sk_FragColor = subpassLoad(uInput);"
846 *outFragShaderModule =
852 *outVertexShaderModule =
860 *outVertexShaderModule,
861 &outShaderStageInfo[0]);
864 *outFragShaderModule,
865 &outShaderStageInfo[1]);
888 VkShaderModule vsModule,
889 VkShaderModule fsModule,
891 VkPipelineLayout pipelineLayout,
893 VkPipelineCache pipelineCache,
896 int numSamples = dstColorAttachmentTexInfo.
numSamples();
939 pipelineCreateInfo.
pNext =
nullptr;
940 pipelineCreateInfo.
flags = 0;
942 pipelineCreateInfo.
pStages = pipelineShaderStages;
952 pipelineCreateInfo.
layout = pipelineLayout;
953 pipelineCreateInfo.
renderPass = compatibleRenderPass->renderPass();
955 VkPipeline vkPipeline;
988 PipelineInfo* pipelineInfo,
989 VkPipelineLayout pipelineLayout,
991 bool hasFragmentUniforms,
992 bool hasStepUniforms,
993 int numTextureSamplers,
994 bool ownsPipelineLayout)
996 , fPipelineLayout(pipelineLayout)
997 , fPipeline(pipeline)
998 , fHasFragmentUniforms(hasFragmentUniforms)
999 , fHasStepUniforms(hasStepUniforms)
1000 , fNumTextureSamplers(numTextureSamplers)
1001 , fOwnsPipelineLayout(ownsPipelineLayout) {}
1003void VulkanGraphicsPipeline::freeGpuData() {
1004 auto sharedCtxt =
static_cast<const VulkanSharedContext*
>(this->
sharedContext());
1007 DestroyPipeline(sharedCtxt->device(), fPipeline,
nullptr));
1011 DestroyPipelineLayout(sharedCtxt->device(), fPipelineLayout,
nullptr));
static int step(int x, SkScalar min, SkScalar max)
SkAssertResult(font.textToGlyphs("Hello", 5, SkTextEncoding::kUTF8, glyphs, std::size(glyphs))==count)
#define SKGPU_LOG_E(fmt,...)
#define SKGPU_LOG_W(fmt,...)
#define SK_ABORT(message,...)
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
#define TRACE_EVENT0_ALWAYS(category_group, name)
#define VULKAN_CALL(IFACE, X)
#define VULKAN_CALL_RESULT(SHARED_CONTEXT, RESULT, X)
constexpr bool empty() const
constexpr size_t size() const
skgpu::ShaderErrorHandler * shaderErrorHandler() const
const ResourceBindingRequirements & resourceBindingRequirements() const
bool storageBufferPreferred() const
const SkSL::ShaderCaps * shaderCaps() const
UniquePaintParamsID paintParamsID() const
uint32_t renderStepID() const
const RenderStep * lookup(uint32_t uniqueID) const
const SharedContext * sharedContext() const
const Caps * caps() const
ShaderCodeDictionary * shaderCodeDictionary()
const RendererProvider * rendererProvider() const
uint32_t numSamples() const
static const DescriptorData kRenderStepUniformDescriptor
static sk_sp< VulkanGraphicsPipeline > Make(const VulkanSharedContext *, const RuntimeEffectDictionary *, const GraphicsPipelineDesc &, const RenderPassDesc &, const sk_sp< VulkanRenderPass > &compatibleRenderPass, VkPipelineCache)
static constexpr unsigned int kInstanceBufferIndex
static const DescriptorData kInputAttachmentDescriptor
static const DescriptorData kIntrinsicUniformBufferDescriptor
static constexpr unsigned int kVertexBufferIndex
static sk_sp< VulkanGraphicsPipeline > MakeLoadMSAAPipeline(const VulkanSharedContext *, VkShaderModule vsModule, VkShaderModule fsModule, VkPipelineShaderStageCreateInfo *pipelineShaderStages, VkPipelineLayout, sk_sp< VulkanRenderPass > compatibleRenderPass, VkPipelineCache, const TextureInfo &dstColorAttachmentTexInfo)
static const DescriptorData kPaintUniformDescriptor
static bool InitializeMSAALoadPipelineStructs(const VulkanSharedContext *, VkShaderModule *outVertexShaderModule, VkShaderModule *outFragShaderModule, VkPipelineShaderStageCreateInfo *outShaderStageInfo, VkPipelineLayout *outPipelineLayout)
const skgpu::VulkanInterface * interface() const
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
static void setup_viewport_scissor_state(VkPipelineViewportStateCreateInfo *viewportInfo)
VertSkSLInfo BuildVertexSkSL(const ResourceBindingRequirements &bindingReqs, const RenderStep *step, bool useStorageBuffers, bool defineLocalCoordsVarying)
static constexpr int kCompareOpCount
static VkDescriptorSetLayout descriptor_data_to_layout(const VulkanSharedContext *sharedContext, const SkSpan< DescriptorData > &descriptorData)
static VkBlendOp blend_equation_to_vk_blend_op(skgpu::BlendEquation equation)
static void setup_depth_stencil_state(const DepthStencilSettings &stencilSettings, VkPipelineDepthStencilStateCreateInfo *stencilInfo)
static VkPipelineLayout setup_pipeline_layout(const VulkanSharedContext *sharedContext, bool usesIntrinsicConstantUbo, bool hasStepUniforms, int numPaintUniforms, int numTextureSamplers, int numInputAttachments)
static void setup_raster_state(bool isWireframe, VkPipelineRasterizationStateCreateInfo *rasterInfo)
static void setup_color_blend_state(const skgpu::BlendInfo &blendInfo, VkPipelineColorBlendStateCreateInfo *colorBlendInfo, VkPipelineColorBlendAttachmentState *attachmentState)
static void setup_stencil_op_state(VkStencilOpState *opState, const DepthStencilSettings::Face &face, uint32_t referenceValue)
static VkPrimitiveTopology primitive_type_to_vk_topology(PrimitiveType primitiveType)
VkShaderModule createVulkanShaderModule(const VulkanSharedContext *context, const std::string &spirv, VkShaderStageFlagBits stage)
FragSkSLInfo BuildFragmentSkSL(const Caps *caps, const ShaderCodeDictionary *dict, const RuntimeEffectDictionary *rteDict, const RenderStep *step, UniquePaintParamsID paintID, bool useStorageBuffers, skgpu::Swizzle writeSwizzle)
@ kCombinedTextureSampler
static void destroy_shader_modules(const VulkanSharedContext *sharedContext, VkShaderModule vsModule, VkShaderModule fsModule)
static void destroy_desc_set_layouts(const VulkanSharedContext *sharedContext, skia_private::TArray< VkDescriptorSetLayout > &setLayouts)
static VkStencilOp stencil_op_to_vk_stencil_op(StencilOp op)
static void setup_dynamic_state(VkPipelineDynamicStateCreateInfo *dynamicInfo, VkDynamicState *dynamicStates)
static constexpr int kStencilOpCount
void DescriptorDataToVkDescSetLayout(const VulkanSharedContext *ctxt, const SkSpan< DescriptorData > &requestedDescriptors, VkDescriptorSetLayout *outLayout)
static void setup_vertex_input_state(const SkSpan< const Attribute > &vertexAttrs, const SkSpan< const Attribute > &instanceAttrs, VkPipelineVertexInputStateCreateInfo *vertexInputInfo, skia_private::STArray< 2, VkVertexInputBindingDescription, true > *bindingDescs, skia_private::STArray< 16, VkVertexInputAttributeDescription > *attributeDescs)
static VkCompareOp compare_op_to_vk_compare_op(CompareOp op)
static void setup_input_assembly_state(PrimitiveType primitiveType, VkPipelineInputAssemblyStateCreateInfo *inputAssemblyInfo)
static void setup_multisample_state(int numSamples, VkPipelineMultisampleStateCreateInfo *multisampleInfo)
static VkFormat attrib_type_to_vkformat(VertexAttribType type)
static void setup_shader_stage_info(VkShaderStageFlagBits stage, VkShaderModule shaderModule, VkPipelineShaderStageCreateInfo *shaderStageInfo)
static VkBlendFactor blend_coeff_to_vk_blend(skgpu::BlendCoeff coeff)
static constexpr bool BlendShouldDisable(BlendEquation equation, BlendCoeff srcCoeff, BlendCoeff dstCoeff)
static const int kBlendEquationCnt
static constexpr bool SampleCountToVkSampleCount(uint32_t samples, VkSampleCountFlagBits *vkSamples)
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)
const VkPipelineTessellationStateCreateInfo * pTessellationState
const VkPipelineDepthStencilStateCreateInfo * pDepthStencilState
int32_t basePipelineIndex
const VkPipelineDynamicStateCreateInfo * pDynamicState
const VkPipelineColorBlendStateCreateInfo * pColorBlendState
VkPipelineCreateFlags flags
const VkPipelineInputAssemblyStateCreateInfo * pInputAssemblyState
const VkPipelineMultisampleStateCreateInfo * pMultisampleState
const VkPipelineVertexInputStateCreateInfo * pVertexInputState
const VkPipelineShaderStageCreateInfo * pStages
VkPipeline basePipelineHandle
const VkPipelineRasterizationStateCreateInfo * pRasterizationState
const VkPipelineViewportStateCreateInfo * pViewportState
VkBlendFactor dstColorBlendFactor
VkBlendFactor dstAlphaBlendFactor
VkBlendFactor srcAlphaBlendFactor
VkBlendFactor srcColorBlendFactor
VkColorComponentFlags colorWriteMask
VkPipelineColorBlendStateCreateFlags flags
const VkPipelineColorBlendAttachmentState * pAttachments
VkPipelineDepthStencilStateCreateFlags flags
VkCompareOp depthCompareOp
VkBool32 depthWriteEnable
VkBool32 stencilTestEnable
VkBool32 depthBoundsTestEnable
VkPipelineDynamicStateCreateFlags flags
const VkDynamicState * pDynamicStates
uint32_t dynamicStateCount
VkPipelineLayoutCreateFlags flags
uint32_t pushConstantRangeCount
const VkPushConstantRange * pPushConstantRanges
const VkDescriptorSetLayout * pSetLayouts
VkPipelineMultisampleStateCreateFlags flags
VkBool32 sampleShadingEnable
VkSampleCountFlagBits rasterizationSamples
VkBool32 alphaToOneEnable
const VkSampleMask * pSampleMask
VkBool32 alphaToCoverageEnable
VkBool32 rasterizerDiscardEnable
float depthBiasConstantFactor
VkBool32 depthClampEnable
VkPolygonMode polygonMode
float depthBiasSlopeFactor
VkPipelineRasterizationStateCreateFlags flags
VkPipelineShaderStageCreateFlags flags
const VkSpecializationInfo * pSpecializationInfo
VkShaderStageFlagBits stage
const VkViewport * pViewports
const VkRect2D * pScissors
VkPipelineViewportStateCreateFlags flags
skgpu::BlendCoeff fDstBlend
skgpu::BlendCoeff fSrcBlend
StencilOp fDepthStencilPassOp
uint32_t fStencilReferenceValue
CompareOp fDepthCompareOp
bool fRequiresLocalCoords
int fNumTexturesAndSamplers
AttachmentDesc fColorResolveAttachment
AttachmentDesc fColorAttachment
@ VK_SHADER_STAGE_VERTEX_BIT
@ VK_SHADER_STAGE_FRAGMENT_BIT
@ VK_DYNAMIC_STATE_BLEND_CONSTANTS
@ VK_DYNAMIC_STATE_VIEWPORT
@ VK_DYNAMIC_STATE_SCISSOR
@ VK_STENCIL_OP_INCREMENT_AND_CLAMP
@ VK_STENCIL_OP_DECREMENT_AND_CLAMP
@ VK_STENCIL_OP_INCREMENT_AND_WRAP
@ VK_STENCIL_OP_DECREMENT_AND_WRAP
@ VK_COMPARE_OP_LESS_OR_EQUAL
@ VK_COMPARE_OP_NOT_EQUAL
@ VK_COMPARE_OP_GREATER_OR_EQUAL
@ VK_BLEND_OP_MULTIPLY_EXT
@ VK_BLEND_OP_HARDLIGHT_EXT
@ VK_BLEND_OP_OVERLAY_EXT
@ VK_BLEND_OP_COLORDODGE_EXT
@ VK_BLEND_OP_HSL_COLOR_EXT
@ VK_BLEND_OP_SOFTLIGHT_EXT
@ VK_BLEND_OP_LIGHTEN_EXT
@ VK_BLEND_OP_HSL_HUE_EXT
@ VK_BLEND_OP_HSL_SATURATION_EXT
@ VK_BLEND_OP_HSL_LUMINOSITY_EXT
@ VK_BLEND_OP_EXCLUSION_EXT
@ VK_BLEND_OP_COLORBURN_EXT
@ VK_BLEND_OP_DIFFERENCE_EXT
@ VK_BLEND_OP_REVERSE_SUBTRACT
VkFlags VkPipelineLayoutCreateFlags
@ VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST
@ VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP
@ VK_PRIMITIVE_TOPOLOGY_POINT_LIST
@ VK_FRONT_FACE_COUNTER_CLOCKWISE
@ VK_VERTEX_INPUT_RATE_VERTEX
@ VK_VERTEX_INPUT_RATE_INSTANCE
@ VK_COLOR_COMPONENT_R_BIT
@ VK_COLOR_COMPONENT_A_BIT
@ VK_COLOR_COMPONENT_B_BIT
@ VK_COLOR_COMPONENT_G_BIT
@ VK_FORMAT_R16G16B16A16_UNORM
@ VK_FORMAT_R16G16_SFLOAT
@ VK_FORMAT_R32G32_SFLOAT
@ VK_FORMAT_R32G32B32A32_SFLOAT
@ VK_FORMAT_R16G16B16A16_SINT
@ VK_FORMAT_R8G8B8A8_UNORM
@ VK_FORMAT_R32G32B32_SINT
@ VK_FORMAT_R16G16B16A16_SFLOAT
@ VK_FORMAT_R8G8B8A8_SINT
@ VK_FORMAT_R32G32B32A32_SINT
@ VK_FORMAT_R32G32B32_SFLOAT
@ VK_FORMAT_R8G8B8A8_UINT
@ VK_BLEND_FACTOR_SRC1_ALPHA
@ VK_BLEND_FACTOR_ONE_MINUS_DST_ALPHA
@ VK_BLEND_FACTOR_ONE_MINUS_SRC1_COLOR
@ VK_BLEND_FACTOR_ONE_MINUS_SRC_COLOR
@ VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR
@ VK_BLEND_FACTOR_SRC_COLOR
@ VK_BLEND_FACTOR_CONSTANT_COLOR
@ VK_BLEND_FACTOR_SRC_ALPHA
@ VK_BLEND_FACTOR_DST_ALPHA
@ VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA
@ VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA
@ VK_BLEND_FACTOR_DST_COLOR
@ VK_BLEND_FACTOR_SRC1_COLOR
@ VK_BLEND_FACTOR_ONE_MINUS_DST_COLOR
@ VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO
@ VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO
@ VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO
@ VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO
@ VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO
@ VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO
@ VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO
@ VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO
@ VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO
@ VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO
@ VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO