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

◆ pack_gpu_value()

template<GpuFormatElement T>
bool MayaFlux::Kakshya::pack_gpu_value ( GpuDataFormat  dst,
const T &  value,
std::span< std::byte >  out 
)
noexcept

Writes a typed value into out as one element of dst.

The value's component count must equal that of dst, so a glm::vec3 packs into VEC3_F32 or VEC3_F64 but not into FLOAT32.

Parameters
dstDestination format.
valueSource value.
outDestination bytes, at least gpu_data_format_bytes(dst).
Returns
False if the component counts differ or out is too small.

Definition at line 249 of file GpuDataFormat.hpp.

253{
254 using V = std::remove_cvref_t<T>;
255
256 std::array<double, 16> components {};
257 size_t count = 0;
258
259 if constexpr (ArithmeticData<V>) {
260 components[count++] = static_cast<double>(value);
261 } else if constexpr (GlmMatrixType<V>) {
262 for (int c = 0; c < 4; ++c) {
263 for (int r = 0; r < 4; ++r) {
264 components[count++] = static_cast<double>(value[c][r]);
265 }
266 }
267 } else {
268 for (int i = 0; i < static_cast<int>(glm_component_count<V>()); ++i) {
269 components[count++] = static_cast<double>(value[i]);
270 }
271 }
272
273 return pack_gpu_components(dst, std::span<const double>(components.data(), count), out);
274}
uint32_t * dst
std::vector< float > * out
glm::vec3 value
size_t count
bool pack_gpu_components(GpuDataFormat dst, std::span< const double > components, std::span< std::byte > out) noexcept
Writes scalar components into out as one element of dst.

References count, dst, out, pack_gpu_components(), and value.

Referenced by MayaFlux::Buffers::FormaBindingsProcessor::flush_push_constant().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: