| Flutter Impeller |

formats.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_CORE_FORMATS_H_
6 #define FLUTTER_IMPELLER_CORE_FORMATS_H_
7
8 #include <cstdint>
9 #include <functional>
10 #include <memory>
11 #include <string>
12 #include <type_traits>
13
14 #include "flutter/fml/hash_combine.h"
15 #include "flutter/fml/logging.h"
16 #include "impeller/geometry/color.h"
17 #include "impeller/geometry/rect.h"
18 #include "impeller/geometry/scalar.h"
19
20 namespace impeller {
21
22 class Texture;
23
24 //------------------------------------------------------------------------------
25 /// @brief Specified where the allocation resides and how it is used.
26 ///
27 enum class StorageMode {
28 //----------------------------------------------------------------------------
29 /// Allocations can be mapped onto the hosts address space and also be used by
30 /// the device.
31 ///
32 kHostVisible,
33 //----------------------------------------------------------------------------
34 /// Allocations can only be used by the device. This location is optimal for
35 /// use by the device. If the host needs to access these allocations, the
36 /// transfer queue must be used to transfer this allocation onto the a host
37 /// visible buffer.
38 ///
39 kDevicePrivate,
40 //----------------------------------------------------------------------------
41 /// Used by the device for temporary render targets. These allocations cannot
42 /// be transferred from and to other allocations using the transfer queue.
43 /// Render pass cannot initialize the contents of these buffers using load and
44 /// store actions.
45 ///
46 /// These allocations reside in tile memory which has higher bandwidth, lower
47 /// latency and lower power consumption. The total device memory usage is
48 /// also lower as a separate allocation does not need to be created in
49 /// device memory. Prefer using these allocations for intermediates like depth
50 /// and stencil buffers.
51 ///
52 kDeviceTransient,
53 };
54
55 constexpr const char* StorageModeToString(StorageMode mode) {
56 switch (mode) {
57 case StorageMode::kHostVisible:
58 return "HostVisible";
59 case StorageMode::kDevicePrivate:
60 return "DevicePrivate";
61 case StorageMode::kDeviceTransient:
62 return "DeviceTransient";
63 }
64 FML_UNREACHABLE();
65 }
66
67 //------------------------------------------------------------------------------
68 /// @brief The Pixel formats supported by Impeller. The naming convention
69 /// denotes the usage of the component, the bit width of that
70 /// component, and then one or more qualifiers to its
71 /// interpretation.
72 ///
73 /// For instance, `kR8G8B8A8UNormIntSRGB` is a 32 bits-per-pixel
74 /// format ordered in RGBA with 8 bits per component with each
75 /// component expressed as an unsigned normalized integer and a
76 /// conversion from sRGB to linear color space.
77 ///
78 /// Key:
79 /// R -> Red Component
80 /// G -> Green Component
81 /// B -> Blue Component
82 /// D -> Depth Component
83 /// S -> Stencil Component
84 /// U -> Unsigned (Lack of this denotes a signed component)
85 /// Norm -> Normalized
86 /// SRGB -> sRGB to linear interpretation
87 ///
88 /// While the effective bit width of the pixel can be determined by
89 /// adding up the widths of each component, only the non-esoteric
90 /// formats are tightly packed. Do not assume tight packing for the
91 /// esoteric formats and use blit passes to convert to a
92 /// non-esoteric pass.
93 ///
94 enum class PixelFormat : uint8_t {
95 kUnknown,
96 kA8UNormInt,
97 kR8UNormInt,
98 kR8G8UNormInt,
99 kR8G8B8A8UNormInt,
100 kR8G8B8A8UNormIntSRGB,
101 kB8G8R8A8UNormInt,
102 kB8G8R8A8UNormIntSRGB,
103 kR32G32B32A32Float,
104 kR16G16B16A16Float,
105 kB10G10R10XR,
106 kB10G10R10XRSRGB,
107 kB10G10R10A10XR,
108 // Depth and stencil formats.
109 kS8UInt,
110 kD24UnormS8Uint,
111 kD32FloatS8UInt,
112 };
113
114 constexpr bool IsDepthWritable(PixelFormat format) {
115 switch (format) {
116 case PixelFormat::kD24UnormS8Uint:
117 case PixelFormat::kD32FloatS8UInt:
118 return true;
119 default:
120 return false;
121 }
122 }
123
124 constexpr bool IsStencilWritable(PixelFormat format) {
125 switch (format) {
126 case PixelFormat::kS8UInt:
127 case PixelFormat::kD24UnormS8Uint:
128 case PixelFormat::kD32FloatS8UInt:
129 return true;
130 default:
131 return false;
132 }
133 }
134
135 constexpr const char* PixelFormatToString(PixelFormat format) {
136 switch (format) {
137 case PixelFormat::kUnknown:
138 return "Unknown";
139 case PixelFormat::kA8UNormInt:
140 return "A8UNormInt";
141 case PixelFormat::kR8UNormInt:
142 return "R8UNormInt";
143 case PixelFormat::kR8G8UNormInt:
144 return "R8G8UNormInt";
145 case PixelFormat::kR8G8B8A8UNormInt:
146 return "R8G8B8A8UNormInt";
147 case PixelFormat::kR8G8B8A8UNormIntSRGB:
148 return "R8G8B8A8UNormIntSRGB";
149 case PixelFormat::kB8G8R8A8UNormInt:
150 return "B8G8R8A8UNormInt";
151 case PixelFormat::kB8G8R8A8UNormIntSRGB:
152 return "B8G8R8A8UNormIntSRGB";
153 case PixelFormat::kR32G32B32A32Float:
154 return "R32G32B32A32Float";
155 case PixelFormat::kR16G16B16A16Float:
156 return "R16G16B16A16Float";
157 case PixelFormat::kB10G10R10XR:
158 return "B10G10R10XR";
159 case PixelFormat::kB10G10R10XRSRGB:
160 return "B10G10R10XRSRGB";
161 case PixelFormat::kB10G10R10A10XR:
162 return "B10G10R10A10XR";
163 case PixelFormat::kS8UInt:
164 return "S8UInt";
165 case PixelFormat::kD24UnormS8Uint:
166 return "D24UnormS8Uint";
167 case PixelFormat::kD32FloatS8UInt:
168 return "D32FloatS8UInt";
169 }
170 FML_UNREACHABLE();
171 }
172
173 enum class BlendFactor {
174 kZero,
175 kOne,
176 kSourceColor,
177 kOneMinusSourceColor,
178 kSourceAlpha,
179 kOneMinusSourceAlpha,
180 kDestinationColor,
181 kOneMinusDestinationColor,
182 kDestinationAlpha,
183 kOneMinusDestinationAlpha,
184 kSourceAlphaSaturated,
185 kBlendColor,
186 kOneMinusBlendColor,
187 kBlendAlpha,
188 kOneMinusBlendAlpha,
189 };
190
191 enum class BlendOperation {
192 kAdd,
193 kSubtract,
194 kReverseSubtract,
195 };
196
197 enum class LoadAction {
198 kDontCare,
199 kLoad,
200 kClear,
201 };
202
203 enum class StoreAction {
204 kDontCare,
205 kStore,
206 kMultisampleResolve,
207 kStoreAndMultisampleResolve,
208 };
209
210 constexpr const char* LoadActionToString(LoadAction action) {
211 switch (action) {
212 case LoadAction::kDontCare:
213 return "DontCare";
214 case LoadAction::kLoad:
215 return "Load";
216 case LoadAction::kClear:
217 return "Clear";
218 }
219 }
220
221 constexpr const char* StoreActionToString(StoreAction action) {
222 switch (action) {
223 case StoreAction::kDontCare:
224 return "DontCare";
225 case StoreAction::kStore:
226 return "Store";
227 case StoreAction::kMultisampleResolve:
228 return "MultisampleResolve";
229 case StoreAction::kStoreAndMultisampleResolve:
230 return "StoreAndMultisampleResolve";
231 }
232 }
233
234 constexpr bool CanClearAttachment(LoadAction action) {
235 switch (action) {
236 case LoadAction::kLoad:
237 return false;
238 case LoadAction::kDontCare:
239 case LoadAction::kClear:
240 return true;
241 }
242 FML_UNREACHABLE();
243 }
244
245 constexpr bool CanDiscardAttachmentWhenDone(StoreAction action) {
246 switch (action) {
247 case StoreAction::kStore:
248 case StoreAction::kStoreAndMultisampleResolve:
249 return false;
250 case StoreAction::kDontCare:
251 case StoreAction::kMultisampleResolve:
252 return true;
253 }
254 FML_UNREACHABLE();
255 }
256
257 enum class TextureType {
258 kTexture2D,
259 kTexture2DMultisample,
260 kTextureCube,
261 kTextureExternalOES,
262 };
263
264 constexpr const char* TextureTypeToString(TextureType type) {
265 switch (type) {
266 case TextureType::kTexture2D:
267 return "Texture2D";
268 case TextureType::kTexture2DMultisample:
269 return "Texture2DMultisample";
270 case TextureType::kTextureCube:
271 return "TextureCube";
272 case TextureType::kTextureExternalOES:
273 return "TextureExternalOES";
274 }
275 FML_UNREACHABLE();
276 }
277
278 constexpr bool IsMultisampleCapable(TextureType type) {
279 switch (type) {
280 case TextureType::kTexture2D:
281 case TextureType::kTextureCube:
282 case TextureType::kTextureExternalOES:
283 return false;
284 case TextureType::kTexture2DMultisample:
285 return true;
286 }
287 return false;
288 }
289
290 enum class SampleCount : uint8_t {
291 kCount1 = 1,
292 kCount4 = 4,
293 };
294
295 using TextureUsageMask = uint64_t;
296
297 enum class TextureUsage : TextureUsageMask {
298 kUnknown = 0,
299 kShaderRead = 1 << 0,
300 kShaderWrite = 1 << 1,
301 kRenderTarget = 1 << 2,
302 };
303
304 constexpr bool TextureUsageIsRenderTarget(TextureUsageMask mask) {
305 return static_cast<TextureUsageMask>(TextureUsage::kRenderTarget) & mask;
306 }
307
308 constexpr const char* TextureUsageToString(TextureUsage usage) {
309 switch (usage) {
310 case TextureUsage::kUnknown:
311 return "Unknown";
312 case TextureUsage::kShaderRead:
313 return "ShaderRead";
314 case TextureUsage::kShaderWrite:
315 return "ShaderWrite";
316 case TextureUsage::kRenderTarget:
317 return "RenderTarget";
318 }
319 FML_UNREACHABLE();
320 }
321
322 std::string TextureUsageMaskToString(TextureUsageMask mask);
323
324 // Texture coordinate system.
325 enum class TextureCoordinateSystem {
326 // Alternative coordinate system used when uploading texture data from the
327 // host.
328 // (0, 0) is the bottom-left of the image with +Y going up.
329 kUploadFromHost,
330 // Default coordinate system.
331 // (0, 0) is the top-left of the image with +Y going down.
332 kRenderToTexture,
333 };
334
335 enum class CullMode {
336 kNone,
337 kFrontFace,
338 kBackFace,
339 };
340
341 enum class IndexType {
342 kUnknown,
343 k16bit,
344 k32bit,
345 /// Does not use the index buffer.
346 kNone,
347 };
348
349 /// Decides how backend draws pixels based on input vertices.
350 enum class PrimitiveType : uint8_t {
351 /// Draws a triage for each separate set of three vertices.
352 ///
353 /// Vertices [A, B, C, D, E, F] will produce triages
354 /// [ABC, DEF].
355 kTriangle,
356
357 /// Draws a triage for every adjacent three vertices.
358 ///
359 /// Vertices [A, B, C, D, E, F] will produce triages
360 /// [ABC, BCD, CDE, DEF].
361 kTriangleStrip,
362
363 /// Draws a line for each separate set of two vertices.
364 ///
365 /// Vertices [A, B, C] will produce discontinued line
366 /// [AB, BC].
367 kLine,
368
369 /// Draws a continuous line that connect every input vertices
370 ///
371 /// Vertices [A, B, C] will produce one continuous line
372 /// [ABC].
373 kLineStrip,
374
375 /// Draws a point at each input vertex.
376 kPoint,
377 // Triangle fans are implementation dependent and need extra extensions
378 // checks. Hence, they are not supported here.
379 };
380
381 enum class PolygonMode {
382 kFill,
383 kLine,
384 };
385
386 struct DepthRange {
387 Scalar z_near = 0.0;
388 Scalar z_far = 1.0;
389
390 constexpr bool operator==(const DepthRange& other) const {
391 return z_near == other.z_near && z_far == other.z_far;
392 }
393 };
394
395 struct Viewport {
396 Rect rect;
397 DepthRange depth_range;
398
399 constexpr bool operator==(const Viewport& other) const {
400 return rect == other.rect && depth_range == other.depth_range;
401 }
402 };
403
404 enum class MinMagFilter {
405 /// Select nearest to the sample point. Most widely supported.
406 kNearest,
407 /// Select two points and linearly interpolate between them. Some formats
408 /// may not support this.
409 kLinear,
410 };
411
412 enum class MipFilter {
413 /// Sample from the nearest mip level.
414 kNearest,
415 /// Sample from the two nearest mip levels and linearly interpolate between
416 /// them.
417 kLinear,
418 };
419
420 enum class SamplerAddressMode {
421 kClampToEdge,
422 kRepeat,
423 kMirror,
424 // More modes are almost always supported but they are usually behind
425 // extensions checks. The ones current in these structs are safe (always
426 // supported) defaults.
427
428 /// @brief decal sampling mode is only supported on devices that pass
429 /// the `Capabilities.SupportsDecalSamplerAddressMode` check.
430 kDecal,
431 };
432
433 enum class ColorWriteMask : uint64_t {
434 kNone = 0,
435 kRed = 1 << 0,
436 kGreen = 1 << 1,
437 kBlue = 1 << 2,
438 kAlpha = 1 << 3,
439 kAll = kRed | kGreen | kBlue | kAlpha,
440 };
441
442 constexpr size_t BytesPerPixelForPixelFormat(PixelFormat format) {
443 switch (format) {
444 case PixelFormat::kUnknown:
445 return 0u;
446 case PixelFormat::kA8UNormInt:
447 case PixelFormat::kR8UNormInt:
448 case PixelFormat::kS8UInt:
449 return 1u;
450 case PixelFormat::kR8G8UNormInt:
451 return 2u;
452 case PixelFormat::kR8G8B8A8UNormInt:
453 case PixelFormat::kR8G8B8A8UNormIntSRGB:
454 case PixelFormat::kB8G8R8A8UNormInt:
455 case PixelFormat::kB8G8R8A8UNormIntSRGB:
456 case PixelFormat::kB10G10R10XRSRGB:
457 case PixelFormat::kB10G10R10XR:
458 return 4u;
459 case PixelFormat::kD24UnormS8Uint:
460 return 4u;
461 case PixelFormat::kD32FloatS8UInt:
462 return 5u;
463 case PixelFormat::kR16G16B16A16Float:
464 case PixelFormat::kB10G10R10A10XR:
465 return 8u;
466 case PixelFormat::kR32G32B32A32Float:
467 return 16u;
468 }
469 return 0u;
470 }
471
472 //------------------------------------------------------------------------------
473 /// @brief Describe the color attachment that will be used with this
474 /// pipeline.
475 ///
476 /// Blending at specific color attachments follows the pseudo-code:
477 /// ```
478 /// if (blending_enabled) {
479 /// final_color.rgb = (src_color_blend_factor * new_color.rgb)
480 /// <color_blend_op>
481 /// (dst_color_blend_factor * old_color.rgb);
482 /// final_color.a = (src_alpha_blend_factor * new_color.a)
483 /// <alpha_blend_op>
484 /// (dst_alpha_blend_factor * old_color.a);
485 /// } else {
486 /// final_color = new_color;
487 /// }
488 /// // IMPORTANT: The write mask is applied irrespective of whether
489 /// // blending_enabled is set.
490 /// final_color = final_color & write_mask;
491 /// ```
492 ///
493 /// The default blend mode is 1 - source alpha.
494 struct ColorAttachmentDescriptor {
495 PixelFormat format = PixelFormat::kUnknown;
496 bool blending_enabled = false;
497
498 BlendFactor src_color_blend_factor = BlendFactor::kSourceAlpha;
499 BlendOperation color_blend_op = BlendOperation::kAdd;
500 BlendFactor dst_color_blend_factor = BlendFactor::kOneMinusSourceAlpha;
501
502 BlendFactor src_alpha_blend_factor = BlendFactor::kSourceAlpha;
503 BlendOperation alpha_blend_op = BlendOperation::kAdd;
504 BlendFactor dst_alpha_blend_factor = BlendFactor::kOneMinusSourceAlpha;
505
506 std::underlying_type_t<ColorWriteMask> write_mask =
507 static_cast<uint64_t>(ColorWriteMask::kAll);
508
509 constexpr bool operator==(const ColorAttachmentDescriptor& o) const {
510 return format == o.format && //
511 blending_enabled == o.blending_enabled && //
512 src_color_blend_factor == o.src_color_blend_factor && //
513 color_blend_op == o.color_blend_op && //
514 dst_color_blend_factor == o.dst_color_blend_factor && //
515 src_alpha_blend_factor == o.src_alpha_blend_factor && //
516 alpha_blend_op == o.alpha_blend_op && //
517 dst_alpha_blend_factor == o.dst_alpha_blend_factor && //
518 write_mask == o.write_mask;
519 }
520
521 constexpr size_t Hash() const {
522 return fml::HashCombine(format, blending_enabled, src_color_blend_factor,
523 color_blend_op, dst_color_blend_factor,
524 src_alpha_blend_factor, alpha_blend_op,
525 dst_alpha_blend_factor, write_mask);
526 }
527 };
528
529 enum class CompareFunction : uint8_t {
530 /// Comparison test never passes.
531 kNever,
532 /// Comparison test passes always passes.
533 kAlways,
534 /// Comparison test passes if new_value < current_value.
535 kLess,
536 /// Comparison test passes if new_value == current_value.
537 kEqual,
538 /// Comparison test passes if new_value <= current_value.
539 kLessEqual,
540 /// Comparison test passes if new_value > current_value.
541 kGreater,
542 /// Comparison test passes if new_value != current_value.
543 kNotEqual,
544 /// Comparison test passes if new_value >= current_value.
545 kGreaterEqual,
546 };
547
548 enum class StencilOperation : uint8_t {
549 /// Don't modify the current stencil value.
550 kKeep,
551 /// Reset the stencil value to zero.
552 kZero,
553 /// Reset the stencil value to the reference value.
554 kSetToReferenceValue,
555 /// Increment the current stencil value by 1. Clamp it to the maximum.
556 kIncrementClamp,
557 /// Decrement the current stencil value by 1. Clamp it to zero.
558 kDecrementClamp,
559 /// Perform a logical bitwise invert on the current stencil value.
560 kInvert,
561 /// Increment the current stencil value by 1. If at maximum, set to zero.
562 kIncrementWrap,
563 /// Decrement the current stencil value by 1. If at zero, set to maximum.
564 kDecrementWrap,
565 };
566
567 struct DepthAttachmentDescriptor {
568 //----------------------------------------------------------------------------
569 /// Indicates how to compare the value with that in the depth buffer.
570 ///
571 CompareFunction depth_compare = CompareFunction::kAlways;
572 //----------------------------------------------------------------------------
573 /// Indicates when writes must be performed to the depth buffer.
574 ///
575 bool depth_write_enabled = false;
576
577 constexpr bool operator==(const DepthAttachmentDescriptor& o) const {
578 return depth_compare == o.depth_compare &&
579 depth_write_enabled == o.depth_write_enabled;
580 }
581
582 constexpr size_t GetHash() const {
583 return fml::HashCombine(depth_compare, depth_write_enabled);
584 }
585 };
586
587 struct StencilAttachmentDescriptor {
588 //----------------------------------------------------------------------------
589 /// Indicates the operation to perform between the reference value and the
590 /// value in the stencil buffer. Both values have the read_mask applied to
591 /// them before performing this operation.
592 ///
593 CompareFunction stencil_compare = CompareFunction::kAlways;
594 //----------------------------------------------------------------------------
595 /// Indicates what to do when the stencil test has failed.
596 ///
597 StencilOperation stencil_failure = StencilOperation::kKeep;
598 //----------------------------------------------------------------------------
599 /// Indicates what to do when the stencil test passes but the depth test
600 /// fails.
601 ///
602 StencilOperation depth_failure = StencilOperation::kKeep;
603 //----------------------------------------------------------------------------
604 /// Indicates what to do when both the stencil and depth tests pass.
605 ///
606 StencilOperation depth_stencil_pass = StencilOperation::kKeep;
607
608 //----------------------------------------------------------------------------
609 /// The mask applied to the reference and stencil buffer values before
610 /// performing the stencil_compare operation.
611 ///
612 uint32_t read_mask = ~0;
613 //----------------------------------------------------------------------------
614 /// The mask applied to the new stencil value before it is written into the
615 /// stencil buffer.
616 ///
617 uint32_t write_mask = ~0;
618
619 constexpr bool operator==(const StencilAttachmentDescriptor& o) const {
620 return stencil_compare == o.stencil_compare &&
621 stencil_failure == o.stencil_failure &&
622 depth_failure == o.depth_failure &&
623 depth_stencil_pass == o.depth_stencil_pass &&
624 read_mask == o.read_mask && write_mask == o.write_mask;
625 }
626
627 constexpr size_t GetHash() const {
628 return fml::HashCombine(stencil_compare, stencil_failure, depth_failure,
629 depth_stencil_pass, read_mask, write_mask);
630 }
631 };
632
633 struct Attachment {
634 std::shared_ptr<Texture> texture;
635 std::shared_ptr<Texture> resolve_texture;
636 LoadAction load_action = LoadAction::kDontCare;
637 StoreAction store_action = StoreAction::kStore;
638
639 bool IsValid() const;
640 };
641
642 struct ColorAttachment : public Attachment {
643 Color clear_color = Color::BlackTransparent();
644 };
645
646 struct DepthAttachment : public Attachment {
647 double clear_depth = 0.0;
648 };
649
650 struct StencilAttachment : public Attachment {
651 uint32_t clear_stencil = 0;
652 };
653
654 std::string AttachmentToString(const Attachment& attachment);
655
656 std::string ColorAttachmentToString(const ColorAttachment& color);
657
658 std::string DepthAttachmentToString(const DepthAttachment& depth);
659
660 std::string StencilAttachmentToString(const StencilAttachment& stencil);
661
662 } // namespace impeller
663
664 namespace std {
665
666 template <>
667 struct hash<impeller::DepthAttachmentDescriptor> {
668 constexpr std::size_t operator()(
669 const impeller::DepthAttachmentDescriptor& des) const {
670 return des.GetHash();
671 }
672 };
673
674 template <>
675 struct hash<impeller::StencilAttachmentDescriptor> {
676 constexpr std::size_t operator()(
677 const impeller::StencilAttachmentDescriptor& des) const {
678 return des.GetHash();
679 }
680 };
681
682 } // namespace std
683
684 #endif // FLUTTER_IMPELLER_CORE_FORMATS_H_
impeller::StoreAction::kMultisampleResolve
@ kMultisampleResolve
impeller::PixelFormat::kS8UInt
@ kS8UInt
impeller::TextureType::kTextureExternalOES
@ kTextureExternalOES
impeller::ColorAttachmentDescriptor::src_color_blend_factor
BlendFactor src_color_blend_factor
Definition: formats.h:498
impeller::CompareFunction::kGreater
@ kGreater
Comparison test passes if new_value > current_value.
impeller::PrimitiveType::kLineStrip
@ kLineStrip
impeller::LoadAction::kLoad
@ kLoad
impeller::StoreAction
StoreAction
Definition: formats.h:203
impeller::StencilOperation::kDecrementClamp
@ kDecrementClamp
Decrement the current stencil value by 1. Clamp it to zero.
impeller::ColorWriteMask
ColorWriteMask
Definition: formats.h:433
impeller::StoreAction::kStoreAndMultisampleResolve
@ kStoreAndMultisampleResolve
impeller::TextureUsageMask
uint64_t TextureUsageMask
Definition: formats.h:295
impeller::IndexType::k16bit
@ k16bit
impeller::Attachment::store_action
StoreAction store_action
Definition: formats.h:637
impeller::PolygonMode
PolygonMode
Definition: formats.h:381
impeller::PixelFormatToString
constexpr const char * PixelFormatToString(PixelFormat format)
Definition: formats.h:135
impeller::Scalar
float Scalar
Definition: scalar.h:18
impeller::CanClearAttachment
constexpr bool CanClearAttachment(LoadAction action)
Definition: formats.h:234
impeller::TextureUsage
TextureUsage
Definition: formats.h:297
impeller::StencilAttachmentDescriptor::depth_failure
StencilOperation depth_failure
Definition: formats.h:602
impeller::StencilAttachmentDescriptor::stencil_compare
CompareFunction stencil_compare
Definition: formats.h:593
impeller::Viewport::rect
Rect rect
Definition: formats.h:396
impeller::PixelFormat::kB10G10R10A10XR
@ kB10G10R10A10XR
impeller::PixelFormat::kB8G8R8A8UNormIntSRGB
@ kB8G8R8A8UNormIntSRGB
impeller::TextureUsage::kUnknown
@ kUnknown
impeller::PixelFormat::kA8UNormInt
@ kA8UNormInt
impeller::Viewport::depth_range
DepthRange depth_range
Definition: formats.h:397
impeller::BlendFactor::kSourceAlphaSaturated
@ kSourceAlphaSaturated
impeller::BlendFactor
BlendFactor
Definition: formats.h:173
impeller::DepthRange::z_far
Scalar z_far
Definition: formats.h:388
impeller::IsDepthWritable
constexpr bool IsDepthWritable(PixelFormat format)
Definition: formats.h:114
impeller::PixelFormat::kR8UNormInt
@ kR8UNormInt
impeller::Color
Definition: color.h:124
impeller::ColorAttachmentDescriptor::write_mask
std::underlying_type_t< ColorWriteMask > write_mask
Definition: formats.h:506
impeller::CompareFunction::kEqual
@ kEqual
Comparison test passes if new_value == current_value.
impeller::BlendFactor::kOneMinusSourceAlpha
@ kOneMinusSourceAlpha
impeller::ColorAttachment
Definition: formats.h:642
impeller::SamplerAddressMode
SamplerAddressMode
Definition: formats.h:420
impeller::CompareFunction::kGreaterEqual
@ kGreaterEqual
Comparison test passes if new_value >= current_value.
impeller::StencilOperation::kKeep
@ kKeep
Don't modify the current stencil value.
impeller::LoadActionToString
constexpr const char * LoadActionToString(LoadAction action)
Definition: formats.h:210
impeller::PixelFormat::kR8G8B8A8UNormInt
@ kR8G8B8A8UNormInt
impeller::TextureType
TextureType
Definition: formats.h:257
impeller::ColorWriteMask::kGreen
@ kGreen
impeller::DepthRange::z_near
Scalar z_near
Definition: formats.h:387
impeller::DepthAttachmentDescriptor::GetHash
constexpr size_t GetHash() const
Definition: formats.h:582
impeller::StencilOperation::kIncrementClamp
@ kIncrementClamp
Increment the current stencil value by 1. Clamp it to the maximum.
impeller::ColorWriteMask::kRed
@ kRed
impeller::ColorAttachmentDescriptor::alpha_blend_op
BlendOperation alpha_blend_op
Definition: formats.h:503
impeller::TextureUsage::kRenderTarget
@ kRenderTarget
impeller::StoreAction::kDontCare
@ kDontCare
impeller::StencilOperation::kInvert
@ kInvert
Perform a logical bitwise invert on the current stencil value.
impeller::SamplerAddressMode::kClampToEdge
@ kClampToEdge
impeller::BlendFactor::kDestinationAlpha
@ kDestinationAlpha
impeller::IndexType::k32bit
@ k32bit
impeller::StencilAttachmentDescriptor::write_mask
uint32_t write_mask
Definition: formats.h:617
impeller::StorageMode::kHostVisible
@ kHostVisible
impeller::StencilOperation
StencilOperation
Definition: formats.h:548
impeller::PolygonMode::kFill
@ kFill
impeller::StencilOperation::kSetToReferenceValue
@ kSetToReferenceValue
Reset the stencil value to the reference value.
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:94
impeller::PrimitiveType::kLine
@ kLine
impeller::BlendFactor::kDestinationColor
@ kDestinationColor
impeller::MinMagFilter::kNearest
@ kNearest
Select nearest to the sample point. Most widely supported.
impeller::TextureCoordinateSystem::kUploadFromHost
@ kUploadFromHost
impeller::PrimitiveType::kTriangle
@ kTriangle
impeller::ColorAttachmentDescriptor::Hash
constexpr size_t Hash() const
Definition: formats.h:521
impeller::BlendFactor::kZero
@ kZero
impeller::TextureType::kTexture2DMultisample
@ kTexture2DMultisample
impeller::StencilAttachment
Definition: formats.h:650
impeller::TextureCoordinateSystem
TextureCoordinateSystem
Definition: formats.h:325
impeller::CullMode
CullMode
Definition: formats.h:335
impeller::MipFilter::kNearest
@ kNearest
Sample from the nearest mip level.
impeller::TextureCoordinateSystem::kRenderToTexture
@ kRenderToTexture
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:529
impeller::DepthAttachmentDescriptor::depth_write_enabled
bool depth_write_enabled
Definition: formats.h:575
impeller::BlendFactor::kOneMinusDestinationColor
@ kOneMinusDestinationColor
impeller::PrimitiveType::kTriangleStrip
@ kTriangleStrip
impeller::PrimitiveType
PrimitiveType
Decides how backend draws pixels based on input vertices.
Definition: formats.h:350
impeller::StorageMode::kDeviceTransient
@ kDeviceTransient
impeller::ColorAttachment::clear_color
Color clear_color
Definition: formats.h:643
impeller::CullMode::kBackFace
@ kBackFace
impeller::StorageMode
StorageMode
Specified where the allocation resides and how it is used.
Definition: formats.h:27
impeller::DepthAttachmentDescriptor::operator==
constexpr bool operator==(const DepthAttachmentDescriptor &o) const
Definition: formats.h:577
impeller::CullMode::kNone
@ kNone
impeller::StencilAttachmentDescriptor::read_mask
uint32_t read_mask
Definition: formats.h:612
impeller::MipFilter
MipFilter
Definition: formats.h:412
impeller::BlendOperation::kReverseSubtract
@ kReverseSubtract
impeller::BytesPerPixelForPixelFormat
constexpr size_t BytesPerPixelForPixelFormat(PixelFormat format)
Definition: formats.h:442
impeller::BlendFactor::kBlendAlpha
@ kBlendAlpha
impeller::Attachment::texture
std::shared_ptr< Texture > texture
Definition: formats.h:634
impeller::DepthRange::operator==
constexpr bool operator==(const DepthRange &other) const
Definition: formats.h:390
impeller::LoadAction
LoadAction
Definition: formats.h:197
impeller::PrimitiveType::kPoint
@ kPoint
Draws a point at each input vertex.
impeller::PixelFormat::kR8G8UNormInt
@ kR8G8UNormInt
impeller::BlendOperation::kAdd
@ kAdd
impeller::ColorWriteMask::kNone
@ kNone
impeller::MinMagFilter::kLinear
@ kLinear
impeller::StorageMode::kDevicePrivate
@ kDevicePrivate
impeller::StorageModeToString
constexpr const char * StorageModeToString(StorageMode mode)
Definition: formats.h:55
impeller::BlendFactor::kBlendColor
@ kBlendColor
std::hash< impeller::DepthAttachmentDescriptor >::operator()
constexpr std::size_t operator()(const impeller::DepthAttachmentDescriptor &des) const
Definition: formats.h:668
impeller::IndexType
IndexType
Definition: formats.h:341
impeller::PixelFormat::kB10G10R10XR
@ kB10G10R10XR
impeller::AttachmentToString
std::string AttachmentToString(const Attachment &attachment)
Definition: formats.cc:104
impeller::ColorAttachmentToString
std::string ColorAttachmentToString(const ColorAttachment &color)
Definition: formats.cc:123
impeller::TextureUsage::kShaderRead
@ kShaderRead
impeller::PixelFormat::kD24UnormS8Uint
@ kD24UnormS8Uint
impeller::StencilAttachmentDescriptor::stencil_failure
StencilOperation stencil_failure
Definition: formats.h:597
impeller::IsStencilWritable
constexpr bool IsStencilWritable(PixelFormat format)
Definition: formats.h:124
impeller::BlendFactor::kOneMinusBlendColor
@ kOneMinusBlendColor
impeller::IndexType::kNone
@ kNone
Does not use the index buffer.
impeller::ColorAttachmentDescriptor::format
PixelFormat format
Definition: formats.h:495
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:404
impeller::PixelFormat::kR16G16B16A16Float
@ kR16G16B16A16Float
impeller::StencilAttachmentDescriptor::depth_stencil_pass
StencilOperation depth_stencil_pass
Definition: formats.h:606
impeller::Attachment
Definition: formats.h:633
impeller::StoreAction::kStore
@ kStore
impeller::StencilAttachment::clear_stencil
uint32_t clear_stencil
Definition: formats.h:651
impeller::CompareFunction::kLessEqual
@ kLessEqual
Comparison test passes if new_value <= current_value.
impeller::StencilAttachmentDescriptor::operator==
constexpr bool operator==(const StencilAttachmentDescriptor &o) const
Definition: formats.h:619
impeller::BlendFactor::kOne
@ kOne
impeller::BlendFactor::kOneMinusBlendAlpha
@ kOneMinusBlendAlpha
impeller::CanDiscardAttachmentWhenDone
constexpr bool CanDiscardAttachmentWhenDone(StoreAction action)
Definition: formats.h:245
impeller::StencilAttachmentDescriptor::GetHash
constexpr size_t GetHash() const
Definition: formats.h:627
impeller::IsMultisampleCapable
constexpr bool IsMultisampleCapable(TextureType type)
Definition: formats.h:278
impeller::CompareFunction::kAlways
@ kAlways
Comparison test passes always passes.
impeller::DepthRange
Definition: formats.h:386
impeller::TextureType::kTexture2D
@ kTexture2D
impeller::StencilOperation::kZero
@ kZero
Reset the stencil value to zero.
impeller::PixelFormat::kR32G32B32A32Float
@ kR32G32B32A32Float
impeller::TextureUsageMaskToString
std::string TextureUsageMaskToString(TextureUsageMask mask)
Definition: formats.cc:81
impeller::PixelFormat::kUnknown
@ kUnknown
impeller::CompareFunction::kNever
@ kNever
Comparison test never passes.
std::hash< impeller::StencilAttachmentDescriptor >::operator()
constexpr std::size_t operator()(const impeller::StencilAttachmentDescriptor &des) const
Definition: formats.h:676
scalar.h
impeller::ColorAttachmentDescriptor::src_alpha_blend_factor
BlendFactor src_alpha_blend_factor
Definition: formats.h:502
impeller::Viewport
Definition: formats.h:395
impeller::CullMode::kFrontFace
@ kFrontFace
impeller::ColorAttachmentDescriptor::dst_color_blend_factor
BlendFactor dst_color_blend_factor
Definition: formats.h:500
impeller::TextureTypeToString
constexpr const char * TextureTypeToString(TextureType type)
Definition: formats.h:264
impeller::BlendOperation
BlendOperation
Definition: formats.h:191
impeller::ColorAttachmentDescriptor::dst_alpha_blend_factor
BlendFactor dst_alpha_blend_factor
Definition: formats.h:504
impeller::Attachment::resolve_texture
std::shared_ptr< Texture > resolve_texture
Definition: formats.h:635
impeller::ColorWriteMask::kAll
@ kAll
impeller::PixelFormat::kR8G8B8A8UNormIntSRGB
@ kR8G8B8A8UNormIntSRGB
impeller::SamplerAddressMode::kMirror
@ kMirror
std
Definition: comparable.h:95
impeller::DepthAttachmentToString
std::string DepthAttachmentToString(const DepthAttachment &depth)
Definition: formats.cc:130
impeller::LoadAction::kDontCare
@ kDontCare
rect.h
impeller::DepthAttachmentDescriptor
Definition: formats.h:567
impeller::Color::BlackTransparent
static constexpr Color BlackTransparent()
Definition: color.h:262
impeller::StencilAttachmentDescriptor
Definition: formats.h:587
impeller::SampleCount
SampleCount
Definition: formats.h:290
impeller::Attachment::load_action
LoadAction load_action
Definition: formats.h:636
impeller::BlendFactor::kOneMinusSourceColor
@ kOneMinusSourceColor
impeller::MipFilter::kLinear
@ kLinear
impeller::Viewport::operator==
constexpr bool operator==(const Viewport &other) const
Definition: formats.h:399
impeller::Attachment::IsValid
bool IsValid() const
Definition: formats.cc:26
impeller::ColorWriteMask::kAlpha
@ kAlpha
color.h
impeller::ColorAttachmentDescriptor::operator==
constexpr bool operator==(const ColorAttachmentDescriptor &o) const
Definition: formats.h:509
impeller::ColorWriteMask::kBlue
@ kBlue
impeller::DepthAttachment::clear_depth
double clear_depth
Definition: formats.h:647
impeller::SampleCount::kCount1
@ kCount1
impeller::SampleCount::kCount4
@ kCount4
impeller::PolygonMode::kLine
@ kLine
impeller::StoreActionToString
constexpr const char * StoreActionToString(StoreAction action)
Definition: formats.h:221
impeller::DepthAttachment
Definition: formats.h:646
impeller::ColorAttachmentDescriptor::color_blend_op
BlendOperation color_blend_op
Definition: formats.h:499
impeller::CompareFunction::kNotEqual
@ kNotEqual
Comparison test passes if new_value != current_value.
impeller::PixelFormat::kB10G10R10XRSRGB
@ kB10G10R10XRSRGB
impeller::PixelFormat::kB8G8R8A8UNormInt
@ kB8G8R8A8UNormInt
impeller::BlendFactor::kSourceAlpha
@ kSourceAlpha
impeller::TextureUsage::kShaderWrite
@ kShaderWrite
impeller::TextureUsageToString
constexpr const char * TextureUsageToString(TextureUsage usage)
Definition: formats.h:308
impeller::CompareFunction::kLess
@ kLess
Comparison test passes if new_value < current_value.
impeller
Definition: aiks_context.cc:10
impeller::StencilAttachmentToString
std::string StencilAttachmentToString(const StencilAttachment &stencil)
Definition: formats.cc:137
impeller::ColorAttachmentDescriptor::blending_enabled
bool blending_enabled
Definition: formats.h:496
impeller::BlendOperation::kSubtract
@ kSubtract
impeller::IndexType::kUnknown
@ kUnknown
impeller::TRect< Scalar >
impeller::BlendFactor::kOneMinusDestinationAlpha
@ kOneMinusDestinationAlpha
impeller::DepthAttachmentDescriptor::depth_compare
CompareFunction depth_compare
Definition: formats.h:571
impeller::TextureUsageIsRenderTarget
constexpr bool TextureUsageIsRenderTarget(TextureUsageMask mask)
Definition: formats.h:304
impeller::ColorAttachmentDescriptor
Describe the color attachment that will be used with this pipeline.
Definition: formats.h:494
impeller::SamplerAddressMode::kRepeat
@ kRepeat
impeller::SamplerAddressMode::kDecal
@ kDecal
decal sampling mode is only supported on devices that pass the Capabilities.SupportsDecalSamplerAddre...