| Flutter Impeller |

formats_vk.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_FORMATS_VK_H_
6 #define FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_FORMATS_VK_H_
7
8 #include <cstdint>
9 #include <ostream>
10
11 #include "flutter/fml/hash_combine.h"
12 #include "flutter/fml/macros.h"
13 #include "impeller/base/validation.h"
14 #include "impeller/core/formats.h"
15 #include "impeller/core/shader_types.h"
16 #include "impeller/renderer/backend/vulkan/vk.h"
17 #include "vulkan/vulkan_enums.hpp"
18
19 namespace impeller {
20
21 constexpr vk::SampleCountFlagBits ToVKSampleCountFlagBits(SampleCount count) {
22 switch (count) {
23 case SampleCount::kCount1:
24 return vk::SampleCountFlagBits::e1;
25 case SampleCount::kCount4:
26 return vk::SampleCountFlagBits::e4;
27 }
28 FML_UNREACHABLE();
29 }
30
31 constexpr vk::BlendFactor ToVKBlendFactor(BlendFactor factor) {
32 switch (factor) {
33 case BlendFactor::kZero:
34 return vk::BlendFactor::eZero;
35 case BlendFactor::kOne:
36 return vk::BlendFactor::eOne;
37 case BlendFactor::kSourceColor:
38 return vk::BlendFactor::eSrcColor;
39 case BlendFactor::kOneMinusSourceColor:
40 return vk::BlendFactor::eOneMinusSrcColor;
41 case BlendFactor::kSourceAlpha:
42 return vk::BlendFactor::eSrcAlpha;
43 case BlendFactor::kOneMinusSourceAlpha:
44 return vk::BlendFactor::eOneMinusSrcAlpha;
45 case BlendFactor::kDestinationColor:
46 return vk::BlendFactor::eDstColor;
47 case BlendFactor::kOneMinusDestinationColor:
48 return vk::BlendFactor::eOneMinusDstColor;
49 case BlendFactor::kDestinationAlpha:
50 return vk::BlendFactor::eDstAlpha;
51 case BlendFactor::kOneMinusDestinationAlpha:
52 return vk::BlendFactor::eOneMinusDstAlpha;
53 case BlendFactor::kSourceAlphaSaturated:
54 return vk::BlendFactor::eSrcAlphaSaturate;
55 case BlendFactor::kBlendColor:
56 return vk::BlendFactor::eConstantColor;
57 case BlendFactor::kOneMinusBlendColor:
58 return vk::BlendFactor::eOneMinusConstantColor;
59 case BlendFactor::kBlendAlpha:
60 return vk::BlendFactor::eConstantAlpha;
61 case BlendFactor::kOneMinusBlendAlpha:
62 return vk::BlendFactor::eOneMinusConstantAlpha;
63 }
64 FML_UNREACHABLE();
65 }
66
67 constexpr vk::BlendOp ToVKBlendOp(BlendOperation op) {
68 switch (op) {
69 case BlendOperation::kAdd:
70 return vk::BlendOp::eAdd;
71 case BlendOperation::kSubtract:
72 return vk::BlendOp::eSubtract;
73 case BlendOperation::kReverseSubtract:
74 return vk::BlendOp::eReverseSubtract;
75 }
76 FML_UNREACHABLE();
77 }
78
79 constexpr vk::ColorComponentFlags ToVKColorComponentFlags(ColorWriteMask type) {
80 vk::ColorComponentFlags mask;
81
82 if (type & ColorWriteMaskBits::kRed) {
83 mask |= vk::ColorComponentFlagBits::eR;
84 }
85
86 if (type & ColorWriteMaskBits::kGreen) {
87 mask |= vk::ColorComponentFlagBits::eG;
88 }
89
90 if (type & ColorWriteMaskBits::kBlue) {
91 mask |= vk::ColorComponentFlagBits::eB;
92 }
93
94 if (type & ColorWriteMaskBits::kAlpha) {
95 mask |= vk::ColorComponentFlagBits::eA;
96 }
97
98 return mask;
99 }
100
101 constexpr vk::PipelineColorBlendAttachmentState
102 ToVKPipelineColorBlendAttachmentState(const ColorAttachmentDescriptor& desc) {
103 vk::PipelineColorBlendAttachmentState res;
104
105 res.setBlendEnable(desc.blending_enabled);
106
107 res.setSrcColorBlendFactor(ToVKBlendFactor(desc.src_color_blend_factor));
108 res.setColorBlendOp(ToVKBlendOp(desc.color_blend_op));
109 res.setDstColorBlendFactor(ToVKBlendFactor(desc.dst_color_blend_factor));
110
111 res.setSrcAlphaBlendFactor(ToVKBlendFactor(desc.src_alpha_blend_factor));
112 res.setAlphaBlendOp(ToVKBlendOp(desc.alpha_blend_op));
113 res.setDstAlphaBlendFactor(ToVKBlendFactor(desc.dst_alpha_blend_factor));
114
115 res.setColorWriteMask(ToVKColorComponentFlags(desc.write_mask));
116
117 return res;
118 }
119
120 constexpr std::optional<vk::ShaderStageFlagBits> ToVKShaderStageFlagBits(
121 ShaderStage stage) {
122 switch (stage) {
123 case ShaderStage::kUnknown:
124 return std::nullopt;
125 case ShaderStage::kVertex:
126 return vk::ShaderStageFlagBits::eVertex;
127 case ShaderStage::kFragment:
128 return vk::ShaderStageFlagBits::eFragment;
129 case ShaderStage::kCompute:
130 return vk::ShaderStageFlagBits::eCompute;
131 }
132 FML_UNREACHABLE();
133 }
134
135 constexpr vk::Format ToVKImageFormat(PixelFormat format) {
136 switch (format) {
137 case PixelFormat::kUnknown:
138 case PixelFormat::kB10G10R10XR:
139 case PixelFormat::kB10G10R10A10XR:
140 case PixelFormat::kB10G10R10XRSRGB:
141 return vk::Format::eUndefined;
142 case PixelFormat::kA8UNormInt:
143 // TODO(csg): This is incorrect. Don't depend on swizzle support for GLES.
144 return vk::Format::eR8Unorm;
145 case PixelFormat::kR8G8B8A8UNormInt:
146 return vk::Format::eR8G8B8A8Unorm;
147 case PixelFormat::kR8G8B8A8UNormIntSRGB:
148 return vk::Format::eR8G8B8A8Srgb;
149 case PixelFormat::kB8G8R8A8UNormInt:
150 return vk::Format::eB8G8R8A8Unorm;
151 case PixelFormat::kB8G8R8A8UNormIntSRGB:
152 return vk::Format::eB8G8R8A8Srgb;
153 case PixelFormat::kR32G32B32A32Float:
154 return vk::Format::eR32G32B32A32Sfloat;
155 case PixelFormat::kR16G16B16A16Float:
156 return vk::Format::eR16G16B16A16Sfloat;
157 case PixelFormat::kS8UInt:
158 return vk::Format::eS8Uint;
159 case PixelFormat::kD24UnormS8Uint:
160 return vk::Format::eD24UnormS8Uint;
161 case PixelFormat::kD32FloatS8UInt:
162 return vk::Format::eD32SfloatS8Uint;
163 case PixelFormat::kR8UNormInt:
164 return vk::Format::eR8Unorm;
165 case PixelFormat::kR8G8UNormInt:
166 return vk::Format::eR8G8Unorm;
167 }
168
169 FML_UNREACHABLE();
170 }
171
172 constexpr PixelFormat ToPixelFormat(vk::Format format) {
173 switch (format) {
174 case vk::Format::eUndefined:
175 return PixelFormat::kUnknown;
176 case vk::Format::eR8G8B8A8Unorm:
177 return PixelFormat::kR8G8B8A8UNormInt;
178 case vk::Format::eR8G8B8A8Srgb:
179 return PixelFormat::kR8G8B8A8UNormIntSRGB;
180 case vk::Format::eB8G8R8A8Unorm:
181 return PixelFormat::kB8G8R8A8UNormInt;
182 case vk::Format::eB8G8R8A8Srgb:
183 return PixelFormat::kB8G8R8A8UNormIntSRGB;
184 case vk::Format::eR32G32B32A32Sfloat:
185 return PixelFormat::kR32G32B32A32Float;
186 case vk::Format::eR16G16B16A16Sfloat:
187 return PixelFormat::kR16G16B16A16Float;
188 case vk::Format::eS8Uint:
189 return PixelFormat::kS8UInt;
190 case vk::Format::eD24UnormS8Uint:
191 return PixelFormat::kD24UnormS8Uint;
192 case vk::Format::eD32SfloatS8Uint:
193 return PixelFormat::kD32FloatS8UInt;
194 case vk::Format::eR8Unorm:
195 return PixelFormat::kR8UNormInt;
196 case vk::Format::eR8G8Unorm:
197 return PixelFormat::kR8G8UNormInt;
198 default:
199 return PixelFormat::kUnknown;
200 }
201 }
202
203 constexpr vk::SampleCountFlagBits ToVKSampleCount(SampleCount sample_count) {
204 switch (sample_count) {
205 case SampleCount::kCount1:
206 return vk::SampleCountFlagBits::e1;
207 case SampleCount::kCount4:
208 return vk::SampleCountFlagBits::e4;
209 }
210
211 FML_UNREACHABLE();
212 }
213
214 constexpr vk::Filter ToVKSamplerMinMagFilter(MinMagFilter filter) {
215 switch (filter) {
216 case MinMagFilter::kNearest:
217 return vk::Filter::eNearest;
218 case MinMagFilter::kLinear:
219 return vk::Filter::eLinear;
220 }
221
222 FML_UNREACHABLE();
223 }
224
225 constexpr vk::SamplerMipmapMode ToVKSamplerMipmapMode(MipFilter filter) {
226 switch (filter) {
227 case MipFilter::kNearest:
228 return vk::SamplerMipmapMode::eNearest;
229 case MipFilter::kLinear:
230 return vk::SamplerMipmapMode::eLinear;
231 }
232
233 FML_UNREACHABLE();
234 }
235
236 constexpr vk::SamplerAddressMode ToVKSamplerAddressMode(
237 SamplerAddressMode mode) {
238 switch (mode) {
239 case SamplerAddressMode::kRepeat:
240 return vk::SamplerAddressMode::eRepeat;
241 case SamplerAddressMode::kMirror:
242 return vk::SamplerAddressMode::eMirroredRepeat;
243 case SamplerAddressMode::kClampToEdge:
244 return vk::SamplerAddressMode::eClampToEdge;
245 case SamplerAddressMode::kDecal:
246 return vk::SamplerAddressMode::eClampToBorder;
247 }
248
249 FML_UNREACHABLE();
250 }
251
252 constexpr vk::ShaderStageFlags ToVkShaderStage(ShaderStage stage) {
253 switch (stage) {
254 case ShaderStage::kUnknown:
255 return vk::ShaderStageFlagBits::eAll;
256 case ShaderStage::kFragment:
257 return vk::ShaderStageFlagBits::eFragment;
258 case ShaderStage::kCompute:
259 return vk::ShaderStageFlagBits::eCompute;
260 case ShaderStage::kVertex:
261 return vk::ShaderStageFlagBits::eVertex;
262 }
263
264 FML_UNREACHABLE();
265 }
266
267 constexpr vk::DescriptorType ToVKDescriptorType(DescriptorType type) {
268 switch (type) {
269 case DescriptorType::kSampledImage:
270 return vk::DescriptorType::eCombinedImageSampler;
271 break;
272 case DescriptorType::kUniformBuffer:
273 return vk::DescriptorType::eUniformBuffer;
274 break;
275 case DescriptorType::kStorageBuffer:
276 return vk::DescriptorType::eStorageBuffer;
277 break;
278 case DescriptorType::kImage:
279 return vk::DescriptorType::eSampledImage;
280 break;
281 case DescriptorType::kSampler:
282 return vk::DescriptorType::eSampler;
283 break;
284 case DescriptorType::kInputAttachment:
285 return vk::DescriptorType::eInputAttachment;
286 }
287
288 FML_UNREACHABLE();
289 }
290
291 constexpr vk::DescriptorSetLayoutBinding ToVKDescriptorSetLayoutBinding(
292 const DescriptorSetLayout& layout) {
293 vk::DescriptorSetLayoutBinding binding;
294 binding.binding = layout.binding;
295 binding.descriptorCount = 1u;
296 binding.descriptorType = ToVKDescriptorType(layout.descriptor_type);
297 binding.stageFlags = ToVkShaderStage(layout.shader_stage);
298 return binding;
299 }
300
301 constexpr vk::AttachmentLoadOp ToVKAttachmentLoadOp(LoadAction load_action) {
302 switch (load_action) {
303 case LoadAction::kLoad:
304 return vk::AttachmentLoadOp::eLoad;
305 case LoadAction::kClear:
306 return vk::AttachmentLoadOp::eClear;
307 case LoadAction::kDontCare:
308 return vk::AttachmentLoadOp::eDontCare;
309 }
310
311 FML_UNREACHABLE();
312 }
313
314 constexpr vk::AttachmentStoreOp ToVKAttachmentStoreOp(StoreAction store_action,
315 bool is_resolve_texture) {
316 switch (store_action) {
317 case StoreAction::kStore:
318 // Both MSAA and resolve textures need to be stored. A resolve is NOT
319 // performed.
320 return vk::AttachmentStoreOp::eStore;
321 case StoreAction::kDontCare:
322 // Both MSAA and resolve textures can be discarded. A resolve is NOT
323 // performed.
324 return vk::AttachmentStoreOp::eDontCare;
325 case StoreAction::kMultisampleResolve:
326 // The resolve texture is stored but the MSAA texture can be discarded. A
327 // resolve IS performed.
328 return is_resolve_texture ? vk::AttachmentStoreOp::eStore
329 : vk::AttachmentStoreOp::eDontCare;
330 case StoreAction::kStoreAndMultisampleResolve:
331 // Both MSAA and resolve textures need to be stored. A resolve IS
332 // performed.
333 return vk::AttachmentStoreOp::eStore;
334 }
335 FML_UNREACHABLE();
336 }
337
338 constexpr bool StoreActionPerformsResolve(StoreAction store_action) {
339 switch (store_action) {
340 case StoreAction::kDontCare:
341 case StoreAction::kStore:
342 return false;
343 case StoreAction::kMultisampleResolve:
344 case StoreAction::kStoreAndMultisampleResolve:
345 return true;
346 }
347 FML_UNREACHABLE();
348 }
349
350 constexpr vk::IndexType ToVKIndexType(IndexType index_type) {
351 switch (index_type) {
352 case IndexType::k16bit:
353 return vk::IndexType::eUint16;
354 case IndexType::k32bit:
355 return vk::IndexType::eUint32;
356 case IndexType::kUnknown:
357 return vk::IndexType::eUint32;
358 case IndexType::kNone:
359 FML_UNREACHABLE();
360 }
361
362 FML_UNREACHABLE();
363 }
364
365 constexpr vk::PolygonMode ToVKPolygonMode(PolygonMode mode) {
366 switch (mode) {
367 case PolygonMode::kFill:
368 return vk::PolygonMode::eFill;
369 case PolygonMode::kLine:
370 return vk::PolygonMode::eLine;
371 }
372 FML_UNREACHABLE();
373 }
374
375 constexpr vk::PrimitiveTopology ToVKPrimitiveTopology(PrimitiveType primitive) {
376 switch (primitive) {
377 case PrimitiveType::kTriangle:
378 return vk::PrimitiveTopology::eTriangleList;
379 case PrimitiveType::kTriangleStrip:
380 return vk::PrimitiveTopology::eTriangleStrip;
381 case PrimitiveType::kLine:
382 return vk::PrimitiveTopology::eLineList;
383 case PrimitiveType::kLineStrip:
384 return vk::PrimitiveTopology::eLineStrip;
385 case PrimitiveType::kPoint:
386 return vk::PrimitiveTopology::ePointList;
387 }
388
389 FML_UNREACHABLE();
390 }
391
392 constexpr bool PixelFormatIsDepthStencil(PixelFormat format) {
393 switch (format) {
394 case PixelFormat::kUnknown:
395 case PixelFormat::kA8UNormInt:
396 case PixelFormat::kR8UNormInt:
397 case PixelFormat::kR8G8UNormInt:
398 case PixelFormat::kR8G8B8A8UNormInt:
399 case PixelFormat::kR8G8B8A8UNormIntSRGB:
400 case PixelFormat::kB8G8R8A8UNormInt:
401 case PixelFormat::kB8G8R8A8UNormIntSRGB:
402 case PixelFormat::kR32G32B32A32Float:
403 case PixelFormat::kR16G16B16A16Float:
404 case PixelFormat::kB10G10R10XR:
405 case PixelFormat::kB10G10R10XRSRGB:
406 case PixelFormat::kB10G10R10A10XR:
407 return false;
408 case PixelFormat::kS8UInt:
409 case PixelFormat::kD24UnormS8Uint:
410 case PixelFormat::kD32FloatS8UInt:
411 return true;
412 }
413 return false;
414 }
415
416 static constexpr vk::AttachmentReference kUnusedAttachmentReference = {
417 VK_ATTACHMENT_UNUSED, vk::ImageLayout::eUndefined};
418
419 constexpr vk::CullModeFlags ToVKCullModeFlags(CullMode mode) {
420 switch (mode) {
421 case CullMode::kNone:
422 return vk::CullModeFlagBits::eNone;
423 case CullMode::kFrontFace:
424 return vk::CullModeFlagBits::eFront;
425 case CullMode::kBackFace:
426 return vk::CullModeFlagBits::eBack;
427 }
428 FML_UNREACHABLE();
429 }
430
431 constexpr vk::CompareOp ToVKCompareOp(CompareFunction op) {
432 switch (op) {
433 case CompareFunction::kNever:
434 return vk::CompareOp::eNever;
435 case CompareFunction::kAlways:
436 return vk::CompareOp::eAlways;
437 case CompareFunction::kLess:
438 return vk::CompareOp::eLess;
439 case CompareFunction::kEqual:
440 return vk::CompareOp::eEqual;
441 case CompareFunction::kLessEqual:
442 return vk::CompareOp::eLessOrEqual;
443 case CompareFunction::kGreater:
444 return vk::CompareOp::eGreater;
445 case CompareFunction::kNotEqual:
446 return vk::CompareOp::eNotEqual;
447 case CompareFunction::kGreaterEqual:
448 return vk::CompareOp::eGreaterOrEqual;
449 }
450 FML_UNREACHABLE();
451 }
452
453 constexpr vk::StencilOp ToVKStencilOp(StencilOperation op) {
454 switch (op) {
455 case StencilOperation::kKeep:
456 return vk::StencilOp::eKeep;
457 case StencilOperation::kZero:
458 return vk::StencilOp::eZero;
459 case StencilOperation::kSetToReferenceValue:
460 return vk::StencilOp::eReplace;
461 case StencilOperation::kIncrementClamp:
462 return vk::StencilOp::eIncrementAndClamp;
463 case StencilOperation::kDecrementClamp:
464 return vk::StencilOp::eDecrementAndClamp;
465 case StencilOperation::kInvert:
466 return vk::StencilOp::eInvert;
467 case StencilOperation::kIncrementWrap:
468 return vk::StencilOp::eIncrementAndWrap;
469 case StencilOperation::kDecrementWrap:
470 return vk::StencilOp::eDecrementAndWrap;
471 break;
472 }
473 FML_UNREACHABLE();
474 }
475
476 constexpr vk::StencilOpState ToVKStencilOpState(
477 const StencilAttachmentDescriptor& desc) {
478 vk::StencilOpState state;
479 state.failOp = ToVKStencilOp(desc.stencil_failure);
480 state.passOp = ToVKStencilOp(desc.depth_stencil_pass);
481 state.depthFailOp = ToVKStencilOp(desc.depth_failure);
482 state.compareOp = ToVKCompareOp(desc.stencil_compare);
483 state.compareMask = desc.read_mask;
484 state.writeMask = desc.write_mask;
485 // This is irrelevant as the stencil references are always dynamic state and
486 // will be set in the render pass.
487 state.reference = 1988;
488 return state;
489 }
490
491 constexpr vk::ImageAspectFlags ToVKImageAspectFlags(PixelFormat format) {
492 switch (format) {
493 case PixelFormat::kUnknown:
494 case PixelFormat::kA8UNormInt:
495 case PixelFormat::kR8UNormInt:
496 case PixelFormat::kR8G8UNormInt:
497 case PixelFormat::kR8G8B8A8UNormInt:
498 case PixelFormat::kR8G8B8A8UNormIntSRGB:
499 case PixelFormat::kB8G8R8A8UNormInt:
500 case PixelFormat::kB8G8R8A8UNormIntSRGB:
501 case PixelFormat::kR32G32B32A32Float:
502 case PixelFormat::kR16G16B16A16Float:
503 case PixelFormat::kB10G10R10XR:
504 case PixelFormat::kB10G10R10XRSRGB:
505 case PixelFormat::kB10G10R10A10XR:
506 return vk::ImageAspectFlagBits::eColor;
507 case PixelFormat::kS8UInt:
508 return vk::ImageAspectFlagBits::eStencil;
509 case PixelFormat::kD24UnormS8Uint:
510 case PixelFormat::kD32FloatS8UInt:
511 return vk::ImageAspectFlagBits::eDepth |
512 vk::ImageAspectFlagBits::eStencil;
513 }
514 FML_UNREACHABLE();
515 }
516
517 constexpr uint32_t ToArrayLayerCount(TextureType type) {
518 switch (type) {
519 case TextureType::kTexture2D:
520 case TextureType::kTexture2DMultisample:
521 return 1u;
522 case TextureType::kTextureCube:
523 return 6u;
524 case TextureType::kTextureExternalOES:
525 VALIDATION_LOG
526 << "kTextureExternalOES can not be used with the Vulkan backend.";
527 }
528 FML_UNREACHABLE();
529 }
530
531 constexpr vk::ImageViewType ToVKImageViewType(TextureType type) {
532 switch (type) {
533 case TextureType::kTexture2D:
534 case TextureType::kTexture2DMultisample:
535 return vk::ImageViewType::e2D;
536 case TextureType::kTextureCube:
537 return vk::ImageViewType::eCube;
538 case TextureType::kTextureExternalOES:
539 VALIDATION_LOG
540 << "kTextureExternalOES can not be used with the Vulkan backend.";
541 }
542 FML_UNREACHABLE();
543 }
544
545 constexpr vk::ImageCreateFlags ToVKImageCreateFlags(TextureType type) {
546 switch (type) {
547 case TextureType::kTexture2D:
548 case TextureType::kTexture2DMultisample:
549 return {};
550 case TextureType::kTextureCube:
551 return vk::ImageCreateFlagBits::eCubeCompatible;
552 case TextureType::kTextureExternalOES:
553 VALIDATION_LOG
554 << "kTextureExternalOES can not be used with the Vulkan backend.";
555 }
556 FML_UNREACHABLE();
557 }
558
559 vk::PipelineDepthStencilStateCreateInfo ToVKPipelineDepthStencilStateCreateInfo(
560 std::optional<DepthAttachmentDescriptor> depth,
561 std::optional<StencilAttachmentDescriptor> front,
562 std::optional<StencilAttachmentDescriptor> back);
563
564 constexpr vk::ImageAspectFlags ToImageAspectFlags(PixelFormat format) {
565 switch (format) {
566 case PixelFormat::kUnknown:
567 return {};
568 case PixelFormat::kA8UNormInt:
569 case PixelFormat::kR8UNormInt:
570 case PixelFormat::kR8G8UNormInt:
571 case PixelFormat::kR8G8B8A8UNormInt:
572 case PixelFormat::kR8G8B8A8UNormIntSRGB:
573 case PixelFormat::kB8G8R8A8UNormInt:
574 case PixelFormat::kB8G8R8A8UNormIntSRGB:
575 case PixelFormat::kR32G32B32A32Float:
576 case PixelFormat::kR16G16B16A16Float:
577 case PixelFormat::kB10G10R10XR:
578 case PixelFormat::kB10G10R10XRSRGB:
579 case PixelFormat::kB10G10R10A10XR:
580 return vk::ImageAspectFlagBits::eColor;
581 case PixelFormat::kS8UInt:
582 return vk::ImageAspectFlagBits::eStencil;
583 case PixelFormat::kD24UnormS8Uint:
584 case PixelFormat::kD32FloatS8UInt:
585 return vk::ImageAspectFlagBits::eDepth |
586 vk::ImageAspectFlagBits::eStencil;
587 }
588 FML_UNREACHABLE();
589 }
590
591 } // namespace impeller
592
593 #endif // FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_FORMATS_VK_H_
impeller::StoreAction::kMultisampleResolve
@ kMultisampleResolve
impeller::PixelFormat::kS8UInt
@ kS8UInt
impeller::TextureType::kTextureExternalOES
@ kTextureExternalOES
impeller::ToVKSampleCount
constexpr vk::SampleCountFlagBits ToVKSampleCount(SampleCount sample_count)
Definition: formats_vk.h:203
impeller::ColorAttachmentDescriptor::src_color_blend_factor
BlendFactor src_color_blend_factor
Definition: formats.h:504
impeller::CompareFunction::kGreater
@ kGreater
Comparison test passes if new_value > current_value.
impeller::PrimitiveType::kLineStrip
@ kLineStrip
impeller::LoadAction::kLoad
@ kLoad
impeller::DescriptorSetLayout
Definition: shader_types.h:162
impeller::StoreAction
StoreAction
Definition: formats.h:209
impeller::StencilOperation::kDecrementClamp
@ kDecrementClamp
Decrement the current stencil value by 1. Clamp it to zero.
impeller::PixelFormatIsDepthStencil
constexpr bool PixelFormatIsDepthStencil(PixelFormat format)
Definition: formats_vk.h:392
impeller::ToVKColorComponentFlags
constexpr vk::ColorComponentFlags ToVKColorComponentFlags(ColorWriteMask type)
Definition: formats_vk.h:79
impeller::StoreAction::kStoreAndMultisampleResolve
@ kStoreAndMultisampleResolve
impeller::ToVKPipelineDepthStencilStateCreateInfo
vk::PipelineDepthStencilStateCreateInfo ToVKPipelineDepthStencilStateCreateInfo(std::optional< DepthAttachmentDescriptor > depth, std::optional< StencilAttachmentDescriptor > front, std::optional< StencilAttachmentDescriptor > back)
Definition: formats_vk.cc:9
impeller::IndexType::k16bit
@ k16bit
impeller::PolygonMode
PolygonMode
Definition: formats.h:384
impeller::StencilAttachmentDescriptor::depth_failure
StencilOperation depth_failure
Definition: formats.h:607
impeller::StencilAttachmentDescriptor::stencil_compare
CompareFunction stencil_compare
Definition: formats.h:598
impeller::ToVKSamplerAddressMode
constexpr vk::SamplerAddressMode ToVKSamplerAddressMode(SamplerAddressMode mode)
Definition: formats_vk.h:236
impeller::PixelFormat::kB10G10R10A10XR
@ kB10G10R10A10XR
impeller::PixelFormat::kB8G8R8A8UNormIntSRGB
@ kB8G8R8A8UNormIntSRGB
impeller::ShaderStage::kUnknown
@ kUnknown
impeller::PixelFormat::kA8UNormInt
@ kA8UNormInt
impeller::ToVKBlendFactor
constexpr vk::BlendFactor ToVKBlendFactor(BlendFactor factor)
Definition: formats_vk.h:31
impeller::BlendFactor::kSourceAlphaSaturated
@ kSourceAlphaSaturated
impeller::BlendFactor
BlendFactor
Definition: formats.h:179
impeller::PixelFormat::kR8UNormInt
@ kR8UNormInt
impeller::ToVKPolygonMode
constexpr vk::PolygonMode ToVKPolygonMode(PolygonMode mode)
Definition: formats_vk.h:365
impeller::ToVKPipelineColorBlendAttachmentState
constexpr vk::PipelineColorBlendAttachmentState ToVKPipelineColorBlendAttachmentState(const ColorAttachmentDescriptor &desc)
Definition: formats_vk.h:102
impeller::ColorWriteMaskBits::kGreen
@ kGreen
impeller::CompareFunction::kEqual
@ kEqual
Comparison test passes if new_value == current_value.
impeller::ToVKDescriptorType
constexpr vk::DescriptorType ToVKDescriptorType(DescriptorType type)
Definition: formats_vk.h:267
impeller::BlendFactor::kOneMinusSourceAlpha
@ kOneMinusSourceAlpha
impeller::SamplerAddressMode
SamplerAddressMode
Definition: formats.h:423
impeller::CompareFunction::kGreaterEqual
@ kGreaterEqual
Comparison test passes if new_value >= current_value.
impeller::StencilOperation::kKeep
@ kKeep
Don't modify the current stencil value.
impeller::PixelFormat::kR8G8B8A8UNormInt
@ kR8G8B8A8UNormInt
impeller::ToArrayLayerCount
constexpr uint32_t ToArrayLayerCount(TextureType type)
Definition: formats_vk.h:517
impeller::TextureType
TextureType
Definition: formats.h:263
formats.h
impeller::StencilOperation::kIncrementClamp
@ kIncrementClamp
Increment the current stencil value by 1. Clamp it to the maximum.
impeller::ColorAttachmentDescriptor::alpha_blend_op
BlendOperation alpha_blend_op
Definition: formats.h:509
impeller::ToVKCullModeFlags
constexpr vk::CullModeFlags ToVKCullModeFlags(CullMode mode)
Definition: formats_vk.h:419
impeller::ShaderStage
ShaderStage
Definition: shader_types.h:22
impeller::StoreAction::kDontCare
@ kDontCare
impeller::ToVKImageCreateFlags
constexpr vk::ImageCreateFlags ToVKImageCreateFlags(TextureType type)
Definition: formats_vk.h:545
impeller::DescriptorSetLayout::shader_stage
ShaderStage shader_stage
Definition: shader_types.h:165
impeller::ToVKSamplerMipmapMode
constexpr vk::SamplerMipmapMode ToVKSamplerMipmapMode(MipFilter filter)
Definition: formats_vk.h:225
impeller::StencilOperation::kInvert
@ kInvert
Perform a logical bitwise invert on the current stencil value.
impeller::SamplerAddressMode::kClampToEdge
@ kClampToEdge
impeller::BlendFactor::kDestinationAlpha
@ kDestinationAlpha
impeller::DescriptorType::kImage
@ kImage
impeller::IndexType::k32bit
@ k32bit
impeller::StencilAttachmentDescriptor::write_mask
uint32_t write_mask
Definition: formats.h:622
validation.h
impeller::ToVKStencilOpState
constexpr vk::StencilOpState ToVKStencilOpState(const StencilAttachmentDescriptor &desc)
Definition: formats_vk.h:476
impeller::StencilOperation
StencilOperation
Definition: formats.h:553
impeller::PolygonMode::kFill
@ kFill
impeller::ToVKAttachmentStoreOp
constexpr vk::AttachmentStoreOp ToVKAttachmentStoreOp(StoreAction store_action, bool is_resolve_texture)
Definition: formats_vk.h:314
impeller::StencilOperation::kSetToReferenceValue
@ kSetToReferenceValue
Reset the stencil value to the reference value.
impeller::ToVKCompareOp
constexpr vk::CompareOp ToVKCompareOp(CompareFunction op)
Definition: formats_vk.h:431
vk.h
impeller::BlendFactor::kSourceColor
@ kSourceColor
impeller::PixelFormat::kD32FloatS8UInt
@ kD32FloatS8UInt
impeller::PixelFormat
PixelFormat
The Pixel formats supported by Impeller. The naming convention denotes the usage of the component,...
Definition: formats.h:100
impeller::PrimitiveType::kLine
@ kLine
impeller::BlendFactor::kDestinationColor
@ kDestinationColor
impeller::MinMagFilter::kNearest
@ kNearest
Select nearest to the sample point. Most widely supported.
impeller::ToVKStencilOp
constexpr vk::StencilOp ToVKStencilOp(StencilOperation op)
Definition: formats_vk.h:453
impeller::Mask< ColorWriteMaskBits >
impeller::PrimitiveType::kTriangle
@ kTriangle
impeller::BlendFactor::kZero
@ kZero
impeller::TextureType::kTexture2DMultisample
@ kTexture2DMultisample
impeller::CullMode
CullMode
Definition: formats.h:338
impeller::MipFilter::kNearest
@ kNearest
Sample from the nearest mip level.
impeller::LoadAction::kClear
@ kClear
impeller::StencilOperation::kDecrementWrap
@ kDecrementWrap
Decrement the current stencil value by 1. If at zero, set to maximum.
impeller::CompareFunction
CompareFunction
Definition: formats.h:534
impeller::BlendFactor::kOneMinusDestinationColor
@ kOneMinusDestinationColor
impeller::PrimitiveType::kTriangleStrip
@ kTriangleStrip
impeller::PrimitiveType
PrimitiveType
Decides how backend draws pixels based on input vertices.
Definition: formats.h:353
impeller::CullMode::kBackFace
@ kBackFace
impeller::CullMode::kNone
@ kNone
impeller::StencilAttachmentDescriptor::read_mask
uint32_t read_mask
Definition: formats.h:617
impeller::ToVKImageFormat
constexpr vk::Format ToVKImageFormat(PixelFormat format)
Definition: formats_vk.h:135
impeller::MipFilter
MipFilter
Definition: formats.h:415
impeller::BlendOperation::kReverseSubtract
@ kReverseSubtract
impeller::ToVKIndexType
constexpr vk::IndexType ToVKIndexType(IndexType index_type)
Definition: formats_vk.h:350
impeller::BlendFactor::kBlendAlpha
@ kBlendAlpha
impeller::LoadAction
LoadAction
Definition: formats.h:203
impeller::PrimitiveType::kPoint
@ kPoint
Draws a point at each input vertex.
impeller::PixelFormat::kR8G8UNormInt
@ kR8G8UNormInt
impeller::BlendOperation::kAdd
@ kAdd
impeller::MinMagFilter::kLinear
@ kLinear
impeller::BlendFactor::kBlendColor
@ kBlendColor
impeller::ToVKDescriptorSetLayoutBinding
constexpr vk::DescriptorSetLayoutBinding ToVKDescriptorSetLayoutBinding(const DescriptorSetLayout &layout)
Definition: formats_vk.h:291
impeller::DescriptorType::kSampler
@ kSampler
impeller::IndexType
IndexType
Definition: formats.h:344
impeller::ToVKPrimitiveTopology
constexpr vk::PrimitiveTopology ToVKPrimitiveTopology(PrimitiveType primitive)
Definition: formats_vk.h:375
impeller::PixelFormat::kB10G10R10XR
@ kB10G10R10XR
impeller::PixelFormat::kD24UnormS8Uint
@ kD24UnormS8Uint
impeller::StencilAttachmentDescriptor::stencil_failure
StencilOperation stencil_failure
Definition: formats.h:602
impeller::BlendFactor::kOneMinusBlendColor
@ kOneMinusBlendColor
impeller::IndexType::kNone
@ kNone
Does not use the index buffer.
impeller::StencilOperation::kIncrementWrap
@ kIncrementWrap
Increment the current stencil value by 1. If at maximum, set to zero.
impeller::TextureType::kTextureCube
@ kTextureCube
impeller::MinMagFilter
MinMagFilter
Definition: formats.h:407
impeller::PixelFormat::kR16G16B16A16Float
@ kR16G16B16A16Float
impeller::StencilAttachmentDescriptor::depth_stencil_pass
StencilOperation depth_stencil_pass
Definition: formats.h:611
impeller::ToVKSampleCountFlagBits
constexpr vk::SampleCountFlagBits ToVKSampleCountFlagBits(SampleCount count)
Definition: formats_vk.h:21
impeller::ShaderStage::kFragment
@ kFragment
impeller::StoreAction::kStore
@ kStore
impeller::ToVkShaderStage
constexpr vk::ShaderStageFlags ToVkShaderStage(ShaderStage stage)
Definition: formats_vk.h:252
impeller::CompareFunction::kLessEqual
@ kLessEqual
Comparison test passes if new_value <= current_value.
impeller::BlendFactor::kOne
@ kOne
impeller::BlendFactor::kOneMinusBlendAlpha
@ kOneMinusBlendAlpha
impeller::DescriptorType::kSampledImage
@ kSampledImage
impeller::ToVKImageViewType
constexpr vk::ImageViewType ToVKImageViewType(TextureType type)
Definition: formats_vk.h:531
impeller::CompareFunction::kAlways
@ kAlways
Comparison test passes always passes.
impeller::ToVKImageAspectFlags
constexpr vk::ImageAspectFlags ToVKImageAspectFlags(PixelFormat format)
Definition: formats_vk.h:491
impeller::TextureType::kTexture2D
@ kTexture2D
impeller::StencilOperation::kZero
@ kZero
Reset the stencil value to zero.
impeller::PixelFormat::kR32G32B32A32Float
@ kR32G32B32A32Float
impeller::DescriptorType::kUniformBuffer
@ kUniformBuffer
impeller::PixelFormat::kUnknown
@ kUnknown
impeller::CompareFunction::kNever
@ kNever
Comparison test never passes.
impeller::ColorAttachmentDescriptor::src_alpha_blend_factor
BlendFactor src_alpha_blend_factor
Definition: formats.h:508
impeller::ToVKAttachmentLoadOp
constexpr vk::AttachmentLoadOp ToVKAttachmentLoadOp(LoadAction load_action)
Definition: formats_vk.h:301
VALIDATION_LOG
#define VALIDATION_LOG
Definition: validation.h:73
impeller::CullMode::kFrontFace
@ kFrontFace
impeller::ColorWriteMaskBits::kAlpha
@ kAlpha
impeller::ColorAttachmentDescriptor::dst_color_blend_factor
BlendFactor dst_color_blend_factor
Definition: formats.h:506
impeller::BlendOperation
BlendOperation
Definition: formats.h:197
impeller::ColorAttachmentDescriptor::dst_alpha_blend_factor
BlendFactor dst_alpha_blend_factor
Definition: formats.h:510
impeller::ToVKSamplerMinMagFilter
constexpr vk::Filter ToVKSamplerMinMagFilter(MinMagFilter filter)
Definition: formats_vk.h:214
impeller::PixelFormat::kR8G8B8A8UNormIntSRGB
@ kR8G8B8A8UNormIntSRGB
impeller::SamplerAddressMode::kMirror
@ kMirror
impeller::ShaderStage::kVertex
@ kVertex
impeller::LoadAction::kDontCare
@ kDontCare
impeller::StencilAttachmentDescriptor
Definition: formats.h:592
impeller::SampleCount
SampleCount
Definition: formats.h:296
impeller::BlendFactor::kOneMinusSourceColor
@ kOneMinusSourceColor
impeller::ColorWriteMaskBits::kRed
@ kRed
impeller::MipFilter::kLinear
@ kLinear
impeller::ColorWriteMaskBits::kBlue
@ kBlue
impeller::kUnusedAttachmentReference
static constexpr vk::AttachmentReference kUnusedAttachmentReference
Definition: formats_vk.h:416
impeller::SampleCount::kCount1
@ kCount1
impeller::SampleCount::kCount4
@ kCount4
impeller::PolygonMode::kLine
@ kLine
impeller::DescriptorType::kInputAttachment
@ kInputAttachment
impeller::ShaderStage::kCompute
@ kCompute
impeller::ColorAttachmentDescriptor::color_blend_op
BlendOperation color_blend_op
Definition: formats.h:505
impeller::CompareFunction::kNotEqual
@ kNotEqual
Comparison test passes if new_value != current_value.
impeller::PixelFormat::kB10G10R10XRSRGB
@ kB10G10R10XRSRGB
impeller::ToVKBlendOp
constexpr vk::BlendOp ToVKBlendOp(BlendOperation op)
Definition: formats_vk.h:67
impeller::ToVKShaderStageFlagBits
constexpr std::optional< vk::ShaderStageFlagBits > ToVKShaderStageFlagBits(ShaderStage stage)
Definition: formats_vk.h:120
impeller::PixelFormat::kB8G8R8A8UNormInt
@ kB8G8R8A8UNormInt
impeller::BlendFactor::kSourceAlpha
@ kSourceAlpha
impeller::DescriptorSetLayout::descriptor_type
DescriptorType descriptor_type
Definition: shader_types.h:164
shader_types.h
impeller::CompareFunction::kLess
@ kLess
Comparison test passes if new_value < current_value.
impeller
Definition: aiks_blur_unittests.cc:20
impeller::ColorAttachmentDescriptor::blending_enabled
bool blending_enabled
Definition: formats.h:502
impeller::BlendOperation::kSubtract
@ kSubtract
impeller::IndexType::kUnknown
@ kUnknown
impeller::DescriptorSetLayout::binding
uint32_t binding
Definition: shader_types.h:163
impeller::BlendFactor::kOneMinusDestinationAlpha
@ kOneMinusDestinationAlpha
impeller::ToPixelFormat
static PixelFormat ToPixelFormat(AHardwareBuffer_Format format)
Definition: ahb_texture_source_vk.cc:216
impeller::DescriptorType::kStorageBuffer
@ kStorageBuffer
impeller::ColorAttachmentDescriptor::write_mask
ColorWriteMask write_mask
Definition: formats.h:512
impeller::DescriptorType
DescriptorType
Definition: shader_types.h:153
impeller::StoreActionPerformsResolve
constexpr bool StoreActionPerformsResolve(StoreAction store_action)
Definition: formats_vk.h:338
impeller::ToImageAspectFlags
constexpr vk::ImageAspectFlags ToImageAspectFlags(PixelFormat format)
Definition: formats_vk.h:564
impeller::ColorAttachmentDescriptor
Describe the color attachment that will be used with this pipeline.
Definition: formats.h:500
impeller::SamplerAddressMode::kRepeat
@ kRepeat
impeller::SamplerAddressMode::kDecal
@ kDecal
decal sampling mode is only supported on devices that pass the Capabilities.SupportsDecalSamplerAddre...