Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/third_party/rust/wgpu-hal/src/dynamic/   (Firefox Browser Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 2 kB image not shown  

Quelle  instance.rs

  Sprache: Rust
 

use crate::{Api, Capabilities, ExposedAdapter, Instance, InstanceError};

use super::{DynAdapter, DynResource, DynResourceExt as _, DynSurface};

pub struct DynExposedAdapter {
    pub adapter: Box<dyn DynAdapter>,
    pub info: wgt::AdapterInfo,
    pub features: wgt::Features,
    pub capabilities: Capabilities,
}

impl DynExposedAdapter {
    /// Returns the backend this adapter is using.
    pub fn backend(&self) -> wgt::Backend {
        self.info.backend
    }
}

impl<A: Api> From<ExposedAdapter<A>> for DynExposedAdapter {
    fn from(exposed_adapter: ExposedAdapter<A>) -> Self {
        Self {
            adapter: Box::new(exposed_adapter.adapter),
            info: exposed_adapter.info,
            features: exposed_adapter.features,
            capabilities: exposed_adapter.capabilities,
        }
    }
}

pub trait DynInstance: DynResource {
    unsafe fn create_surface(
        &self,
        display_handle: raw_window_handle::RawDisplayHandle,
        window_handle: raw_window_handle::RawWindowHandle,
    ) -> Result<Box<dyn DynSurface>, InstanceError>;

    unsafe fn enumerate_adapters(
        &self,
        surface_hint: Option<&dyn DynSurface>,
    ) -> Vec<DynExposedAdapter>;
}

impl<I: Instance + DynResource> DynInstance for I {
    unsafe fn create_surface(
        &self,
        display_handle: raw_window_handle::RawDisplayHandle,
        window_handle: raw_window_handle::RawWindowHandle,
    ) -> Result<Box<dyn DynSurface>, InstanceError> {
        unsafe { I::create_surface(self, display_handle, window_handle) }
            .map(|surface| -> Box<dyn DynSurface> { Box::new(surface) })
    }

    unsafe fn enumerate_adapters(
        &self,
        surface_hint: Option<&dyn DynSurface>,
    ) -> Vec<DynExposedAdapter> {
        let surface_hint = surface_hint.map(|s| s.expect_downcast_ref());
        unsafe { I::enumerate_adapters(self, surface_hint) }
            .into_iter()
            .map(|exposed| DynExposedAdapter {
                adapter: Box::new(exposed.adapter),
                info: exposed.info,
                features: exposed.features,
                capabilities: exposed.capabilities,
            })
            .collect()
    }
}

Messung V0.5 in Prozent
C=82 H=90 G=86

¤ Dauer der Verarbeitung: 0.10 Sekunden  (vorverarbeitet am  2026-06-22) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.