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]>,
|
||||
history_framebuffers: VecDeque<OwnedTexture>,
|
||||
disable_mipmaps: bool,
|
||||
default_options: FrameOptionsMetal
|
||||
}
|
||||
|
||||
impl Debug for FilterChainMetal {
|
||||
|
@ -309,6 +310,7 @@ impl FilterChainMetal {
|
|||
feedback_framebuffers,
|
||||
history_framebuffers,
|
||||
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(
|
||||
get_texture_size(&source.texture).into(),
|
||||
get_texture_size(viewport.output),
|
||||
get_texture_size(&original.texture).into(),
|
||||
&mut self.output_framebuffers,
|
||||
&mut self.feedback_framebuffers,
|
||||
passes,
|
||||
|
@ -389,7 +392,7 @@ impl FilterChainMetal {
|
|||
|
||||
let passes_len = passes.len();
|
||||
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
|
||||
.blitCommandEncoder()
|
||||
|
@ -407,7 +410,7 @@ impl FilterChainMetal {
|
|||
index,
|
||||
&self.common,
|
||||
pass.config.get_frame_count(frame_count),
|
||||
frame_direction,
|
||||
options,
|
||||
viewport,
|
||||
&original,
|
||||
&source,
|
||||
|
@ -445,7 +448,7 @@ impl FilterChainMetal {
|
|||
passes_len - 1,
|
||||
&self.common,
|
||||
pass.config.get_frame_count(frame_count),
|
||||
frame_direction,
|
||||
options,
|
||||
viewport,
|
||||
&original,
|
||||
&source,
|
||||
|
|
|
@ -10,13 +10,14 @@ use librashader_preprocess::ShaderSource;
|
|||
use librashader_presets::ShaderPassConfig;
|
||||
use librashader_reflect::reflect::semantics::{MemberOffset, TextureBinding, UniformBinding};
|
||||
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::quad::QuadType;
|
||||
use librashader_runtime::render_target::RenderTarget;
|
||||
use librashader_runtime::uniforms::{NoUniformBinder, UniformStorage};
|
||||
use objc2::runtime::ProtocolObject;
|
||||
use rustc_hash::FxHashMap;
|
||||
use crate::options::FrameOptionsMetal;
|
||||
|
||||
impl TextureInput for InputTexture {
|
||||
fn size(&self) -> Size<u32> {
|
||||
|
@ -66,7 +67,7 @@ impl FilterPass {
|
|||
pass_index: usize,
|
||||
parent: &FilterCommon,
|
||||
frame_count: u32,
|
||||
frame_direction: i32,
|
||||
options: &FrameOptionsMetal,
|
||||
viewport: &Viewport<&ProtocolObject<dyn MTLTexture>>,
|
||||
original: &InputTexture,
|
||||
source: &InputTexture,
|
||||
|
@ -80,7 +81,7 @@ impl FilterPass {
|
|||
parent,
|
||||
output.mvp,
|
||||
frame_count,
|
||||
frame_direction,
|
||||
options,
|
||||
get_texture_size(output.output),
|
||||
get_texture_size(viewport.output),
|
||||
original,
|
||||
|
@ -120,7 +121,7 @@ impl FilterPass {
|
|||
parent: &FilterCommon,
|
||||
mvp: &[f32; 16],
|
||||
frame_count: u32,
|
||||
frame_direction: i32,
|
||||
options: &FrameOptionsMetal,
|
||||
fb_size: Size<u32>,
|
||||
viewport_size: Size<u32>,
|
||||
original: &InputTexture,
|
||||
|
@ -132,11 +133,16 @@ impl FilterPass {
|
|||
&parent.samplers,
|
||||
&mut self.uniform_storage,
|
||||
&mut renderpass,
|
||||
mvp,
|
||||
frame_count,
|
||||
frame_direction,
|
||||
fb_size,
|
||||
viewport_size,
|
||||
UniformInputs {
|
||||
mvp,
|
||||
frame_count,
|
||||
rotation: options.rotation,
|
||||
total_subframes: options.total_subframes,
|
||||
current_subframe: options.current_subframe,
|
||||
frame_direction: options.frame_direction,
|
||||
framebuffer_size: fb_size,
|
||||
viewport_size,
|
||||
},
|
||||
original,
|
||||
source,
|
||||
&self.uniform_bindings,
|
||||
|
|
|
@ -1,15 +1,7 @@
|
|||
//! Metal shader runtime options.
|
||||
|
||||
/// Options for each Vulkan shader frame.
|
||||
#[repr(C)]
|
||||
#[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,
|
||||
}
|
||||
use librashader_runtime::impl_default_frame_options;
|
||||
impl_default_frame_options!(FrameOptionsMetal);
|
||||
|
||||
/// Options for filter chain creation.
|
||||
#[repr(C)]
|
||||
|
|
|
@ -92,9 +92,10 @@ impl OwnedTexture {
|
|||
format: MTLPixelFormat,
|
||||
viewport_size: &Size<u32>,
|
||||
source_size: &Size<u32>,
|
||||
original_size: &Size<u32>,
|
||||
mipmap: bool,
|
||||
) -> 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
|
||||
|| (mipmap && self.max_miplevels == 1)
|
||||
|
@ -155,6 +156,7 @@ impl ScaleFramebuffer for OwnedTexture {
|
|||
format: ImageFormat,
|
||||
viewport_size: &Size<u32>,
|
||||
source_size: &Size<u32>,
|
||||
original_size: &Size<u32>,
|
||||
should_mipmap: bool,
|
||||
context: &Self::Context,
|
||||
) -> std::result::Result<Size<u32>, Self::Error> {
|
||||
|
@ -164,6 +166,7 @@ impl ScaleFramebuffer for OwnedTexture {
|
|||
format.into(),
|
||||
viewport_size,
|
||||
source_size,
|
||||
original_size,
|
||||
should_mipmap,
|
||||
)?)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue