| 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 }
387
388 FML_UNREACHABLE();
389 }
390
391 constexpr bool PixelFormatIsDepthStencil(PixelFormat format) {
392 switch (format) {
393 case PixelFormat::kUnknown:
394 case PixelFormat::kA8UNormInt:
395 case PixelFormat::kR8UNormInt:
396 case PixelFormat::kR8G8UNormInt:
397 case PixelFormat::kR8G8B8A8UNormInt:
398 case PixelFormat::kR8G8B8A8UNormIntSRGB:
399 case PixelFormat::kB8G8R8A8UNormInt:
400 case PixelFormat::kB8G8R8A8UNormIntSRGB:
401 case PixelFormat::kR32G32B32A32Float:
402 case PixelFormat::kR16G16B16A16Float:
403 case PixelFormat::kB10G10R10XR:
404 case PixelFormat::kB10G10R10XRSRGB:
405 case PixelFormat::kB10G10R10A10XR:
406 return false;
407 case PixelFormat::kS8UInt:
408 case PixelFormat::kD24UnormS8Uint:
409 case PixelFormat::kD32FloatS8UInt:
410 return true;
411 }
412 return false;
413 }
414
415 static constexpr vk::AttachmentReference kUnusedAttachmentReference = {
416 VK_ATTACHMENT_UNUSED, vk::ImageLayout::eUndefined};
417
418 constexpr vk::CullModeFlags ToVKCullModeFlags(CullMode mode) {
419 switch (mode) {
420 case CullMode::kNone:
421 return vk::CullModeFlagBits::eNone;
422 case CullMode::kFrontFace:
423 return vk::CullModeFlagBits::eFront;
424 case CullMode::kBackFace:
425 return vk::CullModeFlagBits::eBack;
426 }
427 FML_UNREACHABLE();
428 }
429
430 constexpr vk::CompareOp ToVKCompareOp(CompareFunction op) {
431 switch (op) {
432 case CompareFunction::kNever:
433 return vk::CompareOp::eNever;
434 case CompareFunction::kAlways:
435 return vk::CompareOp::eAlways;
436 case CompareFunction::kLess:
437 return vk::CompareOp::eLess;
438 case CompareFunction::kEqual:
439 return vk::CompareOp::eEqual;
440 case CompareFunction::kLessEqual:
441 return vk::CompareOp::eLessOrEqual;
442 case CompareFunction::kGreater:
443 return vk::CompareOp::eGreater;
444 case CompareFunction::kNotEqual:
445 return vk::CompareOp::eNotEqual;
446 case CompareFunction::kGreaterEqual:
447 return vk::CompareOp::eGreaterOrEqual;
448 }
449 FML_UNREACHABLE();
450 }
451
452 constexpr vk::StencilOp ToVKStencilOp(StencilOperation op) {
453 switch (op) {
454 case StencilOperation::kKeep:
455 return vk::StencilOp::eKeep;
456 case StencilOperation::kZero:
457 return vk::StencilOp::eZero;
458 case StencilOperation::kSetToReferenceValue:
459 return vk::StencilOp::eReplace;
460 case StencilOperation::kIncrementClamp:
461 return vk::StencilOp::eIncrementAndClamp;
462 case StencilOperation::kDecrementClamp:
463 return vk::StencilOp::eDecrementAndClamp;
464 case StencilOperation::kInvert:
465 return vk::StencilOp::eInvert;
466 case StencilOperation::kIncrementWrap:
467 return vk::StencilOp::eIncrementAndWrap;
468 case StencilOperation::kDecrementWrap:
469 return vk::StencilOp::eDecrementAndWrap;
470 break;
471 }
472 FML_UNREACHABLE();
473 }
474
475 constexpr vk::StencilOpState ToVKStencilOpState(
476 const StencilAttachmentDescriptor& desc) {
477 vk::StencilOpState state;
478 state.failOp = ToVKStencilOp(desc.stencil_failure);
479 state.passOp = ToVKStencilOp(desc.depth_stencil_pass);
480 state.depthFailOp = ToVKStencilOp(desc.depth_failure);
481 state.compareOp = ToVKCompareOp(desc.stencil_compare);
482 state.compareMask = desc.read_mask;
483 state.writeMask = desc.write_mask;
484 // This is irrelevant as the stencil references are always dynamic state and
485 // will be set in the render pass.
486 state.reference = 1988;
487 return state;
488 }
489
490 constexpr vk::ImageAspectFlags ToVKImageAspectFlags(PixelFormat format) {
491 switch (format) {
492 case PixelFormat::kUnknown:
493 case PixelFormat::kA8UNormInt:
494 case PixelFormat::kR8UNormInt:
495 case PixelFormat::kR8G8UNormInt:
496 case PixelFormat::kR8G8B8A8UNormInt:
497 case PixelFormat::kR8G8B8A8UNormIntSRGB:
498 case PixelFormat::kB8G8R8A8UNormInt:
499 case PixelFormat::kB8G8R8A8UNormIntSRGB:
500 case PixelFormat::kR32G32B32A32Float:
501 case PixelFormat::kR16G16B16A16Float:
502 case PixelFormat::kB10G10R10XR:
503 case PixelFormat::kB10G10R10XRSRGB:
504 case PixelFormat::kB10G10R10A10XR:
505 return vk::ImageAspectFlagBits::eColor;
506 case PixelFormat::kS8UInt:
507 return vk::ImageAspectFlagBits::eStencil;
508 case PixelFormat::kD24UnormS8Uint:
509 case PixelFormat::kD32FloatS8UInt:
510 return vk::ImageAspectFlagBits::eDepth |
511 vk::ImageAspectFlagBits::eStencil;
512 }
513 FML_UNREACHABLE();
514 }
515
516 constexpr uint32_t ToArrayLayerCount(TextureType type) {
517 switch (type) {
518 case TextureType::kTexture2D:
519 case TextureType::kTexture2DMultisample:
520 return 1u;
521 case TextureType::kTextureCube:
522 return 6u;
523 case TextureType::kTextureExternalOES:
524 VALIDATION_LOG
525 << "kTextureExternalOES can not be used with the Vulkan backend.";
526 }
527 FML_UNREACHABLE();
528 }
529
530 constexpr vk::ImageViewType ToVKImageViewType(TextureType type) {
531 switch (type) {
532 case TextureType::kTexture2D:
533 case TextureType::kTexture2DMultisample:
534 return vk::ImageViewType::e2D;
535 case TextureType::kTextureCube:
536 return vk::ImageViewType::eCube;
537 case TextureType::kTextureExternalOES:
538 VALIDATION_LOG
539 << "kTextureExternalOES can not be used with the Vulkan backend.";
540 }
541 FML_UNREACHABLE();
542 }
543
544 constexpr vk::ImageCreateFlags ToVKImageCreateFlags(TextureType type) {
545 switch (type) {
546 case TextureType::kTexture2D:
547 case TextureType::kTexture2DMultisample:
548 return {};
549 case TextureType::kTextureCube:
550 return vk::ImageCreateFlagBits::eCubeCompatible;
551 case TextureType::kTextureExternalOES:
552 VALIDATION_LOG
553 << "kTextureExternalOES can not be used with the Vulkan backend.";
554 }
555 FML_UNREACHABLE();
556 }
557
558 vk::PipelineDepthStencilStateCreateInfo ToVKPipelineDepthStencilStateCreateInfo(
559 std::optional<DepthAttachmentDescriptor> depth,
560 std::optional<StencilAttachmentDescriptor> front,
561 std::optional<StencilAttachmentDescriptor> back);
562
563 constexpr vk::ImageAspectFlags ToImageAspectFlags(PixelFormat format) {
564 switch (format) {
565 case PixelFormat::kUnknown:
566 return {};
567 case PixelFormat::kA8UNormInt:
568 case PixelFormat::kR8UNormInt:
569 case PixelFormat::kR8G8UNormInt:
570 case PixelFormat::kR8G8B8A8UNormInt:
571 case PixelFormat::kR8G8B8A8UNormIntSRGB:
572 case PixelFormat::kB8G8R8A8UNormInt:
573 case PixelFormat::kB8G8R8A8UNormIntSRGB:
574 case PixelFormat::kR32G32B32A32Float:
575 case PixelFormat::kR16G16B16A16Float:
576 case PixelFormat::kB10G10R10XR:
577 case PixelFormat::kB10G10R10XRSRGB:
578 case PixelFormat::kB10G10R10A10XR:
579 return vk::ImageAspectFlagBits::eColor;
580 case PixelFormat::kS8UInt:
581 return vk::ImageAspectFlagBits::eStencil;
582 case PixelFormat::kD24UnormS8Uint:
583 case PixelFormat::kD32FloatS8UInt:
584 return vk::ImageAspectFlagBits::eDepth |
585 vk::ImageAspectFlagBits::eStencil;
586 }
587 FML_UNREACHABLE();
588 }
589
590 } // namespace impeller
591
592 #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:516
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: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:391
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:383
impeller::StencilAttachmentDescriptor::depth_failure
StencilOperation depth_failure
Definition: formats.h:619
impeller::StencilAttachmentDescriptor::stencil_compare
CompareFunction stencil_compare
Definition: formats.h:610
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:435
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:516
impeller::TextureType
TextureType
Definition: formats.h:262
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:521
impeller::ToVKCullModeFlags
constexpr vk::CullModeFlags ToVKCullModeFlags(CullMode mode)
Definition: formats_vk.h:418
impeller::ShaderStage
ShaderStage
Definition: shader_types.h:22
impeller::StoreAction::kDontCare
@ kDontCare
impeller::ToVKImageCreateFlags
constexpr vk::ImageCreateFlags ToVKImageCreateFlags(TextureType type)
Definition: formats_vk.h:544
impeller::DescriptorSetLayout::shader_stage
ShaderStage shader_stage
Definition: shader_types.h:165
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:634
validation.h
impeller::ToVKStencilOpState
constexpr vk::StencilOpState ToVKStencilOpState(const StencilAttachmentDescriptor &desc)
Definition: formats_vk.h:475
impeller::StencilOperation
StencilOperation
Definition: formats.h:565
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:430
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:452
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:546
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:629
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:419
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:126
impeller::StencilAttachmentDescriptor::stencil_failure
StencilOperation stencil_failure
Definition: formats.h:614
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:409
impeller::PixelFormat::kR16G16B16A16Float
@ kR16G16B16A16Float
impeller::StencilAttachmentDescriptor::depth_stencil_pass
StencilOperation depth_stencil_pass
Definition: formats.h:623
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:530
impeller::CompareFunction::kAlways
@ kAlways
Comparison test passes always passes.
impeller::ToVKImageAspectFlags
constexpr vk::ImageAspectFlags ToVKImageAspectFlags(PixelFormat format)
Definition: formats_vk.h:490
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:520
impeller::ToVKAttachmentLoadOp
constexpr vk::AttachmentLoadOp ToVKAttachmentLoadOp(LoadAction load_action)
Definition: formats_vk.h:300
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:518
impeller::BlendOperation
BlendOperation
Definition: formats.h:196
impeller::ColorAttachmentDescriptor::dst_alpha_blend_factor
BlendFactor dst_alpha_blend_factor
Definition: formats.h:522
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:604
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:415
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:517
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:164
shader_types.h
impeller::CompareFunction::kLess
@ kLess
Comparison test passes if new_value < current_value.
impeller
Definition: aiks_blend_unittests.cc:18
impeller::ColorAttachmentDescriptor::blending_enabled
bool blending_enabled
Definition: formats.h:514
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:221
impeller::DescriptorType::kStorageBuffer
@ kStorageBuffer
impeller::ColorAttachmentDescriptor::write_mask
ColorWriteMask write_mask
Definition: formats.h:524
impeller::DescriptorType
DescriptorType
Definition: shader_types.h:153
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:563
impeller::ColorAttachmentDescriptor
Describe the color attachment that will be used with this pipeline.
Definition: formats.h:512
impeller::SamplerAddressMode::kRepeat
@ kRepeat
impeller::SamplerAddressMode::kDecal
@ kDecal
decal sampling mode is only supported on devices that pass the Capabilities.SupportsDecalSamplerAddre...