85 : payload_(payload) {
87
89 entrypoint_ = runtime_stage->entrypoint()->str();
90
91 auto* uniforms = runtime_stage->uniforms();
92
93
94
95
96
97 std::optional<size_t> ubo_id;
98 if (uniforms) {
99 for (
auto i = uniforms->begin(), end = uniforms->end();
i != end;
i++) {
100 RuntimeUniformDescription
desc;
101 desc.name =
i->name()->str();
102 desc.location =
i->location();
103 desc.binding =
i->binding();
106 ubo_id =
desc.location;
108 }
109 desc.dimensions = RuntimeUniformDimensions{
110 static_cast<size_t>(
i->rows()),
static_cast<size_t>(
i->columns())};
111 desc.bit_width =
i->bit_width();
112 desc.array_elements =
i->array_elements();
113 if (
i->struct_layout()) {
114 for (
const auto& byte_type : *
i->struct_layout()) {
115 desc.struct_layout.push_back(
static_cast<uint8_t
>(byte_type));
116 }
117 }
118 desc.struct_float_count =
i->struct_float_count();
119 uniforms_.push_back(std::move(
desc));
120 }
121 }
122
123 code_mapping_ = std::make_shared<fml::NonOwnedMapping>(
124 runtime_stage->shader()->data(),
125 runtime_stage->shader()->size(),
126 [payload = payload_](auto, auto) {}
127 );
128
129 size_t binding = 64;
130 if (ubo_id.has_value() && ubo_id.value() == binding) {
131 binding++;
132 }
133 for (auto& uniform : uniforms_) {
135 uniform.binding = binding;
136 binding++;
137 if (ubo_id.has_value() && ubo_id.value() == binding) {
138 binding++;
139 }
140 }
141 }
142
145 descriptor_set_layouts_.push_back(DescriptorSetLayout{
146 static_cast<uint32_t>(uniform.location),
149 });
151 descriptor_set_layouts_.push_back(DescriptorSetLayout{
152 static_cast<uint32_t>(uniform.binding),
155 });
156 }
157 }
158 is_valid_ = true;
159}
const std::vector< RuntimeUniformDescription > & GetUniforms() const
#define FML_DCHECK(condition)
constexpr ShaderStage ToShaderStage(RuntimeShaderStage stage)
static RuntimeUniformType ToType(fb::UniformDataType type)