gl: leave texture unbound if trying to sample from 0
This commit is contained in:
parent
812580e0b9
commit
f2d67f9160
|
@ -253,6 +253,9 @@ impl FilterPass {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (index, output) in parent.history_textures.iter().enumerate() {
|
for (index, output) in parent.history_textures.iter().enumerate() {
|
||||||
|
if !output.is_bound() {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if let Some(binding) = self
|
if let Some(binding) = self
|
||||||
.reflection
|
.reflection
|
||||||
.meta
|
.meta
|
||||||
|
@ -274,6 +277,9 @@ impl FilterPass {
|
||||||
|
|
||||||
// PassOutput
|
// PassOutput
|
||||||
for (index, output) in parent.output_textures.iter().enumerate() {
|
for (index, output) in parent.output_textures.iter().enumerate() {
|
||||||
|
if !output.is_bound() {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if let Some(binding) = self
|
if let Some(binding) = self
|
||||||
.reflection
|
.reflection
|
||||||
.meta
|
.meta
|
||||||
|
@ -294,6 +300,9 @@ impl FilterPass {
|
||||||
|
|
||||||
// PassFeedback
|
// PassFeedback
|
||||||
for (index, feedback) in parent.feedback_textures.iter().enumerate() {
|
for (index, feedback) in parent.feedback_textures.iter().enumerate() {
|
||||||
|
if !feedback.is_bound() {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if let Some(binding) = self
|
if let Some(binding) = self
|
||||||
.reflection
|
.reflection
|
||||||
.meta
|
.meta
|
||||||
|
|
|
@ -13,7 +13,7 @@ pub struct Framebuffer {
|
||||||
pub size: Size<u32>,
|
pub size: Size<u32>,
|
||||||
pub format: GLenum,
|
pub format: GLenum,
|
||||||
pub max_levels: u32,
|
pub max_levels: u32,
|
||||||
pub levels: u32,
|
pub mip_levels: u32,
|
||||||
is_raw: bool,
|
is_raw: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ impl Framebuffer {
|
||||||
},
|
},
|
||||||
format: 0,
|
format: 0,
|
||||||
max_levels,
|
max_levels,
|
||||||
levels: 0,
|
mip_levels: 0,
|
||||||
handle: framebuffer,
|
handle: framebuffer,
|
||||||
is_raw: false,
|
is_raw: false,
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ impl Framebuffer {
|
||||||
size,
|
size,
|
||||||
format,
|
format,
|
||||||
max_levels: miplevels,
|
max_levels: miplevels,
|
||||||
levels: miplevels,
|
mip_levels: miplevels,
|
||||||
handle,
|
handle,
|
||||||
is_raw: true,
|
is_raw: true,
|
||||||
}
|
}
|
||||||
|
@ -250,17 +250,17 @@ impl Framebuffer {
|
||||||
size.height = 1;
|
size.height = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.levels = util::calc_miplevel(size);
|
self.mip_levels = util::calc_miplevel(size);
|
||||||
if self.levels > self.max_levels {
|
if self.mip_levels > self.max_levels {
|
||||||
self.levels = self.max_levels;
|
self.mip_levels = self.max_levels;
|
||||||
}
|
}
|
||||||
if self.levels == 0 {
|
if self.mip_levels == 0 {
|
||||||
self.levels = 1;
|
self.mip_levels = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
gl::TexStorage2D(
|
gl::TexStorage2D(
|
||||||
gl::TEXTURE_2D,
|
gl::TEXTURE_2D,
|
||||||
self.levels as GLsizei,
|
self.mip_levels as GLsizei,
|
||||||
self.format,
|
self.format,
|
||||||
size.width as GLsizei,
|
size.width as GLsizei,
|
||||||
size.height as GLsizei,
|
size.height as GLsizei,
|
||||||
|
@ -291,17 +291,17 @@ impl Framebuffer {
|
||||||
gl::GenTextures(1, &mut self.image);
|
gl::GenTextures(1, &mut self.image);
|
||||||
gl::BindTexture(gl::TEXTURE_2D, self.image);
|
gl::BindTexture(gl::TEXTURE_2D, self.image);
|
||||||
|
|
||||||
self.levels = util::calc_miplevel(size);
|
self.mip_levels = util::calc_miplevel(size);
|
||||||
if self.levels > self.max_levels {
|
if self.mip_levels > self.max_levels {
|
||||||
self.levels = self.max_levels;
|
self.mip_levels = self.max_levels;
|
||||||
}
|
}
|
||||||
if self.levels == 0 {
|
if self.mip_levels == 0 {
|
||||||
self.levels = 1;
|
self.mip_levels = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
gl::TexStorage2D(
|
gl::TexStorage2D(
|
||||||
gl::TEXTURE_2D,
|
gl::TEXTURE_2D,
|
||||||
self.levels as GLsizei,
|
self.mip_levels as GLsizei,
|
||||||
ImageFormat::R8G8B8A8Unorm.into(),
|
ImageFormat::R8G8B8A8Unorm.into(),
|
||||||
size.width as GLsizei,
|
size.width as GLsizei,
|
||||||
size.height as GLsizei,
|
size.height as GLsizei,
|
||||||
|
|
|
@ -31,7 +31,8 @@ mod tests {
|
||||||
fn triangle_gl() {
|
fn triangle_gl() {
|
||||||
let (glfw, window, events, shader, vao) = hello_triangle::setup();
|
let (glfw, window, events, shader, vao) = hello_triangle::setup();
|
||||||
let mut filter =
|
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();
|
.unwrap();
|
||||||
hello_triangle::do_loop(glfw, window, events, shader, vao, &mut filter);
|
hello_triangle::do_loop(glfw, window, events, shader, vao, &mut filter);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,3 +8,9 @@ pub struct Texture {
|
||||||
pub mip_filter: FilterMode,
|
pub mip_filter: FilterMode,
|
||||||
pub wrap_mode: WrapMode,
|
pub wrap_mode: WrapMode,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Texture {
|
||||||
|
pub fn is_bound(&self) -> bool {
|
||||||
|
return self.image.handle != 0
|
||||||
|
}
|
||||||
|
}
|
|
@ -242,6 +242,9 @@ impl FilterPass {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (index, output) in parent.history_textures.iter().enumerate() {
|
for (index, output) in parent.history_textures.iter().enumerate() {
|
||||||
|
if !output.is_bound() {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if let Some(binding) = self
|
if let Some(binding) = self
|
||||||
.reflection
|
.reflection
|
||||||
.meta
|
.meta
|
||||||
|
@ -263,6 +266,9 @@ impl FilterPass {
|
||||||
|
|
||||||
// PassOutput
|
// PassOutput
|
||||||
for (index, output) in parent.output_textures.iter().enumerate() {
|
for (index, output) in parent.output_textures.iter().enumerate() {
|
||||||
|
if !output.is_bound() {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if let Some(binding) = self
|
if let Some(binding) = self
|
||||||
.reflection
|
.reflection
|
||||||
.meta
|
.meta
|
||||||
|
@ -283,6 +289,9 @@ impl FilterPass {
|
||||||
|
|
||||||
// PassFeedback
|
// PassFeedback
|
||||||
for (index, feedback) in parent.feedback_textures.iter().enumerate() {
|
for (index, feedback) in parent.feedback_textures.iter().enumerate() {
|
||||||
|
if !feedback.is_bound() {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if let Some(binding) = self
|
if let Some(binding) = self
|
||||||
.reflection
|
.reflection
|
||||||
.meta
|
.meta
|
||||||
|
|
|
@ -8,3 +8,9 @@ pub struct Texture {
|
||||||
pub mip_filter: FilterMode,
|
pub mip_filter: FilterMode,
|
||||||
pub wrap_mode: WrapMode,
|
pub wrap_mode: WrapMode,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Texture {
|
||||||
|
pub fn is_bound(&self) -> bool {
|
||||||
|
return self.image.handle != 0
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue