ajout material et pipeline_cache
This commit is contained in:
+10
-1
@@ -1,6 +1,13 @@
|
||||
//! # Context Module
|
||||
//!
|
||||
//! Initializes the GPU, creates the surface, and holds the Device and Queue. It is static (created once at startup).
|
||||
//! The **Manager** layer of the architecture — owns hardware resource lifecycle (Device, Queue, Surface).
|
||||
//! Initializes the GPU at startup; orchestrates frame-by-frame rendering via begin_frame() / end_frame().
|
||||
//! Does not own rendering logic (that belongs to Renderer) or shader compilation (PipelineCache).
|
||||
//!
|
||||
//! ## Interaction with Other Modules
|
||||
//! - **renderer**: receives Device/Queue references to write rendered output into the TextureView.
|
||||
//! - **pipeline_cache**: requires Device reference during pipeline creation in Context::new().
|
||||
//! - **error**: returns WsgError variants from all fallible methods.
|
||||
|
||||
use std::sync::Arc;
|
||||
use wgpu::{Adapter, Device, Instance, Queue, Surface};
|
||||
@@ -27,6 +34,7 @@ impl Context {
|
||||
/// Initializes the WGPU context. Creates the surface from the window, requests a device from the adapter,
|
||||
/// and stores all required objects (instance, surface, adapter, device, queue).
|
||||
/// Called once at application startup. Returns an error if GPU initialization fails.
|
||||
/// Internal steps: 1) create Instance → 2) create Surface bound to Window lifecycle → 3) request_adapter for compatible GPU → 4) request_device for Device + Queue.
|
||||
pub async fn new(window: Arc<Window>) -> Result<Self, WsgError> {
|
||||
// WGPU instance
|
||||
let instance = wgpu::Instance::default();
|
||||
@@ -64,6 +72,7 @@ impl Context {
|
||||
/// Inputs: adapter (GPU capabilities), width/height (surface resolution).
|
||||
/// Returns Ok(()) on success or SurfaceIncompatible if no SRGB format + alpha mode exist.
|
||||
/// Typically called by the renderer when window size changes.
|
||||
/// Internal steps: 1) get_capabilities(adapter) → 2) find SRGB format (fallback to first available) → 3) select first alpha mode → 4) build SurfaceConfiguration → 5) configure() the surface.
|
||||
pub fn configure(
|
||||
&self,
|
||||
adapter: &wgpu::Adapter,
|
||||
|
||||
Reference in New Issue
Block a user