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

◆ pack_gpu_components()

MAYAFLUX_API bool MayaFlux::Kakshya::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.

Each component is converted to the component type of dst. Integer destinations saturate and map NaN to zero.

Parameters
dstDestination format.
componentsSource components, in element order (column-major for MAT4_F32).
outDestination bytes, at least gpu_data_format_bytes(dst).
Returns
False, with out untouched, if the component count does not equal gpu_data_format_components(dst) or out is too small.

Definition at line 137 of file GpuDataFormat.cpp.

141{
142 if (components.size() != gpu_data_format_components(dst) || out.size() < gpu_data_format_bytes(dst)) {
143 return false;
144 }
145
146 switch (dst) {
147 case GpuDataFormat::FLOAT32:
148 case GpuDataFormat::VEC2_F32:
149 case GpuDataFormat::VEC3_F32:
150 case GpuDataFormat::VEC4_F32:
151 case GpuDataFormat::MAT4_F32:
152 store_components<float>(components, out.data());
153 return true;
154 case GpuDataFormat::FLOAT64:
155 case GpuDataFormat::VEC2_F64:
156 case GpuDataFormat::VEC3_F64:
157 case GpuDataFormat::VEC4_F64:
158 store_components<double>(components, out.data());
159 return true;
160 case GpuDataFormat::INT32:
161 store_components<int32_t>(components, out.data());
162 return true;
163 case GpuDataFormat::UINT32:
164 store_components<uint32_t>(components, out.data());
165 return true;
166 case GpuDataFormat::UINT8:
167 store_components<uint8_t>(components, out.data());
168 return true;
169 case GpuDataFormat::UINT16:
170 store_components<uint16_t>(components, out.data());
171 return true;
172 default:
173 return false;
174 }
175}
uint32_t * dst
std::vector< float > * out
size_t gpu_data_format_bytes(GpuDataFormat fmt) noexcept
Byte size of one element of a GpuDataFormat.
size_t gpu_data_format_components(GpuDataFormat fmt) noexcept
Number of scalar components in one element of a GpuDataFormat.

References dst, FLOAT32, FLOAT64, gpu_data_format_bytes(), gpu_data_format_components(), INT32, MAT4_F32, out, UINT16, UINT32, UINT8, VEC2_F32, VEC2_F64, VEC3_F32, VEC3_F64, VEC4_F32, and VEC4_F64.

Referenced by pack_gpu_value().

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