pub trait Pack {
type GLSLOutput;
type HLSLOutput;
type GLSLOutputArray;
type HLSLOutputArray;
type CPUOutput;
// Required methods
fn into_packed_glsl(self) -> Self::GLSLOutput;
fn into_packed_hlsl(self) -> Self::HLSLOutput;
fn into_packed_glsl_array(self) -> Self::GLSLOutputArray;
fn into_packed_hlsl_array(self) -> Self::HLSLOutputArray;
fn into_packed_cpu(self) -> Self::CPUOutput;
}
Expand description
Packing the underlying data of a vector or matrix
Required Associated Types§
type GLSLOutput
type HLSLOutput
type GLSLOutputArray
type HLSLOutputArray
type CPUOutput
Required Methods§
Sourcefn into_packed_glsl(self) -> Self::GLSLOutput
fn into_packed_glsl(self) -> Self::GLSLOutput
Convert the struct into packed data ready to be uploaded and consumed with hlsl standard conventions.
This will often round vectors up to alignment multiple sizes with padding bytes and is important for matrices as hlsl shaders are expecting the matrices to be row major.
§Warning
If the matrix this is implemented on is row major it will have to perform an implict transpose and so CAN CHANGE the underlying data beyond adding GPU required padding.
Sourcefn into_packed_hlsl(self) -> Self::HLSLOutput
fn into_packed_hlsl(self) -> Self::HLSLOutput
Convert the struct into packed data ready to be uploaded and consumed with hlsl standard conventions.
This will often round vectors up to alignment multiple sizes with padding bytes and is important for matrices as hlsl shaders are expecting the matrices to be row major.
§Warning
If the matrix this is implemented on is column major it will have to perform an implict transpose and so CAN CHANGE the underlying data beyond adding GPU required padding
Sourcefn into_packed_glsl_array(self) -> Self::GLSLOutputArray
fn into_packed_glsl_array(self) -> Self::GLSLOutputArray
Convert the struct into packed data ready to be uploaded and consumed with hlsl standard conventions.
This function produces a semantically similar result to into_packed_hlsl
but differs in
that for some GPU packing conventions (read: std430) the padding for an item, like a vec3,
differs whether it is on it’s own or if it is an array element.
This will often round vectors up to alignment multiple sizes with padding bytes and is important for matrices as hlsl shaders are expecting the matrices to be row major.
§Warning
If the matrix this is implemented on is row major it will have to perform an implict transpose and so CAN CHANGE the underlying data beyond adding GPU required padding.
Sourcefn into_packed_hlsl_array(self) -> Self::HLSLOutputArray
fn into_packed_hlsl_array(self) -> Self::HLSLOutputArray
Convert the struct into packed data ready to be uploaded and consumed with hlsl standard conventions.
This function produces a semantically similar result to into_packed_hlsl
but differs in
that for some GPU packing conventions (read: std430) the padding for an item, like a vec3,
differs whether it is on it’s own or if it is an array element.
This will often round vectors up to alignment multiple sizes with padding bytes and is important for matrices as hlsl shaders are expecting the matrices to be row major.
§Warning
If the matrix this is implemented on is column major it will have to perform an implict transpose and so CAN CHANGE the underlying data beyond adding GPU required padding.
Sourcefn into_packed_cpu(self) -> Self::CPUOutput
fn into_packed_cpu(self) -> Self::CPUOutput
Convert the struct into packed data for general purpose use on the CPU. This would be ideal for things like serialization where you don’t need to conform to special GPU alignment and padding rules.
This should, by general convention, just produce a flat array of the individual components and should match the underlying number of components (3 for a Vec3, etc).
§Warning
There should be no padding in the results of this function.