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