1e5c31af7Sopenharmony_ci// Copyright 2015-2021 The Khronos Group, Inc. 2e5c31af7Sopenharmony_ci// 3e5c31af7Sopenharmony_ci// SPDX-License-Identifier: CC-BY-4.0 4e5c31af7Sopenharmony_ci 5e5c31af7Sopenharmony_ci[[framebuffer]] 6e5c31af7Sopenharmony_ci= The Framebuffer 7e5c31af7Sopenharmony_ci 8e5c31af7Sopenharmony_ci 9e5c31af7Sopenharmony_ci[[framebuffer-blending]] 10e5c31af7Sopenharmony_ci== Blending 11e5c31af7Sopenharmony_ci 12e5c31af7Sopenharmony_ciBlending combines the incoming _source_ fragment's R, G, B, and A values 13e5c31af7Sopenharmony_ciwith the _destination_ R, G, B, and A values of each sample stored in the 14e5c31af7Sopenharmony_ciframebuffer at the fragment's [eq]#(x~f~,y~f~)# location. 15e5c31af7Sopenharmony_ciBlending is performed for each color sample covered by the fragment, rather 16e5c31af7Sopenharmony_cithan just once for each fragment. 17e5c31af7Sopenharmony_ci 18e5c31af7Sopenharmony_ciSource and destination values are combined according to the 19e5c31af7Sopenharmony_ci<<framebuffer-blendoperations,blend operation>>, quadruplets of source and 20e5c31af7Sopenharmony_cidestination weighting factors determined by the <<framebuffer-blendfactors, 21e5c31af7Sopenharmony_ciblend factors>>, and a <<framebuffer-blendconstants,blend constant>>, to 22e5c31af7Sopenharmony_ciobtain a new set of R, G, B, and A values, as described below. 23e5c31af7Sopenharmony_ci 24e5c31af7Sopenharmony_ciBlending is computed and applied separately to each color attachment used by 25e5c31af7Sopenharmony_cithe subpass, with separate controls for each attachment. 26e5c31af7Sopenharmony_ci 27e5c31af7Sopenharmony_ciPrior to performing the blend operation, signed and unsigned normalized 28e5c31af7Sopenharmony_cifixed-point color components undergo an implied conversion to floating-point 29e5c31af7Sopenharmony_cias specified by <<fundamentals-fixedfpconv,Conversion from Normalized 30e5c31af7Sopenharmony_ciFixed-Point to Floating-Point>>. 31e5c31af7Sopenharmony_ciBlending computations are treated as if carried out in floating-point, and 32e5c31af7Sopenharmony_cibasic blend operations are performed with a precision and dynamic range no 33e5c31af7Sopenharmony_cilower than that used to represent destination components. 34e5c31af7Sopenharmony_ciifdef::VK_EXT_blend_operation_advanced[] 35e5c31af7Sopenharmony_ci<<framebuffer-blend-advanced,Advanced blending operations>> are performed 36e5c31af7Sopenharmony_ciwith a precision and dynamic range no lower than the smaller of that used to 37e5c31af7Sopenharmony_cirepresent destination components or that used to represent 16-bit 38e5c31af7Sopenharmony_cifloating-point values. 39e5c31af7Sopenharmony_ciendif::VK_EXT_blend_operation_advanced[] 40e5c31af7Sopenharmony_ci 41e5c31af7Sopenharmony_ci[NOTE] 42e5c31af7Sopenharmony_ci.Note 43e5c31af7Sopenharmony_ci==== 44e5c31af7Sopenharmony_ciBlending is only defined for floating-point, UNORM, SNORM, and sRGB formats. 45e5c31af7Sopenharmony_ciWithin those formats, the implementation may only support blending on some 46e5c31af7Sopenharmony_cisubset of them. 47e5c31af7Sopenharmony_ciWhich formats support blending is indicated by 48e5c31af7Sopenharmony_ciename:VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT. 49e5c31af7Sopenharmony_ci==== 50e5c31af7Sopenharmony_ci 51e5c31af7Sopenharmony_ciThe pipeline blend state is included in the 52e5c31af7Sopenharmony_cisname:VkPipelineColorBlendStateCreateInfo structure during graphics pipeline 53e5c31af7Sopenharmony_cicreation: 54e5c31af7Sopenharmony_ci 55e5c31af7Sopenharmony_ci[open,refpage='VkPipelineColorBlendStateCreateInfo',desc='Structure specifying parameters of a newly created pipeline color blend state',type='structs'] 56e5c31af7Sopenharmony_ci-- 57e5c31af7Sopenharmony_ciThe sname:VkPipelineColorBlendStateCreateInfo structure is defined as: 58e5c31af7Sopenharmony_ci 59e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkPipelineColorBlendStateCreateInfo.txt[] 60e5c31af7Sopenharmony_ci 61e5c31af7Sopenharmony_ci * pname:sType is the type of this structure. 62e5c31af7Sopenharmony_ci * pname:pNext is `NULL` or a pointer to a structure extending this 63e5c31af7Sopenharmony_ci structure. 64e5c31af7Sopenharmony_ciifndef::VK_ARM_rasterization_order_attachment_access[] 65e5c31af7Sopenharmony_ci * pname:flags is reserved for future use. 66e5c31af7Sopenharmony_ciendif::VK_ARM_rasterization_order_attachment_access[] 67e5c31af7Sopenharmony_ciifdef::VK_ARM_rasterization_order_attachment_access[] 68e5c31af7Sopenharmony_ci * pname:flags is a bitmask of 69e5c31af7Sopenharmony_ci elink:VkPipelineColorBlendStateCreateFlagBits specifying additional 70e5c31af7Sopenharmony_ci color blending information. 71e5c31af7Sopenharmony_ciendif::VK_ARM_rasterization_order_attachment_access[] 72e5c31af7Sopenharmony_ci * pname:logicOpEnable controls whether to apply <<framebuffer-logicop, 73e5c31af7Sopenharmony_ci Logical Operations>>. 74e5c31af7Sopenharmony_ci * pname:logicOp selects which logical operation to apply. 75e5c31af7Sopenharmony_ci * pname:attachmentCount is the number of 76e5c31af7Sopenharmony_ci sname:VkPipelineColorBlendAttachmentState elements in 77e5c31af7Sopenharmony_ci pname:pAttachments. 78e5c31af7Sopenharmony_ci * pname:pAttachments is a pointer to an array of per target attachment 79e5c31af7Sopenharmony_ci states. 80e5c31af7Sopenharmony_ci * pname:blendConstants is a pointer to an array of four values used as the 81e5c31af7Sopenharmony_ci R, G, B, and A components of the blend constant that are used in 82e5c31af7Sopenharmony_ci blending, depending on the <<framebuffer-blendfactors,blend factor>>. 83e5c31af7Sopenharmony_ci 84e5c31af7Sopenharmony_ciEach element of the pname:pAttachments array is a 85e5c31af7Sopenharmony_cislink:VkPipelineColorBlendAttachmentState structure specifying per-target 86e5c31af7Sopenharmony_ciblending state for each individual color attachment. 87e5c31af7Sopenharmony_ciIf the <<features-independentBlend,independent blending>> feature is not 88e5c31af7Sopenharmony_cienabled on the device, all slink:VkPipelineColorBlendAttachmentState 89e5c31af7Sopenharmony_cielements in the pname:pAttachments array must: be identical. 90e5c31af7Sopenharmony_ci 91e5c31af7Sopenharmony_ciThe value of pname:attachmentCount must: be greater than the index of all 92e5c31af7Sopenharmony_cicolor attachments that are not ename:VK_ATTACHMENT_UNUSED in 93e5c31af7Sopenharmony_cisname:VkSubpassDescription::pname:pColorAttachments 94e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_2,VK_KHR_create_renderpass2[] 95e5c31af7Sopenharmony_cior sname:VkSubpassDescription2::pname:pColorAttachments 96e5c31af7Sopenharmony_ciendif::VK_VERSION_1_2,VK_KHR_create_renderpass2[] 97e5c31af7Sopenharmony_cifor the subpass in which this pipeline is used. 98e5c31af7Sopenharmony_ci 99e5c31af7Sopenharmony_ci.Valid Usage 100e5c31af7Sopenharmony_ci**** 101e5c31af7Sopenharmony_ci * [[VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605]] 102e5c31af7Sopenharmony_ci If the <<features-independentBlend,independent blending>> feature is not 103e5c31af7Sopenharmony_ci enabled, all elements of pname:pAttachments must: be identical 104e5c31af7Sopenharmony_ci * [[VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00606]] 105e5c31af7Sopenharmony_ci If the <<features-logicOp,logic operations>> feature is not enabled, 106e5c31af7Sopenharmony_ci pname:logicOpEnable must: be ename:VK_FALSE 107e5c31af7Sopenharmony_ci * [[VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607]] 108e5c31af7Sopenharmony_ci If pname:logicOpEnable is ename:VK_TRUE, pname:logicOp must: be a valid 109e5c31af7Sopenharmony_ci elink:VkLogicOp value 110e5c31af7Sopenharmony_ciifdef::VK_ARM_rasterization_order_attachment_access[] 111e5c31af7Sopenharmony_ci * [[VUID-VkPipelineColorBlendStateCreateInfo-rasterizationOrderColorAttachmentAccess-06465]] 112e5c31af7Sopenharmony_ci If the <<features-rasterizationOrderColorAttachmentAccess, 113e5c31af7Sopenharmony_ci pname:rasterizationOrderColorAttachmentAccess>> feature is not enabled, 114e5c31af7Sopenharmony_ci pname:flags must: not include 115e5c31af7Sopenharmony_ci ename:VK_PIPELINE_COLOR_BLEND_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_BIT_ARM 116e5c31af7Sopenharmony_ciendif::VK_ARM_rasterization_order_attachment_access[] 117e5c31af7Sopenharmony_ci**** 118e5c31af7Sopenharmony_ci 119e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkPipelineColorBlendStateCreateInfo.txt[] 120e5c31af7Sopenharmony_ci-- 121e5c31af7Sopenharmony_ci 122e5c31af7Sopenharmony_ci[open,refpage='VkPipelineColorBlendStateCreateFlags',desc='Bitmask of VkPipelineColorBlendStateCreateFlagBits',type='flags'] 123e5c31af7Sopenharmony_ci-- 124e5c31af7Sopenharmony_ciinclude::{generated}/api/flags/VkPipelineColorBlendStateCreateFlags.txt[] 125e5c31af7Sopenharmony_ci 126e5c31af7Sopenharmony_ciifndef::VK_ARM_rasterization_order_attachment_access[] 127e5c31af7Sopenharmony_citname:VkPipelineColorBlendStateCreateFlags is a bitmask type for setting a 128e5c31af7Sopenharmony_cimask, but is currently reserved for future use. 129e5c31af7Sopenharmony_ciendif::VK_ARM_rasterization_order_attachment_access[] 130e5c31af7Sopenharmony_ciifdef::VK_ARM_rasterization_order_attachment_access[] 131e5c31af7Sopenharmony_citname:VkPipelineColorBlendStateCreateFlags is a bitmask type for setting a 132e5c31af7Sopenharmony_cimask of zero or more elink:VkPipelineColorBlendStateCreateFlagBits. 133e5c31af7Sopenharmony_ciendif::VK_ARM_rasterization_order_attachment_access[] 134e5c31af7Sopenharmony_ci-- 135e5c31af7Sopenharmony_ci 136e5c31af7Sopenharmony_ciifdef::VK_ARM_rasterization_order_attachment_access[] 137e5c31af7Sopenharmony_ci[open,refpage='VkPipelineColorBlendStateCreateFlagBits',desc='Bitmask specifying additional parameters of an image',type='enums'] 138e5c31af7Sopenharmony_ci-- 139e5c31af7Sopenharmony_ciBits which can: be set in the 140e5c31af7Sopenharmony_cislink:VkPipelineColorBlendStateCreateInfo::pname:flags parameter are: 141e5c31af7Sopenharmony_ci 142e5c31af7Sopenharmony_ciinclude::{generated}/api/enums/VkPipelineColorBlendStateCreateFlagBits.txt[] 143e5c31af7Sopenharmony_ci 144e5c31af7Sopenharmony_ci * ename:VK_PIPELINE_COLOR_BLEND_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_BIT_ARM 145e5c31af7Sopenharmony_ci indicates that access to color and input attachments will have implicit 146e5c31af7Sopenharmony_ci framebuffer-local memory dependencies, allowing applications to express 147e5c31af7Sopenharmony_ci custom blending operations in a fragment shader. 148e5c31af7Sopenharmony_ci See <<renderpass-feedbackloop, renderpass feedback loops>> for more 149e5c31af7Sopenharmony_ci information. 150e5c31af7Sopenharmony_ci-- 151e5c31af7Sopenharmony_ciendif::VK_ARM_rasterization_order_attachment_access[] 152e5c31af7Sopenharmony_ci 153e5c31af7Sopenharmony_ci[open,refpage='VkPipelineColorBlendAttachmentState',desc='Structure specifying a pipeline color blend attachment state',type='structs'] 154e5c31af7Sopenharmony_ci-- 155e5c31af7Sopenharmony_ciThe sname:VkPipelineColorBlendAttachmentState structure is defined as: 156e5c31af7Sopenharmony_ci 157e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkPipelineColorBlendAttachmentState.txt[] 158e5c31af7Sopenharmony_ci 159e5c31af7Sopenharmony_ci * pname:blendEnable controls whether blending is enabled for the 160e5c31af7Sopenharmony_ci corresponding color attachment. 161e5c31af7Sopenharmony_ci If blending is not enabled, the source fragment's color for that 162e5c31af7Sopenharmony_ci attachment is passed through unmodified. 163e5c31af7Sopenharmony_ci * pname:srcColorBlendFactor selects which blend factor is used to 164e5c31af7Sopenharmony_ci determine the source factors [eq]#(S~r~,S~g~,S~b~)#. 165e5c31af7Sopenharmony_ci * pname:dstColorBlendFactor selects which blend factor is used to 166e5c31af7Sopenharmony_ci determine the destination factors [eq]#(D~r~,D~g~,D~b~)#. 167e5c31af7Sopenharmony_ci * pname:colorBlendOp selects which blend operation is used to calculate 168e5c31af7Sopenharmony_ci the RGB values to write to the color attachment. 169e5c31af7Sopenharmony_ci * pname:srcAlphaBlendFactor selects which blend factor is used to 170e5c31af7Sopenharmony_ci determine the source factor [eq]#S~a~#. 171e5c31af7Sopenharmony_ci * pname:dstAlphaBlendFactor selects which blend factor is used to 172e5c31af7Sopenharmony_ci determine the destination factor [eq]#D~a~#. 173e5c31af7Sopenharmony_ci * pname:alphaBlendOp selects which blend operation is use to calculate the 174e5c31af7Sopenharmony_ci alpha values to write to the color attachment. 175e5c31af7Sopenharmony_ci * pname:colorWriteMask is a bitmask of elink:VkColorComponentFlagBits 176e5c31af7Sopenharmony_ci specifying which of the R, G, B, and/or A components are enabled for 177e5c31af7Sopenharmony_ci writing, as described for the <<framebuffer-color-write-mask,Color Write 178e5c31af7Sopenharmony_ci Mask>>. 179e5c31af7Sopenharmony_ci 180e5c31af7Sopenharmony_ci.Valid Usage 181e5c31af7Sopenharmony_ci**** 182e5c31af7Sopenharmony_ci * [[VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-00608]] 183e5c31af7Sopenharmony_ci If the <<features-dualSrcBlend,dual source blending>> feature is not 184e5c31af7Sopenharmony_ci enabled, pname:srcColorBlendFactor must: not be 185e5c31af7Sopenharmony_ci ename:VK_BLEND_FACTOR_SRC1_COLOR, 186e5c31af7Sopenharmony_ci ename:VK_BLEND_FACTOR_ONE_MINUS_SRC1_COLOR, 187e5c31af7Sopenharmony_ci ename:VK_BLEND_FACTOR_SRC1_ALPHA, or 188e5c31af7Sopenharmony_ci ename:VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA 189e5c31af7Sopenharmony_ci * [[VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-00609]] 190e5c31af7Sopenharmony_ci If the <<features-dualSrcBlend,dual source blending>> feature is not 191e5c31af7Sopenharmony_ci enabled, pname:dstColorBlendFactor must: not be 192e5c31af7Sopenharmony_ci ename:VK_BLEND_FACTOR_SRC1_COLOR, 193e5c31af7Sopenharmony_ci ename:VK_BLEND_FACTOR_ONE_MINUS_SRC1_COLOR, 194e5c31af7Sopenharmony_ci ename:VK_BLEND_FACTOR_SRC1_ALPHA, or 195e5c31af7Sopenharmony_ci ename:VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA 196e5c31af7Sopenharmony_ci * [[VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-00610]] 197e5c31af7Sopenharmony_ci If the <<features-dualSrcBlend,dual source blending>> feature is not 198e5c31af7Sopenharmony_ci enabled, pname:srcAlphaBlendFactor must: not be 199e5c31af7Sopenharmony_ci ename:VK_BLEND_FACTOR_SRC1_COLOR, 200e5c31af7Sopenharmony_ci ename:VK_BLEND_FACTOR_ONE_MINUS_SRC1_COLOR, 201e5c31af7Sopenharmony_ci ename:VK_BLEND_FACTOR_SRC1_ALPHA, or 202e5c31af7Sopenharmony_ci ename:VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA 203e5c31af7Sopenharmony_ci * [[VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-00611]] 204e5c31af7Sopenharmony_ci If the <<features-dualSrcBlend,dual source blending>> feature is not 205e5c31af7Sopenharmony_ci enabled, pname:dstAlphaBlendFactor must: not be 206e5c31af7Sopenharmony_ci ename:VK_BLEND_FACTOR_SRC1_COLOR, 207e5c31af7Sopenharmony_ci ename:VK_BLEND_FACTOR_ONE_MINUS_SRC1_COLOR, 208e5c31af7Sopenharmony_ci ename:VK_BLEND_FACTOR_SRC1_ALPHA, or 209e5c31af7Sopenharmony_ci ename:VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA 210e5c31af7Sopenharmony_ciifdef::VK_EXT_blend_operation_advanced[] 211e5c31af7Sopenharmony_ci * [[VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-01406]] 212e5c31af7Sopenharmony_ci If either of pname:colorBlendOp or pname:alphaBlendOp is an 213e5c31af7Sopenharmony_ci <<framebuffer-blend-advanced,advanced blend operation>>, then 214e5c31af7Sopenharmony_ci pname:colorBlendOp must: equal pname:alphaBlendOp 215e5c31af7Sopenharmony_ci * [[VUID-VkPipelineColorBlendAttachmentState-advancedBlendIndependentBlend-01407]] 216e5c31af7Sopenharmony_ci If 217e5c31af7Sopenharmony_ci slink:VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT::pname:advancedBlendIndependentBlend 218e5c31af7Sopenharmony_ci is ename:VK_FALSE and pname:colorBlendOp is an 219e5c31af7Sopenharmony_ci <<framebuffer-blend-advanced,advanced blend operation>>, then 220e5c31af7Sopenharmony_ci pname:colorBlendOp must: be the same for all attachments 221e5c31af7Sopenharmony_ci * [[VUID-VkPipelineColorBlendAttachmentState-advancedBlendIndependentBlend-01408]] 222e5c31af7Sopenharmony_ci If 223e5c31af7Sopenharmony_ci slink:VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT::pname:advancedBlendIndependentBlend 224e5c31af7Sopenharmony_ci is ename:VK_FALSE and pname:alphaBlendOp is an 225e5c31af7Sopenharmony_ci <<framebuffer-blend-advanced,advanced blend operation>>, then 226e5c31af7Sopenharmony_ci pname:alphaBlendOp must: be the same for all attachments 227e5c31af7Sopenharmony_ci * [[VUID-VkPipelineColorBlendAttachmentState-advancedBlendAllOperations-01409]] 228e5c31af7Sopenharmony_ci If 229e5c31af7Sopenharmony_ci slink:VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT::pname:advancedBlendAllOperations 230e5c31af7Sopenharmony_ci is ename:VK_FALSE, then pname:colorBlendOp must: not be 231e5c31af7Sopenharmony_ci ename:VK_BLEND_OP_ZERO_EXT, ename:VK_BLEND_OP_SRC_EXT, 232e5c31af7Sopenharmony_ci ename:VK_BLEND_OP_DST_EXT, ename:VK_BLEND_OP_SRC_OVER_EXT, 233e5c31af7Sopenharmony_ci ename:VK_BLEND_OP_DST_OVER_EXT, ename:VK_BLEND_OP_SRC_IN_EXT, 234e5c31af7Sopenharmony_ci ename:VK_BLEND_OP_DST_IN_EXT, ename:VK_BLEND_OP_SRC_OUT_EXT, 235e5c31af7Sopenharmony_ci ename:VK_BLEND_OP_DST_OUT_EXT, ename:VK_BLEND_OP_SRC_ATOP_EXT, 236e5c31af7Sopenharmony_ci ename:VK_BLEND_OP_DST_ATOP_EXT, ename:VK_BLEND_OP_XOR_EXT, 237e5c31af7Sopenharmony_ci ename:VK_BLEND_OP_INVERT_EXT, ename:VK_BLEND_OP_INVERT_RGB_EXT, 238e5c31af7Sopenharmony_ci ename:VK_BLEND_OP_LINEARDODGE_EXT, ename:VK_BLEND_OP_LINEARBURN_EXT, 239e5c31af7Sopenharmony_ci ename:VK_BLEND_OP_VIVIDLIGHT_EXT, ename:VK_BLEND_OP_LINEARLIGHT_EXT, 240e5c31af7Sopenharmony_ci ename:VK_BLEND_OP_PINLIGHT_EXT, ename:VK_BLEND_OP_HARDMIX_EXT, 241e5c31af7Sopenharmony_ci ename:VK_BLEND_OP_PLUS_EXT, ename:VK_BLEND_OP_PLUS_CLAMPED_EXT, 242e5c31af7Sopenharmony_ci ename:VK_BLEND_OP_PLUS_CLAMPED_ALPHA_EXT, 243e5c31af7Sopenharmony_ci ename:VK_BLEND_OP_PLUS_DARKER_EXT, ename:VK_BLEND_OP_MINUS_EXT, 244e5c31af7Sopenharmony_ci ename:VK_BLEND_OP_MINUS_CLAMPED_EXT, ename:VK_BLEND_OP_CONTRAST_EXT, 245e5c31af7Sopenharmony_ci ename:VK_BLEND_OP_INVERT_OVG_EXT, ename:VK_BLEND_OP_RED_EXT, 246e5c31af7Sopenharmony_ci ename:VK_BLEND_OP_GREEN_EXT, or ename:VK_BLEND_OP_BLUE_EXT 247e5c31af7Sopenharmony_ci * [[VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-01410]] 248e5c31af7Sopenharmony_ci If pname:colorBlendOp or pname:alphaBlendOp is an 249e5c31af7Sopenharmony_ci <<framebuffer-blend-advanced,advanced blend operation>>, then 250e5c31af7Sopenharmony_ci pname:colorAttachmentCount of the subpass this pipeline is compiled 251e5c31af7Sopenharmony_ci against must: be less than or equal to 252e5c31af7Sopenharmony_ci slink:VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT::pname:advancedBlendMaxColorAttachments 253e5c31af7Sopenharmony_ciendif::VK_EXT_blend_operation_advanced[] 254e5c31af7Sopenharmony_ciifdef::VK_KHR_portability_subset[] 255e5c31af7Sopenharmony_ci * [[VUID-VkPipelineColorBlendAttachmentState-constantAlphaColorBlendFactors-04454]] 256e5c31af7Sopenharmony_ci If the `apiext:VK_KHR_portability_subset` extension is enabled, and 257e5c31af7Sopenharmony_ci slink:VkPhysicalDevicePortabilitySubsetFeaturesKHR::pname:constantAlphaColorBlendFactors 258e5c31af7Sopenharmony_ci is ename:VK_FALSE, pname:srcColorBlendFactor must: not be 259e5c31af7Sopenharmony_ci ename:VK_BLEND_FACTOR_CONSTANT_ALPHA or 260e5c31af7Sopenharmony_ci ename:VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA 261e5c31af7Sopenharmony_ci * [[VUID-VkPipelineColorBlendAttachmentState-constantAlphaColorBlendFactors-04455]] 262e5c31af7Sopenharmony_ci If the `apiext:VK_KHR_portability_subset` extension is enabled, and 263e5c31af7Sopenharmony_ci slink:VkPhysicalDevicePortabilitySubsetFeaturesKHR::pname:constantAlphaColorBlendFactors 264e5c31af7Sopenharmony_ci is ename:VK_FALSE, pname:dstColorBlendFactor must: not be 265e5c31af7Sopenharmony_ci ename:VK_BLEND_FACTOR_CONSTANT_ALPHA or 266e5c31af7Sopenharmony_ci ename:VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA 267e5c31af7Sopenharmony_ciendif::VK_KHR_portability_subset[] 268e5c31af7Sopenharmony_ci**** 269e5c31af7Sopenharmony_ci 270e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkPipelineColorBlendAttachmentState.txt[] 271e5c31af7Sopenharmony_ci-- 272e5c31af7Sopenharmony_ci 273e5c31af7Sopenharmony_ci 274e5c31af7Sopenharmony_ci[[framebuffer-blendfactors]] 275e5c31af7Sopenharmony_ci=== Blend Factors 276e5c31af7Sopenharmony_ci 277e5c31af7Sopenharmony_ci[open,refpage='VkBlendFactor',desc='Framebuffer blending factors',type='enums'] 278e5c31af7Sopenharmony_ci-- 279e5c31af7Sopenharmony_ciThe source and destination color and alpha blending factors are selected 280e5c31af7Sopenharmony_cifrom the enum: 281e5c31af7Sopenharmony_ci 282e5c31af7Sopenharmony_ciinclude::{generated}/api/enums/VkBlendFactor.txt[] 283e5c31af7Sopenharmony_ci 284e5c31af7Sopenharmony_ciThe semantics of the enum values are described in the table below: 285e5c31af7Sopenharmony_ci 286e5c31af7Sopenharmony_ci.Blend Factors 287e5c31af7Sopenharmony_ci[width="100%",options="header",align="center",cols="59%,28%,13%"] 288e5c31af7Sopenharmony_ci|==== 289e5c31af7Sopenharmony_ci|elink:VkBlendFactor | RGB Blend Factors [eq]#(S~r~,S~g~,S~b~)# or [eq]#(D~r~,D~g~,D~b~)# | Alpha Blend Factor ([eq]#S~a~# or [eq]#D~a~#) 290e5c31af7Sopenharmony_ci|ename:VK_BLEND_FACTOR_ZERO | [eq]#(0,0,0)# | [eq]#0# 291e5c31af7Sopenharmony_ci|ename:VK_BLEND_FACTOR_ONE | [eq]#(1,1,1)# | [eq]#1# 292e5c31af7Sopenharmony_ci|ename:VK_BLEND_FACTOR_SRC_COLOR | [eq]#(R~s0~,G~s0~,B~s0~)# | [eq]#A~s0~# 293e5c31af7Sopenharmony_ci|ename:VK_BLEND_FACTOR_ONE_MINUS_SRC_COLOR | [eq]#(1-R~s0~,1-G~s0~,1-B~s0~)# | [eq]#1-A~s0~# 294e5c31af7Sopenharmony_ci|ename:VK_BLEND_FACTOR_DST_COLOR | [eq]#(R~d~,G~d~,B~d~)# | [eq]#A~d~# 295e5c31af7Sopenharmony_ci|ename:VK_BLEND_FACTOR_ONE_MINUS_DST_COLOR | [eq]#(1-R~d~,1-G~d~,1-B~d~)# | [eq]#1-A~d~# 296e5c31af7Sopenharmony_ci|ename:VK_BLEND_FACTOR_SRC_ALPHA | [eq]#(A~s0~,A~s0~,A~s0~)# | [eq]#A~s0~# 297e5c31af7Sopenharmony_ci|ename:VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA | [eq]#(1-A~s0~,1-A~s0~,1-A~s0~)# | [eq]#1-A~s0~# 298e5c31af7Sopenharmony_ci|ename:VK_BLEND_FACTOR_DST_ALPHA | [eq]#(A~d~,A~d~,A~d~)# | [eq]#A~d~# 299e5c31af7Sopenharmony_ci|ename:VK_BLEND_FACTOR_ONE_MINUS_DST_ALPHA | [eq]#(1-A~d~,1-A~d~,1-A~d~)# | [eq]#1-A~d~# 300e5c31af7Sopenharmony_ci|ename:VK_BLEND_FACTOR_CONSTANT_COLOR | [eq]#(R~c~,G~c~,B~c~)# | [eq]#A~c~# 301e5c31af7Sopenharmony_ci|ename:VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR | [eq]#(1-R~c~,1-G~c~,1-B~c~)# | [eq]#1-A~c~# 302e5c31af7Sopenharmony_ci|ename:VK_BLEND_FACTOR_CONSTANT_ALPHA | [eq]#(A~c~,A~c~,A~c~)# | [eq]#A~c~# 303e5c31af7Sopenharmony_ci|ename:VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA | [eq]#(1-A~c~,1-A~c~,1-A~c~)# | [eq]#1-A~c~# 304e5c31af7Sopenharmony_ci|ename:VK_BLEND_FACTOR_SRC_ALPHA_SATURATE | [eq]#(f,f,f)#; [eq]#f = min(A~s0~,1-A~d~)# | [eq]#1# 305e5c31af7Sopenharmony_ci|ename:VK_BLEND_FACTOR_SRC1_COLOR | [eq]#(R~s1~,G~s1~,B~s1~)# | [eq]#A~s1~# 306e5c31af7Sopenharmony_ci|ename:VK_BLEND_FACTOR_ONE_MINUS_SRC1_COLOR | [eq]#(1-R~s1~,1-G~s1~,1-B~s1~)# | [eq]#1-A~s1~# 307e5c31af7Sopenharmony_ci|ename:VK_BLEND_FACTOR_SRC1_ALPHA | [eq]#(A~s1~,A~s1~,A~s1~)# | [eq]#A~s1~# 308e5c31af7Sopenharmony_ci|ename:VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA | [eq]#(1-A~s1~,1-A~s1~,1-A~s1~)# | [eq]#1-A~s1~# 309e5c31af7Sopenharmony_ci|==== 310e5c31af7Sopenharmony_ci 311e5c31af7Sopenharmony_ciIn this table, the following conventions are used: 312e5c31af7Sopenharmony_ci 313e5c31af7Sopenharmony_ci * [eq]#R~s0~,G~s0~,B~s0~# and [eq]#A~s0~# represent the first source color 314e5c31af7Sopenharmony_ci R, G, B, and A components, respectively, for the fragment output 315e5c31af7Sopenharmony_ci location corresponding to the color attachment being blended. 316e5c31af7Sopenharmony_ci * [eq]#R~s1~,G~s1~,B~s1~# and [eq]#A~s1~# represent the second source 317e5c31af7Sopenharmony_ci color R, G, B, and A components, respectively, used in dual source 318e5c31af7Sopenharmony_ci blending modes, for the fragment output location corresponding to the 319e5c31af7Sopenharmony_ci color attachment being blended. 320e5c31af7Sopenharmony_ci * [eq]#R~d~,G~d~,B~d~# and [eq]#A~d~# represent the R, G, B, and A 321e5c31af7Sopenharmony_ci components of the destination color. 322e5c31af7Sopenharmony_ci That is, the color currently in the corresponding color attachment for 323e5c31af7Sopenharmony_ci this fragment/sample. 324e5c31af7Sopenharmony_ci * [eq]#R~c~,G~c~,B~c~# and [eq]#A~c~# represent the blend constant R, G, 325e5c31af7Sopenharmony_ci B, and A components, respectively. 326e5c31af7Sopenharmony_ci-- 327e5c31af7Sopenharmony_ci 328e5c31af7Sopenharmony_ci[open,refpage='vkCmdSetBlendConstants',desc='Set the values of blend constants',type='protos'] 329e5c31af7Sopenharmony_ci-- 330e5c31af7Sopenharmony_ciTo <<pipelines-dynamic-state, dynamically set and change>> the blend 331e5c31af7Sopenharmony_ciconstants, call: 332e5c31af7Sopenharmony_ci 333e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCmdSetBlendConstants.txt[] 334e5c31af7Sopenharmony_ci 335e5c31af7Sopenharmony_ci * pname:commandBuffer is the command buffer into which the command will be 336e5c31af7Sopenharmony_ci recorded. 337e5c31af7Sopenharmony_ci * pname:blendConstants is a pointer to an array of four values specifying 338e5c31af7Sopenharmony_ci the [eq]#R~c~#, [eq]#G~c~#, [eq]#B~c~#, and [eq]#A~c~# components of the 339e5c31af7Sopenharmony_ci blend constant color used in blending, depending on the 340e5c31af7Sopenharmony_ci <<framebuffer-blendfactors,blend factor>>. 341e5c31af7Sopenharmony_ci 342e5c31af7Sopenharmony_ci[[framebuffer-blendconstants]] 343e5c31af7Sopenharmony_ciThis command sets blend constants for subsequent drawing commands when the 344e5c31af7Sopenharmony_cigraphics pipeline is created with ename:VK_DYNAMIC_STATE_BLEND_CONSTANTS set 345e5c31af7Sopenharmony_ciin slink:VkPipelineDynamicStateCreateInfo::pname:pDynamicStates. 346e5c31af7Sopenharmony_ciOtherwise, this state is specified by the 347e5c31af7Sopenharmony_cislink:VkPipelineColorBlendStateCreateInfo::pname:blendConstants values used 348e5c31af7Sopenharmony_cito create the currently active pipeline. 349e5c31af7Sopenharmony_ci 350e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkCmdSetBlendConstants.txt[] 351e5c31af7Sopenharmony_ci-- 352e5c31af7Sopenharmony_ci 353e5c31af7Sopenharmony_ci 354e5c31af7Sopenharmony_ci[[framebuffer-dsb]] 355e5c31af7Sopenharmony_ci=== Dual-Source Blending 356e5c31af7Sopenharmony_ci 357e5c31af7Sopenharmony_ciBlend factors that use the secondary color input 358e5c31af7Sopenharmony_ci[eq]#(R~s1~,G~s1~,B~s1~,A~s1~)# (ename:VK_BLEND_FACTOR_SRC1_COLOR, 359e5c31af7Sopenharmony_ciename:VK_BLEND_FACTOR_ONE_MINUS_SRC1_COLOR, 360e5c31af7Sopenharmony_ciename:VK_BLEND_FACTOR_SRC1_ALPHA, and 361e5c31af7Sopenharmony_ciename:VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA) may: consume implementation 362e5c31af7Sopenharmony_ciresources that could otherwise be used for rendering to multiple color 363e5c31af7Sopenharmony_ciattachments. 364e5c31af7Sopenharmony_ciTherefore, the number of color attachments that can: be used in a 365e5c31af7Sopenharmony_ciframebuffer may: be lower when using dual-source blending. 366e5c31af7Sopenharmony_ci 367e5c31af7Sopenharmony_ciDual-source blending is only supported if the 368e5c31af7Sopenharmony_ci<<features-dualSrcBlend,pname:dualSrcBlend>> feature is enabled. 369e5c31af7Sopenharmony_ci 370e5c31af7Sopenharmony_ciThe maximum number of color attachments that can: be used in a subpass when 371e5c31af7Sopenharmony_ciusing dual-source blending functions is implementation-dependent and is 372e5c31af7Sopenharmony_cireported as the pname:maxFragmentDualSrcAttachments member of 373e5c31af7Sopenharmony_cisname:VkPhysicalDeviceLimits. 374e5c31af7Sopenharmony_ci 375e5c31af7Sopenharmony_ciWhen using a fragment shader with dual-source blending functions, the color 376e5c31af7Sopenharmony_cioutputs are bound to the first and second inputs of the blender using the 377e5c31af7Sopenharmony_cicode:Index decoration, as described in <<interfaces-fragmentoutput,Fragment 378e5c31af7Sopenharmony_ciOutput Interface>>. 379e5c31af7Sopenharmony_ciIf the second color input to the blender is not written in the shader, or if 380e5c31af7Sopenharmony_cino output is bound to the second input of a blender, the result of the 381e5c31af7Sopenharmony_ciblending operation is not defined. 382e5c31af7Sopenharmony_ci 383e5c31af7Sopenharmony_ci 384e5c31af7Sopenharmony_ci[[framebuffer-blendoperations]] 385e5c31af7Sopenharmony_ci=== Blend Operations 386e5c31af7Sopenharmony_ci 387e5c31af7Sopenharmony_ci[open,refpage='VkBlendOp',desc='Framebuffer blending operations',type='enums'] 388e5c31af7Sopenharmony_ci-- 389e5c31af7Sopenharmony_ciOnce the source and destination blend factors have been selected, they along 390e5c31af7Sopenharmony_ciwith the source and destination components are passed to the blending 391e5c31af7Sopenharmony_cioperations. 392e5c31af7Sopenharmony_ciRGB and alpha components can: use different operations. 393e5c31af7Sopenharmony_ciPossible values of elink:VkBlendOp, specifying the operations, are: 394e5c31af7Sopenharmony_ci 395e5c31af7Sopenharmony_ciinclude::{generated}/api/enums/VkBlendOp.txt[] 396e5c31af7Sopenharmony_ci 397e5c31af7Sopenharmony_ci<<< 398e5c31af7Sopenharmony_ci 399e5c31af7Sopenharmony_ciThe semantics of the basic blend operations are described in the table 400e5c31af7Sopenharmony_cibelow: 401e5c31af7Sopenharmony_ci 402e5c31af7Sopenharmony_ci.Basic Blend Operations 403e5c31af7Sopenharmony_ci[width="100%",cols="45%,30%,25%",options="header",align="center"] 404e5c31af7Sopenharmony_ci|==== 405e5c31af7Sopenharmony_ci|elink:VkBlendOp | RGB Components | Alpha Component 406e5c31af7Sopenharmony_ci 407e5c31af7Sopenharmony_ci|ename:VK_BLEND_OP_ADD 408e5c31af7Sopenharmony_ci| [eq]#R = R~s0~ {times} S~r~ {plus} R~d~ {times} D~r~# + 409e5c31af7Sopenharmony_ci [eq]#G = G~s0~ {times} S~g~ {plus} G~d~ {times} D~g~# + 410e5c31af7Sopenharmony_ci [eq]#B = B~s0~ {times} S~b~ {plus} B~d~ {times} D~b~# 411e5c31af7Sopenharmony_ci| [eq]#A = A~s0~ {times} S~a~ {plus} A~d~ {times} D~a~# 412e5c31af7Sopenharmony_ci 413e5c31af7Sopenharmony_ci|ename:VK_BLEND_OP_SUBTRACT 414e5c31af7Sopenharmony_ci| [eq]#R = R~s0~ {times} S~r~ - R~d~ {times} D~r~# + 415e5c31af7Sopenharmony_ci [eq]#G = G~s0~ {times} S~g~ - G~d~ {times} D~g~# + 416e5c31af7Sopenharmony_ci [eq]#B = B~s0~ {times} S~b~ - B~d~ {times} D~b~# 417e5c31af7Sopenharmony_ci| [eq]#A = A~s0~ {times} S~a~ - A~d~ {times} D~a~# 418e5c31af7Sopenharmony_ci 419e5c31af7Sopenharmony_ci|ename:VK_BLEND_OP_REVERSE_SUBTRACT 420e5c31af7Sopenharmony_ci| [eq]#R = R~d~ {times} D~r~ - R~s0~ {times} S~r~# + 421e5c31af7Sopenharmony_ci [eq]#G = G~d~ {times} D~g~ - G~s0~ {times} S~g~# + 422e5c31af7Sopenharmony_ci [eq]#B = B~d~ {times} D~b~ - B~s0~ {times} S~b~# 423e5c31af7Sopenharmony_ci| [eq]#A = A~d~ {times} D~a~ - A~s0~ {times} S~a~# 424e5c31af7Sopenharmony_ci 425e5c31af7Sopenharmony_ci|ename:VK_BLEND_OP_MIN 426e5c31af7Sopenharmony_ci| [eq]#R = min(R~s0~,R~d~)# + 427e5c31af7Sopenharmony_ci [eq]#G = min(G~s0~,G~d~)# + 428e5c31af7Sopenharmony_ci [eq]#B = min(B~s0~,B~d~)# 429e5c31af7Sopenharmony_ci| [eq]#A = min(A~s0~,A~d~)# 430e5c31af7Sopenharmony_ci 431e5c31af7Sopenharmony_ci|ename:VK_BLEND_OP_MAX 432e5c31af7Sopenharmony_ci| [eq]#R = max(R~s0~,R~d~)# + 433e5c31af7Sopenharmony_ci [eq]#G = max(G~s0~,G~d~)# + 434e5c31af7Sopenharmony_ci [eq]#B = max(B~s0~,B~d~)# 435e5c31af7Sopenharmony_ci| [eq]#A = max(A~s0~,A~d~)# 436e5c31af7Sopenharmony_ci|==== 437e5c31af7Sopenharmony_ci 438e5c31af7Sopenharmony_ciIn this table, the following conventions are used: 439e5c31af7Sopenharmony_ci 440e5c31af7Sopenharmony_ci * [eq]#R~s0~, G~s0~, B~s0~# and [eq]#A~s0~# represent the first source 441e5c31af7Sopenharmony_ci color R, G, B, and A components, respectively. 442e5c31af7Sopenharmony_ci * [eq]#R~d~, G~d~, B~d~# and [eq]#A~d~# represent the R, G, B, and A 443e5c31af7Sopenharmony_ci components of the destination color. 444e5c31af7Sopenharmony_ci That is, the color currently in the corresponding color attachment for 445e5c31af7Sopenharmony_ci this fragment/sample. 446e5c31af7Sopenharmony_ci * [eq]#S~r~, S~g~, S~b~# and [eq]#S~a~# represent the source blend factor 447e5c31af7Sopenharmony_ci R, G, B, and A components, respectively. 448e5c31af7Sopenharmony_ci * [eq]#D~r~, D~g~, D~b~# and [eq]#D~a~# represent the destination blend 449e5c31af7Sopenharmony_ci factor R, G, B, and A components, respectively. 450e5c31af7Sopenharmony_ci 451e5c31af7Sopenharmony_ciThe blending operation produces a new set of values [eq]#R, G, B# and 452e5c31af7Sopenharmony_ci[eq]#A#, which are written to the framebuffer attachment. 453e5c31af7Sopenharmony_ciIf blending is not enabled for this attachment, then [eq]#R, G, B# and 454e5c31af7Sopenharmony_ci[eq]#A# are assigned [eq]#R~s0~, G~s0~, B~s0~# and [eq]#A~s0~#, 455e5c31af7Sopenharmony_cirespectively. 456e5c31af7Sopenharmony_ci 457e5c31af7Sopenharmony_ciIf the color attachment is fixed-point, the components of the source and 458e5c31af7Sopenharmony_cidestination values and blend factors are each clamped to [eq]#[0,1]# or 459e5c31af7Sopenharmony_ci[eq]#[-1,1]# respectively for an unsigned normalized or signed normalized 460e5c31af7Sopenharmony_cicolor attachment prior to evaluating the blend operations. 461e5c31af7Sopenharmony_ciIf the color attachment is floating-point, no clamping occurs. 462e5c31af7Sopenharmony_ci-- 463e5c31af7Sopenharmony_ci 464e5c31af7Sopenharmony_ciIf the numeric format of a framebuffer attachment uses sRGB encoding, the R, 465e5c31af7Sopenharmony_ciG, and B destination color values (after conversion from fixed-point to 466e5c31af7Sopenharmony_cifloating-point) are considered to be encoded for the sRGB color space and 467e5c31af7Sopenharmony_cihence are linearized prior to their use in blending. 468e5c31af7Sopenharmony_ciEach R, G, and B component is converted from nonlinear to linear as 469e5c31af7Sopenharmony_cidescribed in the "`sRGB EOTF`" section of the <<data-format,Khronos Data 470e5c31af7Sopenharmony_ciFormat Specification>>. 471e5c31af7Sopenharmony_ciIf the format is not sRGB, no linearization is performed. 472e5c31af7Sopenharmony_ci 473e5c31af7Sopenharmony_ciIf the numeric format of a framebuffer attachment uses sRGB encoding, then 474e5c31af7Sopenharmony_cithe final R, G and B values are converted into the nonlinear sRGB 475e5c31af7Sopenharmony_cirepresentation before being written to the framebuffer attachment as 476e5c31af7Sopenharmony_cidescribed in the "`sRGB EOTF^ -1^`" section of the Khronos Data Format 477e5c31af7Sopenharmony_ciSpecification. 478e5c31af7Sopenharmony_ci 479e5c31af7Sopenharmony_ciIf the numeric format of a framebuffer color attachment is not sRGB encoded 480e5c31af7Sopenharmony_cithen the resulting [eq]#c~s~# values for R, G and B are unmodified. 481e5c31af7Sopenharmony_ciThe value of A is never sRGB encoded. 482e5c31af7Sopenharmony_ciThat is, the alpha component is always stored in memory as linear. 483e5c31af7Sopenharmony_ci 484e5c31af7Sopenharmony_ciIf the framebuffer color attachment is ename:VK_ATTACHMENT_UNUSED, no writes 485e5c31af7Sopenharmony_ciare performed through that attachment. 486e5c31af7Sopenharmony_ciWrites are not performed to framebuffer color attachments greater than or 487e5c31af7Sopenharmony_ciequal to the sname:VkSubpassDescription::pname:colorAttachmentCount 488e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_2,VK_KHR_create_renderpass2[] 489e5c31af7Sopenharmony_cior sname:VkSubpassDescription2::pname:colorAttachmentCount 490e5c31af7Sopenharmony_ciendif::VK_VERSION_1_2,VK_KHR_create_renderpass2[] 491e5c31af7Sopenharmony_civalue. 492e5c31af7Sopenharmony_ci 493e5c31af7Sopenharmony_ciifdef::VK_EXT_blend_operation_advanced[] 494e5c31af7Sopenharmony_ciinclude::{chapters}/VK_EXT_blend_operation_advanced/advanced_blend.txt[] 495e5c31af7Sopenharmony_ciendif::VK_EXT_blend_operation_advanced[] 496e5c31af7Sopenharmony_ci 497e5c31af7Sopenharmony_ci 498e5c31af7Sopenharmony_ci[[framebuffer-logicop]] 499e5c31af7Sopenharmony_ci== Logical Operations 500e5c31af7Sopenharmony_ci 501e5c31af7Sopenharmony_ciThe application can: enable a _logical operation_ between the fragment's 502e5c31af7Sopenharmony_cicolor values and the existing value in the framebuffer attachment. 503e5c31af7Sopenharmony_ciThis logical operation is applied prior to updating the framebuffer 504e5c31af7Sopenharmony_ciattachment. 505e5c31af7Sopenharmony_ciLogical operations are applied only for signed and unsigned integer and 506e5c31af7Sopenharmony_cinormalized integer framebuffers. 507e5c31af7Sopenharmony_ciLogical operations are not applied to floating-point or sRGB format color 508e5c31af7Sopenharmony_ciattachments. 509e5c31af7Sopenharmony_ci 510e5c31af7Sopenharmony_ci[open,refpage='VkLogicOp',desc='Framebuffer logical operations',type='enums'] 511e5c31af7Sopenharmony_ci-- 512e5c31af7Sopenharmony_ciLogical operations are controlled by the pname:logicOpEnable and 513e5c31af7Sopenharmony_cipname:logicOp members of slink:VkPipelineColorBlendStateCreateInfo. 514e5c31af7Sopenharmony_ciifdef::VK_EXT_extended_dynamic_state2[] 515e5c31af7Sopenharmony_ciIt can also be controlled by flink:vkCmdSetLogicOpEXT if graphics pipeline 516e5c31af7Sopenharmony_ciis created with ename:VK_DYNAMIC_STATE_LOGIC_OP_EXT set in 517e5c31af7Sopenharmony_cislink:VkPipelineDynamicStateCreateInfo::pname:pDynamicStates. 518e5c31af7Sopenharmony_ciendif::VK_EXT_extended_dynamic_state2[] 519e5c31af7Sopenharmony_ciIf pname:logicOpEnable is ename:VK_TRUE, then a logical operation selected 520e5c31af7Sopenharmony_ciby pname:logicOp is applied between each color attachment and the fragment's 521e5c31af7Sopenharmony_cicorresponding output value, and blending of all attachments is treated as if 522e5c31af7Sopenharmony_ciit were disabled. 523e5c31af7Sopenharmony_ciAny attachments using color formats for which logical operations are not 524e5c31af7Sopenharmony_cisupported simply pass through the color values unmodified. 525e5c31af7Sopenharmony_ciThe logical operation is applied independently for each of the red, green, 526e5c31af7Sopenharmony_ciblue, and alpha components. 527e5c31af7Sopenharmony_ciThe pname:logicOp is selected from the following operations: 528e5c31af7Sopenharmony_ci 529e5c31af7Sopenharmony_ciinclude::{generated}/api/enums/VkLogicOp.txt[] 530e5c31af7Sopenharmony_ci 531e5c31af7Sopenharmony_ci<<< 532e5c31af7Sopenharmony_ci 533e5c31af7Sopenharmony_ciThe logical operations supported by Vulkan are summarized in the following 534e5c31af7Sopenharmony_citable in which 535e5c31af7Sopenharmony_ci 536e5c31af7Sopenharmony_ci * [eq]#{lnot}# is bitwise invert, 537e5c31af7Sopenharmony_ci * [eq]#{land}# is bitwise and, 538e5c31af7Sopenharmony_ci * [eq]#{lor}# is bitwise or, 539e5c31af7Sopenharmony_ci * [eq]#{oplus}# is bitwise exclusive or, 540e5c31af7Sopenharmony_ci * [eq]#s# is the fragment's [eq]#R~s0~, G~s0~, B~s0~# or [eq]#A~s0~# 541e5c31af7Sopenharmony_ci component value for the fragment output corresponding to the color 542e5c31af7Sopenharmony_ci attachment being updated, and 543e5c31af7Sopenharmony_ci * [eq]#d# is the color attachment's [eq]#R, G, B# or [eq]#A# component 544e5c31af7Sopenharmony_ci value: 545e5c31af7Sopenharmony_ci 546e5c31af7Sopenharmony_ci.Logical Operations 547e5c31af7Sopenharmony_ci[width="75%",options="header",align="center"] 548e5c31af7Sopenharmony_ci|==== 549e5c31af7Sopenharmony_ci|Mode | Operation 550e5c31af7Sopenharmony_ci|ename:VK_LOGIC_OP_CLEAR | [eq]#0# 551e5c31af7Sopenharmony_ci|ename:VK_LOGIC_OP_AND | [eq]#s {land} d# 552e5c31af7Sopenharmony_ci|ename:VK_LOGIC_OP_AND_REVERSE | [eq]#s {land} {lnot} d# 553e5c31af7Sopenharmony_ci|ename:VK_LOGIC_OP_COPY | [eq]#s# 554e5c31af7Sopenharmony_ci|ename:VK_LOGIC_OP_AND_INVERTED | [eq]#{lnot} s {land} d# 555e5c31af7Sopenharmony_ci|ename:VK_LOGIC_OP_NO_OP | [eq]#d# 556e5c31af7Sopenharmony_ci|ename:VK_LOGIC_OP_XOR | [eq]#s {oplus} d# 557e5c31af7Sopenharmony_ci|ename:VK_LOGIC_OP_OR | [eq]#s {lor} d# 558e5c31af7Sopenharmony_ci|ename:VK_LOGIC_OP_NOR | [eq]#{lnot} (s {lor} d)# 559e5c31af7Sopenharmony_ci|ename:VK_LOGIC_OP_EQUIVALENT | [eq]#{lnot} (s {oplus} d)# 560e5c31af7Sopenharmony_ci|ename:VK_LOGIC_OP_INVERT | [eq]#{lnot} d# 561e5c31af7Sopenharmony_ci|ename:VK_LOGIC_OP_OR_REVERSE | [eq]#s {lor} {lnot} d# 562e5c31af7Sopenharmony_ci|ename:VK_LOGIC_OP_COPY_INVERTED | [eq]#{lnot} s# 563e5c31af7Sopenharmony_ci|ename:VK_LOGIC_OP_OR_INVERTED | [eq]#{lnot} s {lor} d# 564e5c31af7Sopenharmony_ci|ename:VK_LOGIC_OP_NAND | [eq]#{lnot} (s {land} d)# 565e5c31af7Sopenharmony_ci|ename:VK_LOGIC_OP_SET | all 1s 566e5c31af7Sopenharmony_ci|==== 567e5c31af7Sopenharmony_ci 568e5c31af7Sopenharmony_ciThe result of the logical operation is then written to the color attachment 569e5c31af7Sopenharmony_cias controlled by the component write mask, described in 570e5c31af7Sopenharmony_ci<<framebuffer-blendoperations,Blend Operations>>. 571e5c31af7Sopenharmony_ci-- 572e5c31af7Sopenharmony_ci 573e5c31af7Sopenharmony_ciifdef::VK_EXT_extended_dynamic_state2[] 574e5c31af7Sopenharmony_ci[open,refpage='vkCmdSetLogicOpEXT',desc='Select which logical operation to apply for blend state dynamically for a command buffer',type='protos'] 575e5c31af7Sopenharmony_ci-- 576e5c31af7Sopenharmony_ciTo <<pipelines-dynamic-state, dynamically set>> the logical operation to 577e5c31af7Sopenharmony_ciapply for blend state, call: 578e5c31af7Sopenharmony_ci 579e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCmdSetLogicOpEXT.txt[] 580e5c31af7Sopenharmony_ci 581e5c31af7Sopenharmony_ci * pname:commandBuffer is the command buffer into which the command will be 582e5c31af7Sopenharmony_ci recorded. 583e5c31af7Sopenharmony_ci * pname:logicOp specifies the logical operation to apply for blend state. 584e5c31af7Sopenharmony_ci 585e5c31af7Sopenharmony_ciThis command sets the logical operation for blend state for subsequent 586e5c31af7Sopenharmony_cidrawing commands when the graphics pipeline is created with 587e5c31af7Sopenharmony_ciename:VK_DYNAMIC_STATE_LOGIC_OP_EXT set in 588e5c31af7Sopenharmony_cislink:VkPipelineDynamicStateCreateInfo::pname:pDynamicStates. 589e5c31af7Sopenharmony_ciOtherwise, this state is specified by the 590e5c31af7Sopenharmony_cislink:VkPipelineColorBlendStateCreateInfo::pname:logicOp value used to 591e5c31af7Sopenharmony_cicreate the currently active pipeline. 592e5c31af7Sopenharmony_ci 593e5c31af7Sopenharmony_ci.Valid Usage 594e5c31af7Sopenharmony_ci**** 595e5c31af7Sopenharmony_ci * [[VUID-vkCmdSetLogicOpEXT-None-04867]] 596e5c31af7Sopenharmony_ci The <<features-extendedDynamicState2LogicOp, 597e5c31af7Sopenharmony_ci extendedDynamicState2LogicOp>> feature must: be enabled 598e5c31af7Sopenharmony_ci**** 599e5c31af7Sopenharmony_ci 600e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkCmdSetLogicOpEXT.txt[] 601e5c31af7Sopenharmony_ci-- 602e5c31af7Sopenharmony_ciendif::VK_EXT_extended_dynamic_state2[] 603e5c31af7Sopenharmony_ci 604e5c31af7Sopenharmony_ci 605e5c31af7Sopenharmony_ci[[framebuffer-color-write-mask]] 606e5c31af7Sopenharmony_ci== Color Write Mask 607e5c31af7Sopenharmony_ci 608e5c31af7Sopenharmony_ci[open,refpage='VkColorComponentFlagBits',desc='Bitmask controlling which components are written to the framebuffer',type='enums'] 609e5c31af7Sopenharmony_ci-- 610e5c31af7Sopenharmony_ciBits which can: be set in 611e5c31af7Sopenharmony_cislink:VkPipelineColorBlendAttachmentState::pname:colorWriteMask to determine 612e5c31af7Sopenharmony_ciwhether the final color values [eq]#R, G, B# and [eq]#A# are written to the 613e5c31af7Sopenharmony_ciframebuffer attachment are: 614e5c31af7Sopenharmony_ci 615e5c31af7Sopenharmony_ciinclude::{generated}/api/enums/VkColorComponentFlagBits.txt[] 616e5c31af7Sopenharmony_ci 617e5c31af7Sopenharmony_ci * ename:VK_COLOR_COMPONENT_R_BIT specifies that the [eq]#R# value is 618e5c31af7Sopenharmony_ci written to the color attachment for the appropriate sample. 619e5c31af7Sopenharmony_ci Otherwise, the value in memory is unmodified. 620e5c31af7Sopenharmony_ci * ename:VK_COLOR_COMPONENT_G_BIT specifies that the [eq]#G# value is 621e5c31af7Sopenharmony_ci written to the color attachment for the appropriate sample. 622e5c31af7Sopenharmony_ci Otherwise, the value in memory is unmodified. 623e5c31af7Sopenharmony_ci * ename:VK_COLOR_COMPONENT_B_BIT specifies that the [eq]#B# value is 624e5c31af7Sopenharmony_ci written to the color attachment for the appropriate sample. 625e5c31af7Sopenharmony_ci Otherwise, the value in memory is unmodified. 626e5c31af7Sopenharmony_ci * ename:VK_COLOR_COMPONENT_A_BIT specifies that the [eq]#A# value is 627e5c31af7Sopenharmony_ci written to the color attachment for the appropriate sample. 628e5c31af7Sopenharmony_ci Otherwise, the value in memory is unmodified. 629e5c31af7Sopenharmony_ci 630e5c31af7Sopenharmony_ciThe color write mask operation is applied regardless of whether blending is 631e5c31af7Sopenharmony_cienabled. 632e5c31af7Sopenharmony_ci 633e5c31af7Sopenharmony_ciifdef::VK_EXT_color_write_enable[] 634e5c31af7Sopenharmony_ciThe color write mask operation is applied only if 635e5c31af7Sopenharmony_ci<<framebuffer-color-write-enable,Color Write Enable>> is enabled for the 636e5c31af7Sopenharmony_cirespective attachment. 637e5c31af7Sopenharmony_ciOtherwise the color write mask is ignored and writes to all components of 638e5c31af7Sopenharmony_cithe attachment are disabled. 639e5c31af7Sopenharmony_ciendif::VK_EXT_color_write_enable[] 640e5c31af7Sopenharmony_ci-- 641e5c31af7Sopenharmony_ci 642e5c31af7Sopenharmony_ci[open,refpage='VkColorComponentFlags',desc='Bitmask of VkColorComponentFlagBits',type='flags'] 643e5c31af7Sopenharmony_ci-- 644e5c31af7Sopenharmony_ciinclude::{generated}/api/flags/VkColorComponentFlags.txt[] 645e5c31af7Sopenharmony_ci 646e5c31af7Sopenharmony_citname:VkColorComponentFlags is a bitmask type for setting a mask of zero or 647e5c31af7Sopenharmony_cimore elink:VkColorComponentFlagBits. 648e5c31af7Sopenharmony_ci-- 649e5c31af7Sopenharmony_ci 650e5c31af7Sopenharmony_ci 651e5c31af7Sopenharmony_ciifdef::VK_EXT_color_write_enable[] 652e5c31af7Sopenharmony_ci[[framebuffer-color-write-enable]] 653e5c31af7Sopenharmony_ci== Color Write Enable 654e5c31af7Sopenharmony_ci 655e5c31af7Sopenharmony_ci[open,refpage='VkPipelineColorWriteCreateInfoEXT',desc='Structure specifying color write state of a newly created pipeline',type='structs'] 656e5c31af7Sopenharmony_ci-- 657e5c31af7Sopenharmony_ciThe sname:VkPipelineColorWriteCreateInfoEXT structure is defined as: 658e5c31af7Sopenharmony_ci 659e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkPipelineColorWriteCreateInfoEXT.txt[] 660e5c31af7Sopenharmony_ci 661e5c31af7Sopenharmony_ci * pname:sType is the type of this structure. 662e5c31af7Sopenharmony_ci * pname:pNext is `NULL` or a pointer to a structure extending this 663e5c31af7Sopenharmony_ci structure. 664e5c31af7Sopenharmony_ci * pname:attachmentCount is the number of basetype:VkBool32 elements in 665e5c31af7Sopenharmony_ci pname:pColorWriteEnables. 666e5c31af7Sopenharmony_ci * pname:pColorWriteEnables is a pointer to an array of per target 667e5c31af7Sopenharmony_ci attachment boolean values specifying whether color writes are enabled 668e5c31af7Sopenharmony_ci for the given attachment. 669e5c31af7Sopenharmony_ci 670e5c31af7Sopenharmony_ciWhen this structure is included in the pname:pNext chain of 671e5c31af7Sopenharmony_cislink:VkPipelineColorBlendStateCreateInfo, it defines per-attachment color 672e5c31af7Sopenharmony_ciwrite state. 673e5c31af7Sopenharmony_ciIf this structure is not included in the pname:pNext chain, it is equivalent 674e5c31af7Sopenharmony_cito specifying this structure with pname:attachmentCount equal to the 675e5c31af7Sopenharmony_cipname:attachmentCount member of slink:VkPipelineColorBlendStateCreateInfo, 676e5c31af7Sopenharmony_ciand pname:pColorWriteEnables pointing to an array of as many ename:VK_TRUE 677e5c31af7Sopenharmony_civalues. 678e5c31af7Sopenharmony_ci 679e5c31af7Sopenharmony_ciIf the <<features-colorWriteEnable,colorWriteEnable>> feature is not enabled 680e5c31af7Sopenharmony_cion the device, all basetype:VkBool32 elements in the 681e5c31af7Sopenharmony_cipname:pColorWriteEnables array must: be ename:VK_TRUE. 682e5c31af7Sopenharmony_ci 683e5c31af7Sopenharmony_ciColor Write Enable interacts with the <<framebuffer-color-write-mask,Color 684e5c31af7Sopenharmony_ciWrite Mask>> as follows: 685e5c31af7Sopenharmony_ci 686e5c31af7Sopenharmony_ci * If pname:colorWriteEnable is ename:VK_TRUE, writes to the attachment are 687e5c31af7Sopenharmony_ci determined by the pname:colorWriteMask. 688e5c31af7Sopenharmony_ci * If pname:colorWriteEnable is ename:VK_FALSE, the pname:colorWriteMask is 689e5c31af7Sopenharmony_ci ignored and writes to all components of the attachment are disabled. 690e5c31af7Sopenharmony_ci This is equivalent to specifying a pname:colorWriteMask of 0. 691e5c31af7Sopenharmony_ci 692e5c31af7Sopenharmony_ci.Valid Usage 693e5c31af7Sopenharmony_ci**** 694e5c31af7Sopenharmony_ci * [[VUID-VkPipelineColorWriteCreateInfoEXT-pAttachments-04801]] 695e5c31af7Sopenharmony_ci If the <<features-colorWriteEnable,colorWriteEnable>> feature is not 696e5c31af7Sopenharmony_ci enabled, all elements of pname:pColorWriteEnables must: be ename:VK_TRUE 697e5c31af7Sopenharmony_ci * [[VUID-VkPipelineColorWriteCreateInfoEXT-attachmentCount-04802]] 698e5c31af7Sopenharmony_ci pname:attachmentCount must: be equal to the pname:attachmentCount member 699e5c31af7Sopenharmony_ci of the sname:VkPipelineColorBlendStateCreateInfo structure specified 700e5c31af7Sopenharmony_ci during pipeline creation 701e5c31af7Sopenharmony_ci**** 702e5c31af7Sopenharmony_ci 703e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkPipelineColorWriteCreateInfoEXT.txt[] 704e5c31af7Sopenharmony_ci-- 705e5c31af7Sopenharmony_ci 706e5c31af7Sopenharmony_ci[open,refpage='vkCmdSetColorWriteEnableEXT',desc='Enable or disable writes to a color attachment dynamically for a command buffer',type='protos'] 707e5c31af7Sopenharmony_ci-- 708e5c31af7Sopenharmony_ciTo <<pipelines-dynamic-state, dynamically enable or disable>> writes to a 709e5c31af7Sopenharmony_cicolor attachment, call: 710e5c31af7Sopenharmony_ci 711e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCmdSetColorWriteEnableEXT.txt[] 712e5c31af7Sopenharmony_ci 713e5c31af7Sopenharmony_ci * pname:commandBuffer is the command buffer into which the command will be 714e5c31af7Sopenharmony_ci recorded. 715e5c31af7Sopenharmony_ci * pname:attachmentCount is the number of basetype:VkBool32 elements in 716e5c31af7Sopenharmony_ci pname:pColorWriteEnables. 717e5c31af7Sopenharmony_ci * pname:pColorWriteEnables is a pointer to an array of per target 718e5c31af7Sopenharmony_ci attachment boolean values specifying whether color writes are enabled 719e5c31af7Sopenharmony_ci for the given attachment. 720e5c31af7Sopenharmony_ci 721e5c31af7Sopenharmony_ciThis command sets the color write enables for subsequent drawing commands 722e5c31af7Sopenharmony_ciwhen the graphics pipeline is created with 723e5c31af7Sopenharmony_ciename:VK_DYNAMIC_STATE_COLOR_WRITE_ENABLE_EXT set in 724e5c31af7Sopenharmony_cislink:VkPipelineDynamicStateCreateInfo::pname:pDynamicStates. 725e5c31af7Sopenharmony_ciOtherwise, this state is specified by the 726e5c31af7Sopenharmony_cislink:VkPipelineColorWriteCreateInfoEXT::pname:pColorWriteEnables values 727e5c31af7Sopenharmony_ciused to create the currently active pipeline. 728e5c31af7Sopenharmony_ci 729e5c31af7Sopenharmony_ci.Valid Usage 730e5c31af7Sopenharmony_ci**** 731e5c31af7Sopenharmony_ci * [[VUID-vkCmdSetColorWriteEnableEXT-None-04803]] 732e5c31af7Sopenharmony_ci The <<features-colorWriteEnable, colorWriteEnable>> feature must: be 733e5c31af7Sopenharmony_ci enabled 734e5c31af7Sopenharmony_ci * [[VUID-vkCmdSetColorWriteEnableEXT-attachmentCount-04804]] 735e5c31af7Sopenharmony_ci pname:attachmentCount must: be equal to the pname:attachmentCount member 736e5c31af7Sopenharmony_ci of the sname:VkPipelineColorBlendStateCreateInfo structure specified 737e5c31af7Sopenharmony_ci during pipeline creation 738e5c31af7Sopenharmony_ci**** 739e5c31af7Sopenharmony_ci 740e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkCmdSetColorWriteEnableEXT.txt[] 741e5c31af7Sopenharmony_ci-- 742e5c31af7Sopenharmony_ciendif::VK_EXT_color_write_enable[] 743