rt(mtl): update with new semantics
This commit is contained in:
parent
325e39063a
commit
30dfa1a655
4 changed files with 27 additions and 23 deletions
|
@ -59,6 +59,7 @@ pub struct FilterChainMetal {
|
||||||
feedback_framebuffers: Box<[OwnedTexture]>,
|
feedback_framebuffers: Box<[OwnedTexture]>,
|
||||||
history_framebuffers: VecDeque<OwnedTexture>,
|
history_framebuffers: VecDeque<OwnedTexture>,
|
||||||
disable_mipmaps: bool,
|
disable_mipmaps: bool,
|
||||||
|
default_options: FrameOptionsMetal
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Debug for FilterChainMetal {
|
impl Debug for FilterChainMetal {
|
||||||
|
@ -309,6 +310,7 @@ impl FilterChainMetal {
|
||||||
feedback_framebuffers,
|
feedback_framebuffers,
|
||||||
history_framebuffers,
|
history_framebuffers,
|
||||||
disable_mipmaps: options.map(|f| f.force_no_mipmaps).unwrap_or(false),
|
disable_mipmaps: options.map(|f| f.force_no_mipmaps).unwrap_or(false),
|
||||||
|
default_options: Default::default(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -370,6 +372,7 @@ impl FilterChainMetal {
|
||||||
OwnedTexture::scale_framebuffers_with_context(
|
OwnedTexture::scale_framebuffers_with_context(
|
||||||
get_texture_size(&source.texture).into(),
|
get_texture_size(&source.texture).into(),
|
||||||
get_texture_size(viewport.output),
|
get_texture_size(viewport.output),
|
||||||
|
get_texture_size(&original.texture).into(),
|
||||||
&mut self.output_framebuffers,
|
&mut self.output_framebuffers,
|
||||||
&mut self.feedback_framebuffers,
|
&mut self.feedback_framebuffers,
|
||||||
passes,
|
passes,
|
||||||
|
@ -389,7 +392,7 @@ impl FilterChainMetal {
|
||||||
|
|
||||||
let passes_len = passes.len();
|
let passes_len = passes.len();
|
||||||
let (pass, last) = passes.split_at_mut(passes_len - 1);
|
let (pass, last) = passes.split_at_mut(passes_len - 1);
|
||||||
let frame_direction = options.map_or(1, |f| f.frame_direction);
|
let options = options.unwrap_or(&self.default_options);
|
||||||
|
|
||||||
let mipmapper = cmd_buffer
|
let mipmapper = cmd_buffer
|
||||||
.blitCommandEncoder()
|
.blitCommandEncoder()
|
||||||
|
@ -407,7 +410,7 @@ impl FilterChainMetal {
|
||||||
index,
|
index,
|
||||||
&self.common,
|
&self.common,
|
||||||
pass.config.get_frame_count(frame_count),
|
pass.config.get_frame_count(frame_count),
|
||||||
frame_direction,
|
options,
|
||||||
viewport,
|
viewport,
|
||||||
&original,
|
&original,
|
||||||
&source,
|
&source,
|
||||||
|
@ -445,7 +448,7 @@ impl FilterChainMetal {
|
||||||
passes_len - 1,
|
passes_len - 1,
|
||||||
&self.common,
|
&self.common,
|
||||||
pass.config.get_frame_count(frame_count),
|
pass.config.get_frame_count(frame_count),
|
||||||
frame_direction,
|
options,
|
||||||
viewport,
|
viewport,
|
||||||
&original,
|
&original,
|
||||||
&source,
|
&source,
|
||||||
|
|
|
@ -10,13 +10,14 @@ use librashader_preprocess::ShaderSource;
|
||||||
use librashader_presets::ShaderPassConfig;
|
use librashader_presets::ShaderPassConfig;
|
||||||
use librashader_reflect::reflect::semantics::{MemberOffset, TextureBinding, UniformBinding};
|
use librashader_reflect::reflect::semantics::{MemberOffset, TextureBinding, UniformBinding};
|
||||||
use librashader_reflect::reflect::ShaderReflection;
|
use librashader_reflect::reflect::ShaderReflection;
|
||||||
use librashader_runtime::binding::{BindSemantics, TextureInput};
|
use librashader_runtime::binding::{BindSemantics, TextureInput, UniformInputs};
|
||||||
use librashader_runtime::filter_pass::FilterPassMeta;
|
use librashader_runtime::filter_pass::FilterPassMeta;
|
||||||
use librashader_runtime::quad::QuadType;
|
use librashader_runtime::quad::QuadType;
|
||||||
use librashader_runtime::render_target::RenderTarget;
|
use librashader_runtime::render_target::RenderTarget;
|
||||||
use librashader_runtime::uniforms::{NoUniformBinder, UniformStorage};
|
use librashader_runtime::uniforms::{NoUniformBinder, UniformStorage};
|
||||||
use objc2::runtime::ProtocolObject;
|
use objc2::runtime::ProtocolObject;
|
||||||
use rustc_hash::FxHashMap;
|
use rustc_hash::FxHashMap;
|
||||||
|
use crate::options::FrameOptionsMetal;
|
||||||
|
|
||||||
impl TextureInput for InputTexture {
|
impl TextureInput for InputTexture {
|
||||||
fn size(&self) -> Size<u32> {
|
fn size(&self) -> Size<u32> {
|
||||||
|
@ -66,7 +67,7 @@ impl FilterPass {
|
||||||
pass_index: usize,
|
pass_index: usize,
|
||||||
parent: &FilterCommon,
|
parent: &FilterCommon,
|
||||||
frame_count: u32,
|
frame_count: u32,
|
||||||
frame_direction: i32,
|
options: &FrameOptionsMetal,
|
||||||
viewport: &Viewport<&ProtocolObject<dyn MTLTexture>>,
|
viewport: &Viewport<&ProtocolObject<dyn MTLTexture>>,
|
||||||
original: &InputTexture,
|
original: &InputTexture,
|
||||||
source: &InputTexture,
|
source: &InputTexture,
|
||||||
|
@ -80,7 +81,7 @@ impl FilterPass {
|
||||||
parent,
|
parent,
|
||||||
output.mvp,
|
output.mvp,
|
||||||
frame_count,
|
frame_count,
|
||||||
frame_direction,
|
options,
|
||||||
get_texture_size(output.output),
|
get_texture_size(output.output),
|
||||||
get_texture_size(viewport.output),
|
get_texture_size(viewport.output),
|
||||||
original,
|
original,
|
||||||
|
@ -120,7 +121,7 @@ impl FilterPass {
|
||||||
parent: &FilterCommon,
|
parent: &FilterCommon,
|
||||||
mvp: &[f32; 16],
|
mvp: &[f32; 16],
|
||||||
frame_count: u32,
|
frame_count: u32,
|
||||||
frame_direction: i32,
|
options: &FrameOptionsMetal,
|
||||||
fb_size: Size<u32>,
|
fb_size: Size<u32>,
|
||||||
viewport_size: Size<u32>,
|
viewport_size: Size<u32>,
|
||||||
original: &InputTexture,
|
original: &InputTexture,
|
||||||
|
@ -132,11 +133,16 @@ impl FilterPass {
|
||||||
&parent.samplers,
|
&parent.samplers,
|
||||||
&mut self.uniform_storage,
|
&mut self.uniform_storage,
|
||||||
&mut renderpass,
|
&mut renderpass,
|
||||||
mvp,
|
UniformInputs {
|
||||||
frame_count,
|
mvp,
|
||||||
frame_direction,
|
frame_count,
|
||||||
fb_size,
|
rotation: options.rotation,
|
||||||
viewport_size,
|
total_subframes: options.total_subframes,
|
||||||
|
current_subframe: options.current_subframe,
|
||||||
|
frame_direction: options.frame_direction,
|
||||||
|
framebuffer_size: fb_size,
|
||||||
|
viewport_size,
|
||||||
|
},
|
||||||
original,
|
original,
|
||||||
source,
|
source,
|
||||||
&self.uniform_bindings,
|
&self.uniform_bindings,
|
||||||
|
|
|
@ -1,15 +1,7 @@
|
||||||
//! Metal shader runtime options.
|
//! Metal shader runtime options.
|
||||||
|
|
||||||
/// Options for each Vulkan shader frame.
|
use librashader_runtime::impl_default_frame_options;
|
||||||
#[repr(C)]
|
impl_default_frame_options!(FrameOptionsMetal);
|
||||||
#[derive(Default, Debug, Clone)]
|
|
||||||
pub struct FrameOptionsMetal {
|
|
||||||
/// 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,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Options for filter chain creation.
|
/// Options for filter chain creation.
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
|
|
|
@ -92,9 +92,10 @@ impl OwnedTexture {
|
||||||
format: MTLPixelFormat,
|
format: MTLPixelFormat,
|
||||||
viewport_size: &Size<u32>,
|
viewport_size: &Size<u32>,
|
||||||
source_size: &Size<u32>,
|
source_size: &Size<u32>,
|
||||||
|
original_size: &Size<u32>,
|
||||||
mipmap: bool,
|
mipmap: bool,
|
||||||
) -> Result<Size<u32>> {
|
) -> Result<Size<u32>> {
|
||||||
let size = source_size.scale_viewport(scaling, *viewport_size);
|
let size = source_size.scale_viewport(scaling, *viewport_size, *original_size);
|
||||||
|
|
||||||
if self.size != size
|
if self.size != size
|
||||||
|| (mipmap && self.max_miplevels == 1)
|
|| (mipmap && self.max_miplevels == 1)
|
||||||
|
@ -155,6 +156,7 @@ impl ScaleFramebuffer for OwnedTexture {
|
||||||
format: ImageFormat,
|
format: ImageFormat,
|
||||||
viewport_size: &Size<u32>,
|
viewport_size: &Size<u32>,
|
||||||
source_size: &Size<u32>,
|
source_size: &Size<u32>,
|
||||||
|
original_size: &Size<u32>,
|
||||||
should_mipmap: bool,
|
should_mipmap: bool,
|
||||||
context: &Self::Context,
|
context: &Self::Context,
|
||||||
) -> std::result::Result<Size<u32>, Self::Error> {
|
) -> std::result::Result<Size<u32>, Self::Error> {
|
||||||
|
@ -164,6 +166,7 @@ impl ScaleFramebuffer for OwnedTexture {
|
||||||
format.into(),
|
format.into(),
|
||||||
viewport_size,
|
viewport_size,
|
||||||
source_size,
|
source_size,
|
||||||
|
original_size,
|
||||||
should_mipmap,
|
should_mipmap,
|
||||||
)?)
|
)?)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue