Flutter Engine
The Flutter Engine
Functions
GrVkPipeline.cpp File Reference
#include "src/gpu/ganesh/vk/GrVkPipeline.h"
#include "src/core/SkTraceEvent.h"
#include "src/gpu/ganesh/GrGeometryProcessor.h"
#include "src/gpu/ganesh/GrPipeline.h"
#include "src/gpu/ganesh/GrStencilSettings.h"
#include "src/gpu/ganesh/vk/GrVkCommandBuffer.h"
#include "src/gpu/ganesh/vk/GrVkGpu.h"
#include "src/gpu/ganesh/vk/GrVkRenderTarget.h"
#include "src/gpu/ganesh/vk/GrVkUtil.h"
#include "src/gpu/vk/VulkanUtilsPriv.h"

Go to the source code of this file.

Functions

static VkFormat attrib_type_to_vkformat (GrVertexAttribType type)
 
static void setup_vertex_input_state (const GrGeometryProcessor::AttributeSet &vertexAttribs, const GrGeometryProcessor::AttributeSet &instanceAttribs, VkPipelineVertexInputStateCreateInfo *vertexInputInfo, STArray< 2, VkVertexInputBindingDescription, true > *bindingDescs, VkVertexInputAttributeDescription *attributeDesc)
 
static VkPrimitiveTopology gr_primitive_type_to_vk_topology (GrPrimitiveType primitiveType)
 
static void setup_input_assembly_state (GrPrimitiveType primitiveType, VkPipelineInputAssemblyStateCreateInfo *inputAssemblyInfo)
 
static VkStencilOp stencil_op_to_vk_stencil_op (GrStencilOp op)
 
static VkCompareOp stencil_func_to_vk_compare_op (GrStencilTest test)
 
static void setup_stencil_op_state (VkStencilOpState *opState, const GrStencilSettings::Face &stencilFace)
 
static void setup_depth_stencil_state (const GrStencilSettings &stencilSettings, GrSurfaceOrigin origin, VkPipelineDepthStencilStateCreateInfo *stencilInfo)
 
static void setup_viewport_scissor_state (VkPipelineViewportStateCreateInfo *viewportInfo)
 
static void setup_multisample_state (int numSamples, const GrCaps *caps, VkPipelineMultisampleStateCreateInfo *multisampleInfo)
 
static VkBlendFactor blend_coeff_to_vk_blend (skgpu::BlendCoeff coeff)
 
static VkBlendOp blend_equation_to_vk_blend_op (skgpu::BlendEquation equation)
 
static void setup_color_blend_state (const skgpu::BlendInfo &blendInfo, VkPipelineColorBlendStateCreateInfo *colorBlendInfo, VkPipelineColorBlendAttachmentState *attachmentState)
 
static void setup_raster_state (bool isWireframe, const GrCaps *caps, VkPipelineRasterizationStateCreateInfo *rasterInfo)
 
static void setup_conservative_raster_info (VkPipelineRasterizationConservativeStateCreateInfoEXT *conservativeRasterInfo)
 
static void setup_dynamic_state (VkPipelineDynamicStateCreateInfo *dynamicInfo, VkDynamicState *dynamicStates)
 

Function Documentation

◆ attrib_type_to_vkformat()

static VkFormat attrib_type_to_vkformat ( GrVertexAttribType  type)
inlinestatic

Definition at line 26 of file GrVkPipeline.cpp.

26 {
27 switch (type) {
49 return VK_FORMAT_R8_SINT;
55 return VK_FORMAT_R8_UINT;
61 return VK_FORMAT_R8_UNORM;
73 return VK_FORMAT_R32_SINT;
75 return VK_FORMAT_R32_UINT;
80 }
81 SK_ABORT("Unknown vertex attrib type");
82}
@ kUShort_norm_GrVertexAttribType
Definition: GrTypesPriv.h:346
@ kFloat2_GrVertexAttribType
Definition: GrTypesPriv.h:314
@ kUShort2_GrVertexAttribType
Definition: GrTypesPriv.h:340
@ kUInt_GrVertexAttribType
Definition: GrTypesPriv.h:344
@ kUByte4_norm_GrVertexAttribType
Definition: GrTypesPriv.h:334
@ kUByte_GrVertexAttribType
Definition: GrTypesPriv.h:329
@ kShort2_GrVertexAttribType
Definition: GrTypesPriv.h:337
@ kUShort4_norm_GrVertexAttribType
Definition: GrTypesPriv.h:348
@ kInt_GrVertexAttribType
Definition: GrTypesPriv.h:343
@ kByte_GrVertexAttribType
Definition: GrTypesPriv.h:326
@ kByte4_GrVertexAttribType
Definition: GrTypesPriv.h:328
@ kFloat3_GrVertexAttribType
Definition: GrTypesPriv.h:315
@ kFloat_GrVertexAttribType
Definition: GrTypesPriv.h:313
@ kByte2_GrVertexAttribType
Definition: GrTypesPriv.h:327
@ kFloat4_GrVertexAttribType
Definition: GrTypesPriv.h:316
@ kShort4_GrVertexAttribType
Definition: GrTypesPriv.h:338
@ kUShort2_norm_GrVertexAttribType
Definition: GrTypesPriv.h:341
@ kInt3_GrVertexAttribType
Definition: GrTypesPriv.h:322
@ kHalf2_GrVertexAttribType
Definition: GrTypesPriv.h:318
@ kHalf4_GrVertexAttribType
Definition: GrTypesPriv.h:319
@ kUByte4_GrVertexAttribType
Definition: GrTypesPriv.h:331
@ kUByte2_GrVertexAttribType
Definition: GrTypesPriv.h:330
@ kInt4_GrVertexAttribType
Definition: GrTypesPriv.h:323
@ kUByte_norm_GrVertexAttribType
Definition: GrTypesPriv.h:333
@ kInt2_GrVertexAttribType
Definition: GrTypesPriv.h:321
@ kHalf_GrVertexAttribType
Definition: GrTypesPriv.h:317
#define SK_ABORT(message,...)
Definition: SkAssert.h:70
GLenum type
@ VK_FORMAT_R16G16B16A16_UNORM
Definition: vulkan_core.h:1550
@ VK_FORMAT_R16G16_SFLOAT
Definition: vulkan_core.h:1542
@ VK_FORMAT_R32G32_SFLOAT
Definition: vulkan_core.h:1562
@ VK_FORMAT_R16_SFLOAT
Definition: vulkan_core.h:1535
@ VK_FORMAT_R32_SINT
Definition: vulkan_core.h:1558
@ VK_FORMAT_R16G16_UINT
Definition: vulkan_core.h:1540
@ VK_FORMAT_R8_UNORM
Definition: vulkan_core.h:1468
@ VK_FORMAT_R32G32B32A32_SFLOAT
Definition: vulkan_core.h:1568
@ VK_FORMAT_R32_SFLOAT
Definition: vulkan_core.h:1559
@ VK_FORMAT_R16G16B16A16_SINT
Definition: vulkan_core.h:1555
@ VK_FORMAT_R8G8B8A8_UNORM
Definition: vulkan_core.h:1496
@ VK_FORMAT_R16G16_SINT
Definition: vulkan_core.h:1541
@ VK_FORMAT_R8G8_SINT
Definition: vulkan_core.h:1480
@ VK_FORMAT_R32G32B32_SINT
Definition: vulkan_core.h:1564
@ VK_FORMAT_R16_UNORM
Definition: vulkan_core.h:1529
@ VK_FORMAT_R8_SINT
Definition: vulkan_core.h:1473
@ VK_FORMAT_R8_UINT
Definition: vulkan_core.h:1472
@ VK_FORMAT_R16G16B16A16_SFLOAT
Definition: vulkan_core.h:1556
@ VK_FORMAT_R16G16_UNORM
Definition: vulkan_core.h:1536
@ VK_FORMAT_R8G8B8A8_SINT
Definition: vulkan_core.h:1501
@ VK_FORMAT_R32G32B32A32_SINT
Definition: vulkan_core.h:1567
@ VK_FORMAT_R32G32B32_SFLOAT
Definition: vulkan_core.h:1565
@ VK_FORMAT_R8G8B8A8_UINT
Definition: vulkan_core.h:1500
@ VK_FORMAT_R8G8_UINT
Definition: vulkan_core.h:1479
@ VK_FORMAT_R32G32_SINT
Definition: vulkan_core.h:1561
@ VK_FORMAT_R32_UINT
Definition: vulkan_core.h:1557

◆ blend_coeff_to_vk_blend()

static VkBlendFactor blend_coeff_to_vk_blend ( skgpu::BlendCoeff  coeff)
static

Definition at line 292 of file GrVkPipeline.cpp.

292 {
293 switch (coeff) {
297 return VK_BLEND_FACTOR_ONE;
328 }
330}
#define SkUNREACHABLE
Definition: SkAssert.h:135
@ VK_BLEND_FACTOR_ONE
Definition: vulkan_core.h:1842
@ VK_BLEND_FACTOR_SRC1_ALPHA
Definition: vulkan_core.h:1858
@ VK_BLEND_FACTOR_ONE_MINUS_DST_ALPHA
Definition: vulkan_core.h:1850
@ VK_BLEND_FACTOR_ONE_MINUS_SRC1_COLOR
Definition: vulkan_core.h:1857
@ VK_BLEND_FACTOR_ONE_MINUS_SRC_COLOR
Definition: vulkan_core.h:1844
@ VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR
Definition: vulkan_core.h:1852
@ VK_BLEND_FACTOR_SRC_COLOR
Definition: vulkan_core.h:1843
@ VK_BLEND_FACTOR_CONSTANT_COLOR
Definition: vulkan_core.h:1851
@ VK_BLEND_FACTOR_SRC_ALPHA
Definition: vulkan_core.h:1847
@ VK_BLEND_FACTOR_DST_ALPHA
Definition: vulkan_core.h:1849
@ VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA
Definition: vulkan_core.h:1859
@ VK_BLEND_FACTOR_ZERO
Definition: vulkan_core.h:1841
@ VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA
Definition: vulkan_core.h:1848
@ VK_BLEND_FACTOR_DST_COLOR
Definition: vulkan_core.h:1845
@ VK_BLEND_FACTOR_SRC1_COLOR
Definition: vulkan_core.h:1856
@ VK_BLEND_FACTOR_ONE_MINUS_DST_COLOR
Definition: vulkan_core.h:1846

◆ blend_equation_to_vk_blend_op()

static VkBlendOp blend_equation_to_vk_blend_op ( skgpu::BlendEquation  equation)
static

Definition at line 332 of file GrVkPipeline.cpp.

332 {
333 static const VkBlendOp gTable[] = {
334 // Basic blend ops
338
339 // Advanced blend ops
355
356 // Illegal.
358 };
359 static_assert(0 == (int)skgpu::BlendEquation::kAdd);
360 static_assert(1 == (int)skgpu::BlendEquation::kSubtract);
361 static_assert(2 == (int)skgpu::BlendEquation::kReverseSubtract);
362 static_assert(3 == (int)skgpu::BlendEquation::kScreen);
363 static_assert(4 == (int)skgpu::BlendEquation::kOverlay);
364 static_assert(5 == (int)skgpu::BlendEquation::kDarken);
365 static_assert(6 == (int)skgpu::BlendEquation::kLighten);
366 static_assert(7 == (int)skgpu::BlendEquation::kColorDodge);
367 static_assert(8 == (int)skgpu::BlendEquation::kColorBurn);
368 static_assert(9 == (int)skgpu::BlendEquation::kHardLight);
369 static_assert(10 == (int)skgpu::BlendEquation::kSoftLight);
370 static_assert(11 == (int)skgpu::BlendEquation::kDifference);
371 static_assert(12 == (int)skgpu::BlendEquation::kExclusion);
372 static_assert(13 == (int)skgpu::BlendEquation::kMultiply);
373 static_assert(14 == (int)skgpu::BlendEquation::kHSLHue);
374 static_assert(15 == (int)skgpu::BlendEquation::kHSLSaturation);
375 static_assert(16 == (int)skgpu::BlendEquation::kHSLColor);
376 static_assert(17 == (int)skgpu::BlendEquation::kHSLLuminosity);
377 static_assert(std::size(gTable) == skgpu::kBlendEquationCnt);
378
379 SkASSERT((unsigned)equation < skgpu::kBlendEquationCnt);
380 return gTable[(int)equation];
381}
#define SkASSERT(cond)
Definition: SkAssert.h:116
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
Definition: switches.h:259
static const int kBlendEquationCnt
Definition: Blend.h:55
VkBlendOp
Definition: vulkan_core.h:1863
@ VK_BLEND_OP_MULTIPLY_EXT
Definition: vulkan_core.h:1881
@ VK_BLEND_OP_ADD
Definition: vulkan_core.h:1864
@ VK_BLEND_OP_HARDLIGHT_EXT
Definition: vulkan_core.h:1888
@ VK_BLEND_OP_OVERLAY_EXT
Definition: vulkan_core.h:1883
@ VK_BLEND_OP_COLORDODGE_EXT
Definition: vulkan_core.h:1886
@ VK_BLEND_OP_SUBTRACT
Definition: vulkan_core.h:1865
@ VK_BLEND_OP_HSL_COLOR_EXT
Definition: vulkan_core.h:1902
@ VK_BLEND_OP_DARKEN_EXT
Definition: vulkan_core.h:1884
@ VK_BLEND_OP_SOFTLIGHT_EXT
Definition: vulkan_core.h:1889
@ VK_BLEND_OP_LIGHTEN_EXT
Definition: vulkan_core.h:1885
@ VK_BLEND_OP_HSL_HUE_EXT
Definition: vulkan_core.h:1900
@ VK_BLEND_OP_HSL_SATURATION_EXT
Definition: vulkan_core.h:1901
@ VK_BLEND_OP_SCREEN_EXT
Definition: vulkan_core.h:1882
@ VK_BLEND_OP_HSL_LUMINOSITY_EXT
Definition: vulkan_core.h:1903
@ VK_BLEND_OP_EXCLUSION_EXT
Definition: vulkan_core.h:1891
@ VK_BLEND_OP_COLORBURN_EXT
Definition: vulkan_core.h:1887
@ VK_BLEND_OP_DIFFERENCE_EXT
Definition: vulkan_core.h:1890
@ VK_BLEND_OP_REVERSE_SUBTRACT
Definition: vulkan_core.h:1866

◆ gr_primitive_type_to_vk_topology()

static VkPrimitiveTopology gr_primitive_type_to_vk_topology ( GrPrimitiveType  primitiveType)
static

Definition at line 147 of file GrVkPipeline.cpp.

147 {
148 switch (primitiveType) {
159 }
161}
@ VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST
Definition: vulkan_core.h:2037
@ VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP
Definition: vulkan_core.h:2038
@ VK_PRIMITIVE_TOPOLOGY_POINT_LIST
Definition: vulkan_core.h:2034
@ VK_PRIMITIVE_TOPOLOGY_LINE_STRIP
Definition: vulkan_core.h:2036
@ VK_PRIMITIVE_TOPOLOGY_LINE_LIST
Definition: vulkan_core.h:2035

◆ setup_color_blend_state()

static void setup_color_blend_state ( const skgpu::BlendInfo blendInfo,
VkPipelineColorBlendStateCreateInfo colorBlendInfo,
VkPipelineColorBlendAttachmentState attachmentState 
)
static

Definition at line 383 of file GrVkPipeline.cpp.

385 {
386 skgpu::BlendEquation equation = blendInfo.fEquation;
387 skgpu::BlendCoeff srcCoeff = blendInfo.fSrcBlend;
388 skgpu::BlendCoeff dstCoeff = blendInfo.fDstBlend;
389 bool blendOff = skgpu::BlendShouldDisable(equation, srcCoeff, dstCoeff);
390
391 memset(attachmentState, 0, sizeof(VkPipelineColorBlendAttachmentState));
392 attachmentState->blendEnable = !blendOff;
393 if (!blendOff) {
394 attachmentState->srcColorBlendFactor = blend_coeff_to_vk_blend(srcCoeff);
395 attachmentState->dstColorBlendFactor = blend_coeff_to_vk_blend(dstCoeff);
396 attachmentState->colorBlendOp = blend_equation_to_vk_blend_op(equation);
397 attachmentState->srcAlphaBlendFactor = blend_coeff_to_vk_blend(srcCoeff);
398 attachmentState->dstAlphaBlendFactor = blend_coeff_to_vk_blend(dstCoeff);
399 attachmentState->alphaBlendOp = blend_equation_to_vk_blend_op(equation);
400 }
401
402 if (!blendInfo.fWritesColor) {
403 attachmentState->colorWriteMask = 0;
404 } else {
407 }
408
409 memset(colorBlendInfo, 0, sizeof(VkPipelineColorBlendStateCreateInfo));
411 colorBlendInfo->pNext = nullptr;
412 colorBlendInfo->flags = 0;
413 colorBlendInfo->logicOpEnable = VK_FALSE;
414 colorBlendInfo->attachmentCount = 1;
415 colorBlendInfo->pAttachments = attachmentState;
416 // colorBlendInfo->blendConstants is set dynamically
417}
static VkBlendFactor blend_coeff_to_vk_blend(skgpu::BlendCoeff coeff)
static VkBlendOp blend_equation_to_vk_blend_op(skgpu::BlendEquation equation)
static constexpr bool BlendShouldDisable(BlendEquation equation, BlendCoeff srcCoeff, BlendCoeff dstCoeff)
Definition: Blend.h:145
BlendEquation
Definition: Blend.h:26
BlendCoeff
Definition: Blend.h:60
VkColorComponentFlags colorWriteMask
Definition: vulkan_core.h:3644
VkPipelineColorBlendStateCreateFlags flags
Definition: vulkan_core.h:3650
const VkPipelineColorBlendAttachmentState * pAttachments
Definition: vulkan_core.h:3654
skgpu::BlendCoeff fDstBlend
Definition: Blend.h:96
bool fWritesColor
Definition: Blend.h:98
skgpu::BlendCoeff fSrcBlend
Definition: Blend.h:95
#define VK_FALSE
Definition: vulkan_core.h:125
@ VK_COLOR_COMPONENT_R_BIT
Definition: vulkan_core.h:2602
@ VK_COLOR_COMPONENT_A_BIT
Definition: vulkan_core.h:2605
@ VK_COLOR_COMPONENT_B_BIT
Definition: vulkan_core.h:2604
@ VK_COLOR_COMPONENT_G_BIT
Definition: vulkan_core.h:2603
@ VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO
Definition: vulkan_core.h:228

◆ setup_conservative_raster_info()

static void setup_conservative_raster_info ( VkPipelineRasterizationConservativeStateCreateInfoEXT conservativeRasterInfo)
static

Definition at line 439 of file GrVkPipeline.cpp.

440 {
441 memset(conservativeRasterInfo, 0,
443 conservativeRasterInfo->sType =
445 conservativeRasterInfo->pNext = nullptr;
446 conservativeRasterInfo->flags = 0;
447 conservativeRasterInfo->conservativeRasterizationMode =
449 conservativeRasterInfo->extraPrimitiveOverestimationSize = 0;
450}
VkConservativeRasterizationModeEXT conservativeRasterizationMode
VkPipelineRasterizationConservativeStateCreateFlagsEXT flags
@ VK_CONSERVATIVE_RASTERIZATION_MODE_OVERESTIMATE_EXT
@ VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_CONSERVATIVE_STATE_CREATE_INFO_EXT
Definition: vulkan_core.h:610

◆ setup_depth_stencil_state()

static void setup_depth_stencil_state ( const GrStencilSettings stencilSettings,
GrSurfaceOrigin  origin,
VkPipelineDepthStencilStateCreateInfo stencilInfo 
)
static

Definition at line 233 of file GrVkPipeline.cpp.

236 {
237
238 memset(stencilInfo, 0, sizeof(VkPipelineDepthStencilStateCreateInfo));
240 stencilInfo->pNext = nullptr;
241 stencilInfo->flags = 0;
242 // set depth testing defaults
243 stencilInfo->depthTestEnable = VK_FALSE;
244 stencilInfo->depthWriteEnable = VK_FALSE;
246 stencilInfo->depthBoundsTestEnable = VK_FALSE;
247 stencilInfo->stencilTestEnable = !stencilSettings.isDisabled();
248 if (!stencilSettings.isDisabled()) {
249 if (!stencilSettings.isTwoSided()) {
250 setup_stencil_op_state(&stencilInfo->front, stencilSettings.singleSidedFace());
251 stencilInfo->back = stencilInfo->front;
252 } else {
253 setup_stencil_op_state(&stencilInfo->front, stencilSettings.postOriginCCWFace(origin));
254 setup_stencil_op_state(&stencilInfo->back, stencilSettings.postOriginCWFace(origin));
255 }
256 }
257 stencilInfo->minDepthBounds = 0.0f;
258 stencilInfo->maxDepthBounds = 1.0f;
259}
static void setup_stencil_op_state(VkStencilOpState *opState, const GrStencilSettings::Face &stencilFace)
bool isTwoSided() const
const Face & postOriginCCWFace(GrSurfaceOrigin origin) const
bool isDisabled() const
const Face & singleSidedFace() const
const Face & postOriginCWFace(GrSurfaceOrigin origin) const
VkPipelineDepthStencilStateCreateFlags flags
Definition: vulkan_core.h:3624
@ VK_COMPARE_OP_ALWAYS
Definition: vulkan_core.h:1926
@ VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO
Definition: vulkan_core.h:227

◆ setup_dynamic_state()

static void setup_dynamic_state ( VkPipelineDynamicStateCreateInfo dynamicInfo,
VkDynamicState dynamicStates 
)
static

Definition at line 452 of file GrVkPipeline.cpp.

453 {
454 memset(dynamicInfo, 0, sizeof(VkPipelineDynamicStateCreateInfo));
456 dynamicInfo->pNext = VK_NULL_HANDLE;
457 dynamicInfo->flags = 0;
458 dynamicStates[0] = VK_DYNAMIC_STATE_VIEWPORT;
459 dynamicStates[1] = VK_DYNAMIC_STATE_SCISSOR;
460 dynamicStates[2] = VK_DYNAMIC_STATE_BLEND_CONSTANTS;
461 dynamicInfo->dynamicStateCount = 3;
462 dynamicInfo->pDynamicStates = dynamicStates;
463}
VkPipelineDynamicStateCreateFlags flags
Definition: vulkan_core.h:3661
const VkDynamicState * pDynamicStates
Definition: vulkan_core.h:3663
@ VK_DYNAMIC_STATE_BLEND_CONSTANTS
Definition: vulkan_core.h:1935
@ VK_DYNAMIC_STATE_VIEWPORT
Definition: vulkan_core.h:1931
@ VK_DYNAMIC_STATE_SCISSOR
Definition: vulkan_core.h:1932
#define VK_NULL_HANDLE
Definition: vulkan_core.h:46
@ VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO
Definition: vulkan_core.h:229

◆ setup_input_assembly_state()

static void setup_input_assembly_state ( GrPrimitiveType  primitiveType,
VkPipelineInputAssemblyStateCreateInfo inputAssemblyInfo 
)
static

Definition at line 163 of file GrVkPipeline.cpp.

164 {
165 memset(inputAssemblyInfo, 0, sizeof(VkPipelineInputAssemblyStateCreateInfo));
167 inputAssemblyInfo->pNext = nullptr;
168 inputAssemblyInfo->flags = 0;
169 inputAssemblyInfo->primitiveRestartEnable = false;
170 inputAssemblyInfo->topology = gr_primitive_type_to_vk_topology(primitiveType);
171}
static VkPrimitiveTopology gr_primitive_type_to_vk_topology(GrPrimitiveType primitiveType)
VkPipelineInputAssemblyStateCreateFlags flags
Definition: vulkan_core.h:3552
@ VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO
Definition: vulkan_core.h:222

◆ setup_multisample_state()

static void setup_multisample_state ( int  numSamples,
const GrCaps caps,
VkPipelineMultisampleStateCreateInfo multisampleInfo 
)
static

Definition at line 276 of file GrVkPipeline.cpp.

278 {
279 memset(multisampleInfo, 0, sizeof(VkPipelineMultisampleStateCreateInfo));
281 multisampleInfo->pNext = nullptr;
282 multisampleInfo->flags = 0;
284 &multisampleInfo->rasterizationSamples));
285 multisampleInfo->sampleShadingEnable = VK_FALSE;
286 multisampleInfo->minSampleShading = 0.0f;
287 multisampleInfo->pSampleMask = nullptr;
288 multisampleInfo->alphaToCoverageEnable = VK_FALSE;
289 multisampleInfo->alphaToOneEnable = VK_FALSE;
290}
SkAssertResult(font.textToGlyphs("Hello", 5, SkTextEncoding::kUTF8, glyphs, std::size(glyphs))==count)
static constexpr bool SampleCountToVkSampleCount(uint32_t samples, VkSampleCountFlagBits *vkSamples)
VkPipelineMultisampleStateCreateFlags flags
Definition: vulkan_core.h:3602
VkSampleCountFlagBits rasterizationSamples
Definition: vulkan_core.h:3603
@ VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO
Definition: vulkan_core.h:226

◆ setup_raster_state()

static void setup_raster_state ( bool  isWireframe,
const GrCaps caps,
VkPipelineRasterizationStateCreateInfo rasterInfo 
)
static

Definition at line 419 of file GrVkPipeline.cpp.

421 {
422 memset(rasterInfo, 0, sizeof(VkPipelineRasterizationStateCreateInfo));
424 rasterInfo->pNext = nullptr;
425 rasterInfo->flags = 0;
426 rasterInfo->depthClampEnable = VK_FALSE;
427 rasterInfo->rasterizerDiscardEnable = VK_FALSE;
428 rasterInfo->polygonMode = (caps->wireframeMode() || isWireframe) ?
430 rasterInfo->cullMode = VK_CULL_MODE_NONE;
432 rasterInfo->depthBiasEnable = VK_FALSE;
433 rasterInfo->depthBiasConstantFactor = 0.0f;
434 rasterInfo->depthBiasClamp = 0.0f;
435 rasterInfo->depthBiasSlopeFactor = 0.0f;
436 rasterInfo->lineWidth = 1.0f;
437}
bool wireframeMode() const
Definition: GrCaps.h:399
VkPipelineRasterizationStateCreateFlags flags
Definition: vulkan_core.h:3586
@ VK_CULL_MODE_NONE
Definition: vulkan_core.h:2695
@ VK_FRONT_FACE_COUNTER_CLOCKWISE
Definition: vulkan_core.h:2022
@ VK_POLYGON_MODE_FILL
Definition: vulkan_core.h:2049
@ VK_POLYGON_MODE_LINE
Definition: vulkan_core.h:2050
@ VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO
Definition: vulkan_core.h:225

◆ setup_stencil_op_state()

static void setup_stencil_op_state ( VkStencilOpState opState,
const GrStencilSettings::Face stencilFace 
)
static

Definition at line 222 of file GrVkPipeline.cpp.

223 {
224 opState->failOp = stencil_op_to_vk_stencil_op(stencilFace.fFailOp);
225 opState->passOp = stencil_op_to_vk_stencil_op(stencilFace.fPassOp);
226 opState->depthFailOp = opState->failOp;
227 opState->compareOp = stencil_func_to_vk_compare_op(stencilFace.fTest);
228 opState->compareMask = stencilFace.fTestMask;
229 opState->writeMask = stencilFace.fWriteMask;
230 opState->reference = stencilFace.fRef;
231}
static VkStencilOp stencil_op_to_vk_stencil_op(GrStencilOp op)
static VkCompareOp stencil_func_to_vk_compare_op(GrStencilTest test)
VkStencilOp failOp
Definition: vulkan_core.h:3612
VkStencilOp passOp
Definition: vulkan_core.h:3613
uint32_t reference
Definition: vulkan_core.h:3618
VkCompareOp compareOp
Definition: vulkan_core.h:3615
uint32_t writeMask
Definition: vulkan_core.h:3617
uint32_t compareMask
Definition: vulkan_core.h:3616
VkStencilOp depthFailOp
Definition: vulkan_core.h:3614

◆ setup_vertex_input_state()

static void setup_vertex_input_state ( const GrGeometryProcessor::AttributeSet vertexAttribs,
const GrGeometryProcessor::AttributeSet instanceAttribs,
VkPipelineVertexInputStateCreateInfo vertexInputInfo,
STArray< 2, VkVertexInputBindingDescription, true > *  bindingDescs,
VkVertexInputAttributeDescription attributeDesc 
)
static

Definition at line 84 of file GrVkPipeline.cpp.

89 {
90 int vaCount = vertexAttribs.count();
91 int iaCount = instanceAttribs.count();
92
93 uint32_t vertexBinding = 0, instanceBinding = 0;
94
95 int nextBinding = bindingDescs->size();
96 if (vaCount) {
97 vertexBinding = nextBinding++;
98 }
99
100 if (iaCount) {
101 instanceBinding = nextBinding;
102 }
103
104 // setup attribute descriptions
105 int attribIndex = 0;
106 for (auto attrib : vertexAttribs) {
107 VkVertexInputAttributeDescription& vkAttrib = attributeDesc[attribIndex];
108 vkAttrib.location = attribIndex++; // for now assume location = attribIndex
109 vkAttrib.binding = vertexBinding;
110 vkAttrib.format = attrib_type_to_vkformat(attrib.cpuType());
111 vkAttrib.offset = *attrib.offset();
112 }
113
114 for (auto attrib : instanceAttribs) {
115 VkVertexInputAttributeDescription& vkAttrib = attributeDesc[attribIndex];
116 vkAttrib.location = attribIndex++; // for now assume location = attribIndex
117 vkAttrib.binding = instanceBinding;
118 vkAttrib.format = attrib_type_to_vkformat(attrib.cpuType());
119 vkAttrib.offset = *attrib.offset();
120 }
121
122 if (vaCount) {
123 bindingDescs->push_back() = {
124 vertexBinding,
125 (uint32_t) vertexAttribs.stride(),
127 };
128 }
129 if (iaCount) {
130 bindingDescs->push_back() = {
131 instanceBinding,
132 (uint32_t) instanceAttribs.stride(),
134 };
135 }
136
137 memset(vertexInputInfo, 0, sizeof(VkPipelineVertexInputStateCreateInfo));
139 vertexInputInfo->pNext = nullptr;
140 vertexInputInfo->flags = 0;
141 vertexInputInfo->vertexBindingDescriptionCount = bindingDescs->size();
142 vertexInputInfo->pVertexBindingDescriptions = bindingDescs->begin();
143 vertexInputInfo->vertexAttributeDescriptionCount = vaCount + iaCount;
144 vertexInputInfo->pVertexAttributeDescriptions = attributeDesc;
145}
static VkFormat attrib_type_to_vkformat(GrVertexAttribType type)
int size() const
Definition: SkTArray.h:421
const VkVertexInputAttributeDescription * pVertexAttributeDescriptions
Definition: vulkan_core.h:3546
const VkVertexInputBindingDescription * pVertexBindingDescriptions
Definition: vulkan_core.h:3544
VkPipelineVertexInputStateCreateFlags flags
Definition: vulkan_core.h:3542
@ VK_VERTEX_INPUT_RATE_VERTEX
Definition: vulkan_core.h:2028
@ VK_VERTEX_INPUT_RATE_INSTANCE
Definition: vulkan_core.h:2029
@ VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO
Definition: vulkan_core.h:221

◆ setup_viewport_scissor_state()

static void setup_viewport_scissor_state ( VkPipelineViewportStateCreateInfo viewportInfo)
static

Definition at line 261 of file GrVkPipeline.cpp.

261 {
262 memset(viewportInfo, 0, sizeof(VkPipelineViewportStateCreateInfo));
264 viewportInfo->pNext = nullptr;
265 viewportInfo->flags = 0;
266
267 viewportInfo->viewportCount = 1;
268 viewportInfo->pViewports = nullptr; // This is set dynamically
269
270 viewportInfo->scissorCount = 1;
271 viewportInfo->pScissors = nullptr; // This is set dynamically
272
273 SkASSERT(viewportInfo->viewportCount == viewportInfo->scissorCount);
274}
VkPipelineViewportStateCreateFlags flags
Definition: vulkan_core.h:3576
@ VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO
Definition: vulkan_core.h:224

◆ stencil_func_to_vk_compare_op()

static VkCompareOp stencil_func_to_vk_compare_op ( GrStencilTest  test)
static

Definition at line 197 of file GrVkPipeline.cpp.

197 {
198 static const VkCompareOp gTable[] = {
199 VK_COMPARE_OP_ALWAYS, // kAlways
200 VK_COMPARE_OP_NEVER, // kNever
201 VK_COMPARE_OP_GREATER, // kGreater
203 VK_COMPARE_OP_LESS, // kLess
205 VK_COMPARE_OP_EQUAL, // kEqual
206 VK_COMPARE_OP_NOT_EQUAL, // kNotEqual
207 };
208 static_assert(std::size(gTable) == kGrStencilTestCount);
209 static_assert(0 == (int)GrStencilTest::kAlways);
210 static_assert(1 == (int)GrStencilTest::kNever);
211 static_assert(2 == (int)GrStencilTest::kGreater);
212 static_assert(3 == (int)GrStencilTest::kGEqual);
213 static_assert(4 == (int)GrStencilTest::kLess);
214 static_assert(5 == (int)GrStencilTest::kLEqual);
215 static_assert(6 == (int)GrStencilTest::kEqual);
216 static_assert(7 == (int)GrStencilTest::kNotEqual);
218
219 return gTable[(int)test];
220}
static constexpr int kGrStencilTestCount
GrStencilTest
VkCompareOp
Definition: vulkan_core.h:1918
@ VK_COMPARE_OP_LESS_OR_EQUAL
Definition: vulkan_core.h:1922
@ VK_COMPARE_OP_LESS
Definition: vulkan_core.h:1920
@ VK_COMPARE_OP_NOT_EQUAL
Definition: vulkan_core.h:1924
@ VK_COMPARE_OP_NEVER
Definition: vulkan_core.h:1919
@ VK_COMPARE_OP_EQUAL
Definition: vulkan_core.h:1921
@ VK_COMPARE_OP_GREATER_OR_EQUAL
Definition: vulkan_core.h:1925
@ VK_COMPARE_OP_GREATER
Definition: vulkan_core.h:1923

◆ stencil_op_to_vk_stencil_op()

static VkStencilOp stencil_op_to_vk_stencil_op ( GrStencilOp  op)
static

Definition at line 173 of file GrVkPipeline.cpp.

173 {
174 static const VkStencilOp gTable[] = {
175 VK_STENCIL_OP_KEEP, // kKeep
176 VK_STENCIL_OP_ZERO, // kZero
177 VK_STENCIL_OP_REPLACE, // kReplace
178 VK_STENCIL_OP_INVERT, // kInvert
183 };
184 static_assert(std::size(gTable) == kGrStencilOpCount);
185 static_assert(0 == (int)GrStencilOp::kKeep);
186 static_assert(1 == (int)GrStencilOp::kZero);
187 static_assert(2 == (int)GrStencilOp::kReplace);
188 static_assert(3 == (int)GrStencilOp::kInvert);
189 static_assert(4 == (int)GrStencilOp::kIncWrap);
190 static_assert(5 == (int)GrStencilOp::kDecWrap);
191 static_assert(6 == (int)GrStencilOp::kIncClamp);
192 static_assert(7 == (int)GrStencilOp::kDecClamp);
194 return gTable[(int)op];
195}
GrStencilOp
static constexpr int kGrStencilOpCount
VkStencilOp
Definition: vulkan_core.h:2056
@ VK_STENCIL_OP_INCREMENT_AND_CLAMP
Definition: vulkan_core.h:2060
@ VK_STENCIL_OP_DECREMENT_AND_CLAMP
Definition: vulkan_core.h:2061
@ VK_STENCIL_OP_INCREMENT_AND_WRAP
Definition: vulkan_core.h:2063
@ VK_STENCIL_OP_KEEP
Definition: vulkan_core.h:2057
@ VK_STENCIL_OP_REPLACE
Definition: vulkan_core.h:2059
@ VK_STENCIL_OP_ZERO
Definition: vulkan_core.h:2058
@ VK_STENCIL_OP_DECREMENT_AND_WRAP
Definition: vulkan_core.h:2064
@ VK_STENCIL_OP_INVERT
Definition: vulkan_core.h:2062