vk: try to fix feedback (but its not working..)

This commit is contained in:
chyyran 2023-01-12 01:20:13 -05:00
parent d435b43a52
commit 5acf70e362
6 changed files with 41 additions and 17 deletions

View file

@ -13,8 +13,8 @@ use crate::gl::gl3::CompatibilityGL;
use crate::gl::{FramebufferInterface, GLInterface};
use crate::viewport::Viewport;
const WIDTH: u32 = 1920;
const HEIGHT: u32 = 1080;
const WIDTH: u32 = 800;
const HEIGHT: u32 = 600;
const TITLE: &str = "librashader OpenGL";
pub fn compile_program(vertex: &str, fragment: &str) -> GLuint {

View file

@ -13,8 +13,8 @@ use crate::gl::gl46::DirectStateAccessGL;
use crate::gl::{FramebufferInterface, GLInterface};
use crate::viewport::Viewport;
const WIDTH: u32 = 1920;
const HEIGHT: u32 = 1080;
const WIDTH: u32 = 800;
const HEIGHT: u32 = 600;
const TITLE: &str = "librashader OpenGL 4.6";
pub fn compile_program(vertex: &str, fragment: &str) -> GLuint {

View file

@ -32,7 +32,7 @@ mod tests {
fn triangle_gl() {
let (glfw, window, events, shader, vao) = gl::gl3::hello_triangle::setup();
let mut filter = FilterChainGL::load_from_path(
"../test/slang-shaders/border/gameboy-player/gameboy-player-crt-royale.slangp",
"../test/slang-shaders/bezel/Mega_Bezel/Presets/MBZ__0__SMOOTH-ADV.slangp",
Some(&FilterChainOptionsGL {
gl_version: 0,
use_dsa: false,
@ -49,7 +49,7 @@ mod tests {
let (glfw, window, events, shader, vao) = gl::gl46::hello_triangle::setup();
let mut filter = FilterChainGL::load_from_path(
// "../test/slang-shaders/vhs/VHSPro.slangp",
"../test/slang-shaders/border/gameboy-player/gameboy-player-crt-royale.slangp",
"../test/slang-shaders/bezel/Mega_Bezel/Presets/MBZ__0__SMOOTH-ADV.slangp",
Some(&FilterChainOptionsGL {
gl_version: 0,
use_dsa: true,

View file

@ -3,7 +3,7 @@ use crate::{error, util};
use crate::filter_pass::FilterPass;
use crate::luts::LutTexture;
use crate::samplers::SamplerSet;
use crate::texture::{OwnedImage, InputImage, VulkanImage};
use crate::texture::{OwnedImage, InputImage, VulkanImage, OwnedImageLayout};
use crate::ubo_ring::VkUboRing;
use crate::vulkan_state::VulkanGraphicsPipeline;
use ash::vk::{CommandPoolCreateFlags, PFN_vkGetInstanceProcAddr, Queue, StaticFn};
@ -631,7 +631,8 @@ impl FilterChainVulkan {
&original,
&source,
// todo: need to check **next**
pass.config.mipmap_input
pass.config.mipmap_input,
None,
)?;
self.feedback_framebuffers[index].scale(
@ -641,10 +642,15 @@ impl FilterChainVulkan {
&original,
&source,
// todo: need to check **next**
pass.config.mipmap_input
pass.config.mipmap_input,
None
)?;
}
if self.common.feedback_textures[index].is_none() {
self.common.feedback_textures[index] =
Some(source.clone());
}
}
let passes_len = passes.len();
let (pass, last) = passes.split_at_mut(passes_len - 1);
@ -673,7 +679,7 @@ impl FilterChainVulkan {
source = target.as_input(pass.config.filter, pass.config.wrap_mode)?;
self.common.output_textures[index] = Some(source.clone());
let feedback = self.common.output_textures[index].replace(source.clone());
intermediates.dispose_outputs(out.output);
}
@ -696,10 +702,6 @@ impl FilterChainVulkan {
count as u32,
0, viewport, &original, &source, &out)?;
std::mem::swap(
&mut self.output_framebuffers,
&mut self.feedback_framebuffers,
);
intermediates.dispose_outputs(out.output);
}

View file

@ -312,7 +312,7 @@ impl FilterPass {
}
// PassOutput
for (index, output) in parent.output_textures[0..pass_index].iter().enumerate() {
for (index, output) in parent.output_textures.iter().enumerate() {
let Some(output) = output else {
continue;
};

View file

@ -18,6 +18,14 @@ pub struct OwnedImage {
pub levels: u32,
}
pub struct OwnedImageLayout {
pub(crate) dst_layout: vk::ImageLayout,
pub(crate) dst_access: vk::AccessFlags,
pub(crate) src_stage: vk::PipelineStageFlags,
pub(crate) dst_stage: vk::PipelineStageFlags,
pub(crate) cmd: vk::CommandBuffer
}
impl OwnedImage {
fn new_internal(
device: ash::Device,
@ -122,6 +130,7 @@ impl OwnedImage {
_original: &InputImage,
source: &InputImage,
mipmap: bool,
layout: Option<OwnedImageLayout>
) -> error::Result<Size<u32>> {
let size = source.image.size.scale_viewport(scaling, *viewport_size);
if self.image.size != size || (mipmap && self.max_miplevels == 1) || (!mipmap && self.max_miplevels != 1) {
@ -138,7 +147,20 @@ impl OwnedImage {
}, max_levels)?;
let old = std::mem::replace(self, new);
drop(old)
drop(old);
if let Some(layout) = layout {
unsafe {
util::vulkan_image_layout_transition_levels(&self.device, layout.cmd,
self.image.image,
self.levels,
vk::ImageLayout::UNDEFINED,
layout.dst_layout, vk::AccessFlags::empty(),
layout.dst_access, layout.src_stage, layout.dst_stage, vk::QUEUE_FAMILY_IGNORED,
vk::QUEUE_FAMILY_IGNORED)
}
}
}
Ok(size)
}