cli(render): make frame inclusive to ensure correct feedback and history behaviour
This commit is contained in:
parent
84e78f4e48
commit
da53c3df59
74
CLI.md
74
CLI.md
|
@ -38,11 +38,6 @@ Render a shader preset against an image
|
||||||
Usage: librashader-cli render [OPTIONS] --preset <PRESET> --image <IMAGE> --out <OUT> --runtime <RUNTIME>
|
Usage: librashader-cli render [OPTIONS] --preset <PRESET> --image <IMAGE> --out <OUT> --runtime <RUNTIME>
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-f, --frame <FRAME>
|
|
||||||
The frame to render
|
|
||||||
|
|
||||||
[default: 60]
|
|
||||||
|
|
||||||
-p, --preset <PRESET>
|
-p, --preset <PRESET>
|
||||||
The path to the shader preset to load
|
The path to the shader preset to load
|
||||||
|
|
||||||
|
@ -51,17 +46,44 @@ Options:
|
||||||
|
|
||||||
For example, CONTENT-DIR=MyVerticalGames,GAME=mspacman
|
For example, CONTENT-DIR=MyVerticalGames,GAME=mspacman
|
||||||
|
|
||||||
|
-f, --frame <FRAME>
|
||||||
|
The frame to render.
|
||||||
|
|
||||||
|
The renderer will run up to the number of frames specified here to ensure feedback and history.
|
||||||
|
|
||||||
|
[default: 0]
|
||||||
|
|
||||||
--params <PARAMS>...
|
--params <PARAMS>...
|
||||||
Parameters to pass to the shader preset, comma separated with equals signs.
|
Parameters to pass to the shader preset, comma separated with equals signs.
|
||||||
|
|
||||||
For example, crt_gamma=2.5,halation_weight=0.001
|
For example, crt_gamma=2.5,halation_weight=0.001
|
||||||
|
|
||||||
--passes-enabled <PASSES_ENABLED>
|
--passes-enabled <PASSES_ENABLED>
|
||||||
Set the number of passes enabled for the preset
|
Set the number of passes enabled for the preset
|
||||||
|
|
||||||
-i, --image <IMAGE>
|
-i, --image <IMAGE>
|
||||||
The path to the input image
|
The path to the input image
|
||||||
|
|
||||||
|
--frame-direction <FRAME_DIRECTION>
|
||||||
|
The direction of rendering. -1 indicates that the frames are played in reverse order
|
||||||
|
|
||||||
|
[default: 1]
|
||||||
|
|
||||||
|
--rotation <ROTATION>
|
||||||
|
The rotation of the output. 0 = 0deg, 1 = 90deg, 2 = 180deg, 3 = 270deg
|
||||||
|
|
||||||
|
[default: 0]
|
||||||
|
|
||||||
|
--total-subframes <TOTAL_SUBFRAMES>
|
||||||
|
The total number of subframes ran. Default is 1
|
||||||
|
|
||||||
|
[default: 1]
|
||||||
|
|
||||||
|
--current-subframe <CURRENT_SUBFRAME>
|
||||||
|
The current sub frame. Default is 1
|
||||||
|
|
||||||
|
[default: 1]
|
||||||
|
|
||||||
-o, --out <OUT>
|
-o, --out <OUT>
|
||||||
The path to the output image
|
The path to the output image
|
||||||
|
|
||||||
|
@ -70,11 +92,12 @@ Options:
|
||||||
-r, --runtime <RUNTIME>
|
-r, --runtime <RUNTIME>
|
||||||
The runtime to use to render the shader preset
|
The runtime to use to render the shader preset
|
||||||
|
|
||||||
[possible values: opengl3, opengl4, vulkan, wgpu, d3d9, d3d11, d3d12]
|
[possible values: opengl3, opengl4, vulkan, wgpu, d3d9, d3d11, d3d12, metal]
|
||||||
|
|
||||||
-h, --help
|
-h, --help
|
||||||
Print help (see a summary with '-h')
|
Print help (see a summary with '-h')
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
The `render` command can be used to apply a shader preset to an image. The available runtimes will depend on the platform
|
The `render` command can be used to apply a shader preset to an image. The available runtimes will depend on the platform
|
||||||
|
@ -99,11 +122,6 @@ Compare two runtimes and get a similarity score between the two runtimes renderi
|
||||||
Usage: librashader-cli compare [OPTIONS] --preset <PRESET> --image <IMAGE> --left <LEFT> --right <RIGHT>
|
Usage: librashader-cli compare [OPTIONS] --preset <PRESET> --image <IMAGE> --left <LEFT> --right <RIGHT>
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-f, --frame <FRAME>
|
|
||||||
The frame to render
|
|
||||||
|
|
||||||
[default: 60]
|
|
||||||
|
|
||||||
-p, --preset <PRESET>
|
-p, --preset <PRESET>
|
||||||
The path to the shader preset to load
|
The path to the shader preset to load
|
||||||
|
|
||||||
|
@ -112,17 +130,44 @@ Options:
|
||||||
|
|
||||||
For example, CONTENT-DIR=MyVerticalGames,GAME=mspacman
|
For example, CONTENT-DIR=MyVerticalGames,GAME=mspacman
|
||||||
|
|
||||||
|
-f, --frame <FRAME>
|
||||||
|
The frame to render.
|
||||||
|
|
||||||
|
The renderer will run up to the number of frames specified here to ensure feedback and history.
|
||||||
|
|
||||||
|
[default: 0]
|
||||||
|
|
||||||
--params <PARAMS>...
|
--params <PARAMS>...
|
||||||
Parameters to pass to the shader preset, comma separated with equals signs.
|
Parameters to pass to the shader preset, comma separated with equals signs.
|
||||||
|
|
||||||
For example, crt_gamma=2.5,halation_weight=0.001
|
For example, crt_gamma=2.5,halation_weight=0.001
|
||||||
|
|
||||||
--passes-enabled <PASSES_ENABLED>
|
--passes-enabled <PASSES_ENABLED>
|
||||||
Set the number of passes enabled for the preset
|
Set the number of passes enabled for the preset
|
||||||
|
|
||||||
-i, --image <IMAGE>
|
-i, --image <IMAGE>
|
||||||
The path to the input image
|
The path to the input image
|
||||||
|
|
||||||
|
--frame-direction <FRAME_DIRECTION>
|
||||||
|
The direction of rendering. -1 indicates that the frames are played in reverse order
|
||||||
|
|
||||||
|
[default: 1]
|
||||||
|
|
||||||
|
--rotation <ROTATION>
|
||||||
|
The rotation of the output. 0 = 0deg, 1 = 90deg, 2 = 180deg, 3 = 270deg
|
||||||
|
|
||||||
|
[default: 0]
|
||||||
|
|
||||||
|
--total-subframes <TOTAL_SUBFRAMES>
|
||||||
|
The total number of subframes ran. Default is 1
|
||||||
|
|
||||||
|
[default: 1]
|
||||||
|
|
||||||
|
--current-subframe <CURRENT_SUBFRAME>
|
||||||
|
The current sub frame. Default is 1
|
||||||
|
|
||||||
|
[default: 1]
|
||||||
|
|
||||||
-l, --left <LEFT>
|
-l, --left <LEFT>
|
||||||
The runtime to compare against
|
The runtime to compare against
|
||||||
|
|
||||||
|
@ -140,6 +185,7 @@ Options:
|
||||||
|
|
||||||
-h, --help
|
-h, --help
|
||||||
Print help (see a summary with '-h')
|
Print help (see a summary with '-h')
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
The `compare` command can be used to get the similarity of two different runtimes, returning a similarity score and similarity image.
|
The `compare` command can be used to get the similarity of two different runtimes, returning a similarity score and similarity image.
|
||||||
|
|
|
@ -36,7 +36,10 @@ struct PresetArgs {
|
||||||
#[derive(clap::Args, Debug)]
|
#[derive(clap::Args, Debug)]
|
||||||
struct RenderArgs {
|
struct RenderArgs {
|
||||||
/// The frame to render.
|
/// The frame to render.
|
||||||
#[arg(short, long, default_value_t = 60)]
|
///
|
||||||
|
/// The renderer will run up to the number of frames specified here
|
||||||
|
/// to ensure feedback and history.
|
||||||
|
#[arg(short, long, default_value_t = 0)]
|
||||||
frame: usize,
|
frame: usize,
|
||||||
/// Parameters to pass to the shader preset, comma separated with equals signs.
|
/// Parameters to pass to the shader preset, comma separated with equals signs.
|
||||||
///
|
///
|
||||||
|
|
|
@ -36,22 +36,18 @@ impl RenderTest for Direct3D11 {
|
||||||
if let Some(setter) = param_setter {
|
if let Some(setter) = param_setter {
|
||||||
setter(filter_chain.parameters());
|
setter(filter_chain.parameters());
|
||||||
}
|
}
|
||||||
|
let viewport = Viewport::new_render_target_sized_origin(rtv, None)?;
|
||||||
|
let options = frame_options.map(|options| FrameOptions {
|
||||||
|
clear_history: options.clear_history,
|
||||||
|
frame_direction: options.frame_direction,
|
||||||
|
rotation: options.rotation,
|
||||||
|
total_subframes: options.total_subframes,
|
||||||
|
current_subframe: options.current_subframe,
|
||||||
|
});
|
||||||
|
|
||||||
filter_chain.frame(
|
for frame in 0..=frame_count {
|
||||||
None,
|
filter_chain.frame(None, &self.image_srv, &viewport, frame, options.as_ref())?;
|
||||||
&self.image_srv,
|
}
|
||||||
&Viewport::new_render_target_sized_origin(rtv, None)?,
|
|
||||||
frame_count,
|
|
||||||
frame_options
|
|
||||||
.map(|options| FrameOptions {
|
|
||||||
clear_history: options.clear_history,
|
|
||||||
frame_direction: options.frame_direction,
|
|
||||||
rotation: options.rotation,
|
|
||||||
total_subframes: options.total_subframes,
|
|
||||||
current_subframe: options.current_subframe,
|
|
||||||
})
|
|
||||||
.as_ref(),
|
|
||||||
)?;
|
|
||||||
|
|
||||||
let mut renderbuffer_desc = Default::default();
|
let mut renderbuffer_desc = Default::default();
|
||||||
renderbuffer.GetDesc(&mut renderbuffer_desc);
|
renderbuffer.GetDesc(&mut renderbuffer_desc);
|
||||||
|
|
|
@ -134,29 +134,33 @@ impl RenderTest for Direct3D12 {
|
||||||
self.device
|
self.device
|
||||||
.CreateRenderTargetView(&output_texture, None, *descriptor.as_ref());
|
.CreateRenderTargetView(&output_texture, None, *descriptor.as_ref());
|
||||||
|
|
||||||
filter_chain.frame(
|
let viewport = Viewport::new_render_target_sized_origin(
|
||||||
&cmd,
|
D3D12OutputView::new_from_raw(
|
||||||
self.texture.clone(),
|
*descriptor.as_ref(),
|
||||||
&Viewport::new_render_target_sized_origin(
|
self.image.size,
|
||||||
D3D12OutputView::new_from_raw(
|
DXGI_FORMAT_B8G8R8A8_UNORM,
|
||||||
*descriptor.as_ref(),
|
),
|
||||||
self.image.size,
|
None,
|
||||||
DXGI_FORMAT_B8G8R8A8_UNORM,
|
|
||||||
),
|
|
||||||
None,
|
|
||||||
)?,
|
|
||||||
frame_count,
|
|
||||||
frame_options
|
|
||||||
.map(|options| FrameOptions {
|
|
||||||
clear_history: options.clear_history,
|
|
||||||
frame_direction: options.frame_direction,
|
|
||||||
rotation: options.rotation,
|
|
||||||
total_subframes: options.total_subframes,
|
|
||||||
current_subframe: options.current_subframe,
|
|
||||||
})
|
|
||||||
.as_ref(),
|
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
|
let options = frame_options.map(|options| FrameOptions {
|
||||||
|
clear_history: options.clear_history,
|
||||||
|
frame_direction: options.frame_direction,
|
||||||
|
rotation: options.rotation,
|
||||||
|
total_subframes: options.total_subframes,
|
||||||
|
current_subframe: options.current_subframe,
|
||||||
|
});
|
||||||
|
|
||||||
|
for frame in 0..=frame_count {
|
||||||
|
filter_chain.frame(
|
||||||
|
&cmd,
|
||||||
|
self.texture.clone(),
|
||||||
|
&viewport,
|
||||||
|
frame,
|
||||||
|
options.as_ref(),
|
||||||
|
)?;
|
||||||
|
}
|
||||||
|
|
||||||
cmd.Close()?;
|
cmd.Close()?;
|
||||||
self.queue.ExecuteCommandLists(&[Some(cmd.cast()?)]);
|
self.queue.ExecuteCommandLists(&[Some(cmd.cast()?)]);
|
||||||
self.queue.Signal(&fence, 1)?;
|
self.queue.Signal(&fence, 1)?;
|
||||||
|
|
|
@ -84,20 +84,19 @@ impl RenderTest for Direct3D9 {
|
||||||
|
|
||||||
let surface = render_texture.GetSurfaceLevel(0)?;
|
let surface = render_texture.GetSurfaceLevel(0)?;
|
||||||
|
|
||||||
filter_chain.frame(
|
let options = frame_options.map(|options| FrameOptions {
|
||||||
&self.texture,
|
clear_history: options.clear_history,
|
||||||
&Viewport::new_render_target_sized_origin(surface.clone(), None)?,
|
frame_direction: options.frame_direction,
|
||||||
frame_count,
|
rotation: options.rotation,
|
||||||
frame_options
|
total_subframes: options.total_subframes,
|
||||||
.map(|options| FrameOptions {
|
current_subframe: options.current_subframe,
|
||||||
clear_history: options.clear_history,
|
});
|
||||||
frame_direction: options.frame_direction,
|
|
||||||
rotation: options.rotation,
|
let viewport = Viewport::new_render_target_sized_origin(surface.clone(), None)?;
|
||||||
total_subframes: options.total_subframes,
|
|
||||||
current_subframe: options.current_subframe,
|
for frame in 0..=frame_count {
|
||||||
})
|
filter_chain.frame(&self.texture, &viewport, frame, options.as_ref())?;
|
||||||
.as_ref(),
|
}
|
||||||
)?;
|
|
||||||
|
|
||||||
self.device.GetRenderTargetData(&surface, ©_texture)?;
|
self.device.GetRenderTargetData(&surface, ©_texture)?;
|
||||||
|
|
||||||
|
|
|
@ -215,13 +215,11 @@ impl OpenGl {
|
||||||
size: self.image_bytes.size,
|
size: self.image_bytes.size,
|
||||||
};
|
};
|
||||||
|
|
||||||
unsafe {
|
let viewport = Viewport::new_render_target_sized_origin(&output, None)?;
|
||||||
chain.frame(
|
for frame in 0..=frame_count {
|
||||||
&self.texture,
|
unsafe {
|
||||||
&Viewport::new_render_target_sized_origin(&output, None)?,
|
chain.frame(&self.texture, &viewport, frame, options)?;
|
||||||
frame_count,
|
}
|
||||||
options,
|
|
||||||
)?;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// should be the same size as the input image
|
// should be the same size as the input image
|
||||||
|
|
|
@ -5,7 +5,7 @@ use librashader::presets::ShaderPreset;
|
||||||
use librashader::runtime::mtl::{FilterChain, FilterChainOptions, FrameOptions};
|
use librashader::runtime::mtl::{FilterChain, FilterChainOptions, FrameOptions};
|
||||||
use librashader::runtime::Viewport;
|
use librashader::runtime::Viewport;
|
||||||
use librashader::runtime::{FilterChainParameters, RuntimeParameters};
|
use librashader::runtime::{FilterChainParameters, RuntimeParameters};
|
||||||
use librashader_runtime::image::{Image, PixelFormat, UVDirection, BGRA8, RGBA8};
|
use librashader_runtime::image::{Image, PixelFormat, UVDirection, BGRA8};
|
||||||
use objc2::ffi::NSUInteger;
|
use objc2::ffi::NSUInteger;
|
||||||
use objc2::rc::Retained;
|
use objc2::rc::Retained;
|
||||||
use objc2::runtime::ProtocolObject;
|
use objc2::runtime::ProtocolObject;
|
||||||
|
@ -86,21 +86,24 @@ impl RenderTest for Metal {
|
||||||
texture
|
texture
|
||||||
};
|
};
|
||||||
|
|
||||||
filter_chain.frame(
|
let viewport = Viewport::new_render_target_sized_origin(render_texture.as_ref(), None)?;
|
||||||
&self.texture,
|
let options = frame_options.map(|options| FrameOptions {
|
||||||
&Viewport::new_render_target_sized_origin(render_texture.as_ref(), None)?,
|
clear_history: options.clear_history,
|
||||||
cmd.as_ref(),
|
frame_direction: options.frame_direction,
|
||||||
frame_count,
|
rotation: options.rotation,
|
||||||
frame_options
|
total_subframes: options.total_subframes,
|
||||||
.map(|options| FrameOptions {
|
current_subframe: options.current_subframe,
|
||||||
clear_history: options.clear_history,
|
});
|
||||||
frame_direction: options.frame_direction,
|
|
||||||
rotation: options.rotation,
|
for frame in 0..=frame_count {
|
||||||
total_subframes: options.total_subframes,
|
filter_chain.frame(
|
||||||
current_subframe: options.current_subframe,
|
&self.texture,
|
||||||
})
|
&viewport,
|
||||||
.as_ref(),
|
cmd.as_ref(),
|
||||||
)?;
|
frame,
|
||||||
|
options.as_ref(),
|
||||||
|
)?;
|
||||||
|
}
|
||||||
|
|
||||||
cmd.commit();
|
cmd.commit();
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
|
@ -142,32 +142,36 @@ impl RenderTest for Vulkan {
|
||||||
vk::QUEUE_FAMILY_IGNORED,
|
vk::QUEUE_FAMILY_IGNORED,
|
||||||
);
|
);
|
||||||
|
|
||||||
filter_chain.frame(
|
let options = frame_options.map(|options| FrameOptions {
|
||||||
&VulkanImage {
|
clear_history: options.clear_history,
|
||||||
image: self.image,
|
frame_direction: options.frame_direction,
|
||||||
size: self.image_bytes.size,
|
rotation: options.rotation,
|
||||||
|
total_subframes: options.total_subframes,
|
||||||
|
current_subframe: options.current_subframe,
|
||||||
|
});
|
||||||
|
|
||||||
|
let viewport = Viewport::new_render_target_sized_origin(
|
||||||
|
VulkanImage {
|
||||||
|
image: render_texture,
|
||||||
|
size: self.image_bytes.size.into(),
|
||||||
format: vk::Format::B8G8R8A8_UNORM,
|
format: vk::Format::B8G8R8A8_UNORM,
|
||||||
},
|
},
|
||||||
&Viewport::new_render_target_sized_origin(
|
None,
|
||||||
VulkanImage {
|
)?;
|
||||||
image: render_texture,
|
|
||||||
size: self.image_bytes.size.into(),
|
for frame in 0..=frame_count {
|
||||||
|
filter_chain.frame(
|
||||||
|
&VulkanImage {
|
||||||
|
image: self.image,
|
||||||
|
size: self.image_bytes.size,
|
||||||
format: vk::Format::B8G8R8A8_UNORM,
|
format: vk::Format::B8G8R8A8_UNORM,
|
||||||
},
|
},
|
||||||
None,
|
&viewport,
|
||||||
)?,
|
cmd,
|
||||||
cmd,
|
frame,
|
||||||
frame_count,
|
options.as_ref(),
|
||||||
frame_options
|
)?;
|
||||||
.map(|options| FrameOptions {
|
}
|
||||||
clear_history: options.clear_history,
|
|
||||||
frame_direction: options.frame_direction,
|
|
||||||
rotation: options.rotation,
|
|
||||||
total_subframes: options.total_subframes,
|
|
||||||
current_subframe: options.current_subframe,
|
|
||||||
})
|
|
||||||
.as_ref(),
|
|
||||||
)?;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
util::vulkan_image_layout_transition_levels(
|
util::vulkan_image_layout_transition_levels(
|
||||||
|
|
|
@ -108,21 +108,24 @@ impl RenderTest for Wgpu {
|
||||||
TextureFormat::Rgba8Unorm,
|
TextureFormat::Rgba8Unorm,
|
||||||
);
|
);
|
||||||
|
|
||||||
chain.frame(
|
let viewport = Viewport::new_render_target_sized_origin(output, None)?;
|
||||||
Arc::clone(&self.texture),
|
let options = frame_options.map(|options| FrameOptions {
|
||||||
&Viewport::new_render_target_sized_origin(output, None)?,
|
clear_history: options.clear_history,
|
||||||
&mut cmd,
|
frame_direction: options.frame_direction,
|
||||||
frame_count,
|
rotation: options.rotation,
|
||||||
frame_options
|
total_subframes: options.total_subframes,
|
||||||
.map(|options| FrameOptions {
|
current_subframe: options.current_subframe,
|
||||||
clear_history: options.clear_history,
|
});
|
||||||
frame_direction: options.frame_direction,
|
|
||||||
rotation: options.rotation,
|
for frame in 0..=frame_count {
|
||||||
total_subframes: options.total_subframes,
|
chain.frame(
|
||||||
current_subframe: options.current_subframe,
|
Arc::clone(&self.texture),
|
||||||
})
|
&viewport,
|
||||||
.as_ref(),
|
&mut cmd,
|
||||||
)?;
|
frame,
|
||||||
|
options.as_ref(),
|
||||||
|
)?;
|
||||||
|
}
|
||||||
|
|
||||||
cmd.copy_texture_to_buffer(
|
cmd.copy_texture_to_buffer(
|
||||||
output_tex.as_image_copy(),
|
output_tex.as_image_copy(),
|
||||||
|
|
Loading…
Reference in a new issue