Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
GrVkPipeline Class Reference

#include <GrVkPipeline.h>

Inheritance diagram for GrVkPipeline:
GrVkManagedResource GrManagedResource SkNoncopyable

Public Member Functions

VkPipeline pipeline () const
 
VkPipelineLayout layout () const
 
- Public Member Functions inherited from GrVkManagedResource
 GrVkManagedResource (const GrVkGpu *gpu)
 
- Public Member Functions inherited from GrManagedResource
 GrManagedResource ()
 
virtual ~GrManagedResource ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Static Public Member Functions

static sk_sp< GrVkPipelineMake (GrVkGpu *, const GrGeometryProcessor::AttributeSet &vertexAttribs, const GrGeometryProcessor::AttributeSet &instanceAttribs, GrPrimitiveType, GrSurfaceOrigin, const GrStencilSettings &, int numSamples, bool isHWAntialiasState, const skgpu::BlendInfo &, bool isWireframe, bool useConservativeRaster, uint32_t subpass, VkPipelineShaderStageCreateInfo *shaderStageInfo, int shaderStageCount, VkRenderPass compatibleRenderPass, VkPipelineLayout layout, bool ownsLayout, VkPipelineCache cache)
 
static sk_sp< GrVkPipelineMake (GrVkGpu *, const GrProgramInfo &, VkPipelineShaderStageCreateInfo *shaderStageInfo, int shaderStageCount, VkRenderPass compatibleRenderPass, VkPipelineLayout layout, VkPipelineCache cache, uint32_t subpass)
 
static void SetDynamicScissorRectState (GrVkGpu *, GrVkCommandBuffer *, SkISize colorAttachmentDimensions, GrSurfaceOrigin, const SkIRect &scissorRect)
 
static void SetDynamicViewportState (GrVkGpu *, GrVkCommandBuffer *, SkISize colorAttachmentDimensions)
 
static void SetDynamicBlendConstantState (GrVkGpu *, GrVkCommandBuffer *, const skgpu::Swizzle &writeSwizzle, const GrXferProcessor &)
 

Protected Member Functions

 GrVkPipeline (const GrVkGpu *gpu, VkPipeline pipeline, VkPipelineLayout layout)
 

Protected Attributes

VkPipeline fPipeline
 
VkPipelineLayout fPipelineLayout
 
- Protected Attributes inherited from GrVkManagedResource
const GrVkGpufGpu
 

Detailed Description

Definition at line 33 of file GrVkPipeline.h.

Constructor & Destructor Documentation

◆ GrVkPipeline()

GrVkPipeline::GrVkPipeline ( const GrVkGpu gpu,
VkPipeline  pipeline,
VkPipelineLayout  layout 
)
inlineprotected

Definition at line 88 of file GrVkPipeline.h.

89 : INHERITED(gpu), fPipeline(pipeline), fPipelineLayout(layout) {}
VkPipelineLayout layout() const
Definition: GrVkPipeline.h:64
VkPipeline fPipeline
Definition: GrVkPipeline.h:91
VkPipelineLayout fPipelineLayout
Definition: GrVkPipeline.h:92
VkPipeline pipeline() const
Definition: GrVkPipeline.h:63

Member Function Documentation

◆ layout()

VkPipelineLayout GrVkPipeline::layout ( ) const
inline

Definition at line 64 of file GrVkPipeline.h.

64 {
66 return fPipelineLayout;
67 }
#define SkASSERT(cond)
Definition: SkAssert.h:116
#define VK_NULL_HANDLE
Definition: vulkan_core.h:46

◆ Make() [1/2]

sk_sp< GrVkPipeline > GrVkPipeline::Make ( GrVkGpu gpu,
const GrGeometryProcessor::AttributeSet vertexAttribs,
const GrGeometryProcessor::AttributeSet instanceAttribs,
GrPrimitiveType  primitiveType,
GrSurfaceOrigin  origin,
const GrStencilSettings stencilSettings,
int  numSamples,
bool  isHWAntialiasState,
const skgpu::BlendInfo blendInfo,
bool  isWireframe,
bool  useConservativeRaster,
uint32_t  subpass,
VkPipelineShaderStageCreateInfo shaderStageInfo,
int  shaderStageCount,
VkRenderPass  compatibleRenderPass,
VkPipelineLayout  layout,
bool  ownsLayout,
VkPipelineCache  cache 
)
static

Definition at line 465 of file GrVkPipeline.cpp.

482 {
486 int totalAttributeCnt = vertexAttribs.count() + instanceAttribs.count();
487 SkASSERT(totalAttributeCnt <= gpu->vkCaps().maxVertexAttributes());
488 VkVertexInputAttributeDescription* pAttribs = attributeDesc.push_back_n(totalAttributeCnt);
489 setup_vertex_input_state(vertexAttribs, instanceAttribs, &vertexInputInfo, &bindingDescs,
490 pAttribs);
491
493 setup_input_assembly_state(primitiveType, &inputAssemblyInfo);
494
496 setup_depth_stencil_state(stencilSettings, origin, &depthStencilInfo);
497
499 setup_viewport_scissor_state(&viewportInfo);
500
502 setup_multisample_state(numSamples, gpu->caps(), &multisampleInfo);
503
504 // We will only have one color attachment per pipeline.
505 VkPipelineColorBlendAttachmentState attachmentStates[1];
507 setup_color_blend_state(blendInfo, &colorBlendInfo, attachmentStates);
508
510 setup_raster_state(isWireframe, gpu->caps(), &rasterInfo);
511
513 if (useConservativeRaster) {
515 setup_conservative_raster_info(&conservativeRasterInfo);
516 conservativeRasterInfo.pNext = rasterInfo.pNext;
517 rasterInfo.pNext = &conservativeRasterInfo;
518 }
519
520 VkDynamicState dynamicStates[3];
522 setup_dynamic_state(&dynamicInfo, dynamicStates);
523
524 VkGraphicsPipelineCreateInfo pipelineCreateInfo;
525 memset(&pipelineCreateInfo, 0, sizeof(VkGraphicsPipelineCreateInfo));
527 pipelineCreateInfo.pNext = nullptr;
528 pipelineCreateInfo.flags = 0;
529 pipelineCreateInfo.stageCount = shaderStageCount;
530 pipelineCreateInfo.pStages = shaderStageInfo;
531 pipelineCreateInfo.pVertexInputState = &vertexInputInfo;
532 pipelineCreateInfo.pInputAssemblyState = &inputAssemblyInfo;
533 pipelineCreateInfo.pTessellationState = nullptr;
534 pipelineCreateInfo.pViewportState = &viewportInfo;
535 pipelineCreateInfo.pRasterizationState = &rasterInfo;
536 pipelineCreateInfo.pMultisampleState = &multisampleInfo;
537 pipelineCreateInfo.pDepthStencilState = &depthStencilInfo;
538 pipelineCreateInfo.pColorBlendState = &colorBlendInfo;
539 pipelineCreateInfo.pDynamicState = &dynamicInfo;
540 pipelineCreateInfo.layout = layout;
541 pipelineCreateInfo.renderPass = compatibleRenderPass;
542 pipelineCreateInfo.subpass = subpass;
543 pipelineCreateInfo.basePipelineHandle = VK_NULL_HANDLE;
544 pipelineCreateInfo.basePipelineIndex = -1;
545
546 VkPipeline vkPipeline;
547 VkResult err;
548 {
549 TRACE_EVENT0_ALWAYS("skia.shaders", "CreateGraphicsPipeline");
550#if defined(SK_ENABLE_SCOPED_LSAN_SUPPRESSIONS)
551 // skia:8712
552 __lsan::ScopedDisabler lsanDisabler;
553#endif
554 GR_VK_CALL_RESULT(gpu, err, CreateGraphicsPipelines(gpu->device(), cache, 1,
555 &pipelineCreateInfo, nullptr,
556 &vkPipeline));
557 }
558 if (err) {
559 SkDebugf("Failed to create pipeline. Error: %d\n", err);
560 return nullptr;
561 }
562
563 if (!ownsLayout) {
565 }
566 return sk_sp<GrVkPipeline>(new GrVkPipeline(gpu, vkPipeline, layout));
567}
static void setup_multisample_state(int numSamples, const GrCaps *caps, VkPipelineMultisampleStateCreateInfo *multisampleInfo)
static void setup_vertex_input_state(const GrGeometryProcessor::AttributeSet &vertexAttribs, const GrGeometryProcessor::AttributeSet &instanceAttribs, VkPipelineVertexInputStateCreateInfo *vertexInputInfo, STArray< 2, VkVertexInputBindingDescription, true > *bindingDescs, VkVertexInputAttributeDescription *attributeDesc)
static void setup_conservative_raster_info(VkPipelineRasterizationConservativeStateCreateInfoEXT *conservativeRasterInfo)
static void setup_input_assembly_state(GrPrimitiveType primitiveType, VkPipelineInputAssemblyStateCreateInfo *inputAssemblyInfo)
static void setup_viewport_scissor_state(VkPipelineViewportStateCreateInfo *viewportInfo)
static void setup_raster_state(bool isWireframe, const GrCaps *caps, VkPipelineRasterizationStateCreateInfo *rasterInfo)
static void setup_color_blend_state(const skgpu::BlendInfo &blendInfo, VkPipelineColorBlendStateCreateInfo *colorBlendInfo, VkPipelineColorBlendAttachmentState *attachmentState)
static void setup_dynamic_state(VkPipelineDynamicStateCreateInfo *dynamicInfo, VkDynamicState *dynamicStates)
static void setup_depth_stencil_state(const GrStencilSettings &stencilSettings, GrSurfaceOrigin origin, VkPipelineDepthStencilStateCreateInfo *stencilInfo)
#define GR_VK_CALL_RESULT(GPU, RESULT, X)
Definition: GrVkUtil.h:35
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
#define TRACE_EVENT0_ALWAYS(category_group, name)
bool conservativeRasterSupport() const
Definition: GrCaps.h:95
const GrCaps * caps() const
Definition: GrGpu.h:73
VkDevice device() const
Definition: GrVkGpu.h:71
GrVkPipeline(const GrVkGpu *gpu, VkPipeline pipeline, VkPipelineLayout layout)
Definition: GrVkPipeline.h:88
T * push_back_n(int n)
Definition: SkTArray.h:267
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace Enable an endless trace buffer The default is a ring buffer This is useful when very old events need to viewed For during application launch Memory usage will continue to grow indefinitely however Start app with an specific route defined on the framework flutter assets Path to the Flutter assets directory enable service port Allow the VM service to fallback to automatic port selection if binding to a specified port fails trace Trace early application lifecycle Automatically switches to an endless trace buffer trace skia Filters out all Skia trace event categories except those that are specified in this comma separated list dump skp on shader Automatically dump the skp that triggers new shader compilations This is useful for writing custom ShaderWarmUp to reduce jank By this is not enabled to reduce the overhead purge persistent cache
Definition: switches.h:191
const VkPipelineTessellationStateCreateInfo * pTessellationState
Definition: vulkan_core.h:3674
const VkPipelineDepthStencilStateCreateInfo * pDepthStencilState
Definition: vulkan_core.h:3678
const VkPipelineDynamicStateCreateInfo * pDynamicState
Definition: vulkan_core.h:3680
const VkPipelineColorBlendStateCreateInfo * pColorBlendState
Definition: vulkan_core.h:3679
VkPipelineCreateFlags flags
Definition: vulkan_core.h:3669
const VkPipelineInputAssemblyStateCreateInfo * pInputAssemblyState
Definition: vulkan_core.h:3673
const VkPipelineMultisampleStateCreateInfo * pMultisampleState
Definition: vulkan_core.h:3677
const VkPipelineVertexInputStateCreateInfo * pVertexInputState
Definition: vulkan_core.h:3672
const VkPipelineShaderStageCreateInfo * pStages
Definition: vulkan_core.h:3671
const VkPipelineRasterizationStateCreateInfo * pRasterizationState
Definition: vulkan_core.h:3676
const VkPipelineViewportStateCreateInfo * pViewportState
Definition: vulkan_core.h:3675
VkDynamicState
Definition: vulkan_core.h:1930
VkResult
Definition: vulkan_core.h:140
@ VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO
Definition: vulkan_core.h:230

◆ Make() [2/2]

sk_sp< GrVkPipeline > GrVkPipeline::Make ( GrVkGpu gpu,
const GrProgramInfo programInfo,
VkPipelineShaderStageCreateInfo shaderStageInfo,
int  shaderStageCount,
VkRenderPass  compatibleRenderPass,
VkPipelineLayout  layout,
VkPipelineCache  cache,
uint32_t  subpass 
)
static

Definition at line 569 of file GrVkPipeline.cpp.

576 {
577 const GrGeometryProcessor& geomProc = programInfo.geomProc();
578 const GrPipeline& pipeline = programInfo.pipeline();
579
580 return Make(gpu,
581 geomProc.vertexAttributes(),
582 geomProc.instanceAttributes(),
583 programInfo.primitiveType(),
584 programInfo.origin(),
585 programInfo.nonGLStencilSettings(),
586 programInfo.numSamples(),
587 programInfo.numSamples() > 1,
588 pipeline.getXferProcessor().getBlendInfo(),
589 pipeline.isWireframe(),
590 pipeline.usesConservativeRaster(),
591 subpass,
592 shaderStageInfo,
593 shaderStageCount,
594 compatibleRenderPass,
595 layout,
596 /*ownsLayout=*/true,
597 cache);
598}
const AttributeSet & vertexAttributes() const
const AttributeSet & instanceAttributes() const
int numSamples() const
Definition: GrProgramInfo.h:29
GrSurfaceOrigin origin() const
Definition: GrProgramInfo.h:38
GrPrimitiveType primitiveType() const
Definition: GrProgramInfo.h:42
const GrPipeline & pipeline() const
Definition: GrProgramInfo.h:39
const GrGeometryProcessor & geomProc() const
Definition: GrProgramInfo.h:40
GrStencilSettings nonGLStencilSettings() const
static sk_sp< GrVkPipeline > Make(GrVkGpu *, const GrGeometryProcessor::AttributeSet &vertexAttribs, const GrGeometryProcessor::AttributeSet &instanceAttribs, GrPrimitiveType, GrSurfaceOrigin, const GrStencilSettings &, int numSamples, bool isHWAntialiasState, const skgpu::BlendInfo &, bool isWireframe, bool useConservativeRaster, uint32_t subpass, VkPipelineShaderStageCreateInfo *shaderStageInfo, int shaderStageCount, VkRenderPass compatibleRenderPass, VkPipelineLayout layout, bool ownsLayout, VkPipelineCache cache)

◆ pipeline()

VkPipeline GrVkPipeline::pipeline ( ) const
inline

Definition at line 63 of file GrVkPipeline.h.

63{ return fPipeline; }

◆ SetDynamicBlendConstantState()

void GrVkPipeline::SetDynamicBlendConstantState ( GrVkGpu gpu,
GrVkCommandBuffer cmdBuffer,
const skgpu::Swizzle writeSwizzle,
const GrXferProcessor xferProcessor 
)
static

Definition at line 646 of file GrVkPipeline.cpp.

649 {
650 const skgpu::BlendInfo& blendInfo = xferProcessor.getBlendInfo();
651 skgpu::BlendCoeff srcCoeff = blendInfo.fSrcBlend;
652 skgpu::BlendCoeff dstCoeff = blendInfo.fDstBlend;
653 float floatColors[4];
655 // Swizzle the blend to match what the shader will output.
656 SkPMColor4f blendConst = swizzle.applyTo(blendInfo.fBlendConstant);
657 floatColors[0] = blendConst.fR;
658 floatColors[1] = blendConst.fG;
659 floatColors[2] = blendConst.fB;
660 floatColors[3] = blendConst.fA;
661 cmdBuffer->setBlendConstants(gpu, floatColors);
662 }
663}
void setBlendConstants(const GrVkGpu *gpu, const float blendConstants[4])
skgpu::BlendInfo getBlendInfo() const
static constexpr bool BlendCoeffRefsConstant(const BlendCoeff coeff)
Definition: Blend.h:141
BlendCoeff
Definition: Blend.h:60
float fB
blue component
Definition: SkColor.h:265
float fR
red component
Definition: SkColor.h:263
float fG
green component
Definition: SkColor.h:264
float fA
alpha component
Definition: SkColor.h:266
skgpu::BlendCoeff fDstBlend
Definition: Blend.h:96
SkPMColor4f fBlendConstant
Definition: Blend.h:97
skgpu::BlendCoeff fSrcBlend
Definition: Blend.h:95

◆ SetDynamicScissorRectState()

void GrVkPipeline::SetDynamicScissorRectState ( GrVkGpu gpu,
GrVkCommandBuffer cmdBuffer,
SkISize  colorAttachmentDimensions,
GrSurfaceOrigin  rtOrigin,
const SkIRect scissorRect 
)
static

Definition at line 608 of file GrVkPipeline.cpp.

612 {
613 SkASSERT(scissorRect.isEmpty() ||
614 SkIRect::MakeSize(colorAttachmentDimensions).contains(scissorRect));
615
616 VkRect2D scissor;
617 scissor.offset.x = scissorRect.fLeft;
618 scissor.extent.width = scissorRect.width();
619 if (kTopLeft_GrSurfaceOrigin == rtOrigin) {
620 scissor.offset.y = scissorRect.fTop;
621 } else {
623 scissor.offset.y = colorAttachmentDimensions.height() - scissorRect.fBottom;
624 }
625 scissor.extent.height = scissorRect.height();
626
627 SkASSERT(scissor.offset.x >= 0);
628 SkASSERT(scissor.offset.y >= 0);
629 cmdBuffer->setScissor(gpu, 0, 1, &scissor);
630}
@ kBottomLeft_GrSurfaceOrigin
Definition: GrTypes.h:149
@ kTopLeft_GrSurfaceOrigin
Definition: GrTypes.h:148
void setScissor(const GrVkGpu *gpu, uint32_t firstScissor, uint32_t scissorCount, const VkRect2D *scissors)
int32_t fBottom
larger y-axis bounds
Definition: SkRect.h:36
constexpr int32_t height() const
Definition: SkRect.h:165
int32_t fTop
smaller y-axis bounds
Definition: SkRect.h:34
static constexpr SkIRect MakeSize(const SkISize &size)
Definition: SkRect.h:66
constexpr int32_t width() const
Definition: SkRect.h:158
bool isEmpty() const
Definition: SkRect.h:202
int32_t fLeft
smaller x-axis bounds
Definition: SkRect.h:33
bool contains(int32_t x, int32_t y) const
Definition: SkRect.h:463
constexpr int32_t height() const
Definition: SkSize.h:37
uint32_t width
Definition: vulkan_core.h:2858
uint32_t height
Definition: vulkan_core.h:2859
int32_t x
Definition: vulkan_core.h:2869
int32_t y
Definition: vulkan_core.h:2870
VkExtent2D extent
Definition: vulkan_core.h:2881
VkOffset2D offset
Definition: vulkan_core.h:2880

◆ SetDynamicViewportState()

void GrVkPipeline::SetDynamicViewportState ( GrVkGpu gpu,
GrVkCommandBuffer cmdBuffer,
SkISize  colorAttachmentDimensions 
)
static

Definition at line 632 of file GrVkPipeline.cpp.

634 {
635 // We always use one viewport the size of the RT
636 VkViewport viewport;
637 viewport.x = 0.0f;
638 viewport.y = 0.0f;
639 viewport.width = SkIntToScalar(colorAttachmentDimensions.width());
640 viewport.height = SkIntToScalar(colorAttachmentDimensions.height());
641 viewport.minDepth = 0.0f;
642 viewport.maxDepth = 1.0f;
643 cmdBuffer->setViewport(gpu, 0, 1, &viewport);
644}
#define SkIntToScalar(x)
Definition: SkScalar.h:57
void setViewport(const GrVkGpu *gpu, uint32_t firstViewport, uint32_t viewportCount, const VkViewport *viewports)
constexpr int32_t width() const
Definition: SkSize.h:36
float maxDepth
Definition: vulkan_core.h:3570
float height
Definition: vulkan_core.h:3568
float minDepth
Definition: vulkan_core.h:3569

Member Data Documentation

◆ fPipeline

VkPipeline GrVkPipeline::fPipeline
protected

Definition at line 91 of file GrVkPipeline.h.

◆ fPipelineLayout

VkPipelineLayout GrVkPipeline::fPipelineLayout
protected

Definition at line 92 of file GrVkPipeline.h.


The documentation for this class was generated from the following files: