rt: separate out meta information to its own struct

This commit is contained in:
chyyran 2024-09-30 19:02:55 -04:00 committed by Ronny Chan
parent b395b94a40
commit 859d16e64e
21 changed files with 228 additions and 223 deletions

View file

@ -16,8 +16,7 @@ members = [
"librashader-cache",
"librashader-capi",
"librashader-build-script",
"librashader-cli"
]
"librashader-cli"]
resolver = "2"
[workspace.dependencies]

View file

@ -6,8 +6,8 @@ use crate::ffi::extern_fn;
use librashader::runtime::vk::{
FilterChain, FilterChainOptions, FrameOptions, VulkanImage, VulkanInstance,
};
use std::ffi::CStr;
use std::ffi::c_char;
use std::ffi::CStr;
use std::mem::MaybeUninit;
use std::ptr::NonNull;
use std::slice;

View file

@ -1,6 +1,9 @@
use crate::parse::remove_if;
use crate::parse::value::Value;
use crate::{ParameterConfig, Scale2D, Scaling, ShaderPassConfig, ShaderPreset, TextureConfig};
use crate::{
ParameterConfig, Scale2D, Scaling, ShaderPassConfig, ShaderPassMeta, ShaderPreset,
TextureConfig,
};
use vec_extract_if_polyfill::MakeExtractIf;
pub fn resolve_values(mut values: Vec<Value>) -> ShaderPreset {
@ -114,8 +117,9 @@ pub fn resolve_values(mut values: Vec<Value>) -> ShaderPreset {
}
let shader = ShaderPassConfig {
id,
name,
meta: ShaderPassMeta {
id,
alias: shader_values.iter().find_map(|f| match f {
Value::Alias(_, value) => Some(value.clone()),
_ => None,
@ -173,6 +177,7 @@ pub fn resolve_values(mut values: Vec<Value>) -> ShaderPreset {
factor: scale_y.unwrap_or_default(),
},
},
},
};
shaders.push(shader)

View file

@ -9,10 +9,17 @@ use std::str::FromStr;
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct ShaderPassConfig {
/// The index of the shader pass relative to its parent preset.
pub id: i32,
/// The fully qualified path to the shader pass source file.
pub name: PathBuf,
/// Meta information about the shader pass
pub meta: ShaderPassMeta,
}
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct ShaderPassMeta {
/// The index of the shader pass relative to its parent preset.
pub id: i32,
/// The alias of the shader pass if available.
pub alias: Option<ShortString>,
/// The filtering mode that this shader pass should expect.
@ -31,7 +38,7 @@ pub struct ShaderPassConfig {
pub scaling: Scale2D,
}
impl ShaderPassConfig {
impl ShaderPassMeta {
/// If the framebuffer expects a different format than what was defined in the
/// shader source, returns such format.
#[inline(always)]

View file

@ -7,7 +7,7 @@ use crate::reflect::semantics::{
};
use librashader_common::map::{FastHashMap, ShortString};
use librashader_preprocess::{PreprocessError, ShaderSource};
use librashader_presets::{ShaderPassConfig, ShaderPreset, TextureConfig};
use librashader_presets::{ShaderPassConfig, ShaderPassMeta, ShaderPreset, TextureConfig};
/// Artifacts of a reflected and compiled shader pass.
///
@ -27,7 +27,7 @@ use librashader_presets::{ShaderPassConfig, ShaderPreset, TextureConfig};
/// ```
///
/// This allows a runtime to not name the backing type of the compiled artifact if not necessary.
pub type ShaderPassArtifact<T> = (ShaderPassConfig, ShaderSource, CompilerBackend<T>);
pub type ShaderPassArtifact<T> = (ShaderPassMeta, ShaderSource, CompilerBackend<T>);
impl<T: OutputTarget> CompilePresetTarget for T {}
@ -101,22 +101,22 @@ where
}),
);
}
Ok::<_, E>((shader, source, reflect))
Ok::<_, E>((shader.meta, source, reflect))
})
.collect::<Result<Vec<(ShaderPassConfig, ShaderSource, CompilerBackend<_>)>, E>>()?;
.collect::<Result<Vec<(ShaderPassMeta, ShaderSource, CompilerBackend<_>)>, E>>()?;
for (config, source, _) in &passes {
for (meta, source, _) in &passes {
insert_pass_semantics(
&mut uniform_semantics,
&mut texture_semantics,
config.alias.as_ref(),
config.id as usize,
meta.alias.as_ref(),
meta.id as usize,
);
insert_pass_semantics(
&mut uniform_semantics,
&mut texture_semantics,
source.name.as_ref(),
config.id as usize,
meta.id as usize,
);
}
@ -251,14 +251,14 @@ impl ShaderSemantics {
insert_pass_semantics(
&mut uniform_semantics,
&mut texture_semantics,
config.alias.as_ref(),
config.id as usize,
config.meta.alias.as_ref(),
config.meta.id as usize,
);
insert_pass_semantics(
&mut uniform_semantics,
&mut texture_semantics,
source.name.as_ref(),
config.id as usize,
config.meta.id as usize,
);
insert_lut_semantics(
preset.textures.as_slice(),

View file

@ -328,7 +328,7 @@ impl FilterChainD3D11 {
uniform_buffer: ubo_cbuffer,
push_buffer: push_cbuffer,
source,
config,
meta: config,
})
};
@ -425,8 +425,8 @@ impl FilterChainD3D11 {
}
let options = options.unwrap_or(&self.default_options);
let filter = passes[0].config.filter;
let wrap_mode = passes[0].config.wrap_mode;
let filter = passes[0].meta.filter;
let wrap_mode = passes[0].meta.wrap_mode;
for (texture, fbo) in self
.common
@ -467,8 +467,8 @@ impl FilterChainD3D11 {
{
*texture = Some(InputTexture::from_framebuffer(
fbo,
pass.config.wrap_mode,
pass.config.filter,
pass.meta.wrap_mode,
pass.meta.filter,
)?);
}
@ -479,14 +479,14 @@ impl FilterChainD3D11 {
self.common.draw_quad.bind_vbo_for_frame(ctx);
for (index, pass) in pass.iter_mut().enumerate() {
source.filter = pass.config.filter;
source.wrap_mode = pass.config.wrap_mode;
source.filter = pass.meta.filter;
source.wrap_mode = pass.meta.wrap_mode;
let target = &self.output_framebuffers[index];
pass.draw(
ctx,
index,
&self.common,
pass.config.get_frame_count(frame_count),
pass.meta.get_frame_count(frame_count),
options,
viewport,
&original,
@ -497,8 +497,8 @@ impl FilterChainD3D11 {
source = InputTexture {
view: target.create_shader_resource_view()?,
filter: pass.config.filter,
wrap_mode: pass.config.wrap_mode,
filter: pass.meta.filter,
wrap_mode: pass.meta.wrap_mode,
};
self.common.output_textures[index] = Some(source.clone());
}
@ -507,8 +507,8 @@ impl FilterChainD3D11 {
assert_eq!(last.len(), 1);
if let Some(pass) = last.iter_mut().next() {
let index = passes_len - 1;
source.filter = pass.config.filter;
source.wrap_mode = pass.config.wrap_mode;
source.filter = pass.meta.filter;
source.wrap_mode = pass.meta.wrap_mode;
// Draw to output_framebuffers for proper handling of feedback.
@ -518,7 +518,7 @@ impl FilterChainD3D11 {
&ctx,
index,
&self.common,
pass.config.get_frame_count(frame_count),
pass.meta.get_frame_count(frame_count),
options,
viewport,
&original,
@ -535,7 +535,7 @@ impl FilterChainD3D11 {
&ctx,
index,
&self.common,
pass.config.get_frame_count(frame_count),
pass.meta.get_frame_count(frame_count),
options,
viewport,
&original,

View file

@ -6,7 +6,7 @@ use windows::Win32::Foundation::RECT;
use librashader_common::map::FastHashMap;
use librashader_common::{ImageFormat, Size, Viewport};
use librashader_preprocess::ShaderSource;
use librashader_presets::ShaderPassConfig;
use librashader_presets::ShaderPassMeta;
use librashader_reflect::reflect::semantics::{
BindingStage, MemberOffset, TextureBinding, UniformBinding,
};
@ -47,7 +47,7 @@ pub struct FilterPass {
pub uniform_buffer: Option<ConstantBufferBinding>,
pub push_buffer: Option<ConstantBufferBinding>,
pub source: ShaderSource,
pub config: ShaderPassConfig,
pub meta: ShaderPassMeta,
}
// https://doc.rust-lang.org/nightly/core/array/fn.from_fn.html is not ~const :(
@ -90,8 +90,8 @@ impl FilterPassMeta for FilterPass {
self.source.format
}
fn config(&self) -> &ShaderPassConfig {
&self.config
fn meta(&self) -> &ShaderPassMeta {
&self.meta
}
}
@ -157,7 +157,7 @@ impl FilterPass {
output: RenderTarget<ID3D11RenderTargetView>,
vbo_type: QuadType,
) -> error::Result<()> {
if self.config.mipmap_input && !parent.disable_mipmaps {
if self.meta.mipmap_input && !parent.disable_mipmaps {
unsafe {
ctx.GenerateMips(&source.view);
}

View file

@ -619,7 +619,7 @@ impl FilterChainD3D12 {
uniform_bindings,
uniform_storage,
pipeline: graphics_pipeline,
config,
meta: config,
texture_heap,
sampler_heap,
source,
@ -708,8 +708,8 @@ impl FilterChainD3D12 {
let options = options.unwrap_or(&self.default_options);
let filter = passes[0].config.filter;
let wrap_mode = passes[0].config.wrap_mode;
let filter = passes[0].meta.filter;
let wrap_mode = passes[0].meta.wrap_mode;
for ((texture, fbo), pass) in self
.common
@ -720,8 +720,8 @@ impl FilterChainD3D12 {
{
*texture = Some(fbo.create_shader_resource_view(
&mut self.staging_heap,
pass.config.filter,
pass.config.wrap_mode,
pass.meta.filter,
pass.meta.wrap_mode,
)?);
}
@ -771,13 +771,13 @@ impl FilterChainD3D12 {
// refresh inputs
self.common.feedback_textures[index] = Some(feedback.create_shader_resource_view(
&mut self.staging_heap,
pass.config.filter,
pass.config.wrap_mode,
pass.meta.filter,
pass.meta.wrap_mode,
)?);
self.common.output_textures[index] = Some(output.create_shader_resource_view(
&mut self.staging_heap,
pass.config.filter,
pass.config.wrap_mode,
pass.meta.filter,
pass.meta.wrap_mode,
)?);
Ok(())
@ -800,8 +800,8 @@ impl FilterChainD3D12 {
self.common.draw_quad.bind_vertices_for_frame(cmd);
for (index, pass) in pass.iter_mut().enumerate() {
source.filter = pass.config.filter;
source.wrap_mode = pass.config.wrap_mode;
source.filter = pass.meta.filter;
source.wrap_mode = pass.meta.wrap_mode;
let target = &self.output_framebuffers[index];
@ -828,7 +828,7 @@ impl FilterChainD3D12 {
cmd,
index,
&self.common,
pass.config.get_frame_count(frame_count),
pass.meta.get_frame_count(frame_count),
options,
viewport,
&original,
@ -872,8 +872,8 @@ impl FilterChainD3D12 {
if let Some(pass) = last.iter_mut().next() {
let index = passes_len - 1;
source.filter = pass.config.filter;
source.wrap_mode = pass.config.wrap_mode;
source.filter = pass.meta.filter;
source.wrap_mode = pass.meta.wrap_mode;
if self.draw_last_pass_feedback {
let feedback_target = &self.output_framebuffers[index];
@ -900,7 +900,7 @@ impl FilterChainD3D12 {
cmd,
index,
&self.common,
pass.config.get_frame_count(frame_count),
pass.meta.get_frame_count(frame_count),
options,
viewport,
&original,
@ -931,7 +931,7 @@ impl FilterChainD3D12 {
cmd,
passes_len - 1,
&self.common,
pass.config.get_frame_count(frame_count),
pass.meta.get_frame_count(frame_count),
options,
viewport,
&original,

View file

@ -10,7 +10,7 @@ use d3d12_descriptor_heap::D3D12DescriptorHeapSlot;
use librashader_common::map::FastHashMap;
use librashader_common::{ImageFormat, Size, Viewport};
use librashader_preprocess::ShaderSource;
use librashader_presets::ShaderPassConfig;
use librashader_presets::ShaderPassMeta;
use librashader_reflect::reflect::semantics::{MemberOffset, TextureBinding, UniformBinding};
use librashader_reflect::reflect::ShaderReflection;
use librashader_runtime::binding::{BindSemantics, TextureInput, UniformInputs};
@ -30,7 +30,7 @@ use windows::Win32::Graphics::Direct3D12::{
pub(crate) struct FilterPass {
pub(crate) pipeline: D3D12GraphicsPipeline,
pub(crate) reflection: ShaderReflection,
pub(crate) config: ShaderPassConfig,
pub(crate) meta: ShaderPassMeta,
pub(crate) uniform_bindings: FastHashMap<UniformBinding, MemberOffset>,
pub uniform_storage:
UniformStorage<NoUniformBinder, Option<()>, RawD3D12Buffer, RawD3D12Buffer>,
@ -77,8 +77,8 @@ impl FilterPassMeta for FilterPass {
self.source.format
}
fn config(&self) -> &ShaderPassConfig {
&self.config
fn meta(&self) -> &ShaderPassMeta {
&self.meta
}
}

View file

@ -170,7 +170,7 @@ impl FilterChainD3D9 {
uniform_storage,
gl_halfpixel,
source,
config,
meta: config,
})
};
@ -309,8 +309,8 @@ impl FilterChainD3D9 {
}
let options = options.unwrap_or(&self.default_options);
let filter = passes[0].config.filter;
let wrap_mode = passes[0].config.wrap_mode;
let filter = passes[0].meta.filter;
let wrap_mode = passes[0].meta.wrap_mode;
for (texture, fbo) in self
.common
@ -351,11 +351,7 @@ impl FilterChainD3D9 {
.zip(self.feedback_framebuffers.iter())
.zip(passes.iter())
{
*texture = Some(fbo.as_input(
pass.config.filter,
pass.config.filter,
pass.config.wrap_mode,
));
*texture = Some(fbo.as_input(pass.meta.filter, pass.meta.filter, pass.meta.wrap_mode));
}
let passes_len = passes.len();
@ -363,16 +359,16 @@ impl FilterChainD3D9 {
let state_guard = D3D9State::new(&self.common.d3d9)?;
for (index, pass) in pass.iter_mut().enumerate() {
source.filter = pass.config.filter;
source.wrap = pass.config.wrap_mode;
source.is_srgb = pass.config.srgb_framebuffer;
source.filter = pass.meta.filter;
source.wrap = pass.meta.wrap_mode;
source.is_srgb = pass.meta.srgb_framebuffer;
let target = &self.output_framebuffers[index];
let target_rtv = target.as_output()?;
pass.draw(
&self.common.d3d9,
index,
&self.common,
pass.config.get_frame_count(frame_count),
pass.meta.get_frame_count(frame_count),
options,
viewport,
&original,
@ -383,10 +379,10 @@ impl FilterChainD3D9 {
source = D3D9InputTexture {
handle: target.handle.clone(),
filter: pass.config.filter,
wrap: pass.config.wrap_mode,
mipmode: pass.config.filter,
is_srgb: pass.config.srgb_framebuffer,
filter: pass.meta.filter,
wrap: pass.meta.wrap_mode,
mipmode: pass.meta.filter,
is_srgb: pass.meta.srgb_framebuffer,
};
self.common.output_textures[index] = Some(source.clone());
}
@ -395,9 +391,9 @@ impl FilterChainD3D9 {
assert_eq!(last.len(), 1);
if let Some(pass) = last.iter_mut().next() {
let index = passes_len - 1;
source.filter = pass.config.filter;
source.wrap = pass.config.wrap_mode;
source.is_srgb = pass.config.srgb_framebuffer;
source.filter = pass.meta.filter;
source.wrap = pass.meta.wrap_mode;
source.is_srgb = pass.meta.srgb_framebuffer;
if self.draw_last_pass_feedback {
let feedback_target = &self.output_framebuffers[index];
@ -407,7 +403,7 @@ impl FilterChainD3D9 {
&self.common.d3d9,
index,
&self.common,
pass.config.get_frame_count(frame_count),
pass.meta.get_frame_count(frame_count),
options,
viewport,
&original,
@ -421,7 +417,7 @@ impl FilterChainD3D9 {
&self.common.d3d9,
index,
&self.common,
pass.config.get_frame_count(frame_count),
pass.meta.get_frame_count(frame_count),
options,
viewport,
&original,

View file

@ -8,7 +8,7 @@ use librashader_common::map::FastHashMap;
use librashader_common::GetSize;
use librashader_common::{ImageFormat, Size, Viewport};
use librashader_preprocess::ShaderSource;
use librashader_presets::ShaderPassConfig;
use librashader_presets::ShaderPassMeta;
use librashader_reflect::reflect::semantics::{TextureBinding, UniformBinding};
use librashader_reflect::reflect::ShaderReflection;
use librashader_runtime::binding::{BindSemantics, UniformInputs};
@ -28,7 +28,7 @@ pub struct FilterPass {
pub pixel_shader: IDirect3DPixelShader9,
pub uniform_bindings: FastHashMap<UniformBinding, ConstantRegister>,
pub source: ShaderSource,
pub config: ShaderPassConfig,
pub meta: ShaderPassMeta,
pub uniform_storage: D3D9UniformStorage,
pub gl_halfpixel: Option<RegisterAssignment>,
}
@ -38,8 +38,8 @@ impl FilterPassMeta for FilterPass {
self.source.format
}
fn config(&self) -> &ShaderPassConfig {
&self.config
fn meta(&self) -> &ShaderPassMeta {
&self.meta
}
}
@ -150,7 +150,7 @@ impl FilterPass {
output: RenderTarget<IDirect3DSurface9>,
vbo_type: QuadType,
) -> error::Result<()> {
if self.config.mipmap_input && !parent.disable_mipmaps {
if self.meta.mipmap_input && !parent.disable_mipmaps {
unsafe {
source.handle.GenerateMipSubLevels();
}

View file

@ -147,10 +147,10 @@ impl<T: GLInterface> FilterChainImpl<T> {
// initialize passes
let filters = Self::init_passes(&context, version, passes, &semantics, disable_cache)?;
let default_filter = filters.first().map(|f| f.config.filter).unwrap_or_default();
let default_filter = filters.first().map(|f| f.meta.filter).unwrap_or_default();
let default_wrap = filters
.first()
.map(|f| f.config.wrap_mode)
.map(|f| f.meta.wrap_mode)
.unwrap_or_default();
let samplers = SamplerSet::new(&context)?;
@ -256,7 +256,7 @@ impl<T: GLInterface> FilterChainImpl<T> {
uniform_storage,
uniform_bindings,
source,
config,
meta: config,
});
}
@ -309,8 +309,8 @@ impl<T: GLInterface> FilterChainImpl<T> {
self.draw_quad
.bind_vertices(&self.common.context, QuadType::Offscreen);
let filter = passes[0].config.filter;
let wrap_mode = passes[0].config.wrap_mode;
let filter = passes[0].meta.filter;
let wrap_mode = passes[0].meta.wrap_mode;
// update history
for (texture, fbo) in self
@ -352,9 +352,7 @@ impl<T: GLInterface> FilterChainImpl<T> {
.zip(self.feedback_framebuffers.iter())
.zip(passes.iter())
{
texture.image = fbo
.as_texture(pass.config.filter, pass.config.wrap_mode)
.image;
texture.image = fbo.as_texture(pass.meta.filter, pass.meta.wrap_mode).image;
}
let passes_len = passes.len();
@ -364,14 +362,14 @@ impl<T: GLInterface> FilterChainImpl<T> {
.bind_vertices(&self.common.context, QuadType::Offscreen);
for (index, pass) in pass.iter_mut().enumerate() {
let target = &self.output_framebuffers[index];
source.filter = pass.config.filter;
source.mip_filter = pass.config.filter;
source.wrap_mode = pass.config.wrap_mode;
source.filter = pass.meta.filter;
source.mip_filter = pass.meta.filter;
source.wrap_mode = pass.meta.wrap_mode;
pass.draw(
index,
&self.common,
pass.config.get_frame_count(frame_count),
pass.meta.get_frame_count(frame_count),
options,
viewport,
&original,
@ -379,7 +377,7 @@ impl<T: GLInterface> FilterChainImpl<T> {
RenderTarget::identity(target)?,
)?;
let target = target.as_texture(pass.config.filter, pass.config.wrap_mode);
let target = target.as_texture(pass.meta.filter, pass.meta.wrap_mode);
self.common.output_textures[index] = target;
source = target;
}
@ -394,16 +392,16 @@ impl<T: GLInterface> FilterChainImpl<T> {
.render_target
.ensure::<T::FramebufferInterface>(viewport.output)?;
source.filter = pass.config.filter;
source.mip_filter = pass.config.filter;
source.wrap_mode = pass.config.wrap_mode;
source.filter = pass.meta.filter;
source.mip_filter = pass.meta.filter;
source.wrap_mode = pass.meta.wrap_mode;
if self.draw_last_pass_feedback {
let target = &self.output_framebuffers[index];
pass.draw(
index,
&self.common,
pass.config.get_frame_count(frame_count),
pass.meta.get_frame_count(frame_count),
options,
viewport,
&original,
@ -415,7 +413,7 @@ impl<T: GLInterface> FilterChainImpl<T> {
pass.draw(
index,
&self.common,
pass.config.get_frame_count(frame_count),
pass.meta.get_frame_count(frame_count),
options,
viewport,
&original,
@ -424,7 +422,7 @@ impl<T: GLInterface> FilterChainImpl<T> {
)?;
self.common.output_textures[passes_len - 1] = viewport
.output
.as_texture(pass.config.filter, pass.config.wrap_mode);
.as_texture(pass.meta.filter, pass.meta.wrap_mode);
}
// swap feedback framebuffers with output

View file

@ -4,7 +4,7 @@ use librashader_reflect::reflect::ShaderReflection;
use librashader_common::map::FastHashMap;
use librashader_common::{ImageFormat, Size, Viewport};
use librashader_preprocess::ShaderSource;
use librashader_presets::ShaderPassConfig;
use librashader_presets::ShaderPassMeta;
use librashader_reflect::reflect::semantics::{MemberOffset, TextureBinding, UniformBinding};
use librashader_runtime::binding::{BindSemantics, ContextOffset, TextureInput, UniformInputs};
use librashader_runtime::filter_pass::FilterPassMeta;
@ -38,7 +38,7 @@ pub(crate) struct FilterPass<T: GLInterface> {
pub(crate) uniform_storage: GlUniformStorage,
pub uniform_bindings: FastHashMap<UniformBinding, UniformOffset>,
pub source: ShaderSource,
pub config: ShaderPassConfig,
pub meta: ShaderPassMeta,
}
impl TextureInput for InputTexture {
@ -89,7 +89,7 @@ impl<T: GLInterface> FilterPass<T> {
) -> error::Result<()> {
let framebuffer = output.output;
if self.config.mipmap_input && !parent.disable_mipmaps {
if self.meta.mipmap_input && !parent.disable_mipmaps {
T::BindTexture::gen_mipmaps(&parent.context, source);
}
@ -162,8 +162,8 @@ impl<T: GLInterface> FilterPassMeta for FilterPass<T> {
self.source.format
}
fn config(&self) -> &ShaderPassConfig {
&self.config
fn meta(&self) -> &ShaderPassMeta {
&self.meta
}
}

View file

@ -205,7 +205,7 @@ impl FilterChainMetal {
uniform_storage,
uniform_bindings,
source,
config,
meta: config,
graphics_pipeline,
})
})
@ -379,8 +379,8 @@ impl FilterChainMetal {
return Ok(());
}
let filter = passes[0].config.filter;
let wrap_mode = passes[0].config.wrap_mode;
let filter = passes[0].meta.filter;
let wrap_mode = passes[0].meta.wrap_mode;
// update history
for (texture, image) in self
@ -428,9 +428,9 @@ impl FilterChainMetal {
feedback: &OwnedTexture| {
// refresh inputs
self.common.feedback_textures[index] =
Some(feedback.as_input(pass.config.filter, pass.config.wrap_mode)?);
Some(feedback.as_input(pass.meta.filter, pass.meta.wrap_mode)?);
self.common.output_textures[index] =
Some(output.as_input(pass.config.filter, pass.config.wrap_mode)?);
Some(output.as_input(pass.meta.filter, pass.meta.wrap_mode)?);
Ok(())
}),
)?;
@ -441,16 +441,16 @@ impl FilterChainMetal {
for (index, pass) in pass.iter_mut().enumerate() {
let target = &self.output_framebuffers[index];
source.filter_mode = pass.config.filter;
source.wrap_mode = pass.config.wrap_mode;
source.mip_filter = pass.config.filter;
source.filter_mode = pass.meta.filter;
source.wrap_mode = pass.meta.wrap_mode;
source.mip_filter = pass.meta.filter;
let out = RenderTarget::identity(target.texture.as_ref())?;
pass.draw(
&cmd,
index,
&self.common,
pass.config.get_frame_count(frame_count),
pass.meta.get_frame_count(frame_count),
options,
viewport,
&original,
@ -464,7 +464,7 @@ impl FilterChainMetal {
}
self.common.output_textures[index] =
Some(target.as_input(pass.config.filter, pass.config.wrap_mode)?);
Some(target.as_input(pass.meta.filter, pass.meta.wrap_mode)?);
source = self.common.output_textures[index]
.as_ref()
.map(InputTexture::try_clone)
@ -484,9 +484,9 @@ impl FilterChainMetal {
.recompile(&self.common.device, viewport.output.pixelFormat())?;
}
source.filter_mode = pass.config.filter;
source.wrap_mode = pass.config.wrap_mode;
source.mip_filter = pass.config.filter;
source.filter_mode = pass.meta.filter;
source.wrap_mode = pass.meta.wrap_mode;
source.mip_filter = pass.meta.filter;
let index = passes_len - 1;
if self.draw_last_pass_feedback {
@ -496,7 +496,7 @@ impl FilterChainMetal {
&cmd,
passes_len - 1,
&self.common,
pass.config.get_frame_count(frame_count),
pass.meta.get_frame_count(frame_count),
options,
viewport,
&original,
@ -511,7 +511,7 @@ impl FilterChainMetal {
&cmd,
index,
&self.common,
pass.config.get_frame_count(frame_count),
pass.meta.get_frame_count(frame_count),
options,
viewport,
&original,

View file

@ -8,7 +8,7 @@ use crate::texture::{get_texture_size, InputTexture};
use librashader_common::map::FastHashMap;
use librashader_common::{ImageFormat, Size, Viewport};
use librashader_preprocess::ShaderSource;
use librashader_presets::ShaderPassConfig;
use librashader_presets::ShaderPassMeta;
use librashader_reflect::reflect::semantics::{MemberOffset, TextureBinding, UniformBinding};
use librashader_reflect::reflect::ShaderReflection;
use librashader_runtime::binding::{BindSemantics, TextureInput, UniformInputs};
@ -55,7 +55,7 @@ pub struct FilterPass {
UniformStorage<NoUniformBinder, Option<()>, MetalBuffer, MetalBuffer>,
pub uniform_bindings: FastHashMap<UniformBinding, MemberOffset>,
pub source: ShaderSource,
pub config: ShaderPassConfig,
pub meta: ShaderPassMeta,
pub graphics_pipeline: MetalGraphicsPipeline,
}
@ -177,7 +177,7 @@ impl FilterPassMeta for FilterPass {
self.source.format
}
fn config(&self) -> &ShaderPassConfig {
&self.config
fn meta(&self) -> &ShaderPassMeta {
&self.meta
}
}

View file

@ -511,7 +511,7 @@ impl FilterChainVulkan {
uniform_storage,
uniform_bindings,
source,
config,
meta: config,
graphics_pipeline,
// ubo_ring,
frames_in_flight,
@ -654,8 +654,8 @@ impl FilterChainVulkan {
self.vulkan.device.create_image_view(&create_info, None)?
};
let filter = passes[0].config.filter;
let wrap_mode = passes[0].config.wrap_mode;
let filter = passes[0].meta.filter;
let wrap_mode = passes[0].meta.wrap_mode;
// update history
for (texture, image) in self
@ -704,9 +704,9 @@ impl FilterChainVulkan {
feedback: &OwnedImage| {
// refresh inputs
self.common.feedback_textures[index] =
Some(feedback.as_input(pass.config.filter, pass.config.wrap_mode));
Some(feedback.as_input(pass.meta.filter, pass.meta.wrap_mode));
self.common.output_textures[index] =
Some(output.as_input(pass.config.filter, pass.config.wrap_mode));
Some(output.as_input(pass.meta.filter, pass.meta.wrap_mode));
Ok(())
}),
)?;
@ -721,9 +721,9 @@ impl FilterChainVulkan {
.bind_vbo_for_frame(&self.vulkan.device, cmd);
for (index, pass) in pass.iter_mut().enumerate() {
let target = &self.output_framebuffers[index];
source.filter_mode = pass.config.filter;
source.wrap_mode = pass.config.wrap_mode;
source.mip_filter = pass.config.filter;
source.filter_mode = pass.meta.filter;
source.wrap_mode = pass.meta.wrap_mode;
source.mip_filter = pass.meta.filter;
let output_image = OutputImage::new(&self.vulkan.device, target.image.clone())?;
let out = RenderTarget::identity(&output_image)?;
@ -733,7 +733,7 @@ impl FilterChainVulkan {
target.image.format,
index,
&self.common,
pass.config.get_frame_count(frame_count),
pass.meta.get_frame_count(frame_count),
options,
viewport,
&original,
@ -768,9 +768,9 @@ impl FilterChainVulkan {
pass.graphics_pipeline.recompile(viewport.output.format)?;
}
source.filter_mode = pass.config.filter;
source.wrap_mode = pass.config.wrap_mode;
source.mip_filter = pass.config.filter;
source.filter_mode = pass.meta.filter;
source.wrap_mode = pass.meta.wrap_mode;
source.mip_filter = pass.meta.filter;
if self.draw_last_pass_feedback {
let target = &self.output_framebuffers[index];
@ -783,7 +783,7 @@ impl FilterChainVulkan {
target.image.format,
index,
&self.common,
pass.config.get_frame_count(frame_count),
pass.meta.get_frame_count(frame_count),
options,
viewport,
&original,
@ -805,7 +805,7 @@ impl FilterChainVulkan {
viewport.output.format,
index,
&self.common,
pass.config.get_frame_count(frame_count),
pass.meta.get_frame_count(frame_count),
options,
viewport,
&original,

View file

@ -10,7 +10,7 @@ use ash::vk;
use librashader_common::map::FastHashMap;
use librashader_common::{ImageFormat, Size, Viewport};
use librashader_preprocess::ShaderSource;
use librashader_presets::ShaderPassConfig;
use librashader_presets::ShaderPassMeta;
use librashader_reflect::reflect::semantics::{
BindingStage, MemberOffset, TextureBinding, UniformBinding,
};
@ -28,7 +28,7 @@ pub struct FilterPass {
UniformStorage<NoUniformBinder, Option<()>, RawVulkanBuffer, Box<[u8]>, Arc<ash::Device>>,
pub uniform_bindings: FastHashMap<UniformBinding, MemberOffset>,
pub source: ShaderSource,
pub config: ShaderPassConfig,
pub meta: ShaderPassMeta,
pub graphics_pipeline: VulkanGraphicsPipeline,
pub frames_in_flight: u32,
}
@ -78,8 +78,8 @@ impl FilterPassMeta for FilterPass {
self.source.format
}
fn config(&self) -> &ShaderPassConfig {
&self.config
fn meta(&self) -> &ShaderPassMeta {
&self.meta
}
}

View file

@ -336,7 +336,7 @@ impl FilterChainWgpu {
uniform_storage,
uniform_bindings,
source,
config,
meta: config,
graphics_pipeline,
})
})
@ -389,8 +389,8 @@ impl FilterChainWgpu {
let original_image_view = input.create_view(&wgpu::TextureViewDescriptor::default());
let filter = passes[0].config.filter;
let wrap_mode = passes[0].config.wrap_mode;
let filter = passes[0].meta.filter;
let wrap_mode = passes[0].meta.wrap_mode;
// update history
for (texture, image) in self
@ -433,9 +433,9 @@ impl FilterChainWgpu {
feedback: &OwnedImage| {
// refresh inputs
self.common.feedback_textures[index] =
Some(feedback.as_input(pass.config.filter, pass.config.wrap_mode));
Some(feedback.as_input(pass.meta.filter, pass.meta.wrap_mode));
self.common.output_textures[index] =
Some(output.as_input(pass.config.filter, pass.config.wrap_mode));
Some(output.as_input(pass.meta.filter, pass.meta.wrap_mode));
Ok(())
}),
)?;
@ -446,9 +446,9 @@ impl FilterChainWgpu {
let options = options.unwrap_or(&self.default_frame_options);
for (index, pass) in pass.iter_mut().enumerate() {
source.filter_mode = pass.config.filter;
source.wrap_mode = pass.config.wrap_mode;
source.mip_filter = pass.config.filter;
source.filter_mode = pass.meta.filter;
source.wrap_mode = pass.meta.wrap_mode;
source.mip_filter = pass.meta.filter;
let target = &self.output_framebuffers[index];
let output_image = WgpuOutputView::from(target);
@ -458,7 +458,7 @@ impl FilterChainWgpu {
cmd,
index,
&self.common,
pass.config.get_frame_count(frame_count),
pass.meta.get_frame_count(frame_count),
options,
viewport,
&original,
@ -490,9 +490,9 @@ impl FilterChainWgpu {
pass.graphics_pipeline.recompile(viewport.output.format);
}
source.filter_mode = pass.config.filter;
source.wrap_mode = pass.config.wrap_mode;
source.mip_filter = pass.config.filter;
source.filter_mode = pass.meta.filter;
source.wrap_mode = pass.meta.wrap_mode;
source.mip_filter = pass.meta.filter;
if self.draw_last_pass_feedback {
let target = &self.output_framebuffers[index];
@ -503,7 +503,7 @@ impl FilterChainWgpu {
cmd,
index,
&self.common,
pass.config.get_frame_count(frame_count),
pass.meta.get_frame_count(frame_count),
options,
viewport,
&original,
@ -518,7 +518,7 @@ impl FilterChainWgpu {
cmd,
index,
&self.common,
pass.config.get_frame_count(frame_count),
pass.meta.get_frame_count(frame_count),
options,
viewport,
&original,

View file

@ -9,7 +9,7 @@ use crate::texture::InputImage;
use librashader_common::map::FastHashMap;
use librashader_common::{ImageFormat, Size, Viewport};
use librashader_preprocess::ShaderSource;
use librashader_presets::ShaderPassConfig;
use librashader_presets::ShaderPassMeta;
use librashader_reflect::reflect::semantics::{
BindingStage, MemberOffset, TextureBinding, UniformBinding,
};
@ -34,7 +34,7 @@ pub struct FilterPass {
>,
pub uniform_bindings: FastHashMap<UniformBinding, MemberOffset>,
pub source: ShaderSource,
pub config: ShaderPassConfig,
pub meta: ShaderPassMeta,
pub graphics_pipeline: WgpuGraphicsPipeline,
}
@ -255,7 +255,7 @@ impl FilterPassMeta for FilterPass {
self.source.format
}
fn config(&self) -> &ShaderPassConfig {
&self.config
fn meta(&self) -> &ShaderPassMeta {
&self.meta
}
}

View file

@ -1,5 +1,5 @@
use librashader_common::ImageFormat;
use librashader_presets::ShaderPassConfig;
use librashader_presets::ShaderPassMeta;
/// Trait for metadata about a filter pass.
pub trait FilterPassMeta {
@ -7,13 +7,13 @@ pub trait FilterPassMeta {
fn framebuffer_format(&self) -> ImageFormat;
/// Gets a reference to the filter pass config.
fn config(&self) -> &ShaderPassConfig;
fn meta(&self) -> &ShaderPassMeta;
/// Gets the format of the filter pass framebuffer.
#[inline(always)]
fn get_format(&self) -> ImageFormat {
let fb_format = self.framebuffer_format();
if let Some(format) = self.config().get_format_override() {
if let Some(format) = self.meta().get_format_override() {
format
} else if fb_format == ImageFormat::Unknown {
ImageFormat::R8G8B8A8Unorm

View file

@ -212,10 +212,10 @@ where
while let Some((index, pass)) = iterator.next() {
let should_mipmap = iterator
.peek()
.map_or(false, |(_, p)| p.config().mipmap_input);
.map_or(false, |(_, p)| p.meta().mipmap_input);
let next_size = output[index].scale(
pass.config().scaling.clone(),
pass.meta().scaling.clone(),
pass.get_format(),
&viewport_size,
&target_size,
@ -225,7 +225,7 @@ where
)?;
feedback[index].scale(
pass.config().scaling.clone(),
pass.meta().scaling.clone(),
pass.get_format(),
&viewport_size,
&target_size,