| Flutter Impeller |

runtime_types.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_RUNTIME_TYPES_H_
6 #define FLUTTER_IMPELLER_CORE_RUNTIME_TYPES_H_
7
8 #include <cstddef>
9 #include <cstdint>
10 #include <optional>
11 #include <string>
12 #include <vector>
13
14 namespace impeller {
15
16 enum class RuntimeStageBackend {
17 kSkSL,
18 kMetal,
19 kOpenGLES,
20 kOpenGLES3,
21 kVulkan,
22 };
23
24 enum RuntimeUniformType {
25 kFloat,
26 kSampledImage,
27 kStruct,
28 };
29
30 enum class RuntimeShaderStage {
31 kVertex,
32 kFragment,
33 kCompute,
34 };
35
36 struct RuntimeUniformDimensions {
37 size_t rows = 0;
38 size_t cols = 0;
39 };
40
41 enum class RuntimePaddingType : uint8_t {
42 kPadding = 0,
43 kFloat = 1,
44 };
45
46 struct StructField {
47 std::string name;
48 // The size in bytes of this field, not including padding.
49 size_t byte_size;
50 };
51
52 struct RuntimeUniformDescription {
53 std::string name;
54 size_t location = 0u;
55 /// Location, but for Vulkan.
56 size_t binding = 0u;
57 RuntimeUniformType type = RuntimeUniformType::kFloat;
58 RuntimeUniformDimensions dimensions = {};
59 size_t bit_width = 0u;
60 std::optional<size_t> array_elements;
61 std::vector<RuntimePaddingType> padding_layout = {};
62 // The fields of the struct. Necessary on Vulkan, where everything is
63 // packed into a struct.
64 std::vector<StructField> struct_fields = {};
65 size_t struct_float_count = 0u;
66
67 /// @brief Computes the total number of bytes that this uniform requires for
68 /// representation in the Dart float buffer.
69 size_t GetDartSize() const;
70
71 /// @brief Computes the total number of bytes that this uniform requires for
72 /// representation in the GPU.
73 size_t GetGPUSize() const;
74 };
75
76 } // namespace impeller
77
78 #endif // FLUTTER_IMPELLER_CORE_RUNTIME_TYPES_H_
impeller
Definition: allocation.cc:12
impeller::RuntimeShaderStage
RuntimeShaderStage
Definition: runtime_types.h:30
impeller::RuntimeShaderStage::kCompute
@ kCompute
impeller::RuntimeShaderStage::kFragment
@ kFragment
impeller::RuntimeShaderStage::kVertex
@ kVertex
impeller::RuntimePaddingType
RuntimePaddingType
Definition: runtime_types.h:41
impeller::RuntimePaddingType::kPadding
@ kPadding
impeller::RuntimePaddingType::kFloat
@ kFloat
impeller::RuntimeStageBackend
RuntimeStageBackend
Definition: runtime_types.h:16
impeller::RuntimeStageBackend::kOpenGLES
@ kOpenGLES
impeller::RuntimeStageBackend::kMetal
@ kMetal
impeller::RuntimeStageBackend::kVulkan
@ kVulkan
impeller::RuntimeStageBackend::kSkSL
@ kSkSL
impeller::RuntimeStageBackend::kOpenGLES3
@ kOpenGLES3
impeller::RuntimeUniformType
RuntimeUniformType
Definition: runtime_types.h:24
impeller::kSampledImage
@ kSampledImage
Definition: runtime_types.h:26
impeller::kFloat
@ kFloat
Definition: runtime_types.h:25
impeller::kStruct
@ kStruct
Definition: runtime_types.h:27
impeller::RuntimeUniformDescription
Definition: runtime_types.h:52
impeller::RuntimeUniformDescription::GetGPUSize
size_t GetGPUSize() const
Computes the total number of bytes that this uniform requires for representation in the GPU.
Definition: runtime_types.cc:28
impeller::RuntimeUniformDescription::dimensions
RuntimeUniformDimensions dimensions
Definition: runtime_types.h:58
impeller::RuntimeUniformDescription::location
size_t location
Definition: runtime_types.h:54
impeller::RuntimeUniformDescription::GetDartSize
size_t GetDartSize() const
Computes the total number of bytes that this uniform requires for representation in the Dart float bu...
Definition: runtime_types.cc:9
impeller::RuntimeUniformDescription::struct_fields
std::vector< StructField > struct_fields
Definition: runtime_types.h:64
impeller::RuntimeUniformDescription::padding_layout
std::vector< RuntimePaddingType > padding_layout
Definition: runtime_types.h:61
impeller::RuntimeUniformDescription::name
std::string name
Definition: runtime_types.h:53
impeller::RuntimeUniformDescription::type
RuntimeUniformType type
Definition: runtime_types.h:57
impeller::RuntimeUniformDescription::struct_float_count
size_t struct_float_count
Definition: runtime_types.h:65
impeller::RuntimeUniformDescription::array_elements
std::optional< size_t > array_elements
Definition: runtime_types.h:60
impeller::RuntimeUniformDescription::bit_width
size_t bit_width
Definition: runtime_types.h:59
impeller::RuntimeUniformDescription::binding
size_t binding
Location, but for Vulkan.
Definition: runtime_types.h:56
impeller::RuntimeUniformDimensions
Definition: runtime_types.h:36
impeller::RuntimeUniformDimensions::cols
size_t cols
Definition: runtime_types.h:38
impeller::RuntimeUniformDimensions::rows
size_t rows
Definition: runtime_types.h:37
impeller::StructField
Definition: runtime_types.h:46
impeller::StructField::name
std::string name
Definition: runtime_types.h:47
impeller::StructField::byte_size
size_t byte_size
Definition: runtime_types.h:49