@@ -2085,3 +2085,129 @@ TEST_F(PositivePipeline, StaticConstantBlend) {
2085
2085
m_command_buffer.EndRenderPass ();
2086
2086
m_command_buffer.End ();
2087
2087
}
2088
+
2089
+ TEST_F (PositivePipeline, BlendDisabled) {
2090
+ AddRequiredFeature (vkt::Feature::independentBlend);
2091
+ RETURN_IF_SKIP (Init ());
2092
+
2093
+ VkFormat non_blend_format = VK_FORMAT_R8_SINT;
2094
+ VkFormat blend_format = VK_FORMAT_R8G8B8A8_UNORM;
2095
+
2096
+ VkFormatFeatureFlags2 format_features1 = m_device->FormatFeaturesOptimal (non_blend_format);
2097
+ VkFormatFeatureFlags2 format_features2 = m_device->FormatFeaturesOptimal (blend_format);
2098
+
2099
+ if (!(format_features1 & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT) &&
2100
+ (format_features1 & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT)) {
2101
+ GTEST_SKIP () << " Format features not suitable" ;
2102
+ }
2103
+ if (!(format_features2 & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT) &&
2104
+ !(format_features2 & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT)) {
2105
+ GTEST_SKIP () << " Format features not suitable" ;
2106
+ }
2107
+
2108
+ vkt::Image non_blend_image (*m_device, 32u , 32u , non_blend_format, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
2109
+ vkt::ImageView non_blend_view = non_blend_image.CreateView ();
2110
+ vkt::Image blend_image (*m_device, 32u , 32u , blend_format, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
2111
+ vkt::ImageView blend_view = blend_image.CreateView ();
2112
+
2113
+ VkAttachmentDescription attachments[2 ];
2114
+ attachments[0 ] = {};
2115
+ attachments[0 ].format = non_blend_format;
2116
+ attachments[0 ].samples = VK_SAMPLE_COUNT_1_BIT;
2117
+ attachments[0 ].loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
2118
+ attachments[0 ].storeOp = VK_ATTACHMENT_STORE_OP_STORE;
2119
+ attachments[0 ].initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
2120
+ attachments[0 ].finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
2121
+ attachments[1 ] = {};
2122
+ attachments[1 ].format = blend_format;
2123
+ attachments[1 ].samples = VK_SAMPLE_COUNT_1_BIT;
2124
+ attachments[1 ].loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
2125
+ attachments[1 ].storeOp = VK_ATTACHMENT_STORE_OP_STORE;
2126
+ attachments[1 ].initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
2127
+ attachments[1 ].finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
2128
+
2129
+ VkAttachmentReference attachment_references1[2 ];
2130
+ attachment_references1[0 ].attachment = 0u ;
2131
+ attachment_references1[0 ].layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
2132
+ attachment_references1[1 ].attachment = 1u ;
2133
+ attachment_references1[1 ].layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
2134
+
2135
+ VkAttachmentReference attachment_references2[2 ];
2136
+ attachment_references2[0 ].attachment = VK_ATTACHMENT_UNUSED;
2137
+ attachment_references2[0 ].layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
2138
+ attachment_references2[1 ].attachment = 1u ;
2139
+ attachment_references2[1 ].layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
2140
+
2141
+ VkSubpassDescription subpasses[2 ];
2142
+ subpasses[0 ] = {};
2143
+ subpasses[0 ].pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
2144
+ subpasses[0 ].colorAttachmentCount = 2u ;
2145
+ subpasses[0 ].pColorAttachments = attachment_references1;
2146
+ subpasses[1 ] = {};
2147
+ subpasses[1 ].pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
2148
+ subpasses[1 ].colorAttachmentCount = 2u ;
2149
+ subpasses[1 ].pColorAttachments = attachment_references2;
2150
+
2151
+ VkRenderPassCreateInfo render_pass_ci = vku::InitStructHelper ();
2152
+ render_pass_ci.attachmentCount = 2u ;
2153
+ render_pass_ci.pAttachments = attachments;
2154
+ render_pass_ci.subpassCount = 2u ;
2155
+ render_pass_ci.pSubpasses = subpasses;
2156
+ vkt::RenderPass render_pass (*m_device, render_pass_ci);
2157
+
2158
+ VkImageView views[2 ] = {non_blend_view.handle (), blend_view.handle ()};
2159
+ vkt::Framebuffer framebuffer (*m_device, render_pass, 2u , views);
2160
+
2161
+ VkPipelineColorBlendAttachmentState cb_attachments[2 ];
2162
+ cb_attachments[0 ].blendEnable = VK_FALSE;
2163
+ cb_attachments[0 ].srcColorBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA;
2164
+ cb_attachments[0 ].dstColorBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
2165
+ cb_attachments[0 ].colorBlendOp = VK_BLEND_OP_ADD;
2166
+ cb_attachments[0 ].srcAlphaBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA;
2167
+ cb_attachments[0 ].dstAlphaBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
2168
+ cb_attachments[0 ].alphaBlendOp = VK_BLEND_OP_ADD;
2169
+ cb_attachments[0 ].colorWriteMask = VK_COLOR_COMPONENT_R_BIT;
2170
+ cb_attachments[1 ].blendEnable = VK_TRUE;
2171
+ cb_attachments[1 ].srcColorBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA;
2172
+ cb_attachments[1 ].dstColorBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
2173
+ cb_attachments[1 ].colorBlendOp = VK_BLEND_OP_ADD;
2174
+ cb_attachments[1 ].srcAlphaBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA;
2175
+ cb_attachments[1 ].dstAlphaBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
2176
+ cb_attachments[1 ].alphaBlendOp = VK_BLEND_OP_ADD;
2177
+ cb_attachments[1 ].colorWriteMask = VK_COLOR_COMPONENT_R_BIT;
2178
+
2179
+ VkPipelineColorBlendStateCreateInfo cb_state = vku::InitStructHelper ();
2180
+ cb_state.attachmentCount = 2u ;
2181
+ cb_state.pAttachments = cb_attachments;
2182
+
2183
+ CreatePipelineHelper pipe1 (*this );
2184
+ pipe1.gp_ci_ .renderPass = render_pass;
2185
+ pipe1.gp_ci_ .pColorBlendState = &cb_state;
2186
+ pipe1.CreateGraphicsPipeline ();
2187
+
2188
+ cb_attachments[0 ].blendEnable = VK_TRUE;
2189
+ CreatePipelineHelper pipe2 (*this );
2190
+ pipe2.gp_ci_ .renderPass = render_pass;
2191
+ pipe2.gp_ci_ .subpass = 1u ;
2192
+ pipe2.gp_ci_ .pColorBlendState = &cb_state;
2193
+ pipe2.CreateGraphicsPipeline ();
2194
+
2195
+ VkClearValue clear_values[2 ] = {{m_clear_color}, {m_clear_color}};
2196
+
2197
+ VkRenderPassBeginInfo render_pass_bi = vku::InitStructHelper ();
2198
+ render_pass_bi.renderPass = render_pass;
2199
+ render_pass_bi.framebuffer = framebuffer;
2200
+ render_pass_bi.renderArea = {{0 , 0 }, {32u , 32u }};
2201
+ render_pass_bi.clearValueCount = 2u ;
2202
+ render_pass_bi.pClearValues = clear_values;
2203
+
2204
+ m_command_buffer.Begin ();
2205
+ m_command_buffer.BeginRenderPass (render_pass_bi);
2206
+ vk::CmdBindPipeline (m_command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1);
2207
+ vk::CmdDraw (m_command_buffer, 4u , 1u , 0u , 0u );
2208
+ vk::CmdNextSubpass (m_command_buffer, VK_SUBPASS_CONTENTS_INLINE);
2209
+ vk::CmdBindPipeline (m_command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipe2);
2210
+ vk::CmdDraw (m_command_buffer, 4u , 1u , 0u , 0u );
2211
+ m_command_buffer.EndRenderPass ();
2212
+ m_command_buffer.End ();
2213
+ }
0 commit comments