Flutter Impeller
impeller::Attachment Struct Reference

#include <formats.h>

Inheritance diagram for impeller::Attachment:
impeller::ColorAttachment impeller::DepthAttachment impeller::StencilAttachment

Public Member Functions

bool IsValid () const
 

Public Attributes

std::shared_ptr< Texture > texture
 
std::shared_ptr< Texture > resolve_texture
 
LoadAction load_action = LoadAction::kDontCare
 
StoreAction store_action = StoreAction::kStore
 
uint32_t mip_level = 0
 
uint32_t slice = 0
 

Detailed Description

Definition at line 908 of file formats.h.

Member Function Documentation

◆ IsValid()

bool impeller::Attachment::IsValid ( ) const

Definition at line 26 of file formats.cc.

26  {
27  if (!texture || !texture->IsValid()) {
28  VALIDATION_LOG << "Attachment has no texture.";
29  return false;
30  }
31 
32  const TextureDescriptor& desc = texture->GetTextureDescriptor();
33  if (mip_level >= desc.mip_count) {
34  VALIDATION_LOG << "Attachment mip_level " << mip_level
35  << " is out of range; the texture has " << desc.mip_count
36  << " mip levels.";
37  return false;
38  }
39  const uint32_t slice_count = desc.type == TextureType::kTextureCube ? 6u : 1u;
40  if (slice >= slice_count) {
41  VALIDATION_LOG << "Attachment slice " << slice
42  << " is out of range for the texture type.";
43  return false;
44  }
45 
47  if (!resolve_texture || !resolve_texture->IsValid()) {
48  VALIDATION_LOG << "Store action needs resolve but no valid resolve "
49  "texture specified.";
50  return false;
51  }
52  }
53 
54  if (resolve_texture) {
57  VALIDATION_LOG << "A resolve texture was specified, but the store action "
58  "doesn't include multisample resolve.";
59  return false;
60  }
61 
62  if (texture->GetTextureDescriptor().storage_mode ==
66  << "The multisample texture cannot be transient when "
67  "specifying the StoreAndMultisampleResolve StoreAction.";
68  }
69  }
70 
71  auto storage_mode = resolve_texture
72  ? resolve_texture->GetTextureDescriptor().storage_mode
73  : texture->GetTextureDescriptor().storage_mode;
74 
75  if (storage_mode == StorageMode::kDeviceTransient) {
77  VALIDATION_LOG << "The LoadAction cannot be Load when attaching a device "
78  "transient " +
79  std::string(resolve_texture ? "resolve texture."
80  : "texture.");
81  return false;
82  }
84  VALIDATION_LOG << "The StoreAction must be DontCare when attaching a "
85  "device transient " +
86  std::string(resolve_texture ? "resolve texture."
87  : "texture.");
88  return false;
89  }
90  }
91 
92  return true;
93 }
constexpr bool StoreActionNeedsResolveTexture(StoreAction action)
Definition: formats.cc:15
uint32_t mip_level
Definition: formats.h:915
std::shared_ptr< Texture > resolve_texture
Definition: formats.h:910
LoadAction load_action
Definition: formats.h:911
std::shared_ptr< Texture > texture
Definition: formats.h:909
StoreAction store_action
Definition: formats.h:912
#define VALIDATION_LOG
Definition: validation.h:91

References impeller::kDeviceTransient, impeller::kDontCare, impeller::kLoad, impeller::kMultisampleResolve, impeller::kStoreAndMultisampleResolve, impeller::kTextureCube, load_action, impeller::TextureDescriptor::mip_count, mip_level, resolve_texture, slice, store_action, impeller::StoreActionNeedsResolveTexture(), texture, impeller::TextureDescriptor::type, and VALIDATION_LOG.

Referenced by impeller::RenderTarget::SetColorAttachment(), and impeller::testing::TEST_P().

Member Data Documentation

◆ load_action

◆ mip_level

uint32_t impeller::Attachment::mip_level = 0

Definition at line 915 of file formats.h.

Referenced by impeller::ConfigureAttachment(), IsValid(), and impeller::testing::TEST_P().

◆ resolve_texture

◆ slice

uint32_t impeller::Attachment::slice = 0

Definition at line 918 of file formats.h.

Referenced by impeller::ConfigureAttachment(), IsValid(), and impeller::testing::TEST_P().

◆ store_action

◆ texture


The documentation for this struct was generated from the following files: