From 47a0c0317cc774c19b78582bec9b5b09d56f569a Mon Sep 17 00:00:00 2001 From: tcmal Date: Sun, 25 Aug 2024 17:44:23 +0100 Subject: feat(render): draw passes --- stockton-render/src/draw/context.rs | 41 +++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 20 deletions(-) (limited to 'stockton-render/src/draw/context.rs') diff --git a/stockton-render/src/draw/context.rs b/stockton-render/src/draw/context.rs index 1a690fe..65dcff6 100644 --- a/stockton-render/src/draw/context.rs +++ b/stockton-render/src/draw/context.rs @@ -10,20 +10,19 @@ use std::{ use anyhow::{Context, Result}; use hal::pool::CommandPoolCreateFlags; use log::debug; -use na::Mat4; + use winit::window::Window; use super::{ - draw_passes::{DrawPass, IntoDrawPass, LevelDrawPass}, + draw_passes::{DrawPass, IntoDrawPass}, queue_negotiator::{DrawQueue, QueueNegotiator}, target::{SwapchainProperties, TargetChain}, }; use crate::{ error::{EnvironmentError, LockPoisoned}, types::*, - window::UiState, }; -use stockton_levels::prelude::*; + use stockton_types::Session; /// Contains all the hal related stuff. @@ -53,17 +52,15 @@ pub struct RenderingContext { /// Deals with drawing logic, and holds any data required for drawing. draw_pass: ManuallyDrop, - /// View projection matrix - pub(crate) vp_matrix: Mat4, - pub(crate) pixels_per_point: f32, } impl RenderingContext { /// Create a new RenderingContext for the given window. - pub fn new>( + pub fn new>( window: &Window, - idp: ILDP, + session: &Session, + idp: IDP, ) -> Result { // Create surface let (instance, surface, mut adapters) = unsafe { @@ -97,7 +94,7 @@ impl RenderingContext { // Auxiliary queues for DP queue_families_specs.extend( - DP::find_aux_queues(&adapter, &mut qn) + IDP::find_aux_queues(&adapter, &mut qn) .context("Level pass couldn't populate queue negotiator")?, ); @@ -105,7 +102,7 @@ impl RenderingContext { }; // Device & Queue groups - let (device_lock, mut queue_groups) = { + let (device_lock, queue_groups) = { // TODO: This sucks, but hal is restrictive on how we can pass this specific argument. let queue_families_specs_real: Vec<_> = queue_families_specs .iter() @@ -122,16 +119,22 @@ impl RenderingContext { (Arc::new(RwLock::new(gpu.device)), gpu.queue_groups) }; + queue_negotiator.set_queue_groups(queue_groups); + // Figure out what our swapchain will look like let swapchain_properties = SwapchainProperties::find_best(&adapter, &surface) .context("Error getting properties for swapchain")?; // Draw pass - let dp = idp.init( - device_lock.clone(), - &mut queue_negotiator, - &swapchain_properties, - )?; + let dp = idp + .init( + session, + &adapter, + device_lock.clone(), + &mut queue_negotiator, + &swapchain_properties, + ) + .context("Error initialising draw pass")?; // Lock device let mut device = device_lock @@ -172,7 +175,7 @@ impl RenderingContext { adapter, queue: queue_negotiator - .get_queue::(&mut queue_groups) + .get_queue::() .ok_or(EnvironmentError::NoQueues) .context("Error getting draw queue")?, @@ -180,8 +183,6 @@ impl RenderingContext { target_chain: ManuallyDrop::new(target_chain), cmd_pool: ManuallyDrop::new(cmd_pool), - vp_matrix: Mat4::identity(), - // pixels_per_point: window.scale_factor() as f32, pixels_per_point: window.scale_factor() as f32, }) @@ -237,7 +238,7 @@ impl RenderingContext { // Level draw pass self.target_chain - .do_draw_with(&mut device, &mut queue, &*self.draw_pass, session) + .do_draw_with(&mut device, &mut queue, &mut *self.draw_pass, session) .context("Error preparing next target")?; Ok(()) -- cgit v1.2.3