rt: only draw last pass twice if the last pass is needed as feedback
This commit is contained in:
parent
0fe5bbd57b
commit
d6f8950bdc
|
@ -52,6 +52,7 @@ pub struct FilterChainD3D11 {
|
|||
history_framebuffers: VecDeque<OwnedImage>,
|
||||
state: D3D11State,
|
||||
default_options: FrameOptionsD3D11,
|
||||
draw_last_pass_feedback: bool,
|
||||
}
|
||||
|
||||
pub(crate) struct Direct3D11 {
|
||||
|
@ -187,6 +188,7 @@ impl FilterChainD3D11 {
|
|||
let draw_quad = DrawQuad::new(device)?;
|
||||
let state = D3D11State::new(device)?;
|
||||
Ok(FilterChainD3D11 {
|
||||
draw_last_pass_feedback: framebuffer_init.uses_final_pass_as_feedback(),
|
||||
passes: filters,
|
||||
output_framebuffers,
|
||||
feedback_framebuffers,
|
||||
|
@ -510,6 +512,7 @@ impl FilterChainD3D11 {
|
|||
// Draw to output_framebuffers for proper handling of feedback.
|
||||
|
||||
let feedback_target = &self.output_framebuffers[index];
|
||||
if self.draw_last_pass_feedback {
|
||||
pass.draw(
|
||||
&ctx,
|
||||
index,
|
||||
|
@ -525,6 +528,7 @@ impl FilterChainD3D11 {
|
|||
),
|
||||
QuadType::Final,
|
||||
)?;
|
||||
}
|
||||
|
||||
pass.draw(
|
||||
&ctx,
|
||||
|
|
|
@ -15,9 +15,9 @@ use librashader_runtime_d3d11::options::FilterChainOptionsD3D11;
|
|||
// const FILTER_PATH: &str = "../test/shaders_slang/crt/crt-royale.slangp";
|
||||
|
||||
// const FILTER_PATH: &str = "../test/slang-shaders/test/history.slangp";
|
||||
// const FILTER_PATH: &str = "../test/shaders_slang/test/feedback.slangp";
|
||||
const FILTER_PATH: &str = "../test/shaders_slang/test/feedback.slangp";
|
||||
|
||||
const FILTER_PATH: &str = "../test/shaders_slang/crt/crt-royale.slangp";
|
||||
// const FILTER_PATH: &str = "../test/shaders_slang/crt/crt-geom-deluxe.slangp";
|
||||
const IMAGE_PATH: &str = "../triangle.png";
|
||||
#[test]
|
||||
fn triangle_d3d11_args() {
|
||||
|
|
|
@ -79,6 +79,7 @@ pub struct FilterChainD3D12 {
|
|||
disable_mipmaps: bool,
|
||||
|
||||
default_options: FrameOptionsD3D12,
|
||||
draw_last_pass_feedback: bool,
|
||||
}
|
||||
|
||||
pub(crate) struct FilterCommon {
|
||||
|
@ -386,6 +387,7 @@ impl FilterChainD3D12 {
|
|||
let (history_framebuffers, history_textures) = framebuffer_init.init_history()?;
|
||||
|
||||
Ok(FilterChainD3D12 {
|
||||
draw_last_pass_feedback: framebuffer_init.uses_final_pass_as_feedback(),
|
||||
common: FilterCommon {
|
||||
d3d12: device.clone(),
|
||||
samplers,
|
||||
|
@ -848,6 +850,7 @@ impl FilterChainD3D12 {
|
|||
source.filter = pass.config.filter;
|
||||
source.wrap_mode = pass.config.wrap_mode;
|
||||
|
||||
if self.draw_last_pass_feedback {
|
||||
let feedback_target = &self.output_framebuffers[index];
|
||||
|
||||
if pass.pipeline.format != feedback_target.format {
|
||||
|
@ -889,6 +892,7 @@ impl FilterChainD3D12 {
|
|||
D3D12_RESOURCE_STATE_RENDER_TARGET,
|
||||
D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE,
|
||||
));
|
||||
}
|
||||
|
||||
if pass.pipeline.format != viewport.output.format {
|
||||
// eprintln!("recompiling final pipeline");
|
||||
|
|
|
@ -56,6 +56,7 @@ pub struct FilterChainD3D9 {
|
|||
feedback_framebuffers: Box<[D3D9Texture]>,
|
||||
history_framebuffers: VecDeque<D3D9Texture>,
|
||||
default_options: FrameOptionsD3D9,
|
||||
draw_last_pass_feedback: bool,
|
||||
}
|
||||
|
||||
mod compile {
|
||||
|
@ -252,6 +253,7 @@ impl FilterChainD3D9 {
|
|||
let draw_quad = DrawQuad::new(device)?;
|
||||
|
||||
Ok(FilterChainD3D9 {
|
||||
draw_last_pass_feedback: framebuffer_init.uses_final_pass_as_feedback(),
|
||||
passes: filters,
|
||||
output_framebuffers,
|
||||
feedback_framebuffers,
|
||||
|
@ -397,6 +399,7 @@ impl FilterChainD3D9 {
|
|||
source.wrap = pass.config.wrap_mode;
|
||||
source.is_srgb = pass.config.srgb_framebuffer;
|
||||
|
||||
if self.draw_last_pass_feedback {
|
||||
let feedback_target = &self.output_framebuffers[index];
|
||||
let feedback_target_rtv = feedback_target.as_output()?;
|
||||
|
||||
|
@ -412,6 +415,7 @@ impl FilterChainD3D9 {
|
|||
RenderTarget::viewport_with_output(&feedback_target_rtv, viewport),
|
||||
QuadType::Final,
|
||||
)?;
|
||||
}
|
||||
|
||||
pass.draw(
|
||||
&self.common.d3d9,
|
||||
|
|
|
@ -39,6 +39,7 @@ pub(crate) struct FilterChainImpl<T: GLInterface> {
|
|||
feedback_framebuffers: Box<[GLFramebuffer]>,
|
||||
history_framebuffers: VecDeque<GLFramebuffer>,
|
||||
default_options: FrameOptionsGL,
|
||||
draw_last_pass_feedback: bool,
|
||||
}
|
||||
|
||||
pub(crate) struct FilterCommon {
|
||||
|
@ -175,6 +176,7 @@ impl<T: GLInterface> FilterChainImpl<T> {
|
|||
let draw_quad = T::DrawQuad::new();
|
||||
|
||||
Ok(FilterChainImpl {
|
||||
draw_last_pass_feedback: framebuffer_init.uses_final_pass_as_feedback(),
|
||||
passes: filters,
|
||||
output_framebuffers,
|
||||
feedback_framebuffers,
|
||||
|
@ -373,6 +375,7 @@ impl<T: GLInterface> FilterChainImpl<T> {
|
|||
source.mip_filter = pass.config.filter;
|
||||
source.wrap_mode = pass.config.wrap_mode;
|
||||
|
||||
if self.draw_last_pass_feedback {
|
||||
let target = &self.output_framebuffers[index];
|
||||
pass.draw(
|
||||
index,
|
||||
|
@ -384,6 +387,7 @@ impl<T: GLInterface> FilterChainImpl<T> {
|
|||
&source,
|
||||
RenderTarget::viewport_with_output(target, viewport),
|
||||
);
|
||||
}
|
||||
|
||||
pass.draw(
|
||||
index,
|
||||
|
|
|
@ -82,6 +82,7 @@ pub struct FilterChainMetal {
|
|||
prev_frame_history_buffer: OwnedTexture,
|
||||
disable_mipmaps: bool,
|
||||
default_options: FrameOptionsMetal,
|
||||
draw_last_pass_feedback: bool
|
||||
}
|
||||
|
||||
impl Debug for FilterChainMetal {
|
||||
|
@ -317,6 +318,7 @@ impl FilterChainMetal {
|
|||
|
||||
let draw_quad = DrawQuad::new(&device)?;
|
||||
Ok(FilterChainMetal {
|
||||
draw_last_pass_feedback: framebuffer_init.uses_final_pass_as_feedback(),
|
||||
common: FilterCommon {
|
||||
luts,
|
||||
samplers,
|
||||
|
@ -487,8 +489,8 @@ impl FilterChainMetal {
|
|||
source.mip_filter = pass.config.filter;
|
||||
let index = passes_len - 1;
|
||||
|
||||
if self.draw_last_pass_feedback {
|
||||
let output_image = &self.output_framebuffers[index].texture;
|
||||
|
||||
let out = RenderTarget::viewport_with_output(output_image.as_ref(), viewport);
|
||||
pass.draw(
|
||||
&cmd,
|
||||
|
@ -502,6 +504,7 @@ impl FilterChainMetal {
|
|||
&out,
|
||||
QuadType::Final,
|
||||
)?;
|
||||
}
|
||||
|
||||
let output_image = viewport.output;
|
||||
let out = RenderTarget::viewport_with_output(output_image, viewport);
|
||||
|
|
|
@ -126,6 +126,7 @@ pub struct FilterChainVulkan {
|
|||
disable_mipmaps: bool,
|
||||
residuals: Box<[FrameResiduals]>,
|
||||
default_options: FrameOptionsVulkan,
|
||||
draw_last_pass_feedback: bool,
|
||||
}
|
||||
|
||||
pub(crate) struct FilterCommon {
|
||||
|
@ -386,6 +387,7 @@ impl FilterChainVulkan {
|
|||
});
|
||||
|
||||
Ok(FilterChainVulkan {
|
||||
draw_last_pass_feedback: framebuffer_init.uses_final_pass_as_feedback(),
|
||||
common: FilterCommon {
|
||||
luts,
|
||||
samplers,
|
||||
|
@ -727,6 +729,7 @@ impl FilterChainVulkan {
|
|||
source.wrap_mode = pass.config.wrap_mode;
|
||||
source.mip_filter = pass.config.filter;
|
||||
|
||||
if self.draw_last_pass_feedback {
|
||||
let target = &self.output_framebuffers[index];
|
||||
|
||||
let output_image = OutputImage::new(&self.vulkan.device, target.image.clone())?;
|
||||
|
@ -749,6 +752,7 @@ impl FilterChainVulkan {
|
|||
out.output.end_pass(&self.vulkan.device, cmd);
|
||||
intermediates.dispose_outputs(output_image);
|
||||
intermediates.dispose_framebuffers(residual_fb);
|
||||
}
|
||||
|
||||
let output_image = OutputImage::new(&self.vulkan.device, viewport.output.clone())?;
|
||||
let out = RenderTarget::viewport_with_output(&output_image, viewport);
|
||||
|
|
|
@ -74,6 +74,7 @@ pub struct FilterChainWgpu {
|
|||
disable_mipmaps: bool,
|
||||
mipmapper: MipmapGen,
|
||||
default_frame_options: FrameOptionsWgpu,
|
||||
draw_last_pass_feedback: bool,
|
||||
}
|
||||
|
||||
pub(crate) struct FilterCommon {
|
||||
|
@ -197,6 +198,7 @@ impl FilterChainWgpu {
|
|||
let draw_quad = DrawQuad::new(&device);
|
||||
|
||||
Ok(FilterChainWgpu {
|
||||
draw_last_pass_feedback: framebuffer_init.uses_final_pass_as_feedback(),
|
||||
common: FilterCommon {
|
||||
luts,
|
||||
samplers,
|
||||
|
@ -492,6 +494,7 @@ impl FilterChainWgpu {
|
|||
source.wrap_mode = pass.config.wrap_mode;
|
||||
source.mip_filter = pass.config.filter;
|
||||
|
||||
if self.draw_last_pass_feedback {
|
||||
let target = &self.output_framebuffers[index];
|
||||
let output_image = WgpuOutputView::from(target);
|
||||
let out = RenderTarget::viewport_with_output(&output_image, viewport);
|
||||
|
@ -508,6 +511,7 @@ impl FilterChainWgpu {
|
|||
&out,
|
||||
QuadType::Final,
|
||||
)?;
|
||||
}
|
||||
|
||||
let output_image = &viewport.output;
|
||||
let out = RenderTarget::viewport_with_output(output_image, viewport);
|
||||
|
|
Loading…
Reference in a new issue