83MAYAFLUX_API GpuBlockLayout
gpu_block_layout(std::span<const GpuDataFormat> fields);
169 { gpu_data_format_of<std::remove_cvref_t<T>>
::value } -> std::convertible_to<GpuDataFormat>;
175template <GpuFormatElement T>
185 float, glm::vec2, glm::vec3, glm::vec4,
186 double, glm::dvec2, glm::dvec3, glm::dvec4,
193 template <
size_t... I>
234 std::span<const double> components,
235 std::span<std::byte>
out)
noexcept;
248template <GpuFormatElement T>
252 std::span<std::byte>
out)
noexcept
254 using V = std::remove_cvref_t<T>;
256 std::array<double, 16> components {};
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]);
268 for (
int i = 0; i < static_cast<int>(glm_component_count<V>()); ++i) {
269 components[
count++] =
static_cast<double>(
value[i]);
std::vector< float > * out
constexpr bool gpu_value_follows_format_order(std::index_sequence< I... >)
std::variant< float, glm::vec2, glm::vec3, glm::vec4, double, glm::dvec2, glm::dvec3, glm::dvec4, int32_t, uint32_t, uint8_t, uint16_t, glm::mat4 > GpuValue
One value of any GpuDataFormat.
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.
size_t gpu_data_format_bytes(GpuDataFormat fmt) noexcept
Byte size of one element of a GpuDataFormat.
size_t gpu_data_format_align(GpuDataFormat fmt) noexcept
Base alignment in bytes of one element, following std430 rules.
size_t gpu_data_format_components(GpuDataFormat fmt) noexcept
Number of scalar components in one element of a GpuDataFormat.
GpuBlockLayout gpu_block_layout(std::span< const GpuDataFormat > fields)
Lay out fields in declaration order under std430 rules.
GpuDataFormat gpu_value_format(const GpuValue &value) noexcept
The GpuDataFormat of the value held.
size_t gpu_value_write(const GpuValue &value, std::span< std::byte > out) noexcept
Copies the held value's bytes into out, unconverted.
constexpr GpuDataFormat gpu_data_format_v
The GpuDataFormat of a GpuFormatElement type.
bool 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.
GpuDataFormat
GPU data formats with explicit precision levels.
@ VEC3_F64
glm::dvec3 (64-bit components)
@ FLOAT64
64-bit double (audio precision)
@ UINT16
uint16_t, R16F raw half-float storage, packed formats
@ VEC2_F64
glm::dvec2 (64-bit components)
@ VEC2_F32
glm::vec2 (32-bit components)
@ VEC4_F32
glm::vec4 (32-bit components)
@ VEC4_F64
glm::dvec4 (64-bit components)
@ FLOAT32
32-bit float (standard GPU)
@ MAT4_F32
glm::mat4 (column-major), not a sampled image format
@ VEC3_F32
glm::vec3 (32-bit components), not a sampled image format
@ UINT8
uint8_t, R8 / RGBA8 texel data
std::vector< uint32_t > offsets
Member offsets and total size of a block of GpuDataFormat fields.