doc: doc preset

This commit is contained in:
chyyran 2022-12-01 00:24:24 -05:00
parent 8fa38c564c
commit 5d668a2233
2 changed files with 55 additions and 22 deletions

View file

@ -9,7 +9,7 @@ use std::str::FromStr;
pub struct ShaderPassConfig { pub struct ShaderPassConfig {
/// The index of the shader pass relative to its parent preset. /// The index of the shader pass relative to its parent preset.
pub id: i32, pub id: i32,
/// The path to the shader pass source file. /// The fully qualified path to the shader pass source file.
pub name: PathBuf, pub name: PathBuf,
/// The alias of the shader pass if available. /// The alias of the shader pass if available.
pub alias: Option<String>, pub alias: Option<String>,
@ -23,23 +23,31 @@ pub struct ShaderPassConfig {
pub srgb_framebuffer: bool, pub srgb_framebuffer: bool,
/// Whether or not this shader pass expects an float framebuffer output. /// Whether or not this shader pass expects an float framebuffer output.
pub float_framebuffer: bool, pub float_framebuffer: bool,
/// Whether or not to generate mipm /// Whether or not to generate mipmaps for the input texture before passing to the shader.
pub mipmap_input: bool, pub mipmap_input: bool,
/// Specifies the scaling of the output framebuffer for this shader pass.
pub scaling: Scale2D, pub scaling: Scale2D,
} }
#[repr(i32)] #[repr(i32)]
#[derive(Default, Copy, Clone, Debug)] #[derive(Default, Copy, Clone, Debug)]
/// The scaling type for the shader pass.
pub enum ScaleType { pub enum ScaleType {
#[default] #[default]
/// Scale by the size of the input quad.
Input = 0, Input = 0,
/// Scale the framebuffer in absolute units.
Absolute, Absolute,
/// Scale by the size of the viewport.
Viewport, Viewport,
} }
/// The scaling factor for framebuffer scaling.
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
pub enum ScaleFactor { pub enum ScaleFactor {
/// Scale by a fractional float factor.
Float(f32), Float(f32),
/// Scale by an absolute factor.
Absolute(i32), Absolute(i32),
} }
@ -93,34 +101,54 @@ impl FromStr for ScaleType {
} }
} }
/// Framebuffer scaling parameters.
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct Scaling { pub struct Scaling {
/// The method to scale the framebuffer with.
pub scale_type: ScaleType, pub scale_type: ScaleType,
/// The factor to scale by.
pub factor: ScaleFactor, pub factor: ScaleFactor,
} }
/// 2D quad scaling parameters.
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct Scale2D { pub struct Scale2D {
/// Whether or not this combination of scaling factors is valid.
pub valid: bool, pub valid: bool,
/// Scaling parameters for the X axis.
pub x: Scaling, pub x: Scaling,
/// Scaling parameters for the Y axis.
pub y: Scaling, pub y: Scaling,
} }
/// Configuration options for a lookup texture used in the shader.
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct TextureConfig { pub struct TextureConfig {
/// The name of the texture.
pub name: String, pub name: String,
/// The fully qualified path to the texture.
pub path: PathBuf, pub path: PathBuf,
/// The wrap (addressing) mode to use when sampling the texture.
pub wrap_mode: WrapMode, pub wrap_mode: WrapMode,
/// The filter mode to use when sampling the texture.
pub filter_mode: FilterMode, pub filter_mode: FilterMode,
/// Whether or not to generate mipmaps for this texture.
pub mipmap: bool, pub mipmap: bool,
} }
/// Configuration options for a shader parameter.
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct ParameterConfig { pub struct ParameterConfig {
/// The name of the parameter.
pub name: String, pub name: String,
/// The value it is set to in the preset.
pub value: f32, pub value: f32,
} }
/// A shader preset including all specified parameters, textures, and paths to specified shaders.
///
/// A shader preset can be used to create a filter chain runtime instance, or reflected to get
/// parameter metadata.
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct ShaderPreset { pub struct ShaderPreset {
/// Used in legacy GLSL shader semantics. If < 0, no feedback pass is used. /// Used in legacy GLSL shader semantics. If < 0, no feedback pass is used.

View file

@ -164,27 +164,32 @@ impl OwnedFramebuffer {
self.init(image.size, ImageFormat::from(format))?; self.init(image.size, ImageFormat::from(format))?;
} }
// unsafe { // todo: improve mipmap generation?
// self.context.CopySubresourceRegion( // will need a staging texture + full so might not be worth it.
// &self.texture,
// 0, #[cfg(feature = "testing_full_gpu_copy")]
// 0, unsafe {
// 0, self.context.CopySubresourceRegion(
// 0, &self.texture,
// &resource, 0,
// 0, 0,
// Some(&D3D11_BOX { 0,
// left: 0, 0,
// top: 0, &resource,
// front: 0, 0,
// right: self.size.width, Some(&D3D11_BOX {
// bottom: self.size.height, left: 0,
// back: 1, top: 0,
// }), front: 0,
// ) right: self.size.width,
// } bottom: self.size.height,
// back: 1,
}),
)
}
self.texture = resource; self.texture = resource;
Ok(()) Ok(())
} }
} }