Flutter Impeller
impeller::compiler::StructMember Struct Reference

#include <reflector.h>

Public Types

enum class  UnderlyingType {
  kPadding ,
  kFloat ,
  kOther
}
 

Public Member Functions

 StructMember (std::string p_type, spirv_cross::SPIRType::BaseType p_base_type, std::string p_name, size_t p_offset, size_t p_size, size_t p_byte_length, std::optional< size_t > p_array_elements, size_t p_element_padding, std::optional< std::string > p_float_type=std::nullopt, UnderlyingType p_underlying_type=UnderlyingType::kOther)
 Constructs a new StructMember. More...
 

Static Public Member Functions

static std::string BaseTypeToString (spirv_cross::SPIRType::BaseType type)
 
static UnderlyingType DetermineUnderlyingType (spirv_cross::SPIRType::BaseType type)
 

Public Attributes

std::string type
 
spirv_cross::SPIRType::BaseType base_type
 
std::string name
 
size_t offset = 0u
 
size_t size = 0u
 
size_t byte_length = 0u
 
std::optional< size_t > array_elements = std::nullopt
 
size_t element_padding = 0u
 
std::optional< std::string > float_type = std::nullopt
 
UnderlyingType underlying_type = UnderlyingType::kOther
 

Detailed Description

Definition at line 25 of file reflector.h.

Member Enumeration Documentation

◆ UnderlyingType

Enumerator
kPadding 
kFloat 
kOther 

Definition at line 28 of file reflector.h.

28  {
29  kPadding,
30  kFloat,
31  kOther,
32  };
constexpr auto kPadding

Constructor & Destructor Documentation

◆ StructMember()

impeller::compiler::StructMember::StructMember ( std::string  p_type,
spirv_cross::SPIRType::BaseType  p_base_type,
std::string  p_name,
size_t  p_offset,
size_t  p_size,
size_t  p_byte_length,
std::optional< size_t >  p_array_elements,
size_t  p_element_padding,
std::optional< std::string >  p_float_type = std::nullopt,
UnderlyingType  p_underlying_type = UnderlyingType::kOther 
)
inline

Constructs a new StructMember.

Parameters
p_typeThe string type name (e.g. "float", "Point", "Matrix").
p_base_typeThe SPIR-V base type.
p_nameThe name of the struct member.
p_offsetThe offset in bytes from the start of the parent struct.
p_sizeThe size in bytes of a single element of this type (ignoring padding/stride).
p_byte_lengthThe total size in bytes this member occupies in the struct, including all array elements and padding.
p_array_elementsThe number of array elements. For matrices treated as arrays of columns, this includes the column count.
p_element_paddingThe padding in bytes after each array element to satisfy alignment requirements (stride - size).
p_float_typeThe float type of the member.
p_underlying_typeThe underlying type category, used for runtime validation.

Definition at line 142 of file reflector.h.

152  : type(std::move(p_type)),
153  base_type(p_base_type),
154  name(std::move(p_name)),
155  offset(p_offset),
156  size(p_size),
157  byte_length(p_byte_length),
158  array_elements(p_array_elements),
159  element_padding(p_element_padding),
160  float_type(std::move(p_float_type)),
UnderlyingType underlying_type
Definition: reflector.h:43
std::optional< size_t > array_elements
Definition: reflector.h:40
std::optional< std::string > float_type
Definition: reflector.h:42
static UnderlyingType DetermineUnderlyingType(spirv_cross::SPIRType::BaseType type)
Definition: reflector.h:90
spirv_cross::SPIRType::BaseType base_type
Definition: reflector.h:35

Member Function Documentation

◆ BaseTypeToString()

static std::string impeller::compiler::StructMember::BaseTypeToString ( spirv_cross::SPIRType::BaseType  type)
inlinestatic

Definition at line 45 of file reflector.h.

45  {
46  using Type = spirv_cross::SPIRType::BaseType;
47  switch (type) {
48  case Type::Void:
49  return "ShaderType::kVoid";
50  case Type::Boolean:
51  return "ShaderType::kBoolean";
52  case Type::SByte:
53  return "ShaderType::kSignedByte";
54  case Type::UByte:
55  return "ShaderType::kUnsignedByte";
56  case Type::Short:
57  return "ShaderType::kSignedShort";
58  case Type::UShort:
59  return "ShaderType::kUnsignedShort";
60  case Type::Int:
61  return "ShaderType::kSignedInt";
62  case Type::UInt:
63  return "ShaderType::kUnsignedInt";
64  case Type::Int64:
65  return "ShaderType::kSignedInt64";
66  case Type::UInt64:
67  return "ShaderType::kUnsignedInt64";
68  case Type::AtomicCounter:
69  return "ShaderType::kAtomicCounter";
70  case Type::Half:
71  return "ShaderType::kHalfFloat";
72  case Type::Float:
73  return "ShaderType::kFloat";
74  case Type::Double:
75  return "ShaderType::kDouble";
76  case Type::Struct:
77  return "ShaderType::kStruct";
78  case Type::Image:
79  return "ShaderType::kImage";
80  case Type::SampledImage:
81  return "ShaderType::kSampledImage";
82  case Type::Sampler:
83  return "ShaderType::kSampler";
84  default:
85  return "ShaderType::kUnknown";
86  }
87  FML_UNREACHABLE();
88  }

References type.

◆ DetermineUnderlyingType()

static UnderlyingType impeller::compiler::StructMember::DetermineUnderlyingType ( spirv_cross::SPIRType::BaseType  type)
inlinestatic

Definition at line 90 of file reflector.h.

91  {
92  switch (type) {
93  case spirv_cross::SPIRType::Void:
95  case spirv_cross::SPIRType::Float:
97  case spirv_cross::SPIRType::Unknown:
98  case spirv_cross::SPIRType::Boolean:
99  case spirv_cross::SPIRType::SByte:
100  case spirv_cross::SPIRType::UByte:
101  case spirv_cross::SPIRType::Short:
102  case spirv_cross::SPIRType::UShort:
103  case spirv_cross::SPIRType::Int:
104  case spirv_cross::SPIRType::UInt:
105  case spirv_cross::SPIRType::Int64:
106  case spirv_cross::SPIRType::UInt64:
107  case spirv_cross::SPIRType::AtomicCounter:
108  case spirv_cross::SPIRType::Half:
109  case spirv_cross::SPIRType::Double:
110  case spirv_cross::SPIRType::Struct:
111  case spirv_cross::SPIRType::Image:
112  case spirv_cross::SPIRType::SampledImage:
113  case spirv_cross::SPIRType::Sampler:
114  case spirv_cross::SPIRType::AccelerationStructure:
115  case spirv_cross::SPIRType::RayQuery:
116  case spirv_cross::SPIRType::ControlPointArray:
117  case spirv_cross::SPIRType::Interpolant:
118  case spirv_cross::SPIRType::Char:
119  default:
120  return UnderlyingType::kOther;
121  }
122  FML_UNREACHABLE();
123  }

References kFloat, kOther, kPadding, and type.

Member Data Documentation

◆ array_elements

std::optional<size_t> impeller::compiler::StructMember::array_elements = std::nullopt

Definition at line 40 of file reflector.h.

◆ base_type

spirv_cross::SPIRType::BaseType impeller::compiler::StructMember::base_type

Definition at line 35 of file reflector.h.

◆ byte_length

size_t impeller::compiler::StructMember::byte_length = 0u

Definition at line 39 of file reflector.h.

◆ element_padding

size_t impeller::compiler::StructMember::element_padding = 0u

Definition at line 41 of file reflector.h.

◆ float_type

std::optional<std::string> impeller::compiler::StructMember::float_type = std::nullopt

Definition at line 42 of file reflector.h.

◆ name

std::string impeller::compiler::StructMember::name

Definition at line 36 of file reflector.h.

◆ offset

size_t impeller::compiler::StructMember::offset = 0u

Definition at line 37 of file reflector.h.

◆ size

size_t impeller::compiler::StructMember::size = 0u

Definition at line 38 of file reflector.h.

◆ type

std::string impeller::compiler::StructMember::type

Definition at line 34 of file reflector.h.

Referenced by BaseTypeToString(), and DetermineUnderlyingType().

◆ underlying_type

UnderlyingType impeller::compiler::StructMember::underlying_type = UnderlyingType::kOther

Definition at line 43 of file reflector.h.


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