mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-19 14:01:08 +01:00
Remove ContextCore from CoreAdapter
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
1 parent
0b899360ca
commit
eda2630fa5
3 files changed
+30
-43
No files matched your search
@@ -80,11 +80,7 @@ impl Adapter {
|
||||
desc: &DeviceDescriptor<'_>,
|
||||
) -> Result<(Device, Queue), RequestDeviceError> {
|
||||
let core_adapter = self.inner.as_core();
|
||||
let (device, queue) = unsafe {
|
||||
core_adapter
|
||||
.context
|
||||
.create_device_from_hal(core_adapter, hal_device, desc)
|
||||
}?;
|
||||
let (device, queue) = unsafe { core_adapter.create_device_from_hal(hal_device, desc) }?;
|
||||
|
||||
Ok((
|
||||
Device {
|
||||
@@ -133,7 +129,7 @@ impl Adapter {
|
||||
) -> Option<impl Deref<Target = A::Adapter> + WasmNotSendSync> {
|
||||
let adapter = self.inner.as_core_opt()?;
|
||||
|
||||
unsafe { adapter.context.adapter_as_hal::<A>(adapter) }
|
||||
unsafe { adapter.as_hal::<A>() }
|
||||
}
|
||||
|
||||
#[cfg(custom)]
|
||||
|
||||
@@ -390,10 +390,7 @@ impl Instance {
|
||||
) -> Adapter {
|
||||
let core_instance = self.inner.as_core();
|
||||
let wgpu_adapter = unsafe { core_instance.create_adapter_from_hal(hal_adapter) };
|
||||
let core = backend::wgpu_core::CoreAdapter {
|
||||
context: core_instance.clone(),
|
||||
wgpu_adapter,
|
||||
};
|
||||
let core = backend::wgpu_core::CoreAdapter { wgpu_adapter };
|
||||
|
||||
Adapter { inner: core.into() }
|
||||
}
|
||||
|
||||
@@ -83,32 +83,6 @@ impl ContextWgpuCore {
|
||||
) -> Arc<wgc::instance::Adapter> {
|
||||
unsafe { self.0.create_adapter_from_hal(hal_adapter.into()) }
|
||||
}
|
||||
|
||||
pub unsafe fn adapter_as_hal<A: hal::Api>(
|
||||
&self,
|
||||
adapter: &CoreAdapter,
|
||||
) -> Option<impl Deref<Target = A::Adapter> + WasmNotSendSync> {
|
||||
unsafe { adapter.wgpu_adapter.clone().as_hal::<A>() }
|
||||
}
|
||||
|
||||
pub unsafe fn create_device_from_hal<A: hal::Api>(
|
||||
&self,
|
||||
adapter: &CoreAdapter,
|
||||
hal_device: hal::OpenDevice<A>,
|
||||
desc: &crate::DeviceDescriptor<'_>,
|
||||
) -> Result<(CoreDevice, CoreQueue), crate::RequestDeviceError> {
|
||||
let (device, queue) = unsafe {
|
||||
adapter.wgpu_adapter.create_device_and_queue_from_hal(
|
||||
hal_device.into(),
|
||||
&desc.map_label(|l| l.map(Borrowed)),
|
||||
)
|
||||
}?;
|
||||
let device = CoreDevice {
|
||||
wgpu_device: device.clone(),
|
||||
};
|
||||
let queue = CoreQueue { wgpu_queue: queue };
|
||||
Ok((device, queue))
|
||||
}
|
||||
}
|
||||
|
||||
fn map_buffer_copy_view(
|
||||
@@ -193,19 +167,43 @@ impl CoreSurface {
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct CoreAdapter {
|
||||
pub(crate) context: ContextWgpuCore,
|
||||
pub(crate) wgpu_adapter: Arc<wgc::instance::Adapter>,
|
||||
}
|
||||
|
||||
impl fmt::Debug for CoreAdapter {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_struct("CoreAdapter")
|
||||
.field("context", &self.context)
|
||||
.field("wgpu_adapter", &Arc::as_ptr(&self.wgpu_adapter))
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl CoreAdapter {
|
||||
pub unsafe fn as_hal<A: hal::Api>(
|
||||
&self,
|
||||
) -> Option<impl Deref<Target = A::Adapter> + WasmNotSendSync> {
|
||||
unsafe { self.wgpu_adapter.clone().as_hal::<A>() }
|
||||
}
|
||||
|
||||
pub unsafe fn create_device_from_hal<A: hal::Api>(
|
||||
&self,
|
||||
hal_device: hal::OpenDevice<A>,
|
||||
desc: &crate::DeviceDescriptor<'_>,
|
||||
) -> Result<(CoreDevice, CoreQueue), crate::RequestDeviceError> {
|
||||
let (device, queue) = unsafe {
|
||||
self.wgpu_adapter.create_device_and_queue_from_hal(
|
||||
hal_device.into(),
|
||||
&desc.map_label(|l| l.map(Borrowed)),
|
||||
)
|
||||
}?;
|
||||
let device = CoreDevice {
|
||||
wgpu_device: device.clone(),
|
||||
};
|
||||
let queue = CoreQueue { wgpu_queue: queue };
|
||||
Ok((device, queue))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct CoreDevice {
|
||||
pub(crate) wgpu_device: Arc<wgc::device::Device>,
|
||||
@@ -645,10 +643,7 @@ impl dispatch::InstanceInterface for ContextWgpuCore {
|
||||
wgt::Backends::all(),
|
||||
);
|
||||
let adapter = adapter.map(|wgpu_adapter| {
|
||||
let core = CoreAdapter {
|
||||
context: self.clone(),
|
||||
wgpu_adapter,
|
||||
};
|
||||
let core = CoreAdapter { wgpu_adapter };
|
||||
let generic: dispatch::DispatchAdapter = core.into();
|
||||
generic
|
||||
});
|
||||
@@ -695,7 +690,6 @@ impl dispatch::InstanceInterface for ContextWgpuCore {
|
||||
.into_iter()
|
||||
.map(|adapter| {
|
||||
let core = crate::backend::wgpu_core::CoreAdapter {
|
||||
context: self.clone(),
|
||||
wgpu_adapter: adapter,
|
||||
};
|
||||
core.into()
|
||||
|
||||
Reference in new issue
Block a user