diff options
| author | Irene Knapp <ireneista@irenes.space> | 2026-08-17 01:41:16 -0700 |
|---|---|---|
| committer | Irene Knapp <ireneista@irenes.space> | 2026-08-17 02:07:34 -0700 |
| commit | b52d1be4302e452a45a03595f8c70411a061f920 (patch) | |
| tree | 27af0086f681df583389cfadafd65d7067d26fb2 /src/main.rs | |
| parent | db64249ce8108439ada78a2d23d67d2c573a1688 (diff) | |
move the texture binding to a push descriptor
with a descriptor update template, even yay this also moves us to a minimum Vulkan version of 1.4, which we understand to be widely deployed. in theory, push descriptors and update templates were available via extensions in earlier versions, but it doesn't seem worth doing the work to switch out whether we use the extensions based on the version, so we don't. Force-Push: yes Change-Id: I26db8771abf5626d9614630c66e019ea99babcac
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/src/main.rs b/src/main.rs index d461a63..4d0748f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,7 @@ #![deny(unsafe_code)] use crate::error::*; use crate::assets::asset; -use crate::graphics::{ Permanent, ForReinit, Render, Texture }; +use crate::graphics::{ Permanent, ForReinit, Render }; use crate::graphics::scene::generate_scene_commands; use crate::graphics::window_dressing::{ WindowDressing, N_SIMULTANEOUS_FRAMES @@ -36,7 +36,6 @@ struct Surreality { for_reinit: RefCell<Option<ForReinit>>, window_dressing: RefCell<Option<WindowDressing>>, render: RefCell<Option<Render>>, - texture: RefCell<Option<Texture>>, is_minimized: bool, is_reinit_queued: bool, frame_index: usize, @@ -54,7 +53,6 @@ impl Surreality { for_reinit: RefCell::new(None), window_dressing: RefCell::new(None), render: RefCell::new(None), - texture: RefCell::new(None), is_minimized: false, is_reinit_queued: false, frame_index: 0, @@ -70,14 +68,14 @@ impl Surreality { let (permanent, for_reinit, enable_anisotropy, enable_swapchain) = Permanent::new(event_loop)?; - let png = asset("textures/forest_leaves_04_diff.png")?; - let (texture, mip_count) = load_png(png, &permanent)?; - if enable_swapchain.0 { + let png = asset("textures/forest_leaves_04_diff.png")?; + let (texture, mip_count) = load_png(png, &permanent)?; + let window_dressing = WindowDressing::new(&permanent, &for_reinit, enable_anisotropy, mip_count)?; - let mut render = Render::new(&permanent, &for_reinit, &window_dressing, - &texture)?; + let mut render = Render::new(&permanent, &for_reinit, &window_dressing)?; + render.set_texture(texture); let obj = asset("models/teapot.obj")?; let model = load_obj(obj, &permanent)?; @@ -87,7 +85,6 @@ impl Surreality { *self.render.get_mut() = Some(render); } - *self.texture.get_mut() = Some(texture); *self.permanent.get_mut() = Some(permanent); *self.for_reinit.get_mut() = Some(for_reinit); @@ -100,10 +97,9 @@ impl Surreality { && let Some(window_dressing) = self.window_dressing.borrow_mut().as_mut() && let Some(render) = self.render.borrow_mut().as_mut() - && let Some(texture) = self.texture.borrow_mut().as_mut() { window_dressing.reinit(permanent, for_reinit)?; - render.reinit(permanent, for_reinit, &window_dressing, &texture)?; + render.reinit(permanent, for_reinit, &window_dressing)?; } Ok(()) @@ -234,10 +230,6 @@ impl Drop for Surreality { window_dressing.destroy(&permanent.device); } - if let Some(texture) = self.texture.replace(None) { - texture.destroy(&permanent.device); - } - if let Some(for_reinit) = self.for_reinit.replace(None) { for_reinit.destroy(&permanent.device); } |