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) {
602 settings.fForceNoRTFlip =
true;
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]);
712 !
step->uniforms().empty(),
731 pipelineCreateInfo.
pNext =
nullptr;
732 pipelineCreateInfo.
flags = 0;
733 pipelineCreateInfo.
stageCount = hasFragmentSkSL ? 2 : 1;
734 pipelineCreateInfo.
pStages = &pipelineShaderStages[0];
744 pipelineCreateInfo.
layout = pipelineLayout;
745 pipelineCreateInfo.
renderPass = compatibleRenderPass->renderPass();
746 pipelineCreateInfo.
subpass = loadMsaaFromResolve ? 1 : 0;
750 VkPipeline vkPipeline;
771#if defined(GRAPHITE_TEST_UTILS)
772 GraphicsPipeline::PipelineInfo pipelineInfo = {pipelineDesc.
renderStepID(),
776 "SPIR-V disassembly not available",
777 "SPIR-V disassembly not available"};
778 GraphicsPipeline::PipelineInfo* pipelineInfoPtr = &pipelineInfo;
780 GraphicsPipeline::PipelineInfo* pipelineInfoPtr =
nullptr;
789 !
step->uniforms().empty(),
796 VkShaderModule* outVertexShaderModule,
797 VkShaderModule* outFragShaderModule,
799 VkPipelineLayout* outPipelineLayout) {
802 settings.fForceNoRTFlip =
true;
803 std::string vsSPIRV, fsSPIRV;
806 std::string vertShaderText;
807 vertShaderText.append(
808 "// MSAA Load Program VS\n"
809 "layout(vulkan, location=0) in float2 ndc_position;"
812 "sk_Position.xy = ndc_position;"
813 "sk_Position.zw = half2(0, 1);"
816 std::string fragShaderText;
817 fragShaderText.append(
818 "layout(vulkan, input_attachment_index=0, set=0, binding=0) subpassInput uInput;"
820 "// MSAA Load Program FS\n"
822 "sk_FragColor = subpassLoad(uInput);"
843 *outFragShaderModule =
849 *outVertexShaderModule =
857 *outVertexShaderModule,
858 &outShaderStageInfo[0]);
861 *outFragShaderModule,
862 &outShaderStageInfo[1]);
885 VkShaderModule vsModule,
886 VkShaderModule fsModule,
888 VkPipelineLayout pipelineLayout,
890 VkPipelineCache pipelineCache,
893 int numSamples = dstColorAttachmentTexInfo.
numSamples();
936 pipelineCreateInfo.
pNext =
nullptr;
937 pipelineCreateInfo.
flags = 0;
939 pipelineCreateInfo.
pStages = pipelineShaderStages;
949 pipelineCreateInfo.
layout = pipelineLayout;
950 pipelineCreateInfo.
renderPass = compatibleRenderPass->renderPass();
952 VkPipeline vkPipeline;
985 PipelineInfo* pipelineInfo,
986 VkPipelineLayout pipelineLayout,
988 bool hasFragmentUniforms,
989 bool hasStepUniforms,
990 int numTextureSamplers,
991 bool ownsPipelineLayout)
993 , fPipelineLayout(pipelineLayout)
994 , fPipeline(pipeline)
995 , fHasFragmentUniforms(hasFragmentUniforms)
996 , fHasStepUniforms(hasStepUniforms)
997 , fNumTextureSamplers(numTextureSamplers)
998 , fOwnsPipelineLayout(ownsPipelineLayout) {}
1004 DestroyPipeline(sharedCtxt->device(), fPipeline,
nullptr));
1008 DestroyPipelineLayout(sharedCtxt->device(), fPipelineLayout,
nullptr));
static int step(int x, SkScalar min, SkScalar max)
#define SKGPU_LOG_E(fmt,...)
#define SKGPU_LOG_W(fmt,...)
#define SkAssertResult(cond)
#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)
Type::kYUV Type::kRGBA() int(0.7 *637)
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
void freeGpuData() override
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
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
VkShaderModule const char * pName
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