preset: add original
scaletype
As defined in https://github.com/libretro/RetroArch/pull/15937
This commit is contained in:
parent
4762055dc1
commit
3c3f024ef8
|
@ -63,6 +63,8 @@ pub enum ScaleType {
|
|||
Absolute,
|
||||
/// Scale by the size of the viewport.
|
||||
Viewport,
|
||||
/// Scale by the size of the original input quad.
|
||||
Original,
|
||||
}
|
||||
|
||||
/// The scaling factor for framebuffer scaling.
|
||||
|
@ -119,6 +121,7 @@ impl FromStr for ScaleType {
|
|||
"source" => Ok(ScaleType::Input),
|
||||
"viewport" => Ok(ScaleType::Viewport),
|
||||
"absolute" => Ok(ScaleType::Absolute),
|
||||
"original" => Ok(ScaleType::Original),
|
||||
_ => Err(ParsePresetError::InvalidScaleType(s.to_string())),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -441,6 +441,7 @@ impl FilterChainD3D11 {
|
|||
OwnedImage::scale_framebuffers(
|
||||
source.size(),
|
||||
viewport.output.size,
|
||||
original.view.size,
|
||||
&mut self.output_framebuffers,
|
||||
&mut self.feedback_framebuffers,
|
||||
passes,
|
||||
|
|
|
@ -69,9 +69,10 @@ impl OwnedImage {
|
|||
format: ImageFormat,
|
||||
viewport_size: &Size<u32>,
|
||||
source_size: &Size<u32>,
|
||||
original_size: &Size<u32>,
|
||||
should_mipmap: bool,
|
||||
) -> error::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
|
||||
|| (should_mipmap && self.max_mipmap == 1)
|
||||
|
@ -255,9 +256,17 @@ impl ScaleFramebuffer for OwnedImage {
|
|||
format: ImageFormat,
|
||||
viewport_size: &Size<u32>,
|
||||
source_size: &Size<u32>,
|
||||
original_size: &Size<u32>,
|
||||
should_mipmap: bool,
|
||||
_context: &Self::Context,
|
||||
) -> Result<Size<u32>, Self::Error> {
|
||||
self.scale(scaling, format, viewport_size, source_size, should_mipmap)
|
||||
self.scale(
|
||||
scaling,
|
||||
format,
|
||||
viewport_size,
|
||||
source_size,
|
||||
original_size,
|
||||
should_mipmap,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -668,6 +668,7 @@ impl FilterChainD3D12 {
|
|||
OwnedImage::scale_framebuffers(
|
||||
source.size(),
|
||||
viewport.output.size,
|
||||
original.size(),
|
||||
&mut self.output_framebuffers,
|
||||
&mut self.feedback_framebuffers,
|
||||
passes,
|
||||
|
|
|
@ -319,9 +319,10 @@ impl OwnedImage {
|
|||
format: ImageFormat,
|
||||
viewport_size: &Size<u32>,
|
||||
source_size: &Size<u32>,
|
||||
original_size: &Size<u32>,
|
||||
mipmap: bool,
|
||||
) -> error::Result<Size<u32>> {
|
||||
let size = source_size.scale_viewport(scaling, *viewport_size);
|
||||
let size = source_size.scale_viewport(scaling, *viewport_size, *original_size);
|
||||
let format = Self::get_format_support(&self.device, format.into(), mipmap);
|
||||
|
||||
if self.size != size
|
||||
|
@ -346,9 +347,17 @@ impl ScaleFramebuffer for OwnedImage {
|
|||
format: ImageFormat,
|
||||
viewport_size: &Size<u32>,
|
||||
source_size: &Size<u32>,
|
||||
original_size: &Size<u32>,
|
||||
should_mipmap: bool,
|
||||
_context: &Self::Context,
|
||||
) -> Result<Size<u32>, Self::Error> {
|
||||
self.scale(scaling, format, viewport_size, source_size, should_mipmap)
|
||||
self.scale(
|
||||
scaling,
|
||||
format,
|
||||
viewport_size,
|
||||
source_size,
|
||||
original_size,
|
||||
should_mipmap,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -321,6 +321,7 @@ impl<T: GLInterface> FilterChainImpl<T> {
|
|||
<GLFramebuffer as ScaleFramebuffer<T::FramebufferInterface>>::scale_framebuffers(
|
||||
source.image.size,
|
||||
viewport.output.size,
|
||||
original.image.size,
|
||||
&mut self.output_framebuffers,
|
||||
&mut self.feedback_framebuffers,
|
||||
passes,
|
||||
|
|
|
@ -53,9 +53,18 @@ impl GLFramebuffer {
|
|||
format: ImageFormat,
|
||||
viewport: &Size<u32>,
|
||||
source_size: &Size<u32>,
|
||||
original_size: &Size<u32>,
|
||||
mipmap: bool,
|
||||
) -> Result<Size<u32>> {
|
||||
T::scale(self, scaling, format, viewport, source_size, mipmap)
|
||||
T::scale(
|
||||
self,
|
||||
scaling,
|
||||
format,
|
||||
viewport,
|
||||
source_size,
|
||||
original_size,
|
||||
mipmap,
|
||||
)
|
||||
}
|
||||
|
||||
pub(crate) fn copy_from<T: FramebufferInterface>(&mut self, image: &GLImage) -> Result<()> {
|
||||
|
@ -103,9 +112,17 @@ impl<T: FramebufferInterface> ScaleFramebuffer<T> for GLFramebuffer {
|
|||
format: ImageFormat,
|
||||
viewport_size: &Size<u32>,
|
||||
source_size: &Size<u32>,
|
||||
original_size: &Size<u32>,
|
||||
should_mipmap: bool,
|
||||
_context: &Self::Context,
|
||||
) -> Result<Size<u32>> {
|
||||
self.scale::<T>(scaling, format, viewport_size, source_size, should_mipmap)
|
||||
self.scale::<T>(
|
||||
scaling,
|
||||
format,
|
||||
viewport_size,
|
||||
source_size,
|
||||
original_size,
|
||||
should_mipmap,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,13 +39,14 @@ impl FramebufferInterface for Gl3Framebuffer {
|
|||
format: ImageFormat,
|
||||
viewport_size: &Size<u32>,
|
||||
source_size: &Size<u32>,
|
||||
original_size: &Size<u32>,
|
||||
mipmap: bool,
|
||||
) -> Result<Size<u32>> {
|
||||
if fb.is_raw {
|
||||
return Ok(fb.size);
|
||||
}
|
||||
|
||||
let size = source_size.scale_viewport(scaling, *viewport_size);
|
||||
let size = source_size.scale_viewport(scaling, *viewport_size, *original_size);
|
||||
|
||||
if fb.size != size || (mipmap && fb.max_levels == 1) || (!mipmap && fb.max_levels != 1) {
|
||||
fb.size = size;
|
||||
|
|
|
@ -37,13 +37,14 @@ impl FramebufferInterface for Gl46Framebuffer {
|
|||
format: ImageFormat,
|
||||
viewport_size: &Size<u32>,
|
||||
source_size: &Size<u32>,
|
||||
original_size: &Size<u32>,
|
||||
mipmap: bool,
|
||||
) -> Result<Size<u32>> {
|
||||
if fb.is_raw {
|
||||
return Ok(fb.size);
|
||||
}
|
||||
|
||||
let size = source_size.scale_viewport(scaling, *viewport_size);
|
||||
let size = source_size.scale_viewport(scaling, *viewport_size, *original_size);
|
||||
|
||||
if fb.size != size || (mipmap && fb.max_levels == 1) || (!mipmap && fb.max_levels != 1) {
|
||||
fb.size = size;
|
||||
|
|
|
@ -52,6 +52,7 @@ pub(crate) trait FramebufferInterface {
|
|||
format: ImageFormat,
|
||||
viewport_size: &Size<u32>,
|
||||
source_size: &Size<u32>,
|
||||
original_size: &Size<u32>,
|
||||
mipmap: bool,
|
||||
) -> Result<Size<u32>>;
|
||||
fn clear<const REBIND: bool>(fb: &GLFramebuffer);
|
||||
|
|
|
@ -640,6 +640,7 @@ impl FilterChainVulkan {
|
|||
OwnedImage::scale_framebuffers_with_context(
|
||||
source.image.size,
|
||||
viewport.output.size,
|
||||
original.image.size,
|
||||
&mut self.output_framebuffers,
|
||||
&mut self.feedback_framebuffers,
|
||||
passes,
|
||||
|
|
|
@ -122,10 +122,11 @@ impl OwnedImage {
|
|||
format: ImageFormat,
|
||||
viewport_size: &Size<u32>,
|
||||
source_size: &Size<u32>,
|
||||
original_size: &Size<u32>,
|
||||
mipmap: bool,
|
||||
layout: Option<OwnedImageLayout>,
|
||||
) -> error::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.image.size != size
|
||||
|| (mipmap && self.max_miplevels == 1)
|
||||
|| (!mipmap && self.max_miplevels != 1)
|
||||
|
@ -519,6 +520,7 @@ impl ScaleFramebuffer for OwnedImage {
|
|||
format: ImageFormat,
|
||||
viewport_size: &Size<u32>,
|
||||
source_size: &Size<u32>,
|
||||
original_size: &Size<u32>,
|
||||
should_mipmap: bool,
|
||||
context: &Self::Context,
|
||||
) -> Result<Size<u32>, Self::Error> {
|
||||
|
@ -527,6 +529,7 @@ impl ScaleFramebuffer for OwnedImage {
|
|||
format,
|
||||
viewport_size,
|
||||
source_size,
|
||||
original_size,
|
||||
should_mipmap,
|
||||
context.clone(),
|
||||
)
|
||||
|
|
|
@ -387,6 +387,7 @@ impl FilterChainWgpu {
|
|||
OwnedImage::scale_framebuffers_with_context(
|
||||
source.image.size().into(),
|
||||
viewport.output.size,
|
||||
original.image.size().into(),
|
||||
&mut self.output_framebuffers,
|
||||
&mut self.feedback_framebuffers,
|
||||
passes,
|
||||
|
|
|
@ -81,9 +81,10 @@ impl OwnedImage {
|
|||
format: ImageFormat,
|
||||
viewport_size: &Size<u32>,
|
||||
source_size: &Size<u32>,
|
||||
original_size: &Size<u32>,
|
||||
mipmap: bool,
|
||||
) -> Size<u32> {
|
||||
let size = source_size.scale_viewport(scaling, *viewport_size);
|
||||
let size = source_size.scale_viewport(scaling, *viewport_size, *original_size);
|
||||
let format: Option<wgpu::TextureFormat> = format.into();
|
||||
let format = format.unwrap_or(wgpu::TextureFormat::Rgba8Unorm);
|
||||
|
||||
|
@ -144,9 +145,17 @@ impl ScaleFramebuffer for OwnedImage {
|
|||
format: ImageFormat,
|
||||
viewport_size: &Size<u32>,
|
||||
source_size: &Size<u32>,
|
||||
original_size: &Size<u32>,
|
||||
should_mipmap: bool,
|
||||
_context: &Self::Context,
|
||||
) -> Result<Size<u32>, Self::Error> {
|
||||
Ok(self.scale(scaling, format, viewport_size, source_size, should_mipmap))
|
||||
Ok(self.scale(
|
||||
scaling,
|
||||
format,
|
||||
viewport_size,
|
||||
source_size,
|
||||
original_size,
|
||||
should_mipmap,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ where
|
|||
f32: AsPrimitive<T>,
|
||||
{
|
||||
/// Produce a `Size<T>` scaled with the input scaling options.
|
||||
fn scale_viewport(self, scaling: Scale2D, viewport: Size<T>) -> Size<T>;
|
||||
fn scale_viewport(self, scaling: Scale2D, viewport: Size<T>, original: Size<T>) -> Size<T>;
|
||||
}
|
||||
|
||||
impl<T> ViewportSize<T> for Size<T>
|
||||
|
@ -20,12 +20,12 @@ where
|
|||
T: Mul<ScaleFactor, Output = f32> + Copy + 'static,
|
||||
f32: AsPrimitive<T>,
|
||||
{
|
||||
fn scale_viewport(self, scaling: Scale2D, viewport: Size<T>) -> Size<T>
|
||||
fn scale_viewport(self, scaling: Scale2D, viewport: Size<T>, original: Size<T>) -> Size<T>
|
||||
where
|
||||
T: Mul<ScaleFactor, Output = f32> + Copy + 'static,
|
||||
f32: AsPrimitive<T>,
|
||||
{
|
||||
scaling::scale(scaling, self, viewport)
|
||||
scaling::scale(scaling, self, viewport, original)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ impl MipmapSize<u32> for Size<u32> {
|
|||
}
|
||||
}
|
||||
|
||||
fn scale<T>(scaling: Scale2D, source: Size<T>, viewport: Size<T>) -> Size<T>
|
||||
fn scale<T>(scaling: Scale2D, source: Size<T>, viewport: Size<T>, original: Size<T>) -> Size<T>
|
||||
where
|
||||
T: Mul<ScaleFactor, Output = f32> + Copy + 'static,
|
||||
f32: AsPrimitive<T>,
|
||||
|
@ -75,6 +75,10 @@ where
|
|||
scale_type: ScaleType::Viewport,
|
||||
factor,
|
||||
} => viewport.width * factor,
|
||||
Scaling {
|
||||
scale_type: ScaleType::Original,
|
||||
factor,
|
||||
} => original.width * factor,
|
||||
};
|
||||
|
||||
let height = match scaling.y {
|
||||
|
@ -90,6 +94,10 @@ where
|
|||
scale_type: ScaleType::Viewport,
|
||||
factor,
|
||||
} => viewport.height * factor,
|
||||
Scaling {
|
||||
scale_type: ScaleType::Original,
|
||||
factor,
|
||||
} => original.height * factor,
|
||||
};
|
||||
|
||||
Size {
|
||||
|
@ -109,6 +117,7 @@ pub trait ScaleFramebuffer<T = ()> {
|
|||
format: ImageFormat,
|
||||
viewport_size: &Size<u32>,
|
||||
source_size: &Size<u32>,
|
||||
original_size: &Size<u32>,
|
||||
should_mipmap: bool,
|
||||
context: &Self::Context,
|
||||
) -> Result<Size<u32>, Self::Error>;
|
||||
|
@ -118,6 +127,7 @@ pub trait ScaleFramebuffer<T = ()> {
|
|||
fn scale_framebuffers<P>(
|
||||
source_size: Size<u32>,
|
||||
viewport_size: Size<u32>,
|
||||
original_size: Size<u32>,
|
||||
output: &mut [Self],
|
||||
feedback: &mut [Self],
|
||||
passes: &[P],
|
||||
|
@ -131,6 +141,7 @@ pub trait ScaleFramebuffer<T = ()> {
|
|||
scale_framebuffers_with_context_callback::<T, Self, Self::Error, Self::Context, _>(
|
||||
source_size,
|
||||
viewport_size,
|
||||
original_size,
|
||||
output,
|
||||
feedback,
|
||||
passes,
|
||||
|
@ -144,6 +155,7 @@ pub trait ScaleFramebuffer<T = ()> {
|
|||
fn scale_framebuffers_with_context<P>(
|
||||
source_size: Size<u32>,
|
||||
viewport_size: Size<u32>,
|
||||
original_size: Size<u32>,
|
||||
output: &mut [Self],
|
||||
feedback: &mut [Self],
|
||||
passes: &[P],
|
||||
|
@ -157,6 +169,7 @@ pub trait ScaleFramebuffer<T = ()> {
|
|||
scale_framebuffers_with_context_callback::<T, Self, Self::Error, Self::Context, _>(
|
||||
source_size,
|
||||
viewport_size,
|
||||
original_size,
|
||||
output,
|
||||
feedback,
|
||||
passes,
|
||||
|
@ -172,6 +185,7 @@ pub trait ScaleFramebuffer<T = ()> {
|
|||
fn scale_framebuffers_with_context_callback<T, F, E, C, P>(
|
||||
source_size: Size<u32>,
|
||||
viewport_size: Size<u32>,
|
||||
original_size: Size<u32>,
|
||||
output: &mut [F],
|
||||
feedback: &mut [F],
|
||||
passes: &[P],
|
||||
|
@ -195,6 +209,7 @@ where
|
|||
pass.get_format(),
|
||||
&viewport_size,
|
||||
&target_size,
|
||||
&original_size,
|
||||
should_mipmap,
|
||||
context,
|
||||
)?;
|
||||
|
@ -204,6 +219,7 @@ where
|
|||
pass.get_format(),
|
||||
&viewport_size,
|
||||
&target_size,
|
||||
&original_size,
|
||||
should_mipmap,
|
||||
context,
|
||||
)?;
|
||||
|
|
Loading…
Reference in a new issue