2023-01-15 19:06:09 +11:00
|
|
|
use crate::uniforms::{BindUniform, NoUniformBinder, UniformStorage};
|
2023-01-15 19:01:23 +11:00
|
|
|
use librashader_common::Size;
|
|
|
|
use librashader_preprocess::ShaderParameter;
|
2023-01-15 19:06:09 +11:00
|
|
|
use librashader_reflect::reflect::semantics::{
|
2023-02-06 08:17:14 +11:00
|
|
|
BindingMeta, MemberOffset, Semantic, TextureBinding, TextureSemantics, UniformBinding,
|
|
|
|
UniformMeta, UniqueSemantics,
|
2023-01-15 19:06:09 +11:00
|
|
|
};
|
2023-02-06 08:17:14 +11:00
|
|
|
use rustc_hash::FxHashMap;
|
2023-01-15 19:06:09 +11:00
|
|
|
use std::collections::HashMap;
|
|
|
|
use std::hash::BuildHasher;
|
2023-01-16 16:16:31 +11:00
|
|
|
use std::ops::{Deref, DerefMut};
|
2023-01-15 19:01:23 +11:00
|
|
|
|
|
|
|
/// Trait for input textures used during uniform binding,
|
|
|
|
pub trait TextureInput {
|
|
|
|
/// Gets the size of this input texture.
|
|
|
|
fn size(&self) -> Size<u32>;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// A uniform member offset with context that needs to be resolved.
|
|
|
|
pub trait ContextOffset<H, C>
|
2023-01-15 19:06:09 +11:00
|
|
|
where
|
|
|
|
H: BindUniform<C, f32>,
|
|
|
|
H: BindUniform<C, u32>,
|
|
|
|
H: BindUniform<C, i32>,
|
|
|
|
H: for<'a> BindUniform<C, &'a [f32; 4]>,
|
|
|
|
H: for<'a> BindUniform<C, &'a [f32; 16]>,
|
2023-01-15 19:01:23 +11:00
|
|
|
{
|
|
|
|
/// Gets the `MemberOffset` part of the offset.
|
|
|
|
fn offset(&self) -> MemberOffset;
|
|
|
|
|
|
|
|
/// Gets the context part of the offset.
|
|
|
|
fn context(&self) -> C;
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<H> ContextOffset<H, Option<()>> for MemberOffset
|
2023-01-15 19:06:09 +11:00
|
|
|
where
|
|
|
|
H: BindUniform<Option<()>, f32>,
|
|
|
|
H: BindUniform<Option<()>, u32>,
|
|
|
|
H: BindUniform<Option<()>, i32>,
|
|
|
|
H: for<'a> BindUniform<Option<()>, &'a [f32; 4]>,
|
|
|
|
H: for<'a> BindUniform<Option<()>, &'a [f32; 16]>,
|
2023-01-15 19:01:23 +11:00
|
|
|
{
|
|
|
|
fn offset(&self) -> MemberOffset {
|
|
|
|
*self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn context(&self) -> Option<()> {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-12 17:56:39 +11:00
|
|
|
/// Inputs to binding semantics
|
|
|
|
pub struct UniformInputs<'a> {
|
|
|
|
/// MVP
|
|
|
|
pub mvp: &'a [f32; 16],
|
|
|
|
/// FrameCount
|
|
|
|
pub frame_count: u32,
|
|
|
|
/// Rotation
|
|
|
|
pub rotation: u32,
|
|
|
|
/// TotalSubFrames
|
|
|
|
pub total_subframes: u32,
|
|
|
|
/// CurrentSubFrame
|
|
|
|
pub current_subframe: u32,
|
|
|
|
/// FrameDirection
|
|
|
|
pub frame_direction: i32,
|
|
|
|
/// OutputSize
|
|
|
|
pub framebuffer_size: Size<u32>,
|
|
|
|
/// FinalViewportSize
|
|
|
|
pub viewport_size: Size<u32>,
|
|
|
|
}
|
|
|
|
|
2023-01-15 19:01:23 +11:00
|
|
|
/// Trait that abstracts binding of semantics to shader uniforms.
|
2023-02-06 14:24:58 +11:00
|
|
|
pub trait BindSemantics<H = NoUniformBinder, C = Option<()>, U = Box<[u8]>, P = Box<[u8]>>
|
2023-01-15 19:06:09 +11:00
|
|
|
where
|
2023-01-29 17:57:09 +11:00
|
|
|
C: Copy,
|
2023-02-06 14:24:58 +11:00
|
|
|
U: Deref<Target = [u8]> + DerefMut,
|
|
|
|
P: Deref<Target = [u8]> + DerefMut,
|
2023-01-15 19:06:09 +11:00
|
|
|
H: BindUniform<C, f32>,
|
|
|
|
H: BindUniform<C, u32>,
|
|
|
|
H: BindUniform<C, i32>,
|
|
|
|
H: for<'b> BindUniform<C, &'b [f32; 4]>,
|
|
|
|
H: for<'b> BindUniform<C, &'b [f32; 16]>,
|
2023-01-15 19:01:23 +11:00
|
|
|
{
|
|
|
|
/// The type of the input texture used for semantic binding.
|
|
|
|
type InputTexture: TextureInput;
|
|
|
|
|
|
|
|
/// The set of texture samplers available.
|
|
|
|
type SamplerSet;
|
|
|
|
|
|
|
|
/// The descriptor set or object that holds sampler and texture bindings.
|
|
|
|
type DescriptorSet<'a>;
|
|
|
|
|
|
|
|
/// The device context containing the state of the graphics processor.
|
|
|
|
type DeviceContext;
|
|
|
|
|
|
|
|
/// The type of uniform offsets to use.
|
|
|
|
type UniformOffset: ContextOffset<H, C>;
|
|
|
|
|
|
|
|
/// Bind a texture to the input descriptor set
|
|
|
|
fn bind_texture<'a>(
|
|
|
|
descriptors: &mut Self::DescriptorSet<'a>,
|
|
|
|
samplers: &Self::SamplerSet,
|
|
|
|
binding: &TextureBinding,
|
|
|
|
texture: &Self::InputTexture,
|
2023-01-15 19:06:09 +11:00
|
|
|
device: &Self::DeviceContext,
|
2023-01-15 19:01:23 +11:00
|
|
|
);
|
|
|
|
|
2023-01-16 03:08:13 +11:00
|
|
|
#[allow(clippy::too_many_arguments)]
|
2023-01-15 19:01:23 +11:00
|
|
|
/// Write uniform and texture semantics to the provided storages.
|
|
|
|
fn bind_semantics<'a>(
|
|
|
|
device: &Self::DeviceContext,
|
|
|
|
sampler_set: &Self::SamplerSet,
|
2023-02-06 14:24:58 +11:00
|
|
|
uniform_storage: &mut UniformStorage<H, C, U, P>,
|
2023-01-15 19:01:23 +11:00
|
|
|
descriptor_set: &mut Self::DescriptorSet<'a>,
|
2024-02-12 17:56:39 +11:00
|
|
|
uniform_inputs: UniformInputs<'_>,
|
2023-01-15 19:01:23 +11:00
|
|
|
original: &Self::InputTexture,
|
|
|
|
source: &Self::InputTexture,
|
|
|
|
uniform_bindings: &HashMap<UniformBinding, Self::UniformOffset, impl BuildHasher>,
|
|
|
|
texture_meta: &HashMap<Semantic<TextureSemantics>, TextureBinding, impl BuildHasher>,
|
|
|
|
pass_outputs: impl Iterator<Item = Option<impl AsRef<Self::InputTexture>>>,
|
|
|
|
pass_feedback: impl Iterator<Item = Option<impl AsRef<Self::InputTexture>>>,
|
|
|
|
original_history: impl Iterator<Item = Option<impl AsRef<Self::InputTexture>>>,
|
|
|
|
lookup_textures: impl Iterator<Item = (usize, impl AsRef<Self::InputTexture>)>,
|
2023-01-16 06:06:38 +11:00
|
|
|
parameter_defaults: &HashMap<String, ShaderParameter, impl BuildHasher>,
|
2023-01-15 19:01:23 +11:00
|
|
|
runtime_parameters: &HashMap<String, f32, impl BuildHasher>,
|
2023-01-15 19:06:09 +11:00
|
|
|
) {
|
2023-01-15 19:01:23 +11:00
|
|
|
// Bind MVP
|
|
|
|
if let Some(offset) = uniform_bindings.get(&UniqueSemantics::MVP.into()) {
|
2024-02-12 17:56:39 +11:00
|
|
|
uniform_storage.bind_mat4(offset.offset(), uniform_inputs.mvp, offset.context());
|
2023-01-15 19:01:23 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
// Bind OutputSize
|
|
|
|
if let Some(offset) = uniform_bindings.get(&UniqueSemantics::Output.into()) {
|
2024-02-12 17:56:39 +11:00
|
|
|
uniform_storage.bind_vec4(
|
|
|
|
offset.offset(),
|
|
|
|
uniform_inputs.framebuffer_size,
|
|
|
|
offset.context(),
|
|
|
|
);
|
2023-01-15 19:01:23 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
// bind FinalViewportSize
|
2023-01-15 19:06:09 +11:00
|
|
|
if let Some(offset) = uniform_bindings.get(&UniqueSemantics::FinalViewport.into()) {
|
2024-02-12 17:56:39 +11:00
|
|
|
uniform_storage.bind_vec4(
|
|
|
|
offset.offset(),
|
|
|
|
uniform_inputs.viewport_size,
|
|
|
|
offset.context(),
|
|
|
|
);
|
2023-01-15 19:01:23 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
// bind FrameCount
|
2023-01-15 19:06:09 +11:00
|
|
|
if let Some(offset) = uniform_bindings.get(&UniqueSemantics::FrameCount.into()) {
|
2024-02-12 17:56:39 +11:00
|
|
|
uniform_storage.bind_scalar(
|
|
|
|
offset.offset(),
|
|
|
|
uniform_inputs.frame_count,
|
|
|
|
offset.context(),
|
|
|
|
);
|
2023-01-15 19:01:23 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
// bind FrameDirection
|
2023-01-15 19:06:09 +11:00
|
|
|
if let Some(offset) = uniform_bindings.get(&UniqueSemantics::FrameDirection.into()) {
|
2024-02-12 17:56:39 +11:00
|
|
|
uniform_storage.bind_scalar(
|
|
|
|
offset.offset(),
|
|
|
|
uniform_inputs.frame_direction,
|
|
|
|
offset.context(),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
// bind Rotation
|
|
|
|
if let Some(offset) = uniform_bindings.get(&UniqueSemantics::Rotation.into()) {
|
|
|
|
uniform_storage.bind_scalar(offset.offset(), uniform_inputs.rotation, offset.context());
|
|
|
|
}
|
|
|
|
|
|
|
|
// bind TotalSubFrames
|
|
|
|
if let Some(offset) = uniform_bindings.get(&UniqueSemantics::TotalSubFrames.into()) {
|
|
|
|
uniform_storage.bind_scalar(
|
|
|
|
offset.offset(),
|
|
|
|
uniform_inputs.total_subframes,
|
|
|
|
offset.context(),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
// bind CurrentSubFrames
|
|
|
|
if let Some(offset) = uniform_bindings.get(&UniqueSemantics::CurrentSubFrame.into()) {
|
|
|
|
uniform_storage.bind_scalar(
|
|
|
|
offset.offset(),
|
|
|
|
uniform_inputs.current_subframe,
|
|
|
|
offset.context(),
|
|
|
|
);
|
2023-01-15 19:01:23 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
// bind Original sampler
|
2023-01-15 19:06:09 +11:00
|
|
|
if let Some(binding) = texture_meta.get(&TextureSemantics::Original.semantics(0)) {
|
|
|
|
Self::bind_texture(descriptor_set, sampler_set, binding, original, device);
|
2023-01-15 19:01:23 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
// bind OriginalSize
|
2023-01-15 19:06:09 +11:00
|
|
|
if let Some(offset) = uniform_bindings.get(&TextureSemantics::Original.semantics(0).into())
|
2023-01-15 19:01:23 +11:00
|
|
|
{
|
2023-01-15 19:06:09 +11:00
|
|
|
uniform_storage.bind_vec4(offset.offset(), original.size(), offset.context());
|
2023-01-15 19:01:23 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
// bind Source sampler
|
2023-01-15 19:06:09 +11:00
|
|
|
if let Some(binding) = texture_meta.get(&TextureSemantics::Source.semantics(0)) {
|
|
|
|
Self::bind_texture(descriptor_set, sampler_set, binding, source, device);
|
2023-01-15 19:01:23 +11:00
|
|
|
}
|
|
|
|
|
2024-02-12 17:56:39 +11:00
|
|
|
// bind SourceSize
|
2023-01-15 19:06:09 +11:00
|
|
|
if let Some(offset) = uniform_bindings.get(&TextureSemantics::Source.semantics(0).into()) {
|
|
|
|
uniform_storage.bind_vec4(offset.offset(), source.size(), offset.context());
|
2023-01-15 19:01:23 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
// OriginalHistory0 aliases OriginalHistory
|
|
|
|
|
|
|
|
// bind OriginalHistory0 sampler
|
2023-01-15 19:06:09 +11:00
|
|
|
if let Some(binding) = texture_meta.get(&TextureSemantics::OriginalHistory.semantics(0)) {
|
|
|
|
Self::bind_texture(descriptor_set, sampler_set, binding, original, device);
|
2023-01-15 19:01:23 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
// bind OriginalHistory0Size
|
2023-01-15 19:06:09 +11:00
|
|
|
if let Some(offset) =
|
|
|
|
uniform_bindings.get(&TextureSemantics::OriginalHistory.semantics(0).into())
|
2023-01-15 19:01:23 +11:00
|
|
|
{
|
2023-01-15 19:06:09 +11:00
|
|
|
uniform_storage.bind_vec4(offset.offset(), original.size(), offset.context());
|
2023-01-15 19:01:23 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
// bind OriginalHistory1-..
|
|
|
|
for (index, history) in original_history.enumerate() {
|
|
|
|
let Some(history) = history else {
|
|
|
|
continue;
|
|
|
|
};
|
|
|
|
|
|
|
|
let history = history.as_ref();
|
|
|
|
|
2023-01-15 19:06:09 +11:00
|
|
|
if let Some(binding) =
|
|
|
|
texture_meta.get(&TextureSemantics::OriginalHistory.semantics(index + 1))
|
2023-01-15 19:01:23 +11:00
|
|
|
{
|
2023-01-15 19:06:09 +11:00
|
|
|
Self::bind_texture(descriptor_set, sampler_set, binding, history, device);
|
2023-01-15 19:01:23 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
if let Some(offset) = uniform_bindings.get(
|
|
|
|
&TextureSemantics::OriginalHistory
|
|
|
|
.semantics(index + 1)
|
|
|
|
.into(),
|
|
|
|
) {
|
2023-01-15 19:06:09 +11:00
|
|
|
uniform_storage.bind_vec4(offset.offset(), history.size(), offset.context());
|
2023-01-15 19:01:23 +11:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// bind PassOutput0..
|
|
|
|
// The caller should be responsible for limiting this up to
|
|
|
|
// pass_index
|
|
|
|
for (index, output) in pass_outputs.enumerate() {
|
|
|
|
let Some(output) = output else {
|
|
|
|
continue;
|
|
|
|
};
|
|
|
|
|
|
|
|
let output = output.as_ref();
|
|
|
|
|
2023-01-15 19:06:09 +11:00
|
|
|
if let Some(binding) = texture_meta.get(&TextureSemantics::PassOutput.semantics(index))
|
2023-01-15 19:01:23 +11:00
|
|
|
{
|
2023-01-15 19:06:09 +11:00
|
|
|
Self::bind_texture(descriptor_set, sampler_set, binding, output, device);
|
2023-01-15 19:01:23 +11:00
|
|
|
}
|
|
|
|
|
2023-01-15 19:06:09 +11:00
|
|
|
if let Some(offset) =
|
|
|
|
uniform_bindings.get(&TextureSemantics::PassOutput.semantics(index).into())
|
|
|
|
{
|
|
|
|
uniform_storage.bind_vec4(offset.offset(), output.size(), offset.context());
|
2023-01-15 19:01:23 +11:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// bind PassFeedback0..
|
|
|
|
for (index, feedback) in pass_feedback.enumerate() {
|
|
|
|
let Some(output) = feedback else {
|
|
|
|
continue;
|
|
|
|
};
|
|
|
|
|
|
|
|
let feedback = output.as_ref();
|
|
|
|
|
2023-01-15 19:06:09 +11:00
|
|
|
if let Some(binding) =
|
|
|
|
texture_meta.get(&TextureSemantics::PassFeedback.semantics(index))
|
2023-01-15 19:01:23 +11:00
|
|
|
{
|
2023-01-15 19:06:09 +11:00
|
|
|
Self::bind_texture(descriptor_set, sampler_set, binding, feedback, device);
|
2023-01-15 19:01:23 +11:00
|
|
|
}
|
|
|
|
|
2023-01-15 19:06:09 +11:00
|
|
|
if let Some(offset) =
|
|
|
|
uniform_bindings.get(&TextureSemantics::PassFeedback.semantics(index).into())
|
|
|
|
{
|
|
|
|
uniform_storage.bind_vec4(offset.offset(), feedback.size(), offset.context());
|
2023-01-15 19:01:23 +11:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// bind User parameters
|
2023-01-15 19:06:09 +11:00
|
|
|
for (id, offset) in uniform_bindings
|
2023-01-15 19:01:23 +11:00
|
|
|
.iter()
|
|
|
|
.filter_map(|(binding, value)| match binding {
|
|
|
|
UniformBinding::Parameter(id) => Some((id, value)),
|
|
|
|
_ => None,
|
|
|
|
})
|
|
|
|
{
|
|
|
|
let id = id.as_str();
|
|
|
|
|
2023-02-06 10:34:30 +11:00
|
|
|
let default = parameter_defaults.get(id).map_or(0f32, |f| f.initial);
|
2023-01-15 19:01:23 +11:00
|
|
|
|
2023-01-16 10:21:01 +11:00
|
|
|
let value = *runtime_parameters.get(id).unwrap_or(&default);
|
2023-01-15 19:01:23 +11:00
|
|
|
|
|
|
|
uniform_storage.bind_scalar(offset.offset(), value, offset.context());
|
|
|
|
}
|
|
|
|
|
|
|
|
// bind luts
|
|
|
|
for (index, lut) in lookup_textures {
|
|
|
|
let lut = lut.as_ref();
|
2023-01-15 19:06:09 +11:00
|
|
|
if let Some(binding) = texture_meta.get(&TextureSemantics::User.semantics(index)) {
|
|
|
|
Self::bind_texture(descriptor_set, sampler_set, binding, lut, device);
|
2023-01-15 19:01:23 +11:00
|
|
|
}
|
|
|
|
|
2023-01-15 19:06:09 +11:00
|
|
|
if let Some(offset) =
|
|
|
|
uniform_bindings.get(&TextureSemantics::User.semantics(index).into())
|
2023-01-15 19:01:23 +11:00
|
|
|
{
|
2023-01-15 19:06:09 +11:00
|
|
|
uniform_storage.bind_vec4(offset.offset(), lut.size(), offset.context());
|
2023-01-15 19:01:23 +11:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-01-15 19:06:09 +11:00
|
|
|
}
|
2023-02-06 08:17:14 +11:00
|
|
|
|
|
|
|
/// Trait for objects that can be used to create a binding map.
|
|
|
|
pub trait BindingUtil {
|
|
|
|
/// Create the uniform binding map with the given reflection information.
|
|
|
|
fn create_binding_map<T>(
|
|
|
|
&self,
|
|
|
|
f: impl Fn(&dyn UniformMeta) -> T,
|
|
|
|
) -> FxHashMap<UniformBinding, T>;
|
|
|
|
|
|
|
|
/// Calculate the number of required images for history.
|
|
|
|
fn calculate_required_history<'a>(pass_meta: impl Iterator<Item = &'a Self>) -> usize
|
|
|
|
where
|
|
|
|
Self: 'a;
|
|
|
|
}
|
|
|
|
|
|
|
|
impl BindingUtil for BindingMeta {
|
|
|
|
fn create_binding_map<T>(
|
|
|
|
&self,
|
|
|
|
f: impl Fn(&dyn UniformMeta) -> T,
|
|
|
|
) -> FxHashMap<UniformBinding, T> {
|
|
|
|
let mut uniform_bindings = FxHashMap::default();
|
|
|
|
for param in self.parameter_meta.values() {
|
|
|
|
uniform_bindings.insert(UniformBinding::Parameter(param.id.clone()), f(param));
|
|
|
|
}
|
|
|
|
|
|
|
|
for (semantics, param) in &self.unique_meta {
|
|
|
|
uniform_bindings.insert(UniformBinding::SemanticVariable(*semantics), f(param));
|
|
|
|
}
|
|
|
|
|
|
|
|
for (semantics, param) in &self.texture_size_meta {
|
|
|
|
uniform_bindings.insert(UniformBinding::TextureSize(*semantics), f(param));
|
|
|
|
}
|
|
|
|
|
|
|
|
uniform_bindings
|
|
|
|
}
|
|
|
|
|
|
|
|
fn calculate_required_history<'a>(pass_meta: impl Iterator<Item = &'a Self>) -> usize
|
|
|
|
where
|
|
|
|
Self: 'a,
|
|
|
|
{
|
|
|
|
let mut required_images = 0;
|
|
|
|
|
|
|
|
for pass in pass_meta {
|
|
|
|
// If a shader uses history size, but not history, we still need to keep the texture.
|
2023-02-11 16:20:35 +11:00
|
|
|
let texture_max_index = pass
|
2023-02-06 08:17:14 +11:00
|
|
|
.texture_meta
|
|
|
|
.iter()
|
|
|
|
.filter(|(semantics, _)| semantics.semantics == TextureSemantics::OriginalHistory)
|
2023-02-11 16:20:35 +11:00
|
|
|
.map(|(semantic, _)| semantic.index)
|
|
|
|
.fold(0, std::cmp::max);
|
|
|
|
let texture_size_max_index = pass
|
2023-02-06 08:17:14 +11:00
|
|
|
.texture_size_meta
|
|
|
|
.iter()
|
|
|
|
.filter(|(semantics, _)| semantics.semantics == TextureSemantics::OriginalHistory)
|
2023-02-11 16:20:35 +11:00
|
|
|
.map(|(semantic, _)| semantic.index)
|
|
|
|
.fold(0, std::cmp::max);
|
2023-02-06 08:17:14 +11:00
|
|
|
|
2023-02-11 16:20:35 +11:00
|
|
|
required_images = std::cmp::max(required_images, texture_max_index);
|
|
|
|
required_images = std::cmp::max(required_images, texture_size_max_index);
|
2023-02-06 08:17:14 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
required_images
|
|
|
|
}
|
|
|
|
}
|
2024-02-12 17:56:39 +11:00
|
|
|
|
|
|
|
#[macro_export]
|
|
|
|
macro_rules! impl_default_frame_options {
|
|
|
|
($ty:ident) => {
|
|
|
|
/// Options for each frame.
|
|
|
|
#[repr(C)]
|
|
|
|
#[derive(Debug, Clone)]
|
|
|
|
pub struct $ty {
|
|
|
|
/// Whether or not to clear the history buffers.
|
|
|
|
pub clear_history: bool,
|
|
|
|
/// The direction of rendering.
|
|
|
|
/// -1 indicates that the frames are played in reverse order.
|
|
|
|
pub frame_direction: i32,
|
|
|
|
/// The rotation of the output. 0 = 0deg, 1 = 90deg, 2 = 180deg, 4 = 270deg.
|
|
|
|
pub rotation: u32,
|
|
|
|
/// The total number of subframes ran. Default is 1.
|
|
|
|
pub total_subframes: u32,
|
|
|
|
// The current sub frame. Default is 1.
|
|
|
|
pub current_subframe: u32,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Default for $ty {
|
|
|
|
fn default() -> Self {
|
|
|
|
Self {
|
|
|
|
clear_history: false,
|
|
|
|
frame_direction: 1,
|
|
|
|
rotation: 0,
|
|
|
|
total_subframes: 1,
|
|
|
|
current_subframe: 1,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|