gl: leave texture unbound if trying to sample from 0

This commit is contained in:
chyyran 2022-11-29 19:36:09 -05:00
parent 812580e0b9
commit f2d67f9160
6 changed files with 47 additions and 16 deletions

View file

@ -253,6 +253,9 @@ impl FilterPass {
}
for (index, output) in parent.history_textures.iter().enumerate() {
if !output.is_bound() {
continue;
}
if let Some(binding) = self
.reflection
.meta
@ -274,6 +277,9 @@ impl FilterPass {
// PassOutput
for (index, output) in parent.output_textures.iter().enumerate() {
if !output.is_bound() {
continue;
}
if let Some(binding) = self
.reflection
.meta
@ -294,6 +300,9 @@ impl FilterPass {
// PassFeedback
for (index, feedback) in parent.feedback_textures.iter().enumerate() {
if !feedback.is_bound() {
continue;
}
if let Some(binding) = self
.reflection
.meta

View file

@ -13,7 +13,7 @@ pub struct Framebuffer {
pub size: Size<u32>,
pub format: GLenum,
pub max_levels: u32,
pub levels: u32,
pub mip_levels: u32,
is_raw: bool,
}
@ -34,7 +34,7 @@ impl Framebuffer {
},
format: 0,
max_levels,
levels: 0,
mip_levels: 0,
handle: framebuffer,
is_raw: false,
}
@ -52,7 +52,7 @@ impl Framebuffer {
size,
format,
max_levels: miplevels,
levels: miplevels,
mip_levels: miplevels,
handle,
is_raw: true,
}
@ -250,17 +250,17 @@ impl Framebuffer {
size.height = 1;
}
self.levels = util::calc_miplevel(size);
if self.levels > self.max_levels {
self.levels = self.max_levels;
self.mip_levels = util::calc_miplevel(size);
if self.mip_levels > self.max_levels {
self.mip_levels = self.max_levels;
}
if self.levels == 0 {
self.levels = 1;
if self.mip_levels == 0 {
self.mip_levels = 1;
}
gl::TexStorage2D(
gl::TEXTURE_2D,
self.levels as GLsizei,
self.mip_levels as GLsizei,
self.format,
size.width as GLsizei,
size.height as GLsizei,
@ -291,17 +291,17 @@ impl Framebuffer {
gl::GenTextures(1, &mut self.image);
gl::BindTexture(gl::TEXTURE_2D, self.image);
self.levels = util::calc_miplevel(size);
if self.levels > self.max_levels {
self.levels = self.max_levels;
self.mip_levels = util::calc_miplevel(size);
if self.mip_levels > self.max_levels {
self.mip_levels = self.max_levels;
}
if self.levels == 0 {
self.levels = 1;
if self.mip_levels == 0 {
self.mip_levels = 1;
}
gl::TexStorage2D(
gl::TEXTURE_2D,
self.levels as GLsizei,
self.mip_levels as GLsizei,
ImageFormat::R8G8B8A8Unorm.into(),
size.width as GLsizei,
size.height as GLsizei,

View file

@ -31,7 +31,8 @@ mod tests {
fn triangle_gl() {
let (glfw, window, events, shader, vao) = hello_triangle::setup();
let mut filter =
FilterChain::load_from_path("../test/slang-shaders/vhs/VHSPro.slangp", None)
// FilterChain::load_from_path("../test/slang-shaders/vhs/VHSPro.slangp", None)
FilterChain::load_from_path("../test/slang-shaders/bezel/Mega_Bezel/Presets/MBZ__0__SMOOTH-ADV.slangp", None)
.unwrap();
hello_triangle::do_loop(glfw, window, events, shader, vao, &mut filter);
}

View file

@ -8,3 +8,9 @@ pub struct Texture {
pub mip_filter: FilterMode,
pub wrap_mode: WrapMode,
}
impl Texture {
pub fn is_bound(&self) -> bool {
return self.image.handle != 0
}
}

View file

@ -242,6 +242,9 @@ impl FilterPass {
}
for (index, output) in parent.history_textures.iter().enumerate() {
if !output.is_bound() {
continue;
}
if let Some(binding) = self
.reflection
.meta
@ -263,6 +266,9 @@ impl FilterPass {
// PassOutput
for (index, output) in parent.output_textures.iter().enumerate() {
if !output.is_bound() {
continue;
}
if let Some(binding) = self
.reflection
.meta
@ -283,6 +289,9 @@ impl FilterPass {
// PassFeedback
for (index, feedback) in parent.feedback_textures.iter().enumerate() {
if !feedback.is_bound() {
continue;
}
if let Some(binding) = self
.reflection
.meta

View file

@ -8,3 +8,9 @@ pub struct Texture {
pub mip_filter: FilterMode,
pub wrap_mode: WrapMode,
}
impl Texture {
pub fn is_bound(&self) -> bool {
return self.image.handle != 0
}
}