mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-12-08 21:26:17 +00:00
Add expose-ids feature (#3104)
This commit is contained in:
parent
eda77e6abb
commit
6ed103ec18
@ -86,6 +86,7 @@ angle = ["wgc/angle"]
|
|||||||
webgl = ["wgc"]
|
webgl = ["wgc"]
|
||||||
emscripten = ["webgl"]
|
emscripten = ["webgl"]
|
||||||
vulkan-portability = ["wgc/vulkan-portability"]
|
vulkan-portability = ["wgc/vulkan-portability"]
|
||||||
|
expose-ids = []
|
||||||
|
|
||||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies.wgc]
|
[target.'cfg(not(target_arch = "wasm32"))'.dependencies.wgc]
|
||||||
workspace = true
|
workspace = true
|
||||||
|
|||||||
@ -815,6 +815,49 @@ pub(crate) struct CommandEncoder {
|
|||||||
open: bool,
|
open: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) type Id = (u32, u32, wgt::Backend);
|
||||||
|
|
||||||
|
impl<T: wgc::id::TypedId> crate::GlobalId for T {
|
||||||
|
fn global_id(&self) -> Id {
|
||||||
|
self.unzip()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl crate::GlobalId for Surface {
|
||||||
|
fn global_id(&self) -> Id {
|
||||||
|
use wgc::id::TypedId;
|
||||||
|
self.id.unzip()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl crate::GlobalId for Device {
|
||||||
|
fn global_id(&self) -> Id {
|
||||||
|
use wgc::id::TypedId;
|
||||||
|
self.id.unzip()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl crate::GlobalId for Buffer {
|
||||||
|
fn global_id(&self) -> Id {
|
||||||
|
use wgc::id::TypedId;
|
||||||
|
self.id.unzip()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl crate::GlobalId for Texture {
|
||||||
|
fn global_id(&self) -> Id {
|
||||||
|
use wgc::id::TypedId;
|
||||||
|
self.id.unzip()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl crate::GlobalId for CommandEncoder {
|
||||||
|
fn global_id(&self) -> Id {
|
||||||
|
use wgc::id::TypedId;
|
||||||
|
self.id.unzip()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl crate::Context for Context {
|
impl crate::Context for Context {
|
||||||
type AdapterId = wgc::id::AdapterId;
|
type AdapterId = wgc::id::AdapterId;
|
||||||
type DeviceId = Device;
|
type DeviceId = Device;
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
#[cfg(all(target_arch = "wasm32", not(feature = "webgl")))]
|
#[cfg(all(target_arch = "wasm32", not(feature = "webgl")))]
|
||||||
mod web;
|
mod web;
|
||||||
#[cfg(all(target_arch = "wasm32", not(feature = "webgl")))]
|
#[cfg(all(target_arch = "wasm32", not(feature = "webgl")))]
|
||||||
pub(crate) use web::{BufferMappedRange, Context, QueueWriteBuffer};
|
pub(crate) use web::{BufferMappedRange, Context, Id, QueueWriteBuffer};
|
||||||
|
|
||||||
#[cfg(any(not(target_arch = "wasm32"), feature = "webgl"))]
|
#[cfg(any(not(target_arch = "wasm32"), feature = "webgl"))]
|
||||||
mod direct;
|
mod direct;
|
||||||
#[cfg(any(not(target_arch = "wasm32"), feature = "webgl"))]
|
#[cfg(any(not(target_arch = "wasm32"), feature = "webgl"))]
|
||||||
pub(crate) use direct::{BufferMappedRange, Context, QueueWriteBuffer};
|
pub(crate) use direct::{BufferMappedRange, Context, Id, QueueWriteBuffer};
|
||||||
|
|||||||
@ -25,6 +25,41 @@ pub(crate) struct Sendable<T>(T);
|
|||||||
unsafe impl<T> Send for Sendable<T> {}
|
unsafe impl<T> Send for Sendable<T> {}
|
||||||
unsafe impl<T> Sync for Sendable<T> {}
|
unsafe impl<T> Sync for Sendable<T> {}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug)]
|
||||||
|
pub(crate) struct Identified<T>(T, #[cfg(feature = "expose-ids")] u64);
|
||||||
|
unsafe impl<T> Send for Identified<T> {}
|
||||||
|
unsafe impl<T> Sync for Identified<T> {}
|
||||||
|
|
||||||
|
impl<T> crate::GlobalId for Identified<T> {
|
||||||
|
#[cfg(not(feature = "expose-ids"))]
|
||||||
|
fn global_id(&self) -> Id {
|
||||||
|
0
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "expose-ids")]
|
||||||
|
fn global_id(&self) -> Id {
|
||||||
|
self.1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) type Id = u64;
|
||||||
|
|
||||||
|
#[cfg(feature = "expose-ids")]
|
||||||
|
static NEXT_ID: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(0);
|
||||||
|
|
||||||
|
#[cfg(not(feature = "expose-ids"))]
|
||||||
|
fn create_identified<T>(value: T) -> Identified<T> {
|
||||||
|
Identified(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "expose-ids")]
|
||||||
|
fn create_identified<T>(value: T) -> Identified<T> {
|
||||||
|
Identified(
|
||||||
|
value,
|
||||||
|
NEXT_ID.fetch_add(1, std::sync::atomic::Ordering::Relaxed),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) struct Context(web_sys::Gpu);
|
pub(crate) struct Context(web_sys::Gpu);
|
||||||
unsafe impl Send for Context {}
|
unsafe impl Send for Context {}
|
||||||
unsafe impl Sync for Context {}
|
unsafe impl Sync for Context {}
|
||||||
@ -93,13 +128,13 @@ impl<F, M> MakeSendFuture<F, M> {
|
|||||||
unsafe impl<F, M> Send for MakeSendFuture<F, M> {}
|
unsafe impl<F, M> Send for MakeSendFuture<F, M> {}
|
||||||
|
|
||||||
impl crate::ComputePassInner<Context> for ComputePass {
|
impl crate::ComputePassInner<Context> for ComputePass {
|
||||||
fn set_pipeline(&mut self, pipeline: &Sendable<web_sys::GpuComputePipeline>) {
|
fn set_pipeline(&mut self, pipeline: &Identified<web_sys::GpuComputePipeline>) {
|
||||||
self.0.set_pipeline(&pipeline.0);
|
self.0.set_pipeline(&pipeline.0);
|
||||||
}
|
}
|
||||||
fn set_bind_group(
|
fn set_bind_group(
|
||||||
&mut self,
|
&mut self,
|
||||||
index: u32,
|
index: u32,
|
||||||
bind_group: &Sendable<web_sys::GpuBindGroup>,
|
bind_group: &Identified<web_sys::GpuBindGroup>,
|
||||||
offsets: &[wgt::DynamicOffset],
|
offsets: &[wgt::DynamicOffset],
|
||||||
) {
|
) {
|
||||||
self.0
|
self.0
|
||||||
@ -137,20 +172,24 @@ impl crate::ComputePassInner<Context> for ComputePass {
|
|||||||
}
|
}
|
||||||
fn dispatch_workgroups_indirect(
|
fn dispatch_workgroups_indirect(
|
||||||
&mut self,
|
&mut self,
|
||||||
indirect_buffer: &Sendable<web_sys::GpuBuffer>,
|
indirect_buffer: &Identified<web_sys::GpuBuffer>,
|
||||||
indirect_offset: wgt::BufferAddress,
|
indirect_offset: wgt::BufferAddress,
|
||||||
) {
|
) {
|
||||||
self.0
|
self.0
|
||||||
.dispatch_workgroups_indirect_with_f64(&indirect_buffer.0, indirect_offset as f64);
|
.dispatch_workgroups_indirect_with_f64(&indirect_buffer.0, indirect_offset as f64);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write_timestamp(&mut self, _query_set: &Sendable<web_sys::GpuQuerySet>, _query_index: u32) {
|
fn write_timestamp(
|
||||||
|
&mut self,
|
||||||
|
_query_set: &Identified<web_sys::GpuQuerySet>,
|
||||||
|
_query_index: u32,
|
||||||
|
) {
|
||||||
panic!("WRITE_TIMESTAMP_INSIDE_PASSES feature must be enabled to call write_timestamp in a compute pass")
|
panic!("WRITE_TIMESTAMP_INSIDE_PASSES feature must be enabled to call write_timestamp in a compute pass")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn begin_pipeline_statistics_query(
|
fn begin_pipeline_statistics_query(
|
||||||
&mut self,
|
&mut self,
|
||||||
_query_set: &Sendable<web_sys::GpuQuerySet>,
|
_query_set: &Identified<web_sys::GpuQuerySet>,
|
||||||
_query_index: u32,
|
_query_index: u32,
|
||||||
) {
|
) {
|
||||||
// Not available in gecko yet
|
// Not available in gecko yet
|
||||||
@ -162,13 +201,13 @@ impl crate::ComputePassInner<Context> for ComputePass {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl crate::RenderInner<Context> for RenderPass {
|
impl crate::RenderInner<Context> for RenderPass {
|
||||||
fn set_pipeline(&mut self, pipeline: &Sendable<web_sys::GpuRenderPipeline>) {
|
fn set_pipeline(&mut self, pipeline: &Identified<web_sys::GpuRenderPipeline>) {
|
||||||
self.0.set_pipeline(&pipeline.0);
|
self.0.set_pipeline(&pipeline.0);
|
||||||
}
|
}
|
||||||
fn set_bind_group(
|
fn set_bind_group(
|
||||||
&mut self,
|
&mut self,
|
||||||
index: u32,
|
index: u32,
|
||||||
bind_group: &Sendable<web_sys::GpuBindGroup>,
|
bind_group: &Identified<web_sys::GpuBindGroup>,
|
||||||
offsets: &[wgt::DynamicOffset],
|
offsets: &[wgt::DynamicOffset],
|
||||||
) {
|
) {
|
||||||
self.0
|
self.0
|
||||||
@ -182,7 +221,7 @@ impl crate::RenderInner<Context> for RenderPass {
|
|||||||
}
|
}
|
||||||
fn set_index_buffer(
|
fn set_index_buffer(
|
||||||
&mut self,
|
&mut self,
|
||||||
buffer: &Sendable<web_sys::GpuBuffer>,
|
buffer: &Identified<web_sys::GpuBuffer>,
|
||||||
index_format: wgt::IndexFormat,
|
index_format: wgt::IndexFormat,
|
||||||
offset: wgt::BufferAddress,
|
offset: wgt::BufferAddress,
|
||||||
size: Option<wgt::BufferSize>,
|
size: Option<wgt::BufferSize>,
|
||||||
@ -208,7 +247,7 @@ impl crate::RenderInner<Context> for RenderPass {
|
|||||||
fn set_vertex_buffer(
|
fn set_vertex_buffer(
|
||||||
&mut self,
|
&mut self,
|
||||||
slot: u32,
|
slot: u32,
|
||||||
buffer: &Sendable<web_sys::GpuBuffer>,
|
buffer: &Identified<web_sys::GpuBuffer>,
|
||||||
offset: wgt::BufferAddress,
|
offset: wgt::BufferAddress,
|
||||||
size: Option<wgt::BufferSize>,
|
size: Option<wgt::BufferSize>,
|
||||||
) {
|
) {
|
||||||
@ -251,7 +290,7 @@ impl crate::RenderInner<Context> for RenderPass {
|
|||||||
}
|
}
|
||||||
fn draw_indirect(
|
fn draw_indirect(
|
||||||
&mut self,
|
&mut self,
|
||||||
indirect_buffer: &Sendable<web_sys::GpuBuffer>,
|
indirect_buffer: &Identified<web_sys::GpuBuffer>,
|
||||||
indirect_offset: wgt::BufferAddress,
|
indirect_offset: wgt::BufferAddress,
|
||||||
) {
|
) {
|
||||||
self.0
|
self.0
|
||||||
@ -259,7 +298,7 @@ impl crate::RenderInner<Context> for RenderPass {
|
|||||||
}
|
}
|
||||||
fn draw_indexed_indirect(
|
fn draw_indexed_indirect(
|
||||||
&mut self,
|
&mut self,
|
||||||
indirect_buffer: &Sendable<web_sys::GpuBuffer>,
|
indirect_buffer: &Identified<web_sys::GpuBuffer>,
|
||||||
indirect_offset: wgt::BufferAddress,
|
indirect_offset: wgt::BufferAddress,
|
||||||
) {
|
) {
|
||||||
self.0
|
self.0
|
||||||
@ -267,7 +306,7 @@ impl crate::RenderInner<Context> for RenderPass {
|
|||||||
}
|
}
|
||||||
fn multi_draw_indirect(
|
fn multi_draw_indirect(
|
||||||
&mut self,
|
&mut self,
|
||||||
_indirect_buffer: &Sendable<web_sys::GpuBuffer>,
|
_indirect_buffer: &Identified<web_sys::GpuBuffer>,
|
||||||
_indirect_offset: wgt::BufferAddress,
|
_indirect_offset: wgt::BufferAddress,
|
||||||
_count: u32,
|
_count: u32,
|
||||||
) {
|
) {
|
||||||
@ -275,7 +314,7 @@ impl crate::RenderInner<Context> for RenderPass {
|
|||||||
}
|
}
|
||||||
fn multi_draw_indexed_indirect(
|
fn multi_draw_indexed_indirect(
|
||||||
&mut self,
|
&mut self,
|
||||||
_indirect_buffer: &Sendable<web_sys::GpuBuffer>,
|
_indirect_buffer: &Identified<web_sys::GpuBuffer>,
|
||||||
_indirect_offset: wgt::BufferAddress,
|
_indirect_offset: wgt::BufferAddress,
|
||||||
_count: u32,
|
_count: u32,
|
||||||
) {
|
) {
|
||||||
@ -283,9 +322,9 @@ impl crate::RenderInner<Context> for RenderPass {
|
|||||||
}
|
}
|
||||||
fn multi_draw_indirect_count(
|
fn multi_draw_indirect_count(
|
||||||
&mut self,
|
&mut self,
|
||||||
_indirect_buffer: &Sendable<web_sys::GpuBuffer>,
|
_indirect_buffer: &Identified<web_sys::GpuBuffer>,
|
||||||
_indirect_offset: wgt::BufferAddress,
|
_indirect_offset: wgt::BufferAddress,
|
||||||
_count_buffer: &Sendable<web_sys::GpuBuffer>,
|
_count_buffer: &Identified<web_sys::GpuBuffer>,
|
||||||
_count_buffer_offset: wgt::BufferAddress,
|
_count_buffer_offset: wgt::BufferAddress,
|
||||||
_max_count: u32,
|
_max_count: u32,
|
||||||
) {
|
) {
|
||||||
@ -295,9 +334,9 @@ impl crate::RenderInner<Context> for RenderPass {
|
|||||||
}
|
}
|
||||||
fn multi_draw_indexed_indirect_count(
|
fn multi_draw_indexed_indirect_count(
|
||||||
&mut self,
|
&mut self,
|
||||||
_indirect_buffer: &Sendable<web_sys::GpuBuffer>,
|
_indirect_buffer: &Identified<web_sys::GpuBuffer>,
|
||||||
_indirect_offset: wgt::BufferAddress,
|
_indirect_offset: wgt::BufferAddress,
|
||||||
_count_buffer: &Sendable<web_sys::GpuBuffer>,
|
_count_buffer: &Identified<web_sys::GpuBuffer>,
|
||||||
_count_buffer_offset: wgt::BufferAddress,
|
_count_buffer_offset: wgt::BufferAddress,
|
||||||
_max_count: u32,
|
_max_count: u32,
|
||||||
) {
|
) {
|
||||||
@ -306,13 +345,13 @@ impl crate::RenderInner<Context> for RenderPass {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl crate::RenderInner<Context> for RenderBundleEncoder {
|
impl crate::RenderInner<Context> for RenderBundleEncoder {
|
||||||
fn set_pipeline(&mut self, pipeline: &Sendable<web_sys::GpuRenderPipeline>) {
|
fn set_pipeline(&mut self, pipeline: &Identified<web_sys::GpuRenderPipeline>) {
|
||||||
self.0.set_pipeline(&pipeline.0);
|
self.0.set_pipeline(&pipeline.0);
|
||||||
}
|
}
|
||||||
fn set_bind_group(
|
fn set_bind_group(
|
||||||
&mut self,
|
&mut self,
|
||||||
index: u32,
|
index: u32,
|
||||||
bind_group: &Sendable<web_sys::GpuBindGroup>,
|
bind_group: &Identified<web_sys::GpuBindGroup>,
|
||||||
offsets: &[wgt::DynamicOffset],
|
offsets: &[wgt::DynamicOffset],
|
||||||
) {
|
) {
|
||||||
self.0
|
self.0
|
||||||
@ -326,7 +365,7 @@ impl crate::RenderInner<Context> for RenderBundleEncoder {
|
|||||||
}
|
}
|
||||||
fn set_index_buffer(
|
fn set_index_buffer(
|
||||||
&mut self,
|
&mut self,
|
||||||
buffer: &Sendable<web_sys::GpuBuffer>,
|
buffer: &Identified<web_sys::GpuBuffer>,
|
||||||
index_format: wgt::IndexFormat,
|
index_format: wgt::IndexFormat,
|
||||||
offset: wgt::BufferAddress,
|
offset: wgt::BufferAddress,
|
||||||
size: Option<wgt::BufferSize>,
|
size: Option<wgt::BufferSize>,
|
||||||
@ -352,7 +391,7 @@ impl crate::RenderInner<Context> for RenderBundleEncoder {
|
|||||||
fn set_vertex_buffer(
|
fn set_vertex_buffer(
|
||||||
&mut self,
|
&mut self,
|
||||||
slot: u32,
|
slot: u32,
|
||||||
buffer: &Sendable<web_sys::GpuBuffer>,
|
buffer: &Identified<web_sys::GpuBuffer>,
|
||||||
offset: wgt::BufferAddress,
|
offset: wgt::BufferAddress,
|
||||||
size: Option<wgt::BufferSize>,
|
size: Option<wgt::BufferSize>,
|
||||||
) {
|
) {
|
||||||
@ -395,7 +434,7 @@ impl crate::RenderInner<Context> for RenderBundleEncoder {
|
|||||||
}
|
}
|
||||||
fn draw_indirect(
|
fn draw_indirect(
|
||||||
&mut self,
|
&mut self,
|
||||||
indirect_buffer: &Sendable<web_sys::GpuBuffer>,
|
indirect_buffer: &Identified<web_sys::GpuBuffer>,
|
||||||
indirect_offset: wgt::BufferAddress,
|
indirect_offset: wgt::BufferAddress,
|
||||||
) {
|
) {
|
||||||
self.0
|
self.0
|
||||||
@ -403,7 +442,7 @@ impl crate::RenderInner<Context> for RenderBundleEncoder {
|
|||||||
}
|
}
|
||||||
fn draw_indexed_indirect(
|
fn draw_indexed_indirect(
|
||||||
&mut self,
|
&mut self,
|
||||||
indirect_buffer: &Sendable<web_sys::GpuBuffer>,
|
indirect_buffer: &Identified<web_sys::GpuBuffer>,
|
||||||
indirect_offset: wgt::BufferAddress,
|
indirect_offset: wgt::BufferAddress,
|
||||||
) {
|
) {
|
||||||
self.0
|
self.0
|
||||||
@ -411,7 +450,7 @@ impl crate::RenderInner<Context> for RenderBundleEncoder {
|
|||||||
}
|
}
|
||||||
fn multi_draw_indirect(
|
fn multi_draw_indirect(
|
||||||
&mut self,
|
&mut self,
|
||||||
_indirect_buffer: &Sendable<web_sys::GpuBuffer>,
|
_indirect_buffer: &Identified<web_sys::GpuBuffer>,
|
||||||
_indirect_offset: wgt::BufferAddress,
|
_indirect_offset: wgt::BufferAddress,
|
||||||
_count: u32,
|
_count: u32,
|
||||||
) {
|
) {
|
||||||
@ -419,7 +458,7 @@ impl crate::RenderInner<Context> for RenderBundleEncoder {
|
|||||||
}
|
}
|
||||||
fn multi_draw_indexed_indirect(
|
fn multi_draw_indexed_indirect(
|
||||||
&mut self,
|
&mut self,
|
||||||
_indirect_buffer: &Sendable<web_sys::GpuBuffer>,
|
_indirect_buffer: &Identified<web_sys::GpuBuffer>,
|
||||||
_indirect_offset: wgt::BufferAddress,
|
_indirect_offset: wgt::BufferAddress,
|
||||||
_count: u32,
|
_count: u32,
|
||||||
) {
|
) {
|
||||||
@ -427,9 +466,9 @@ impl crate::RenderInner<Context> for RenderBundleEncoder {
|
|||||||
}
|
}
|
||||||
fn multi_draw_indirect_count(
|
fn multi_draw_indirect_count(
|
||||||
&mut self,
|
&mut self,
|
||||||
_indirect_buffer: &Sendable<web_sys::GpuBuffer>,
|
_indirect_buffer: &Identified<web_sys::GpuBuffer>,
|
||||||
_indirect_offset: wgt::BufferAddress,
|
_indirect_offset: wgt::BufferAddress,
|
||||||
_count_buffer: &Sendable<web_sys::GpuBuffer>,
|
_count_buffer: &Identified<web_sys::GpuBuffer>,
|
||||||
_count_buffer_offset: wgt::BufferAddress,
|
_count_buffer_offset: wgt::BufferAddress,
|
||||||
_max_count: u32,
|
_max_count: u32,
|
||||||
) {
|
) {
|
||||||
@ -439,9 +478,9 @@ impl crate::RenderInner<Context> for RenderBundleEncoder {
|
|||||||
}
|
}
|
||||||
fn multi_draw_indexed_indirect_count(
|
fn multi_draw_indexed_indirect_count(
|
||||||
&mut self,
|
&mut self,
|
||||||
_indirect_buffer: &Sendable<web_sys::GpuBuffer>,
|
_indirect_buffer: &Identified<web_sys::GpuBuffer>,
|
||||||
_indirect_offset: wgt::BufferAddress,
|
_indirect_offset: wgt::BufferAddress,
|
||||||
_count_buffer: &Sendable<web_sys::GpuBuffer>,
|
_count_buffer: &Identified<web_sys::GpuBuffer>,
|
||||||
_count_buffer_offset: wgt::BufferAddress,
|
_count_buffer_offset: wgt::BufferAddress,
|
||||||
_max_count: u32,
|
_max_count: u32,
|
||||||
) {
|
) {
|
||||||
@ -488,7 +527,7 @@ impl crate::RenderPassInner<Context> for RenderPass {
|
|||||||
// self.0.pop_debug_group();
|
// self.0.pop_debug_group();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn execute_bundles<'a, I: Iterator<Item = &'a Sendable<web_sys::GpuRenderBundle>>>(
|
fn execute_bundles<'a, I: Iterator<Item = &'a Identified<web_sys::GpuRenderBundle>>>(
|
||||||
&mut self,
|
&mut self,
|
||||||
render_bundles: I,
|
render_bundles: I,
|
||||||
) {
|
) {
|
||||||
@ -498,13 +537,17 @@ impl crate::RenderPassInner<Context> for RenderPass {
|
|||||||
self.0.execute_bundles(&mapped);
|
self.0.execute_bundles(&mapped);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write_timestamp(&mut self, _query_set: &Sendable<web_sys::GpuQuerySet>, _query_index: u32) {
|
fn write_timestamp(
|
||||||
|
&mut self,
|
||||||
|
_query_set: &Identified<web_sys::GpuQuerySet>,
|
||||||
|
_query_index: u32,
|
||||||
|
) {
|
||||||
panic!("WRITE_TIMESTAMP_INSIDE_PASSES feature must be enabled to call write_timestamp in a compute pass")
|
panic!("WRITE_TIMESTAMP_INSIDE_PASSES feature must be enabled to call write_timestamp in a compute pass")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn begin_pipeline_statistics_query(
|
fn begin_pipeline_statistics_query(
|
||||||
&mut self,
|
&mut self,
|
||||||
_query_set: &Sendable<web_sys::GpuQuerySet>,
|
_query_set: &Identified<web_sys::GpuQuerySet>,
|
||||||
_query_index: u32,
|
_query_index: u32,
|
||||||
) {
|
) {
|
||||||
// Not available in gecko yet
|
// Not available in gecko yet
|
||||||
@ -903,22 +946,28 @@ fn map_map_mode(mode: crate::MapMode) -> u32 {
|
|||||||
|
|
||||||
type JsFutureResult = Result<wasm_bindgen::JsValue, wasm_bindgen::JsValue>;
|
type JsFutureResult = Result<wasm_bindgen::JsValue, wasm_bindgen::JsValue>;
|
||||||
|
|
||||||
fn future_request_adapter(result: JsFutureResult) -> Option<Sendable<web_sys::GpuAdapter>> {
|
fn future_request_adapter(result: JsFutureResult) -> Option<Identified<web_sys::GpuAdapter>> {
|
||||||
match result.and_then(wasm_bindgen::JsCast::dyn_into) {
|
match result.and_then(wasm_bindgen::JsCast::dyn_into) {
|
||||||
Ok(adapter) => Some(Sendable(adapter)),
|
Ok(adapter) => Some(create_identified(adapter)),
|
||||||
Err(_) => None,
|
Err(_) => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn future_request_device(
|
fn future_request_device(
|
||||||
result: JsFutureResult,
|
result: JsFutureResult,
|
||||||
) -> Result<(Sendable<web_sys::GpuDevice>, Sendable<web_sys::GpuQueue>), crate::RequestDeviceError>
|
) -> Result<
|
||||||
{
|
(
|
||||||
|
Identified<web_sys::GpuDevice>,
|
||||||
|
Identified<web_sys::GpuQueue>,
|
||||||
|
),
|
||||||
|
crate::RequestDeviceError,
|
||||||
|
> {
|
||||||
result
|
result
|
||||||
.map(|js_value| {
|
.map(|js_value| {
|
||||||
let device_id = web_sys::GpuDevice::from(js_value);
|
let device_id = web_sys::GpuDevice::from(js_value);
|
||||||
let queue_id = device_id.queue();
|
let queue_id = device_id.queue();
|
||||||
(Sendable(device_id), Sendable(queue_id))
|
|
||||||
|
(create_identified(device_id), create_identified(queue_id))
|
||||||
})
|
})
|
||||||
.map_err(|_| crate::RequestDeviceError)
|
.map_err(|_| crate::RequestDeviceError)
|
||||||
}
|
}
|
||||||
@ -984,7 +1033,7 @@ impl Context {
|
|||||||
Ok(Some(ctx)) => ctx.into(),
|
Ok(Some(ctx)) => ctx.into(),
|
||||||
_ => panic!("expected to get context from canvas"),
|
_ => panic!("expected to get context from canvas"),
|
||||||
};
|
};
|
||||||
Sendable(context.into())
|
create_identified(context.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn instance_create_surface_from_offscreen_canvas(
|
pub fn instance_create_surface_from_offscreen_canvas(
|
||||||
@ -995,12 +1044,12 @@ impl Context {
|
|||||||
Ok(Some(ctx)) => ctx.into(),
|
Ok(Some(ctx)) => ctx.into(),
|
||||||
_ => panic!("expected to get context from canvas"),
|
_ => panic!("expected to get context from canvas"),
|
||||||
};
|
};
|
||||||
Sendable(context.into())
|
create_identified(context.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn queue_copy_external_image_to_texture(
|
pub fn queue_copy_external_image_to_texture(
|
||||||
&self,
|
&self,
|
||||||
queue: &Sendable<web_sys::GpuQueue>,
|
queue: &Identified<web_sys::GpuQueue>,
|
||||||
image: &web_sys::ImageBitmap,
|
image: &web_sys::ImageBitmap,
|
||||||
texture: crate::ImageCopyTexture,
|
texture: crate::ImageCopyTexture,
|
||||||
size: wgt::Extent3d,
|
size: wgt::Extent3d,
|
||||||
@ -1037,27 +1086,27 @@ extern "C" {
|
|||||||
pub struct SubmissionIndex;
|
pub struct SubmissionIndex;
|
||||||
|
|
||||||
impl crate::Context for Context {
|
impl crate::Context for Context {
|
||||||
type AdapterId = Sendable<web_sys::GpuAdapter>;
|
type AdapterId = Identified<web_sys::GpuAdapter>;
|
||||||
type DeviceId = Sendable<web_sys::GpuDevice>;
|
type DeviceId = Identified<web_sys::GpuDevice>;
|
||||||
type QueueId = Sendable<web_sys::GpuQueue>;
|
type QueueId = Identified<web_sys::GpuQueue>;
|
||||||
type ShaderModuleId = Sendable<web_sys::GpuShaderModule>;
|
type ShaderModuleId = Identified<web_sys::GpuShaderModule>;
|
||||||
type BindGroupLayoutId = Sendable<web_sys::GpuBindGroupLayout>;
|
type BindGroupLayoutId = Identified<web_sys::GpuBindGroupLayout>;
|
||||||
type BindGroupId = Sendable<web_sys::GpuBindGroup>;
|
type BindGroupId = Identified<web_sys::GpuBindGroup>;
|
||||||
type TextureViewId = Sendable<web_sys::GpuTextureView>;
|
type TextureViewId = Identified<web_sys::GpuTextureView>;
|
||||||
type SamplerId = Sendable<web_sys::GpuSampler>;
|
type SamplerId = Identified<web_sys::GpuSampler>;
|
||||||
type BufferId = Sendable<web_sys::GpuBuffer>;
|
type BufferId = Identified<web_sys::GpuBuffer>;
|
||||||
type TextureId = Sendable<web_sys::GpuTexture>;
|
type TextureId = Identified<web_sys::GpuTexture>;
|
||||||
type QuerySetId = Sendable<web_sys::GpuQuerySet>;
|
type QuerySetId = Identified<web_sys::GpuQuerySet>;
|
||||||
type PipelineLayoutId = Sendable<web_sys::GpuPipelineLayout>;
|
type PipelineLayoutId = Identified<web_sys::GpuPipelineLayout>;
|
||||||
type RenderPipelineId = Sendable<web_sys::GpuRenderPipeline>;
|
type RenderPipelineId = Identified<web_sys::GpuRenderPipeline>;
|
||||||
type ComputePipelineId = Sendable<web_sys::GpuComputePipeline>;
|
type ComputePipelineId = Identified<web_sys::GpuComputePipeline>;
|
||||||
type CommandEncoderId = Sendable<web_sys::GpuCommandEncoder>;
|
type CommandEncoderId = Sendable<web_sys::GpuCommandEncoder>;
|
||||||
type ComputePassId = ComputePass;
|
type ComputePassId = ComputePass;
|
||||||
type RenderPassId = RenderPass;
|
type RenderPassId = RenderPass;
|
||||||
type CommandBufferId = Sendable<web_sys::GpuCommandBuffer>;
|
type CommandBufferId = Sendable<web_sys::GpuCommandBuffer>;
|
||||||
type RenderBundleEncoderId = RenderBundleEncoder;
|
type RenderBundleEncoderId = RenderBundleEncoder;
|
||||||
type RenderBundleId = Sendable<web_sys::GpuRenderBundle>;
|
type RenderBundleId = Identified<web_sys::GpuRenderBundle>;
|
||||||
type SurfaceId = Sendable<web_sys::GpuCanvasContext>;
|
type SurfaceId = Identified<web_sys::GpuCanvasContext>;
|
||||||
|
|
||||||
type SurfaceOutputDetail = SurfaceOutputDetail;
|
type SurfaceOutputDetail = SurfaceOutputDetail;
|
||||||
type SubmissionIndex = SubmissionIndex;
|
type SubmissionIndex = SubmissionIndex;
|
||||||
@ -1338,7 +1387,7 @@ impl crate::Context for Context {
|
|||||||
Self::SurfaceOutputDetail,
|
Self::SurfaceOutputDetail,
|
||||||
) {
|
) {
|
||||||
(
|
(
|
||||||
Some(Sendable(surface.0.get_current_texture())),
|
Some(create_identified(surface.0.get_current_texture())),
|
||||||
wgt::SurfaceStatus::Good,
|
wgt::SurfaceStatus::Good,
|
||||||
(),
|
(),
|
||||||
)
|
)
|
||||||
@ -1462,7 +1511,7 @@ impl crate::Context for Context {
|
|||||||
if let Some(label) = desc.label {
|
if let Some(label) = desc.label {
|
||||||
descriptor.label(label);
|
descriptor.label(label);
|
||||||
}
|
}
|
||||||
Sendable(device.0.create_shader_module(&descriptor))
|
create_identified(device.0.create_shader_module(&descriptor))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn device_create_bind_group_layout(
|
fn device_create_bind_group_layout(
|
||||||
@ -1560,7 +1609,7 @@ impl crate::Context for Context {
|
|||||||
if let Some(label) = desc.label {
|
if let Some(label) = desc.label {
|
||||||
mapped_desc.label(label);
|
mapped_desc.label(label);
|
||||||
}
|
}
|
||||||
Sendable(device.0.create_bind_group_layout(&mapped_desc))
|
create_identified(device.0.create_bind_group_layout(&mapped_desc))
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn device_create_shader_module_spirv(
|
unsafe fn device_create_shader_module_spirv(
|
||||||
@ -1618,7 +1667,7 @@ impl crate::Context for Context {
|
|||||||
if let Some(label) = desc.label {
|
if let Some(label) = desc.label {
|
||||||
mapped_desc.label(label);
|
mapped_desc.label(label);
|
||||||
}
|
}
|
||||||
Sendable(device.0.create_bind_group(&mapped_desc))
|
create_identified(device.0.create_bind_group(&mapped_desc))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn device_create_pipeline_layout(
|
fn device_create_pipeline_layout(
|
||||||
@ -1635,7 +1684,7 @@ impl crate::Context for Context {
|
|||||||
if let Some(label) = desc.label {
|
if let Some(label) = desc.label {
|
||||||
mapped_desc.label(label);
|
mapped_desc.label(label);
|
||||||
}
|
}
|
||||||
Sendable(device.0.create_pipeline_layout(&mapped_desc))
|
create_identified(device.0.create_pipeline_layout(&mapped_desc))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn device_create_render_pipeline(
|
fn device_create_render_pipeline(
|
||||||
@ -1726,7 +1775,7 @@ impl crate::Context for Context {
|
|||||||
let mapped_primitive = map_primitive_state(&desc.primitive);
|
let mapped_primitive = map_primitive_state(&desc.primitive);
|
||||||
mapped_desc.primitive(&mapped_primitive);
|
mapped_desc.primitive(&mapped_primitive);
|
||||||
|
|
||||||
Sendable(device.0.create_render_pipeline(&mapped_desc))
|
create_identified(device.0.create_render_pipeline(&mapped_desc))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn device_create_compute_pipeline(
|
fn device_create_compute_pipeline(
|
||||||
@ -1747,7 +1796,7 @@ impl crate::Context for Context {
|
|||||||
if let Some(label) = desc.label {
|
if let Some(label) = desc.label {
|
||||||
mapped_desc.label(label);
|
mapped_desc.label(label);
|
||||||
}
|
}
|
||||||
Sendable(device.0.create_compute_pipeline(&mapped_desc))
|
create_identified(device.0.create_compute_pipeline(&mapped_desc))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn device_create_buffer(
|
fn device_create_buffer(
|
||||||
@ -1761,7 +1810,7 @@ impl crate::Context for Context {
|
|||||||
if let Some(label) = desc.label {
|
if let Some(label) = desc.label {
|
||||||
mapped_desc.label(label);
|
mapped_desc.label(label);
|
||||||
}
|
}
|
||||||
Sendable(device.0.create_buffer(&mapped_desc))
|
create_identified(device.0.create_buffer(&mapped_desc))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn device_create_texture(
|
fn device_create_texture(
|
||||||
@ -1780,7 +1829,7 @@ impl crate::Context for Context {
|
|||||||
mapped_desc.dimension(map_texture_dimension(desc.dimension));
|
mapped_desc.dimension(map_texture_dimension(desc.dimension));
|
||||||
mapped_desc.mip_level_count(desc.mip_level_count);
|
mapped_desc.mip_level_count(desc.mip_level_count);
|
||||||
mapped_desc.sample_count(desc.sample_count);
|
mapped_desc.sample_count(desc.sample_count);
|
||||||
Sendable(device.0.create_texture(&mapped_desc))
|
create_identified(device.0.create_texture(&mapped_desc))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn device_create_sampler(
|
fn device_create_sampler(
|
||||||
@ -1805,7 +1854,7 @@ impl crate::Context for Context {
|
|||||||
if let Some(label) = desc.label {
|
if let Some(label) = desc.label {
|
||||||
mapped_desc.label(label);
|
mapped_desc.label(label);
|
||||||
}
|
}
|
||||||
Sendable(device.0.create_sampler_with_descriptor(&mapped_desc))
|
create_identified(device.0.create_sampler_with_descriptor(&mapped_desc))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn device_create_query_set(
|
fn device_create_query_set(
|
||||||
@ -1822,7 +1871,7 @@ impl crate::Context for Context {
|
|||||||
if let Some(label) = desc.label {
|
if let Some(label) = desc.label {
|
||||||
mapped_desc.label(label);
|
mapped_desc.label(label);
|
||||||
}
|
}
|
||||||
Sendable(device.0.create_query_set(&mapped_desc))
|
create_identified(device.0.create_query_set(&mapped_desc))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn device_create_command_encoder(
|
fn device_create_command_encoder(
|
||||||
@ -1968,7 +2017,7 @@ impl crate::Context for Context {
|
|||||||
if let Some(label) = desc.label {
|
if let Some(label) = desc.label {
|
||||||
mapped.label(label);
|
mapped.label(label);
|
||||||
}
|
}
|
||||||
Sendable(texture.0.create_view_with_descriptor(&mapped))
|
create_identified(texture.0.create_view_with_descriptor(&mapped))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn surface_drop(&self, _surface: &Self::SurfaceId) {
|
fn surface_drop(&self, _surface: &Self::SurfaceId) {
|
||||||
@ -2048,7 +2097,7 @@ impl crate::Context for Context {
|
|||||||
pipeline: &Self::ComputePipelineId,
|
pipeline: &Self::ComputePipelineId,
|
||||||
index: u32,
|
index: u32,
|
||||||
) -> Self::BindGroupLayoutId {
|
) -> Self::BindGroupLayoutId {
|
||||||
Sendable(pipeline.0.get_bind_group_layout(index))
|
create_identified(pipeline.0.get_bind_group_layout(index))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_pipeline_get_bind_group_layout(
|
fn render_pipeline_get_bind_group_layout(
|
||||||
@ -2056,7 +2105,7 @@ impl crate::Context for Context {
|
|||||||
pipeline: &Self::RenderPipelineId,
|
pipeline: &Self::RenderPipelineId,
|
||||||
index: u32,
|
index: u32,
|
||||||
) -> Self::BindGroupLayoutId {
|
) -> Self::BindGroupLayoutId {
|
||||||
Sendable(pipeline.0.get_bind_group_layout(index))
|
create_identified(pipeline.0.get_bind_group_layout(index))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn command_encoder_copy_buffer_to_buffer(
|
fn command_encoder_copy_buffer_to_buffer(
|
||||||
@ -2305,7 +2354,7 @@ impl crate::Context for Context {
|
|||||||
encoder: Self::RenderBundleEncoderId,
|
encoder: Self::RenderBundleEncoderId,
|
||||||
desc: &crate::RenderBundleDescriptor,
|
desc: &crate::RenderBundleDescriptor,
|
||||||
) -> Self::RenderBundleId {
|
) -> Self::RenderBundleId {
|
||||||
Sendable(match desc.label {
|
create_identified(match desc.label {
|
||||||
Some(label) => {
|
Some(label) => {
|
||||||
let mut mapped_desc = web_sys::GpuRenderBundleDescriptor::new();
|
let mut mapped_desc = web_sys::GpuRenderBundleDescriptor::new();
|
||||||
mapped_desc.label(label);
|
mapped_desc.label(label);
|
||||||
|
|||||||
237
wgpu/src/lib.rs
237
wgpu/src/lib.rs
@ -43,7 +43,7 @@ pub use wgt::{
|
|||||||
QUERY_RESOLVE_BUFFER_ALIGNMENT, QUERY_SET_MAX_QUERIES, QUERY_SIZE, VERTEX_STRIDE_ALIGNMENT,
|
QUERY_RESOLVE_BUFFER_ALIGNMENT, QUERY_SET_MAX_QUERIES, QUERY_SIZE, VERTEX_STRIDE_ALIGNMENT,
|
||||||
};
|
};
|
||||||
|
|
||||||
use backend::{BufferMappedRange, Context as C, QueueWriteBuffer};
|
use backend::{BufferMappedRange, Context as C, Id as BackendId, QueueWriteBuffer};
|
||||||
|
|
||||||
/// Filter for error scopes.
|
/// Filter for error scopes.
|
||||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, PartialOrd)]
|
#[derive(Clone, Copy, Debug, Eq, PartialEq, PartialOrd)]
|
||||||
@ -164,28 +164,32 @@ trait RenderPassInner<Ctx: Context>: RenderInner<Ctx> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
trait GlobalId {
|
||||||
|
fn global_id(&self) -> BackendId;
|
||||||
|
}
|
||||||
|
|
||||||
trait Context: Debug + Send + Sized + Sync {
|
trait Context: Debug + Send + Sized + Sync {
|
||||||
type AdapterId: Debug + Send + Sync + 'static;
|
type AdapterId: GlobalId + Debug + Send + Sync + 'static;
|
||||||
type DeviceId: Debug + Send + Sync + 'static;
|
type DeviceId: GlobalId + Debug + Send + Sync + 'static;
|
||||||
type QueueId: Debug + Send + Sync + 'static;
|
type QueueId: GlobalId + Debug + Send + Sync + 'static;
|
||||||
type ShaderModuleId: Debug + Send + Sync + 'static;
|
type ShaderModuleId: GlobalId + Debug + Send + Sync + 'static;
|
||||||
type BindGroupLayoutId: Debug + Send + Sync + 'static;
|
type BindGroupLayoutId: GlobalId + Debug + Send + Sync + 'static;
|
||||||
type BindGroupId: Debug + Send + Sync + 'static;
|
type BindGroupId: GlobalId + Debug + Send + Sync + 'static;
|
||||||
type TextureViewId: Debug + Send + Sync + 'static;
|
type TextureViewId: GlobalId + Debug + Send + Sync + 'static;
|
||||||
type SamplerId: Debug + Send + Sync + 'static;
|
type SamplerId: GlobalId + Debug + Send + Sync + 'static;
|
||||||
type BufferId: Debug + Send + Sync + 'static;
|
type BufferId: GlobalId + Debug + Send + Sync + 'static;
|
||||||
type TextureId: Debug + Send + Sync + 'static;
|
type TextureId: GlobalId + Debug + Send + Sync + 'static;
|
||||||
type QuerySetId: Debug + Send + Sync + 'static;
|
type QuerySetId: GlobalId + Debug + Send + Sync + 'static;
|
||||||
type PipelineLayoutId: Debug + Send + Sync + 'static;
|
type PipelineLayoutId: GlobalId + Debug + Send + Sync + 'static;
|
||||||
type RenderPipelineId: Debug + Send + Sync + 'static;
|
type RenderPipelineId: GlobalId + Debug + Send + Sync + 'static;
|
||||||
type ComputePipelineId: Debug + Send + Sync + 'static;
|
type ComputePipelineId: GlobalId + Debug + Send + Sync + 'static;
|
||||||
type CommandEncoderId: Debug;
|
type CommandEncoderId: Debug;
|
||||||
type ComputePassId: Debug + ComputePassInner<Self>;
|
type ComputePassId: Debug + ComputePassInner<Self>;
|
||||||
type RenderPassId: Debug + RenderPassInner<Self>;
|
type RenderPassId: Debug + RenderPassInner<Self>;
|
||||||
type CommandBufferId: Debug + Send + Sync;
|
type CommandBufferId: Debug + Send + Sync;
|
||||||
type RenderBundleEncoderId: Debug + RenderInner<Self>;
|
type RenderBundleEncoderId: Debug + RenderInner<Self>;
|
||||||
type RenderBundleId: Debug + Send + Sync + 'static;
|
type RenderBundleId: GlobalId + Debug + Send + Sync + 'static;
|
||||||
type SurfaceId: Debug + Send + Sync + 'static;
|
type SurfaceId: GlobalId + Debug + Send + Sync + 'static;
|
||||||
|
|
||||||
type SurfaceOutputDetail: Send;
|
type SurfaceOutputDetail: Send;
|
||||||
type SubmissionIndex: Debug + Copy + Clone + Send + 'static;
|
type SubmissionIndex: Debug + Copy + Clone + Send + 'static;
|
||||||
@ -3796,6 +3800,205 @@ impl Surface {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Opaque globally-unique identifier
|
||||||
|
#[cfg(feature = "expose-ids")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "expose-ids")))]
|
||||||
|
#[repr(transparent)]
|
||||||
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||||
|
pub struct Id(BackendId);
|
||||||
|
|
||||||
|
#[cfg(feature = "expose-ids")]
|
||||||
|
impl Adapter {
|
||||||
|
/// Returns a globally-unique identifier for this `Adapter`.
|
||||||
|
///
|
||||||
|
/// Calling this method multiple times on the same object will always return the same value.
|
||||||
|
/// The returned value is guaranteed to be different for all resources created from the same `Instance`.
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "expose-ids")))]
|
||||||
|
pub fn global_id(&self) -> Id {
|
||||||
|
Id(self.id.global_id())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "expose-ids")]
|
||||||
|
impl Device {
|
||||||
|
/// Returns a globally-unique identifier for this `Device`.
|
||||||
|
///
|
||||||
|
/// Calling this method multiple times on the same object will always return the same value.
|
||||||
|
/// The returned value is guaranteed to be different for all resources created from the same `Instance`.
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "expose-ids")))]
|
||||||
|
pub fn global_id(&self) -> Id {
|
||||||
|
Id(self.id.global_id())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "expose-ids")]
|
||||||
|
impl Queue {
|
||||||
|
/// Returns a globally-unique identifier for this `Queue`.
|
||||||
|
///
|
||||||
|
/// Calling this method multiple times on the same object will always return the same value.
|
||||||
|
/// The returned value is guaranteed to be different for all resources created from the same `Instance`.
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "expose-ids")))]
|
||||||
|
pub fn global_id(&self) -> Id {
|
||||||
|
Id(self.id.global_id())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "expose-ids")]
|
||||||
|
impl ShaderModule {
|
||||||
|
/// Returns a globally-unique identifier for this `ShaderModule`.
|
||||||
|
///
|
||||||
|
/// Calling this method multiple times on the same object will always return the same value.
|
||||||
|
/// The returned value is guaranteed to be different for all resources created from the same `Instance`.
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "expose-ids")))]
|
||||||
|
pub fn global_id(&self) -> Id {
|
||||||
|
Id(self.id.global_id())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "expose-ids")]
|
||||||
|
impl BindGroupLayout {
|
||||||
|
/// Returns a globally-unique identifier for this `BindGroupLayout`.
|
||||||
|
///
|
||||||
|
/// Calling this method multiple times on the same object will always return the same value.
|
||||||
|
/// The returned value is guaranteed to be different for all resources created from the same `Instance`.
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "expose-ids")))]
|
||||||
|
pub fn global_id(&self) -> Id {
|
||||||
|
Id(self.id.global_id())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "expose-ids")]
|
||||||
|
impl BindGroup {
|
||||||
|
/// Returns a globally-unique identifier for this `BindGroup`.
|
||||||
|
///
|
||||||
|
/// Calling this method multiple times on the same object will always return the same value.
|
||||||
|
/// The returned value is guaranteed to be different for all resources created from the same `Instance`.
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "expose-ids")))]
|
||||||
|
pub fn global_id(&self) -> Id {
|
||||||
|
Id(self.id.global_id())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "expose-ids")]
|
||||||
|
impl TextureView {
|
||||||
|
/// Returns a globally-unique identifier for this `TextureView`.
|
||||||
|
///
|
||||||
|
/// Calling this method multiple times on the same object will always return the same value.
|
||||||
|
/// The returned value is guaranteed to be different for all resources created from the same `Instance`.
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "expose-ids")))]
|
||||||
|
pub fn global_id(&self) -> Id {
|
||||||
|
Id(self.id.global_id())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "expose-ids")]
|
||||||
|
impl Sampler {
|
||||||
|
/// Returns a globally-unique identifier for this `Sampler`.
|
||||||
|
///
|
||||||
|
/// Calling this method multiple times on the same object will always return the same value.
|
||||||
|
/// The returned value is guaranteed to be different for all resources created from the same `Instance`.
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "expose-ids")))]
|
||||||
|
pub fn global_id(&self) -> Id {
|
||||||
|
Id(self.id.global_id())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "expose-ids")]
|
||||||
|
impl Buffer {
|
||||||
|
/// Returns a globally-unique identifier for this `Buffer`.
|
||||||
|
///
|
||||||
|
/// Calling this method multiple times on the same object will always return the same value.
|
||||||
|
/// The returned value is guaranteed to be different for all resources created from the same `Instance`.
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "expose-ids")))]
|
||||||
|
pub fn global_id(&self) -> Id {
|
||||||
|
Id(self.id.global_id())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "expose-ids")]
|
||||||
|
impl Texture {
|
||||||
|
/// Returns a globally-unique identifier for this `Texture`.
|
||||||
|
///
|
||||||
|
/// Calling this method multiple times on the same object will always return the same value.
|
||||||
|
/// The returned value is guaranteed to be different for all resources created from the same `Instance`.
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "expose-ids")))]
|
||||||
|
pub fn global_id(&self) -> Id {
|
||||||
|
Id(self.id.global_id())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "expose-ids")]
|
||||||
|
impl QuerySet {
|
||||||
|
/// Returns a globally-unique identifier for this `QuerySet`.
|
||||||
|
///
|
||||||
|
/// Calling this method multiple times on the same object will always return the same value.
|
||||||
|
/// The returned value is guaranteed to be different for all resources created from the same `Instance`.
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "expose-ids")))]
|
||||||
|
pub fn global_id(&self) -> Id {
|
||||||
|
Id(self.id.global_id())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "expose-ids")]
|
||||||
|
impl PipelineLayout {
|
||||||
|
/// Returns a globally-unique identifier for this `PipelineLayout`.
|
||||||
|
///
|
||||||
|
/// Calling this method multiple times on the same object will always return the same value.
|
||||||
|
/// The returned value is guaranteed to be different for all resources created from the same `Instance`.
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "expose-ids")))]
|
||||||
|
pub fn global_id(&self) -> Id {
|
||||||
|
Id(self.id.global_id())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "expose-ids")]
|
||||||
|
impl RenderPipeline {
|
||||||
|
/// Returns a globally-unique identifier for this `RenderPipeline`.
|
||||||
|
///
|
||||||
|
/// Calling this method multiple times on the same object will always return the same value.
|
||||||
|
/// The returned value is guaranteed to be different for all resources created from the same `Instance`.
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "expose-ids")))]
|
||||||
|
pub fn global_id(&self) -> Id {
|
||||||
|
Id(self.id.global_id())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "expose-ids")]
|
||||||
|
impl ComputePipeline {
|
||||||
|
/// Returns a globally-unique identifier for this `ComputePipeline`.
|
||||||
|
///
|
||||||
|
/// Calling this method multiple times on the same object will always return the same value.
|
||||||
|
/// The returned value is guaranteed to be different for all resources created from the same `Instance`.
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "expose-ids")))]
|
||||||
|
pub fn global_id(&self) -> Id {
|
||||||
|
Id(self.id.global_id())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "expose-ids")]
|
||||||
|
impl RenderBundle {
|
||||||
|
/// Returns a globally-unique identifier for this `RenderBundle`.
|
||||||
|
///
|
||||||
|
/// Calling this method multiple times on the same object will always return the same value.
|
||||||
|
/// The returned value is guaranteed to be different for all resources created from the same `Instance`.
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "expose-ids")))]
|
||||||
|
pub fn global_id(&self) -> Id {
|
||||||
|
Id(self.id.global_id())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "expose-ids")]
|
||||||
|
impl Surface {
|
||||||
|
/// Returns a globally-unique identifier for this `Surface`.
|
||||||
|
///
|
||||||
|
/// Calling this method multiple times on the same object will always return the same value.
|
||||||
|
/// The returned value is guaranteed to be different for all resources created from the same `Instance`.
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "expose-ids")))]
|
||||||
|
pub fn global_id(&self) -> Id {
|
||||||
|
Id(self.id.global_id())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Type for the callback of uncaptured error handler
|
/// Type for the callback of uncaptured error handler
|
||||||
pub trait UncapturedErrorHandler: Fn(Error) + Send + 'static {}
|
pub trait UncapturedErrorHandler: Fn(Error) + Send + 'static {}
|
||||||
impl<T> UncapturedErrorHandler for T where T: Fn(Error) + Send + 'static {}
|
impl<T> UncapturedErrorHandler for T where T: Fn(Error) + Send + 'static {}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user