1e5c31af7Sopenharmony_ci// Copyright 2015-2024 The Khronos Group Inc. 2e5c31af7Sopenharmony_ci// 3e5c31af7Sopenharmony_ci// SPDX-License-Identifier: CC-BY-4.0 4e5c31af7Sopenharmony_ci 5e5c31af7Sopenharmony_ci[[primsrast]] 6e5c31af7Sopenharmony_ci= Rasterization 7e5c31af7Sopenharmony_ci 8e5c31af7Sopenharmony_ciRasterization is the process by which a primitive is converted to a 9e5c31af7Sopenharmony_citwo-dimensional image. 10e5c31af7Sopenharmony_ciEach discrete location of this image contains associated data such as depth, 11e5c31af7Sopenharmony_cicolor, or other attributes. 12e5c31af7Sopenharmony_ci 13e5c31af7Sopenharmony_ciRasterizing a primitive begins by determining which squares of an integer 14e5c31af7Sopenharmony_cigrid in framebuffer coordinates are occupied by the primitive, and assigning 15e5c31af7Sopenharmony_cione or more depth values to each such square. 16e5c31af7Sopenharmony_ciThis process is described below for points, lines, and polygons. 17e5c31af7Sopenharmony_ci 18e5c31af7Sopenharmony_ciA grid square, including its [eq]#(x,y)# framebuffer coordinates, [eq]#z# 19e5c31af7Sopenharmony_ci(depth), and associated data added by fragment shaders, is called a 20e5c31af7Sopenharmony_cifragment. 21e5c31af7Sopenharmony_ciA fragment is located by its upper left corner, which lies on integer grid 22e5c31af7Sopenharmony_cicoordinates. 23e5c31af7Sopenharmony_ci 24e5c31af7Sopenharmony_ciRasterization operations also refer to a fragment's sample locations, which 25e5c31af7Sopenharmony_ciare offset by fractional values from its upper left corner. 26e5c31af7Sopenharmony_ciThe rasterization rules for points, lines, and triangles involve testing 27e5c31af7Sopenharmony_ciwhether each sample location is inside the primitive. 28e5c31af7Sopenharmony_ciFragments need not actually be square, and rasterization rules are not 29e5c31af7Sopenharmony_ciaffected by the aspect ratio of fragments. 30e5c31af7Sopenharmony_ciDisplay of non-square grids, however, will cause rasterized points and line 31e5c31af7Sopenharmony_cisegments to appear fatter in one direction than the other. 32e5c31af7Sopenharmony_ci 33e5c31af7Sopenharmony_ciWe assume that fragments are square, since it simplifies antialiasing and 34e5c31af7Sopenharmony_citexturing. 35e5c31af7Sopenharmony_ciAfter rasterization, fragments are processed by <<fragops, fragment 36e5c31af7Sopenharmony_cioperations>>. 37e5c31af7Sopenharmony_ci 38e5c31af7Sopenharmony_ciSeveral factors affect rasterization, including the members of 39e5c31af7Sopenharmony_cislink:VkPipelineRasterizationStateCreateInfo and 40e5c31af7Sopenharmony_cislink:VkPipelineMultisampleStateCreateInfo. 41e5c31af7Sopenharmony_ci 42e5c31af7Sopenharmony_ci[open,refpage='VkPipelineRasterizationStateCreateInfo',desc='Structure specifying parameters of a newly created pipeline rasterization state',type='structs'] 43e5c31af7Sopenharmony_ci-- 44e5c31af7Sopenharmony_ciThe sname:VkPipelineRasterizationStateCreateInfo structure is defined as: 45e5c31af7Sopenharmony_ci 46e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkPipelineRasterizationStateCreateInfo.adoc[] 47e5c31af7Sopenharmony_ci 48e5c31af7Sopenharmony_ci * pname:sType is a elink:VkStructureType value identifying this structure. 49e5c31af7Sopenharmony_ci * pname:pNext is `NULL` or a pointer to a structure extending this 50e5c31af7Sopenharmony_ci structure. 51e5c31af7Sopenharmony_ci * pname:flags is reserved for future use. 52e5c31af7Sopenharmony_ci * pname:depthClampEnable controls whether to clamp the fragment's depth 53e5c31af7Sopenharmony_ci values as described in <<fragops-depth,Depth Test>>. 54e5c31af7Sopenharmony_ciifdef::VK_EXT_depth_clip_enable[] 55e5c31af7Sopenharmony_ci If the pipeline is not created with 56e5c31af7Sopenharmony_ci slink:VkPipelineRasterizationDepthClipStateCreateInfoEXT present then 57e5c31af7Sopenharmony_ci enabling depth clamp will also disable clipping primitives to the z 58e5c31af7Sopenharmony_ci planes of the frustum as described in <<vertexpostproc-clipping, 59e5c31af7Sopenharmony_ci Primitive Clipping>>. 60e5c31af7Sopenharmony_ci Otherwise depth clipping is controlled by the state set in 61e5c31af7Sopenharmony_ci slink:VkPipelineRasterizationDepthClipStateCreateInfoEXT. 62e5c31af7Sopenharmony_ciendif::VK_EXT_depth_clip_enable[] 63e5c31af7Sopenharmony_ciifndef::VK_EXT_depth_clip_enable[] 64e5c31af7Sopenharmony_ci Enabling depth clamp will also disable clipping primitives to the z 65e5c31af7Sopenharmony_ci planes of the frustum as described in <<vertexpostproc-clipping, 66e5c31af7Sopenharmony_ci Primitive Clipping>>. 67e5c31af7Sopenharmony_ciendif::VK_EXT_depth_clip_enable[] 68e5c31af7Sopenharmony_ci * pname:rasterizerDiscardEnable controls whether primitives are discarded 69e5c31af7Sopenharmony_ci immediately before the rasterization stage. 70e5c31af7Sopenharmony_ci * pname:polygonMode is the triangle rendering mode. 71e5c31af7Sopenharmony_ci See elink:VkPolygonMode. 72e5c31af7Sopenharmony_ci * pname:cullMode is the triangle facing direction used for primitive 73e5c31af7Sopenharmony_ci culling. 74e5c31af7Sopenharmony_ci See elink:VkCullModeFlagBits. 75e5c31af7Sopenharmony_ci * pname:frontFace is a elink:VkFrontFace value specifying the front-facing 76e5c31af7Sopenharmony_ci triangle orientation to be used for culling. 77e5c31af7Sopenharmony_ci * pname:depthBiasEnable controls whether to bias fragment depth values. 78e5c31af7Sopenharmony_ci * pname:depthBiasConstantFactor is a scalar factor controlling the 79e5c31af7Sopenharmony_ci constant depth value added to each fragment. 80e5c31af7Sopenharmony_ci * pname:depthBiasClamp is the maximum (or minimum) depth bias of a 81e5c31af7Sopenharmony_ci fragment. 82e5c31af7Sopenharmony_ci * pname:depthBiasSlopeFactor is a scalar factor applied to a fragment's 83e5c31af7Sopenharmony_ci slope in depth bias calculations. 84e5c31af7Sopenharmony_ci * pname:lineWidth is the width of rasterized line segments. 85e5c31af7Sopenharmony_ci 86e5c31af7Sopenharmony_ciifdef::VK_AMD_rasterization_order[] 87e5c31af7Sopenharmony_ciThe application can: also add a 88e5c31af7Sopenharmony_cisname:VkPipelineRasterizationStateRasterizationOrderAMD structure to the 89e5c31af7Sopenharmony_cipname:pNext chain of a slink:VkPipelineRasterizationStateCreateInfo 90e5c31af7Sopenharmony_cistructure. 91e5c31af7Sopenharmony_ciThis structure enables selecting the rasterization order to use when 92e5c31af7Sopenharmony_cirendering with the corresponding graphics pipeline as described in 93e5c31af7Sopenharmony_ci<<primsrast-order, Rasterization Order>>. 94e5c31af7Sopenharmony_ciendif::VK_AMD_rasterization_order[] 95e5c31af7Sopenharmony_ci 96e5c31af7Sopenharmony_ci.Valid Usage 97e5c31af7Sopenharmony_ci**** 98e5c31af7Sopenharmony_ci * [[VUID-VkPipelineRasterizationStateCreateInfo-depthClampEnable-00782]] 99e5c31af7Sopenharmony_ci If the <<features-depthClamp, pname:depthClamp>> feature is not enabled, 100e5c31af7Sopenharmony_ci pname:depthClampEnable must: be ename:VK_FALSE 101e5c31af7Sopenharmony_ci * [[VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507]] 102e5c31af7Sopenharmony_ci If the <<features-fillModeNonSolid, pname:fillModeNonSolid>> feature is 103e5c31af7Sopenharmony_ci not enabled, pname:polygonMode must: be ename:VK_POLYGON_MODE_FILL 104e5c31af7Sopenharmony_ciifdef::VK_NV_fill_rectangle[or ename:VK_POLYGON_MODE_FILL_RECTANGLE_NV] 105e5c31af7Sopenharmony_ciifdef::VK_NV_fill_rectangle[] 106e5c31af7Sopenharmony_ci * [[VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414]] 107e5c31af7Sopenharmony_ci If the `apiext:VK_NV_fill_rectangle` extension is not enabled, 108e5c31af7Sopenharmony_ci pname:polygonMode must: not be ename:VK_POLYGON_MODE_FILL_RECTANGLE_NV 109e5c31af7Sopenharmony_ciendif::VK_NV_fill_rectangle[] 110e5c31af7Sopenharmony_ciifdef::VK_KHR_portability_subset[] 111e5c31af7Sopenharmony_ci * [[VUID-VkPipelineRasterizationStateCreateInfo-pointPolygons-04458]] 112e5c31af7Sopenharmony_ci If the `apiext:VK_KHR_portability_subset` extension is enabled, and 113e5c31af7Sopenharmony_ci slink:VkPhysicalDevicePortabilitySubsetFeaturesKHR::pname:pointPolygons 114e5c31af7Sopenharmony_ci is ename:VK_FALSE, and pname:rasterizerDiscardEnable is ename:VK_FALSE, 115e5c31af7Sopenharmony_ci pname:polygonMode must: not be ename:VK_POLYGON_MODE_POINT 116e5c31af7Sopenharmony_ciendif::VK_KHR_portability_subset[] 117e5c31af7Sopenharmony_ci**** 118e5c31af7Sopenharmony_ci 119e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkPipelineRasterizationStateCreateInfo.adoc[] 120e5c31af7Sopenharmony_ci-- 121e5c31af7Sopenharmony_ci 122e5c31af7Sopenharmony_ci[open,refpage='VkPipelineRasterizationStateCreateFlags',desc='Reserved for future use',type='flags'] 123e5c31af7Sopenharmony_ci-- 124e5c31af7Sopenharmony_ciinclude::{generated}/api/flags/VkPipelineRasterizationStateCreateFlags.adoc[] 125e5c31af7Sopenharmony_ci 126e5c31af7Sopenharmony_citname:VkPipelineRasterizationStateCreateFlags is a bitmask type for setting 127e5c31af7Sopenharmony_cia mask, but is currently reserved for future use. 128e5c31af7Sopenharmony_ci-- 129e5c31af7Sopenharmony_ci 130e5c31af7Sopenharmony_ciifdef::VK_EXT_depth_clip_enable[] 131e5c31af7Sopenharmony_ci[open,refpage='VkPipelineRasterizationDepthClipStateCreateInfoEXT',desc='Structure specifying depth clipping state',type='structs'] 132e5c31af7Sopenharmony_ci-- 133e5c31af7Sopenharmony_ciIf the pname:pNext chain of slink:VkPipelineRasterizationStateCreateInfo 134e5c31af7Sopenharmony_ciincludes a sname:VkPipelineRasterizationDepthClipStateCreateInfoEXT 135e5c31af7Sopenharmony_cistructure, then that structure controls whether depth clipping is enabled or 136e5c31af7Sopenharmony_cidisabled. 137e5c31af7Sopenharmony_ci 138e5c31af7Sopenharmony_ciThe sname:VkPipelineRasterizationDepthClipStateCreateInfoEXT structure is 139e5c31af7Sopenharmony_cidefined as: 140e5c31af7Sopenharmony_ci 141e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkPipelineRasterizationDepthClipStateCreateInfoEXT.adoc[] 142e5c31af7Sopenharmony_ci 143e5c31af7Sopenharmony_ci * pname:sType is a elink:VkStructureType value identifying this structure. 144e5c31af7Sopenharmony_ci * pname:pNext is `NULL` or a pointer to a structure extending this 145e5c31af7Sopenharmony_ci structure. 146e5c31af7Sopenharmony_ci * pname:flags is reserved for future use. 147e5c31af7Sopenharmony_ci * pname:depthClipEnable controls whether depth clipping is enabled as 148e5c31af7Sopenharmony_ci described in <<vertexpostproc-clipping, Primitive Clipping>>. 149e5c31af7Sopenharmony_ci 150e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkPipelineRasterizationDepthClipStateCreateInfoEXT.adoc[] 151e5c31af7Sopenharmony_ci-- 152e5c31af7Sopenharmony_ci 153e5c31af7Sopenharmony_ci[open,refpage='VkPipelineRasterizationDepthClipStateCreateFlagsEXT',desc='Reserved for future use',type='flags'] 154e5c31af7Sopenharmony_ci-- 155e5c31af7Sopenharmony_ciinclude::{generated}/api/flags/VkPipelineRasterizationDepthClipStateCreateFlagsEXT.adoc[] 156e5c31af7Sopenharmony_ci 157e5c31af7Sopenharmony_citname:VkPipelineRasterizationDepthClipStateCreateFlagsEXT is a bitmask type 158e5c31af7Sopenharmony_cifor setting a mask, but is currently reserved for future use. 159e5c31af7Sopenharmony_ci-- 160e5c31af7Sopenharmony_ciendif::VK_EXT_depth_clip_enable[] 161e5c31af7Sopenharmony_ci 162e5c31af7Sopenharmony_ci[open,refpage='VkPipelineMultisampleStateCreateInfo',desc='Structure specifying parameters of a newly created pipeline multisample state',type='structs'] 163e5c31af7Sopenharmony_ci-- 164e5c31af7Sopenharmony_ciThe sname:VkPipelineMultisampleStateCreateInfo structure is defined as: 165e5c31af7Sopenharmony_ci 166e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkPipelineMultisampleStateCreateInfo.adoc[] 167e5c31af7Sopenharmony_ci 168e5c31af7Sopenharmony_ci * pname:sType is a elink:VkStructureType value identifying this structure. 169e5c31af7Sopenharmony_ci * pname:pNext is `NULL` or a pointer to a structure extending this 170e5c31af7Sopenharmony_ci structure. 171e5c31af7Sopenharmony_ci * pname:flags is reserved for future use. 172e5c31af7Sopenharmony_ci * pname:rasterizationSamples is a elink:VkSampleCountFlagBits value 173e5c31af7Sopenharmony_ci specifying the number of samples used in rasterization. 174e5c31af7Sopenharmony_ciifdef::VK_EXT_extended_dynamic_state3[] 175e5c31af7Sopenharmony_ci This value is ignored for the purposes of setting the number of samples 176e5c31af7Sopenharmony_ci used in rasterization if the pipeline is created with the 177e5c31af7Sopenharmony_ci ename:VK_DYNAMIC_STATE_RASTERIZATION_SAMPLES_EXT dynamic state set, but 178e5c31af7Sopenharmony_ci if ename:VK_DYNAMIC_STATE_SAMPLE_MASK_EXT dynamic state is not set, it 179e5c31af7Sopenharmony_ci is still used to define the size of the pname:pSampleMask array as 180e5c31af7Sopenharmony_ci described below. 181e5c31af7Sopenharmony_ciendif::VK_EXT_extended_dynamic_state3[] 182e5c31af7Sopenharmony_ci * pname:sampleShadingEnable can: be used to enable 183e5c31af7Sopenharmony_ci <<primsrast-sampleshading,Sample Shading>>. 184e5c31af7Sopenharmony_ci * pname:minSampleShading specifies a minimum fraction of sample shading if 185e5c31af7Sopenharmony_ci pname:sampleShadingEnable is set to ename:VK_TRUE. 186e5c31af7Sopenharmony_ci * pname:pSampleMask is a pointer to an array of basetype:VkSampleMask 187e5c31af7Sopenharmony_ci values used in the <<fragops-samplemask,sample mask test>>. 188e5c31af7Sopenharmony_ci * pname:alphaToCoverageEnable controls whether a temporary coverage value 189e5c31af7Sopenharmony_ci is generated based on the alpha component of the fragment's first color 190e5c31af7Sopenharmony_ci output as specified in the <<fragops-covg,Multisample Coverage>> 191e5c31af7Sopenharmony_ci section. 192e5c31af7Sopenharmony_ci * pname:alphaToOneEnable controls whether the alpha component of the 193e5c31af7Sopenharmony_ci fragment's first color output is replaced with one as described in 194e5c31af7Sopenharmony_ci <<fragops-covg,Multisample Coverage>>. 195e5c31af7Sopenharmony_ci 196e5c31af7Sopenharmony_ciEach bit in the sample mask is associated with a unique 197e5c31af7Sopenharmony_ci<<primsrast-multisampling-coverage-mask, sample index>> as defined for the 198e5c31af7Sopenharmony_ci<<primsrast-multisampling-coverage-mask, coverage mask>>. 199e5c31af7Sopenharmony_ciEach bit [eq]#b# for mask word [eq]#w# in the sample mask corresponds to 200e5c31af7Sopenharmony_cisample index [eq]#i#, where [eq]#i = 32 {times} w {plus} b#. 201e5c31af7Sopenharmony_cipname:pSampleMask has a length equal to [eq]#{lceil} 202e5c31af7Sopenharmony_cipname:rasterizationSamples / 32 {rceil}# words. 203e5c31af7Sopenharmony_ci 204e5c31af7Sopenharmony_ciIf pname:pSampleMask is `NULL`, it is treated as if the mask has all bits 205e5c31af7Sopenharmony_ciset to `1`. 206e5c31af7Sopenharmony_ci 207e5c31af7Sopenharmony_ci.Valid Usage 208e5c31af7Sopenharmony_ci**** 209e5c31af7Sopenharmony_ci * [[VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784]] 210e5c31af7Sopenharmony_ci If the <<features-sampleRateShading, pname:sampleRateShading>> feature 211e5c31af7Sopenharmony_ci is not enabled, pname:sampleShadingEnable must: be ename:VK_FALSE 212e5c31af7Sopenharmony_ci * [[VUID-VkPipelineMultisampleStateCreateInfo-alphaToOneEnable-00785]] 213e5c31af7Sopenharmony_ci If the <<features-alphaToOne, pname:alphaToOne>> feature is not enabled, 214e5c31af7Sopenharmony_ci pname:alphaToOneEnable must: be ename:VK_FALSE 215e5c31af7Sopenharmony_ci * [[VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786]] 216e5c31af7Sopenharmony_ci pname:minSampleShading must: be in the range [eq]#[0,1]# 217e5c31af7Sopenharmony_ciifdef::VK_NV_framebuffer_mixed_samples[] 218e5c31af7Sopenharmony_ci * [[VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-01415]] 219e5c31af7Sopenharmony_ci If the `apiext:VK_NV_framebuffer_mixed_samples` extension is enabled, 220e5c31af7Sopenharmony_ci and if the subpass has any color attachments and 221e5c31af7Sopenharmony_ci pname:rasterizationSamples is greater than the number of color samples, 222e5c31af7Sopenharmony_ci then pname:sampleShadingEnable must: be ename:VK_FALSE 223e5c31af7Sopenharmony_ciendif::VK_NV_framebuffer_mixed_samples[] 224e5c31af7Sopenharmony_ci**** 225e5c31af7Sopenharmony_ci 226e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkPipelineMultisampleStateCreateInfo.adoc[] 227e5c31af7Sopenharmony_ci-- 228e5c31af7Sopenharmony_ci 229e5c31af7Sopenharmony_ci[open,refpage='VkPipelineMultisampleStateCreateFlags',desc='Reserved for future use',type='flags'] 230e5c31af7Sopenharmony_ci-- 231e5c31af7Sopenharmony_ciinclude::{generated}/api/flags/VkPipelineMultisampleStateCreateFlags.adoc[] 232e5c31af7Sopenharmony_ci 233e5c31af7Sopenharmony_citname:VkPipelineMultisampleStateCreateFlags is a bitmask type for setting a 234e5c31af7Sopenharmony_cimask, but is currently reserved for future use. 235e5c31af7Sopenharmony_ci-- 236e5c31af7Sopenharmony_ci 237e5c31af7Sopenharmony_ci[open,refpage='VkSampleMask',desc='Mask of sample coverage information',type='basetypes',xrefs='VkPipelineMultisampleStateCreateInfo'] 238e5c31af7Sopenharmony_ci-- 239e5c31af7Sopenharmony_ciThe elements of the sample mask array are of type basetype:VkSampleMask, 240e5c31af7Sopenharmony_cieach representing 32 bits of coverage information: 241e5c31af7Sopenharmony_ci 242e5c31af7Sopenharmony_ciinclude::{generated}/api/basetypes/VkSampleMask.adoc[] 243e5c31af7Sopenharmony_ci-- 244e5c31af7Sopenharmony_ci 245e5c31af7Sopenharmony_ciRasterization only generates fragments which cover one or more pixels inside 246e5c31af7Sopenharmony_cithe framebuffer. 247e5c31af7Sopenharmony_ciPixels outside the framebuffer are never considered covered in the fragment. 248e5c31af7Sopenharmony_ciFragments which would be produced by application of any of the primitive 249e5c31af7Sopenharmony_cirasterization rules described below but which lie outside the framebuffer 250e5c31af7Sopenharmony_ciare not produced, nor are they processed by any later stage of the pipeline, 251e5c31af7Sopenharmony_ciincluding any of the <<fragops, fragment operations>>. 252e5c31af7Sopenharmony_ci 253e5c31af7Sopenharmony_ciSurviving fragments are processed by fragment shaders. 254e5c31af7Sopenharmony_ciFragment shaders determine associated data for fragments, and can: also 255e5c31af7Sopenharmony_cimodify or replace their assigned depth values. 256e5c31af7Sopenharmony_ci 257e5c31af7Sopenharmony_ci 258e5c31af7Sopenharmony_ci[[primsrast-discard]] 259e5c31af7Sopenharmony_ci== Discarding Primitives Before Rasterization 260e5c31af7Sopenharmony_ci 261e5c31af7Sopenharmony_ciPrimitives are discarded before rasterization if the 262e5c31af7Sopenharmony_cipname:rasterizerDiscardEnable member of 263e5c31af7Sopenharmony_cislink:VkPipelineRasterizationStateCreateInfo is enabled. 264e5c31af7Sopenharmony_ciWhen enabled, primitives are discarded after they are processed by the last 265e5c31af7Sopenharmony_ciactive shader stage in the pipeline before rasterization. 266e5c31af7Sopenharmony_ci 267e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_3,VK_EXT_extended_dynamic_state2,VK_EXT_shader_object[] 268e5c31af7Sopenharmony_ci[open,refpage='vkCmdSetRasterizerDiscardEnable',desc='Control whether primitives are discarded before the rasterization stage dynamically for a command buffer',type='protos',alias='vkCmdSetRasterizerDiscardEnableEXT'] 269e5c31af7Sopenharmony_ci-- 270e5c31af7Sopenharmony_ciTo <<pipelines-dynamic-state, dynamically enable>> whether primitives are 271e5c31af7Sopenharmony_cidiscarded before the rasterization stage, call: 272e5c31af7Sopenharmony_ci 273e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_3[] 274e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCmdSetRasterizerDiscardEnable.adoc[] 275e5c31af7Sopenharmony_ci 276e5c31af7Sopenharmony_ciifdef::VK_EXT_extended_dynamic_state2,VK_EXT_shader_object[or the equivalent command] 277e5c31af7Sopenharmony_ciendif::VK_VERSION_1_3[] 278e5c31af7Sopenharmony_ci 279e5c31af7Sopenharmony_ciifdef::VK_EXT_extended_dynamic_state2,VK_EXT_shader_object[] 280e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCmdSetRasterizerDiscardEnableEXT.adoc[] 281e5c31af7Sopenharmony_ciendif::VK_EXT_extended_dynamic_state2,VK_EXT_shader_object[] 282e5c31af7Sopenharmony_ci 283e5c31af7Sopenharmony_ci * pname:commandBuffer is the command buffer into which the command will be 284e5c31af7Sopenharmony_ci recorded. 285e5c31af7Sopenharmony_ci * pname:rasterizerDiscardEnable controls whether primitives are discarded 286e5c31af7Sopenharmony_ci immediately before the rasterization stage. 287e5c31af7Sopenharmony_ci 288e5c31af7Sopenharmony_ciThis command sets the discard enable for subsequent drawing commands 289e5c31af7Sopenharmony_ciifdef::VK_EXT_shader_object[] 290e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_3,VK_EXT_extended_dynamic_state2[when drawing using <<shaders-objects, shader objects>>, or] 291e5c31af7Sopenharmony_ciifndef::VK_VERSION_1_3,VK_EXT_extended_dynamic_state2[when drawing using <<shaders-objects, shader objects>>.] 292e5c31af7Sopenharmony_ciendif::VK_EXT_shader_object[] 293e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_3,VK_EXT_extended_dynamic_state2[] 294e5c31af7Sopenharmony_ciwhen the graphics pipeline is created with 295e5c31af7Sopenharmony_ciename:VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE set in 296e5c31af7Sopenharmony_cislink:VkPipelineDynamicStateCreateInfo::pname:pDynamicStates. 297e5c31af7Sopenharmony_ciendif::VK_VERSION_1_3,VK_EXT_extended_dynamic_state2[] 298e5c31af7Sopenharmony_ciOtherwise, this state is specified by the 299e5c31af7Sopenharmony_cislink:VkPipelineRasterizationStateCreateInfo::pname:rasterizerDiscardEnable 300e5c31af7Sopenharmony_civalue used to create the currently active pipeline. 301e5c31af7Sopenharmony_ci 302e5c31af7Sopenharmony_ci:refpage: vkCmdSetRasterizerDiscardEnable 303e5c31af7Sopenharmony_ci 304e5c31af7Sopenharmony_ci.Valid Usage 305e5c31af7Sopenharmony_ci**** 306e5c31af7Sopenharmony_ciinclude::{chapters}/commonvalidity/dynamic_state2_feature_common.adoc[] 307e5c31af7Sopenharmony_ci**** 308e5c31af7Sopenharmony_ci 309e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkCmdSetRasterizerDiscardEnable.adoc[] 310e5c31af7Sopenharmony_ci-- 311e5c31af7Sopenharmony_ciendif::VK_VERSION_1_3,VK_EXT_extended_dynamic_state2,VK_EXT_shader_object[] 312e5c31af7Sopenharmony_ci 313e5c31af7Sopenharmony_ci 314e5c31af7Sopenharmony_ciifdef::VK_EXT_transform_feedback[] 315e5c31af7Sopenharmony_ci[[primsrast-stream]] 316e5c31af7Sopenharmony_ci== Controlling the Vertex Stream Used for Rasterization 317e5c31af7Sopenharmony_ci 318e5c31af7Sopenharmony_ciBy default vertex data output from the last 319e5c31af7Sopenharmony_ci<<pipelines-graphics-subsets-pre-rasterization,pre-rasterization shader 320e5c31af7Sopenharmony_cistage>> are directed to vertex stream zero. 321e5c31af7Sopenharmony_ciGeometry shaders can: emit primitives to multiple independent vertex 322e5c31af7Sopenharmony_cistreams. 323e5c31af7Sopenharmony_ciEach vertex emitted by the geometry shader is directed at one of the vertex 324e5c31af7Sopenharmony_cistreams. 325e5c31af7Sopenharmony_ciAs vertices are received on each vertex stream, they are arranged into 326e5c31af7Sopenharmony_ciprimitives of the type specified by the geometry shader output primitive 327e5c31af7Sopenharmony_citype. 328e5c31af7Sopenharmony_ciThe shading language instructions code:OpEndPrimitive and 329e5c31af7Sopenharmony_cicode:OpEndStreamPrimitive can: be used to end the primitive being assembled 330e5c31af7Sopenharmony_cion a given vertex stream and start a new empty primitive of the same type. 331e5c31af7Sopenharmony_ciAn implementation supports up to 332e5c31af7Sopenharmony_cisname:VkPhysicalDeviceTransformFeedbackPropertiesEXT::pname:maxTransformFeedbackStreams 333e5c31af7Sopenharmony_cistreams, which is at least 1. 334e5c31af7Sopenharmony_ciThe individual streams are numbered 0 through 335e5c31af7Sopenharmony_cipname:maxTransformFeedbackStreams minus 1. 336e5c31af7Sopenharmony_ciThere is no requirement on the order of the streams to which vertices are 337e5c31af7Sopenharmony_ciemitted, and the number of vertices emitted to each vertex stream can: be 338e5c31af7Sopenharmony_cicompletely independent, subject only to the 339e5c31af7Sopenharmony_cisname:VkPhysicalDeviceTransformFeedbackPropertiesEXT::pname:maxTransformFeedbackStreamDataSize 340e5c31af7Sopenharmony_ciand 341e5c31af7Sopenharmony_cisname:VkPhysicalDeviceTransformFeedbackPropertiesEXT::pname:maxTransformFeedbackBufferDataSize 342e5c31af7Sopenharmony_cilimits. 343e5c31af7Sopenharmony_ciThe primitives output from all vertex streams are passed to the transform 344e5c31af7Sopenharmony_cifeedback stage to be captured to transform feedback buffers in the manner 345e5c31af7Sopenharmony_cispecified by the last 346e5c31af7Sopenharmony_ci<<pipelines-graphics-subsets-pre-rasterization,pre-rasterization shader 347e5c31af7Sopenharmony_cistage>> shader's code:XfbBuffer, code:XfbStride, and code:Offsets 348e5c31af7Sopenharmony_cidecorations on the output interface variables in the graphics pipeline. 349e5c31af7Sopenharmony_ciTo use a vertex stream other than zero, or to use multiple streams, the 350e5c31af7Sopenharmony_cicode:GeometryStreams capability must: be specified. 351e5c31af7Sopenharmony_ci 352e5c31af7Sopenharmony_ciBy default, the primitives output from vertex stream zero are rasterized. 353e5c31af7Sopenharmony_ciIf the implementation supports the 354e5c31af7Sopenharmony_cislink:VkPhysicalDeviceTransformFeedbackPropertiesEXT::pname:transformFeedbackRasterizationStreamSelect 355e5c31af7Sopenharmony_ciproperty it is possible to rasterize a vertex stream other than zero. 356e5c31af7Sopenharmony_ci 357e5c31af7Sopenharmony_ciBy default, geometry shaders that emit vertices to multiple vertex streams 358e5c31af7Sopenharmony_ciare limited to using only the code:OutputPoints output primitive type. 359e5c31af7Sopenharmony_ciIf the implementation supports the 360e5c31af7Sopenharmony_cislink:VkPhysicalDeviceTransformFeedbackPropertiesEXT::pname:transformFeedbackStreamsLinesTriangles 361e5c31af7Sopenharmony_ciproperty it is possible to emit code:OutputLineStrip or 362e5c31af7Sopenharmony_cicode:OutputTriangleStrip in addition to code:OutputPoints. 363e5c31af7Sopenharmony_ci 364e5c31af7Sopenharmony_ci[open,refpage='VkPipelineRasterizationStateStreamCreateInfoEXT',desc='Structure defining the geometry stream used for rasterization',type='structs'] 365e5c31af7Sopenharmony_ci-- 366e5c31af7Sopenharmony_ciThe vertex stream used for rasterization is specified by adding a 367e5c31af7Sopenharmony_cisname:VkPipelineRasterizationStateStreamCreateInfoEXT structure to the 368e5c31af7Sopenharmony_cipname:pNext chain of a slink:VkPipelineRasterizationStateCreateInfo 369e5c31af7Sopenharmony_cistructure. 370e5c31af7Sopenharmony_ci 371e5c31af7Sopenharmony_ciThe sname:VkPipelineRasterizationStateStreamCreateInfoEXT structure is 372e5c31af7Sopenharmony_cidefined as: 373e5c31af7Sopenharmony_ci 374e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkPipelineRasterizationStateStreamCreateInfoEXT.adoc[] 375e5c31af7Sopenharmony_ci 376e5c31af7Sopenharmony_ci * pname:sType is a elink:VkStructureType value identifying this structure. 377e5c31af7Sopenharmony_ci * pname:pNext is `NULL` or a pointer to a structure extending this 378e5c31af7Sopenharmony_ci structure. 379e5c31af7Sopenharmony_ci * pname:flags is reserved for future use. 380e5c31af7Sopenharmony_ci * pname:rasterizationStream is the vertex stream selected for 381e5c31af7Sopenharmony_ci rasterization. 382e5c31af7Sopenharmony_ci 383e5c31af7Sopenharmony_ciIf this structure is not present, pname:rasterizationStream is assumed to be 384e5c31af7Sopenharmony_cizero. 385e5c31af7Sopenharmony_ci 386e5c31af7Sopenharmony_ci.Valid Usage 387e5c31af7Sopenharmony_ci**** 388e5c31af7Sopenharmony_ci * [[VUID-VkPipelineRasterizationStateStreamCreateInfoEXT-geometryStreams-02324]] 389e5c31af7Sopenharmony_ci sname:VkPhysicalDeviceTransformFeedbackFeaturesEXT::pname:geometryStreams 390e5c31af7Sopenharmony_ci must: be enabled 391e5c31af7Sopenharmony_ci * [[VUID-VkPipelineRasterizationStateStreamCreateInfoEXT-rasterizationStream-02325]] 392e5c31af7Sopenharmony_ci pname:rasterizationStream must: be less than 393e5c31af7Sopenharmony_ci slink:VkPhysicalDeviceTransformFeedbackPropertiesEXT::pname:maxTransformFeedbackStreams 394e5c31af7Sopenharmony_ci * [[VUID-VkPipelineRasterizationStateStreamCreateInfoEXT-rasterizationStream-02326]] 395e5c31af7Sopenharmony_ci pname:rasterizationStream must: be zero if 396e5c31af7Sopenharmony_ci sname:VkPhysicalDeviceTransformFeedbackPropertiesEXT::pname:transformFeedbackRasterizationStreamSelect 397e5c31af7Sopenharmony_ci is ename:VK_FALSE 398e5c31af7Sopenharmony_ci**** 399e5c31af7Sopenharmony_ci 400e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkPipelineRasterizationStateStreamCreateInfoEXT.adoc[] 401e5c31af7Sopenharmony_ci-- 402e5c31af7Sopenharmony_ci 403e5c31af7Sopenharmony_ci[open,refpage='VkPipelineRasterizationStateStreamCreateFlagsEXT',desc='Reserved for future use',type='flags'] 404e5c31af7Sopenharmony_ci-- 405e5c31af7Sopenharmony_ciinclude::{generated}/api/flags/VkPipelineRasterizationStateStreamCreateFlagsEXT.adoc[] 406e5c31af7Sopenharmony_ci 407e5c31af7Sopenharmony_citname:VkPipelineRasterizationStateStreamCreateFlagsEXT is a bitmask type for 408e5c31af7Sopenharmony_cisetting a mask, but is currently reserved for future use. 409e5c31af7Sopenharmony_ci-- 410e5c31af7Sopenharmony_ci 411e5c31af7Sopenharmony_ciifdef::VK_EXT_extended_dynamic_state3,VK_EXT_shader_object[] 412e5c31af7Sopenharmony_ci[open,refpage='vkCmdSetRasterizationStreamEXT',desc='Specify the rasterization stream dynamically for a command buffer',type='protos'] 413e5c31af7Sopenharmony_ci-- 414e5c31af7Sopenharmony_ciTo <<pipelines-dynamic-state, dynamically set>> the 415e5c31af7Sopenharmony_cipname:rasterizationStream state, call: 416e5c31af7Sopenharmony_ci 417e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCmdSetRasterizationStreamEXT.adoc[] 418e5c31af7Sopenharmony_ci 419e5c31af7Sopenharmony_ci * pname:commandBuffer is the command buffer into which the command will be 420e5c31af7Sopenharmony_ci recorded. 421e5c31af7Sopenharmony_ci * pname:rasterizationStream specifies the pname:rasterizationStream state. 422e5c31af7Sopenharmony_ci 423e5c31af7Sopenharmony_ciThis command sets the pname:rasterizationStream state for subsequent drawing 424e5c31af7Sopenharmony_cicommands 425e5c31af7Sopenharmony_ciifdef::VK_EXT_shader_object[] 426e5c31af7Sopenharmony_ciifdef::VK_EXT_extended_dynamic_state3[when drawing using <<shaders-objects, shader objects>>, or] 427e5c31af7Sopenharmony_ciifndef::VK_EXT_extended_dynamic_state3[when drawing using <<shaders-objects, shader objects>>.] 428e5c31af7Sopenharmony_ciendif::VK_EXT_shader_object[] 429e5c31af7Sopenharmony_ciifdef::VK_EXT_extended_dynamic_state3[] 430e5c31af7Sopenharmony_ciwhen the graphics pipeline is created with 431e5c31af7Sopenharmony_ciename:VK_DYNAMIC_STATE_RASTERIZATION_STREAM_EXT set in 432e5c31af7Sopenharmony_cislink:VkPipelineDynamicStateCreateInfo::pname:pDynamicStates. 433e5c31af7Sopenharmony_ciendif::VK_EXT_extended_dynamic_state3[] 434e5c31af7Sopenharmony_ciOtherwise, this state is specified by the 435e5c31af7Sopenharmony_cislink:VkPipelineRasterizationStateStreamCreateInfoEXT::pname:rasterizationStream 436e5c31af7Sopenharmony_civalue used to create the currently active pipeline. 437e5c31af7Sopenharmony_ci 438e5c31af7Sopenharmony_ci:refpage: vkCmdSetRasterizationStreamEXT 439e5c31af7Sopenharmony_ci:requiredfeature: extendedDynamicState3RasterizationStream 440e5c31af7Sopenharmony_ci 441e5c31af7Sopenharmony_ci.Valid Usage 442e5c31af7Sopenharmony_ci**** 443e5c31af7Sopenharmony_ciinclude::{chapters}/commonvalidity/dynamic_state3_feature_common.adoc[] 444e5c31af7Sopenharmony_ci * [[VUID-vkCmdSetRasterizationStreamEXT-transformFeedback-07411]] 445e5c31af7Sopenharmony_ci The <<features-transformFeedback, pname:transformFeedback>> feature 446e5c31af7Sopenharmony_ci must: be enabled 447e5c31af7Sopenharmony_ci * [[VUID-vkCmdSetRasterizationStreamEXT-rasterizationStream-07412]] 448e5c31af7Sopenharmony_ci pname:rasterizationStream must: be less than 449e5c31af7Sopenharmony_ci slink:VkPhysicalDeviceTransformFeedbackPropertiesEXT::pname:maxTransformFeedbackStreams 450e5c31af7Sopenharmony_ci * [[VUID-vkCmdSetRasterizationStreamEXT-rasterizationStream-07413]] 451e5c31af7Sopenharmony_ci pname:rasterizationStream must: be zero if 452e5c31af7Sopenharmony_ci sname:VkPhysicalDeviceTransformFeedbackPropertiesEXT::pname:transformFeedbackRasterizationStreamSelect 453e5c31af7Sopenharmony_ci is ename:VK_FALSE 454e5c31af7Sopenharmony_ci**** 455e5c31af7Sopenharmony_ci 456e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkCmdSetRasterizationStreamEXT.adoc[] 457e5c31af7Sopenharmony_ci-- 458e5c31af7Sopenharmony_ciendif::VK_EXT_extended_dynamic_state3,VK_EXT_shader_object[] 459e5c31af7Sopenharmony_ciendif::VK_EXT_transform_feedback[] 460e5c31af7Sopenharmony_ci 461e5c31af7Sopenharmony_ci 462e5c31af7Sopenharmony_ci[[primsrast-order]] 463e5c31af7Sopenharmony_ci== Rasterization Order 464e5c31af7Sopenharmony_ci 465e5c31af7Sopenharmony_ciWithin a subpass of a <<renderpass,render pass instance>>, for a given 466e5c31af7Sopenharmony_ci(x,y,layer,sample) sample location, the following operations are guaranteed 467e5c31af7Sopenharmony_cito execute in _rasterization order_, for each separate primitive that 468e5c31af7Sopenharmony_ciincludes that sample location: 469e5c31af7Sopenharmony_ci 470e5c31af7Sopenharmony_ci . <<fragops, Fragment operations>>, in the order defined 471e5c31af7Sopenharmony_ci . <<framebuffer-blending, Blending>>, <<framebuffer-logicop, logic 472e5c31af7Sopenharmony_ci operations>>, and color writes 473e5c31af7Sopenharmony_ci 474e5c31af7Sopenharmony_ciExecution of these operations for each primitive in a subpass occurs in 475e5c31af7Sopenharmony_ciifndef::VK_AMD_rasterization_order[] 476e5c31af7Sopenharmony_ci<<drawing-primitive-order, primitive order>>. 477e5c31af7Sopenharmony_ciendif::VK_AMD_rasterization_order[] 478e5c31af7Sopenharmony_ciifdef::VK_AMD_rasterization_order[] 479e5c31af7Sopenharmony_cian order determined by the application. 480e5c31af7Sopenharmony_ci 481e5c31af7Sopenharmony_ci[open,refpage='VkPipelineRasterizationStateRasterizationOrderAMD',desc='Structure defining rasterization order for a graphics pipeline',type='structs'] 482e5c31af7Sopenharmony_ci-- 483e5c31af7Sopenharmony_ciThe rasterization order to use for a graphics pipeline is specified by 484e5c31af7Sopenharmony_ciadding a sname:VkPipelineRasterizationStateRasterizationOrderAMD structure 485e5c31af7Sopenharmony_cito the pname:pNext chain of a slink:VkPipelineRasterizationStateCreateInfo 486e5c31af7Sopenharmony_cistructure. 487e5c31af7Sopenharmony_ci 488e5c31af7Sopenharmony_ciThe sname:VkPipelineRasterizationStateRasterizationOrderAMD structure is 489e5c31af7Sopenharmony_cidefined as: 490e5c31af7Sopenharmony_ci 491e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkPipelineRasterizationStateRasterizationOrderAMD.adoc[] 492e5c31af7Sopenharmony_ci 493e5c31af7Sopenharmony_ci * pname:sType is a elink:VkStructureType value identifying this structure. 494e5c31af7Sopenharmony_ci * pname:pNext is `NULL` or a pointer to a structure extending this 495e5c31af7Sopenharmony_ci structure. 496e5c31af7Sopenharmony_ci * pname:rasterizationOrder is a elink:VkRasterizationOrderAMD value 497e5c31af7Sopenharmony_ci specifying the primitive rasterization order to use. 498e5c31af7Sopenharmony_ci 499e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkPipelineRasterizationStateRasterizationOrderAMD.adoc[] 500e5c31af7Sopenharmony_ci 501e5c31af7Sopenharmony_ciIf the `apiext:VK_AMD_rasterization_order` device extension is not enabled 502e5c31af7Sopenharmony_cior the application does not request a particular rasterization order through 503e5c31af7Sopenharmony_cispecifying a sname:VkPipelineRasterizationStateRasterizationOrderAMD 504e5c31af7Sopenharmony_cistructure then the rasterization order used by the graphics pipeline 505e5c31af7Sopenharmony_cidefaults to ename:VK_RASTERIZATION_ORDER_STRICT_AMD. 506e5c31af7Sopenharmony_ci-- 507e5c31af7Sopenharmony_ci 508e5c31af7Sopenharmony_ci[open,refpage='VkRasterizationOrderAMD',desc='Specify rasterization order for a graphics pipeline',type='enums'] 509e5c31af7Sopenharmony_ci-- 510e5c31af7Sopenharmony_ciPossible values of 511e5c31af7Sopenharmony_cislink:VkPipelineRasterizationStateRasterizationOrderAMD::pname:rasterizationOrder, 512e5c31af7Sopenharmony_cispecifying the primitive rasterization order, are: 513e5c31af7Sopenharmony_ci 514e5c31af7Sopenharmony_ciinclude::{generated}/api/enums/VkRasterizationOrderAMD.adoc[] 515e5c31af7Sopenharmony_ci 516e5c31af7Sopenharmony_ci * ename:VK_RASTERIZATION_ORDER_STRICT_AMD specifies that operations for 517e5c31af7Sopenharmony_ci each primitive in a subpass must: occur in <<drawing-primitive-order, 518e5c31af7Sopenharmony_ci primitive order>>. 519e5c31af7Sopenharmony_ci * ename:VK_RASTERIZATION_ORDER_RELAXED_AMD specifies that operations for 520e5c31af7Sopenharmony_ci each primitive in a subpass may: not occur in <<drawing-primitive-order, 521e5c31af7Sopenharmony_ci primitive order>>. 522e5c31af7Sopenharmony_ci-- 523e5c31af7Sopenharmony_ciendif::VK_AMD_rasterization_order[] 524e5c31af7Sopenharmony_ci 525e5c31af7Sopenharmony_ci 526e5c31af7Sopenharmony_ci[[primsrast-multisampling]] 527e5c31af7Sopenharmony_ci== Multisampling 528e5c31af7Sopenharmony_ci 529e5c31af7Sopenharmony_ciMultisampling is a mechanism to antialias all Vulkan primitives: points, 530e5c31af7Sopenharmony_cilines, and polygons. 531e5c31af7Sopenharmony_ciThe technique is to sample all primitives multiple times at each pixel. 532e5c31af7Sopenharmony_ciEach sample in each framebuffer attachment has storage for a color, depth, 533e5c31af7Sopenharmony_ciand/or stencil value, such that per-fragment operations apply to each sample 534e5c31af7Sopenharmony_ciindependently. 535e5c31af7Sopenharmony_ciThe color sample values can: be later _resolved_ to a single color (see 536e5c31af7Sopenharmony_ci<<copies-resolve,Resolving Multisample Images>> and the <<renderpass,Render 537e5c31af7Sopenharmony_ciPass>> chapter for more details on how to resolve multisample images to 538e5c31af7Sopenharmony_cinon-multisample images). 539e5c31af7Sopenharmony_ci 540e5c31af7Sopenharmony_ciVulkan defines rasterization rules for single-sample modes in a way that is 541e5c31af7Sopenharmony_ciequivalent to a multisample mode with a single sample in the center of each 542e5c31af7Sopenharmony_cifragment. 543e5c31af7Sopenharmony_ci 544e5c31af7Sopenharmony_ciEach fragment includes a <<primsrast-multisampling-coverage-mask, coverage 545e5c31af7Sopenharmony_cimask>> with a single bit for each sample in the fragment, and a number of 546e5c31af7Sopenharmony_cidepth values and associated data for each sample. 547e5c31af7Sopenharmony_ci 548e5c31af7Sopenharmony_ciIt is understood that each pixel has pname:rasterizationSamples locations 549e5c31af7Sopenharmony_ciassociated with it. 550e5c31af7Sopenharmony_ciThese locations are exact positions, rather than regions or areas, and each 551e5c31af7Sopenharmony_ciis referred to as a sample point. 552e5c31af7Sopenharmony_ciThe sample points associated with a pixel must: be located inside or on the 553e5c31af7Sopenharmony_ciboundary of the unit square that is considered to bound the pixel. 554e5c31af7Sopenharmony_ciFurthermore, the relative locations of sample points may: be identical for 555e5c31af7Sopenharmony_cieach pixel in the framebuffer, or they may: differ. 556e5c31af7Sopenharmony_ci 557e5c31af7Sopenharmony_ciifdef::VK_EXT_fragment_density_map[] 558e5c31af7Sopenharmony_ciIf the render pass has a fragment density map attachment, each fragment only 559e5c31af7Sopenharmony_cihas pname:rasterizationSamples locations associated with it regardless of 560e5c31af7Sopenharmony_cihow many pixels are covered in the fragment area. 561e5c31af7Sopenharmony_ciFragment sample locations are defined as if the fragment had an area of 562e5c31af7Sopenharmony_ci[eq]#(1,1)# and its sample points must: be located within these bounds. 563e5c31af7Sopenharmony_ciTheir actual location in the framebuffer is calculated by scaling the sample 564e5c31af7Sopenharmony_cilocation by the fragment area. 565e5c31af7Sopenharmony_ciAttachments with storage for multiple samples per pixel are located at the 566e5c31af7Sopenharmony_cipixel sample locations. 567e5c31af7Sopenharmony_ciOtherwise, the fragment's sample locations are generally used for evaluation 568e5c31af7Sopenharmony_ciof associated data and fragment operations. 569e5c31af7Sopenharmony_ciendif::VK_EXT_fragment_density_map[] 570e5c31af7Sopenharmony_ci 571e5c31af7Sopenharmony_ciIf the current pipeline includes a fragment shader with one or more 572e5c31af7Sopenharmony_civariables in its interface decorated with code:Sample and code:Input, the 573e5c31af7Sopenharmony_cidata associated with those variables will be assigned independently for each 574e5c31af7Sopenharmony_cisample. 575e5c31af7Sopenharmony_ciThe values for each sample must: be evaluated at the location of the sample. 576e5c31af7Sopenharmony_ciThe data associated with any other variables not decorated with code:Sample 577e5c31af7Sopenharmony_ciand code:Input need not be evaluated independently for each sample. 578e5c31af7Sopenharmony_ci 579e5c31af7Sopenharmony_ci[[primsrast-multisampling-coverage-mask]] 580e5c31af7Sopenharmony_ciA _coverage mask_ is generated for each fragment, based on which samples 581e5c31af7Sopenharmony_ciwithin that fragment are determined to be within the area of the primitive 582e5c31af7Sopenharmony_cithat generated the fragment. 583e5c31af7Sopenharmony_ci 584e5c31af7Sopenharmony_ciSingle pixel fragments 585e5c31af7Sopenharmony_ciifdef::VK_EXT_fragment_density_map[] 586e5c31af7Sopenharmony_ciand multi-pixel fragments defined by a 587e5c31af7Sopenharmony_ci<<renderpass-fragmentdensitymapattachment, fragment density map>> 588e5c31af7Sopenharmony_ciendif::VK_EXT_fragment_density_map[] 589e5c31af7Sopenharmony_cihave one set of samples. 590e5c31af7Sopenharmony_ciifdef::VK_NV_shading_rate_image[] 591e5c31af7Sopenharmony_ciMulti-pixel fragments defined by a <<primsrast-shading-rate-image, shading 592e5c31af7Sopenharmony_cirate image>> have one set of samples per pixel. 593e5c31af7Sopenharmony_ciendif::VK_NV_shading_rate_image[] 594e5c31af7Sopenharmony_ciifdef::VK_KHR_fragment_shading_rate[] 595e5c31af7Sopenharmony_ciMulti-pixel fragments defined by setting the 596e5c31af7Sopenharmony_ci<<primsrast-fragment-shading-rate, fragment shading rate>> have one set of 597e5c31af7Sopenharmony_cisamples per pixel. 598e5c31af7Sopenharmony_ciendif::VK_KHR_fragment_shading_rate[] 599e5c31af7Sopenharmony_ciEach set of samples has a number of samples determined by 600e5c31af7Sopenharmony_cislink:VkPipelineMultisampleStateCreateInfo::pname:rasterizationSamples. 601e5c31af7Sopenharmony_ciEach sample in a set is assigned a unique _sample index_ [eq]#i# in the 602e5c31af7Sopenharmony_cirange [eq]#[0, pname:rasterizationSamples)#. 603e5c31af7Sopenharmony_ci 604e5c31af7Sopenharmony_ciifdef::VK_EXT_extended_dynamic_state3,VK_EXT_shader_object[] 605e5c31af7Sopenharmony_ci[open,refpage='vkCmdSetRasterizationSamplesEXT',desc='Specify the rasterization samples dynamically for a command buffer',type='protos'] 606e5c31af7Sopenharmony_ci-- 607e5c31af7Sopenharmony_ciTo <<pipelines-dynamic-state, dynamically set>> the 608e5c31af7Sopenharmony_cipname:rasterizationSamples, call: 609e5c31af7Sopenharmony_ci 610e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCmdSetRasterizationSamplesEXT.adoc[] 611e5c31af7Sopenharmony_ci 612e5c31af7Sopenharmony_ci * pname:commandBuffer is the command buffer into which the command will be 613e5c31af7Sopenharmony_ci recorded. 614e5c31af7Sopenharmony_ci * pname:rasterizationSamples specifies pname:rasterizationSamples. 615e5c31af7Sopenharmony_ci 616e5c31af7Sopenharmony_ciThis command sets the pname:rasterizationSamples for subsequent drawing 617e5c31af7Sopenharmony_cicommands 618e5c31af7Sopenharmony_ciifdef::VK_EXT_shader_object[] 619e5c31af7Sopenharmony_ciifdef::VK_EXT_extended_dynamic_state3[when drawing using <<shaders-objects, shader objects>>, or] 620e5c31af7Sopenharmony_ciifndef::VK_EXT_extended_dynamic_state3[when drawing using <<shaders-objects, shader objects>>.] 621e5c31af7Sopenharmony_ciendif::VK_EXT_shader_object[] 622e5c31af7Sopenharmony_ciifdef::VK_EXT_extended_dynamic_state3[] 623e5c31af7Sopenharmony_ciwhen the graphics pipeline is created with 624e5c31af7Sopenharmony_ciename:VK_DYNAMIC_STATE_RASTERIZATION_SAMPLES_EXT set in 625e5c31af7Sopenharmony_cislink:VkPipelineDynamicStateCreateInfo::pname:pDynamicStates. 626e5c31af7Sopenharmony_ciendif::VK_EXT_extended_dynamic_state3[] 627e5c31af7Sopenharmony_ciOtherwise, this state is specified by the 628e5c31af7Sopenharmony_cislink:VkPipelineMultisampleStateCreateInfo::pname:rasterizationSamples value 629e5c31af7Sopenharmony_ciused to create the currently active pipeline. 630e5c31af7Sopenharmony_ci 631e5c31af7Sopenharmony_ci:refpage: vkCmdSetRasterizationSamplesEXT 632e5c31af7Sopenharmony_ci:requiredfeature: extendedDynamicState3RasterizationSamples 633e5c31af7Sopenharmony_ci 634e5c31af7Sopenharmony_ci.Valid Usage 635e5c31af7Sopenharmony_ci**** 636e5c31af7Sopenharmony_ciinclude::{chapters}/commonvalidity/dynamic_state3_feature_common.adoc[] 637e5c31af7Sopenharmony_ci**** 638e5c31af7Sopenharmony_ci 639e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkCmdSetRasterizationSamplesEXT.adoc[] 640e5c31af7Sopenharmony_ci-- 641e5c31af7Sopenharmony_ciendif::VK_EXT_extended_dynamic_state3,VK_EXT_shader_object[] 642e5c31af7Sopenharmony_ci 643e5c31af7Sopenharmony_ci[[primsrast-multisampling-coverageindex]] 644e5c31af7Sopenharmony_ciEach sample in a fragment is also assigned a unique _coverage index_ [eq]#j# 645e5c31af7Sopenharmony_ciin the range [eq]#[0, n {times} pname:rasterizationSamples)#, where [eq]#n# 646e5c31af7Sopenharmony_ciis the number of sets in the fragment. 647e5c31af7Sopenharmony_ciIf the fragment contains a single set of samples, the _coverage index_ is 648e5c31af7Sopenharmony_cialways equal to the _sample index_. 649e5c31af7Sopenharmony_ciifdef::VK_NV_shading_rate_image[] 650e5c31af7Sopenharmony_ciIf a <<primsrast-shading-rate-image,shading rate image>> is used and a 651e5c31af7Sopenharmony_cifragment covers multiple pixels, the coverage index is determined as defined 652e5c31af7Sopenharmony_ciby slink:VkPipelineViewportCoarseSampleOrderStateCreateInfoNV or 653e5c31af7Sopenharmony_ciflink:vkCmdSetCoarseSampleOrderNV. 654e5c31af7Sopenharmony_ciendif::VK_NV_shading_rate_image[] 655e5c31af7Sopenharmony_ci 656e5c31af7Sopenharmony_ciifdef::VK_KHR_fragment_shading_rate[] 657e5c31af7Sopenharmony_ci[[primsrast-multisampling-coverage-mask-vrfs]] 658e5c31af7Sopenharmony_ciIf the <<primsrast-fragment-shading-rate, fragment shading rate>> is set, 659e5c31af7Sopenharmony_cithe coverage index [eq]#j# is determined as a function of the _pixel index_ 660e5c31af7Sopenharmony_ci[eq]#p#, the _sample index_ [eq]#i#, and the number of rasterization samples 661e5c31af7Sopenharmony_ci[eq]#r# as: 662e5c31af7Sopenharmony_ci 663e5c31af7Sopenharmony_ci {empty}:: [eq]#j = i + r {times} ((f~w~ {times} f~h~) - 1 - p)# 664e5c31af7Sopenharmony_ci 665e5c31af7Sopenharmony_ciwhere the pixel index [eq]#p# is determined as a function of the pixel's 666e5c31af7Sopenharmony_ciframebuffer location [eq]#(x,y)# and the fragment size [eq]#(f~w~,f~h~)#: 667e5c31af7Sopenharmony_ci 668e5c31af7Sopenharmony_ci {empty}:: [eq]#p~x~ = x % f~w~# 669e5c31af7Sopenharmony_ci {empty}:: [eq]#p~y~ = y % f~h~# 670e5c31af7Sopenharmony_ci {empty}:: [eq]#p = p~x~ + (p~y~ {times} f~w~)# 671e5c31af7Sopenharmony_ci 672e5c31af7Sopenharmony_ciThe table below illustrates the pixel index for multi-pixel fragments: 673e5c31af7Sopenharmony_ci 674e5c31af7Sopenharmony_ci.Pixel indices - 1 wide 675e5c31af7Sopenharmony_ci[align="center"] 676e5c31af7Sopenharmony_ci|==== 677e5c31af7Sopenharmony_ci| 1x1 | 1x2 | 1x4 678e5c31af7Sopenharmony_ci 679e5c31af7Sopenharmony_ci.>| image:{images}/pixel_index_1x1.svg[pdfwidth=90pt,opts="{imageopts}"] 680e5c31af7Sopenharmony_ci.>| image:{images}/pixel_index_1x2.svg[pdfwidth=90pt,align="center",opts="{imageopts}"] 681e5c31af7Sopenharmony_ci.>| image:{images}/pixel_index_1x4.svg[pdfwidth=90pt,align="center",opts="{imageopts}"] 682e5c31af7Sopenharmony_ci|==== 683e5c31af7Sopenharmony_ci 684e5c31af7Sopenharmony_ci.Pixel indices - 2 wide 685e5c31af7Sopenharmony_ci[align="center"] 686e5c31af7Sopenharmony_ci|==== 687e5c31af7Sopenharmony_ci| 2x1 | 2x2 | 2x4 688e5c31af7Sopenharmony_ci 689e5c31af7Sopenharmony_ci.>| image:{images}/pixel_index_2x1.svg[pdfwidth=90pt,align="center",opts="{imageopts}"] 690e5c31af7Sopenharmony_ci.>| image:{images}/pixel_index_2x2.svg[pdfwidth=90pt,align="center",opts="{imageopts}"] 691e5c31af7Sopenharmony_ci.>| image:{images}/pixel_index_2x4.svg[pdfwidth=90pt,align="center",opts="{imageopts}"] 692e5c31af7Sopenharmony_ci|==== 693e5c31af7Sopenharmony_ci 694e5c31af7Sopenharmony_ci.Pixel indices - 4 wide 695e5c31af7Sopenharmony_ci[align="center"] 696e5c31af7Sopenharmony_ci|==== 697e5c31af7Sopenharmony_ci| 4x1 | 4x2 | 4x4 698e5c31af7Sopenharmony_ci 699e5c31af7Sopenharmony_ci.>| image:{images}/pixel_index_4x1.svg[pdfwidth=90pt,align="center",opts="{imageopts}"] 700e5c31af7Sopenharmony_ci.>| image:{images}/pixel_index_4x2.svg[pdfwidth=90pt,align="center",opts="{imageopts}"] 701e5c31af7Sopenharmony_ci.>| image:{images}/pixel_index_4x4.svg[pdfwidth=90pt,align="center",opts="{imageopts}"] 702e5c31af7Sopenharmony_ci|==== 703e5c31af7Sopenharmony_ciendif::VK_KHR_fragment_shading_rate[] 704e5c31af7Sopenharmony_ci 705e5c31af7Sopenharmony_ciThe coverage mask includes [eq]#B# bits packed into [eq]#W# words, defined 706e5c31af7Sopenharmony_cias: 707e5c31af7Sopenharmony_ci 708e5c31af7Sopenharmony_ci {empty}:: [eq]#B = n {times} pname:rasterizationSamples# 709e5c31af7Sopenharmony_ci {empty}:: [eq]#W = {lceil}B/32{rceil}# 710e5c31af7Sopenharmony_ci 711e5c31af7Sopenharmony_ciBit [eq]#b# in coverage mask word [eq]#w# is `1` if the sample with coverage 712e5c31af7Sopenharmony_ciindex [eq]#j = 32{times}w + b# is covered, and `0` otherwise. 713e5c31af7Sopenharmony_ci 714e5c31af7Sopenharmony_ciIf the pname:standardSampleLocations member of slink:VkPhysicalDeviceLimits 715e5c31af7Sopenharmony_ciis ename:VK_TRUE, then the sample counts ename:VK_SAMPLE_COUNT_1_BIT, 716e5c31af7Sopenharmony_ciename:VK_SAMPLE_COUNT_2_BIT, ename:VK_SAMPLE_COUNT_4_BIT, 717e5c31af7Sopenharmony_ciename:VK_SAMPLE_COUNT_8_BIT, and ename:VK_SAMPLE_COUNT_16_BIT have sample 718e5c31af7Sopenharmony_cilocations as listed in the following table, with the [eq]##i##th entry in 719e5c31af7Sopenharmony_cithe table corresponding to sample index [eq]#i#. 720e5c31af7Sopenharmony_ciename:VK_SAMPLE_COUNT_32_BIT and ename:VK_SAMPLE_COUNT_64_BIT do not have 721e5c31af7Sopenharmony_cistandard sample locations. 722e5c31af7Sopenharmony_ciLocations are defined relative to an origin in the upper left corner of the 723e5c31af7Sopenharmony_cifragment. 724e5c31af7Sopenharmony_ci 725e5c31af7Sopenharmony_ci<<< 726e5c31af7Sopenharmony_ci 727e5c31af7Sopenharmony_ci.Standard sample locations 728e5c31af7Sopenharmony_ci[options="header",align="center"] 729e5c31af7Sopenharmony_ci|==== 730e5c31af7Sopenharmony_ci| Sample count 2+| Sample Locations 731e5c31af7Sopenharmony_ci|ename:VK_SAMPLE_COUNT_1_BIT 732e5c31af7Sopenharmony_ci | [eq]#(0.5,0.5)# 733e5c31af7Sopenharmony_ci | image:{images}/sample_count_1.svg[pdfwidth=90pt,align="center",opts="{imageopts}"] 734e5c31af7Sopenharmony_ci|ename:VK_SAMPLE_COUNT_2_BIT 735e5c31af7Sopenharmony_ci | [eq]#(0.75,0.75)# + 736e5c31af7Sopenharmony_ci [eq]#(0.25,0.25)# 737e5c31af7Sopenharmony_ci | image:{images}/sample_count_2.svg[pdfwidth=90pt,align="center",opts="{imageopts}"] 738e5c31af7Sopenharmony_ci|ename:VK_SAMPLE_COUNT_4_BIT 739e5c31af7Sopenharmony_ci | [eq]#(0.375, 0.125)# + 740e5c31af7Sopenharmony_ci [eq]#(0.875, 0.375)# + 741e5c31af7Sopenharmony_ci [eq]#(0.125, 0.625)# + 742e5c31af7Sopenharmony_ci [eq]#(0.625, 0.875)# 743e5c31af7Sopenharmony_ci | image:{images}/sample_count_4.svg[pdfwidth=90pt,align="center",opts="{imageopts}"] 744e5c31af7Sopenharmony_ci|ename:VK_SAMPLE_COUNT_8_BIT 745e5c31af7Sopenharmony_ci | [eq]#(0.5625, 0.3125)# + 746e5c31af7Sopenharmony_ci [eq]#(0.4375, 0.6875)# + 747e5c31af7Sopenharmony_ci [eq]#(0.8125, 0.5625)# + 748e5c31af7Sopenharmony_ci [eq]#(0.3125, 0.1875)# + 749e5c31af7Sopenharmony_ci [eq]#(0.1875, 0.8125)# + 750e5c31af7Sopenharmony_ci [eq]#(0.0625, 0.4375)# + 751e5c31af7Sopenharmony_ci [eq]#(0.6875, 0.9375)# + 752e5c31af7Sopenharmony_ci [eq]#(0.9375, 0.0625)# 753e5c31af7Sopenharmony_ci | image:{images}/sample_count_8.svg[pdfwidth=90pt,align="center",opts="{imageopts}"] 754e5c31af7Sopenharmony_ci|ename:VK_SAMPLE_COUNT_16_BIT 755e5c31af7Sopenharmony_ci | [eq]#(0.5625, 0.5625)# + 756e5c31af7Sopenharmony_ci [eq]#(0.4375, 0.3125)# + 757e5c31af7Sopenharmony_ci [eq]#(0.3125, 0.625)# + 758e5c31af7Sopenharmony_ci [eq]#(0.75, 0.4375)# + 759e5c31af7Sopenharmony_ci [eq]#(0.1875, 0.375)# + 760e5c31af7Sopenharmony_ci [eq]#(0.625, 0.8125)# + 761e5c31af7Sopenharmony_ci [eq]#(0.8125, 0.6875)# + 762e5c31af7Sopenharmony_ci [eq]#(0.6875, 0.1875)# + 763e5c31af7Sopenharmony_ci [eq]#(0.375, 0.875)# + 764e5c31af7Sopenharmony_ci [eq]#(0.5, 0.0625)# + 765e5c31af7Sopenharmony_ci [eq]#(0.25, 0.125)# + 766e5c31af7Sopenharmony_ci [eq]#(0.125, 0.75)# + 767e5c31af7Sopenharmony_ci [eq]#(0.0, 0.5)# + 768e5c31af7Sopenharmony_ci [eq]#(0.9375, 0.25)# + 769e5c31af7Sopenharmony_ci [eq]#(0.875, 0.9375)# + 770e5c31af7Sopenharmony_ci [eq]#(0.0625, 0.0)# 771e5c31af7Sopenharmony_ci | image:{images}/sample_count_16.svg[pdfwidth=90pt,align="center",opts="{imageopts}"] 772e5c31af7Sopenharmony_ci|==== 773e5c31af7Sopenharmony_ci 774e5c31af7Sopenharmony_ciifdef::VK_AMD_shader_fragment_mask[] 775e5c31af7Sopenharmony_ciColor images created with multiple samples per pixel use a compression 776e5c31af7Sopenharmony_citechnique where there are two arrays of data associated with each pixel. 777e5c31af7Sopenharmony_ciThe first array contains one element per sample where each element stores an 778e5c31af7Sopenharmony_ciindex to the second array defining the _fragment mask_ of the pixel. 779e5c31af7Sopenharmony_ciThe second array contains one element per _color fragment_ and each element 780e5c31af7Sopenharmony_cistores a unique color value in the format of the image. 781e5c31af7Sopenharmony_ciWith this compression technique it is not always necessary to actually use 782e5c31af7Sopenharmony_ciunique storage locations for each color sample: when multiple samples share 783e5c31af7Sopenharmony_cithe same color value the fragment mask may: have two samples referring to 784e5c31af7Sopenharmony_cithe same color fragment. 785e5c31af7Sopenharmony_ciThe number of color fragments is determined by the pname:samples member of 786e5c31af7Sopenharmony_cithe slink:VkImageCreateInfo structure used to create the image. 787e5c31af7Sopenharmony_ciThe `apiext:VK_AMD_shader_fragment_mask` device extension provides shader 788e5c31af7Sopenharmony_ciinstructions enabling the application to get direct access to the fragment 789e5c31af7Sopenharmony_cimask and the individual color fragment values. 790e5c31af7Sopenharmony_ci 791e5c31af7Sopenharmony_ci[[vk-amd-shader-fragment-mask-diagram]] 792e5c31af7Sopenharmony_ciimage::{images}/fragment_mask.svg[align="center",title="Fragment Mask",align="center",opts="{imageopts}"] 793e5c31af7Sopenharmony_ci 794e5c31af7Sopenharmony_ciendif::VK_AMD_shader_fragment_mask[] 795e5c31af7Sopenharmony_ci 796e5c31af7Sopenharmony_ci 797e5c31af7Sopenharmony_ciifdef::VK_EXT_sample_locations[] 798e5c31af7Sopenharmony_ci[[primsrast-samplelocations]] 799e5c31af7Sopenharmony_ci== Custom Sample Locations 800e5c31af7Sopenharmony_ci 801e5c31af7Sopenharmony_ci[open,refpage='VkPipelineSampleLocationsStateCreateInfoEXT',desc='Structure specifying sample locations for a pipeline',type='structs'] 802e5c31af7Sopenharmony_ci-- 803e5c31af7Sopenharmony_ciApplications can: also control the sample locations used for rasterization. 804e5c31af7Sopenharmony_ci 805e5c31af7Sopenharmony_ciIf the pname:pNext chain of the slink:VkPipelineMultisampleStateCreateInfo 806e5c31af7Sopenharmony_cistructure specified at pipeline creation time includes a 807e5c31af7Sopenharmony_cisname:VkPipelineSampleLocationsStateCreateInfoEXT structure, then that 808e5c31af7Sopenharmony_cistructure controls the sample locations used when rasterizing primitives 809e5c31af7Sopenharmony_ciwith the pipeline. 810e5c31af7Sopenharmony_ci 811e5c31af7Sopenharmony_ciThe sname:VkPipelineSampleLocationsStateCreateInfoEXT structure is defined 812e5c31af7Sopenharmony_cias: 813e5c31af7Sopenharmony_ci 814e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkPipelineSampleLocationsStateCreateInfoEXT.adoc[] 815e5c31af7Sopenharmony_ci 816e5c31af7Sopenharmony_ci * pname:sType is a elink:VkStructureType value identifying this structure. 817e5c31af7Sopenharmony_ci * pname:pNext is `NULL` or a pointer to a structure extending this 818e5c31af7Sopenharmony_ci structure. 819e5c31af7Sopenharmony_ci * pname:sampleLocationsEnable controls whether custom sample locations are 820e5c31af7Sopenharmony_ci used. 821e5c31af7Sopenharmony_ci If pname:sampleLocationsEnable is ename:VK_FALSE, the default sample 822e5c31af7Sopenharmony_ci locations are used and the values specified in pname:sampleLocationsInfo 823e5c31af7Sopenharmony_ci are ignored. 824e5c31af7Sopenharmony_ci * pname:sampleLocationsInfo is the sample locations to use during 825e5c31af7Sopenharmony_ci rasterization if pname:sampleLocationsEnable is ename:VK_TRUE and the 826e5c31af7Sopenharmony_ci graphics pipeline is not created with 827e5c31af7Sopenharmony_ci ename:VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT. 828e5c31af7Sopenharmony_ci 829e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkPipelineSampleLocationsStateCreateInfoEXT.adoc[] 830e5c31af7Sopenharmony_ci-- 831e5c31af7Sopenharmony_ci 832e5c31af7Sopenharmony_ci[open,refpage='VkSampleLocationsInfoEXT',desc='Structure specifying a set of sample locations',type='structs'] 833e5c31af7Sopenharmony_ci-- 834e5c31af7Sopenharmony_ciThe sname:VkSampleLocationsInfoEXT structure is defined as: 835e5c31af7Sopenharmony_ci 836e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkSampleLocationsInfoEXT.adoc[] 837e5c31af7Sopenharmony_ci 838e5c31af7Sopenharmony_ci * pname:sType is a elink:VkStructureType value identifying this structure. 839e5c31af7Sopenharmony_ci * pname:pNext is `NULL` or a pointer to a structure extending this 840e5c31af7Sopenharmony_ci structure. 841e5c31af7Sopenharmony_ci * pname:sampleLocationsPerPixel is a elink:VkSampleCountFlagBits value 842e5c31af7Sopenharmony_ci specifying the number of sample locations per pixel. 843e5c31af7Sopenharmony_ci * pname:sampleLocationGridSize is the size of the sample location grid to 844e5c31af7Sopenharmony_ci select custom sample locations for. 845e5c31af7Sopenharmony_ci * pname:sampleLocationsCount is the number of sample locations in 846e5c31af7Sopenharmony_ci pname:pSampleLocations. 847e5c31af7Sopenharmony_ci * pname:pSampleLocations is a pointer to an array of 848e5c31af7Sopenharmony_ci pname:sampleLocationsCount slink:VkSampleLocationEXT structures. 849e5c31af7Sopenharmony_ci 850e5c31af7Sopenharmony_ciThis structure can: be used either to specify the sample locations to be 851e5c31af7Sopenharmony_ciused for rendering or to specify the set of sample locations an image 852e5c31af7Sopenharmony_cisubresource has been last rendered with for the purposes of layout 853e5c31af7Sopenharmony_citransitions of depth/stencil images created with 854e5c31af7Sopenharmony_ciename:VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT. 855e5c31af7Sopenharmony_ci 856e5c31af7Sopenharmony_ciThe sample locations in pname:pSampleLocations specify 857e5c31af7Sopenharmony_cipname:sampleLocationsPerPixel number of sample locations for each pixel in 858e5c31af7Sopenharmony_cithe grid of the size specified in pname:sampleLocationGridSize. 859e5c31af7Sopenharmony_ciThe sample location for sample [eq]#i# at the pixel grid location 860e5c31af7Sopenharmony_ci[eq]#(x,y)# is taken from [eq]#pname:pSampleLocations[(x {plus} y {times} 861e5c31af7Sopenharmony_cipname:sampleLocationGridSize.width) {times} pname:sampleLocationsPerPixel 862e5c31af7Sopenharmony_ci{plus} i]#. 863e5c31af7Sopenharmony_ci 864e5c31af7Sopenharmony_ciifdef::VK_EXT_fragment_density_map[] 865e5c31af7Sopenharmony_ciIf the render pass has a fragment density map, the implementation will 866e5c31af7Sopenharmony_cichoose the sample locations for the fragment and the contents of 867e5c31af7Sopenharmony_cipname:pSampleLocations may: be ignored. 868e5c31af7Sopenharmony_ciendif::VK_EXT_fragment_density_map[] 869e5c31af7Sopenharmony_ci 870e5c31af7Sopenharmony_ci.Valid Usage 871e5c31af7Sopenharmony_ci**** 872e5c31af7Sopenharmony_ci * [[VUID-VkSampleLocationsInfoEXT-sampleLocationsPerPixel-01526]] 873e5c31af7Sopenharmony_ci pname:sampleLocationsPerPixel must: be a valid 874e5c31af7Sopenharmony_ci elink:VkSampleCountFlagBits value that is set in 875e5c31af7Sopenharmony_ci slink:VkPhysicalDeviceSampleLocationsPropertiesEXT::pname:sampleLocationSampleCounts 876e5c31af7Sopenharmony_ci * [[VUID-VkSampleLocationsInfoEXT-sampleLocationsCount-01527]] 877e5c31af7Sopenharmony_ci pname:sampleLocationsCount must: equal 878e5c31af7Sopenharmony_ci [eq]#pname:sampleLocationsPerPixel {times} 879e5c31af7Sopenharmony_ci pname:sampleLocationGridSize.width {times} 880e5c31af7Sopenharmony_ci pname:sampleLocationGridSize.height# 881e5c31af7Sopenharmony_ci**** 882e5c31af7Sopenharmony_ci 883e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkSampleLocationsInfoEXT.adoc[] 884e5c31af7Sopenharmony_ci-- 885e5c31af7Sopenharmony_ci 886e5c31af7Sopenharmony_ci[open,refpage='VkSampleLocationEXT',desc='Structure specifying the coordinates of a sample location',type='structs'] 887e5c31af7Sopenharmony_ci-- 888e5c31af7Sopenharmony_ciThe sname:VkSampleLocationEXT structure is defined as: 889e5c31af7Sopenharmony_ci 890e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkSampleLocationEXT.adoc[] 891e5c31af7Sopenharmony_ci 892e5c31af7Sopenharmony_ci * pname:x is the horizontal coordinate of the sample's location. 893e5c31af7Sopenharmony_ci * pname:y is the vertical coordinate of the sample's location. 894e5c31af7Sopenharmony_ci 895e5c31af7Sopenharmony_ciThe domain space of the sample location coordinates has an upper-left origin 896e5c31af7Sopenharmony_ciwithin the pixel in framebuffer space. 897e5c31af7Sopenharmony_ci 898e5c31af7Sopenharmony_ciThe values specified in a sname:VkSampleLocationEXT structure are always 899e5c31af7Sopenharmony_ciclamped to the implementation-dependent sample location coordinate range 900e5c31af7Sopenharmony_ci[eq]#[pname:sampleLocationCoordinateRange[0],pname:sampleLocationCoordinateRange[1]]# 901e5c31af7Sopenharmony_cithat can: be queried using 902e5c31af7Sopenharmony_cislink:VkPhysicalDeviceSampleLocationsPropertiesEXT. 903e5c31af7Sopenharmony_ci 904e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkSampleLocationEXT.adoc[] 905e5c31af7Sopenharmony_ci-- 906e5c31af7Sopenharmony_ci 907e5c31af7Sopenharmony_ciifdef::VK_EXT_extended_dynamic_state3,VK_EXT_shader_object[] 908e5c31af7Sopenharmony_ci 909e5c31af7Sopenharmony_ci[open,refpage='vkCmdSetSampleLocationsEnableEXT',desc='Specify the samples locations enable state dynamically for a command buffer',type='protos'] 910e5c31af7Sopenharmony_ci-- 911e5c31af7Sopenharmony_ciTo <<pipelines-dynamic-state, dynamically set>> the 912e5c31af7Sopenharmony_cipname:sampleLocationsEnable state, call: 913e5c31af7Sopenharmony_ci 914e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCmdSetSampleLocationsEnableEXT.adoc[] 915e5c31af7Sopenharmony_ci 916e5c31af7Sopenharmony_ci * pname:commandBuffer is the command buffer into which the command will be 917e5c31af7Sopenharmony_ci recorded. 918e5c31af7Sopenharmony_ci * pname:sampleLocationsEnable specifies the pname:sampleLocationsEnable 919e5c31af7Sopenharmony_ci state. 920e5c31af7Sopenharmony_ci 921e5c31af7Sopenharmony_ciThis command sets the pname:sampleLocationsEnable state for subsequent 922e5c31af7Sopenharmony_cidrawing commands 923e5c31af7Sopenharmony_ciifdef::VK_EXT_shader_object[] 924e5c31af7Sopenharmony_ciifdef::VK_EXT_extended_dynamic_state3[when drawing using <<shaders-objects, shader objects>>, or] 925e5c31af7Sopenharmony_ciifndef::VK_EXT_extended_dynamic_state3[when drawing using <<shaders-objects, shader objects>>.] 926e5c31af7Sopenharmony_ciendif::VK_EXT_shader_object[] 927e5c31af7Sopenharmony_ciifdef::VK_EXT_extended_dynamic_state3[] 928e5c31af7Sopenharmony_ciwhen the graphics pipeline is created with 929e5c31af7Sopenharmony_ciename:VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_ENABLE_EXT set in 930e5c31af7Sopenharmony_cislink:VkPipelineDynamicStateCreateInfo::pname:pDynamicStates. 931e5c31af7Sopenharmony_ciendif::VK_EXT_extended_dynamic_state3[] 932e5c31af7Sopenharmony_ciOtherwise, this state is specified by the 933e5c31af7Sopenharmony_cislink:VkPipelineSampleLocationsStateCreateInfoEXT::pname:sampleLocationsEnable 934e5c31af7Sopenharmony_civalue used to create the currently active pipeline. 935e5c31af7Sopenharmony_ci 936e5c31af7Sopenharmony_ci:refpage: vkCmdSetSampleLocationsEnableEXT 937e5c31af7Sopenharmony_ci:requiredfeature: extendedDynamicState3SampleLocationsEnable 938e5c31af7Sopenharmony_ci 939e5c31af7Sopenharmony_ci.Valid Usage 940e5c31af7Sopenharmony_ci**** 941e5c31af7Sopenharmony_ciinclude::{chapters}/commonvalidity/dynamic_state3_feature_common.adoc[] 942e5c31af7Sopenharmony_ci**** 943e5c31af7Sopenharmony_ci 944e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkCmdSetSampleLocationsEnableEXT.adoc[] 945e5c31af7Sopenharmony_ci-- 946e5c31af7Sopenharmony_ci 947e5c31af7Sopenharmony_ciendif::VK_EXT_extended_dynamic_state3,VK_EXT_shader_object[] 948e5c31af7Sopenharmony_ci 949e5c31af7Sopenharmony_ci[open,refpage='vkCmdSetSampleLocationsEXT',desc='Set sample locations dynamically for a command buffer',type='protos'] 950e5c31af7Sopenharmony_ci-- 951e5c31af7Sopenharmony_ciTo <<pipelines-dynamic-state, dynamically set>> the sample locations used 952e5c31af7Sopenharmony_cifor rasterization, call: 953e5c31af7Sopenharmony_ci 954e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCmdSetSampleLocationsEXT.adoc[] 955e5c31af7Sopenharmony_ci 956e5c31af7Sopenharmony_ci * pname:commandBuffer is the command buffer into which the command will be 957e5c31af7Sopenharmony_ci recorded. 958e5c31af7Sopenharmony_ci * pname:pSampleLocationsInfo is the sample locations state to set. 959e5c31af7Sopenharmony_ci 960e5c31af7Sopenharmony_ciThis command sets the custom sample locations for subsequent drawing 961e5c31af7Sopenharmony_cicommands 962e5c31af7Sopenharmony_ciifdef::VK_EXT_shader_object[when drawing using <<shaders-objects, shader objects>>, or] 963e5c31af7Sopenharmony_ciwhen the graphics pipeline is created with 964e5c31af7Sopenharmony_ciename:VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT set in 965e5c31af7Sopenharmony_cislink:VkPipelineDynamicStateCreateInfo::pname:pDynamicStates, and when the 966e5c31af7Sopenharmony_cislink:VkPipelineSampleLocationsStateCreateInfoEXT::pname:sampleLocationsEnable 967e5c31af7Sopenharmony_ciproperty of the bound graphics pipeline is ename:VK_TRUE. 968e5c31af7Sopenharmony_ciOtherwise, this state is specified by the 969e5c31af7Sopenharmony_cislink:VkPipelineSampleLocationsStateCreateInfoEXT::pname:sampleLocationsInfo 970e5c31af7Sopenharmony_civalues used to create the currently active pipeline. 971e5c31af7Sopenharmony_ci 972e5c31af7Sopenharmony_ci.Valid Usage 973e5c31af7Sopenharmony_ci**** 974e5c31af7Sopenharmony_ci * [[VUID-vkCmdSetSampleLocationsEXT-variableSampleLocations-01530]] 975e5c31af7Sopenharmony_ci If 976e5c31af7Sopenharmony_ci slink:VkPhysicalDeviceSampleLocationsPropertiesEXT::pname:variableSampleLocations 977e5c31af7Sopenharmony_ci is ename:VK_FALSE then the current render pass must: have been begun by 978e5c31af7Sopenharmony_ci specifying a slink:VkRenderPassSampleLocationsBeginInfoEXT structure 979e5c31af7Sopenharmony_ci whose pname:pPostSubpassSampleLocations member contains an element with 980e5c31af7Sopenharmony_ci a pname:subpassIndex matching the current subpass index and the 981e5c31af7Sopenharmony_ci pname:sampleLocationsInfo member of that element must: match the sample 982e5c31af7Sopenharmony_ci locations state pointed to by pname:pSampleLocationsInfo 983e5c31af7Sopenharmony_ci**** 984e5c31af7Sopenharmony_ci 985e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkCmdSetSampleLocationsEXT.adoc[] 986e5c31af7Sopenharmony_ci-- 987e5c31af7Sopenharmony_ciendif::VK_EXT_sample_locations[] 988e5c31af7Sopenharmony_ci 989e5c31af7Sopenharmony_ci 990e5c31af7Sopenharmony_ciifdef::VK_KHR_fragment_shading_rate[] 991e5c31af7Sopenharmony_ci[[primsrast-fragment-shading-rate]] 992e5c31af7Sopenharmony_ci== Fragment Shading Rates 993e5c31af7Sopenharmony_ci 994e5c31af7Sopenharmony_ciThe features advertised by 995e5c31af7Sopenharmony_cislink:VkPhysicalDeviceFragmentShadingRateFeaturesKHR allow an application to 996e5c31af7Sopenharmony_cicontrol the <<glossary-shading-rate, shading rate>> of a given fragment 997e5c31af7Sopenharmony_cishader invocation. 998e5c31af7Sopenharmony_ci 999e5c31af7Sopenharmony_ciThe fragment shading rate strongly interacts with <<primsrast-multisampling, 1000e5c31af7Sopenharmony_ciMultisampling>>, and the set of available rates for an implementation may: 1001e5c31af7Sopenharmony_cibe restricted by sample rate. 1002e5c31af7Sopenharmony_ci 1003e5c31af7Sopenharmony_ci[open,refpage='vkGetPhysicalDeviceFragmentShadingRatesKHR',desc='Get available shading rates for a physical device',type='protos'] 1004e5c31af7Sopenharmony_ci-- 1005e5c31af7Sopenharmony_ci:refpage: vkGetPhysicalDeviceFragmentShadingRatesKHR 1006e5c31af7Sopenharmony_ci 1007e5c31af7Sopenharmony_ciTo query available shading rates, call: 1008e5c31af7Sopenharmony_ci 1009e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkGetPhysicalDeviceFragmentShadingRatesKHR.adoc[] 1010e5c31af7Sopenharmony_ci 1011e5c31af7Sopenharmony_ci * pname:physicalDevice is the handle to the physical device whose 1012e5c31af7Sopenharmony_ci properties will be queried. 1013e5c31af7Sopenharmony_ci * pname:pFragmentShadingRateCount is a pointer to an integer related to 1014e5c31af7Sopenharmony_ci the number of fragment shading rates available or queried, as described 1015e5c31af7Sopenharmony_ci below. 1016e5c31af7Sopenharmony_ci * pname:pFragmentShadingRates is either `NULL` or a pointer to an array of 1017e5c31af7Sopenharmony_ci slink:VkPhysicalDeviceFragmentShadingRateKHR structures. 1018e5c31af7Sopenharmony_ci 1019e5c31af7Sopenharmony_ciIf pname:pFragmentShadingRates is `NULL`, then the number of fragment 1020e5c31af7Sopenharmony_cishading rates available is returned in pname:pFragmentShadingRateCount. 1021e5c31af7Sopenharmony_ciOtherwise, pname:pFragmentShadingRateCount must: point to a variable set by 1022e5c31af7Sopenharmony_cithe user to the number of elements in the pname:pFragmentShadingRates array, 1023e5c31af7Sopenharmony_ciand on return the variable is overwritten with the number of structures 1024e5c31af7Sopenharmony_ciactually written to pname:pFragmentShadingRates. 1025e5c31af7Sopenharmony_ciIf pname:pFragmentShadingRateCount is less than the number of fragment 1026e5c31af7Sopenharmony_cishading rates available, at most pname:pFragmentShadingRateCount structures 1027e5c31af7Sopenharmony_ciwill be written, and ename:VK_INCOMPLETE will be returned instead of 1028e5c31af7Sopenharmony_ciename:VK_SUCCESS, to indicate that not all the available fragment shading 1029e5c31af7Sopenharmony_cirates were returned. 1030e5c31af7Sopenharmony_ci 1031e5c31af7Sopenharmony_ciThe returned array of fragment shading rates must: be ordered from largest 1032e5c31af7Sopenharmony_cipname:fragmentSize.width value to smallest, and each set of fragment shading 1033e5c31af7Sopenharmony_cirates with the same pname:fragmentSize.width value must: be ordered from 1034e5c31af7Sopenharmony_cilargest pname:fragmentSize.height to smallest. 1035e5c31af7Sopenharmony_ciAny two entries in the array must: not have the same pname:fragmentSize 1036e5c31af7Sopenharmony_civalues. 1037e5c31af7Sopenharmony_ci 1038e5c31af7Sopenharmony_ciFor any entry in the array, the following rules also apply: 1039e5c31af7Sopenharmony_ci 1040e5c31af7Sopenharmony_ci * The value of pname:fragmentSize.width must: be less than or equal to 1041e5c31af7Sopenharmony_ci <<limits-maxFragmentSize, pname:maxFragmentSize.width>>. 1042e5c31af7Sopenharmony_ci * The value of pname:fragmentSize.width must: be greater than or equal to 1043e5c31af7Sopenharmony_ci `1`. 1044e5c31af7Sopenharmony_ci * The value of pname:fragmentSize.width must: be a power-of-two. 1045e5c31af7Sopenharmony_ci * The value of pname:fragmentSize.height must: be less than or equal to 1046e5c31af7Sopenharmony_ci <<limits-maxFragmentSize, pname:maxFragmentSize.height>>. 1047e5c31af7Sopenharmony_ci * The value of pname:fragmentSize.height must: be greater than or equal to 1048e5c31af7Sopenharmony_ci `1`. 1049e5c31af7Sopenharmony_ci * The value of pname:fragmentSize.height must: be a power-of-two. 1050e5c31af7Sopenharmony_ci * The highest sample count in pname:sampleCounts must: be less than or 1051e5c31af7Sopenharmony_ci equal to <<limits-maxFragmentShadingRateRasterizationSamples, 1052e5c31af7Sopenharmony_ci pname:maxFragmentShadingRateRasterizationSamples>>. 1053e5c31af7Sopenharmony_ci * The product of pname:fragmentSize.width, pname:fragmentSize.height, and 1054e5c31af7Sopenharmony_ci the highest sample count in pname:sampleCounts must: be less than or 1055e5c31af7Sopenharmony_ci equal to <<limits-maxFragmentShadingRateCoverageSamples, 1056e5c31af7Sopenharmony_ci pname:maxFragmentShadingRateCoverageSamples>>. 1057e5c31af7Sopenharmony_ci 1058e5c31af7Sopenharmony_ciImplementations must: support at least the following shading rates: 1059e5c31af7Sopenharmony_ci 1060e5c31af7Sopenharmony_ci[options="autowidth"] 1061e5c31af7Sopenharmony_ci|=== 1062e5c31af7Sopenharmony_ci| pname:sampleCounts | pname:fragmentSize 1063e5c31af7Sopenharmony_ci 1064e5c31af7Sopenharmony_ci| ename:VK_SAMPLE_COUNT_1_BIT \| ename:VK_SAMPLE_COUNT_4_BIT | {2,2} 1065e5c31af7Sopenharmony_ci| ename:VK_SAMPLE_COUNT_1_BIT \| ename:VK_SAMPLE_COUNT_4_BIT | {2,1} 1066e5c31af7Sopenharmony_ci| ~0 | {1,1} 1067e5c31af7Sopenharmony_ci|=== 1068e5c31af7Sopenharmony_ci 1069e5c31af7Sopenharmony_ciIf <<limits-framebufferColorSampleCounts, 1070e5c31af7Sopenharmony_cipname:framebufferColorSampleCounts>>, includes ename:VK_SAMPLE_COUNT_2_BIT, 1071e5c31af7Sopenharmony_cithe required rates must: also include ename:VK_SAMPLE_COUNT_2_BIT. 1072e5c31af7Sopenharmony_ci 1073e5c31af7Sopenharmony_ci[NOTE] 1074e5c31af7Sopenharmony_ci.Note 1075e5c31af7Sopenharmony_ci==== 1076e5c31af7Sopenharmony_ciIncluding the {1,1} fragment size is done for completeness; it has no actual 1077e5c31af7Sopenharmony_cieffect on the support of rendering without setting the fragment size. 1078e5c31af7Sopenharmony_ciAll sample counts 1079e5c31af7Sopenharmony_ciifdef::VK_QCOM_render_pass_transform[] 1080e5c31af7Sopenharmony_ciand render pass transforms 1081e5c31af7Sopenharmony_ciendif::VK_QCOM_render_pass_transform[] 1082e5c31af7Sopenharmony_ciare supported for this rate. 1083e5c31af7Sopenharmony_ci==== 1084e5c31af7Sopenharmony_ci 1085e5c31af7Sopenharmony_ciifdef::VK_QCOM_render_pass_transform[] 1086e5c31af7Sopenharmony_ciThe returned set of fragment shading rates must: be returned in the native 1087e5c31af7Sopenharmony_ci(rotated) coordinate system. 1088e5c31af7Sopenharmony_ciFor rasterization using render pass pname:transform not equal to 1089e5c31af7Sopenharmony_ciename:VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR, the application must: transform 1090e5c31af7Sopenharmony_cithe returned fragment shading rates into the current (unrotated) coordinate 1091e5c31af7Sopenharmony_cisystem to get the supported rates for that transform. 1092e5c31af7Sopenharmony_ci 1093e5c31af7Sopenharmony_ci[NOTE] 1094e5c31af7Sopenharmony_ci.Note 1095e5c31af7Sopenharmony_ci==== 1096e5c31af7Sopenharmony_ciFor example, consider an implementation returning support for 4x2, but not 1097e5c31af7Sopenharmony_ci2x4 in the set of supported fragment shading rates. 1098e5c31af7Sopenharmony_ciThis means that for transforms ename:VK_SURFACE_TRANSFORM_ROTATE_90_BIT_KHR 1099e5c31af7Sopenharmony_ciand ename:VK_SURFACE_TRANSFORM_ROTATE_270_BIT_KHR, 2x4 is a supported rate, 1100e5c31af7Sopenharmony_cibut 4x2 is an unsupported rate. 1101e5c31af7Sopenharmony_ci==== 1102e5c31af7Sopenharmony_ciendif::VK_QCOM_render_pass_transform[] 1103e5c31af7Sopenharmony_ci 1104e5c31af7Sopenharmony_ciinclude::{chapters}/commonvalidity/no_dynamic_allocations_common.adoc[] 1105e5c31af7Sopenharmony_ci 1106e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkGetPhysicalDeviceFragmentShadingRatesKHR.adoc[] 1107e5c31af7Sopenharmony_ci-- 1108e5c31af7Sopenharmony_ci 1109e5c31af7Sopenharmony_ci[open,refpage='VkPhysicalDeviceFragmentShadingRateKHR',desc='Structure returning information about sample count specific additional multisampling capabilities',type='structs'] 1110e5c31af7Sopenharmony_ci-- 1111e5c31af7Sopenharmony_ciThe sname:VkPhysicalDeviceFragmentShadingRateKHR structure is defined as 1112e5c31af7Sopenharmony_ci 1113e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkPhysicalDeviceFragmentShadingRateKHR.adoc[] 1114e5c31af7Sopenharmony_ci 1115e5c31af7Sopenharmony_ci * pname:sType is a elink:VkStructureType value identifying this structure. 1116e5c31af7Sopenharmony_ci * pname:pNext is `NULL` or a pointer to a structure extending this 1117e5c31af7Sopenharmony_ci structure. 1118e5c31af7Sopenharmony_ci * pname:sampleCounts is a bitmask of sample counts for which the shading 1119e5c31af7Sopenharmony_ci rate described by pname:fragmentSize is supported. 1120e5c31af7Sopenharmony_ci * pname:fragmentSize is a slink:VkExtent2D describing the width and height 1121e5c31af7Sopenharmony_ci of a supported shading rate. 1122e5c31af7Sopenharmony_ci 1123e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkPhysicalDeviceFragmentShadingRateKHR.adoc[] 1124e5c31af7Sopenharmony_ci-- 1125e5c31af7Sopenharmony_ci 1126e5c31af7Sopenharmony_ciFragment shading rates can: be set at three points, with the three rates 1127e5c31af7Sopenharmony_cicombined to determine the final shading rate. 1128e5c31af7Sopenharmony_ci 1129e5c31af7Sopenharmony_ci 1130e5c31af7Sopenharmony_ci[[primsrast-fragment-shading-rate-pipeline]] 1131e5c31af7Sopenharmony_ci=== Pipeline Fragment Shading Rate 1132e5c31af7Sopenharmony_ci 1133e5c31af7Sopenharmony_ciThe _pipeline fragment shading rate_ can: be set on a per-draw basis by 1134e5c31af7Sopenharmony_cieither setting the rate in a graphics pipeline, or dynamically via 1135e5c31af7Sopenharmony_ciflink:vkCmdSetFragmentShadingRateKHR. 1136e5c31af7Sopenharmony_ci 1137e5c31af7Sopenharmony_ci[open,refpage='VkPipelineFragmentShadingRateStateCreateInfoKHR',desc='Structure specifying parameters controlling the fragment shading rate',type='structs'] 1138e5c31af7Sopenharmony_ci-- 1139e5c31af7Sopenharmony_ciThe sname:VkPipelineFragmentShadingRateStateCreateInfoKHR structure is 1140e5c31af7Sopenharmony_cidefined as: 1141e5c31af7Sopenharmony_ci 1142e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkPipelineFragmentShadingRateStateCreateInfoKHR.adoc[] 1143e5c31af7Sopenharmony_ci 1144e5c31af7Sopenharmony_ci * pname:sType is a elink:VkStructureType value identifying this structure. 1145e5c31af7Sopenharmony_ci * pname:pNext is `NULL` or a pointer to a structure extending this 1146e5c31af7Sopenharmony_ci structure. 1147e5c31af7Sopenharmony_ci * pname:fragmentSize specifies a slink:VkExtent2D structure containing the 1148e5c31af7Sopenharmony_ci fragment size used to define the pipeline fragment shading rate for 1149e5c31af7Sopenharmony_ci drawing commands using this pipeline. 1150e5c31af7Sopenharmony_ci * pname:combinerOps specifies a elink:VkFragmentShadingRateCombinerOpKHR 1151e5c31af7Sopenharmony_ci value determining how the 1152e5c31af7Sopenharmony_ci <<primsrast-fragment-shading-rate-pipeline,pipeline>>, 1153e5c31af7Sopenharmony_ci <<primsrast-fragment-shading-rate-primitive,primitive>>, and 1154e5c31af7Sopenharmony_ci <<primsrast-fragment-shading-rate-attachment,attachment shading rates>> 1155e5c31af7Sopenharmony_ci are <<primsrast-fragment-shading-rate-combining,combined>> for fragments 1156e5c31af7Sopenharmony_ci generated by drawing commands using the created pipeline. 1157e5c31af7Sopenharmony_ci 1158e5c31af7Sopenharmony_ciIf the pname:pNext chain of slink:VkGraphicsPipelineCreateInfo includes a 1159e5c31af7Sopenharmony_cisname:VkPipelineFragmentShadingRateStateCreateInfoKHR structure, then that 1160e5c31af7Sopenharmony_cistructure includes parameters controlling the pipeline fragment shading 1161e5c31af7Sopenharmony_cirate. 1162e5c31af7Sopenharmony_ci 1163e5c31af7Sopenharmony_ciIf this structure is not present, pname:fragmentSize is considered to be 1164e5c31af7Sopenharmony_ciequal to [eq]#(1,1)#, and both elements of pname:combinerOps are considered 1165e5c31af7Sopenharmony_cito be equal to ename:VK_FRAGMENT_SHADING_RATE_COMBINER_OP_KEEP_KHR. 1166e5c31af7Sopenharmony_ci 1167e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkPipelineFragmentShadingRateStateCreateInfoKHR.adoc[] 1168e5c31af7Sopenharmony_ci-- 1169e5c31af7Sopenharmony_ci 1170e5c31af7Sopenharmony_ci[open,refpage='vkCmdSetFragmentShadingRateKHR',desc='Set pipeline fragment shading rate and combiner operation dynamically for a command buffer',type='protos'] 1171e5c31af7Sopenharmony_ci-- 1172e5c31af7Sopenharmony_ciTo <<pipelines-dynamic-state, dynamically set>> the pipeline fragment 1173e5c31af7Sopenharmony_cishading rate and combiner operation, call: 1174e5c31af7Sopenharmony_ci 1175e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCmdSetFragmentShadingRateKHR.adoc[] 1176e5c31af7Sopenharmony_ci 1177e5c31af7Sopenharmony_ci * pname:commandBuffer is the command buffer into which the command will be 1178e5c31af7Sopenharmony_ci recorded. 1179e5c31af7Sopenharmony_ci * pname:pFragmentSize specifies the pipeline fragment shading rate for 1180e5c31af7Sopenharmony_ci subsequent drawing commands. 1181e5c31af7Sopenharmony_ci * pname:combinerOps specifies a elink:VkFragmentShadingRateCombinerOpKHR 1182e5c31af7Sopenharmony_ci determining how the 1183e5c31af7Sopenharmony_ci <<primsrast-fragment-shading-rate-pipeline,pipeline>>, 1184e5c31af7Sopenharmony_ci <<primsrast-fragment-shading-rate-primitive,primitive>>, and 1185e5c31af7Sopenharmony_ci <<primsrast-fragment-shading-rate-attachment,attachment shading rates>> 1186e5c31af7Sopenharmony_ci are <<primsrast-fragment-shading-rate-combining,combined>> for fragments 1187e5c31af7Sopenharmony_ci generated by subsequent drawing commands. 1188e5c31af7Sopenharmony_ci 1189e5c31af7Sopenharmony_ciThis command sets the pipeline fragment shading rate and combiner operation 1190e5c31af7Sopenharmony_cifor subsequent drawing commands 1191e5c31af7Sopenharmony_ciifdef::VK_EXT_shader_object[when drawing using <<shaders-objects, shader objects>>, or] 1192e5c31af7Sopenharmony_ciwhen the graphics pipeline is created with 1193e5c31af7Sopenharmony_ciename:VK_DYNAMIC_STATE_FRAGMENT_SHADING_RATE_KHR set in 1194e5c31af7Sopenharmony_cislink:VkPipelineDynamicStateCreateInfo::pname:pDynamicStates. 1195e5c31af7Sopenharmony_ciOtherwise, this state is specified by the 1196e5c31af7Sopenharmony_cislink:VkPipelineFragmentShadingRateStateCreateInfoKHR values used to create 1197e5c31af7Sopenharmony_cithe currently active pipeline. 1198e5c31af7Sopenharmony_ci 1199e5c31af7Sopenharmony_ci.Valid Usage 1200e5c31af7Sopenharmony_ci**** 1201e5c31af7Sopenharmony_ci * [[VUID-vkCmdSetFragmentShadingRateKHR-pipelineFragmentShadingRate-04507]] 1202e5c31af7Sopenharmony_ci If <<features-pipelineFragmentShadingRate, 1203e5c31af7Sopenharmony_ci pname:pipelineFragmentShadingRate>> is not enabled, 1204e5c31af7Sopenharmony_ci pname:pFragmentSize->width must: be `1` 1205e5c31af7Sopenharmony_ci * [[VUID-vkCmdSetFragmentShadingRateKHR-pipelineFragmentShadingRate-04508]] 1206e5c31af7Sopenharmony_ci If <<features-pipelineFragmentShadingRate, 1207e5c31af7Sopenharmony_ci pname:pipelineFragmentShadingRate>> is not enabled, 1208e5c31af7Sopenharmony_ci pname:pFragmentSize->height must: be `1` 1209e5c31af7Sopenharmony_ci * [[VUID-vkCmdSetFragmentShadingRateKHR-pipelineFragmentShadingRate-04509]] 1210e5c31af7Sopenharmony_ci One of <<features-pipelineFragmentShadingRate, 1211e5c31af7Sopenharmony_ci pname:pipelineFragmentShadingRate>>, 1212e5c31af7Sopenharmony_ci <<features-primitiveFragmentShadingRate, 1213e5c31af7Sopenharmony_ci pname:primitiveFragmentShadingRate>>, or 1214e5c31af7Sopenharmony_ci <<features-attachmentFragmentShadingRate, 1215e5c31af7Sopenharmony_ci pname:attachmentFragmentShadingRate>> must: be enabled 1216e5c31af7Sopenharmony_ci * [[VUID-vkCmdSetFragmentShadingRateKHR-primitiveFragmentShadingRate-04510]] 1217e5c31af7Sopenharmony_ci If the <<features-primitiveFragmentShadingRate, 1218e5c31af7Sopenharmony_ci pname:primitiveFragmentShadingRate>> feature is not enabled, 1219e5c31af7Sopenharmony_ci pname:combinerOps[0] must: be 1220e5c31af7Sopenharmony_ci ename:VK_FRAGMENT_SHADING_RATE_COMBINER_OP_KEEP_KHR 1221e5c31af7Sopenharmony_ci * [[VUID-vkCmdSetFragmentShadingRateKHR-attachmentFragmentShadingRate-04511]] 1222e5c31af7Sopenharmony_ci If the <<features-attachmentFragmentShadingRate, 1223e5c31af7Sopenharmony_ci pname:attachmentFragmentShadingRate>> feature is not enabled, 1224e5c31af7Sopenharmony_ci pname:combinerOps[1] must: be 1225e5c31af7Sopenharmony_ci ename:VK_FRAGMENT_SHADING_RATE_COMBINER_OP_KEEP_KHR 1226e5c31af7Sopenharmony_ci * [[VUID-vkCmdSetFragmentShadingRateKHR-fragmentSizeNonTrivialCombinerOps-04512]] 1227e5c31af7Sopenharmony_ci If the <<limits-fragmentShadingRateNonTrivialCombinerOps, 1228e5c31af7Sopenharmony_ci pname:fragmentSizeNonTrivialCombinerOps>> limit is not supported, 1229e5c31af7Sopenharmony_ci elements of pname:combinerOps must: be either 1230e5c31af7Sopenharmony_ci ename:VK_FRAGMENT_SHADING_RATE_COMBINER_OP_KEEP_KHR or 1231e5c31af7Sopenharmony_ci ename:VK_FRAGMENT_SHADING_RATE_COMBINER_OP_REPLACE_KHR 1232e5c31af7Sopenharmony_ci * [[VUID-vkCmdSetFragmentShadingRateKHR-pFragmentSize-04513]] 1233e5c31af7Sopenharmony_ci pname:pFragmentSize->width must: be greater than or equal to `1` 1234e5c31af7Sopenharmony_ci * [[VUID-vkCmdSetFragmentShadingRateKHR-pFragmentSize-04514]] 1235e5c31af7Sopenharmony_ci pname:pFragmentSize->height must: be greater than or equal to `1` 1236e5c31af7Sopenharmony_ci * [[VUID-vkCmdSetFragmentShadingRateKHR-pFragmentSize-04515]] 1237e5c31af7Sopenharmony_ci pname:pFragmentSize->width must: be a power-of-two value 1238e5c31af7Sopenharmony_ci * [[VUID-vkCmdSetFragmentShadingRateKHR-pFragmentSize-04516]] 1239e5c31af7Sopenharmony_ci pname:pFragmentSize->height must: be a power-of-two value 1240e5c31af7Sopenharmony_ci * [[VUID-vkCmdSetFragmentShadingRateKHR-pFragmentSize-04517]] 1241e5c31af7Sopenharmony_ci pname:pFragmentSize->width must: be less than or equal to `4` 1242e5c31af7Sopenharmony_ci * [[VUID-vkCmdSetFragmentShadingRateKHR-pFragmentSize-04518]] 1243e5c31af7Sopenharmony_ci pname:pFragmentSize->height must: be less than or equal to `4` 1244e5c31af7Sopenharmony_ci**** 1245e5c31af7Sopenharmony_ci 1246e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkCmdSetFragmentShadingRateKHR.adoc[] 1247e5c31af7Sopenharmony_ci-- 1248e5c31af7Sopenharmony_ci 1249e5c31af7Sopenharmony_ci 1250e5c31af7Sopenharmony_ci[[primsrast-fragment-shading-rate-primitive]] 1251e5c31af7Sopenharmony_ci=== Primitive Fragment Shading Rate 1252e5c31af7Sopenharmony_ci 1253e5c31af7Sopenharmony_ciThe _primitive fragment shading rate_ can: be set via the 1254e5c31af7Sopenharmony_ci<<interfaces-builtin-variables-primitiveshadingrate, 1255e5c31af7Sopenharmony_cicode:PrimitiveShadingRateKHR>> built-in in the last active 1256e5c31af7Sopenharmony_ci<<pipelines-graphics-subsets-pre-rasterization,pre-rasterization shader 1257e5c31af7Sopenharmony_cistage>>. 1258e5c31af7Sopenharmony_ciifdef::VK_EXT_mesh_shader[] 1259e5c31af7Sopenharmony_ciIf the last <<pipelines-graphics-subsets-pre-rasterization,pre-rasterization 1260e5c31af7Sopenharmony_cishader stage>> is using the code:MeshEXT {ExecutionModel}, the rate 1261e5c31af7Sopenharmony_ciassociated with a given primitive is sourced from the value written to the 1262e5c31af7Sopenharmony_ciper-primitive code:PrimitiveShadingRateKHR. 1263e5c31af7Sopenharmony_ciOtherwise the 1264e5c31af7Sopenharmony_ciendif::VK_EXT_mesh_shader[] 1265e5c31af7Sopenharmony_ciifndef::VK_EXT_mesh_shader[The] 1266e5c31af7Sopenharmony_cirate associated with a given primitive is sourced from the value written to 1267e5c31af7Sopenharmony_cicode:PrimitiveShadingRateKHR by that primitive's 1268e5c31af7Sopenharmony_ci<<vertexpostproc-flatshading,provoking vertex>>. 1269e5c31af7Sopenharmony_ci 1270e5c31af7Sopenharmony_ci 1271e5c31af7Sopenharmony_ci[[primsrast-fragment-shading-rate-attachment]] 1272e5c31af7Sopenharmony_ci=== Attachment Fragment Shading Rate 1273e5c31af7Sopenharmony_ci 1274e5c31af7Sopenharmony_ciThe _attachment shading rate_ can: be set by including 1275e5c31af7Sopenharmony_cislink:VkFragmentShadingRateAttachmentInfoKHR in a subpass to define a 1276e5c31af7Sopenharmony_ci_fragment shading rate attachment_. 1277e5c31af7Sopenharmony_ciEach pixel in the framebuffer is assigned an attachment fragment shading 1278e5c31af7Sopenharmony_cirate by the corresponding texel in the fragment shading rate attachment, 1279e5c31af7Sopenharmony_ciaccording to: 1280e5c31af7Sopenharmony_ci 1281e5c31af7Sopenharmony_ci {empty}:: [eq]#x' = floor(x / region~x~)# 1282e5c31af7Sopenharmony_ci {empty}:: [eq]#y' = floor(y / region~y~)# 1283e5c31af7Sopenharmony_ci 1284e5c31af7Sopenharmony_ciwhere [eq]#x'# and [eq]#y'# are the coordinates of a texel in the fragment 1285e5c31af7Sopenharmony_cishading rate attachment, [eq]#x# and [eq]#y# are the coordinates of the 1286e5c31af7Sopenharmony_cipixel in the framebuffer, and [eq]#region~x~# and [eq]#region~y~# are the 1287e5c31af7Sopenharmony_cisize of the region each texel corresponds to, as defined by the 1288e5c31af7Sopenharmony_cipname:shadingRateAttachmentTexelSize member of 1289e5c31af7Sopenharmony_cislink:VkFragmentShadingRateAttachmentInfoKHR. 1290e5c31af7Sopenharmony_ci 1291e5c31af7Sopenharmony_ciIf <<VkRenderPassMultiviewCreateInfo, multiview is enabled>> and the shading 1292e5c31af7Sopenharmony_cirate attachment has multiple layers, the shading rate attachment texel is 1293e5c31af7Sopenharmony_ciselected from the layer determined by the 1294e5c31af7Sopenharmony_ci<<interfaces-builtin-variables-viewindex,code:ViewIndex>> built-in. 1295e5c31af7Sopenharmony_ciIf <<VkRenderPassMultiviewCreateInfo, multiview is disabled>>, and both the 1296e5c31af7Sopenharmony_cishading rate attachment and the framebuffer have multiple layers, the 1297e5c31af7Sopenharmony_cishading rate attachment texel is selected from the layer determined by the 1298e5c31af7Sopenharmony_ci<<interfaces-builtin-variables-layer,code:Layer>> built-in. 1299e5c31af7Sopenharmony_ciOtherwise, the texel is unconditionally selected from the first layer of the 1300e5c31af7Sopenharmony_ciattachment. 1301e5c31af7Sopenharmony_ci 1302e5c31af7Sopenharmony_ciThe fragment size is encoded into the first component of the identified 1303e5c31af7Sopenharmony_citexel as follows: 1304e5c31af7Sopenharmony_ci 1305e5c31af7Sopenharmony_ci {empty}:: [eq]#size~w~ = 2^((texel / 4) & 3)^# 1306e5c31af7Sopenharmony_ci {empty}:: [eq]#size~h~ = 2^(texel & 3)^# 1307e5c31af7Sopenharmony_ci 1308e5c31af7Sopenharmony_ciwhere [eq]#texel# is the value in the first component of the identified 1309e5c31af7Sopenharmony_citexel, and [eq]#size~w~# and [eq]#size~h~# are the width and height of the 1310e5c31af7Sopenharmony_cifragment size, decoded from the texel. 1311e5c31af7Sopenharmony_ci 1312e5c31af7Sopenharmony_ciIf no fragment shading rate attachment is specified, this size is calculated 1313e5c31af7Sopenharmony_cias [eq]#size~w~ = size~h~ = 1#. 1314e5c31af7Sopenharmony_ciApplications must: not specify a width or height greater than 4 by this 1315e5c31af7Sopenharmony_cimethod. 1316e5c31af7Sopenharmony_ci 1317e5c31af7Sopenharmony_ciThe _Fragment Shading Rate_ enumeration in SPIR-V adheres to the above 1318e5c31af7Sopenharmony_ciencoding. 1319e5c31af7Sopenharmony_ci 1320e5c31af7Sopenharmony_ci 1321e5c31af7Sopenharmony_ci[[primsrast-fragment-shading-rate-combining]] 1322e5c31af7Sopenharmony_ci=== Combining the Fragment Shading Rates 1323e5c31af7Sopenharmony_ci 1324e5c31af7Sopenharmony_ciThe final rate ([eq]#C~xy~'#) used for fragment shading must: be one of the 1325e5c31af7Sopenharmony_cirates returned by flink:vkGetPhysicalDeviceFragmentShadingRatesKHR for the 1326e5c31af7Sopenharmony_cisample count 1327e5c31af7Sopenharmony_ciifdef::VK_QCOM_render_pass_transform[] 1328e5c31af7Sopenharmony_ciand render pass transform 1329e5c31af7Sopenharmony_ciendif::VK_QCOM_render_pass_transform[] 1330e5c31af7Sopenharmony_ciused by rasterization. 1331e5c31af7Sopenharmony_ci 1332e5c31af7Sopenharmony_ciIf any of the following conditions are met, [eq]#C~xy~'# must: be set to 1333e5c31af7Sopenharmony_ci[eq]#{1,1}#: 1334e5c31af7Sopenharmony_ci 1335e5c31af7Sopenharmony_ci * If <<primsrast-sampleshading,Sample Shading>> is enabled. 1336e5c31af7Sopenharmony_ci * The <<limits-fragmentShadingRateWithSampleMask, 1337e5c31af7Sopenharmony_ci pname:fragmentShadingRateWithSampleMask>> limit is not supported, and 1338e5c31af7Sopenharmony_ci slink:VkPipelineMultisampleStateCreateInfo::pname:pSampleMask contains a 1339e5c31af7Sopenharmony_ci zero value in any bit used by fragment operations. 1340e5c31af7Sopenharmony_ci * The <<limits-fragmentShadingRateWithShaderSampleMask, 1341e5c31af7Sopenharmony_ci pname:fragmentShadingRateWithShaderSampleMask>> is not supported, and 1342e5c31af7Sopenharmony_ci the fragment shader has code:SampleMask in the input or output 1343e5c31af7Sopenharmony_ci interface. 1344e5c31af7Sopenharmony_ci * The <<limits-fragmentShadingRateWithShaderDepthStencilWrites, 1345e5c31af7Sopenharmony_ci pname:fragmentShadingRateWithShaderDepthStencilWrites>> limit is not 1346e5c31af7Sopenharmony_ci supported, and the fragment shader declares the code:FragDepth 1347e5c31af7Sopenharmony_ciifdef::VK_EXT_shader_stencil_export[] 1348e5c31af7Sopenharmony_ci or code:FragStencilRefEXT 1349e5c31af7Sopenharmony_ciendif::VK_EXT_shader_stencil_export[] 1350e5c31af7Sopenharmony_ci built-in. 1351e5c31af7Sopenharmony_ciifdef::VK_EXT_conservative_rasterization[] 1352e5c31af7Sopenharmony_ci * The <<limits-fragmentShadingRateWithConservativeRasterization, 1353e5c31af7Sopenharmony_ci pname:fragmentShadingRateWithConservativeRasterization>> limit is not 1354e5c31af7Sopenharmony_ci supported, and 1355e5c31af7Sopenharmony_ci slink:VkPipelineRasterizationConservativeStateCreateInfoEXT::pname:conservativeRasterizationMode 1356e5c31af7Sopenharmony_ci is not ename:VK_CONSERVATIVE_RASTERIZATION_MODE_DISABLED_EXT. 1357e5c31af7Sopenharmony_ciendif::VK_EXT_conservative_rasterization[] 1358e5c31af7Sopenharmony_ciifdef::VK_EXT_fragment_shader_interlock[] 1359e5c31af7Sopenharmony_ci * The <<limits-fragmentShadingRateWithFragmentShaderInterlock, 1360e5c31af7Sopenharmony_ci pname:fragmentShadingRateWithFragmentShaderInterlock>> limit is not 1361e5c31af7Sopenharmony_ci supported, and the fragment shader declares any of the 1362e5c31af7Sopenharmony_ci <<fragops-shader-interlock, fragment shader interlock>> execution modes. 1363e5c31af7Sopenharmony_ciendif::VK_EXT_fragment_shader_interlock[] 1364e5c31af7Sopenharmony_ciifdef::VK_EXT_sample_locations[] 1365e5c31af7Sopenharmony_ci * The <<limits-fragmentShadingRateWithCustomSampleLocations, 1366e5c31af7Sopenharmony_ci pname:fragmentShadingRateWithCustomSampleLocations>> limit is not 1367e5c31af7Sopenharmony_ci supported, and 1368e5c31af7Sopenharmony_ci slink:VkPipelineSampleLocationsStateCreateInfoEXT::pname:sampleLocationsEnable 1369e5c31af7Sopenharmony_ci is ename:VK_TRUE. 1370e5c31af7Sopenharmony_ciendif::VK_EXT_sample_locations[] 1371e5c31af7Sopenharmony_ciifdef::VK_EXT_shader_tile_image[] 1372e5c31af7Sopenharmony_ci * The fragment shader declares any of the 1373e5c31af7Sopenharmony_ci code:TileImageColorReadAccessEXT, code:TileImageDepthReadAccessEXT, or 1374e5c31af7Sopenharmony_ci code:TileImageStencilReadAccessEXT capabilities. 1375e5c31af7Sopenharmony_ciendif::VK_EXT_shader_tile_image[] 1376e5c31af7Sopenharmony_ci 1377e5c31af7Sopenharmony_ciOtherwise, each of the specified shading rates are combined and then used to 1378e5c31af7Sopenharmony_ciderive the value of [eq]#C~xy~'#. 1379e5c31af7Sopenharmony_ciAs there are three ways to specify shading rates, two combiner operations 1380e5c31af7Sopenharmony_ciare specified - between the 1381e5c31af7Sopenharmony_ci<<primsrast-fragment-shading-rate-pipeline,pipeline>> and 1382e5c31af7Sopenharmony_ci<<primsrast-fragment-shading-rate-primitive,primitive>> shading rates, and 1383e5c31af7Sopenharmony_cibetween the result of that and the 1384e5c31af7Sopenharmony_ci<<primsrast-fragment-shading-rate-attachment,attachment shading rate>>. 1385e5c31af7Sopenharmony_ci 1386e5c31af7Sopenharmony_ci[open,refpage='VkFragmentShadingRateCombinerOpKHR',desc='Control how fragment shading rates are combined',type='enums'] 1387e5c31af7Sopenharmony_ci-- 1388e5c31af7Sopenharmony_ciThe equation used for each combiner operation is defined by 1389e5c31af7Sopenharmony_ciename:VkFragmentShadingRateCombinerOpKHR: 1390e5c31af7Sopenharmony_ci 1391e5c31af7Sopenharmony_ciinclude::{generated}/api/enums/VkFragmentShadingRateCombinerOpKHR.adoc[] 1392e5c31af7Sopenharmony_ci 1393e5c31af7Sopenharmony_ci * ename:VK_FRAGMENT_SHADING_RATE_COMBINER_OP_KEEP_KHR specifies a combiner 1394e5c31af7Sopenharmony_ci operation of [eq]#combine(A~xy~,B~xy~) = A~xy~#. 1395e5c31af7Sopenharmony_ci * ename:VK_FRAGMENT_SHADING_RATE_COMBINER_OP_REPLACE_KHR specifies a 1396e5c31af7Sopenharmony_ci combiner operation of [eq]#combine(A~xy~,B~xy~) = B~xy~#. 1397e5c31af7Sopenharmony_ci * ename:VK_FRAGMENT_SHADING_RATE_COMBINER_OP_MIN_KHR specifies a combiner 1398e5c31af7Sopenharmony_ci operation of [eq]#combine(A~xy~,B~xy~) = min(A~xy~,B~xy~)#. 1399e5c31af7Sopenharmony_ci * ename:VK_FRAGMENT_SHADING_RATE_COMBINER_OP_MAX_KHR specifies a combiner 1400e5c31af7Sopenharmony_ci operation of [eq]#combine(A~xy~,B~xy~) = max(A~xy~,B~xy~)#. 1401e5c31af7Sopenharmony_ci * ename:VK_FRAGMENT_SHADING_RATE_COMBINER_OP_MUL_KHR specifies a combiner 1402e5c31af7Sopenharmony_ci operation of [eq]#combine(A~xy~,B~xy~) = A~xy~*B~xy~#. 1403e5c31af7Sopenharmony_ci 1404e5c31af7Sopenharmony_ciwhere [eq]#combine(A~xy~,B~xy~)# is the combine operation, and [eq]#A~xy~# 1405e5c31af7Sopenharmony_ciand [eq]#B~xy~# are the inputs to the operation. 1406e5c31af7Sopenharmony_ci 1407e5c31af7Sopenharmony_ciIf <<limits-fragmentShadingRateStrictMultiplyCombiner, 1408e5c31af7Sopenharmony_cipname:fragmentShadingRateStrictMultiplyCombiner>> is ename:VK_FALSE, using 1409e5c31af7Sopenharmony_ciename:VK_FRAGMENT_SHADING_RATE_COMBINER_OP_MUL_KHR with values of 1 for both 1410e5c31af7Sopenharmony_ciA and B in the same dimension results in the value 2 being produced for that 1411e5c31af7Sopenharmony_cidimension. 1412e5c31af7Sopenharmony_ciSee the definition of <<limits-fragmentShadingRateStrictMultiplyCombiner, 1413e5c31af7Sopenharmony_cipname:fragmentShadingRateStrictMultiplyCombiner>> for more information. 1414e5c31af7Sopenharmony_ci 1415e5c31af7Sopenharmony_ciThese operations are performed in a component-wise fashion. 1416e5c31af7Sopenharmony_ci-- 1417e5c31af7Sopenharmony_ci 1418e5c31af7Sopenharmony_ciThis is used to generate a combined fragment area using the equation: 1419e5c31af7Sopenharmony_ci 1420e5c31af7Sopenharmony_ci {empty}:: [eq]#C~xy~ = combine(A~xy~,B~xy~)# 1421e5c31af7Sopenharmony_ci 1422e5c31af7Sopenharmony_ciwhere [eq]#C~xy~# is the combined fragment area result, and [eq]#A~xy~# and 1423e5c31af7Sopenharmony_ci[eq]#B~xy~# are the fragment areas of the fragment shading rates being 1424e5c31af7Sopenharmony_cicombined. 1425e5c31af7Sopenharmony_ci 1426e5c31af7Sopenharmony_ciTwo combine operations are performed, first with [eq]#A~xy~# equal to the 1427e5c31af7Sopenharmony_ci<<primsrast-fragment-shading-rate-pipeline,pipeline fragment shading rate>> 1428e5c31af7Sopenharmony_ciand [eq]#B~xy~# equal to the <<primsrast-fragment-shading-rate-primitive, 1429e5c31af7Sopenharmony_ciprimitive fragment shading rate>>, with the [eq]#combine()# operation 1430e5c31af7Sopenharmony_ciselected by combinerOps[0]. 1431e5c31af7Sopenharmony_ciA second combination is then performed, with [eq]#A~xy~# equal to the result 1432e5c31af7Sopenharmony_ciof the first combination and [eq]#B~xy~# equal to the 1433e5c31af7Sopenharmony_ci<<primsrast-fragment-shading-rate-attachment, attachment fragment shading 1434e5c31af7Sopenharmony_cirate>>, with the [eq]#combine()# operation selected by combinerOps[1]. 1435e5c31af7Sopenharmony_ciThe result of the second combination is used as the final fragment shading 1436e5c31af7Sopenharmony_cirate, reported via the <<interfaces-builtin-variables-primitiveshadingrate, 1437e5c31af7Sopenharmony_cicode:ShadingRateKHR built-in>>. 1438e5c31af7Sopenharmony_ci 1439e5c31af7Sopenharmony_ciImplementations should: clamp the inputs to the combiner operations 1440e5c31af7Sopenharmony_ci[eq]#A~xy~# and [eq]#B~xy~#, and must: 1441e5c31af7Sopenharmony_ciifdef::VK_KHR_maintenance6[] 1442e5c31af7Sopenharmony_cido so if 1443e5c31af7Sopenharmony_cisname:VkPhysicalDeviceMaintenance6PropertiesKHR::pname:fragmentShadingRateClampCombinerInputs 1444e5c31af7Sopenharmony_ciis set to ename:VK_TRUE. 1445e5c31af7Sopenharmony_ciAll implementations must: 1446e5c31af7Sopenharmony_ciendif::VK_KHR_maintenance6[] 1447e5c31af7Sopenharmony_ciclamp the result of the second combiner operation. 1448e5c31af7Sopenharmony_ci 1449e5c31af7Sopenharmony_ciA fragment shading rate [eq]#R~xy~# representing any of [eq]#A~xy~#, 1450e5c31af7Sopenharmony_ci[eq]#B~xy~# or [eq]#C~xy~# is clamped as follows. 1451e5c31af7Sopenharmony_ciIf [eq]#R~xy~# is one of the rates returned by 1452e5c31af7Sopenharmony_ciflink:vkGetPhysicalDeviceFragmentShadingRatesKHR for the sample count 1453e5c31af7Sopenharmony_ciifdef::VK_QCOM_render_pass_transform[] 1454e5c31af7Sopenharmony_ciand render pass transform 1455e5c31af7Sopenharmony_ciendif::VK_QCOM_render_pass_transform[] 1456e5c31af7Sopenharmony_ciused by rasterization, the clamped shading rate [eq]#R~xy~'# is [eq]#R~xy~#. 1457e5c31af7Sopenharmony_ciOtherwise, the clamped shading rate is selected from the rates returned by 1458e5c31af7Sopenharmony_ciflink:vkGetPhysicalDeviceFragmentShadingRatesKHR for the sample count 1459e5c31af7Sopenharmony_ciifdef::VK_QCOM_render_pass_transform[] 1460e5c31af7Sopenharmony_ciand render pass transform 1461e5c31af7Sopenharmony_ciendif::VK_QCOM_render_pass_transform[] 1462e5c31af7Sopenharmony_ciused by rasterization. 1463e5c31af7Sopenharmony_ciFrom this list of supported rates, the following steps are applied in order, 1464e5c31af7Sopenharmony_cito select a single value: 1465e5c31af7Sopenharmony_ci 1466e5c31af7Sopenharmony_ci . Keep only rates where [eq]#R~x~' {leq} R~x~# and [eq]#R~y~' {leq} R~y~#. 1467e5c31af7Sopenharmony_ci ** Implementations may: also keep rates where [eq]#R~x~' {leq} R~y~# and 1468e5c31af7Sopenharmony_ci [eq]#R~y~' {leq} R~x~#. 1469e5c31af7Sopenharmony_ci . Keep only rates with the highest area ([eq]#R~x~' {times} R~y~'#). 1470e5c31af7Sopenharmony_ci . Keep only rates with the lowest aspect ratio ([eq]#R~x~' {plus} R~y~'#). 1471e5c31af7Sopenharmony_ci . In cases where a wide (e.g. 4x1) and tall (e.g. 1x4) rate remain, the 1472e5c31af7Sopenharmony_ci implementation may: choose either rate. 1473e5c31af7Sopenharmony_ci However, it must: choose this rate consistently for the same shading 1474e5c31af7Sopenharmony_ci rates, 1475e5c31af7Sopenharmony_ciifdef::VK_QCOM_render_pass_transform[] 1476e5c31af7Sopenharmony_ci render pass transform, 1477e5c31af7Sopenharmony_ciendif::VK_QCOM_render_pass_transform[] 1478e5c31af7Sopenharmony_ci and combiner operations for the lifetime of the slink:VkDevice. 1479e5c31af7Sopenharmony_ciendif::VK_KHR_fragment_shading_rate[] 1480e5c31af7Sopenharmony_ci 1481e5c31af7Sopenharmony_ci 1482e5c31af7Sopenharmony_ciifdef::VK_NV_fragment_shading_rate_enums[] 1483e5c31af7Sopenharmony_ci=== Extended Fragment Shading Rates 1484e5c31af7Sopenharmony_ci 1485e5c31af7Sopenharmony_ciThe features advertised by 1486e5c31af7Sopenharmony_cislink:VkPhysicalDeviceFragmentShadingRateEnumsFeaturesNV provide support for 1487e5c31af7Sopenharmony_ciadditional fragment shading rates beyond those specifying one fragment 1488e5c31af7Sopenharmony_cishader invocation covering all pixels in a fragment whose size is indicated 1489e5c31af7Sopenharmony_ciby the fragment shading rate. 1490e5c31af7Sopenharmony_ci 1491e5c31af7Sopenharmony_ci[open,refpage='VkFragmentShadingRateNV',desc='Enumeration with fragment shading rates',type='enums'] 1492e5c31af7Sopenharmony_ci-- 1493e5c31af7Sopenharmony_ciIf the pname:fragmentShadingRateEnums feature is enabled, fragment shading 1494e5c31af7Sopenharmony_cirates may be specified using the elink:VkFragmentShadingRateNV enumerated 1495e5c31af7Sopenharmony_citype defined as: 1496e5c31af7Sopenharmony_ci 1497e5c31af7Sopenharmony_ciinclude::{generated}/api/enums/VkFragmentShadingRateNV.adoc[] 1498e5c31af7Sopenharmony_ci 1499e5c31af7Sopenharmony_ci * ename:VK_FRAGMENT_SHADING_RATE_1_INVOCATION_PER_PIXEL_NV specifies a 1500e5c31af7Sopenharmony_ci fragment size of 1x1 pixels. 1501e5c31af7Sopenharmony_ci * ename:VK_FRAGMENT_SHADING_RATE_1_INVOCATION_PER_1X2_PIXELS_NV specifies 1502e5c31af7Sopenharmony_ci a fragment size of 1x2 pixels. 1503e5c31af7Sopenharmony_ci * ename:VK_FRAGMENT_SHADING_RATE_1_INVOCATION_PER_2X1_PIXELS_NV specifies 1504e5c31af7Sopenharmony_ci a fragment size of 2x1 pixels. 1505e5c31af7Sopenharmony_ci * ename:VK_FRAGMENT_SHADING_RATE_1_INVOCATION_PER_2X2_PIXELS_NV specifies 1506e5c31af7Sopenharmony_ci a fragment size of 2x2 pixels. 1507e5c31af7Sopenharmony_ci * ename:VK_FRAGMENT_SHADING_RATE_1_INVOCATION_PER_2X4_PIXELS_NV specifies 1508e5c31af7Sopenharmony_ci a fragment size of 2x4 pixels. 1509e5c31af7Sopenharmony_ci * ename:VK_FRAGMENT_SHADING_RATE_1_INVOCATION_PER_4X2_PIXELS_NV specifies 1510e5c31af7Sopenharmony_ci a fragment size of 4x2 pixels. 1511e5c31af7Sopenharmony_ci * ename:VK_FRAGMENT_SHADING_RATE_1_INVOCATION_PER_4X4_PIXELS_NV specifies 1512e5c31af7Sopenharmony_ci a fragment size of 4x4 pixels. 1513e5c31af7Sopenharmony_ci * ename:VK_FRAGMENT_SHADING_RATE_2_INVOCATIONS_PER_PIXEL_NV specifies a 1514e5c31af7Sopenharmony_ci fragment size of 1x1 pixels, with two fragment shader invocations per 1515e5c31af7Sopenharmony_ci fragment. 1516e5c31af7Sopenharmony_ci * ename:VK_FRAGMENT_SHADING_RATE_4_INVOCATIONS_PER_PIXEL_NV specifies a 1517e5c31af7Sopenharmony_ci fragment size of 1x1 pixels, with four fragment shader invocations per 1518e5c31af7Sopenharmony_ci fragment. 1519e5c31af7Sopenharmony_ci * ename:VK_FRAGMENT_SHADING_RATE_8_INVOCATIONS_PER_PIXEL_NV specifies a 1520e5c31af7Sopenharmony_ci fragment size of 1x1 pixels, with eight fragment shader invocations per 1521e5c31af7Sopenharmony_ci fragment. 1522e5c31af7Sopenharmony_ci * ename:VK_FRAGMENT_SHADING_RATE_16_INVOCATIONS_PER_PIXEL_NV specifies a 1523e5c31af7Sopenharmony_ci fragment size of 1x1 pixels, with sixteen fragment shader invocations 1524e5c31af7Sopenharmony_ci per fragment. 1525e5c31af7Sopenharmony_ci * ename:VK_FRAGMENT_SHADING_RATE_NO_INVOCATIONS_NV specifies that any 1526e5c31af7Sopenharmony_ci portions of a primitive that use that shading rate should be discarded 1527e5c31af7Sopenharmony_ci without invoking any fragment shader. 1528e5c31af7Sopenharmony_ci 1529e5c31af7Sopenharmony_ciTo use the shading rates 1530e5c31af7Sopenharmony_ciename:VK_FRAGMENT_SHADING_RATE_2_INVOCATIONS_PER_PIXEL_NV, 1531e5c31af7Sopenharmony_ciename:VK_FRAGMENT_SHADING_RATE_4_INVOCATIONS_PER_PIXEL_NV, 1532e5c31af7Sopenharmony_ciename:VK_FRAGMENT_SHADING_RATE_8_INVOCATIONS_PER_PIXEL_NV, and 1533e5c31af7Sopenharmony_ciename:VK_FRAGMENT_SHADING_RATE_16_INVOCATIONS_PER_PIXEL_NV as a pipeline, 1534e5c31af7Sopenharmony_ciprimitive, or attachment shading rate, the 1535e5c31af7Sopenharmony_cipname:supersampleFragmentShadingRates feature must: be enabled. 1536e5c31af7Sopenharmony_ciTo use the shading rate ename:VK_FRAGMENT_SHADING_RATE_NO_INVOCATIONS_NV as 1537e5c31af7Sopenharmony_cia pipeline, primitive, or attachment shading rate, the 1538e5c31af7Sopenharmony_cipname:noInvocationFragmentShadingRates feature must: be enabled. 1539e5c31af7Sopenharmony_ci-- 1540e5c31af7Sopenharmony_ci 1541e5c31af7Sopenharmony_ciWhen using fragment shading rate enums, the pipeline fragment shading rate 1542e5c31af7Sopenharmony_cican: be set on a per-draw basis by either setting the rate in a graphics 1543e5c31af7Sopenharmony_cipipeline, or dynamically via flink:vkCmdSetFragmentShadingRateEnumNV. 1544e5c31af7Sopenharmony_ci 1545e5c31af7Sopenharmony_ci[open,refpage='VkPipelineFragmentShadingRateEnumStateCreateInfoNV',desc='Structure specifying parameters controlling the fragment shading rate using rate enums',type='structs'] 1546e5c31af7Sopenharmony_ci-- 1547e5c31af7Sopenharmony_ciThe sname:VkPipelineFragmentShadingRateEnumStateCreateInfoNV structure is 1548e5c31af7Sopenharmony_cidefined as: 1549e5c31af7Sopenharmony_ci 1550e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkPipelineFragmentShadingRateEnumStateCreateInfoNV.adoc[] 1551e5c31af7Sopenharmony_ci 1552e5c31af7Sopenharmony_ci * pname:sType is a elink:VkStructureType value identifying this structure. 1553e5c31af7Sopenharmony_ci * pname:pNext is `NULL` or a pointer to a structure extending this 1554e5c31af7Sopenharmony_ci structure. 1555e5c31af7Sopenharmony_ci * pname:shadingRateType specifies a elink:VkFragmentShadingRateTypeNV 1556e5c31af7Sopenharmony_ci value indicating whether fragment shading rates are specified using 1557e5c31af7Sopenharmony_ci fragment sizes or elink:VkFragmentShadingRateNV enums. 1558e5c31af7Sopenharmony_ci * pname:shadingRate specifies a elink:VkFragmentShadingRateNV value 1559e5c31af7Sopenharmony_ci indicating the pipeline fragment shading rate. 1560e5c31af7Sopenharmony_ci * pname:combinerOps specifies elink:VkFragmentShadingRateCombinerOpKHR 1561e5c31af7Sopenharmony_ci values determining how the 1562e5c31af7Sopenharmony_ci <<primsrast-fragment-shading-rate-pipeline,pipeline>>, 1563e5c31af7Sopenharmony_ci <<primsrast-fragment-shading-rate-primitive,primitive>>, and 1564e5c31af7Sopenharmony_ci <<primsrast-fragment-shading-rate-attachment,attachment shading rates>> 1565e5c31af7Sopenharmony_ci are <<primsrast-fragment-shading-rate-combining,combined>> for fragments 1566e5c31af7Sopenharmony_ci generated by drawing commands using the created pipeline. 1567e5c31af7Sopenharmony_ci 1568e5c31af7Sopenharmony_ciIf the pname:pNext chain of slink:VkGraphicsPipelineCreateInfo includes a 1569e5c31af7Sopenharmony_cisname:VkPipelineFragmentShadingRateEnumStateCreateInfoNV structure, then 1570e5c31af7Sopenharmony_cithat structure includes parameters controlling the pipeline fragment shading 1571e5c31af7Sopenharmony_cirate. 1572e5c31af7Sopenharmony_ci 1573e5c31af7Sopenharmony_ciIf this structure is not present, pname:shadingRateType is considered to be 1574e5c31af7Sopenharmony_ciequal to ename:VK_FRAGMENT_SHADING_RATE_TYPE_FRAGMENT_SIZE_NV, 1575e5c31af7Sopenharmony_cipname:shadingRate is considered to be equal to 1576e5c31af7Sopenharmony_ciename:VK_FRAGMENT_SHADING_RATE_1_INVOCATION_PER_PIXEL_NV, and both elements 1577e5c31af7Sopenharmony_ciof pname:combinerOps are considered to be equal to 1578e5c31af7Sopenharmony_ciename:VK_FRAGMENT_SHADING_RATE_COMBINER_OP_KEEP_KHR. 1579e5c31af7Sopenharmony_ci 1580e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkPipelineFragmentShadingRateEnumStateCreateInfoNV.adoc[] 1581e5c31af7Sopenharmony_ci-- 1582e5c31af7Sopenharmony_ci 1583e5c31af7Sopenharmony_ci[open,refpage='VkFragmentShadingRateTypeNV',desc='Enumeration with fragment shading rate types',type='enums'] 1584e5c31af7Sopenharmony_ci-- 1585e5c31af7Sopenharmony_ciThe elink:VkFragmentShadingRateTypeNV enumerated type specifies whether a 1586e5c31af7Sopenharmony_cigraphics pipeline gets its pipeline fragment shading rates and combiners 1587e5c31af7Sopenharmony_cifrom the slink:VkPipelineFragmentShadingRateEnumStateCreateInfoNV structure 1588e5c31af7Sopenharmony_cior the slink:VkPipelineFragmentShadingRateStateCreateInfoKHR structure. 1589e5c31af7Sopenharmony_ci 1590e5c31af7Sopenharmony_ciinclude::{generated}/api/enums/VkFragmentShadingRateTypeNV.adoc[] 1591e5c31af7Sopenharmony_ci 1592e5c31af7Sopenharmony_ci * ename:VK_FRAGMENT_SHADING_RATE_TYPE_FRAGMENT_SIZE_NV specifies that a 1593e5c31af7Sopenharmony_ci graphics pipeline should obtain its pipeline fragment shading rate and 1594e5c31af7Sopenharmony_ci shading rate combiner state from the 1595e5c31af7Sopenharmony_ci slink:VkPipelineFragmentShadingRateStateCreateInfoKHR structure and that 1596e5c31af7Sopenharmony_ci any state specified by the 1597e5c31af7Sopenharmony_ci slink:VkPipelineFragmentShadingRateEnumStateCreateInfoNV structure 1598e5c31af7Sopenharmony_ci should be ignored. 1599e5c31af7Sopenharmony_ci * ename:VK_FRAGMENT_SHADING_RATE_TYPE_ENUMS_NV specifies that a graphics 1600e5c31af7Sopenharmony_ci pipeline should obtain its pipeline fragment shading rate and shading 1601e5c31af7Sopenharmony_ci rate combiner state from the 1602e5c31af7Sopenharmony_ci slink:VkPipelineFragmentShadingRateEnumStateCreateInfoNV structure and 1603e5c31af7Sopenharmony_ci that any state specified by the 1604e5c31af7Sopenharmony_ci slink:VkPipelineFragmentShadingRateStateCreateInfoKHR structure should 1605e5c31af7Sopenharmony_ci be ignored. 1606e5c31af7Sopenharmony_ci-- 1607e5c31af7Sopenharmony_ci 1608e5c31af7Sopenharmony_ci[open,refpage='vkCmdSetFragmentShadingRateEnumNV',desc='Set pipeline fragment shading rate dynamically for a command buffer using enums',type='protos'] 1609e5c31af7Sopenharmony_ci-- 1610e5c31af7Sopenharmony_ciTo <<pipelines-dynamic-state, dynamically set>> the pipeline fragment 1611e5c31af7Sopenharmony_cishading rate and combiner operation, call: 1612e5c31af7Sopenharmony_ci 1613e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCmdSetFragmentShadingRateEnumNV.adoc[] 1614e5c31af7Sopenharmony_ci 1615e5c31af7Sopenharmony_ci * pname:commandBuffer is the command buffer into which the command will be 1616e5c31af7Sopenharmony_ci recorded. 1617e5c31af7Sopenharmony_ci * pname:shadingRate specifies a elink:VkFragmentShadingRateNV enum 1618e5c31af7Sopenharmony_ci indicating the pipeline fragment shading rate for subsequent drawing 1619e5c31af7Sopenharmony_ci commands. 1620e5c31af7Sopenharmony_ci * pname:combinerOps specifies a elink:VkFragmentShadingRateCombinerOpKHR 1621e5c31af7Sopenharmony_ci determining how the 1622e5c31af7Sopenharmony_ci <<primsrast-fragment-shading-rate-pipeline,pipeline>>, 1623e5c31af7Sopenharmony_ci <<primsrast-fragment-shading-rate-primitive,primitive>>, and 1624e5c31af7Sopenharmony_ci <<primsrast-fragment-shading-rate-attachment,attachment shading rates>> 1625e5c31af7Sopenharmony_ci are <<primsrast-fragment-shading-rate-combining,combined>> for fragments 1626e5c31af7Sopenharmony_ci generated by subsequent drawing commands. 1627e5c31af7Sopenharmony_ci 1628e5c31af7Sopenharmony_ciThis command sets the pipeline fragment shading rate and combiner operation 1629e5c31af7Sopenharmony_cifor subsequent drawing commands 1630e5c31af7Sopenharmony_ciifdef::VK_EXT_shader_object[when drawing using <<shaders-objects, shader objects>>, or] 1631e5c31af7Sopenharmony_ciwhen the graphics pipeline is created with 1632e5c31af7Sopenharmony_ciename:VK_DYNAMIC_STATE_FRAGMENT_SHADING_RATE_KHR set in 1633e5c31af7Sopenharmony_cislink:VkPipelineDynamicStateCreateInfo::pname:pDynamicStates. 1634e5c31af7Sopenharmony_ciOtherwise, this state is specified by the 1635e5c31af7Sopenharmony_cislink:VkPipelineFragmentShadingRateEnumStateCreateInfoNV values used to 1636e5c31af7Sopenharmony_cicreate the currently active pipeline. 1637e5c31af7Sopenharmony_ci 1638e5c31af7Sopenharmony_ci[NOTE] 1639e5c31af7Sopenharmony_ci.Note 1640e5c31af7Sopenharmony_ci==== 1641e5c31af7Sopenharmony_ciThis command allows specifying additional shading rates beyond those 1642e5c31af7Sopenharmony_cisupported by flink:vkCmdSetFragmentShadingRateKHR. 1643e5c31af7Sopenharmony_ciFor more information, refer to the 1644e5c31af7Sopenharmony_ci`apiext:VK_NV_fragment_shading_rate_enums` appendix. 1645e5c31af7Sopenharmony_ci==== 1646e5c31af7Sopenharmony_ci 1647e5c31af7Sopenharmony_ci.Valid Usage 1648e5c31af7Sopenharmony_ci**** 1649e5c31af7Sopenharmony_ci * [[VUID-vkCmdSetFragmentShadingRateEnumNV-pipelineFragmentShadingRate-04576]] 1650e5c31af7Sopenharmony_ci If <<features-pipelineFragmentShadingRate, 1651e5c31af7Sopenharmony_ci pname:pipelineFragmentShadingRate>> is not enabled, pname:shadingRate 1652e5c31af7Sopenharmony_ci must: be ename:VK_FRAGMENT_SHADING_RATE_1_INVOCATION_PER_PIXEL_NV 1653e5c31af7Sopenharmony_ci * [[VUID-vkCmdSetFragmentShadingRateEnumNV-supersampleFragmentShadingRates-04577]] 1654e5c31af7Sopenharmony_ci If <<features-supersampleFragmentShadingRates, 1655e5c31af7Sopenharmony_ci pname:supersampleFragmentShadingRates>> is not enabled, 1656e5c31af7Sopenharmony_ci pname:shadingRate must: not be 1657e5c31af7Sopenharmony_ci ename:VK_FRAGMENT_SHADING_RATE_2_INVOCATIONS_PER_PIXEL_NV, 1658e5c31af7Sopenharmony_ci ename:VK_FRAGMENT_SHADING_RATE_4_INVOCATIONS_PER_PIXEL_NV, 1659e5c31af7Sopenharmony_ci ename:VK_FRAGMENT_SHADING_RATE_8_INVOCATIONS_PER_PIXEL_NV, or 1660e5c31af7Sopenharmony_ci ename:VK_FRAGMENT_SHADING_RATE_16_INVOCATIONS_PER_PIXEL_NV 1661e5c31af7Sopenharmony_ci * [[VUID-vkCmdSetFragmentShadingRateEnumNV-noInvocationFragmentShadingRates-04578]] 1662e5c31af7Sopenharmony_ci If <<features-noInvocationFragmentShadingRates, 1663e5c31af7Sopenharmony_ci pname:noInvocationFragmentShadingRates>> is not enabled, 1664e5c31af7Sopenharmony_ci pname:shadingRate must: not be 1665e5c31af7Sopenharmony_ci ename:VK_FRAGMENT_SHADING_RATE_NO_INVOCATIONS_NV 1666e5c31af7Sopenharmony_ci * [[VUID-vkCmdSetFragmentShadingRateEnumNV-fragmentShadingRateEnums-04579]] 1667e5c31af7Sopenharmony_ci The <<features-fragmentShadingRateEnums, 1668e5c31af7Sopenharmony_ci pname:fragmentShadingRateEnums>> feature must: be enabled 1669e5c31af7Sopenharmony_ci * [[VUID-vkCmdSetFragmentShadingRateEnumNV-pipelineFragmentShadingRate-04580]] 1670e5c31af7Sopenharmony_ci One of the <<features-pipelineFragmentShadingRate, 1671e5c31af7Sopenharmony_ci pname:pipelineFragmentShadingRate>>, 1672e5c31af7Sopenharmony_ci <<features-primitiveFragmentShadingRate, 1673e5c31af7Sopenharmony_ci pname:primitiveFragmentShadingRate>>, or 1674e5c31af7Sopenharmony_ci <<features-attachmentFragmentShadingRate, 1675e5c31af7Sopenharmony_ci pname:attachmentFragmentShadingRate>> features must: be enabled 1676e5c31af7Sopenharmony_ci * [[VUID-vkCmdSetFragmentShadingRateEnumNV-primitiveFragmentShadingRate-04581]] 1677e5c31af7Sopenharmony_ci If the <<features-primitiveFragmentShadingRate, 1678e5c31af7Sopenharmony_ci pname:primitiveFragmentShadingRate>> feature is not enabled, 1679e5c31af7Sopenharmony_ci pname:combinerOps[0] must: be 1680e5c31af7Sopenharmony_ci ename:VK_FRAGMENT_SHADING_RATE_COMBINER_OP_KEEP_KHR 1681e5c31af7Sopenharmony_ci * [[VUID-vkCmdSetFragmentShadingRateEnumNV-attachmentFragmentShadingRate-04582]] 1682e5c31af7Sopenharmony_ci If the <<features-attachmentFragmentShadingRate, 1683e5c31af7Sopenharmony_ci pname:attachmentFragmentShadingRate>> feature is not enabled, 1684e5c31af7Sopenharmony_ci pname:combinerOps[1] must: be 1685e5c31af7Sopenharmony_ci ename:VK_FRAGMENT_SHADING_RATE_COMBINER_OP_KEEP_KHR 1686e5c31af7Sopenharmony_ci * [[VUID-vkCmdSetFragmentShadingRateEnumNV-fragmentSizeNonTrivialCombinerOps-04583]] 1687e5c31af7Sopenharmony_ci If the <<limits-fragmentShadingRateNonTrivialCombinerOps, 1688e5c31af7Sopenharmony_ci pname:fragmentSizeNonTrivialCombinerOps>> limit is not supported, 1689e5c31af7Sopenharmony_ci elements of pname:combinerOps must: be either 1690e5c31af7Sopenharmony_ci ename:VK_FRAGMENT_SHADING_RATE_COMBINER_OP_KEEP_KHR or 1691e5c31af7Sopenharmony_ci ename:VK_FRAGMENT_SHADING_RATE_COMBINER_OP_REPLACE_KHR 1692e5c31af7Sopenharmony_ci**** 1693e5c31af7Sopenharmony_ci 1694e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkCmdSetFragmentShadingRateEnumNV.adoc[] 1695e5c31af7Sopenharmony_ci-- 1696e5c31af7Sopenharmony_ci 1697e5c31af7Sopenharmony_ciWhen the <<features-supersampleFragmentShadingRates, 1698e5c31af7Sopenharmony_cipname:supersampleFragmentShadingRates>> or 1699e5c31af7Sopenharmony_ci<<features-noInvocationFragmentShadingRates, 1700e5c31af7Sopenharmony_cipname:noInvocationFragmentShadingRates>> features are enabled, the behavior 1701e5c31af7Sopenharmony_ciof the <<primsrast-fragment-shading-rate-combining,shading rate combiner 1702e5c31af7Sopenharmony_cioperations>> is extended to support the shading rates enabled by those 1703e5c31af7Sopenharmony_cifeatures. 1704e5c31af7Sopenharmony_ciPrimitive and attachment shading rate values are interpreted as 1705e5c31af7Sopenharmony_cielink:VkFragmentShadingRateNV values and the behavior of the combiners is 1706e5c31af7Sopenharmony_cimodified as follows: 1707e5c31af7Sopenharmony_ci 1708e5c31af7Sopenharmony_ci * For ename:VK_FRAGMENT_SHADING_RATE_COMBINER_OP_MIN_KHR, 1709e5c31af7Sopenharmony_ci ename:VK_FRAGMENT_SHADING_RATE_COMBINER_OP_MAX_KHR, and 1710e5c31af7Sopenharmony_ci ename:VK_FRAGMENT_SHADING_RATE_COMBINER_OP_MUL_KHR, if either 1711e5c31af7Sopenharmony_ci [eq]#A~xy~# or [eq]#B~xy~# is 1712e5c31af7Sopenharmony_ci ename:VK_FRAGMENT_SHADING_RATE_NO_INVOCATIONS_NV, 1713e5c31af7Sopenharmony_ci [eq]#combine(A~xy~,B~xy~)# produces a shading rate of 1714e5c31af7Sopenharmony_ci ename:VK_FRAGMENT_SHADING_RATE_NO_INVOCATIONS_NV, regardless of the 1715e5c31af7Sopenharmony_ci other input shading rate. 1716e5c31af7Sopenharmony_ci * For ename:VK_FRAGMENT_SHADING_RATE_COMBINER_OP_MIN_KHR, 1717e5c31af7Sopenharmony_ci [eq]#combine(A~xy~,B~xy~)# produces a shading rate whose fragment size 1718e5c31af7Sopenharmony_ci is the smaller of the fragment sizes of [eq]#A~xy~# and [eq]#B~xy~# and 1719e5c31af7Sopenharmony_ci whose invocation count is the larger of the invocation counts of 1720e5c31af7Sopenharmony_ci [eq]#A~xy~# and [eq]#B~xy~#. 1721e5c31af7Sopenharmony_ci * For ename:VK_FRAGMENT_SHADING_RATE_COMBINER_OP_MAX_KHR, 1722e5c31af7Sopenharmony_ci [eq]#combine(A~xy~,B~xy~)# produces a shading rate whose fragment size 1723e5c31af7Sopenharmony_ci is the larger of the fragment sizes of [eq]#A~xy~# and [eq]#B~xy~# and 1724e5c31af7Sopenharmony_ci whose invocation count is the smaller of the invocation counts of 1725e5c31af7Sopenharmony_ci [eq]#A~xy~# and [eq]#B~xy~#. 1726e5c31af7Sopenharmony_ci * For ename:VK_FRAGMENT_SHADING_RATE_COMBINER_OP_MUL_KHR, 1727e5c31af7Sopenharmony_ci [eq]#combine(A~xy~,B~xy~)# produces a shading rate whose fragment size 1728e5c31af7Sopenharmony_ci and invocation count is the product of the fragment sizes and invocation 1729e5c31af7Sopenharmony_ci counts, respectively, of [eq]#A~xy~# and [eq]#B~xy~#. 1730e5c31af7Sopenharmony_ci If the resulting shading rate has both multiple pixels and multiple 1731e5c31af7Sopenharmony_ci invocations per fragment, an implementation may: adjust the shading rate 1732e5c31af7Sopenharmony_ci by reducing both the pixel and invocation counts. 1733e5c31af7Sopenharmony_ci 1734e5c31af7Sopenharmony_ciIf the final shading rate from the combiners is 1735e5c31af7Sopenharmony_ciename:VK_FRAGMENT_SHADING_RATE_NO_INVOCATIONS_NV, no fragments will be 1736e5c31af7Sopenharmony_cigenerated for any portion of a primitive using that shading rate. 1737e5c31af7Sopenharmony_ci 1738e5c31af7Sopenharmony_ciIf the final shading rate from the combiners specifies multiple fragment 1739e5c31af7Sopenharmony_cishader invocations per fragment, the fragment will be processed with 1740e5c31af7Sopenharmony_cimultiple unique samples as in <<primsrast-sampleshading, sample shading>>, 1741e5c31af7Sopenharmony_ciwhere the total number the total number of invocations is taken from the 1742e5c31af7Sopenharmony_cishading rate and then clamped to pname:rasterizationSamples and 1743e5c31af7Sopenharmony_ci<<limits-maxFragmentShadingRateInvocationCount, 1744e5c31af7Sopenharmony_cipname:maxFragmentShadingRateInvocationCount>>. 1745e5c31af7Sopenharmony_ci 1746e5c31af7Sopenharmony_ciendif::VK_NV_fragment_shading_rate_enums[] 1747e5c31af7Sopenharmony_ci 1748e5c31af7Sopenharmony_ci 1749e5c31af7Sopenharmony_ciifdef::VK_NV_shading_rate_image[] 1750e5c31af7Sopenharmony_ci[[primsrast-shading-rate-image]] 1751e5c31af7Sopenharmony_ci== Shading Rate Image 1752e5c31af7Sopenharmony_ci 1753e5c31af7Sopenharmony_ciThe <<features-shadingRateImage, pname:shadingRateImage>> feature allows 1754e5c31af7Sopenharmony_cipipelines to use a <<glossary-shading-rate-image,shading rate image>> to 1755e5c31af7Sopenharmony_cicontrol the <<glossary-fragment-area, fragment area>> and the minimum number 1756e5c31af7Sopenharmony_ciof fragment shader invocations launched for each fragment. 1757e5c31af7Sopenharmony_ciWhen the shading rate image is enabled, the rasterizer determines a base 1758e5c31af7Sopenharmony_ci<<glossary-shading-rate,shading rate>> for each region of the framebuffer 1759e5c31af7Sopenharmony_cicovered by a primitive by fetching a value from the shading rate image and 1760e5c31af7Sopenharmony_citranslating it to a shading rate using a per-viewport shading rate palette. 1761e5c31af7Sopenharmony_ciThis base shading rate is then adjusted to derive a final shading rate. 1762e5c31af7Sopenharmony_ciThe final shading rate specifies the fragment area and fragment shader 1763e5c31af7Sopenharmony_ciinvocation count to use for fragments generated in the region. 1764e5c31af7Sopenharmony_ci 1765e5c31af7Sopenharmony_ci[open,refpage='VkPipelineViewportShadingRateImageStateCreateInfoNV',desc='Structure specifying parameters controlling shading rate image usage',type='structs'] 1766e5c31af7Sopenharmony_ci-- 1767e5c31af7Sopenharmony_ciIf the pname:pNext chain of slink:VkPipelineViewportStateCreateInfo includes 1768e5c31af7Sopenharmony_cia sname:VkPipelineViewportShadingRateImageStateCreateInfoNV structure, then 1769e5c31af7Sopenharmony_cithat structure includes parameters controlling the shading rate. 1770e5c31af7Sopenharmony_ci 1771e5c31af7Sopenharmony_ciThe sname:VkPipelineViewportShadingRateImageStateCreateInfoNV structure is 1772e5c31af7Sopenharmony_cidefined as: 1773e5c31af7Sopenharmony_ci 1774e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkPipelineViewportShadingRateImageStateCreateInfoNV.adoc[] 1775e5c31af7Sopenharmony_ci 1776e5c31af7Sopenharmony_ci * pname:sType is a elink:VkStructureType value identifying this structure. 1777e5c31af7Sopenharmony_ci * pname:pNext is `NULL` or a pointer to a structure extending this 1778e5c31af7Sopenharmony_ci structure. 1779e5c31af7Sopenharmony_ci * pname:shadingRateImageEnable specifies whether shading rate image and 1780e5c31af7Sopenharmony_ci palettes are used during rasterization. 1781e5c31af7Sopenharmony_ci * pname:viewportCount specifies the number of per-viewport palettes used 1782e5c31af7Sopenharmony_ci to translate values stored in shading rate images. 1783e5c31af7Sopenharmony_ci * pname:pShadingRatePalettes is a pointer to an array of 1784e5c31af7Sopenharmony_ci slink:VkShadingRatePaletteNV structures defining the palette for each 1785e5c31af7Sopenharmony_ci viewport. 1786e5c31af7Sopenharmony_ci If the shading rate palette state is dynamic, this member is ignored. 1787e5c31af7Sopenharmony_ci 1788e5c31af7Sopenharmony_ciIf this structure is not present, pname:shadingRateImageEnable is considered 1789e5c31af7Sopenharmony_cito be ename:VK_FALSE, and the shading rate image and palettes are not used. 1790e5c31af7Sopenharmony_ci 1791e5c31af7Sopenharmony_ci.Valid Usage 1792e5c31af7Sopenharmony_ci**** 1793e5c31af7Sopenharmony_ci * [[VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054]] 1794e5c31af7Sopenharmony_ci If the <<features-multiViewport, pname:multiViewport>> feature is not 1795e5c31af7Sopenharmony_ci enabled, pname:viewportCount must: be `0` or `1` 1796e5c31af7Sopenharmony_ci * [[VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055]] 1797e5c31af7Sopenharmony_ci pname:viewportCount must: be less than or equal to 1798e5c31af7Sopenharmony_ci sname:VkPhysicalDeviceLimits::pname:maxViewports 1799e5c31af7Sopenharmony_ci * [[VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056]] 1800e5c31af7Sopenharmony_ci If pname:shadingRateImageEnable is ename:VK_TRUE, pname:viewportCount 1801e5c31af7Sopenharmony_ci must: be greater or equal to the pname:viewportCount member of 1802e5c31af7Sopenharmony_ci slink:VkPipelineViewportStateCreateInfo 1803e5c31af7Sopenharmony_ci**** 1804e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkPipelineViewportShadingRateImageStateCreateInfoNV.adoc[] 1805e5c31af7Sopenharmony_ci-- 1806e5c31af7Sopenharmony_ci 1807e5c31af7Sopenharmony_ci[open,refpage='vkCmdBindShadingRateImageNV',desc='Bind a shading rate image on a command buffer',type='protos'] 1808e5c31af7Sopenharmony_ci-- 1809e5c31af7Sopenharmony_ciWhen shading rate image usage is enabled in the bound pipeline, the pipeline 1810e5c31af7Sopenharmony_ciuses a shading rate image specified by the command: 1811e5c31af7Sopenharmony_ci 1812e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCmdBindShadingRateImageNV.adoc[] 1813e5c31af7Sopenharmony_ci 1814e5c31af7Sopenharmony_ci * pname:commandBuffer is the command buffer into which the command will be 1815e5c31af7Sopenharmony_ci recorded. 1816e5c31af7Sopenharmony_ci * pname:imageView is an image view handle specifying the shading rate 1817e5c31af7Sopenharmony_ci image. 1818e5c31af7Sopenharmony_ci pname:imageView may: be set to dlink:VK_NULL_HANDLE, which is equivalent 1819e5c31af7Sopenharmony_ci to specifying a view of an image filled with zero values. 1820e5c31af7Sopenharmony_ci * pname:imageLayout is the layout that the image subresources accessible 1821e5c31af7Sopenharmony_ci from pname:imageView will be in when the shading rate image is accessed. 1822e5c31af7Sopenharmony_ci 1823e5c31af7Sopenharmony_ci.Valid Usage 1824e5c31af7Sopenharmony_ci**** 1825e5c31af7Sopenharmony_ci * [[VUID-vkCmdBindShadingRateImageNV-None-02058]] 1826e5c31af7Sopenharmony_ci The <<features-shadingRateImage, pname:shadingRateImage>> feature must: 1827e5c31af7Sopenharmony_ci be enabled 1828e5c31af7Sopenharmony_ci * [[VUID-vkCmdBindShadingRateImageNV-imageView-02059]] 1829e5c31af7Sopenharmony_ci If pname:imageView is not dlink:VK_NULL_HANDLE, it must: be a valid 1830e5c31af7Sopenharmony_ci slink:VkImageView handle of type ename:VK_IMAGE_VIEW_TYPE_2D or 1831e5c31af7Sopenharmony_ci ename:VK_IMAGE_VIEW_TYPE_2D_ARRAY 1832e5c31af7Sopenharmony_ci * [[VUID-vkCmdBindShadingRateImageNV-imageView-02060]] 1833e5c31af7Sopenharmony_ci If pname:imageView is not dlink:VK_NULL_HANDLE, it must: have a format 1834e5c31af7Sopenharmony_ci of ename:VK_FORMAT_R8_UINT 1835e5c31af7Sopenharmony_ci * [[VUID-vkCmdBindShadingRateImageNV-imageView-02061]] 1836e5c31af7Sopenharmony_ci If pname:imageView is not dlink:VK_NULL_HANDLE, it must: have been 1837e5c31af7Sopenharmony_ci created with a pname:usage value including 1838e5c31af7Sopenharmony_ci ename:VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV 1839e5c31af7Sopenharmony_ci * [[VUID-vkCmdBindShadingRateImageNV-imageView-02062]] 1840e5c31af7Sopenharmony_ci If pname:imageView is not dlink:VK_NULL_HANDLE, pname:imageLayout must: 1841e5c31af7Sopenharmony_ci match the actual elink:VkImageLayout of each subresource accessible from 1842e5c31af7Sopenharmony_ci pname:imageView at the time the subresource is accessed 1843e5c31af7Sopenharmony_ci * [[VUID-vkCmdBindShadingRateImageNV-imageLayout-02063]] 1844e5c31af7Sopenharmony_ci If pname:imageView is not dlink:VK_NULL_HANDLE, pname:imageLayout must: 1845e5c31af7Sopenharmony_ci be ename:VK_IMAGE_LAYOUT_SHADING_RATE_OPTIMAL_NV or 1846e5c31af7Sopenharmony_ci ename:VK_IMAGE_LAYOUT_GENERAL 1847e5c31af7Sopenharmony_ci**** 1848e5c31af7Sopenharmony_ci 1849e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkCmdBindShadingRateImageNV.adoc[] 1850e5c31af7Sopenharmony_ci-- 1851e5c31af7Sopenharmony_ci 1852e5c31af7Sopenharmony_ciWhen the shading rate image is enabled in the current pipeline, rasterizing 1853e5c31af7Sopenharmony_cia primitive covering the pixel with coordinates (_x_,_y_) will fetch a 1854e5c31af7Sopenharmony_cishading rate index value from the shading rate image bound by 1855e5c31af7Sopenharmony_cifname:vkCmdBindShadingRateImageNV. 1856e5c31af7Sopenharmony_ciIf the shading rate image view has a type of ename:VK_IMAGE_VIEW_TYPE_2D, 1857e5c31af7Sopenharmony_cithe lookup will use texel coordinates (_u_,_v_) where latexmath:[u = 1858e5c31af7Sopenharmony_ci\left\lfloor \frac{x}{twidth} \right\rfloor], latexmath:[v = \left\lfloor 1859e5c31af7Sopenharmony_ci\frac{y}{theight} \right\rfloor], and latexmath:[twidth] and 1860e5c31af7Sopenharmony_cilatexmath:[theight] are the width and height of the implementation-dependent 1861e5c31af7Sopenharmony_ci<<limits-shadingRateTexelSize, shading rate texel size>>. 1862e5c31af7Sopenharmony_ciIf the shading rate image view has a type of 1863e5c31af7Sopenharmony_ciename:VK_IMAGE_VIEW_TYPE_2D_ARRAY, the lookup will use texel coordinates 1864e5c31af7Sopenharmony_ci(_u_,_v_) to extract a texel from the layer _l_, where _l_ is the layer of 1865e5c31af7Sopenharmony_cithe framebuffer being rendered to. 1866e5c31af7Sopenharmony_ciIf _l_ is greater than or equal to the number of layers in the image view, 1867e5c31af7Sopenharmony_cilayer zero will be used. 1868e5c31af7Sopenharmony_ci 1869e5c31af7Sopenharmony_ciIf the bound shading rate image view is not dlink:VK_NULL_HANDLE and 1870e5c31af7Sopenharmony_cicontains a texel with coordinates (_u_,_v_) in layer _l_ (if applicable), 1871e5c31af7Sopenharmony_cithe single unsigned integer component for that texel will be used as the 1872e5c31af7Sopenharmony_cishading rate index. 1873e5c31af7Sopenharmony_ciIf the (_u_,_v_) coordinate is outside the extents of the subresource used 1874e5c31af7Sopenharmony_ciby the shading rate image view, or if the image view is 1875e5c31af7Sopenharmony_cidlink:VK_NULL_HANDLE, the shading rate index is zero. 1876e5c31af7Sopenharmony_ciIf the shading rate image view has multiple mipmap levels, the base level 1877e5c31af7Sopenharmony_ciidentified by sname:VkImageSubresourceRange::pname:baseMipLevel will be 1878e5c31af7Sopenharmony_ciused. 1879e5c31af7Sopenharmony_ci 1880e5c31af7Sopenharmony_ciA shading rate index is mapped to a base shading rate using a lookup table 1881e5c31af7Sopenharmony_cicalled the shading rate image palette. 1882e5c31af7Sopenharmony_ciThere is a separate palette for each viewport. 1883e5c31af7Sopenharmony_ciThe number of entries in each palette is given by the 1884e5c31af7Sopenharmony_ciimplementation-dependent <<limits-shadingRatePaletteSize, shading rate image 1885e5c31af7Sopenharmony_cipalette size>>. 1886e5c31af7Sopenharmony_ci 1887e5c31af7Sopenharmony_ciifdef::VK_EXT_extended_dynamic_state3,VK_EXT_shader_object[] 1888e5c31af7Sopenharmony_ci[open,refpage='vkCmdSetShadingRateImageEnableNV',desc='Specify the shading rate image enable state dynamically for a command buffer',type='protos'] 1889e5c31af7Sopenharmony_ci-- 1890e5c31af7Sopenharmony_ciTo <<pipelines-dynamic-state, dynamically set>> the 1891e5c31af7Sopenharmony_cipname:shadingRateImageEnable state, call: 1892e5c31af7Sopenharmony_ci 1893e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCmdSetShadingRateImageEnableNV.adoc[] 1894e5c31af7Sopenharmony_ci 1895e5c31af7Sopenharmony_ci * pname:commandBuffer is the command buffer into which the command will be 1896e5c31af7Sopenharmony_ci recorded. 1897e5c31af7Sopenharmony_ci * pname:shadingRateImageEnable specifies the pname:shadingRateImageEnable 1898e5c31af7Sopenharmony_ci state. 1899e5c31af7Sopenharmony_ci 1900e5c31af7Sopenharmony_ciThis command sets the pname:shadingRateImageEnable state for subsequent 1901e5c31af7Sopenharmony_cidrawing commands 1902e5c31af7Sopenharmony_ciifdef::VK_EXT_shader_object[] 1903e5c31af7Sopenharmony_ciifdef::VK_EXT_extended_dynamic_state3[when drawing using <<shaders-objects, shader objects>>, or] 1904e5c31af7Sopenharmony_ciifndef::VK_EXT_extended_dynamic_state3[when drawing using <<shaders-objects, shader objects>>.] 1905e5c31af7Sopenharmony_ciendif::VK_EXT_shader_object[] 1906e5c31af7Sopenharmony_ciifdef::VK_EXT_extended_dynamic_state3[] 1907e5c31af7Sopenharmony_ciwhen the graphics pipeline is created with 1908e5c31af7Sopenharmony_ciename:VK_DYNAMIC_STATE_SHADING_RATE_IMAGE_ENABLE_NV set in 1909e5c31af7Sopenharmony_cislink:VkPipelineDynamicStateCreateInfo::pname:pDynamicStates. 1910e5c31af7Sopenharmony_ciendif::VK_EXT_extended_dynamic_state3[] 1911e5c31af7Sopenharmony_ciOtherwise, this state is specified by the 1912e5c31af7Sopenharmony_cislink:VkPipelineViewportShadingRateImageStateCreateInfoNV::pname:shadingRateImageEnable 1913e5c31af7Sopenharmony_civalue used to create the currently active pipeline. 1914e5c31af7Sopenharmony_ci 1915e5c31af7Sopenharmony_ci:refpage: vkCmdSetShadingRateImageEnableNV 1916e5c31af7Sopenharmony_ci:requiredfeature: extendedDynamicState3ShadingRateImageEnable 1917e5c31af7Sopenharmony_ci 1918e5c31af7Sopenharmony_ci.Valid Usage 1919e5c31af7Sopenharmony_ci**** 1920e5c31af7Sopenharmony_ciinclude::{chapters}/commonvalidity/dynamic_state3_feature_common.adoc[] 1921e5c31af7Sopenharmony_ci**** 1922e5c31af7Sopenharmony_ci 1923e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkCmdSetShadingRateImageEnableNV.adoc[] 1924e5c31af7Sopenharmony_ci-- 1925e5c31af7Sopenharmony_ciendif::VK_EXT_extended_dynamic_state3,VK_EXT_shader_object[] 1926e5c31af7Sopenharmony_ci 1927e5c31af7Sopenharmony_ci[open,refpage='vkCmdSetViewportShadingRatePaletteNV',desc='Set shading rate image palettes dynamically for a command buffer',type='protos'] 1928e5c31af7Sopenharmony_ci-- 1929e5c31af7Sopenharmony_ciTo <<pipelines-dynamic-state, dynamically set>> the per-viewport shading 1930e5c31af7Sopenharmony_cirate image palettes, call: 1931e5c31af7Sopenharmony_ci 1932e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCmdSetViewportShadingRatePaletteNV.adoc[] 1933e5c31af7Sopenharmony_ci 1934e5c31af7Sopenharmony_ci * pname:commandBuffer is the command buffer into which the command will be 1935e5c31af7Sopenharmony_ci recorded. 1936e5c31af7Sopenharmony_ci * pname:firstViewport is the index of the first viewport whose shading 1937e5c31af7Sopenharmony_ci rate palette is updated by the command. 1938e5c31af7Sopenharmony_ci * pname:viewportCount is the number of viewports whose shading rate 1939e5c31af7Sopenharmony_ci palettes are updated by the command. 1940e5c31af7Sopenharmony_ci * pname:pShadingRatePalettes is a pointer to an array of 1941e5c31af7Sopenharmony_ci slink:VkShadingRatePaletteNV structures defining the palette for each 1942e5c31af7Sopenharmony_ci viewport. 1943e5c31af7Sopenharmony_ci 1944e5c31af7Sopenharmony_ciThis command sets the per-viewport shading rate image palettes for 1945e5c31af7Sopenharmony_cisubsequent drawing commands 1946e5c31af7Sopenharmony_ciifdef::VK_EXT_shader_object[when drawing using <<shaders-objects, shader objects>>, or] 1947e5c31af7Sopenharmony_ciwhen the graphics pipeline is created with 1948e5c31af7Sopenharmony_ciename:VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV set in 1949e5c31af7Sopenharmony_cislink:VkPipelineDynamicStateCreateInfo::pname:pDynamicStates. 1950e5c31af7Sopenharmony_ciOtherwise, this state is specified by the 1951e5c31af7Sopenharmony_cislink:VkPipelineViewportShadingRateImageStateCreateInfoNV::pname:pShadingRatePalettes 1952e5c31af7Sopenharmony_civalues used to create the currently active pipeline. 1953e5c31af7Sopenharmony_ci 1954e5c31af7Sopenharmony_ci.Valid Usage 1955e5c31af7Sopenharmony_ci**** 1956e5c31af7Sopenharmony_ci * [[VUID-vkCmdSetViewportShadingRatePaletteNV-None-02064]] 1957e5c31af7Sopenharmony_ci The <<features-shadingRateImage, pname:shadingRateImage>> feature must: 1958e5c31af7Sopenharmony_ci be enabled 1959e5c31af7Sopenharmony_ci * [[VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067]] 1960e5c31af7Sopenharmony_ci The sum of pname:firstViewport and pname:viewportCount must: be between 1961e5c31af7Sopenharmony_ci `1` and sname:VkPhysicalDeviceLimits::pname:maxViewports, inclusive 1962e5c31af7Sopenharmony_ci * [[VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068]] 1963e5c31af7Sopenharmony_ci If the <<features-multiViewport, pname:multiViewport>> feature is not 1964e5c31af7Sopenharmony_ci enabled, pname:firstViewport must: be `0` 1965e5c31af7Sopenharmony_ci * [[VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069]] 1966e5c31af7Sopenharmony_ci If the <<features-multiViewport, pname:multiViewport>> feature is not 1967e5c31af7Sopenharmony_ci enabled, pname:viewportCount must: be `1` 1968e5c31af7Sopenharmony_ci**** 1969e5c31af7Sopenharmony_ci 1970e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkCmdSetViewportShadingRatePaletteNV.adoc[] 1971e5c31af7Sopenharmony_ci-- 1972e5c31af7Sopenharmony_ci 1973e5c31af7Sopenharmony_ci[open,refpage='VkShadingRatePaletteNV',desc='Structure specifying a single shading rate palette',type='structs'] 1974e5c31af7Sopenharmony_ci-- 1975e5c31af7Sopenharmony_ciThe sname:VkShadingRatePaletteNV structure specifies to contents of a single 1976e5c31af7Sopenharmony_cishading rate image palette and is defined as: 1977e5c31af7Sopenharmony_ci 1978e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkShadingRatePaletteNV.adoc[] 1979e5c31af7Sopenharmony_ci 1980e5c31af7Sopenharmony_ci * pname:shadingRatePaletteEntryCount specifies the number of entries in 1981e5c31af7Sopenharmony_ci the shading rate image palette. 1982e5c31af7Sopenharmony_ci * pname:pShadingRatePaletteEntries is a pointer to an array of 1983e5c31af7Sopenharmony_ci elink:VkShadingRatePaletteEntryNV enums defining the shading rate for 1984e5c31af7Sopenharmony_ci each palette entry. 1985e5c31af7Sopenharmony_ci 1986e5c31af7Sopenharmony_ci.Valid Usage 1987e5c31af7Sopenharmony_ci**** 1988e5c31af7Sopenharmony_ci * [[VUID-VkShadingRatePaletteNV-shadingRatePaletteEntryCount-02071]] 1989e5c31af7Sopenharmony_ci pname:shadingRatePaletteEntryCount must: be between `1` and 1990e5c31af7Sopenharmony_ci sname:VkPhysicalDeviceShadingRateImagePropertiesNV::pname:shadingRatePaletteSize, 1991e5c31af7Sopenharmony_ci inclusive 1992e5c31af7Sopenharmony_ci 1993e5c31af7Sopenharmony_ci**** 1994e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkShadingRatePaletteNV.adoc[] 1995e5c31af7Sopenharmony_ci-- 1996e5c31af7Sopenharmony_ci 1997e5c31af7Sopenharmony_ciTo determine the base shading rate image, a shading rate index _i_ is mapped 1998e5c31af7Sopenharmony_cito array element _i_ in the array pname:pShadingRatePaletteEntries for the 1999e5c31af7Sopenharmony_cipalette corresponding to the viewport used for the fragment. 2000e5c31af7Sopenharmony_ciIf _i_ is greater than or equal to the palette size 2001e5c31af7Sopenharmony_cipname:shadingRatePaletteEntryCount, the base shading rate is undefined:. 2002e5c31af7Sopenharmony_ci 2003e5c31af7Sopenharmony_ci[open,refpage='VkShadingRatePaletteEntryNV',desc='Shading rate image palette entry types',type='enums'] 2004e5c31af7Sopenharmony_ci-- 2005e5c31af7Sopenharmony_ciThe supported shading rate image palette entries are defined by 2006e5c31af7Sopenharmony_cielink:VkShadingRatePaletteEntryNV: 2007e5c31af7Sopenharmony_ci 2008e5c31af7Sopenharmony_ciinclude::{generated}/api/enums/VkShadingRatePaletteEntryNV.adoc[] 2009e5c31af7Sopenharmony_ci 2010e5c31af7Sopenharmony_ciThe following table indicates the width and height (in pixels) of each 2011e5c31af7Sopenharmony_cifragment generated using the indicated shading rate, as well as the maximum 2012e5c31af7Sopenharmony_cinumber of fragment shader invocations launched for each fragment. 2013e5c31af7Sopenharmony_ciWhen processing regions of a primitive that have a shading rate of 2014e5c31af7Sopenharmony_ciename:VK_SHADING_RATE_PALETTE_ENTRY_NO_INVOCATIONS_NV, no fragments will be 2015e5c31af7Sopenharmony_cigenerated in that region. 2016e5c31af7Sopenharmony_ci 2017e5c31af7Sopenharmony_ci[options="header"] 2018e5c31af7Sopenharmony_ci|==== 2019e5c31af7Sopenharmony_ci| Shading Rate | Width | Height | Invocations 2020e5c31af7Sopenharmony_ci| ename:VK_SHADING_RATE_PALETTE_ENTRY_NO_INVOCATIONS_NV | 0 | 0 | 0 2021e5c31af7Sopenharmony_ci| ename:VK_SHADING_RATE_PALETTE_ENTRY_16_INVOCATIONS_PER_PIXEL_NV | 1 | 1 | 16 2022e5c31af7Sopenharmony_ci| ename:VK_SHADING_RATE_PALETTE_ENTRY_8_INVOCATIONS_PER_PIXEL_NV | 1 | 1 | 8 2023e5c31af7Sopenharmony_ci| ename:VK_SHADING_RATE_PALETTE_ENTRY_4_INVOCATIONS_PER_PIXEL_NV | 1 | 1 | 4 2024e5c31af7Sopenharmony_ci| ename:VK_SHADING_RATE_PALETTE_ENTRY_2_INVOCATIONS_PER_PIXEL_NV | 1 | 1 | 2 2025e5c31af7Sopenharmony_ci| ename:VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_PIXEL_NV | 1 | 1 | 1 2026e5c31af7Sopenharmony_ci| ename:VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV | 2 | 1 | 1 2027e5c31af7Sopenharmony_ci| ename:VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV | 1 | 2 | 1 2028e5c31af7Sopenharmony_ci| ename:VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV | 2 | 2 | 1 2029e5c31af7Sopenharmony_ci| ename:VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV | 4 | 2 | 1 2030e5c31af7Sopenharmony_ci| ename:VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV | 2 | 4 | 1 2031e5c31af7Sopenharmony_ci| ename:VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV | 4 | 4 | 1 2032e5c31af7Sopenharmony_ci|==== 2033e5c31af7Sopenharmony_ci-- 2034e5c31af7Sopenharmony_ci 2035e5c31af7Sopenharmony_ciWhen the shading rate image is disabled, a shading rate of 2036e5c31af7Sopenharmony_ciename:VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_PIXEL_NV will be used 2037e5c31af7Sopenharmony_cias the base shading rate. 2038e5c31af7Sopenharmony_ci 2039e5c31af7Sopenharmony_ciOnce a base shading rate has been established, it is adjusted to produce a 2040e5c31af7Sopenharmony_cifinal shading rate. 2041e5c31af7Sopenharmony_ciFirst, if the base shading rate uses multiple pixels for each fragment, the 2042e5c31af7Sopenharmony_ciimplementation may: reduce the fragment area to ensure that the total number 2043e5c31af7Sopenharmony_ciof coverage samples for all pixels in a fragment does not exceed 2044e5c31af7Sopenharmony_ci<<limits-shadingRateMaxCoarseSamples, an implementation-dependent maximum>>. 2045e5c31af7Sopenharmony_ci 2046e5c31af7Sopenharmony_ciIf <<primsrast-sampleshading, sample shading>> is active in the current 2047e5c31af7Sopenharmony_cipipeline and would result in processing _n_ (_n_ > 1) unique samples per 2048e5c31af7Sopenharmony_cifragment when the shading rate image is disabled, the shading rate is 2049e5c31af7Sopenharmony_ciadjusted in an implementation-dependent manner to increase the number of 2050e5c31af7Sopenharmony_cifragment shader invocations spawned by the primitive. 2051e5c31af7Sopenharmony_ciIf the shading rate indicates _fs_ pixels per fragment and _fs_ is greater 2052e5c31af7Sopenharmony_cithan _n_, the fragment area is adjusted so each fragment has approximately 2053e5c31af7Sopenharmony_cilatexmath:[fs \over n] pixels. 2054e5c31af7Sopenharmony_ciOtherwise, if the shading rate indicates _ipf_ invocations per fragment, the 2055e5c31af7Sopenharmony_cifragment area will be adjusted to a single pixel with approximately 2056e5c31af7Sopenharmony_cilatexmath:[ipf \times n \over fs] invocations per fragment. 2057e5c31af7Sopenharmony_ci 2058e5c31af7Sopenharmony_ciIf sample shading occurs due to the use of a fragment shader input variable 2059e5c31af7Sopenharmony_cidecorated with code:SampleId or code:SamplePosition, the shading rate is 2060e5c31af7Sopenharmony_ciignored. 2061e5c31af7Sopenharmony_ciEach fragment will have a single pixel and will spawn up to 2062e5c31af7Sopenharmony_cipname:rasterizationSamples fragment shader invocations, as when using 2063e5c31af7Sopenharmony_ci<<primsrast-sampleshading, sample shading>> without a shading rate image. 2064e5c31af7Sopenharmony_ci 2065e5c31af7Sopenharmony_ciFinally, if the shading rate specifies multiple fragment shader invocations 2066e5c31af7Sopenharmony_ciper fragment, the total number of invocations in the shading rate is clamped 2067e5c31af7Sopenharmony_cito be no larger than pname:rasterizationSamples. 2068e5c31af7Sopenharmony_ci 2069e5c31af7Sopenharmony_ciWhen the final shading rate for a primitive covering pixel (_x_,_y_) has a 2070e5c31af7Sopenharmony_cifragment area of latexmath:[fw \times fh], the fragment for that pixel will 2071e5c31af7Sopenharmony_cicover all pixels with coordinates (_x_',_y_') that satisfy the equations: 2072e5c31af7Sopenharmony_ci 2073e5c31af7Sopenharmony_ci[latexmath] 2074e5c31af7Sopenharmony_ci+++++++++++++++++++ 2075e5c31af7Sopenharmony_ci\begin{aligned} 2076e5c31af7Sopenharmony_ci\left\lfloor \frac{x}{fw} \right\rfloor = \left\lfloor \frac{x'}{fw} \right\rfloor 2077e5c31af7Sopenharmony_ci\end{aligned} 2078e5c31af7Sopenharmony_ci+++++++++++++++++++ 2079e5c31af7Sopenharmony_ci[latexmath] 2080e5c31af7Sopenharmony_ci+++++++++++++++++++ 2081e5c31af7Sopenharmony_ci\begin{aligned} 2082e5c31af7Sopenharmony_ci\left\lfloor \frac{y}{fh} \right\rfloor = \left\lfloor \frac{y'}{fh} \right\rfloor 2083e5c31af7Sopenharmony_ci\end{aligned} 2084e5c31af7Sopenharmony_ci+++++++++++++++++++ 2085e5c31af7Sopenharmony_ci 2086e5c31af7Sopenharmony_ciThis combined fragment is considered to have multiple coverage samples; the 2087e5c31af7Sopenharmony_citotal number of samples in this fragment is given by latexmath:[samples = fw 2088e5c31af7Sopenharmony_ci\times fh \times rs] where _rs_ indicates the value of 2089e5c31af7Sopenharmony_cisname:VkPipelineMultisampleStateCreateInfo::pname:rasterizationSamples 2090e5c31af7Sopenharmony_cispecified at pipeline creation time. 2091e5c31af7Sopenharmony_ciThe set of coverage samples in the fragment is the union of the per-pixel 2092e5c31af7Sopenharmony_cicoverage samples in each of the fragment's pixels The location and order of 2093e5c31af7Sopenharmony_cicoverage samples within each pixel in the combined fragment are assigned as 2094e5c31af7Sopenharmony_cidescribed in 2095e5c31af7Sopenharmony_ciifndef::VK_EXT_sample_locations[] 2096e5c31af7Sopenharmony_ci<<primsrast-multisampling, Multisampling>>. 2097e5c31af7Sopenharmony_ciendif::VK_EXT_sample_locations[] 2098e5c31af7Sopenharmony_ciifdef::VK_EXT_sample_locations[] 2099e5c31af7Sopenharmony_ci<<primsrast-multisampling, Multisampling>> and <<primsrast-samplelocations, 2100e5c31af7Sopenharmony_ciCustom Sample Locations>>. 2101e5c31af7Sopenharmony_ciendif::VK_EXT_sample_locations[] 2102e5c31af7Sopenharmony_ciEach coverage sample in the set of pixels belonging to the combined fragment 2103e5c31af7Sopenharmony_ciis assigned a unique <<primsrast-multisampling-coverage-mask, coverage 2104e5c31af7Sopenharmony_ciindex>> in the range [0,_samples_-1]. 2105e5c31af7Sopenharmony_ciIf the <<features-shadingRateCoarseSampleOrder, 2106e5c31af7Sopenharmony_cipname:shadingRateCoarseSampleOrder>> feature is supported, the order of 2107e5c31af7Sopenharmony_cicoverage samples can: be specified for each combination of fragment area and 2108e5c31af7Sopenharmony_cicoverage sample count. 2109e5c31af7Sopenharmony_ciIf this feature is not supported, the sample order is 2110e5c31af7Sopenharmony_ciimplementation-dependent. 2111e5c31af7Sopenharmony_ci 2112e5c31af7Sopenharmony_ci[open,refpage='VkPipelineViewportCoarseSampleOrderStateCreateInfoNV',desc='Structure specifying parameters controlling sample order in coarse fragments',type='structs'] 2113e5c31af7Sopenharmony_ci-- 2114e5c31af7Sopenharmony_ciIf the pname:pNext chain of slink:VkPipelineViewportStateCreateInfo includes 2115e5c31af7Sopenharmony_cia sname:VkPipelineViewportCoarseSampleOrderStateCreateInfoNV structure, then 2116e5c31af7Sopenharmony_cithat structure includes parameters controlling the order of coverage samples 2117e5c31af7Sopenharmony_ciin fragments larger than one pixel. 2118e5c31af7Sopenharmony_ci 2119e5c31af7Sopenharmony_ciThe sname:VkPipelineViewportCoarseSampleOrderStateCreateInfoNV structure is 2120e5c31af7Sopenharmony_cidefined as: 2121e5c31af7Sopenharmony_ci 2122e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkPipelineViewportCoarseSampleOrderStateCreateInfoNV.adoc[] 2123e5c31af7Sopenharmony_ci 2124e5c31af7Sopenharmony_ci * pname:sType is a elink:VkStructureType value identifying this structure. 2125e5c31af7Sopenharmony_ci * pname:pNext is `NULL` or a pointer to a structure extending this 2126e5c31af7Sopenharmony_ci structure. 2127e5c31af7Sopenharmony_ci * pname:sampleOrderType specifies the mechanism used to order coverage 2128e5c31af7Sopenharmony_ci samples in fragments larger than one pixel. 2129e5c31af7Sopenharmony_ci * pname:customSampleOrderCount specifies the number of custom sample 2130e5c31af7Sopenharmony_ci orderings to use when ordering coverage samples. 2131e5c31af7Sopenharmony_ci * pname:pCustomSampleOrders is a pointer to an array of 2132e5c31af7Sopenharmony_ci pname:customSampleOrderCount slink:VkCoarseSampleOrderCustomNV 2133e5c31af7Sopenharmony_ci structures, each structure specifying the coverage sample order for a 2134e5c31af7Sopenharmony_ci single combination of fragment area and coverage sample count. 2135e5c31af7Sopenharmony_ci 2136e5c31af7Sopenharmony_ciIf this structure is not present, pname:sampleOrderType is considered to be 2137e5c31af7Sopenharmony_ciename:VK_COARSE_SAMPLE_ORDER_TYPE_DEFAULT_NV. 2138e5c31af7Sopenharmony_ci 2139e5c31af7Sopenharmony_ciIf pname:sampleOrderType is ename:VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, the 2140e5c31af7Sopenharmony_cicoverage sample order used for any combination of fragment area and coverage 2141e5c31af7Sopenharmony_cisample count not enumerated in pname:pCustomSampleOrders will be identical 2142e5c31af7Sopenharmony_cito that used for ename:VK_COARSE_SAMPLE_ORDER_TYPE_DEFAULT_NV. 2143e5c31af7Sopenharmony_ci 2144e5c31af7Sopenharmony_ciIf the pipeline was created with 2145e5c31af7Sopenharmony_ciename:VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV, the contents of this 2146e5c31af7Sopenharmony_cistructure (if present) are ignored, and the coverage sample order is instead 2147e5c31af7Sopenharmony_cispecified by flink:vkCmdSetCoarseSampleOrderNV. 2148e5c31af7Sopenharmony_ci 2149e5c31af7Sopenharmony_ci.Valid Usage 2150e5c31af7Sopenharmony_ci**** 2151e5c31af7Sopenharmony_ci * [[VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072]] 2152e5c31af7Sopenharmony_ci If pname:sampleOrderType is not 2153e5c31af7Sopenharmony_ci ename:VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, 2154e5c31af7Sopenharmony_ci pname:customSamplerOrderCount must: be `0` 2155e5c31af7Sopenharmony_ci * [[VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-pCustomSampleOrders-02234]] 2156e5c31af7Sopenharmony_ci The array pname:pCustomSampleOrders must: not contain two structures 2157e5c31af7Sopenharmony_ci with matching values for both the pname:shadingRate and 2158e5c31af7Sopenharmony_ci pname:sampleCount members 2159e5c31af7Sopenharmony_ci**** 2160e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkPipelineViewportCoarseSampleOrderStateCreateInfoNV.adoc[] 2161e5c31af7Sopenharmony_ci-- 2162e5c31af7Sopenharmony_ci 2163e5c31af7Sopenharmony_ci[open,refpage='VkCoarseSampleOrderTypeNV',desc='Shading rate image sample ordering types',type='enums'] 2164e5c31af7Sopenharmony_ci-- 2165e5c31af7Sopenharmony_ciThe type elink:VkCoarseSampleOrderTypeNV specifies the technique used to 2166e5c31af7Sopenharmony_ciorder coverage samples in fragments larger than one pixel, and is defined 2167e5c31af7Sopenharmony_cias: 2168e5c31af7Sopenharmony_ci 2169e5c31af7Sopenharmony_ciinclude::{generated}/api/enums/VkCoarseSampleOrderTypeNV.adoc[] 2170e5c31af7Sopenharmony_ci 2171e5c31af7Sopenharmony_ci * ename:VK_COARSE_SAMPLE_ORDER_TYPE_DEFAULT_NV specifies that coverage 2172e5c31af7Sopenharmony_ci samples will be ordered in an implementation-dependent manner. 2173e5c31af7Sopenharmony_ci * ename:VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV specifies that coverage 2174e5c31af7Sopenharmony_ci samples will be ordered according to the array of custom orderings 2175e5c31af7Sopenharmony_ci provided in either the pname:pCustomSampleOrders member of 2176e5c31af7Sopenharmony_ci sname:VkPipelineViewportCoarseSampleOrderStateCreateInfoNV or the 2177e5c31af7Sopenharmony_ci pname:pCustomSampleOrders member of flink:vkCmdSetCoarseSampleOrderNV. 2178e5c31af7Sopenharmony_ci * ename:VK_COARSE_SAMPLE_ORDER_TYPE_PIXEL_MAJOR_NV specifies that coverage 2179e5c31af7Sopenharmony_ci samples will be ordered sequentially, sorted first by pixel coordinate 2180e5c31af7Sopenharmony_ci (in row-major order) and then by 2181e5c31af7Sopenharmony_ci <<primsrast-multisampling-coverage-mask, sample index>>. 2182e5c31af7Sopenharmony_ci * ename:VK_COARSE_SAMPLE_ORDER_TYPE_SAMPLE_MAJOR_NV specifies that 2183e5c31af7Sopenharmony_ci coverage samples will be ordered sequentially, sorted first by 2184e5c31af7Sopenharmony_ci <<primsrast-multisampling-coverage-mask, sample index>> and then by 2185e5c31af7Sopenharmony_ci pixel coordinate (in row-major order). 2186e5c31af7Sopenharmony_ci-- 2187e5c31af7Sopenharmony_ci 2188e5c31af7Sopenharmony_ciWhen using a coarse sample order of 2189e5c31af7Sopenharmony_ciename:VK_COARSE_SAMPLE_ORDER_TYPE_PIXEL_MAJOR_NV for a fragment with an 2190e5c31af7Sopenharmony_ciupper-left corner of latexmath:[(fx,fy)] with a width of latexmath:[fw 2191e5c31af7Sopenharmony_ci\times fh] and latexmath:[fsc] samples per pixel, 2192e5c31af7Sopenharmony_ci<<primsrast-multisampling-coverage-mask, coverage index>> latexmath:[cs] of 2193e5c31af7Sopenharmony_cithe fragment will be assigned to <<primsrast-multisampling-coverage-mask, 2194e5c31af7Sopenharmony_cisample index>> latexmath:[fs] of pixel latexmath:[(px,py)] as follows: 2195e5c31af7Sopenharmony_ci 2196e5c31af7Sopenharmony_ci[latexmath] 2197e5c31af7Sopenharmony_ci+++++++++++++++++++ 2198e5c31af7Sopenharmony_ci\begin{aligned} 2199e5c31af7Sopenharmony_cipx = & fx + (\left\lfloor {cs \over fsc} \right\rfloor \text{ \% } fw) \\ 2200e5c31af7Sopenharmony_cipy = & fy + \left\lfloor {cs \over {fsc \times fw}} \right\rfloor \\ 2201e5c31af7Sopenharmony_cifs = & cs \text{ \% } fsc 2202e5c31af7Sopenharmony_ci\end{aligned} 2203e5c31af7Sopenharmony_ci+++++++++++++++++++ 2204e5c31af7Sopenharmony_ci 2205e5c31af7Sopenharmony_ciWhen using a coarse sample order of 2206e5c31af7Sopenharmony_ciename:VK_COARSE_SAMPLE_ORDER_TYPE_SAMPLE_MAJOR_NV, 2207e5c31af7Sopenharmony_ci<<primsrast-multisampling-coverage-mask, coverage index>> latexmath:[cs] 2208e5c31af7Sopenharmony_ciwill be assigned as follows: 2209e5c31af7Sopenharmony_ci 2210e5c31af7Sopenharmony_ci[latexmath] 2211e5c31af7Sopenharmony_ci+++++++++++++++++++ 2212e5c31af7Sopenharmony_ci\begin{aligned} 2213e5c31af7Sopenharmony_cipx = & fx + cs \text{ \% } fw \\ 2214e5c31af7Sopenharmony_cipy = & (fy + \left\lfloor {cs \over fw} \right\rfloor \text{ \% } fh) \\ 2215e5c31af7Sopenharmony_cifs = & \left\lfloor {cs \over {fw \times fh}} \right\rfloor 2216e5c31af7Sopenharmony_ci\end{aligned} 2217e5c31af7Sopenharmony_ci+++++++++++++++++++ 2218e5c31af7Sopenharmony_ci 2219e5c31af7Sopenharmony_ci[open,refpage='VkCoarseSampleOrderCustomNV',desc='Structure specifying parameters controlling shading rate image usage',type='structs'] 2220e5c31af7Sopenharmony_ci-- 2221e5c31af7Sopenharmony_ciThe sname:VkCoarseSampleOrderCustomNV structure is defined as: 2222e5c31af7Sopenharmony_ci 2223e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkCoarseSampleOrderCustomNV.adoc[] 2224e5c31af7Sopenharmony_ci 2225e5c31af7Sopenharmony_ci * pname:shadingRate is a shading rate palette entry that identifies the 2226e5c31af7Sopenharmony_ci fragment width and height for the combination of fragment area and 2227e5c31af7Sopenharmony_ci per-pixel coverage sample count to control. 2228e5c31af7Sopenharmony_ci * pname:sampleCount identifies the per-pixel coverage sample count for the 2229e5c31af7Sopenharmony_ci combination of fragment area and coverage sample count to control. 2230e5c31af7Sopenharmony_ci * pname:sampleLocationCount specifies the number of sample locations in 2231e5c31af7Sopenharmony_ci the custom ordering. 2232e5c31af7Sopenharmony_ci * pname:pSampleLocations is a pointer to an array of 2233e5c31af7Sopenharmony_ci slink:VkCoarseSampleLocationNV structures specifying the location of 2234e5c31af7Sopenharmony_ci each sample in the custom ordering. 2235e5c31af7Sopenharmony_ci 2236e5c31af7Sopenharmony_ciThe sname:VkCoarseSampleOrderCustomNV structure is used with a coverage 2237e5c31af7Sopenharmony_cisample ordering type of ename:VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV to 2238e5c31af7Sopenharmony_cispecify the order of coverage samples for one combination of fragment width, 2239e5c31af7Sopenharmony_cifragment height, and coverage sample count. 2240e5c31af7Sopenharmony_ci 2241e5c31af7Sopenharmony_ciWhen using a custom sample ordering, element _j_ in pname:pSampleLocations 2242e5c31af7Sopenharmony_cispecifies a specific pixel location and 2243e5c31af7Sopenharmony_ci<<primsrast-multisampling-coverage-mask, sample index>> that corresponds to 2244e5c31af7Sopenharmony_ci<<primsrast-multisampling-coverage-mask, coverage index>> _j_ in the 2245e5c31af7Sopenharmony_cimulti-pixel fragment. 2246e5c31af7Sopenharmony_ci 2247e5c31af7Sopenharmony_ci.Valid Usage 2248e5c31af7Sopenharmony_ci**** 2249e5c31af7Sopenharmony_ci * [[VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073]] 2250e5c31af7Sopenharmony_ci pname:shadingRate must: be a shading rate that generates fragments with 2251e5c31af7Sopenharmony_ci more than one pixel 2252e5c31af7Sopenharmony_ci * [[VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074]] 2253e5c31af7Sopenharmony_ci pname:sampleCount must: correspond to a sample count enumerated in 2254e5c31af7Sopenharmony_ci tlink:VkSampleCountFlags whose corresponding bit is set in 2255e5c31af7Sopenharmony_ci slink:VkPhysicalDeviceLimits::pname:framebufferNoAttachmentsSampleCounts 2256e5c31af7Sopenharmony_ci * [[VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075]] 2257e5c31af7Sopenharmony_ci pname:sampleLocationCount must: be equal to the product of 2258e5c31af7Sopenharmony_ci pname:sampleCount, the fragment width for pname:shadingRate, and the 2259e5c31af7Sopenharmony_ci fragment height for pname:shadingRate 2260e5c31af7Sopenharmony_ci * [[VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076]] 2261e5c31af7Sopenharmony_ci pname:sampleLocationCount must: be less than or equal to the value of 2262e5c31af7Sopenharmony_ci sname:VkPhysicalDeviceShadingRateImagePropertiesNV::pname:shadingRateMaxCoarseSamples 2263e5c31af7Sopenharmony_ci * [[VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077]] 2264e5c31af7Sopenharmony_ci The array pname:pSampleLocations must: contain exactly one entry for 2265e5c31af7Sopenharmony_ci every combination of valid values for pname:pixelX, pname:pixelY, and 2266e5c31af7Sopenharmony_ci pname:sample in the structure slink:VkCoarseSampleOrderCustomNV 2267e5c31af7Sopenharmony_ci**** 2268e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkCoarseSampleOrderCustomNV.adoc[] 2269e5c31af7Sopenharmony_ci-- 2270e5c31af7Sopenharmony_ci 2271e5c31af7Sopenharmony_ci[open,refpage='VkCoarseSampleLocationNV',desc='Structure specifying parameters controlling shading rate image usage',type='structs'] 2272e5c31af7Sopenharmony_ci-- 2273e5c31af7Sopenharmony_ciThe sname:VkCoarseSampleLocationNV structure identifies a specific pixel and 2274e5c31af7Sopenharmony_ci<<primsrast-multisampling-coverage-mask, sample index>> for one of the 2275e5c31af7Sopenharmony_cicoverage samples in a fragment that is larger than one pixel. 2276e5c31af7Sopenharmony_ciThis structure is defined as: 2277e5c31af7Sopenharmony_ci 2278e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkCoarseSampleLocationNV.adoc[] 2279e5c31af7Sopenharmony_ci 2280e5c31af7Sopenharmony_ci * pname:pixelX is added to the x coordinate of the upper-leftmost pixel of 2281e5c31af7Sopenharmony_ci each fragment to identify the pixel containing the coverage sample. 2282e5c31af7Sopenharmony_ci * pname:pixelY is added to the y coordinate of the upper-leftmost pixel of 2283e5c31af7Sopenharmony_ci each fragment to identify the pixel containing the coverage sample. 2284e5c31af7Sopenharmony_ci * pname:sample is the number of the coverage sample in the pixel 2285e5c31af7Sopenharmony_ci identified by pname:pixelX and pname:pixelY. 2286e5c31af7Sopenharmony_ci 2287e5c31af7Sopenharmony_ci.Valid Usage 2288e5c31af7Sopenharmony_ci**** 2289e5c31af7Sopenharmony_ci * [[VUID-VkCoarseSampleLocationNV-pixelX-02078]] 2290e5c31af7Sopenharmony_ci pname:pixelX must: be less than the width (in pixels) of the fragment 2291e5c31af7Sopenharmony_ci * [[VUID-VkCoarseSampleLocationNV-pixelY-02079]] 2292e5c31af7Sopenharmony_ci pname:pixelY must: be less than the height (in pixels) of the fragment 2293e5c31af7Sopenharmony_ci * [[VUID-VkCoarseSampleLocationNV-sample-02080]] 2294e5c31af7Sopenharmony_ci pname:sample must: be less than the number of coverage samples in each 2295e5c31af7Sopenharmony_ci pixel belonging to the fragment 2296e5c31af7Sopenharmony_ci**** 2297e5c31af7Sopenharmony_ci 2298e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkCoarseSampleLocationNV.adoc[] 2299e5c31af7Sopenharmony_ci-- 2300e5c31af7Sopenharmony_ci 2301e5c31af7Sopenharmony_ci[open,refpage='vkCmdSetCoarseSampleOrderNV',desc='Set order of coverage samples for coarse fragments dynamically for a command buffer',type='protos'] 2302e5c31af7Sopenharmony_ci-- 2303e5c31af7Sopenharmony_ciTo <<pipelines-dynamic-state, dynamically set>> the order of coverage 2304e5c31af7Sopenharmony_cisamples in fragments larger than one pixel, call: 2305e5c31af7Sopenharmony_ci 2306e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCmdSetCoarseSampleOrderNV.adoc[] 2307e5c31af7Sopenharmony_ci 2308e5c31af7Sopenharmony_ci * pname:commandBuffer is the command buffer into which the command will be 2309e5c31af7Sopenharmony_ci recorded. 2310e5c31af7Sopenharmony_ci * pname:sampleOrderType specifies the mechanism used to order coverage 2311e5c31af7Sopenharmony_ci samples in fragments larger than one pixel. 2312e5c31af7Sopenharmony_ci * pname:customSampleOrderCount specifies the number of custom sample 2313e5c31af7Sopenharmony_ci orderings to use when ordering coverage samples. 2314e5c31af7Sopenharmony_ci * pname:pCustomSampleOrders is a pointer to an array of 2315e5c31af7Sopenharmony_ci slink:VkCoarseSampleOrderCustomNV structures, each structure specifying 2316e5c31af7Sopenharmony_ci the coverage sample order for a single combination of fragment area and 2317e5c31af7Sopenharmony_ci coverage sample count. 2318e5c31af7Sopenharmony_ci 2319e5c31af7Sopenharmony_ciIf pname:sampleOrderType is ename:VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, the 2320e5c31af7Sopenharmony_cicoverage sample order used for any combination of fragment area and coverage 2321e5c31af7Sopenharmony_cisample count not enumerated in pname:pCustomSampleOrders will be identical 2322e5c31af7Sopenharmony_cito that used for ename:VK_COARSE_SAMPLE_ORDER_TYPE_DEFAULT_NV. 2323e5c31af7Sopenharmony_ci 2324e5c31af7Sopenharmony_ciThis command sets the order of coverage samples for subsequent drawing 2325e5c31af7Sopenharmony_cicommands 2326e5c31af7Sopenharmony_ciifdef::VK_EXT_shader_object[when drawing using <<shaders-objects, shader objects>>, or] 2327e5c31af7Sopenharmony_ciwhen the graphics pipeline is created with 2328e5c31af7Sopenharmony_ciename:VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV set in 2329e5c31af7Sopenharmony_cislink:VkPipelineDynamicStateCreateInfo::pname:pDynamicStates. 2330e5c31af7Sopenharmony_ciOtherwise, this state is specified by the 2331e5c31af7Sopenharmony_cislink:VkPipelineViewportCoarseSampleOrderStateCreateInfoNV values used to 2332e5c31af7Sopenharmony_cicreate the currently active pipeline. 2333e5c31af7Sopenharmony_ci 2334e5c31af7Sopenharmony_ci.Valid Usage 2335e5c31af7Sopenharmony_ci**** 2336e5c31af7Sopenharmony_ci * [[VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081]] 2337e5c31af7Sopenharmony_ci If pname:sampleOrderType is not 2338e5c31af7Sopenharmony_ci ename:VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, 2339e5c31af7Sopenharmony_ci pname:customSamplerOrderCount must: be `0` 2340e5c31af7Sopenharmony_ci * [[VUID-vkCmdSetCoarseSampleOrderNV-pCustomSampleOrders-02235]] 2341e5c31af7Sopenharmony_ci The array pname:pCustomSampleOrders must: not contain two structures 2342e5c31af7Sopenharmony_ci with matching values for both the pname:shadingRate and 2343e5c31af7Sopenharmony_ci pname:sampleCount members 2344e5c31af7Sopenharmony_ci**** 2345e5c31af7Sopenharmony_ci 2346e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkCmdSetCoarseSampleOrderNV.adoc[] 2347e5c31af7Sopenharmony_ci-- 2348e5c31af7Sopenharmony_ci 2349e5c31af7Sopenharmony_ciIf the final shading rate for a primitive covering pixel (_x_,_y_) results 2350e5c31af7Sopenharmony_ciin _n_ invocations per pixel (_n_ > 1), _n_ separate fragment shader 2351e5c31af7Sopenharmony_ciinvocations will be generated for the fragment. 2352e5c31af7Sopenharmony_ciEach coverage sample in the fragment will be assigned to one of the _n_ 2353e5c31af7Sopenharmony_cifragment shader invocations in an implementation-dependent manner. 2354e5c31af7Sopenharmony_ciThe outputs from the <<interfaces-fragmentoutput, fragment output 2355e5c31af7Sopenharmony_ciinterface>> of each shader invocation will be broadcast to all of the 2356e5c31af7Sopenharmony_ciframebuffer samples associated with the invocation. 2357e5c31af7Sopenharmony_ciIf none of the coverage samples associated with a fragment shader invocation 2358e5c31af7Sopenharmony_ciis covered by a primitive, the implementation may: discard the fragment 2359e5c31af7Sopenharmony_cishader invocation for those samples. 2360e5c31af7Sopenharmony_ci 2361e5c31af7Sopenharmony_ciIf the final shading rate for a primitive covering pixel (_x_,_y_) results 2362e5c31af7Sopenharmony_ciin a fragment containing multiple pixels, a single set of fragment shader 2363e5c31af7Sopenharmony_ciinvocations will be generated for all pixels in the combined fragment. 2364e5c31af7Sopenharmony_ciOutputs from the <<interfaces-fragmentoutput, fragment output interface>> 2365e5c31af7Sopenharmony_ciwill be broadcast to all covered framebuffer samples belonging to the 2366e5c31af7Sopenharmony_cifragment. 2367e5c31af7Sopenharmony_ciIf the fragment shader executes code discarding the fragment, none of the 2368e5c31af7Sopenharmony_cisamples of the fragment will be updated. 2369e5c31af7Sopenharmony_ci 2370e5c31af7Sopenharmony_ciendif::VK_NV_shading_rate_image[] 2371e5c31af7Sopenharmony_ci 2372e5c31af7Sopenharmony_ci 2373e5c31af7Sopenharmony_ci[[primsrast-sampleshading]] 2374e5c31af7Sopenharmony_ci== Sample Shading 2375e5c31af7Sopenharmony_ci 2376e5c31af7Sopenharmony_ciSample shading can: be used to specify a minimum number of unique samples to 2377e5c31af7Sopenharmony_ciprocess for each fragment. 2378e5c31af7Sopenharmony_ciIf sample shading is enabled, an implementation must: invoke the fragment 2379e5c31af7Sopenharmony_cishader at least [eq]#max({lceil} 2380e5c31af7Sopenharmony_cislink:VkPipelineMultisampleStateCreateInfo::pname:minSampleShading {times} 2381e5c31af7Sopenharmony_cislink:VkPipelineMultisampleStateCreateInfo::pname:rasterizationSamples 2382e5c31af7Sopenharmony_ci{rceil}, 1)# times per fragment. 2383e5c31af7Sopenharmony_ciIf slink:VkPipelineMultisampleStateCreateInfo::pname:sampleShadingEnable is 2384e5c31af7Sopenharmony_ciset to ename:VK_TRUE, sample shading is enabled. 2385e5c31af7Sopenharmony_ci 2386e5c31af7Sopenharmony_ciIf a fragment shader entry point <<shaders-staticuse, statically uses>> an 2387e5c31af7Sopenharmony_ciinput variable decorated with a code:BuiltIn of code:SampleId or 2388e5c31af7Sopenharmony_cicode:SamplePosition, sample shading is enabled and a value of `1.0` is used 2389e5c31af7Sopenharmony_ciinstead of pname:minSampleShading. 2390e5c31af7Sopenharmony_ciIf a fragment shader entry point <<shaders-staticuse, statically uses>> an 2391e5c31af7Sopenharmony_ciinput variable decorated with code:Sample, sample shading may: be enabled 2392e5c31af7Sopenharmony_ciand a value of `1.0` will be used instead of pname:minSampleShading if it 2393e5c31af7Sopenharmony_ciis. 2394e5c31af7Sopenharmony_ciifdef::VK_AMD_mixed_attachment_samples[] 2395e5c31af7Sopenharmony_ciIf the `apiext:VK_AMD_mixed_attachment_samples` extension is enabled and the 2396e5c31af7Sopenharmony_cisubpass uses color attachments, the pname:samples value used to create each 2397e5c31af7Sopenharmony_cicolor attachment is used instead of pname:rasterizationSamples. 2398e5c31af7Sopenharmony_ciendif::VK_AMD_mixed_attachment_samples[] 2399e5c31af7Sopenharmony_ci 2400e5c31af7Sopenharmony_ci[NOTE] 2401e5c31af7Sopenharmony_ci.Note 2402e5c31af7Sopenharmony_ci==== 2403e5c31af7Sopenharmony_ciIf a shader decorates an input variable with code:Sample and that value 2404e5c31af7Sopenharmony_cimeaningfully impacts the output of a shader, sample shading will be enabled 2405e5c31af7Sopenharmony_cito ensure that the input is in fact interpolated per-sample. 2406e5c31af7Sopenharmony_ciThis is inherent to the specification and not spelled out here - if an 2407e5c31af7Sopenharmony_ciapplication simply declares such a variable it is implementation-defined 2408e5c31af7Sopenharmony_ciwhether sample shading is enabled or not. 2409e5c31af7Sopenharmony_ciIt is possible to see the effects of this by using atomics in the shader or 2410e5c31af7Sopenharmony_ciusing a pipeline statistics query to query the number of fragment 2411e5c31af7Sopenharmony_ciinvocations, even if the shader itself does not use any per-sample 2412e5c31af7Sopenharmony_civariables. 2413e5c31af7Sopenharmony_ci==== 2414e5c31af7Sopenharmony_ci 2415e5c31af7Sopenharmony_ciIf there are fewer fragment invocations than <<fragops,covered samples>>, 2416e5c31af7Sopenharmony_ciimplementations may: include those samples in fragment shader invocations in 2417e5c31af7Sopenharmony_ciany manner as long as covered samples are all shaded at least once, and each 2418e5c31af7Sopenharmony_ciinvocation that is not a <<shaders-helper-invocations, helper invocation>> 2419e5c31af7Sopenharmony_cicovers at least one sample. 2420e5c31af7Sopenharmony_ci 2421e5c31af7Sopenharmony_ciifdef::VK_NV_fragment_shader_barycentric,VK_KHR_fragment_shader_barycentric[] 2422e5c31af7Sopenharmony_ci[[primsrast-barycentric]] 2423e5c31af7Sopenharmony_ci== Barycentric Interpolation 2424e5c31af7Sopenharmony_ci 2425e5c31af7Sopenharmony_ciWhen the pname:fragmentShaderBarycentric feature is enabled, the 2426e5c31af7Sopenharmony_cicode:PerVertexKHR <<shaders-interpolation-decorations, interpolation 2427e5c31af7Sopenharmony_cidecoration>> can: be used with fragment shader inputs to indicate that the 2428e5c31af7Sopenharmony_cidecorated inputs do not have associated data in the fragment. 2429e5c31af7Sopenharmony_ciSuch inputs can: only be accessed in a fragment shader using an array index 2430e5c31af7Sopenharmony_ciwhose value (0, 1, or 2) identifies one of the vertices of the primitive 2431e5c31af7Sopenharmony_cithat produced the fragment. 2432e5c31af7Sopenharmony_ciReads of per-vertex values for missing vertices, such as the third vertex of 2433e5c31af7Sopenharmony_cia line primitive, will return values from the valid vertex with the highest 2434e5c31af7Sopenharmony_ciindex. 2435e5c31af7Sopenharmony_ciThis means that the per-vertex values of indices 1 and 2 for point 2436e5c31af7Sopenharmony_ciprimitives will be equal to those of index 0, and the per-vertex values of 2437e5c31af7Sopenharmony_ciindex 2 for line primitives will be equal to those of index 1. 2438e5c31af7Sopenharmony_ci 2439e5c31af7Sopenharmony_ciifndef::VK_NV_mesh_shader,VK_EXT_mesh_shader[] 2440e5c31af7Sopenharmony_ciWhen <<tessellation, tessellation>> and <<geometry, geometry shading>> 2441e5c31af7Sopenharmony_ciendif::VK_NV_mesh_shader,VK_EXT_mesh_shader[] 2442e5c31af7Sopenharmony_ciifdef::VK_NV_mesh_shader,VK_EXT_mesh_shader[] 2443e5c31af7Sopenharmony_ciWhen <<tessellation, tessellation>>, <<geometry, geometry shading>>, and 2444e5c31af7Sopenharmony_ci<<mesh,mesh shading>> 2445e5c31af7Sopenharmony_ciendif::VK_NV_mesh_shader,VK_EXT_mesh_shader[] 2446e5c31af7Sopenharmony_ciare not active, fragment shader inputs decorated with code:PerVertexKHR will 2447e5c31af7Sopenharmony_citake values from one of the vertices of the primitive that produced the 2448e5c31af7Sopenharmony_cifragment, identified by the extra index provided in SPIR-V code accessing 2449e5c31af7Sopenharmony_cithe input. 2450e5c31af7Sopenharmony_ciIf the _n_ vertices passed to a draw call are numbered 0 through _n_-1, and 2451e5c31af7Sopenharmony_cithe point, line, and triangle primitives produced by the draw call are 2452e5c31af7Sopenharmony_cinumbered with consecutive integers beginning with zero, the following table 2453e5c31af7Sopenharmony_ciindicates the original vertex numbers used 2454e5c31af7Sopenharmony_ciifdef::VK_EXT_provoking_vertex[] 2455e5c31af7Sopenharmony_ciwhen the <<vertexpostproc-flatshading,provoking vertex mode>> is 2456e5c31af7Sopenharmony_ciename:VK_PROVOKING_VERTEX_MODE_FIRST_VERTEX_EXT 2457e5c31af7Sopenharmony_ciendif::VK_EXT_provoking_vertex[] 2458e5c31af7Sopenharmony_cifor index values of 0, 1, and 2. 2459e5c31af7Sopenharmony_ciIf an input decorated with code:PerVertexKHR is accessed with any other 2460e5c31af7Sopenharmony_civertex index value, or is accessed while rasterizing a polygon when the 2461e5c31af7Sopenharmony_cislink:VkPipelineRasterizationStateCreateInfo::pname:polygonMode property of 2462e5c31af7Sopenharmony_cithe currently active pipeline is not ename:VK_POLYGON_MODE_FILL, an 2463e5c31af7Sopenharmony_ciundefined: value is returned. 2464e5c31af7Sopenharmony_ci 2465e5c31af7Sopenharmony_ci[[primsrast-barycentric-order-table]] 2466e5c31af7Sopenharmony_ci[options="header"] 2467e5c31af7Sopenharmony_ci|==== 2468e5c31af7Sopenharmony_ci| Primitive Topology | Vertex 0 | Vertex 1 | Vertex 2 2469e5c31af7Sopenharmony_ci| ename:VK_PRIMITIVE_TOPOLOGY_POINT_LIST | i | i | i 2470e5c31af7Sopenharmony_ci| ename:VK_PRIMITIVE_TOPOLOGY_LINE_LIST | 2i | 2i+1 | 2i+1 2471e5c31af7Sopenharmony_ci| ename:VK_PRIMITIVE_TOPOLOGY_LINE_STRIP | i | i+1 | i+1 2472e5c31af7Sopenharmony_ci| ename:VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST | 3i | 3i+1 | 3i+2 2473e5c31af7Sopenharmony_ci| ename:VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP (even) | i | i+1 | i+2 2474e5c31af7Sopenharmony_ci| ename:VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP (odd) | i | i+2 | i+1 2475e5c31af7Sopenharmony_ci| ename:VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN | i+1 | i+2 | 0 2476e5c31af7Sopenharmony_ci| ename:VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY | 4i+1 | 4i+2 | 4i+2 2477e5c31af7Sopenharmony_ci| ename:VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY | i+1 | i+2 | i+2 2478e5c31af7Sopenharmony_ci| ename:VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY | 6i | 6i+2 | 6i+4 2479e5c31af7Sopenharmony_ci| ename:VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY (even) | 2i | 2i+2 | 2i+4 2480e5c31af7Sopenharmony_ci| ename:VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY (odd) | 2i | 2i+4 | 2i+2 2481e5c31af7Sopenharmony_ci|==== 2482e5c31af7Sopenharmony_ci 2483e5c31af7Sopenharmony_ciifdef::VK_EXT_provoking_vertex[] 2484e5c31af7Sopenharmony_ciWhen the provoking vertex mode is 2485e5c31af7Sopenharmony_ciename:VK_PROVOKING_VERTEX_MODE_LAST_VERTEX_EXT, the original vertex numbers 2486e5c31af7Sopenharmony_ciused are the same as above except as indicated in the table below. 2487e5c31af7Sopenharmony_ci 2488e5c31af7Sopenharmony_ci[[primsrast-barycentric-order-table-last-vertex]] 2489e5c31af7Sopenharmony_ci[options="header"] 2490e5c31af7Sopenharmony_ci|==== 2491e5c31af7Sopenharmony_ci| Primitive Topology | Vertex 0 | Vertex 1 | Vertex 2 2492e5c31af7Sopenharmony_ciifdef::VK_KHR_fragment_shader_barycentric[] 2493e5c31af7Sopenharmony_ci| ename:VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP (odd, and 2494e5c31af7Sopenharmony_cipname:triStripVertexOrderIndependentOfProvokingVertex of 2495e5c31af7Sopenharmony_cislink:VkPhysicalDeviceFragmentShaderBarycentricPropertiesKHR is ename:VK_FALSE) | i+1 | i | i+2 2496e5c31af7Sopenharmony_ciendif::VK_KHR_fragment_shader_barycentric[] 2497e5c31af7Sopenharmony_ciifndef::VK_KHR_fragment_shader_barycentric[] 2498e5c31af7Sopenharmony_ci| ename:VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP (odd) | i+1 | i | i+2 2499e5c31af7Sopenharmony_ciendif::VK_KHR_fragment_shader_barycentric[] 2500e5c31af7Sopenharmony_ci| ename:VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN | 0 | i+1 | i+2 2501e5c31af7Sopenharmony_ci| ename:VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY (odd) | 2i+2 | 2i | 2i+4 2502e5c31af7Sopenharmony_ci|==== 2503e5c31af7Sopenharmony_ciendif::VK_EXT_provoking_vertex[] 2504e5c31af7Sopenharmony_ci 2505e5c31af7Sopenharmony_ciWhen geometry 2506e5c31af7Sopenharmony_ciifdef::VK_NV_mesh_shader,VK_EXT_mesh_shader[or mesh] 2507e5c31af7Sopenharmony_cishading is active, primitives processed by fragment shaders are assembled 2508e5c31af7Sopenharmony_cifrom the vertices emitted by the geometry 2509e5c31af7Sopenharmony_ciifdef::VK_NV_mesh_shader,VK_EXT_mesh_shader[or mesh] 2510e5c31af7Sopenharmony_cishader. 2511e5c31af7Sopenharmony_ciIn this case, the vertices used for fragment shader inputs decorated with 2512e5c31af7Sopenharmony_cicode:PerVertexKHR are derived by treating the primitives produced by the 2513e5c31af7Sopenharmony_cishader as though they were specified by a draw call and consulting 2514e5c31af7Sopenharmony_ci<<primsrast-barycentric-order-table, the table above>>. 2515e5c31af7Sopenharmony_ci 2516e5c31af7Sopenharmony_ciWhen using tessellation without geometry shading, the tessellator produces 2517e5c31af7Sopenharmony_ciprimitives in an implementation-dependent manner. 2518e5c31af7Sopenharmony_ciWhile there is no defined vertex ordering for inputs decorated with 2519e5c31af7Sopenharmony_cicode:PerVertexKHR, the vertex ordering used in this case will be consistent 2520e5c31af7Sopenharmony_ciwith the ordering used to derive the values of inputs decorated with 2521e5c31af7Sopenharmony_cicode:BaryCoordKHR or code:BaryCoordNoPerspKHR. 2522e5c31af7Sopenharmony_ci 2523e5c31af7Sopenharmony_ciFragment shader inputs decorated with code:BaryCoordKHR or 2524e5c31af7Sopenharmony_cicode:BaryCoordNoPerspKHR hold three-component vectors with barycentric 2525e5c31af7Sopenharmony_ciweights that indicate the location of the fragment relative to the 2526e5c31af7Sopenharmony_ciscreen-space locations of vertices of its primitive. 2527e5c31af7Sopenharmony_ciFor point primitives, such variables are always assigned the value 2528e5c31af7Sopenharmony_ci[eq]#(1,0,0)#. 2529e5c31af7Sopenharmony_ciFor <<primsrast-lines-basic, line>> primitives, the built-ins are obtained 2530e5c31af7Sopenharmony_ciby interpolating an attribute whose values for the vertices numbered 0 and 1 2531e5c31af7Sopenharmony_ciare [eq]#(1,0,0)# and [eq]#(0,1,0)#, respectively. 2532e5c31af7Sopenharmony_ciFor <<primsrast-polygons-basic, polygon>> primitives, the built-ins are 2533e5c31af7Sopenharmony_ciobtained by interpolating an attribute whose values for the vertices 2534e5c31af7Sopenharmony_cinumbered 0, 1, and 2 are [eq]#(1,0,0)#, [eq]#(0,1,0)#, and [eq]#(0,0,1)#, 2535e5c31af7Sopenharmony_cirespectively. 2536e5c31af7Sopenharmony_ciFor code:BaryCoordKHR, the values are obtained using perspective 2537e5c31af7Sopenharmony_ciinterpolation. 2538e5c31af7Sopenharmony_ciFor code:BaryCoordNoPerspKHR, the values are obtained using linear 2539e5c31af7Sopenharmony_ciinterpolation. 2540e5c31af7Sopenharmony_ciThe values of code:BaryCoordKHR and code:BaryCoordNoPerspKHR are undefined: 2541e5c31af7Sopenharmony_ciwhile rasterizing a polygon when the 2542e5c31af7Sopenharmony_cislink:VkPipelineRasterizationStateCreateInfo::pname:polygonMode property of 2543e5c31af7Sopenharmony_cithe currently active pipeline is not ename:VK_POLYGON_MODE_FILL. 2544e5c31af7Sopenharmony_ci 2545e5c31af7Sopenharmony_ciendif::VK_NV_fragment_shader_barycentric,VK_KHR_fragment_shader_barycentric[] 2546e5c31af7Sopenharmony_ci 2547e5c31af7Sopenharmony_ci 2548e5c31af7Sopenharmony_ci[[primsrast-points]] 2549e5c31af7Sopenharmony_ci== Points 2550e5c31af7Sopenharmony_ci 2551e5c31af7Sopenharmony_ciA point is drawn by generating a set of fragments in the shape of a square 2552e5c31af7Sopenharmony_cicentered around the vertex of the point. 2553e5c31af7Sopenharmony_ciEach vertex has an associated point size controlling the width/height of 2554e5c31af7Sopenharmony_cithat square. 2555e5c31af7Sopenharmony_ciThe point size is taken from the (potentially clipped) shader built-in 2556e5c31af7Sopenharmony_cicode:PointSize written by: 2557e5c31af7Sopenharmony_ci 2558e5c31af7Sopenharmony_ci * the geometry shader, if active; 2559e5c31af7Sopenharmony_ci * the tessellation evaluation shader, if active and no geometry shader is 2560e5c31af7Sopenharmony_ci active; 2561e5c31af7Sopenharmony_ci * the vertex shader, otherwise 2562e5c31af7Sopenharmony_ci 2563e5c31af7Sopenharmony_ciand clamped to the implementation-dependent point size range 2564e5c31af7Sopenharmony_ci[eq]#[pname:pointSizeRange[0],pname:pointSizeRange[1]]#. 2565e5c31af7Sopenharmony_ciThe value written to code:PointSize must: be greater than zero. 2566e5c31af7Sopenharmony_ciifdef::VK_KHR_maintenance5[] 2567e5c31af7Sopenharmony_ciIf <<features-maintenance5, pname:maintenance5>> is enabled, and a value is 2568e5c31af7Sopenharmony_cinot written to code:PointSize, the point size takes a default value of 1.0. 2569e5c31af7Sopenharmony_ciendif::VK_KHR_maintenance5[] 2570e5c31af7Sopenharmony_ci 2571e5c31af7Sopenharmony_ciNot all point sizes need be supported, but the size 1.0 must: be supported. 2572e5c31af7Sopenharmony_ciThe range of supported sizes and the size of evenly-spaced gradations within 2573e5c31af7Sopenharmony_cithat range are implementation-dependent. 2574e5c31af7Sopenharmony_ciThe range and gradations are obtained from the pname:pointSizeRange and 2575e5c31af7Sopenharmony_cipname:pointSizeGranularity members of slink:VkPhysicalDeviceLimits. 2576e5c31af7Sopenharmony_ciIf, for instance, the size range is from 0.1 to 2.0 and the gradation size 2577e5c31af7Sopenharmony_ciis 0.1, then the sizes 0.1, 0.2, ..., 1.9, 2.0 are supported. 2578e5c31af7Sopenharmony_ciAdditional point sizes may: also be supported. 2579e5c31af7Sopenharmony_ciThere is no requirement that these sizes be equally spaced. 2580e5c31af7Sopenharmony_ciIf an unsupported size is requested, the nearest supported size is used 2581e5c31af7Sopenharmony_ciinstead. 2582e5c31af7Sopenharmony_ci 2583e5c31af7Sopenharmony_ciifdef::VK_EXT_fragment_density_map[] 2584e5c31af7Sopenharmony_ciFurther, if the render pass has a fragment density map attachment, point 2585e5c31af7Sopenharmony_cisize may: be rounded by the implementation to a multiple of the fragment's 2586e5c31af7Sopenharmony_ciwidth or height. 2587e5c31af7Sopenharmony_ciendif::VK_EXT_fragment_density_map[] 2588e5c31af7Sopenharmony_ci 2589e5c31af7Sopenharmony_ci 2590e5c31af7Sopenharmony_ci[[primsrast-points-basic]] 2591e5c31af7Sopenharmony_ci=== Basic Point Rasterization 2592e5c31af7Sopenharmony_ci 2593e5c31af7Sopenharmony_ciPoint rasterization produces a fragment for each fragment area group of 2594e5c31af7Sopenharmony_ciframebuffer pixels with one or more sample points that intersect a region 2595e5c31af7Sopenharmony_cicentered at the point's [eq]#(x~f~,y~f~)#. 2596e5c31af7Sopenharmony_ciThis region is a square with side equal to the current point size. 2597e5c31af7Sopenharmony_ciCoverage bits that correspond to sample points that intersect the region are 2598e5c31af7Sopenharmony_ci1, other coverage bits are 0. 2599e5c31af7Sopenharmony_ciAll fragments produced in rasterizing a point are assigned the same 2600e5c31af7Sopenharmony_ciassociated data, which are those of the vertex corresponding to the point. 2601e5c31af7Sopenharmony_ciHowever, the fragment shader built-in code:PointCoord contains point sprite 2602e5c31af7Sopenharmony_citexture coordinates. 2603e5c31af7Sopenharmony_ciThe [eq]#s# and [eq]#t# point sprite texture coordinates vary from zero to 2604e5c31af7Sopenharmony_cione across the point horizontally left-to-right and vertically 2605e5c31af7Sopenharmony_citop-to-bottom, respectively. 2606e5c31af7Sopenharmony_ciThe following formulas are used to evaluate [eq]#s# and [eq]#t#: 2607e5c31af7Sopenharmony_ci 2608e5c31af7Sopenharmony_ci[latexmath] 2609e5c31af7Sopenharmony_ci++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2610e5c31af7Sopenharmony_cis = {1 \over 2} + { \left( x_p - x_f \right) \over \text{size} } 2611e5c31af7Sopenharmony_ci++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2612e5c31af7Sopenharmony_ci 2613e5c31af7Sopenharmony_ci[latexmath] 2614e5c31af7Sopenharmony_ci++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2615e5c31af7Sopenharmony_cit = {1 \over 2} + { \left( y_p - y_f \right) \over \text{size} } 2616e5c31af7Sopenharmony_ci++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2617e5c31af7Sopenharmony_ci 2618e5c31af7Sopenharmony_ciwhere size is the point's size; [eq]#(x~p~,y~p~)# is the location at which 2619e5c31af7Sopenharmony_cithe point sprite coordinates are evaluated - this may: be the framebuffer 2620e5c31af7Sopenharmony_cicoordinates of the fragment center, or the location of a sample; and 2621e5c31af7Sopenharmony_ci[eq]#(x~f~,y~f~)# is the exact, unrounded framebuffer coordinate of the 2622e5c31af7Sopenharmony_civertex for the point. 2623e5c31af7Sopenharmony_ci 2624e5c31af7Sopenharmony_ci 2625e5c31af7Sopenharmony_ci[[primsrast-lines]] 2626e5c31af7Sopenharmony_ci== Line Segments 2627e5c31af7Sopenharmony_ci 2628e5c31af7Sopenharmony_ciifdef::VK_EXT_line_rasterization[] 2629e5c31af7Sopenharmony_ci[open,refpage='VkPipelineRasterizationLineStateCreateInfoEXT',desc='Structure specifying parameters of a newly created pipeline line rasterization state',type='structs'] 2630e5c31af7Sopenharmony_ci-- 2631e5c31af7Sopenharmony_ciLine segment rasterization options are controlled by the 2632e5c31af7Sopenharmony_cislink:VkPipelineRasterizationLineStateCreateInfoEXT structure. 2633e5c31af7Sopenharmony_ci 2634e5c31af7Sopenharmony_ciThe sname:VkPipelineRasterizationLineStateCreateInfoEXT structure is defined 2635e5c31af7Sopenharmony_cias: 2636e5c31af7Sopenharmony_ci 2637e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkPipelineRasterizationLineStateCreateInfoEXT.adoc[] 2638e5c31af7Sopenharmony_ci 2639e5c31af7Sopenharmony_ci * pname:sType is a elink:VkStructureType value identifying this structure. 2640e5c31af7Sopenharmony_ci * pname:pNext is `NULL` or a pointer to a structure extending this 2641e5c31af7Sopenharmony_ci structure. 2642e5c31af7Sopenharmony_ci * pname:lineRasterizationMode is a elink:VkLineRasterizationModeEXT value 2643e5c31af7Sopenharmony_ci selecting the style of line rasterization. 2644e5c31af7Sopenharmony_ci * pname:stippledLineEnable enables <<primsrast-lines-stipple, stippled 2645e5c31af7Sopenharmony_ci line rasterization>>. 2646e5c31af7Sopenharmony_ci * pname:lineStippleFactor is the repeat factor used in stippled line 2647e5c31af7Sopenharmony_ci rasterization. 2648e5c31af7Sopenharmony_ci * pname:lineStipplePattern is the bit pattern used in stippled line 2649e5c31af7Sopenharmony_ci rasterization. 2650e5c31af7Sopenharmony_ci 2651e5c31af7Sopenharmony_ciIf pname:stippledLineEnable is ename:VK_FALSE, the values of 2652e5c31af7Sopenharmony_cipname:lineStippleFactor and pname:lineStipplePattern are ignored. 2653e5c31af7Sopenharmony_ci 2654e5c31af7Sopenharmony_ci.Valid Usage 2655e5c31af7Sopenharmony_ci**** 2656e5c31af7Sopenharmony_ci * [[VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768]] 2657e5c31af7Sopenharmony_ci If pname:lineRasterizationMode is 2658e5c31af7Sopenharmony_ci ename:VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT, then the 2659e5c31af7Sopenharmony_ci <<features-rectangularLines, pname:rectangularLines>> feature must: be 2660e5c31af7Sopenharmony_ci enabled 2661e5c31af7Sopenharmony_ci * [[VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769]] 2662e5c31af7Sopenharmony_ci If pname:lineRasterizationMode is 2663e5c31af7Sopenharmony_ci ename:VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT, then the 2664e5c31af7Sopenharmony_ci <<features-bresenhamLines, pname:bresenhamLines>> feature must: be 2665e5c31af7Sopenharmony_ci enabled 2666e5c31af7Sopenharmony_ci * [[VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770]] 2667e5c31af7Sopenharmony_ci If pname:lineRasterizationMode is 2668e5c31af7Sopenharmony_ci ename:VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT, then the 2669e5c31af7Sopenharmony_ci <<features-smoothLines, pname:smoothLines>> feature must: be enabled 2670e5c31af7Sopenharmony_ci * [[VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771]] 2671e5c31af7Sopenharmony_ci If pname:stippledLineEnable is ename:VK_TRUE and 2672e5c31af7Sopenharmony_ci pname:lineRasterizationMode is 2673e5c31af7Sopenharmony_ci ename:VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT, then the 2674e5c31af7Sopenharmony_ci <<features-stippledRectangularLines, pname:stippledRectangularLines>> 2675e5c31af7Sopenharmony_ci feature must: be enabled 2676e5c31af7Sopenharmony_ci * [[VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772]] 2677e5c31af7Sopenharmony_ci If pname:stippledLineEnable is ename:VK_TRUE and 2678e5c31af7Sopenharmony_ci pname:lineRasterizationMode is 2679e5c31af7Sopenharmony_ci ename:VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT, then the 2680e5c31af7Sopenharmony_ci <<features-stippledBresenhamLines, pname:stippledBresenhamLines>> 2681e5c31af7Sopenharmony_ci feature must: be enabled 2682e5c31af7Sopenharmony_ci * [[VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773]] 2683e5c31af7Sopenharmony_ci If pname:stippledLineEnable is ename:VK_TRUE and 2684e5c31af7Sopenharmony_ci pname:lineRasterizationMode is 2685e5c31af7Sopenharmony_ci ename:VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT, then the 2686e5c31af7Sopenharmony_ci <<features-stippledSmoothLines, pname:stippledSmoothLines>> feature 2687e5c31af7Sopenharmony_ci must: be enabled 2688e5c31af7Sopenharmony_ci * [[VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774]] 2689e5c31af7Sopenharmony_ci If pname:stippledLineEnable is ename:VK_TRUE and 2690e5c31af7Sopenharmony_ci pname:lineRasterizationMode is 2691e5c31af7Sopenharmony_ci ename:VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT, then the 2692e5c31af7Sopenharmony_ci <<features-stippledRectangularLines, pname:stippledRectangularLines>> 2693e5c31af7Sopenharmony_ci feature must: be enabled and 2694e5c31af7Sopenharmony_ci slink:VkPhysicalDeviceLimits::pname:strictLines must: be ename:VK_TRUE 2695e5c31af7Sopenharmony_ci**** 2696e5c31af7Sopenharmony_ci 2697e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkPipelineRasterizationLineStateCreateInfoEXT.adoc[] 2698e5c31af7Sopenharmony_ci-- 2699e5c31af7Sopenharmony_ci 2700e5c31af7Sopenharmony_ci[open,refpage='VkLineRasterizationModeEXT',desc='Line rasterization modes',type='enums'] 2701e5c31af7Sopenharmony_ci-- 2702e5c31af7Sopenharmony_ciPossible values of 2703e5c31af7Sopenharmony_cislink:VkPipelineRasterizationLineStateCreateInfoEXT::pname:lineRasterizationMode 2704e5c31af7Sopenharmony_ciare: 2705e5c31af7Sopenharmony_ci 2706e5c31af7Sopenharmony_ciinclude::{generated}/api/enums/VkLineRasterizationModeEXT.adoc[] 2707e5c31af7Sopenharmony_ci 2708e5c31af7Sopenharmony_ci * ename:VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT is equivalent to 2709e5c31af7Sopenharmony_ci ename:VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT if 2710e5c31af7Sopenharmony_ci slink:VkPhysicalDeviceLimits::pname:strictLines is ename:VK_TRUE, 2711e5c31af7Sopenharmony_ci otherwise lines are drawn as non-pname:strictLines parallelograms. 2712e5c31af7Sopenharmony_ci Both of these modes are defined in <<primsrast-lines-basic,Basic Line 2713e5c31af7Sopenharmony_ci Segment Rasterization>>. 2714e5c31af7Sopenharmony_ci * ename:VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT specifies lines drawn 2715e5c31af7Sopenharmony_ci as if they were rectangles extruded from the line 2716e5c31af7Sopenharmony_ci * ename:VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT specifies lines drawn by 2717e5c31af7Sopenharmony_ci determining which pixel diamonds the line intersects and exits, as 2718e5c31af7Sopenharmony_ci defined in <<primsrast-lines-bresenham,Bresenham Line Segment 2719e5c31af7Sopenharmony_ci Rasterization>>. 2720e5c31af7Sopenharmony_ci * ename:VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT specifies lines 2721e5c31af7Sopenharmony_ci drawn if they were rectangles extruded from the line, with alpha 2722e5c31af7Sopenharmony_ci falloff, as defined in <<primsrast-lines-smooth,Smooth Lines>>. 2723e5c31af7Sopenharmony_ci-- 2724e5c31af7Sopenharmony_ci 2725e5c31af7Sopenharmony_ciifdef::VK_EXT_extended_dynamic_state3,VK_EXT_shader_object[] 2726e5c31af7Sopenharmony_ci 2727e5c31af7Sopenharmony_ci[open,refpage='vkCmdSetLineRasterizationModeEXT',desc='Specify the line rasterization mode dynamically for a command buffer',type='protos'] 2728e5c31af7Sopenharmony_ci-- 2729e5c31af7Sopenharmony_ciTo <<pipelines-dynamic-state, dynamically set>> the 2730e5c31af7Sopenharmony_cipname:lineRasterizationMode state, call: 2731e5c31af7Sopenharmony_ci 2732e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCmdSetLineRasterizationModeEXT.adoc[] 2733e5c31af7Sopenharmony_ci 2734e5c31af7Sopenharmony_ci * pname:commandBuffer is the command buffer into which the command will be 2735e5c31af7Sopenharmony_ci recorded. 2736e5c31af7Sopenharmony_ci * pname:lineRasterizationMode specifies the pname:lineRasterizationMode 2737e5c31af7Sopenharmony_ci state. 2738e5c31af7Sopenharmony_ci 2739e5c31af7Sopenharmony_ciThis command sets the pname:lineRasterizationMode state for subsequent 2740e5c31af7Sopenharmony_cidrawing commands 2741e5c31af7Sopenharmony_ciifdef::VK_EXT_shader_object[] 2742e5c31af7Sopenharmony_ciifdef::VK_EXT_extended_dynamic_state3[when drawing using <<shaders-objects, shader objects>>, or] 2743e5c31af7Sopenharmony_ciifndef::VK_EXT_extended_dynamic_state3[when drawing using <<shaders-objects, shader objects>>.] 2744e5c31af7Sopenharmony_ciendif::VK_EXT_shader_object[] 2745e5c31af7Sopenharmony_ciifdef::VK_EXT_extended_dynamic_state3[] 2746e5c31af7Sopenharmony_ciwhen the graphics pipeline is created with 2747e5c31af7Sopenharmony_ciename:VK_DYNAMIC_STATE_LINE_RASTERIZATION_MODE_EXT set in 2748e5c31af7Sopenharmony_cislink:VkPipelineDynamicStateCreateInfo::pname:pDynamicStates. 2749e5c31af7Sopenharmony_ciendif::VK_EXT_extended_dynamic_state3[] 2750e5c31af7Sopenharmony_ciOtherwise, this state is specified by the 2751e5c31af7Sopenharmony_cislink:VkPipelineRasterizationLineStateCreateInfoEXT::pname:lineRasterizationMode 2752e5c31af7Sopenharmony_civalue used to create the currently active pipeline. 2753e5c31af7Sopenharmony_ci 2754e5c31af7Sopenharmony_ci:refpage: vkCmdSetLineRasterizationModeEXT 2755e5c31af7Sopenharmony_ci:requiredfeature: extendedDynamicState3LineRasterizationMode 2756e5c31af7Sopenharmony_ci 2757e5c31af7Sopenharmony_ci.Valid Usage 2758e5c31af7Sopenharmony_ci**** 2759e5c31af7Sopenharmony_ciinclude::{chapters}/commonvalidity/dynamic_state3_feature_common.adoc[] 2760e5c31af7Sopenharmony_ci * [[VUID-vkCmdSetLineRasterizationModeEXT-lineRasterizationMode-07418]] 2761e5c31af7Sopenharmony_ci If pname:lineRasterizationMode is 2762e5c31af7Sopenharmony_ci ename:VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT, then the 2763e5c31af7Sopenharmony_ci <<features-rectangularLines, pname:rectangularLines>> feature must: be 2764e5c31af7Sopenharmony_ci enabled 2765e5c31af7Sopenharmony_ci * [[VUID-vkCmdSetLineRasterizationModeEXT-lineRasterizationMode-07419]] 2766e5c31af7Sopenharmony_ci If pname:lineRasterizationMode is 2767e5c31af7Sopenharmony_ci ename:VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT, then the 2768e5c31af7Sopenharmony_ci <<features-bresenhamLines, pname:bresenhamLines>> feature must: be 2769e5c31af7Sopenharmony_ci enabled 2770e5c31af7Sopenharmony_ci * [[VUID-vkCmdSetLineRasterizationModeEXT-lineRasterizationMode-07420]] 2771e5c31af7Sopenharmony_ci If pname:lineRasterizationMode is 2772e5c31af7Sopenharmony_ci ename:VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT, then the 2773e5c31af7Sopenharmony_ci <<features-smoothLines, pname:smoothLines>> feature must: be enabled 2774e5c31af7Sopenharmony_ci**** 2775e5c31af7Sopenharmony_ci 2776e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkCmdSetLineRasterizationModeEXT.adoc[] 2777e5c31af7Sopenharmony_ci-- 2778e5c31af7Sopenharmony_ci 2779e5c31af7Sopenharmony_ci[open,refpage='vkCmdSetLineStippleEnableEXT',desc='Specify the line stipple enable dynamically for a command buffer',type='protos'] 2780e5c31af7Sopenharmony_ci-- 2781e5c31af7Sopenharmony_ciTo <<pipelines-dynamic-state, dynamically set>> the pname:stippledLineEnable 2782e5c31af7Sopenharmony_cistate, call: 2783e5c31af7Sopenharmony_ci 2784e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCmdSetLineStippleEnableEXT.adoc[] 2785e5c31af7Sopenharmony_ci 2786e5c31af7Sopenharmony_ci * pname:commandBuffer is the command buffer into which the command will be 2787e5c31af7Sopenharmony_ci recorded. 2788e5c31af7Sopenharmony_ci * pname:stippledLineEnable specifies the pname:stippledLineEnable state. 2789e5c31af7Sopenharmony_ci 2790e5c31af7Sopenharmony_ciThis command sets the pname:stippledLineEnable state for subsequent drawing 2791e5c31af7Sopenharmony_cicommands 2792e5c31af7Sopenharmony_ciifdef::VK_EXT_shader_object[] 2793e5c31af7Sopenharmony_ciifdef::VK_EXT_extended_dynamic_state3[when drawing using <<shaders-objects, shader objects>>, or] 2794e5c31af7Sopenharmony_ciifndef::VK_EXT_extended_dynamic_state3[when drawing using <<shaders-objects, shader objects>>.] 2795e5c31af7Sopenharmony_ciendif::VK_EXT_shader_object[] 2796e5c31af7Sopenharmony_ciifdef::VK_EXT_extended_dynamic_state3[] 2797e5c31af7Sopenharmony_ciwhen the graphics pipeline is created with 2798e5c31af7Sopenharmony_ciename:VK_DYNAMIC_STATE_LINE_STIPPLE_ENABLE_EXT set in 2799e5c31af7Sopenharmony_cislink:VkPipelineDynamicStateCreateInfo::pname:pDynamicStates. 2800e5c31af7Sopenharmony_ciendif::VK_EXT_extended_dynamic_state3[] 2801e5c31af7Sopenharmony_ciOtherwise, this state is specified by the 2802e5c31af7Sopenharmony_cislink:VkPipelineRasterizationLineStateCreateInfoEXT::pname:stippledLineEnable 2803e5c31af7Sopenharmony_civalue used to create the currently active pipeline. 2804e5c31af7Sopenharmony_ci 2805e5c31af7Sopenharmony_ci:refpage: vkCmdSetLineStippleEnableEXT 2806e5c31af7Sopenharmony_ci:requiredfeature: extendedDynamicState3LineStippleEnable 2807e5c31af7Sopenharmony_ci 2808e5c31af7Sopenharmony_ci.Valid Usage 2809e5c31af7Sopenharmony_ci**** 2810e5c31af7Sopenharmony_ciinclude::{chapters}/commonvalidity/dynamic_state3_feature_common.adoc[] 2811e5c31af7Sopenharmony_ci**** 2812e5c31af7Sopenharmony_ci 2813e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkCmdSetLineStippleEnableEXT.adoc[] 2814e5c31af7Sopenharmony_ci-- 2815e5c31af7Sopenharmony_ci 2816e5c31af7Sopenharmony_ciendif::VK_EXT_extended_dynamic_state3,VK_EXT_shader_object[] 2817e5c31af7Sopenharmony_ci 2818e5c31af7Sopenharmony_ciendif::VK_EXT_line_rasterization[] 2819e5c31af7Sopenharmony_ci 2820e5c31af7Sopenharmony_ci[open,refpage='vkCmdSetLineWidth',desc='Set line width dynamically for a command buffer',type='protos'] 2821e5c31af7Sopenharmony_ci-- 2822e5c31af7Sopenharmony_ciTo <<pipelines-dynamic-state, dynamically set>> the line width, call: 2823e5c31af7Sopenharmony_ci 2824e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCmdSetLineWidth.adoc[] 2825e5c31af7Sopenharmony_ci 2826e5c31af7Sopenharmony_ci * pname:commandBuffer is the command buffer into which the command will be 2827e5c31af7Sopenharmony_ci recorded. 2828e5c31af7Sopenharmony_ci * pname:lineWidth is the width of rasterized line segments. 2829e5c31af7Sopenharmony_ci 2830e5c31af7Sopenharmony_ciThis command sets the line width for subsequent drawing commands 2831e5c31af7Sopenharmony_ciifdef::VK_EXT_shader_object[when drawing using <<shaders-objects, shader objects>>, or] 2832e5c31af7Sopenharmony_ciwhen the graphics pipeline is created with ename:VK_DYNAMIC_STATE_LINE_WIDTH 2833e5c31af7Sopenharmony_ciset in slink:VkPipelineDynamicStateCreateInfo::pname:pDynamicStates. 2834e5c31af7Sopenharmony_ciOtherwise, this state is specified by the 2835e5c31af7Sopenharmony_cislink:VkPipelineRasterizationStateCreateInfo::pname:lineWidth value used to 2836e5c31af7Sopenharmony_cicreate the currently active pipeline. 2837e5c31af7Sopenharmony_ci 2838e5c31af7Sopenharmony_ci.Valid Usage 2839e5c31af7Sopenharmony_ci**** 2840e5c31af7Sopenharmony_ci * [[VUID-vkCmdSetLineWidth-lineWidth-00788]] 2841e5c31af7Sopenharmony_ci If the <<features-wideLines, pname:wideLines>> feature is not enabled, 2842e5c31af7Sopenharmony_ci pname:lineWidth must: be `1.0` 2843e5c31af7Sopenharmony_ci**** 2844e5c31af7Sopenharmony_ci 2845e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkCmdSetLineWidth.adoc[] 2846e5c31af7Sopenharmony_ci-- 2847e5c31af7Sopenharmony_ci 2848e5c31af7Sopenharmony_ciNot all line widths need be supported for line segment rasterization, but 2849e5c31af7Sopenharmony_ciwidth 1.0 antialiased segments must: be provided. 2850e5c31af7Sopenharmony_ciThe range and gradations are obtained from the pname:lineWidthRange and 2851e5c31af7Sopenharmony_cipname:lineWidthGranularity members of slink:VkPhysicalDeviceLimits. 2852e5c31af7Sopenharmony_ciIf, for instance, the size range is from 0.1 to 2.0 and the gradation size 2853e5c31af7Sopenharmony_ciis 0.1, then the sizes 0.1, 0.2, ..., 1.9, 2.0 are supported. 2854e5c31af7Sopenharmony_ciAdditional line widths may: also be supported. 2855e5c31af7Sopenharmony_ciThere is no requirement that these widths be equally spaced. 2856e5c31af7Sopenharmony_ciIf an unsupported width is requested, the nearest supported width is used 2857e5c31af7Sopenharmony_ciinstead. 2858e5c31af7Sopenharmony_ci 2859e5c31af7Sopenharmony_ciifdef::VK_EXT_fragment_density_map[] 2860e5c31af7Sopenharmony_ciFurther, if the render pass has a fragment density map attachment, line 2861e5c31af7Sopenharmony_ciwidth may: be rounded by the implementation to a multiple of the fragment's 2862e5c31af7Sopenharmony_ciwidth or height. 2863e5c31af7Sopenharmony_ciendif::VK_EXT_fragment_density_map[] 2864e5c31af7Sopenharmony_ci 2865e5c31af7Sopenharmony_ci 2866e5c31af7Sopenharmony_ci[[primsrast-lines-basic]] 2867e5c31af7Sopenharmony_ci=== Basic Line Segment Rasterization 2868e5c31af7Sopenharmony_ci 2869e5c31af7Sopenharmony_ciifdef::VK_EXT_line_rasterization[] 2870e5c31af7Sopenharmony_ciIf the pname:lineRasterizationMode member of 2871e5c31af7Sopenharmony_cislink:VkPipelineRasterizationLineStateCreateInfoEXT is 2872e5c31af7Sopenharmony_ciename:VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT, rasterized 2873e5c31af7Sopenharmony_ciendif::VK_EXT_line_rasterization[] 2874e5c31af7Sopenharmony_ciifndef::VK_EXT_line_rasterization[] 2875e5c31af7Sopenharmony_ciRasterized 2876e5c31af7Sopenharmony_ciendif::VK_EXT_line_rasterization[] 2877e5c31af7Sopenharmony_ciline segments produce fragments which intersect a rectangle centered on the 2878e5c31af7Sopenharmony_ciline segment. 2879e5c31af7Sopenharmony_ciTwo of the edges are parallel to the specified line segment; each is at a 2880e5c31af7Sopenharmony_cidistance of one-half the current width from that segment in directions 2881e5c31af7Sopenharmony_ciperpendicular to the direction of the line. 2882e5c31af7Sopenharmony_ciThe other two edges pass through the line endpoints and are perpendicular to 2883e5c31af7Sopenharmony_cithe direction of the specified line segment. 2884e5c31af7Sopenharmony_ciCoverage bits that correspond to sample points that intersect the rectangle 2885e5c31af7Sopenharmony_ciare 1, other coverage bits are 0. 2886e5c31af7Sopenharmony_ci 2887e5c31af7Sopenharmony_ciNext we specify how the data associated with each rasterized fragment are 2888e5c31af7Sopenharmony_ciobtained. 2889e5c31af7Sopenharmony_ciLet [eq]#**p**~r~ = (x~d~, y~d~)# be the framebuffer coordinates at which 2890e5c31af7Sopenharmony_ciassociated data are evaluated. 2891e5c31af7Sopenharmony_ciThis may: be the center of a fragment or the location of a sample within the 2892e5c31af7Sopenharmony_cifragment. 2893e5c31af7Sopenharmony_ciWhen pname:rasterizationSamples is ename:VK_SAMPLE_COUNT_1_BIT, the fragment 2894e5c31af7Sopenharmony_cicenter must: be used. 2895e5c31af7Sopenharmony_ciLet [eq]#**p**~a~ = (x~a~, y~a~)# and [eq]#**p**~b~ = (x~b~,y~b~)# be 2896e5c31af7Sopenharmony_ciinitial and final endpoints of the line segment, respectively. 2897e5c31af7Sopenharmony_ciSet 2898e5c31af7Sopenharmony_ci 2899e5c31af7Sopenharmony_ci// Equation {linet:eq} 2900e5c31af7Sopenharmony_ci[latexmath] 2901e5c31af7Sopenharmony_ci++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2902e5c31af7Sopenharmony_cit = {{( \mathbf{p}_r - \mathbf{p}_a ) \cdot ( \mathbf{p}_b - \mathbf{p}_a )} 2903e5c31af7Sopenharmony_ci \over {\| \mathbf{p}_b - \mathbf{p}_a \|^2 }} 2904e5c31af7Sopenharmony_ci++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2905e5c31af7Sopenharmony_ci 2906e5c31af7Sopenharmony_ci(Note that [eq]#t = 0# at [eq]#**p**~a~# and [eq]#t = 1# at [eq]#**p**~b~#. 2907e5c31af7Sopenharmony_ciAlso note that this calculation projects the vector from [eq]#**p**~a~# to 2908e5c31af7Sopenharmony_ci[eq]#**p**~r~# onto the line, and thus computes the normalized distance of 2909e5c31af7Sopenharmony_cithe fragment along the line.) 2910e5c31af7Sopenharmony_ci 2911e5c31af7Sopenharmony_ciIf <<limits-strictLines, pname:strictLines>> is ename:VK_TRUE, line segments 2912e5c31af7Sopenharmony_ciare rasterized using perspective or linear interpolation. 2913e5c31af7Sopenharmony_ci 2914e5c31af7Sopenharmony_ci[[line_perspective_interpolation]] 2915e5c31af7Sopenharmony_ci_Perspective interpolation_ for a line segment interpolates two values in a 2916e5c31af7Sopenharmony_cimanner that is correct when taking the perspective of the viewport into 2917e5c31af7Sopenharmony_ciconsideration, by way of the line segment's clip coordinates. 2918e5c31af7Sopenharmony_ciAn interpolated value [eq]#f# can be determined by 2919e5c31af7Sopenharmony_ci 2920e5c31af7Sopenharmony_ci[latexmath] 2921e5c31af7Sopenharmony_ci++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2922e5c31af7Sopenharmony_cif = {{ (1-t) {f_a / w_a} + t { f_b / w_b} } \over 2923e5c31af7Sopenharmony_ci {(1-t) / w_a + t / w_b }} 2924e5c31af7Sopenharmony_ci++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2925e5c31af7Sopenharmony_ci 2926e5c31af7Sopenharmony_ciwhere [eq]#f~a~# and [eq]#f~b~# are the data associated with the starting 2927e5c31af7Sopenharmony_ciand ending endpoints of the segment, respectively; [eq]#w~a~# and [eq]#w~b~# 2928e5c31af7Sopenharmony_ciare the clip [eq]#w# coordinates of the starting and ending endpoints of the 2929e5c31af7Sopenharmony_cisegment, respectively. 2930e5c31af7Sopenharmony_ci 2931e5c31af7Sopenharmony_ci[[line_linear_interpolation]] 2932e5c31af7Sopenharmony_ci_Linear interpolation_ for a line segment directly interpolates two values, 2933e5c31af7Sopenharmony_ciand an interpolated value [eq]#f# can be determined by 2934e5c31af7Sopenharmony_ci 2935e5c31af7Sopenharmony_ci {empty}:: [eq]#f = (1 - t) f~a~ {plus} t f~b~# 2936e5c31af7Sopenharmony_ci 2937e5c31af7Sopenharmony_ciwhere [eq]#f~a~# and [eq]#f~b~# are the data associated with the starting 2938e5c31af7Sopenharmony_ciand ending endpoints of the segment, respectively. 2939e5c31af7Sopenharmony_ci 2940e5c31af7Sopenharmony_ciThe clip coordinate [eq]#w# for a sample is determined using perspective 2941e5c31af7Sopenharmony_ciinterpolation. 2942e5c31af7Sopenharmony_ciThe depth value [eq]#z# for a sample is determined using linear 2943e5c31af7Sopenharmony_ciinterpolation. 2944e5c31af7Sopenharmony_ciInterpolation of fragment shader input values are determined by 2945e5c31af7Sopenharmony_ci<<shaders-interpolation-decorations,Interpolation decorations>>. 2946e5c31af7Sopenharmony_ci 2947e5c31af7Sopenharmony_ciThe above description documents the preferred method of line rasterization, 2948e5c31af7Sopenharmony_ciand must: be used when 2949e5c31af7Sopenharmony_ciifdef::VK_EXT_line_rasterization[] 2950e5c31af7Sopenharmony_cipname:lineRasterizationMode is 2951e5c31af7Sopenharmony_ciename:VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT. 2952e5c31af7Sopenharmony_ciendif::VK_EXT_line_rasterization[] 2953e5c31af7Sopenharmony_ciifndef::VK_EXT_line_rasterization[] 2954e5c31af7Sopenharmony_cithe implementation advertises the pname:strictLines limit in 2955e5c31af7Sopenharmony_cislink:VkPhysicalDeviceLimits as ename:VK_TRUE. 2956e5c31af7Sopenharmony_ciendif::VK_EXT_line_rasterization[] 2957e5c31af7Sopenharmony_ci 2958e5c31af7Sopenharmony_ciifndef::VK_KHR_maintenance5[] 2959e5c31af7Sopenharmony_ciWhen 2960e5c31af7Sopenharmony_ciendif::VK_KHR_maintenance5[] 2961e5c31af7Sopenharmony_ciifdef::VK_KHR_maintenance5[] 2962e5c31af7Sopenharmony_ciBy default, when 2963e5c31af7Sopenharmony_ciendif::VK_KHR_maintenance5[] 2964e5c31af7Sopenharmony_cipname:strictLines is ename:VK_FALSE, 2965e5c31af7Sopenharmony_ciifdef::VK_IMG_relaxed_line_rasterization[] 2966e5c31af7Sopenharmony_cior the <<features-relaxedLineRasterization, pname:relaxedLineRasterization>> 2967e5c31af7Sopenharmony_cifeature is enabled, 2968e5c31af7Sopenharmony_ciendif::VK_IMG_relaxed_line_rasterization[] 2969e5c31af7Sopenharmony_ciifdef::VK_EXT_line_rasterization[] 2970e5c31af7Sopenharmony_ciand when the pname:lineRasterizationMode is 2971e5c31af7Sopenharmony_ciename:VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT, 2972e5c31af7Sopenharmony_ciendif::VK_EXT_line_rasterization[] 2973e5c31af7Sopenharmony_cithe edges of the lines are generated as a parallelogram surrounding the 2974e5c31af7Sopenharmony_cioriginal line. 2975e5c31af7Sopenharmony_ciThe major axis is chosen by noting the axis in which there is the greatest 2976e5c31af7Sopenharmony_cidistance between the line start and end points. 2977e5c31af7Sopenharmony_ciIf the difference is equal in both directions then the X axis is chosen as 2978e5c31af7Sopenharmony_cithe major axis. 2979e5c31af7Sopenharmony_ciEdges 2 and 3 are aligned to the minor axis and are centered on the 2980e5c31af7Sopenharmony_ciendpoints of the line as in <<fig-non-strict-lines>>, and each is 2981e5c31af7Sopenharmony_cipname:lineWidth long. 2982e5c31af7Sopenharmony_ciEdges 0 and 1 are parallel to the line and connect the endpoints of edges 2 2983e5c31af7Sopenharmony_ciand 3. 2984e5c31af7Sopenharmony_ciCoverage bits that correspond to sample points that intersect the 2985e5c31af7Sopenharmony_ciparallelogram are 1, other coverage bits are 0. 2986e5c31af7Sopenharmony_ci 2987e5c31af7Sopenharmony_ciSamples that fall exactly on the edge of the parallelogram follow the 2988e5c31af7Sopenharmony_cipolygon rasterization rules. 2989e5c31af7Sopenharmony_ci 2990e5c31af7Sopenharmony_ciInterpolation occurs as if the parallelogram was decomposed into two 2991e5c31af7Sopenharmony_citriangles where each pair of vertices at each end of the line has identical 2992e5c31af7Sopenharmony_ciattributes. 2993e5c31af7Sopenharmony_ci 2994e5c31af7Sopenharmony_ci[[fig-non-strict-lines]] 2995e5c31af7Sopenharmony_ciimage::{images}/non_strict_lines.svg[align="center",title="Non strict lines",opts="{imageopts}"] 2996e5c31af7Sopenharmony_ci 2997e5c31af7Sopenharmony_ciifndef::VK_IMG_relaxed_line_rasterization[Only when] 2998e5c31af7Sopenharmony_ciifdef::VK_IMG_relaxed_line_rasterization[When] 2999e5c31af7Sopenharmony_cipname:strictLines is ename:VK_FALSE 3000e5c31af7Sopenharmony_ciifdef::VK_IMG_relaxed_line_rasterization[] 3001e5c31af7Sopenharmony_cior when the <<features-relaxedLineRasterization, 3002e5c31af7Sopenharmony_cipname:relaxedLineRasterization>> feature is enabled, 3003e5c31af7Sopenharmony_ciifdef::VK_EXT_line_rasterization[] 3004e5c31af7Sopenharmony_ciand pname:lineRasterizationMode is 3005e5c31af7Sopenharmony_ciename:VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT 3006e5c31af7Sopenharmony_ciendif::VK_EXT_line_rasterization[] 3007e5c31af7Sopenharmony_ciendif::VK_IMG_relaxed_line_rasterization[] 3008e5c31af7Sopenharmony_ciimplementations may: deviate from the non-strict line algorithm described 3009e5c31af7Sopenharmony_ciabove in the following ways: 3010e5c31af7Sopenharmony_ci 3011e5c31af7Sopenharmony_ci * Implementations may: instead interpolate each fragment according to the 3012e5c31af7Sopenharmony_ci formula in <<primsrast-lines-basic, Basic Line Segment Rasterization>> 3013e5c31af7Sopenharmony_ci using the original line segment endpoints. 3014e5c31af7Sopenharmony_ci 3015e5c31af7Sopenharmony_ci * Rasterization of non-antialiased non-strict line segments may: be 3016e5c31af7Sopenharmony_ci performed using the rules defined in 3017e5c31af7Sopenharmony_ci <<primsrast-lines-bresenham,Bresenham Line Segment Rasterization>>. 3018e5c31af7Sopenharmony_ci 3019e5c31af7Sopenharmony_ciifdef::VK_KHR_maintenance5[] 3020e5c31af7Sopenharmony_ciIf 3021e5c31af7Sopenharmony_cisname:VkPhysicalDeviceMaintenance5PropertiesKHR::pname:nonStrictSinglePixelWideLinesUseParallelogram 3022e5c31af7Sopenharmony_ciis ename:VK_TRUE, 3023e5c31af7Sopenharmony_ciifdef::VK_EXT_line_rasterization[] 3024e5c31af7Sopenharmony_cithe pname:lineRasterizationMode is 3025e5c31af7Sopenharmony_ciename:VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT, 3026e5c31af7Sopenharmony_ciendif::VK_EXT_line_rasterization[] 3027e5c31af7Sopenharmony_ciand pname:strictLines is ename:VK_FALSE, non-strict lines of width 1.0 are 3028e5c31af7Sopenharmony_cirasterized as parallelograms, otherwise they are rasterized using 3029e5c31af7Sopenharmony_ciBresenham's algorithm. 3030e5c31af7Sopenharmony_ci 3031e5c31af7Sopenharmony_ciIf 3032e5c31af7Sopenharmony_cisname:VkPhysicalDeviceMaintenance5PropertiesKHR::pname:nonStrictWideLinesUseParallelogram 3033e5c31af7Sopenharmony_ciis ename:VK_TRUE, 3034e5c31af7Sopenharmony_ciifdef::VK_EXT_line_rasterization[] 3035e5c31af7Sopenharmony_cithe pname:lineRasterizationMode is 3036e5c31af7Sopenharmony_ciename:VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT, 3037e5c31af7Sopenharmony_ciendif::VK_EXT_line_rasterization[] 3038e5c31af7Sopenharmony_ciand pname:strictLines is ename:VK_FALSE, non-strict lines of width greater 3039e5c31af7Sopenharmony_cithan 1.0 are rasterized as parallelograms, otherwise they are rasterized 3040e5c31af7Sopenharmony_ciusing Bresenham's algorithm. 3041e5c31af7Sopenharmony_ciendif::VK_KHR_maintenance5[] 3042e5c31af7Sopenharmony_ci 3043e5c31af7Sopenharmony_ci[[primsrast-lines-bresenham]] 3044e5c31af7Sopenharmony_ci=== Bresenham Line Segment Rasterization 3045e5c31af7Sopenharmony_ci 3046e5c31af7Sopenharmony_ciifdef::VK_EXT_line_rasterization[] 3047e5c31af7Sopenharmony_ciIf pname:lineRasterizationMode is 3048e5c31af7Sopenharmony_ciename:VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT, then the following rules 3049e5c31af7Sopenharmony_cireplace the line rasterization rules defined in <<primsrast-lines-basic, 3050e5c31af7Sopenharmony_ciBasic Line Segment Rasterization>>. 3051e5c31af7Sopenharmony_ciendif::VK_EXT_line_rasterization[] 3052e5c31af7Sopenharmony_ci 3053e5c31af7Sopenharmony_ciNon-strict lines may: also follow these rasterization rules for 3054e5c31af7Sopenharmony_cinon-antialiased lines. 3055e5c31af7Sopenharmony_ci 3056e5c31af7Sopenharmony_ciifdef::VK_IMG_relaxed_line_rasterization[] 3057e5c31af7Sopenharmony_ciIf the <<features-relaxedLineRasterization, pname:relaxedLineRasterization>> 3058e5c31af7Sopenharmony_cifeature is enabled, 3059e5c31af7Sopenharmony_ciifdef::VK_EXT_line_rasterization[] 3060e5c31af7Sopenharmony_ciand pname:lineRasterizationMode is 3061e5c31af7Sopenharmony_ciename:VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT 3062e5c31af7Sopenharmony_ciendif::VK_EXT_line_rasterization[] 3063e5c31af7Sopenharmony_ciimplementations must: follow these rasterization rules for non-antialised 3064e5c31af7Sopenharmony_cilines of width 1.0. 3065e5c31af7Sopenharmony_ciendif::VK_IMG_relaxed_line_rasterization[] 3066e5c31af7Sopenharmony_ci 3067e5c31af7Sopenharmony_ciLine segment rasterization begins by characterizing the segment as either 3068e5c31af7Sopenharmony_ci_x-major_ or _y-major_. 3069e5c31af7Sopenharmony_cix-major line segments have slope in the closed interval [eq]#[-1,1]#; all 3070e5c31af7Sopenharmony_ciother line segments are y-major (slope is determined by the segment's 3071e5c31af7Sopenharmony_ciendpoints). 3072e5c31af7Sopenharmony_ciWe specify rasterization only for x-major segments except in cases where the 3073e5c31af7Sopenharmony_cimodifications for y-major segments are not self-evident. 3074e5c31af7Sopenharmony_ci 3075e5c31af7Sopenharmony_ciIdeally, Vulkan uses a _diamond-exit_ rule to determine those fragments that 3076e5c31af7Sopenharmony_ciare produced by rasterizing a line segment. 3077e5c31af7Sopenharmony_ciFor each fragment [eq]#f# with center at framebuffer coordinates [eq]#x~f~# 3078e5c31af7Sopenharmony_ciand [eq]#y~f~#, define a diamond-shaped region that is the intersection of 3079e5c31af7Sopenharmony_cifour half planes: 3080e5c31af7Sopenharmony_ci 3081e5c31af7Sopenharmony_ci[latexmath] 3082e5c31af7Sopenharmony_ci+++++++++++++++++++ 3083e5c31af7Sopenharmony_ci R_f = \{ (x,y) \mid | x - x_f | + | y - y_f | < \frac{1}{2} \} 3084e5c31af7Sopenharmony_ci+++++++++++++++++++ 3085e5c31af7Sopenharmony_ci 3086e5c31af7Sopenharmony_ciEssentially, a line segment starting at [eq]#p~a~# and ending at [eq]#p~b~# 3087e5c31af7Sopenharmony_ciproduces those fragments [eq]#f# for which the segment intersects 3088e5c31af7Sopenharmony_ci[eq]#R~f~#, except if [eq]#p~b~# is contained in [eq]#R~f~#. 3089e5c31af7Sopenharmony_ci 3090e5c31af7Sopenharmony_ciimage::{images}/bresenham.svg[title="Visualization of Bresenham's algorithm",align="center",opts="{imageopts}"] 3091e5c31af7Sopenharmony_ci 3092e5c31af7Sopenharmony_ciTo avoid difficulties when an endpoint lies on a boundary of [eq]#R~f~# we 3093e5c31af7Sopenharmony_ci(in principle) perturb the supplied endpoints by a tiny amount. 3094e5c31af7Sopenharmony_ciLet [eq]#p~a~# and [eq]#p~b~# have framebuffer coordinates [eq]#(x~a~, 3095e5c31af7Sopenharmony_ciy~a~)# and [eq]#(x~b~, y~b~)#, respectively. 3096e5c31af7Sopenharmony_ciObtain the perturbed endpoints [eq]#p~a~'# given by [eq]#(x~a~, y~a~) - 3097e5c31af7Sopenharmony_ci({epsilon}, {epsilon}^2^)# and [eq]#p~b~'# given by [eq]#(x~b~, y~b~) - 3098e5c31af7Sopenharmony_ci({epsilon}, {epsilon}^2^)#. 3099e5c31af7Sopenharmony_ciRasterizing the line segment starting at [eq]#p~a~# and ending at [eq]#p~b~# 3100e5c31af7Sopenharmony_ciproduces those fragments [eq]#f# for which the segment starting at 3101e5c31af7Sopenharmony_ci[eq]#p~a~'# and ending on [eq]#p~b~'# intersects [eq]#R~f~#, except if 3102e5c31af7Sopenharmony_ci[eq]#p~b~'# is contained in [eq]#R~f~#. 3103e5c31af7Sopenharmony_ci[eq]#{epsilon}# is chosen to be so small that rasterizing the line segment 3104e5c31af7Sopenharmony_ciproduces the same fragments when [eq]#{delta}# is substituted for 3105e5c31af7Sopenharmony_ci[eq]#{epsilon}# for any [eq]#0 < {delta} {leq} {epsilon}#. 3106e5c31af7Sopenharmony_ci 3107e5c31af7Sopenharmony_ciWhen [eq]#p~a~# and [eq]#p~b~# lie on fragment centers, this 3108e5c31af7Sopenharmony_cicharacterization of fragments reduces to Bresenham's algorithm with one 3109e5c31af7Sopenharmony_cimodification: lines produced in this description are "`half-open`", meaning 3110e5c31af7Sopenharmony_cithat the final fragment (corresponding to [eq]#p~b~#) is not drawn. 3111e5c31af7Sopenharmony_ciThis means that when rasterizing a series of connected line segments, shared 3112e5c31af7Sopenharmony_ciendpoints will be produced only once rather than twice (as would occur with 3113e5c31af7Sopenharmony_ciBresenham's algorithm). 3114e5c31af7Sopenharmony_ci 3115e5c31af7Sopenharmony_ciImplementations may: use other line segment rasterization algorithms, 3116e5c31af7Sopenharmony_cisubject to the following rules: 3117e5c31af7Sopenharmony_ci 3118e5c31af7Sopenharmony_ci * The coordinates of a fragment produced by the algorithm must: not 3119e5c31af7Sopenharmony_ci deviate by more than one unit in either x or y framebuffer coordinates 3120e5c31af7Sopenharmony_ci from a corresponding fragment produced by the diamond-exit rule. 3121e5c31af7Sopenharmony_ci * The total number of fragments produced by the algorithm must: not differ 3122e5c31af7Sopenharmony_ci from that produced by the diamond-exit rule by more than one. 3123e5c31af7Sopenharmony_ci * For an x-major line, two fragments that lie in the same 3124e5c31af7Sopenharmony_ci framebuffer-coordinate column must: not be produced (for a y-major line, 3125e5c31af7Sopenharmony_ci two fragments that lie in the same framebuffer-coordinate row must: not 3126e5c31af7Sopenharmony_ci be produced). 3127e5c31af7Sopenharmony_ci * If two line segments share a common endpoint, and both segments are 3128e5c31af7Sopenharmony_ci either x-major (both left-to-right or both right-to-left) or y-major 3129e5c31af7Sopenharmony_ci (both bottom-to-top or both top-to-bottom), then rasterizing both 3130e5c31af7Sopenharmony_ci segments must: not produce duplicate fragments. 3131e5c31af7Sopenharmony_ci Fragments also must: not be omitted so as to interrupt continuity of the 3132e5c31af7Sopenharmony_ci connected segments. 3133e5c31af7Sopenharmony_ci 3134e5c31af7Sopenharmony_ciThe actual width [eq]#w# of Bresenham lines is determined by rounding the 3135e5c31af7Sopenharmony_ciline width to the nearest integer, clamping it to the 3136e5c31af7Sopenharmony_ciimplementation-dependent pname:lineWidthRange (with both values rounded to 3137e5c31af7Sopenharmony_cithe nearest integer), then clamping it to be no less than 1. 3138e5c31af7Sopenharmony_ci 3139e5c31af7Sopenharmony_ciBresenham line segments of width other than one are rasterized by offsetting 3140e5c31af7Sopenharmony_cithem in the minor direction (for an x-major line, the minor direction is y, 3141e5c31af7Sopenharmony_ciand for a y-major line, the minor direction is x) and producing a row or 3142e5c31af7Sopenharmony_cicolumn of fragments in the minor direction. 3143e5c31af7Sopenharmony_ciIf the line segment has endpoints given by [eq]#(x~0~, y~0~)# and 3144e5c31af7Sopenharmony_ci[eq]#(x~1~, y~1~)# in framebuffer coordinates, the segment with endpoints 3145e5c31af7Sopenharmony_cilatexmath:[(x_0, y_0 - \frac{w-1}{2})] and latexmath:[(x_1, y_1 - 3146e5c31af7Sopenharmony_ci\frac{w-1}{2})] is rasterized, but instead of a single fragment, a column of 3147e5c31af7Sopenharmony_cifragments of height w (a row of fragments of length w for a y-major segment) 3148e5c31af7Sopenharmony_ciis produced at each x (y for y-major) location. 3149e5c31af7Sopenharmony_ciThe lowest fragment of this column is the fragment that would be produced by 3150e5c31af7Sopenharmony_cirasterizing the segment of width 1 with the modified coordinates. 3151e5c31af7Sopenharmony_ci 3152e5c31af7Sopenharmony_ciThe preferred method of attribute interpolation for a wide line is to 3153e5c31af7Sopenharmony_cigenerate the same attribute values for all fragments in the row or column 3154e5c31af7Sopenharmony_cidescribed above, as if the adjusted line was used for interpolation and 3155e5c31af7Sopenharmony_cithose values replicated to the other fragments, except for code:FragCoord 3156e5c31af7Sopenharmony_ciwhich is interpolated as usual. 3157e5c31af7Sopenharmony_ciImplementations may: instead interpolate each fragment according to the 3158e5c31af7Sopenharmony_ciformula in <<primsrast-lines-basic,Basic Line Segment Rasterization>>, using 3159e5c31af7Sopenharmony_cithe original line segment endpoints. 3160e5c31af7Sopenharmony_ci 3161e5c31af7Sopenharmony_ciWhen Bresenham lines are being rasterized, sample locations may: all be 3162e5c31af7Sopenharmony_citreated as being at the pixel center (this may: affect attribute and depth 3163e5c31af7Sopenharmony_ciinterpolation). 3164e5c31af7Sopenharmony_ci 3165e5c31af7Sopenharmony_ci[NOTE] 3166e5c31af7Sopenharmony_ci.Note 3167e5c31af7Sopenharmony_ci==== 3168e5c31af7Sopenharmony_ciThe sample locations described above are *not* used for determining 3169e5c31af7Sopenharmony_cicoverage, they are only used for things like attribute interpolation. 3170e5c31af7Sopenharmony_ciThe rasterization rules that determine coverage are defined in terms of 3171e5c31af7Sopenharmony_ciwhether the line intersects *pixels*, as opposed to the point sampling rules 3172e5c31af7Sopenharmony_ciused for other primitive types. 3173e5c31af7Sopenharmony_ciSo these rules are independent of the sample locations. 3174e5c31af7Sopenharmony_ciOne consequence of this is that Bresenham lines cover the same pixels 3175e5c31af7Sopenharmony_ciregardless of the number of rasterization samples, and cover all samples in 3176e5c31af7Sopenharmony_cithose pixels (unless masked out or killed). 3177e5c31af7Sopenharmony_ci==== 3178e5c31af7Sopenharmony_ci 3179e5c31af7Sopenharmony_ci 3180e5c31af7Sopenharmony_ciifdef::VK_EXT_line_rasterization[] 3181e5c31af7Sopenharmony_ci[[primsrast-lines-stipple]] 3182e5c31af7Sopenharmony_ci=== Line Stipple 3183e5c31af7Sopenharmony_ci 3184e5c31af7Sopenharmony_ciIf the pname:stippledLineEnable member of 3185e5c31af7Sopenharmony_cislink:VkPipelineRasterizationLineStateCreateInfoEXT is ename:VK_TRUE, then 3186e5c31af7Sopenharmony_cilines are rasterized with a _line stipple_ determined by 3187e5c31af7Sopenharmony_cipname:lineStippleFactor and pname:lineStipplePattern. 3188e5c31af7Sopenharmony_cipname:lineStipplePattern is an unsigned 16-bit integer that determines which 3189e5c31af7Sopenharmony_cifragments are to be drawn or discarded when the line is rasterized. 3190e5c31af7Sopenharmony_cipname:lineStippleFactor is a count that is used to modify the effective line 3191e5c31af7Sopenharmony_cistipple by causing each bit in pname:lineStipplePattern to be used 3192e5c31af7Sopenharmony_cipname:lineStippleFactor times. 3193e5c31af7Sopenharmony_ci 3194e5c31af7Sopenharmony_ciLine stippling discards certain fragments that are produced by 3195e5c31af7Sopenharmony_cirasterization. 3196e5c31af7Sopenharmony_ciThe masking is achieved using three parameters: the 16-bit line stipple 3197e5c31af7Sopenharmony_cipattern _p_, the line stipple factor _r_, and an integer stipple counter 3198e5c31af7Sopenharmony_ci_s_. 3199e5c31af7Sopenharmony_ciLet 3200e5c31af7Sopenharmony_ci 3201e5c31af7Sopenharmony_ci[latexmath] 3202e5c31af7Sopenharmony_ci+++++++++++++++++++ 3203e5c31af7Sopenharmony_cib = \left\lfloor \frac{s}{r} \right\rfloor \bmod 16 3204e5c31af7Sopenharmony_ci+++++++++++++++++++ 3205e5c31af7Sopenharmony_ci 3206e5c31af7Sopenharmony_ciThen a fragment is produced if the _b_'th bit of _p_ is 1, and discarded 3207e5c31af7Sopenharmony_ciotherwise. 3208e5c31af7Sopenharmony_ciThe bits of _p_ are numbered with 0 being the least significant and 15 being 3209e5c31af7Sopenharmony_cithe most significant. 3210e5c31af7Sopenharmony_ci 3211e5c31af7Sopenharmony_ciThe initial value of _s_ is zero. 3212e5c31af7Sopenharmony_ciFor ename:VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT lines, _s_ is incremented 3213e5c31af7Sopenharmony_ciafter production of each fragment of a line segment (fragments are produced 3214e5c31af7Sopenharmony_ciin order, beginning at the starting point and working towards the ending 3215e5c31af7Sopenharmony_cipoint). 3216e5c31af7Sopenharmony_ciFor ename:VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT and 3217e5c31af7Sopenharmony_ciename:VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT lines, the 3218e5c31af7Sopenharmony_cirectangular region is subdivided into adjacent unit-length rectangles, and s 3219e5c31af7Sopenharmony_ciis incremented once for each rectangle. 3220e5c31af7Sopenharmony_ciRectangles with a value of _s_ such that the _b_'th bit of _p_ is zero are 3221e5c31af7Sopenharmony_cidiscarded. 3222e5c31af7Sopenharmony_ciIf the last rectangle in a line segment is shorter than unit-length, then 3223e5c31af7Sopenharmony_cithe remainder may: carry over to the next line segment in the line strip 3224e5c31af7Sopenharmony_ciusing the same value of _s_ (this is the preferred behavior, for the stipple 3225e5c31af7Sopenharmony_cipattern to appear more consistent through the strip). 3226e5c31af7Sopenharmony_ci 3227e5c31af7Sopenharmony_ci_s_ is reset to 0 at the start of each strip (for line strips), and before 3228e5c31af7Sopenharmony_cievery line segment in a group of independent segments. 3229e5c31af7Sopenharmony_ci 3230e5c31af7Sopenharmony_ciIf the line segment has been clipped, then the value of _s_ at the beginning 3231e5c31af7Sopenharmony_ciof the line segment is implementation-dependent. 3232e5c31af7Sopenharmony_ci 3233e5c31af7Sopenharmony_ci[open,refpage='vkCmdSetLineStippleEXT',desc='Set line stipple dynamically for a command buffer',type='protos'] 3234e5c31af7Sopenharmony_ci-- 3235e5c31af7Sopenharmony_ciTo <<pipelines-dynamic-state, dynamically set>> the line stipple state, 3236e5c31af7Sopenharmony_cicall: 3237e5c31af7Sopenharmony_ci 3238e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCmdSetLineStippleEXT.adoc[] 3239e5c31af7Sopenharmony_ci 3240e5c31af7Sopenharmony_ci * pname:commandBuffer is the command buffer into which the command will be 3241e5c31af7Sopenharmony_ci recorded. 3242e5c31af7Sopenharmony_ci * pname:lineStippleFactor is the repeat factor used in stippled line 3243e5c31af7Sopenharmony_ci rasterization. 3244e5c31af7Sopenharmony_ci * pname:lineStipplePattern is the bit pattern used in stippled line 3245e5c31af7Sopenharmony_ci rasterization. 3246e5c31af7Sopenharmony_ci 3247e5c31af7Sopenharmony_ciThis command sets the line stipple state for subsequent drawing commands 3248e5c31af7Sopenharmony_ciifdef::VK_EXT_shader_object[when drawing using <<shaders-objects, shader objects>>, or] 3249e5c31af7Sopenharmony_ciwhen the graphics pipeline is created with 3250e5c31af7Sopenharmony_ciename:VK_DYNAMIC_STATE_LINE_STIPPLE_EXT set in 3251e5c31af7Sopenharmony_cislink:VkPipelineDynamicStateCreateInfo::pname:pDynamicStates. 3252e5c31af7Sopenharmony_ciOtherwise, this state is specified by the 3253e5c31af7Sopenharmony_cislink:VkPipelineRasterizationLineStateCreateInfoEXT::pname:lineStippleFactor 3254e5c31af7Sopenharmony_ciand 3255e5c31af7Sopenharmony_cislink:VkPipelineRasterizationLineStateCreateInfoEXT::pname:lineStipplePattern 3256e5c31af7Sopenharmony_civalues used to create the currently active pipeline. 3257e5c31af7Sopenharmony_ci 3258e5c31af7Sopenharmony_ci.Valid Usage 3259e5c31af7Sopenharmony_ci**** 3260e5c31af7Sopenharmony_ci * [[VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776]] 3261e5c31af7Sopenharmony_ci pname:lineStippleFactor must: be in the range [eq]#[1,256]# 3262e5c31af7Sopenharmony_ci**** 3263e5c31af7Sopenharmony_ci 3264e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkCmdSetLineStippleEXT.adoc[] 3265e5c31af7Sopenharmony_ci-- 3266e5c31af7Sopenharmony_ci 3267e5c31af7Sopenharmony_ci 3268e5c31af7Sopenharmony_ci[[primsrast-lines-smooth]] 3269e5c31af7Sopenharmony_ci=== Smooth Lines 3270e5c31af7Sopenharmony_ci 3271e5c31af7Sopenharmony_ciIf the pname:lineRasterizationMode member of 3272e5c31af7Sopenharmony_cislink:VkPipelineRasterizationLineStateCreateInfoEXT is 3273e5c31af7Sopenharmony_ciename:VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT, then lines are 3274e5c31af7Sopenharmony_ciconsidered to be rectangles using the same geometry as for 3275e5c31af7Sopenharmony_ciename:VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT lines. 3276e5c31af7Sopenharmony_ciThe rules for determining which pixels are covered are 3277e5c31af7Sopenharmony_ciimplementation-dependent, and may: include nearby pixels where no sample 3278e5c31af7Sopenharmony_cilocations are covered or where the rectangle does not intersect the pixel at 3279e5c31af7Sopenharmony_ciall. 3280e5c31af7Sopenharmony_ciFor each pixel that is considered covered, the fragment computes a coverage 3281e5c31af7Sopenharmony_civalue that approximates the area of the intersection of the rectangle with 3282e5c31af7Sopenharmony_cithe pixel square, and this coverage value is multiplied into the color 3283e5c31af7Sopenharmony_cilocation 0's alpha value after fragment shading, as described in 3284e5c31af7Sopenharmony_ci<<fragops-covg,Multisample Coverage>>. 3285e5c31af7Sopenharmony_ci 3286e5c31af7Sopenharmony_ci[NOTE] 3287e5c31af7Sopenharmony_ci.Note 3288e5c31af7Sopenharmony_ci==== 3289e5c31af7Sopenharmony_ciThe details of the rasterization rules and area calculation are left 3290e5c31af7Sopenharmony_ciintentionally vague, to allow implementations to generate coverage and 3291e5c31af7Sopenharmony_civalues that are aesthetically pleasing. 3292e5c31af7Sopenharmony_ci==== 3293e5c31af7Sopenharmony_ciendif::VK_EXT_line_rasterization[] 3294e5c31af7Sopenharmony_ci 3295e5c31af7Sopenharmony_ci 3296e5c31af7Sopenharmony_ci[[primsrast-polygons]] 3297e5c31af7Sopenharmony_ci== Polygons 3298e5c31af7Sopenharmony_ci 3299e5c31af7Sopenharmony_ciA polygon results from the decomposition of a triangle strip, triangle fan 3300e5c31af7Sopenharmony_cior a series of independent triangles. 3301e5c31af7Sopenharmony_ciLike points and line segments, polygon rasterization is controlled by 3302e5c31af7Sopenharmony_ciseveral variables in the slink:VkPipelineRasterizationStateCreateInfo 3303e5c31af7Sopenharmony_cistructure. 3304e5c31af7Sopenharmony_ci 3305e5c31af7Sopenharmony_ci 3306e5c31af7Sopenharmony_ci[[primsrast-polygons-basic]] 3307e5c31af7Sopenharmony_ci=== Basic Polygon Rasterization 3308e5c31af7Sopenharmony_ci 3309e5c31af7Sopenharmony_ci[open,refpage='VkFrontFace',desc='Interpret polygon front-facing orientation',type='enums'] 3310e5c31af7Sopenharmony_ci-- 3311e5c31af7Sopenharmony_ciThe first step of polygon rasterization is to determine whether the triangle 3312e5c31af7Sopenharmony_ciis _back-facing_ or _front-facing_. 3313e5c31af7Sopenharmony_ciThis determination is made based on the sign of the (clipped or unclipped) 3314e5c31af7Sopenharmony_cipolygon's area computed in framebuffer coordinates. 3315e5c31af7Sopenharmony_ciOne way to compute this area is: 3316e5c31af7Sopenharmony_ci 3317e5c31af7Sopenharmony_ci[latexmath] 3318e5c31af7Sopenharmony_ci++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3319e5c31af7Sopenharmony_cia = -{1 \over 2}\sum_{i=0}^{n-1} 3320e5c31af7Sopenharmony_ci x_f^i y_f^{i \oplus 1} - 3321e5c31af7Sopenharmony_ci x_f^{i \oplus 1} y_f^i 3322e5c31af7Sopenharmony_ci++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3323e5c31af7Sopenharmony_ci 3324e5c31af7Sopenharmony_ciwhere latexmath:[x_f^i] and latexmath:[y_f^i] are the [eq]#x# and [eq]#y# 3325e5c31af7Sopenharmony_ciframebuffer coordinates of the [eq]##i##th vertex of the [eq]#n#-vertex 3326e5c31af7Sopenharmony_cipolygon (vertices are numbered starting at zero for the purposes of this 3327e5c31af7Sopenharmony_cicomputation) and [eq]#i {oplus} 1# is [eq]#(i {plus} 1) mod n#. 3328e5c31af7Sopenharmony_ci 3329e5c31af7Sopenharmony_ciThe interpretation of the sign of [eq]#a# is determined by the 3330e5c31af7Sopenharmony_cislink:VkPipelineRasterizationStateCreateInfo::pname:frontFace property of 3331e5c31af7Sopenharmony_cithe currently active pipeline. 3332e5c31af7Sopenharmony_ciPossible values are: 3333e5c31af7Sopenharmony_ci 3334e5c31af7Sopenharmony_ciinclude::{generated}/api/enums/VkFrontFace.adoc[] 3335e5c31af7Sopenharmony_ci 3336e5c31af7Sopenharmony_ci * ename:VK_FRONT_FACE_COUNTER_CLOCKWISE specifies that a triangle with 3337e5c31af7Sopenharmony_ci positive area is considered front-facing. 3338e5c31af7Sopenharmony_ci * ename:VK_FRONT_FACE_CLOCKWISE specifies that a triangle with negative 3339e5c31af7Sopenharmony_ci area is considered front-facing. 3340e5c31af7Sopenharmony_ci 3341e5c31af7Sopenharmony_ciAny triangle which is not front-facing is back-facing, including zero-area 3342e5c31af7Sopenharmony_citriangles. 3343e5c31af7Sopenharmony_ci-- 3344e5c31af7Sopenharmony_ci 3345e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_3,VK_EXT_extended_dynamic_state,VK_EXT_shader_object[] 3346e5c31af7Sopenharmony_ci[open,refpage='vkCmdSetFrontFace',desc='Set front face orientation dynamically for a command buffer',type='protos',alias='vkCmdSetFrontFaceEXT'] 3347e5c31af7Sopenharmony_ci-- 3348e5c31af7Sopenharmony_ciTo <<pipelines-dynamic-state, dynamically set>> the front face orientation, 3349e5c31af7Sopenharmony_cicall: 3350e5c31af7Sopenharmony_ci 3351e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_3[] 3352e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCmdSetFrontFace.adoc[] 3353e5c31af7Sopenharmony_ci 3354e5c31af7Sopenharmony_ciifdef::VK_EXT_extended_dynamic_state,VK_EXT_shader_object[or the equivalent command] 3355e5c31af7Sopenharmony_ciendif::VK_VERSION_1_3[] 3356e5c31af7Sopenharmony_ci 3357e5c31af7Sopenharmony_ciifdef::VK_EXT_extended_dynamic_state,VK_EXT_shader_object[] 3358e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCmdSetFrontFaceEXT.adoc[] 3359e5c31af7Sopenharmony_ciendif::VK_EXT_extended_dynamic_state,VK_EXT_shader_object[] 3360e5c31af7Sopenharmony_ci 3361e5c31af7Sopenharmony_ci * pname:commandBuffer is the command buffer into which the command will be 3362e5c31af7Sopenharmony_ci recorded. 3363e5c31af7Sopenharmony_ci * pname:frontFace is a elink:VkFrontFace value specifying the front-facing 3364e5c31af7Sopenharmony_ci triangle orientation to be used for culling. 3365e5c31af7Sopenharmony_ci 3366e5c31af7Sopenharmony_ciThis command sets the front face orientation for subsequent drawing commands 3367e5c31af7Sopenharmony_ciifdef::VK_EXT_shader_object[] 3368e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_3,VK_EXT_extended_dynamic_state[when drawing using <<shaders-objects, shader objects>>, or] 3369e5c31af7Sopenharmony_ciifndef::VK_VERSION_1_3,VK_EXT_extended_dynamic_state[when drawing using <<shaders-objects, shader objects>>.] 3370e5c31af7Sopenharmony_ciendif::VK_EXT_shader_object[] 3371e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_3,VK_EXT_extended_dynamic_state[] 3372e5c31af7Sopenharmony_ciwhen the graphics pipeline is created with ename:VK_DYNAMIC_STATE_FRONT_FACE 3373e5c31af7Sopenharmony_ciset in slink:VkPipelineDynamicStateCreateInfo::pname:pDynamicStates. 3374e5c31af7Sopenharmony_ciendif::VK_VERSION_1_3,VK_EXT_extended_dynamic_state[] 3375e5c31af7Sopenharmony_ciOtherwise, this state is specified by the 3376e5c31af7Sopenharmony_cislink:VkPipelineRasterizationStateCreateInfo::pname:frontFace value used to 3377e5c31af7Sopenharmony_cicreate the currently active pipeline. 3378e5c31af7Sopenharmony_ci 3379e5c31af7Sopenharmony_ci:refpage: vkCmdSetFrontFace 3380e5c31af7Sopenharmony_ci 3381e5c31af7Sopenharmony_ci.Valid Usage 3382e5c31af7Sopenharmony_ci**** 3383e5c31af7Sopenharmony_ciinclude::{chapters}/commonvalidity/dynamic_state_feature_common.adoc[] 3384e5c31af7Sopenharmony_ci**** 3385e5c31af7Sopenharmony_ci 3386e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkCmdSetFrontFace.adoc[] 3387e5c31af7Sopenharmony_ci-- 3388e5c31af7Sopenharmony_ciendif::VK_VERSION_1_3,VK_EXT_extended_dynamic_state,VK_EXT_shader_object[] 3389e5c31af7Sopenharmony_ci 3390e5c31af7Sopenharmony_ci 3391e5c31af7Sopenharmony_ci[open,refpage='VkCullModeFlagBits',desc='Bitmask controlling triangle culling',type='enums'] 3392e5c31af7Sopenharmony_ci-- 3393e5c31af7Sopenharmony_ciOnce the orientation of triangles is determined, they are culled according 3394e5c31af7Sopenharmony_cito the slink:VkPipelineRasterizationStateCreateInfo::pname:cullMode property 3395e5c31af7Sopenharmony_ciof the currently active pipeline. 3396e5c31af7Sopenharmony_ciPossible values are: 3397e5c31af7Sopenharmony_ci 3398e5c31af7Sopenharmony_ciinclude::{generated}/api/enums/VkCullModeFlagBits.adoc[] 3399e5c31af7Sopenharmony_ci 3400e5c31af7Sopenharmony_ci * ename:VK_CULL_MODE_NONE specifies that no triangles are discarded 3401e5c31af7Sopenharmony_ci * ename:VK_CULL_MODE_FRONT_BIT specifies that front-facing triangles are 3402e5c31af7Sopenharmony_ci discarded 3403e5c31af7Sopenharmony_ci * ename:VK_CULL_MODE_BACK_BIT specifies that back-facing triangles are 3404e5c31af7Sopenharmony_ci discarded 3405e5c31af7Sopenharmony_ci * ename:VK_CULL_MODE_FRONT_AND_BACK specifies that all triangles are 3406e5c31af7Sopenharmony_ci discarded. 3407e5c31af7Sopenharmony_ci 3408e5c31af7Sopenharmony_ciFollowing culling, fragments are produced for any triangles which have not 3409e5c31af7Sopenharmony_cibeen discarded. 3410e5c31af7Sopenharmony_ci-- 3411e5c31af7Sopenharmony_ci 3412e5c31af7Sopenharmony_ci[open,refpage='VkCullModeFlags',desc='Bitmask of VkCullModeFlagBits',type='flags'] 3413e5c31af7Sopenharmony_ci-- 3414e5c31af7Sopenharmony_ciinclude::{generated}/api/flags/VkCullModeFlags.adoc[] 3415e5c31af7Sopenharmony_ci 3416e5c31af7Sopenharmony_citname:VkCullModeFlags is a bitmask type for setting a mask of zero or more 3417e5c31af7Sopenharmony_cielink:VkCullModeFlagBits. 3418e5c31af7Sopenharmony_ci-- 3419e5c31af7Sopenharmony_ci 3420e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_3,VK_EXT_extended_dynamic_state,VK_EXT_shader_object[] 3421e5c31af7Sopenharmony_ci[open,refpage='vkCmdSetCullMode',desc='Set cull mode dynamically for a command buffer',type='protos',alias='vkCmdSetCullModeEXT'] 3422e5c31af7Sopenharmony_ci-- 3423e5c31af7Sopenharmony_ciTo <<pipelines-dynamic-state, dynamically set>> the cull mode, call: 3424e5c31af7Sopenharmony_ci 3425e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_3[] 3426e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCmdSetCullMode.adoc[] 3427e5c31af7Sopenharmony_ci 3428e5c31af7Sopenharmony_ciifdef::VK_EXT_extended_dynamic_state,VK_EXT_shader_object[or the equivalent command] 3429e5c31af7Sopenharmony_ciendif::VK_VERSION_1_3[] 3430e5c31af7Sopenharmony_ci 3431e5c31af7Sopenharmony_ciifdef::VK_EXT_extended_dynamic_state,VK_EXT_shader_object[] 3432e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCmdSetCullModeEXT.adoc[] 3433e5c31af7Sopenharmony_ciendif::VK_EXT_extended_dynamic_state,VK_EXT_shader_object[] 3434e5c31af7Sopenharmony_ci 3435e5c31af7Sopenharmony_ci * pname:commandBuffer is the command buffer into which the command will be 3436e5c31af7Sopenharmony_ci recorded. 3437e5c31af7Sopenharmony_ci * pname:cullMode specifies the cull mode property to use for drawing. 3438e5c31af7Sopenharmony_ci 3439e5c31af7Sopenharmony_ciThis command sets the cull mode for subsequent drawing commands 3440e5c31af7Sopenharmony_ciifdef::VK_EXT_shader_object[] 3441e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_3,VK_EXT_extended_dynamic_state[when drawing using <<shaders-objects, shader objects>>, or] 3442e5c31af7Sopenharmony_ciifndef::VK_VERSION_1_3,VK_EXT_extended_dynamic_state[when drawing using <<shaders-objects, shader objects>>.] 3443e5c31af7Sopenharmony_ciendif::VK_EXT_shader_object[] 3444e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_3,VK_EXT_extended_dynamic_state[] 3445e5c31af7Sopenharmony_ciwhen the graphics pipeline is created with ename:VK_DYNAMIC_STATE_CULL_MODE 3446e5c31af7Sopenharmony_ciset in slink:VkPipelineDynamicStateCreateInfo::pname:pDynamicStates. 3447e5c31af7Sopenharmony_ciendif::VK_VERSION_1_3,VK_EXT_extended_dynamic_state[] 3448e5c31af7Sopenharmony_ciOtherwise, this state is specified by the 3449e5c31af7Sopenharmony_cislink:VkPipelineRasterizationStateCreateInfo::pname:cullMode value used to 3450e5c31af7Sopenharmony_cicreate the currently active pipeline. 3451e5c31af7Sopenharmony_ci 3452e5c31af7Sopenharmony_ci:refpage: vkCmdSetCullMode 3453e5c31af7Sopenharmony_ci 3454e5c31af7Sopenharmony_ci.Valid Usage 3455e5c31af7Sopenharmony_ci**** 3456e5c31af7Sopenharmony_ciinclude::{chapters}/commonvalidity/dynamic_state_feature_common.adoc[] 3457e5c31af7Sopenharmony_ci**** 3458e5c31af7Sopenharmony_ci 3459e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkCmdSetCullMode.adoc[] 3460e5c31af7Sopenharmony_ci-- 3461e5c31af7Sopenharmony_ciendif::VK_VERSION_1_3,VK_EXT_extended_dynamic_state,VK_EXT_shader_object[] 3462e5c31af7Sopenharmony_ci 3463e5c31af7Sopenharmony_ciThe rule for determining which fragments are produced by polygon 3464e5c31af7Sopenharmony_cirasterization is called _point sampling_. 3465e5c31af7Sopenharmony_ciThe two-dimensional projection obtained by taking the x and y framebuffer 3466e5c31af7Sopenharmony_cicoordinates of the polygon's vertices is formed. 3467e5c31af7Sopenharmony_ciFragments are produced for any fragment area groups of pixels for which any 3468e5c31af7Sopenharmony_cisample points lie inside of this polygon. 3469e5c31af7Sopenharmony_ciCoverage bits that correspond to sample points that satisfy the point 3470e5c31af7Sopenharmony_cisampling criteria are 1, other coverage bits are 0. 3471e5c31af7Sopenharmony_ciSpecial treatment is given to a sample whose sample location lies on a 3472e5c31af7Sopenharmony_cipolygon edge. 3473e5c31af7Sopenharmony_ciIn such a case, if two polygons lie on either side of a common edge (with 3474e5c31af7Sopenharmony_ciidentical endpoints) on which a sample point lies, then exactly one of the 3475e5c31af7Sopenharmony_cipolygons must: result in a covered sample for that fragment during 3476e5c31af7Sopenharmony_cirasterization. 3477e5c31af7Sopenharmony_ciAs for the data associated with each fragment produced by rasterizing a 3478e5c31af7Sopenharmony_cipolygon, we begin by specifying how these values are produced for fragments 3479e5c31af7Sopenharmony_ciin a triangle. 3480e5c31af7Sopenharmony_ci 3481e5c31af7Sopenharmony_ci[[primsrast-polygon-barycentrics]] 3482e5c31af7Sopenharmony_ci_Barycentric coordinates_ are a set of three numbers, [eq]#a#, [eq]#b#, and 3483e5c31af7Sopenharmony_ci[eq]#c#, each in the range [eq]#[0,1]#, with [eq]#a {plus} b {plus} c = 1#. 3484e5c31af7Sopenharmony_ciThese coordinates uniquely specify any point [eq]#p# within the triangle or 3485e5c31af7Sopenharmony_cion the triangle's boundary as 3486e5c31af7Sopenharmony_ci 3487e5c31af7Sopenharmony_ci {empty}:: [eq]#p = a p~a~ {plus} b p~b~ {plus} c p~c~# 3488e5c31af7Sopenharmony_ci 3489e5c31af7Sopenharmony_ciwhere [eq]#p~a~#, [eq]#p~b~#, and [eq]#p~c~# are the vertices of the 3490e5c31af7Sopenharmony_citriangle. 3491e5c31af7Sopenharmony_ci[eq]#a#, [eq]#b#, and [eq]#c# are determined by: 3492e5c31af7Sopenharmony_ci 3493e5c31af7Sopenharmony_ci[latexmath] 3494e5c31af7Sopenharmony_ci++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3495e5c31af7Sopenharmony_cia = {{\mathrm{A}(p p_b p_c)} \over {\mathrm{A}(p_a p_b p_c)}}, \quad 3496e5c31af7Sopenharmony_cib = {{\mathrm{A}(p p_a p_c)} \over {\mathrm{A}(p_a p_b p_c)}}, \quad 3497e5c31af7Sopenharmony_cic = {{\mathrm{A}(p p_a p_b)} \over {\mathrm{A}(p_a p_b p_c)}}, 3498e5c31af7Sopenharmony_ci++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3499e5c31af7Sopenharmony_ci 3500e5c31af7Sopenharmony_ciwhere [eq]#A(lmn)# denotes the area in framebuffer coordinates of the 3501e5c31af7Sopenharmony_citriangle with vertices [eq]#l#, [eq]#m#, and [eq]#n#. 3502e5c31af7Sopenharmony_ci 3503e5c31af7Sopenharmony_ciDenote an associated datum at [eq]#p~a~#, [eq]#p~b~#, or [eq]#p~c~# as 3504e5c31af7Sopenharmony_ci[eq]#f~a~#, [eq]#f~b~#, or [eq]#f~c~#, respectively. 3505e5c31af7Sopenharmony_ci 3506e5c31af7Sopenharmony_ci[[triangle_perspective_interpolation]] 3507e5c31af7Sopenharmony_ci_Perspective interpolation_ for a triangle interpolates three values in a 3508e5c31af7Sopenharmony_cimanner that is correct when taking the perspective of the viewport into 3509e5c31af7Sopenharmony_ciconsideration, by way of the triangle's clip coordinates. 3510e5c31af7Sopenharmony_ciAn interpolated value [eq]#f# can be determined by 3511e5c31af7Sopenharmony_ci 3512e5c31af7Sopenharmony_ci[latexmath] 3513e5c31af7Sopenharmony_ci++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3514e5c31af7Sopenharmony_cif = {{ a {f_a / w_a} + b {f_b / w_b} + c {f_c / w_c} } \over 3515e5c31af7Sopenharmony_ci { {a / w_a} + {b / w_b} + {c / w_c} }} 3516e5c31af7Sopenharmony_ci++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3517e5c31af7Sopenharmony_ci 3518e5c31af7Sopenharmony_ciwhere [eq]#w~a~#, [eq]#w~b~#, and [eq]#w~c~# are the clip [eq]#w# 3519e5c31af7Sopenharmony_cicoordinates of [eq]#p~a~#, [eq]#p~b~#, and [eq]#p~c~#, respectively. 3520e5c31af7Sopenharmony_ci[eq]#a#, [eq]#b#, and [eq]#c# are the barycentric coordinates of the 3521e5c31af7Sopenharmony_cilocation at which the data are produced. 3522e5c31af7Sopenharmony_ci 3523e5c31af7Sopenharmony_ci[[triangle_linear_interpolation]] 3524e5c31af7Sopenharmony_ci_Linear interpolation_ for a triangle directly interpolates three values, 3525e5c31af7Sopenharmony_ciand an interpolated value [eq]#f# can be determined by 3526e5c31af7Sopenharmony_ci 3527e5c31af7Sopenharmony_ci {empty}:: [eq]#f = a f~a~ {plus} b f~b~ {plus} c f~c~# 3528e5c31af7Sopenharmony_ci 3529e5c31af7Sopenharmony_ciwhere [eq]#f~a~#, [eq]#f~b~#, and [eq]#f~c~# are the data associated with 3530e5c31af7Sopenharmony_ci[eq]#p~a~#, [eq]#p~b~#, and [eq]#p~c~#, respectively. 3531e5c31af7Sopenharmony_ci 3532e5c31af7Sopenharmony_ciThe clip coordinate [eq]#w# for a sample is determined using perspective 3533e5c31af7Sopenharmony_ciinterpolation. 3534e5c31af7Sopenharmony_ciThe depth value [eq]#z# for a sample is determined using linear 3535e5c31af7Sopenharmony_ciinterpolation. 3536e5c31af7Sopenharmony_ciInterpolation of fragment shader input values are determined by 3537e5c31af7Sopenharmony_ci<<shaders-interpolation-decorations,Interpolation decorations>>. 3538e5c31af7Sopenharmony_ci 3539e5c31af7Sopenharmony_ciFor a polygon with more than three edges, such as are produced by clipping a 3540e5c31af7Sopenharmony_citriangle, a convex combination of the values of the datum at the polygon's 3541e5c31af7Sopenharmony_civertices must: be used to obtain the value assigned to each fragment 3542e5c31af7Sopenharmony_ciproduced by the rasterization algorithm. 3543e5c31af7Sopenharmony_ciThat is, it must: be the case that at every fragment 3544e5c31af7Sopenharmony_ci 3545e5c31af7Sopenharmony_ci[latexmath] 3546e5c31af7Sopenharmony_ci++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3547e5c31af7Sopenharmony_cif = \sum_{i=1}^{n} a_i f_i 3548e5c31af7Sopenharmony_ci++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3549e5c31af7Sopenharmony_ci 3550e5c31af7Sopenharmony_ciwhere [eq]#n# is the number of vertices in the polygon and [eq]#f~i~# is the 3551e5c31af7Sopenharmony_civalue of [eq]#f# at vertex [eq]#i#. 3552e5c31af7Sopenharmony_ciFor each [eq]#i#, [eq]#0 {leq} a~i~ {leq} 1# and 3553e5c31af7Sopenharmony_cilatexmath:[\sum_{i=1}^{n}a_i = 1]. 3554e5c31af7Sopenharmony_ciThe values of [eq]#a~i~# may: differ from fragment to fragment, but at 3555e5c31af7Sopenharmony_civertex [eq]#i#, [eq]#a~i~ = 1# and [eq]#a~j~ = 0# for [eq]#j {neq} i#. 3556e5c31af7Sopenharmony_ci 3557e5c31af7Sopenharmony_ci[NOTE] 3558e5c31af7Sopenharmony_ci.Note 3559e5c31af7Sopenharmony_ci==== 3560e5c31af7Sopenharmony_ciOne algorithm that achieves the required behavior is to triangulate a 3561e5c31af7Sopenharmony_cipolygon (without adding any vertices) and then treat each triangle 3562e5c31af7Sopenharmony_ciindividually as already discussed. 3563e5c31af7Sopenharmony_ciA scan-line rasterizer that linearly interpolates data along each edge and 3564e5c31af7Sopenharmony_cithen linearly interpolates data across each horizontal span from edge to 3565e5c31af7Sopenharmony_ciedge also satisfies the restrictions (in this case the numerator and 3566e5c31af7Sopenharmony_cidenominator of <<triangle_perspective_interpolation, perspective 3567e5c31af7Sopenharmony_ciinterpolation>> are iterated independently, and a division is performed for 3568e5c31af7Sopenharmony_cieach fragment). 3569e5c31af7Sopenharmony_ci==== 3570e5c31af7Sopenharmony_ci 3571e5c31af7Sopenharmony_ci 3572e5c31af7Sopenharmony_ci[[primsrast-polygonmode]] 3573e5c31af7Sopenharmony_ci=== Polygon Mode 3574e5c31af7Sopenharmony_ci 3575e5c31af7Sopenharmony_ci[open,refpage='VkPolygonMode',desc='Control polygon rasterization mode',type='enums'] 3576e5c31af7Sopenharmony_ci-- 3577e5c31af7Sopenharmony_ciPossible values of the 3578e5c31af7Sopenharmony_cislink:VkPipelineRasterizationStateCreateInfo::pname:polygonMode property of 3579e5c31af7Sopenharmony_cithe currently active pipeline, specifying the method of rasterization for 3580e5c31af7Sopenharmony_cipolygons, are: 3581e5c31af7Sopenharmony_ci 3582e5c31af7Sopenharmony_ciinclude::{generated}/api/enums/VkPolygonMode.adoc[] 3583e5c31af7Sopenharmony_ci 3584e5c31af7Sopenharmony_ci * ename:VK_POLYGON_MODE_POINT specifies that polygon vertices are drawn as 3585e5c31af7Sopenharmony_ci points. 3586e5c31af7Sopenharmony_ci * ename:VK_POLYGON_MODE_LINE specifies that polygon edges are drawn as 3587e5c31af7Sopenharmony_ci line segments. 3588e5c31af7Sopenharmony_ci * ename:VK_POLYGON_MODE_FILL specifies that polygons are rendered using 3589e5c31af7Sopenharmony_ci the polygon rasterization rules in this section. 3590e5c31af7Sopenharmony_ciifdef::VK_NV_fill_rectangle[] 3591e5c31af7Sopenharmony_ci * ename:VK_POLYGON_MODE_FILL_RECTANGLE_NV specifies that polygons are 3592e5c31af7Sopenharmony_ci rendered using polygon rasterization rules, modified to consider a 3593e5c31af7Sopenharmony_ci sample within the primitive if the sample location is inside the 3594e5c31af7Sopenharmony_ci axis-aligned bounding box of the triangle after projection. 3595e5c31af7Sopenharmony_ci Note that the barycentric weights used in attribute interpolation can: 3596e5c31af7Sopenharmony_ci extend outside the range [eq]#[0,1]# when these primitives are shaded. 3597e5c31af7Sopenharmony_ci Special treatment is given to a sample position on the boundary edge of 3598e5c31af7Sopenharmony_ci the bounding box. 3599e5c31af7Sopenharmony_ci In such a case, if two rectangles lie on either side of a common edge 3600e5c31af7Sopenharmony_ci (with identical endpoints) on which a sample position lies, then exactly 3601e5c31af7Sopenharmony_ci one of the triangles must: produce a fragment that covers that sample 3602e5c31af7Sopenharmony_ci during rasterization. 3603e5c31af7Sopenharmony_ci+ 3604e5c31af7Sopenharmony_ciPolygons rendered in ename:VK_POLYGON_MODE_FILL_RECTANGLE_NV mode may: be 3605e5c31af7Sopenharmony_ciclipped by the frustum or by user clip planes. 3606e5c31af7Sopenharmony_ciIf clipping is applied, the triangle is culled rather than clipped. 3607e5c31af7Sopenharmony_ci+ 3608e5c31af7Sopenharmony_ciArea calculation and facingness are determined for 3609e5c31af7Sopenharmony_ciename:VK_POLYGON_MODE_FILL_RECTANGLE_NV mode using the triangle's vertices. 3610e5c31af7Sopenharmony_ciendif::VK_NV_fill_rectangle[] 3611e5c31af7Sopenharmony_ci 3612e5c31af7Sopenharmony_ciThese modes affect only the final rasterization of polygons: in particular, 3613e5c31af7Sopenharmony_cia polygon's vertices are shaded and the polygon is clipped and possibly 3614e5c31af7Sopenharmony_ciculled before these modes are applied. 3615e5c31af7Sopenharmony_ci 3616e5c31af7Sopenharmony_ciifndef::VK_KHR_maintenance5[] 3617e5c31af7Sopenharmony_ciThe point size of the final rasterization of polygons when 3618e5c31af7Sopenharmony_ci<<primsrast-polygonmode, polygon mode>> is ename:VK_POLYGON_MODE_POINT is 3619e5c31af7Sopenharmony_ciimplementation-dependent, and the point size may: either be code:PointSize 3620e5c31af7Sopenharmony_cior 1.0. 3621e5c31af7Sopenharmony_ciendif::VK_KHR_maintenance5[] 3622e5c31af7Sopenharmony_ciifdef::VK_KHR_maintenance5[] 3623e5c31af7Sopenharmony_ciIf 3624e5c31af7Sopenharmony_cisname:VkPhysicalDeviceMaintenance5PropertiesKHR::pname:polygonModePointSize 3625e5c31af7Sopenharmony_ciis set to ename:VK_TRUE, the point size of the final rasterization of 3626e5c31af7Sopenharmony_cipolygons is taken from code:PointSize when <<primsrast-polygonmode, polygon 3627e5c31af7Sopenharmony_cimode>> is ename:VK_POLYGON_MODE_POINT. 3628e5c31af7Sopenharmony_ci 3629e5c31af7Sopenharmony_ciOtherwise, if 3630e5c31af7Sopenharmony_cisname:VkPhysicalDeviceMaintenance5PropertiesKHR::pname:polygonModePointSize 3631e5c31af7Sopenharmony_ciis set to ename:VK_FALSE, the point size of the final rasterization of 3632e5c31af7Sopenharmony_cipolygons is 1.0 when <<primsrast-polygonmode, polygon mode>> is 3633e5c31af7Sopenharmony_ciename:VK_POLYGON_MODE_POINT. 3634e5c31af7Sopenharmony_ciendif::VK_KHR_maintenance5[] 3635e5c31af7Sopenharmony_ci-- 3636e5c31af7Sopenharmony_ci 3637e5c31af7Sopenharmony_ciifdef::VK_EXT_extended_dynamic_state3,VK_EXT_shader_object[] 3638e5c31af7Sopenharmony_ci 3639e5c31af7Sopenharmony_ci[open,refpage='vkCmdSetPolygonModeEXT',desc='Specify polygon mode dynamically for a command buffer',type='protos'] 3640e5c31af7Sopenharmony_ci-- 3641e5c31af7Sopenharmony_ciTo <<pipelines-dynamic-state, dynamically set>> the polygon mode, call: 3642e5c31af7Sopenharmony_ci 3643e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCmdSetPolygonModeEXT.adoc[] 3644e5c31af7Sopenharmony_ci 3645e5c31af7Sopenharmony_ci * pname:commandBuffer is the command buffer into which the command will be 3646e5c31af7Sopenharmony_ci recorded. 3647e5c31af7Sopenharmony_ci * pname:polygonMode specifies polygon mode. 3648e5c31af7Sopenharmony_ci 3649e5c31af7Sopenharmony_ciThis command sets the polygon mode for subsequent drawing commands 3650e5c31af7Sopenharmony_ciifdef::VK_EXT_shader_object[] 3651e5c31af7Sopenharmony_ciifdef::VK_EXT_extended_dynamic_state3[when drawing using <<shaders-objects, shader objects>>, or] 3652e5c31af7Sopenharmony_ciifndef::VK_EXT_extended_dynamic_state3[when drawing using <<shaders-objects, shader objects>>.] 3653e5c31af7Sopenharmony_ciendif::VK_EXT_shader_object[] 3654e5c31af7Sopenharmony_ciifdef::VK_EXT_extended_dynamic_state3[] 3655e5c31af7Sopenharmony_ciwhen the graphics pipeline is created with 3656e5c31af7Sopenharmony_ciename:VK_DYNAMIC_STATE_POLYGON_MODE_EXT set in 3657e5c31af7Sopenharmony_cislink:VkPipelineDynamicStateCreateInfo::pname:pDynamicStates. 3658e5c31af7Sopenharmony_ciendif::VK_EXT_extended_dynamic_state3[] 3659e5c31af7Sopenharmony_ciOtherwise, this state is specified by the 3660e5c31af7Sopenharmony_cislink:VkPipelineRasterizationStateCreateInfo::pname:polygonMode value used 3661e5c31af7Sopenharmony_cito create the currently active pipeline. 3662e5c31af7Sopenharmony_ci 3663e5c31af7Sopenharmony_ci:refpage: vkCmdSetPolygonModeEXT 3664e5c31af7Sopenharmony_ci:requiredfeature: extendedDynamicState3PolygonMode 3665e5c31af7Sopenharmony_ci 3666e5c31af7Sopenharmony_ci.Valid Usage 3667e5c31af7Sopenharmony_ci**** 3668e5c31af7Sopenharmony_ciinclude::{chapters}/commonvalidity/dynamic_state3_feature_common.adoc[] 3669e5c31af7Sopenharmony_ci * [[VUID-vkCmdSetPolygonModeEXT-fillModeNonSolid-07424]] 3670e5c31af7Sopenharmony_ci If the <<features-fillModeNonSolid, pname:fillModeNonSolid>> feature is 3671e5c31af7Sopenharmony_ci not enabled, pname:polygonMode must: be ename:VK_POLYGON_MODE_FILL 3672e5c31af7Sopenharmony_ciifdef::VK_NV_fill_rectangle[or ename:VK_POLYGON_MODE_FILL_RECTANGLE_NV] 3673e5c31af7Sopenharmony_ciifdef::VK_NV_fill_rectangle[] 3674e5c31af7Sopenharmony_ci * [[VUID-vkCmdSetPolygonModeEXT-polygonMode-07425]] 3675e5c31af7Sopenharmony_ci If the `apiext:VK_NV_fill_rectangle` extension is not enabled, 3676e5c31af7Sopenharmony_ci pname:polygonMode must: not be ename:VK_POLYGON_MODE_FILL_RECTANGLE_NV 3677e5c31af7Sopenharmony_ciendif::VK_NV_fill_rectangle[] 3678e5c31af7Sopenharmony_ci**** 3679e5c31af7Sopenharmony_ci 3680e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkCmdSetPolygonModeEXT.adoc[] 3681e5c31af7Sopenharmony_ci-- 3682e5c31af7Sopenharmony_ci 3683e5c31af7Sopenharmony_ciendif::VK_EXT_extended_dynamic_state3,VK_EXT_shader_object[] 3684e5c31af7Sopenharmony_ci 3685e5c31af7Sopenharmony_ci 3686e5c31af7Sopenharmony_ci[[primsrast-depthbias]] 3687e5c31af7Sopenharmony_ci=== Depth Bias 3688e5c31af7Sopenharmony_ci 3689e5c31af7Sopenharmony_ciThe depth values of all fragments generated by the rasterization of a 3690e5c31af7Sopenharmony_cipolygon can: be biased (offset) by a single depth bias value latexmath:[o] 3691e5c31af7Sopenharmony_cithat is computed for that polygon. 3692e5c31af7Sopenharmony_ci 3693e5c31af7Sopenharmony_ci 3694e5c31af7Sopenharmony_ci[[primsrast-depthbias-enable]] 3695e5c31af7Sopenharmony_ci==== Depth Bias Enable 3696e5c31af7Sopenharmony_ci 3697e5c31af7Sopenharmony_ciThe depth bias computation is enabled by the 3698e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_3,VK_EXT_extended_dynamic_state2[] 3699e5c31af7Sopenharmony_cipname:depthBiasEnable set with flink:vkCmdSetDepthBiasEnable 3700e5c31af7Sopenharmony_ciifdef::VK_EXT_extended_dynamic_state2[] 3701e5c31af7Sopenharmony_ciand fname:vkCmdSetDepthBiasEnableEXT, 3702e5c31af7Sopenharmony_ciendif::VK_EXT_extended_dynamic_state2[] 3703e5c31af7Sopenharmony_cior the corresponding 3704e5c31af7Sopenharmony_ciendif::VK_VERSION_1_3,VK_EXT_extended_dynamic_state2[] 3705e5c31af7Sopenharmony_cislink:VkPipelineRasterizationStateCreateInfo::pname:depthBiasEnable value 3706e5c31af7Sopenharmony_ciused to create the currently active pipeline. 3707e5c31af7Sopenharmony_ciIf the depth bias enable is ename:VK_FALSE, no bias is applied and the 3708e5c31af7Sopenharmony_cifragment's depth values are unchanged. 3709e5c31af7Sopenharmony_ci 3710e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_3,VK_EXT_extended_dynamic_state2,VK_EXT_shader_object[] 3711e5c31af7Sopenharmony_ci[open,refpage='vkCmdSetDepthBiasEnable',desc='Control whether to bias fragment depth values dynamically for a command buffer',type='protos',alias='vkCmdSetDepthBiasEnableEXT'] 3712e5c31af7Sopenharmony_ci-- 3713e5c31af7Sopenharmony_ciTo <<pipelines-dynamic-state, dynamically enable>> whether to bias fragment 3714e5c31af7Sopenharmony_cidepth values, call: 3715e5c31af7Sopenharmony_ci 3716e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_3[] 3717e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCmdSetDepthBiasEnable.adoc[] 3718e5c31af7Sopenharmony_ci 3719e5c31af7Sopenharmony_ciifdef::VK_EXT_extended_dynamic_state2,VK_EXT_shader_object[or the equivalent command] 3720e5c31af7Sopenharmony_ciendif::VK_VERSION_1_3[] 3721e5c31af7Sopenharmony_ci 3722e5c31af7Sopenharmony_ciifdef::VK_EXT_extended_dynamic_state2,VK_EXT_shader_object[] 3723e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCmdSetDepthBiasEnableEXT.adoc[] 3724e5c31af7Sopenharmony_ciendif::VK_EXT_extended_dynamic_state2,VK_EXT_shader_object[] 3725e5c31af7Sopenharmony_ci 3726e5c31af7Sopenharmony_ci * pname:commandBuffer is the command buffer into which the command will be 3727e5c31af7Sopenharmony_ci recorded. 3728e5c31af7Sopenharmony_ci * pname:depthBiasEnable controls whether to bias fragment depth values. 3729e5c31af7Sopenharmony_ci 3730e5c31af7Sopenharmony_ciThis command sets the depth bias enable for subsequent drawing commands 3731e5c31af7Sopenharmony_ciifdef::VK_EXT_shader_object[] 3732e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_3,VK_EXT_extended_dynamic_state2[when drawing using <<shaders-objects, shader objects>>, or] 3733e5c31af7Sopenharmony_ciifndef::VK_VERSION_1_3,VK_EXT_extended_dynamic_state2[when drawing using <<shaders-objects, shader objects>>.] 3734e5c31af7Sopenharmony_ciendif::VK_EXT_shader_object[] 3735e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_3,VK_EXT_extended_dynamic_state2[] 3736e5c31af7Sopenharmony_ciwhen the graphics pipeline is created with 3737e5c31af7Sopenharmony_ciename:VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE set in 3738e5c31af7Sopenharmony_cislink:VkPipelineDynamicStateCreateInfo::pname:pDynamicStates. 3739e5c31af7Sopenharmony_ciendif::VK_VERSION_1_3,VK_EXT_extended_dynamic_state2[] 3740e5c31af7Sopenharmony_ciOtherwise, this state is specified by the 3741e5c31af7Sopenharmony_cislink:VkPipelineRasterizationStateCreateInfo::pname:depthBiasEnable value 3742e5c31af7Sopenharmony_ciused to create the currently active pipeline. 3743e5c31af7Sopenharmony_ci 3744e5c31af7Sopenharmony_ci:refpage: vkCmdSetDepthBiasEnable 3745e5c31af7Sopenharmony_ci 3746e5c31af7Sopenharmony_ci.Valid Usage 3747e5c31af7Sopenharmony_ci**** 3748e5c31af7Sopenharmony_ciinclude::{chapters}/commonvalidity/dynamic_state2_feature_common.adoc[] 3749e5c31af7Sopenharmony_ci**** 3750e5c31af7Sopenharmony_ci 3751e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkCmdSetDepthBiasEnable.adoc[] 3752e5c31af7Sopenharmony_ci-- 3753e5c31af7Sopenharmony_ciendif::VK_VERSION_1_3,VK_EXT_extended_dynamic_state2,VK_EXT_shader_object[] 3754e5c31af7Sopenharmony_ci 3755e5c31af7Sopenharmony_ci 3756e5c31af7Sopenharmony_ci[[primsrast-depthbias-computation]] 3757e5c31af7Sopenharmony_ci==== Depth Bias Computation 3758e5c31af7Sopenharmony_ci 3759e5c31af7Sopenharmony_ciThe depth bias depends on three parameters: 3760e5c31af7Sopenharmony_ci 3761e5c31af7Sopenharmony_ci * pname:depthBiasSlopeFactor scales the maximum depth slope [eq]#m# of the 3762e5c31af7Sopenharmony_ci polygon 3763e5c31af7Sopenharmony_ci * pname:depthBiasConstantFactor scales the parameter [eq]#r# of the depth 3764e5c31af7Sopenharmony_ci attachment 3765e5c31af7Sopenharmony_ci * the scaled terms are summed to produce a value which is then clamped to 3766e5c31af7Sopenharmony_ci a minimum or maximum value specified by pname:depthBiasClamp 3767e5c31af7Sopenharmony_ci 3768e5c31af7Sopenharmony_cipname:depthBiasSlopeFactor, pname:depthBiasConstantFactor, and 3769e5c31af7Sopenharmony_cipname:depthBiasClamp can: each be positive, negative, or zero. 3770e5c31af7Sopenharmony_ciThese parameters are set as described for flink:vkCmdSetDepthBias 3771e5c31af7Sopenharmony_ciifdef::VK_EXT_depth_bias_control[] 3772e5c31af7Sopenharmony_ciand flink:vkCmdSetDepthBias2EXT 3773e5c31af7Sopenharmony_ciendif::VK_EXT_depth_bias_control[] 3774e5c31af7Sopenharmony_cibelow. 3775e5c31af7Sopenharmony_ci 3776e5c31af7Sopenharmony_ciThe maximum depth slope [eq]#m# of a triangle is 3777e5c31af7Sopenharmony_ci 3778e5c31af7Sopenharmony_ci[latexmath] 3779e5c31af7Sopenharmony_ci++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3780e5c31af7Sopenharmony_cim = \sqrt{ \left({{\partial z_f} \over {\partial x_f}}\right)^2 3781e5c31af7Sopenharmony_ci + \left({{\partial z_f} \over {\partial y_f}}\right)^2} 3782e5c31af7Sopenharmony_ci++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3783e5c31af7Sopenharmony_ci 3784e5c31af7Sopenharmony_ciwhere [eq]#(x~f~, y~f~, z~f~)# is a point on the triangle. 3785e5c31af7Sopenharmony_ci[eq]#m# may: be approximated as 3786e5c31af7Sopenharmony_ci 3787e5c31af7Sopenharmony_ci[latexmath] 3788e5c31af7Sopenharmony_ci++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3789e5c31af7Sopenharmony_cim = \max\left( \left| { {\partial z_f} \over {\partial x_f} } \right|, 3790e5c31af7Sopenharmony_ci \left| { {\partial z_f} \over {\partial y_f} } \right| 3791e5c31af7Sopenharmony_ci \right). 3792e5c31af7Sopenharmony_ci++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3793e5c31af7Sopenharmony_ci 3794e5c31af7Sopenharmony_ciifdef::VK_EXT_depth_bias_control[] 3795e5c31af7Sopenharmony_ciIn a pipeline with a depth bias representation of 3796e5c31af7Sopenharmony_ciename:VK_DEPTH_BIAS_REPRESENTATION_FLOAT_EXT, [eq]#r#, for the given 3797e5c31af7Sopenharmony_ciprimitive is defined as 3798e5c31af7Sopenharmony_ci 3799e5c31af7Sopenharmony_ci {empty}:: [eq]#r = 1# 3800e5c31af7Sopenharmony_ci 3801e5c31af7Sopenharmony_ci 3802e5c31af7Sopenharmony_ciOtherwise 3803e5c31af7Sopenharmony_ciendif::VK_EXT_depth_bias_control[] 3804e5c31af7Sopenharmony_ci[eq]#r# is the minimum resolvable difference that depends on the depth 3805e5c31af7Sopenharmony_ciattachment representation. 3806e5c31af7Sopenharmony_ciifdef::VK_EXT_depth_bias_control[] 3807e5c31af7Sopenharmony_ciIf sname:VkDepthBiasRepresentationInfoEXT::pname:depthBiasExact is 3808e5c31af7Sopenharmony_ciename:VK_FALSE it 3809e5c31af7Sopenharmony_ciendif::VK_EXT_depth_bias_control[] 3810e5c31af7Sopenharmony_ciifndef::VK_EXT_depth_bias_control[It] 3811e5c31af7Sopenharmony_ciis the smallest difference in framebuffer coordinate [eq]#z# values that is 3812e5c31af7Sopenharmony_ciguaranteed to remain distinct throughout polygon rasterization and in the 3813e5c31af7Sopenharmony_cidepth attachment. 3814e5c31af7Sopenharmony_ciAll pairs of fragments generated by the rasterization of two polygons with 3815e5c31af7Sopenharmony_ciotherwise identical vertices, but [eq]#pname:z~f~# values that differ by 3816e5c31af7Sopenharmony_ci[eq]#r#, will have distinct depth values. 3817e5c31af7Sopenharmony_ci 3818e5c31af7Sopenharmony_ciFor fixed-point depth attachment representations, 3819e5c31af7Sopenharmony_ciifdef::VK_EXT_depth_bias_control[] 3820e5c31af7Sopenharmony_cior in a pipeline with a depth bias representation of 3821e5c31af7Sopenharmony_ciename:VK_DEPTH_BIAS_REPRESENTATION_LEAST_REPRESENTABLE_VALUE_FORCE_UNORM_EXT, 3822e5c31af7Sopenharmony_ciendif::VK_EXT_depth_bias_control[] 3823e5c31af7Sopenharmony_ci[eq]#r# is constant throughout the range of the entire depth attachment. 3824e5c31af7Sopenharmony_ciifdef::VK_EXT_depth_bias_control[] 3825e5c31af7Sopenharmony_ciIf sname:VkDepthBiasRepresentationInfoEXT::pname:depthBiasExact is 3826e5c31af7Sopenharmony_ciename:VK_TRUE, then its value must: be 3827e5c31af7Sopenharmony_ci 3828e5c31af7Sopenharmony_ci {empty}:: [eq]#r = 2^-n^# 3829e5c31af7Sopenharmony_ci 3830e5c31af7Sopenharmony_ciOtherwise its value is implementation-dependent but must: be at most 3831e5c31af7Sopenharmony_ciendif::VK_EXT_depth_bias_control[] 3832e5c31af7Sopenharmony_ciifndef::VK_EXT_depth_bias_control[] 3833e5c31af7Sopenharmony_ciIts value is implementation-dependent but must: be at most 3834e5c31af7Sopenharmony_ciendif::VK_EXT_depth_bias_control[] 3835e5c31af7Sopenharmony_ci 3836e5c31af7Sopenharmony_ci {empty}:: [eq]#r = 2 {times} 2^-n^# 3837e5c31af7Sopenharmony_ci 3838e5c31af7Sopenharmony_ciwhere [eq]#n# is the number of bits used for the depth 3839e5c31af7Sopenharmony_ciifndef::VK_EXT_depth_bias_control[aspect.] 3840e5c31af7Sopenharmony_ciifdef::VK_EXT_depth_bias_control[] 3841e5c31af7Sopenharmony_ciaspect when using a fixed-point attachment, or the number of mantissa bits 3842e5c31af7Sopenharmony_ciplus one when using a floating-point attachment. 3843e5c31af7Sopenharmony_ciendif::VK_EXT_depth_bias_control[] 3844e5c31af7Sopenharmony_ci 3845e5c31af7Sopenharmony_ci 3846e5c31af7Sopenharmony_ciifdef::VK_EXT_depth_bias_control[Otherwise for] 3847e5c31af7Sopenharmony_ciifndef::VK_EXT_depth_bias_control[For] 3848e5c31af7Sopenharmony_cifloating-point depth attachment, there is no single minimum resolvable 3849e5c31af7Sopenharmony_cidifference. 3850e5c31af7Sopenharmony_ciIn this case, the minimum resolvable difference for a given polygon is 3851e5c31af7Sopenharmony_cidependent on the maximum exponent, [eq]#e#, in the range of [eq]#z# values 3852e5c31af7Sopenharmony_cispanned by the primitive. 3853e5c31af7Sopenharmony_ciIf [eq]#n# is the number of bits in the floating-point mantissa, the minimum 3854e5c31af7Sopenharmony_ciresolvable difference, [eq]#r#, for the given primitive is defined as 3855e5c31af7Sopenharmony_ci 3856e5c31af7Sopenharmony_ci {empty}:: [eq]#r = 2^e-n^# 3857e5c31af7Sopenharmony_ci 3858e5c31af7Sopenharmony_ciifdef::VK_NV_fill_rectangle[] 3859e5c31af7Sopenharmony_ciIf a triangle is rasterized using the 3860e5c31af7Sopenharmony_ciename:VK_POLYGON_MODE_FILL_RECTANGLE_NV polygon mode, then this minimum 3861e5c31af7Sopenharmony_ciresolvable difference may: not be resolvable for samples outside of the 3862e5c31af7Sopenharmony_citriangle, where the depth is extrapolated. 3863e5c31af7Sopenharmony_ciendif::VK_NV_fill_rectangle[] 3864e5c31af7Sopenharmony_ci 3865e5c31af7Sopenharmony_ciIf no depth attachment is present, [eq]#r# is undefined:. 3866e5c31af7Sopenharmony_ci 3867e5c31af7Sopenharmony_ciThe bias value [eq]#o# for a polygon is 3868e5c31af7Sopenharmony_ci 3869e5c31af7Sopenharmony_ci[latexmath] 3870e5c31af7Sopenharmony_ci++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3871e5c31af7Sopenharmony_ci\begin{aligned} 3872e5c31af7Sopenharmony_cio &= \mathrm{dbclamp}( m \times \mathtt{depthBiasSlopeFactor} + r \times \mathtt{depthBiasConstantFactor} ) \\ 3873e5c31af7Sopenharmony_ci\text{where} &\quad \mathrm{dbclamp}(x) = 3874e5c31af7Sopenharmony_ci\begin{cases} 3875e5c31af7Sopenharmony_ci x & \mathtt{depthBiasClamp} = 0 \ \text{or}\ \texttt{NaN} \\ 3876e5c31af7Sopenharmony_ci \min(x, \mathtt{depthBiasClamp}) & \mathtt{depthBiasClamp} > 0 \\ 3877e5c31af7Sopenharmony_ci \max(x, \mathtt{depthBiasClamp}) & \mathtt{depthBiasClamp} < 0 \\ 3878e5c31af7Sopenharmony_ci\end{cases} 3879e5c31af7Sopenharmony_ci\end{aligned} 3880e5c31af7Sopenharmony_ci++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3881e5c31af7Sopenharmony_ci 3882e5c31af7Sopenharmony_ci[eq]#m# is computed as described above. 3883e5c31af7Sopenharmony_ciIf the depth attachment uses a fixed-point representation, [eq]#m# is a 3884e5c31af7Sopenharmony_cifunction of depth values in the range [eq]#[0,1]#, and [eq]#o# is applied to 3885e5c31af7Sopenharmony_cidepth values in the same range. 3886e5c31af7Sopenharmony_ci 3887e5c31af7Sopenharmony_ciDepth bias is applied to triangle topology primitives received by the 3888e5c31af7Sopenharmony_cirasterizer regardless of <<primsrast-polygonmode, polygon mode>>. 3889e5c31af7Sopenharmony_ciDepth bias may: also be applied to line and point topology primitives 3890e5c31af7Sopenharmony_cireceived by the rasterizer. 3891e5c31af7Sopenharmony_ci 3892e5c31af7Sopenharmony_ci[open,refpage='vkCmdSetDepthBias',desc='Set depth bias factors and clamp dynamically for a command buffer',type='protos'] 3893e5c31af7Sopenharmony_ci-- 3894e5c31af7Sopenharmony_ciTo <<pipelines-dynamic-state, dynamically set>> the depth bias parameters, 3895e5c31af7Sopenharmony_cicall: 3896e5c31af7Sopenharmony_ci 3897e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCmdSetDepthBias.adoc[] 3898e5c31af7Sopenharmony_ci 3899e5c31af7Sopenharmony_ci * pname:commandBuffer is the command buffer into which the command will be 3900e5c31af7Sopenharmony_ci recorded. 3901e5c31af7Sopenharmony_ci * pname:depthBiasConstantFactor is a scalar factor controlling the 3902e5c31af7Sopenharmony_ci constant depth value added to each fragment. 3903e5c31af7Sopenharmony_ci * pname:depthBiasClamp is the maximum (or minimum) depth bias of a 3904e5c31af7Sopenharmony_ci fragment. 3905e5c31af7Sopenharmony_ci * pname:depthBiasSlopeFactor is a scalar factor applied to a fragment's 3906e5c31af7Sopenharmony_ci slope in depth bias calculations. 3907e5c31af7Sopenharmony_ci 3908e5c31af7Sopenharmony_ciThis command sets the depth bias parameters for subsequent drawing commands 3909e5c31af7Sopenharmony_ciifdef::VK_EXT_shader_object[when drawing using <<shaders-objects, shader objects>>, or] 3910e5c31af7Sopenharmony_ciwhen the graphics pipeline is created with ename:VK_DYNAMIC_STATE_DEPTH_BIAS 3911e5c31af7Sopenharmony_ciset in slink:VkPipelineDynamicStateCreateInfo::pname:pDynamicStates. 3912e5c31af7Sopenharmony_ciOtherwise, this state is specified by the corresponding 3913e5c31af7Sopenharmony_cislink:VkPipelineRasterizationStateCreateInfo::pname:depthBiasConstantFactor, 3914e5c31af7Sopenharmony_cipname:depthBiasClamp, and pname:depthBiasSlopeFactor values used to create 3915e5c31af7Sopenharmony_cithe currently active pipeline. 3916e5c31af7Sopenharmony_ci 3917e5c31af7Sopenharmony_ciifdef::VK_EXT_depth_bias_control[] 3918e5c31af7Sopenharmony_ciCalling this function is equivalent to calling fname:vkCmdSetDepthBias2EXT 3919e5c31af7Sopenharmony_ciwithout a sname:VkDepthBiasRepresentationInfoEXT in the pNext chain of 3920e5c31af7Sopenharmony_cisname:VkDepthBiasInfoEXT. 3921e5c31af7Sopenharmony_ciendif::VK_EXT_depth_bias_control[] 3922e5c31af7Sopenharmony_ci 3923e5c31af7Sopenharmony_ci.Valid Usage 3924e5c31af7Sopenharmony_ci**** 3925e5c31af7Sopenharmony_ci * [[VUID-vkCmdSetDepthBias-depthBiasClamp-00790]] 3926e5c31af7Sopenharmony_ci If the <<features-depthBiasClamp, pname:depthBiasClamp>> feature is not 3927e5c31af7Sopenharmony_ci enabled, pname:depthBiasClamp must: be `0.0` 3928e5c31af7Sopenharmony_ci**** 3929e5c31af7Sopenharmony_ci 3930e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkCmdSetDepthBias.adoc[] 3931e5c31af7Sopenharmony_ci-- 3932e5c31af7Sopenharmony_ci 3933e5c31af7Sopenharmony_ciifdef::VK_EXT_depth_bias_control[] 3934e5c31af7Sopenharmony_ci[open,refpage='VkDepthBiasRepresentationInfoEXT',desc='Structure specifying depth bias parameters',type='structs'] 3935e5c31af7Sopenharmony_ci-- 3936e5c31af7Sopenharmony_ci:refpage: VkDepthBiasRepresentationInfoEXT 3937e5c31af7Sopenharmony_ci 3938e5c31af7Sopenharmony_ciThe sname:VkDepthBiasRepresentationInfoEXT structure is defined as: 3939e5c31af7Sopenharmony_ci 3940e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkDepthBiasRepresentationInfoEXT.adoc[] 3941e5c31af7Sopenharmony_ci 3942e5c31af7Sopenharmony_ci * pname:sType is a elink:VkStructureType value identifying this structure. 3943e5c31af7Sopenharmony_ci * pname:pNext is `NULL` or a pointer to a structure extending this 3944e5c31af7Sopenharmony_ci structure. 3945e5c31af7Sopenharmony_ci * pname:depthBiasRepresentation is a elink:VkDepthBiasRepresentationEXT 3946e5c31af7Sopenharmony_ci value specifying the depth bias representation. 3947e5c31af7Sopenharmony_ci * pname:depthBiasExact specifies that the implementation is not allowed to 3948e5c31af7Sopenharmony_ci scale the depth bias value to ensure a minimum resolvable distance. 3949e5c31af7Sopenharmony_ci 3950e5c31af7Sopenharmony_ci.Valid Usage 3951e5c31af7Sopenharmony_ci**** 3952e5c31af7Sopenharmony_ci * [[VUID-VkDepthBiasRepresentationInfoEXT-leastRepresentableValueForceUnormRepresentation-08947]] 3953e5c31af7Sopenharmony_ci If the <<features-leastRepresentableValueForceUnormRepresentation, 3954e5c31af7Sopenharmony_ci pname:leastRepresentableValueForceUnormRepresentation>> feature is not 3955e5c31af7Sopenharmony_ci enabled, pname:depthBiasRepresentation must: not be 3956e5c31af7Sopenharmony_ci `VK_DEPTH_BIAS_REPRESENTATION_LEAST_REPRESENTABLE_VALUE_FORCE_UNORM_EXT` 3957e5c31af7Sopenharmony_ci * [[VUID-VkDepthBiasRepresentationInfoEXT-floatRepresentation-08948]] 3958e5c31af7Sopenharmony_ci If the <<features-floatRepresentation, pname:floatRepresentation>> 3959e5c31af7Sopenharmony_ci feature is not enabled, pname:depthBiasRepresentation must: not be 3960e5c31af7Sopenharmony_ci `VK_DEPTH_BIAS_REPRESENTATION_FLOAT_EXT` 3961e5c31af7Sopenharmony_ci * [[VUID-VkDepthBiasRepresentationInfoEXT-depthBiasExact-08949]] 3962e5c31af7Sopenharmony_ci If the <<features-depthBiasExact, pname:depthBiasExact>> feature is not 3963e5c31af7Sopenharmony_ci enabled, pname:depthBiasExact must: be `VK_FALSE` 3964e5c31af7Sopenharmony_ci**** 3965e5c31af7Sopenharmony_ci 3966e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkDepthBiasRepresentationInfoEXT.adoc[] 3967e5c31af7Sopenharmony_ci-- 3968e5c31af7Sopenharmony_ci 3969e5c31af7Sopenharmony_ci[open,refpage='VkDepthBiasRepresentationEXT',desc='Specify the depth bias representation',type='enums'] 3970e5c31af7Sopenharmony_ci-- 3971e5c31af7Sopenharmony_ciPossible values of 3972e5c31af7Sopenharmony_cislink:VkDepthBiasRepresentationInfoEXT::pname:depthBiasRepresentation, 3973e5c31af7Sopenharmony_cispecifying the depth bias representation are: 3974e5c31af7Sopenharmony_ci 3975e5c31af7Sopenharmony_ciinclude::{generated}/api/enums/VkDepthBiasRepresentationEXT.adoc[] 3976e5c31af7Sopenharmony_ci 3977e5c31af7Sopenharmony_ci * ename:VK_DEPTH_BIAS_REPRESENTATION_LEAST_REPRESENTABLE_VALUE_FORMAT_EXT 3978e5c31af7Sopenharmony_ci specifies that the depth bias representation is a factor of the format's 3979e5c31af7Sopenharmony_ci [eq]#r# as described in <<primsrast-depthbias-computation>>. 3980e5c31af7Sopenharmony_ci * ename:VK_DEPTH_BIAS_REPRESENTATION_LEAST_REPRESENTABLE_VALUE_FORCE_UNORM_EXT 3981e5c31af7Sopenharmony_ci specifies that the depth bias representation is a factor of a constant 3982e5c31af7Sopenharmony_ci [eq]#r# defined by the bit-size or mantissa of the format as described 3983e5c31af7Sopenharmony_ci in <<primsrast-depthbias-computation>>. 3984e5c31af7Sopenharmony_ci * ename:VK_DEPTH_BIAS_REPRESENTATION_FLOAT_EXT specifies that the depth 3985e5c31af7Sopenharmony_ci bias representation is a factor of constant [eq]#r# equal to 1. 3986e5c31af7Sopenharmony_ci-- 3987e5c31af7Sopenharmony_ci 3988e5c31af7Sopenharmony_ci[open,refpage='VkDepthBiasInfoEXT',desc='Structure specifying depth bias parameters',type='structs'] 3989e5c31af7Sopenharmony_ci-- 3990e5c31af7Sopenharmony_ci:refpage: VkDepthBiasInfoEXT 3991e5c31af7Sopenharmony_ci 3992e5c31af7Sopenharmony_ciThe sname:VkDepthBiasInfoEXT structure is defined as: 3993e5c31af7Sopenharmony_ci 3994e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkDepthBiasInfoEXT.adoc[] 3995e5c31af7Sopenharmony_ci 3996e5c31af7Sopenharmony_ci * pname:sType is a elink:VkStructureType value identifying this structure. 3997e5c31af7Sopenharmony_ci * pname:pNext is `NULL` or a pointer to a structure extending this 3998e5c31af7Sopenharmony_ci structure. 3999e5c31af7Sopenharmony_ci * pname:depthBiasConstantFactor is a scalar factor controlling the 4000e5c31af7Sopenharmony_ci constant depth value added to each fragment. 4001e5c31af7Sopenharmony_ci * pname:depthBiasClamp is the maximum (or minimum) depth bias of a 4002e5c31af7Sopenharmony_ci fragment. 4003e5c31af7Sopenharmony_ci * pname:depthBiasSlopeFactor is a scalar factor applied to a fragment's 4004e5c31af7Sopenharmony_ci slope in depth bias calculations. 4005e5c31af7Sopenharmony_ci 4006e5c31af7Sopenharmony_ciIf pname:pNext does not contain a slink:VkDepthBiasRepresentationInfoEXT 4007e5c31af7Sopenharmony_cistructure, then this command is equivalent to including a 4008e5c31af7Sopenharmony_cislink:VkDepthBiasRepresentationInfoEXT with pname:depthBiasExact set to 4009e5c31af7Sopenharmony_ciename:VK_FALSE and pname:depthBiasRepresentation set to 4010e5c31af7Sopenharmony_ciename:VK_DEPTH_BIAS_REPRESENTATION_LEAST_REPRESENTABLE_VALUE_FORMAT_EXT. 4011e5c31af7Sopenharmony_ci 4012e5c31af7Sopenharmony_ci.Valid Usage 4013e5c31af7Sopenharmony_ci**** 4014e5c31af7Sopenharmony_ci * [[VUID-VkDepthBiasInfoEXT-depthBiasClamp-08950]] 4015e5c31af7Sopenharmony_ci If the <<features-depthBiasClamp, pname:depthBiasClamp>> feature is not 4016e5c31af7Sopenharmony_ci enabled, pname:depthBiasClamp must: be `0.0` 4017e5c31af7Sopenharmony_ci**** 4018e5c31af7Sopenharmony_ci 4019e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkDepthBiasInfoEXT.adoc[] 4020e5c31af7Sopenharmony_ci-- 4021e5c31af7Sopenharmony_ci 4022e5c31af7Sopenharmony_ci[open,refpage='vkCmdSetDepthBias2EXT',desc='Set depth bias factors and clamp dynamically for a command buffer',type='protos'] 4023e5c31af7Sopenharmony_ci-- 4024e5c31af7Sopenharmony_ciTo <<pipelines-dynamic-state, dynamically set>> the depth bias parameters, 4025e5c31af7Sopenharmony_cicall: 4026e5c31af7Sopenharmony_ci 4027e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCmdSetDepthBias2EXT.adoc[] 4028e5c31af7Sopenharmony_ci 4029e5c31af7Sopenharmony_ci * pname:commandBuffer is the command buffer into which the command will be 4030e5c31af7Sopenharmony_ci recorded. 4031e5c31af7Sopenharmony_ci * pname:pDepthBiasInfo is a pointer to a slink:VkDepthBiasInfoEXT 4032e5c31af7Sopenharmony_ci structure specifying depth bias parameters. 4033e5c31af7Sopenharmony_ci 4034e5c31af7Sopenharmony_ciThis command is functionally identical to flink:vkCmdSetDepthBias, but 4035e5c31af7Sopenharmony_ciincludes extensible sub-structures that include pname:sType and pname:pNext 4036e5c31af7Sopenharmony_ciparameters, allowing them to be more easily extended. 4037e5c31af7Sopenharmony_ci 4038e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkCmdSetDepthBias2EXT.adoc[] 4039e5c31af7Sopenharmony_ci-- 4040e5c31af7Sopenharmony_ciendif::VK_EXT_depth_bias_control[] 4041e5c31af7Sopenharmony_ci 4042e5c31af7Sopenharmony_ciifdef::VK_EXT_conservative_rasterization[] 4043e5c31af7Sopenharmony_ci[[primsrast-conservativeraster]] 4044e5c31af7Sopenharmony_ci=== Conservative Rasterization 4045e5c31af7Sopenharmony_ci 4046e5c31af7Sopenharmony_ci[open,refpage='VkPipelineRasterizationConservativeStateCreateInfoEXT',desc='Structure specifying conservative raster state',type='structs'] 4047e5c31af7Sopenharmony_ci-- 4048e5c31af7Sopenharmony_ciIf the pname:pNext chain of slink:VkPipelineRasterizationStateCreateInfo 4049e5c31af7Sopenharmony_ciincludes a sname:VkPipelineRasterizationConservativeStateCreateInfoEXT 4050e5c31af7Sopenharmony_cistructure, then that structure includes parameters controlling conservative 4051e5c31af7Sopenharmony_cirasterization. 4052e5c31af7Sopenharmony_ci 4053e5c31af7Sopenharmony_cisname:VkPipelineRasterizationConservativeStateCreateInfoEXT is defined as: 4054e5c31af7Sopenharmony_ci 4055e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkPipelineRasterizationConservativeStateCreateInfoEXT.adoc[] 4056e5c31af7Sopenharmony_ci 4057e5c31af7Sopenharmony_ci * pname:sType is a elink:VkStructureType value identifying this structure. 4058e5c31af7Sopenharmony_ci * pname:pNext is `NULL` or a pointer to a structure extending this 4059e5c31af7Sopenharmony_ci structure. 4060e5c31af7Sopenharmony_ci * pname:flags is reserved for future use. 4061e5c31af7Sopenharmony_ci * pname:conservativeRasterizationMode is the conservative rasterization 4062e5c31af7Sopenharmony_ci mode to use. 4063e5c31af7Sopenharmony_ci * pname:extraPrimitiveOverestimationSize is the extra size in pixels to 4064e5c31af7Sopenharmony_ci increase the generating primitive during conservative rasterization at 4065e5c31af7Sopenharmony_ci each of its edges in `X` and `Y` equally in screen space beyond the base 4066e5c31af7Sopenharmony_ci overestimation specified in 4067e5c31af7Sopenharmony_ci sname:VkPhysicalDeviceConservativeRasterizationPropertiesEXT::pname:primitiveOverestimationSize. 4068e5c31af7Sopenharmony_ci If pname:conservativeRasterizationMode is not 4069e5c31af7Sopenharmony_ci ename:VK_CONSERVATIVE_RASTERIZATION_MODE_OVERESTIMATE_EXT, this value is 4070e5c31af7Sopenharmony_ci ignored. 4071e5c31af7Sopenharmony_ci 4072e5c31af7Sopenharmony_ciIf this structure is not included in the pname:pNext chain, 4073e5c31af7Sopenharmony_cipname:conservativeRasterizationMode is considered to be 4074e5c31af7Sopenharmony_ciename:VK_CONSERVATIVE_RASTERIZATION_MODE_DISABLED_EXT, and and conservative 4075e5c31af7Sopenharmony_cirasterization is disabled. 4076e5c31af7Sopenharmony_ci 4077e5c31af7Sopenharmony_ciPolygon rasterization can: be made conservative by setting 4078e5c31af7Sopenharmony_cipname:conservativeRasterizationMode to 4079e5c31af7Sopenharmony_ciename:VK_CONSERVATIVE_RASTERIZATION_MODE_OVERESTIMATE_EXT or 4080e5c31af7Sopenharmony_ciename:VK_CONSERVATIVE_RASTERIZATION_MODE_UNDERESTIMATE_EXT in 4081e5c31af7Sopenharmony_cisname:VkPipelineRasterizationConservativeStateCreateInfoEXT. 4082e5c31af7Sopenharmony_ci 4083e5c31af7Sopenharmony_ci[NOTE] 4084e5c31af7Sopenharmony_ci.Note 4085e5c31af7Sopenharmony_ci==== 4086e5c31af7Sopenharmony_ciIf <<limits-conservativePointAndLineRasterization, 4087e5c31af7Sopenharmony_cipname:conservativePointAndLineRasterization>> is supported, conservative 4088e5c31af7Sopenharmony_cirasterization can be applied to line and point primitives, otherwise it must 4089e5c31af7Sopenharmony_cibe disabled. 4090e5c31af7Sopenharmony_ci==== 4091e5c31af7Sopenharmony_ci 4092e5c31af7Sopenharmony_ci.Valid Usage 4093e5c31af7Sopenharmony_ci**** 4094e5c31af7Sopenharmony_ci * [[VUID-VkPipelineRasterizationConservativeStateCreateInfoEXT-extraPrimitiveOverestimationSize-01769]] 4095e5c31af7Sopenharmony_ci pname:extraPrimitiveOverestimationSize must: be in the range of `0.0` to 4096e5c31af7Sopenharmony_ci sname:VkPhysicalDeviceConservativeRasterizationPropertiesEXT::pname:maxExtraPrimitiveOverestimationSize 4097e5c31af7Sopenharmony_ci inclusive 4098e5c31af7Sopenharmony_ci**** 4099e5c31af7Sopenharmony_ci 4100e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkPipelineRasterizationConservativeStateCreateInfoEXT.adoc[] 4101e5c31af7Sopenharmony_ci-- 4102e5c31af7Sopenharmony_ci 4103e5c31af7Sopenharmony_ci[open,refpage='VkPipelineRasterizationConservativeStateCreateFlagsEXT',desc='Reserved for future use',type='flags'] 4104e5c31af7Sopenharmony_ci-- 4105e5c31af7Sopenharmony_ciinclude::{generated}/api/flags/VkPipelineRasterizationConservativeStateCreateFlagsEXT.adoc[] 4106e5c31af7Sopenharmony_ci 4107e5c31af7Sopenharmony_citname:VkPipelineRasterizationConservativeStateCreateFlagsEXT is a bitmask 4108e5c31af7Sopenharmony_citype for setting a mask, but is currently reserved for future use. 4109e5c31af7Sopenharmony_ci-- 4110e5c31af7Sopenharmony_ci 4111e5c31af7Sopenharmony_ci[open,refpage='VkConservativeRasterizationModeEXT',desc='Specify the conservative rasterization mode',type='enums'] 4112e5c31af7Sopenharmony_ci-- 4113e5c31af7Sopenharmony_ciPossible values of 4114e5c31af7Sopenharmony_cislink:VkPipelineRasterizationConservativeStateCreateInfoEXT::pname:conservativeRasterizationMode, 4115e5c31af7Sopenharmony_cispecifying the conservative rasterization mode are: 4116e5c31af7Sopenharmony_ci 4117e5c31af7Sopenharmony_ciinclude::{generated}/api/enums/VkConservativeRasterizationModeEXT.adoc[] 4118e5c31af7Sopenharmony_ci 4119e5c31af7Sopenharmony_ci * ename:VK_CONSERVATIVE_RASTERIZATION_MODE_DISABLED_EXT specifies that 4120e5c31af7Sopenharmony_ci conservative rasterization is disabled and rasterization proceeds as 4121e5c31af7Sopenharmony_ci normal. 4122e5c31af7Sopenharmony_ci * ename:VK_CONSERVATIVE_RASTERIZATION_MODE_OVERESTIMATE_EXT specifies that 4123e5c31af7Sopenharmony_ci conservative rasterization is enabled in overestimation mode. 4124e5c31af7Sopenharmony_ci * ename:VK_CONSERVATIVE_RASTERIZATION_MODE_UNDERESTIMATE_EXT specifies 4125e5c31af7Sopenharmony_ci that conservative rasterization is enabled in underestimation mode. 4126e5c31af7Sopenharmony_ci-- 4127e5c31af7Sopenharmony_ci 4128e5c31af7Sopenharmony_ciifdef::VK_EXT_extended_dynamic_state3,VK_EXT_shader_object[] 4129e5c31af7Sopenharmony_ci 4130e5c31af7Sopenharmony_ci[open,refpage='vkCmdSetConservativeRasterizationModeEXT',desc='Specify the conservative rasterization mode dynamically for a command buffer',type='protos'] 4131e5c31af7Sopenharmony_ci-- 4132e5c31af7Sopenharmony_ciTo <<pipelines-dynamic-state, dynamically set>> the 4133e5c31af7Sopenharmony_cipname:conservativeRasterizationMode, call: 4134e5c31af7Sopenharmony_ci 4135e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCmdSetConservativeRasterizationModeEXT.adoc[] 4136e5c31af7Sopenharmony_ci 4137e5c31af7Sopenharmony_ci * pname:commandBuffer is the command buffer into which the command will be 4138e5c31af7Sopenharmony_ci recorded. 4139e5c31af7Sopenharmony_ci * pname:conservativeRasterizationMode specifies the 4140e5c31af7Sopenharmony_ci pname:conservativeRasterizationMode state. 4141e5c31af7Sopenharmony_ci 4142e5c31af7Sopenharmony_ciThis command sets the pname:conservativeRasterizationMode state for 4143e5c31af7Sopenharmony_cisubsequent drawing commands 4144e5c31af7Sopenharmony_ciifdef::VK_EXT_shader_object[] 4145e5c31af7Sopenharmony_ciifdef::VK_EXT_extended_dynamic_state3[when drawing using <<shaders-objects, shader objects>>, or] 4146e5c31af7Sopenharmony_ciifndef::VK_EXT_extended_dynamic_state3[when drawing using <<shaders-objects, shader objects>>.] 4147e5c31af7Sopenharmony_ciendif::VK_EXT_shader_object[] 4148e5c31af7Sopenharmony_ciifdef::VK_EXT_extended_dynamic_state3[] 4149e5c31af7Sopenharmony_ciwhen the graphics pipeline is created with 4150e5c31af7Sopenharmony_ciename:VK_DYNAMIC_STATE_CONSERVATIVE_RASTERIZATION_MODE_EXT set in 4151e5c31af7Sopenharmony_cislink:VkPipelineDynamicStateCreateInfo::pname:pDynamicStates. 4152e5c31af7Sopenharmony_ciendif::VK_EXT_extended_dynamic_state3[] 4153e5c31af7Sopenharmony_ciOtherwise, this state is specified by the 4154e5c31af7Sopenharmony_cislink:VkPipelineRasterizationConservativeStateCreateInfoEXT::pname:conservativeRasterizationMode 4155e5c31af7Sopenharmony_civalue used to create the currently active pipeline. 4156e5c31af7Sopenharmony_ci 4157e5c31af7Sopenharmony_ci:refpage: vkCmdSetConservativeRasterizationModeEXT 4158e5c31af7Sopenharmony_ci:requiredfeature: extendedDynamicState3ConservativeRasterizationMode 4159e5c31af7Sopenharmony_ci 4160e5c31af7Sopenharmony_ci.Valid Usage 4161e5c31af7Sopenharmony_ci**** 4162e5c31af7Sopenharmony_ciinclude::{chapters}/commonvalidity/dynamic_state3_feature_common.adoc[] 4163e5c31af7Sopenharmony_ci**** 4164e5c31af7Sopenharmony_ci 4165e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkCmdSetConservativeRasterizationModeEXT.adoc[] 4166e5c31af7Sopenharmony_ci-- 4167e5c31af7Sopenharmony_ci 4168e5c31af7Sopenharmony_ci[open,refpage='vkCmdSetExtraPrimitiveOverestimationSizeEXT',desc='Specify the conservative rasterization extra primitive overestimation size dynamically for a command buffer',type='protos'] 4169e5c31af7Sopenharmony_ci-- 4170e5c31af7Sopenharmony_ciTo <<pipelines-dynamic-state, dynamically set>> the 4171e5c31af7Sopenharmony_cipname:extraPrimitiveOverestimationSize, call: 4172e5c31af7Sopenharmony_ci 4173e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCmdSetExtraPrimitiveOverestimationSizeEXT.adoc[] 4174e5c31af7Sopenharmony_ci 4175e5c31af7Sopenharmony_ci * pname:commandBuffer is the command buffer into which the command will be 4176e5c31af7Sopenharmony_ci recorded. 4177e5c31af7Sopenharmony_ci * pname:extraPrimitiveOverestimationSize specifies the 4178e5c31af7Sopenharmony_ci pname:extraPrimitiveOverestimationSize. 4179e5c31af7Sopenharmony_ci 4180e5c31af7Sopenharmony_ciThis command sets the pname:extraPrimitiveOverestimationSize for subsequent 4181e5c31af7Sopenharmony_cidrawing commands 4182e5c31af7Sopenharmony_ciifdef::VK_EXT_shader_object[] 4183e5c31af7Sopenharmony_ciifdef::VK_EXT_extended_dynamic_state3[when drawing using <<shaders-objects, shader objects>>, or] 4184e5c31af7Sopenharmony_ciifndef::VK_EXT_extended_dynamic_state3[when drawing using <<shaders-objects, shader objects>>.] 4185e5c31af7Sopenharmony_ciendif::VK_EXT_shader_object[] 4186e5c31af7Sopenharmony_ciifdef::VK_EXT_extended_dynamic_state3[] 4187e5c31af7Sopenharmony_ciwhen the graphics pipeline is created with 4188e5c31af7Sopenharmony_ciename:VK_DYNAMIC_STATE_EXTRA_PRIMITIVE_OVERESTIMATION_SIZE_EXT set in 4189e5c31af7Sopenharmony_cislink:VkPipelineDynamicStateCreateInfo::pname:pDynamicStates. 4190e5c31af7Sopenharmony_ciendif::VK_EXT_extended_dynamic_state3[] 4191e5c31af7Sopenharmony_ciOtherwise, this state is specified by the 4192e5c31af7Sopenharmony_cislink:VkPipelineRasterizationConservativeStateCreateInfoEXT::pname:extraPrimitiveOverestimationSize 4193e5c31af7Sopenharmony_civalue used to create the currently active pipeline. 4194e5c31af7Sopenharmony_ci 4195e5c31af7Sopenharmony_ci:refpage: vkCmdSetExtraPrimitiveOverestimationSizeEXT 4196e5c31af7Sopenharmony_ci:requiredfeature: extendedDynamicState3ExtraPrimitiveOverestimationSize 4197e5c31af7Sopenharmony_ci 4198e5c31af7Sopenharmony_ci.Valid Usage 4199e5c31af7Sopenharmony_ci**** 4200e5c31af7Sopenharmony_ciinclude::{chapters}/commonvalidity/dynamic_state3_feature_common.adoc[] 4201e5c31af7Sopenharmony_ci * [[VUID-vkCmdSetExtraPrimitiveOverestimationSizeEXT-extraPrimitiveOverestimationSize-07428]] 4202e5c31af7Sopenharmony_ci pname:extraPrimitiveOverestimationSize must: be in the range of `0.0` to 4203e5c31af7Sopenharmony_ci sname:VkPhysicalDeviceConservativeRasterizationPropertiesEXT::pname:maxExtraPrimitiveOverestimationSize 4204e5c31af7Sopenharmony_ci inclusive 4205e5c31af7Sopenharmony_ci**** 4206e5c31af7Sopenharmony_ci 4207e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkCmdSetExtraPrimitiveOverestimationSizeEXT.adoc[] 4208e5c31af7Sopenharmony_ci-- 4209e5c31af7Sopenharmony_ci 4210e5c31af7Sopenharmony_ciendif::VK_EXT_extended_dynamic_state3,VK_EXT_shader_object[] 4211e5c31af7Sopenharmony_ci 4212e5c31af7Sopenharmony_ciWhen overestimate conservative rasterization is enabled, rather than 4213e5c31af7Sopenharmony_cievaluating coverage at individual sample locations, a determination is made 4214e5c31af7Sopenharmony_ciwhether any portion of the pixel (including its edges and corners) is 4215e5c31af7Sopenharmony_cicovered by the primitive. 4216e5c31af7Sopenharmony_ciIf any portion of the pixel is covered, then all bits of the 4217e5c31af7Sopenharmony_ci<<primsrast-multisampling-coverage-mask, coverage mask>> for the fragment 4218e5c31af7Sopenharmony_cicorresponding to that pixel are enabled. 4219e5c31af7Sopenharmony_ciifdef::VK_EXT_fragment_density_map[] 4220e5c31af7Sopenharmony_ciIf the render pass has a fragment density map attachment and any bit of the 4221e5c31af7Sopenharmony_ci<<primsrast-multisampling-coverage-mask, coverage mask>> for the fragment is 4222e5c31af7Sopenharmony_cienabled, then all bits of the <<primsrast-multisampling-coverage-mask, 4223e5c31af7Sopenharmony_cicoverage mask>> for the fragment are enabled. 4224e5c31af7Sopenharmony_ciendif::VK_EXT_fragment_density_map[] 4225e5c31af7Sopenharmony_ci 4226e5c31af7Sopenharmony_ciFor the purposes of evaluating which pixels are covered by the primitive, 4227e5c31af7Sopenharmony_ciimplementations can: increase the size of the primitive by up to 4228e5c31af7Sopenharmony_cisname:VkPhysicalDeviceConservativeRasterizationPropertiesEXT::pname:primitiveOverestimationSize 4229e5c31af7Sopenharmony_cipixels at each of the primitive edges. 4230e5c31af7Sopenharmony_ciThis may: increase the number of fragments generated by this primitive and 4231e5c31af7Sopenharmony_cirepresents an overestimation of the pixel coverage. 4232e5c31af7Sopenharmony_ci 4233e5c31af7Sopenharmony_ciThis overestimation size can be increased further by setting the 4234e5c31af7Sopenharmony_cipname:extraPrimitiveOverestimationSize value above `0.0` in steps of 4235e5c31af7Sopenharmony_cisname:VkPhysicalDeviceConservativeRasterizationPropertiesEXT::pname:extraPrimitiveOverestimationSizeGranularity 4236e5c31af7Sopenharmony_ciup to and including 4237e5c31af7Sopenharmony_cisname:VkPhysicalDeviceConservativeRasterizationPropertiesEXT::pname:extraPrimitiveOverestimationSize. 4238e5c31af7Sopenharmony_ciThis may: further increase the number of fragments generated by this 4239e5c31af7Sopenharmony_ciprimitive. 4240e5c31af7Sopenharmony_ci 4241e5c31af7Sopenharmony_ciThe actual precision of the overestimation size used for conservative 4242e5c31af7Sopenharmony_cirasterization may: vary between implementations and produce results that 4243e5c31af7Sopenharmony_cionly approximate the pname:primitiveOverestimationSize and 4244e5c31af7Sopenharmony_cipname:extraPrimitiveOverestimationSizeGranularity properties. 4245e5c31af7Sopenharmony_ciifdef::VK_EXT_fragment_density_map[] 4246e5c31af7Sopenharmony_ciImplementations may: especially vary these approximations when the render 4247e5c31af7Sopenharmony_cipass has a fragment density map and the fragment area covers multiple 4248e5c31af7Sopenharmony_cipixels. 4249e5c31af7Sopenharmony_ciendif::VK_EXT_fragment_density_map[] 4250e5c31af7Sopenharmony_ci 4251e5c31af7Sopenharmony_ciFor triangles if ename:VK_CONSERVATIVE_RASTERIZATION_MODE_OVERESTIMATE_EXT 4252e5c31af7Sopenharmony_ciis enabled, fragments will be generated if the primitive area covers any 4253e5c31af7Sopenharmony_ciportion of any pixel inside the fragment area, including their edges or 4254e5c31af7Sopenharmony_cicorners. 4255e5c31af7Sopenharmony_ciThe tie-breaking rule described in <<primsrast-polygons-basic, Basic Polygon 4256e5c31af7Sopenharmony_ciRasterization>> does not apply during conservative rasterization and 4257e5c31af7Sopenharmony_cicoverage is set for all fragments generated from shared edges of polygons. 4258e5c31af7Sopenharmony_ciDegenerate triangles that evaluate to zero area after rasterization, even 4259e5c31af7Sopenharmony_cifor pixels containing a vertex or edge of the zero-area polygon, will be 4260e5c31af7Sopenharmony_ciculled if 4261e5c31af7Sopenharmony_cisname:VkPhysicalDeviceConservativeRasterizationPropertiesEXT::pname:degenerateTrianglesRasterized 4262e5c31af7Sopenharmony_ciis ename:VK_FALSE or will generate fragments if 4263e5c31af7Sopenharmony_cipname:degenerateTrianglesRasterized is ename:VK_TRUE. 4264e5c31af7Sopenharmony_ciThe fragment input values for these degenerate triangles take their 4265e5c31af7Sopenharmony_ciattribute and depth values from the provoking vertex. 4266e5c31af7Sopenharmony_ciDegenerate triangles are considered backfacing and the application can: 4267e5c31af7Sopenharmony_cienable backface culling if desired. 4268e5c31af7Sopenharmony_ciTriangles that are zero area before rasterization may: be culled regardless. 4269e5c31af7Sopenharmony_ci 4270e5c31af7Sopenharmony_ciFor lines if ename:VK_CONSERVATIVE_RASTERIZATION_MODE_OVERESTIMATE_EXT is 4271e5c31af7Sopenharmony_cienabled, and the implementation sets 4272e5c31af7Sopenharmony_cisname:VkPhysicalDeviceConservativeRasterizationPropertiesEXT::pname:conservativePointAndLineRasterization 4273e5c31af7Sopenharmony_cito ename:VK_TRUE, fragments will be generated if the line covers any portion 4274e5c31af7Sopenharmony_ciof any pixel inside the fragment area, including their edges or corners. 4275e5c31af7Sopenharmony_ciDegenerate lines that evaluate to zero length after rasterization will be 4276e5c31af7Sopenharmony_ciculled if 4277e5c31af7Sopenharmony_cisname:VkPhysicalDeviceConservativeRasterizationPropertiesEXT::pname:degenerateLinesRasterized 4278e5c31af7Sopenharmony_ciis ename:VK_FALSE or will generate fragments if 4279e5c31af7Sopenharmony_cipname:degenerateLinesRasterized is ename:VK_TRUE. 4280e5c31af7Sopenharmony_ciThe fragments input values for these degenerate lines take their attribute 4281e5c31af7Sopenharmony_ciand depth values from the provoking vertex. 4282e5c31af7Sopenharmony_ciLines that are zero length before rasterization may: be culled regardless. 4283e5c31af7Sopenharmony_ci 4284e5c31af7Sopenharmony_ciFor points if ename:VK_CONSERVATIVE_RASTERIZATION_MODE_OVERESTIMATE_EXT is 4285e5c31af7Sopenharmony_cienabled, and the implementation sets 4286e5c31af7Sopenharmony_cisname:VkPhysicalDeviceConservativeRasterizationPropertiesEXT::pname:conservativePointAndLineRasterization 4287e5c31af7Sopenharmony_cito ename:VK_TRUE, fragments will be generated if the point square covers any 4288e5c31af7Sopenharmony_ciportion of any pixel inside the fragment area, including their edges or 4289e5c31af7Sopenharmony_cicorners. 4290e5c31af7Sopenharmony_ci 4291e5c31af7Sopenharmony_ciWhen underestimate conservative rasterization is enabled, rather than 4292e5c31af7Sopenharmony_cievaluating coverage at individual sample locations, a determination is made 4293e5c31af7Sopenharmony_ciwhether all of the pixel (including its edges and corners) is covered by the 4294e5c31af7Sopenharmony_ciprimitive. 4295e5c31af7Sopenharmony_ciIf the entire pixel is covered, then a fragment is generated with all bits 4296e5c31af7Sopenharmony_ciof its <<primsrast-multisampling-coverage-mask, coverage mask>> 4297e5c31af7Sopenharmony_cicorresponding to the pixel enabled, otherwise the pixel is not considered 4298e5c31af7Sopenharmony_cicovered even if some portion of the pixel is covered. 4299e5c31af7Sopenharmony_ciThe fragment is discarded if no pixels inside the fragment area are 4300e5c31af7Sopenharmony_ciconsidered covered. 4301e5c31af7Sopenharmony_ciifdef::VK_EXT_fragment_density_map[] 4302e5c31af7Sopenharmony_ciIf the render pass has a fragment density map attachment and any pixel 4303e5c31af7Sopenharmony_ciinside the fragment area is not considered covered, then the fragment is 4304e5c31af7Sopenharmony_cidiscarded even if some pixels are considered covered. 4305e5c31af7Sopenharmony_ciendif::VK_EXT_fragment_density_map[] 4306e5c31af7Sopenharmony_ci 4307e5c31af7Sopenharmony_ciFor triangles, if ename:VK_CONSERVATIVE_RASTERIZATION_MODE_UNDERESTIMATE_EXT 4308e5c31af7Sopenharmony_ciis enabled, fragments will only be generated if any pixel inside the 4309e5c31af7Sopenharmony_cifragment area is fully covered by the generating primitive, including its 4310e5c31af7Sopenharmony_ciedges and corners. 4311e5c31af7Sopenharmony_ci 4312e5c31af7Sopenharmony_ciFor lines, if ename:VK_CONSERVATIVE_RASTERIZATION_MODE_UNDERESTIMATE_EXT is 4313e5c31af7Sopenharmony_cienabled, fragments will be generated if any pixel inside the fragment area, 4314e5c31af7Sopenharmony_ciincluding its edges and corners, are entirely covered by the line. 4315e5c31af7Sopenharmony_ci 4316e5c31af7Sopenharmony_ciFor points, if ename:VK_CONSERVATIVE_RASTERIZATION_MODE_UNDERESTIMATE_EXT is 4317e5c31af7Sopenharmony_cienabled, fragments will only be generated if the point square covers the 4318e5c31af7Sopenharmony_cientirety of any pixel square inside the fragment area, including its edges 4319e5c31af7Sopenharmony_cior corners. 4320e5c31af7Sopenharmony_ci 4321e5c31af7Sopenharmony_ciifdef::VK_EXT_fragment_density_map[] 4322e5c31af7Sopenharmony_ciIf the render pass has a fragment density map and 4323e5c31af7Sopenharmony_ciename:VK_CONSERVATIVE_RASTERIZATION_MODE_UNDERESTIMATE_EXT is enabled, 4324e5c31af7Sopenharmony_cifragments will only be generated if the entirety of all pixels inside the 4325e5c31af7Sopenharmony_cifragment area are covered by the generating primitive, line, or point. 4326e5c31af7Sopenharmony_ciendif::VK_EXT_fragment_density_map[] 4327e5c31af7Sopenharmony_ci 4328e5c31af7Sopenharmony_ciFor both overestimate and underestimate conservative rasterization modes a 4329e5c31af7Sopenharmony_cifragment has all of its pixel squares fully covered by the generating 4330e5c31af7Sopenharmony_ciprimitive must: set code:FullyCoveredEXT to ename:VK_TRUE if the 4331e5c31af7Sopenharmony_ciimplementation enables the 4332e5c31af7Sopenharmony_cisname:VkPhysicalDeviceConservativeRasterizationPropertiesEXT::pname:fullyCoveredFragmentShaderInputVariable 4333e5c31af7Sopenharmony_cifeature. 4334e5c31af7Sopenharmony_ci 4335e5c31af7Sopenharmony_ciifdef::VK_NV_shading_rate_image,VK_KHR_fragment_shading_rate[] 4336e5c31af7Sopenharmony_ciWhen 4337e5c31af7Sopenharmony_ciifdef::VK_NV_shading_rate_image[] 4338e5c31af7Sopenharmony_cithe use of a <<primsrast-shading-rate-image, shading rate image>> 4339e5c31af7Sopenharmony_ciendif::VK_NV_shading_rate_image[] 4340e5c31af7Sopenharmony_ciifdef::VK_NV_shading_rate_image+VK_KHR_fragment_shading_rate[or] 4341e5c31af7Sopenharmony_ciifdef::VK_KHR_fragment_shading_rate[] 4342e5c31af7Sopenharmony_cisetting the <<primsrast-fragment-shading-rate, fragment shading rate>> 4343e5c31af7Sopenharmony_ciendif::VK_KHR_fragment_shading_rate[] 4344e5c31af7Sopenharmony_ciresults in fragments covering multiple pixels, coverage for conservative 4345e5c31af7Sopenharmony_cirasterization is still evaluated on a per-pixel basis and may result in 4346e5c31af7Sopenharmony_cifragments with partial coverage. 4347e5c31af7Sopenharmony_ciFor fragment shader inputs decorated with code:FullyCoveredEXT, a fragment 4348e5c31af7Sopenharmony_ciis considered fully covered if and only if all pixels in the fragment are 4349e5c31af7Sopenharmony_cifully covered by the generating primitive. 4350e5c31af7Sopenharmony_ciendif::VK_NV_shading_rate_image,VK_KHR_fragment_shading_rate[] 4351e5c31af7Sopenharmony_ci 4352e5c31af7Sopenharmony_ciendif::VK_EXT_conservative_rasterization[] 4353