MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ emit_word_pair_map()

std::string MayaFlux::Portal::Graphics::detail::emit_word_pair_map ( const ShaderSpec & spec)
nodiscard

Emit the globals, soft-double function and entry point of the WordPairMap template.

Returns an empty string when the spec does not have the template's shape: VEC2_U32 bindings (a, b and result, or a and result for Sqrt and ToFloat32), a FLOAT32 result for ToFloat32, one UINT32 push constant and a workgroup size from 1 to 1024.

Definition at line 1208 of file AsmSoftDouble.cpp.

1209{
1210 const uint32_t local = spec.workgroup_size[0];
1211 const bool to_float = spec.word_op == WordPairOp::ToFloat32;
1212 const size_t bindings = spec.word_op == WordPairOp::Sqrt || to_float ? 2U : 3U;
1213 const auto expected = [&](size_t index) {
1214 return to_float && index + 1 == bindings ? Kakshya::GpuDataFormat::FLOAT32 : Kakshya::GpuDataFormat::VEC2_U32;
1215 };
1216 bool formats = spec.bindings.size() == bindings;
1217 for (size_t i = 0; formats && i < spec.bindings.size(); ++i) {
1218 formats = spec.bindings[i].format == expected(i);
1219 }
1220 const bool shaped = formats && spec.pc_fields.size() == 1
1221 && spec.pc_fields[0].format == Kakshya::GpuDataFormat::UINT32;
1222 const bool sized = local >= 1 && local <= 1024;
1223 if (!shaped || !sized) {
1224 return {};
1225 }
1226
1227 Builder builder;
1228 return builder.word_pair_map(spec);
1229}
@ VEC2_U32
glm::uvec2: a 64-bit value as low word (x) and high word (y), not a sampled image format
@ FLOAT32
32-bit float (standard GPU)
@ ToFloat32
float32(a) rounded to nearest even, with IEEE results for zeros, infinities, NaN, overflow and float ...
@ Sqrt
sqrt(a). Unary: no b binding.
std::vector< PushConstantField > pc_fields
std::vector< BindingSlot > bindings
WordPairOp word_op
WordPairMap only.
std::array< uint32_t, 3 > workgroup_size

References MayaFlux::Portal::Graphics::ShaderSpec::bindings, MayaFlux::Kakshya::FLOAT32, MayaFlux::Portal::Graphics::ShaderSpec::pc_fields, MayaFlux::Portal::Graphics::Sqrt, MayaFlux::Portal::Graphics::ToFloat32, MayaFlux::Kakshya::UINT32, MayaFlux::Kakshya::VEC2_U32, MayaFlux::Portal::Graphics::ShaderSpec::word_op, and MayaFlux::Portal::Graphics::ShaderSpec::workgroup_size.

Referenced by emit_spirv_asm().

Here is the caller graph for this function: