statically assert public wgpu types appropriately implement Send and Sync (#3025)

This commit is contained in:
i509VCB 2022-09-16 11:36:23 -05:00 committed by GitHub
parent 9e3efd7019
commit b752c7d248
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 85 additions and 13 deletions

View File

@ -68,6 +68,7 @@ the same every time it is rendered, we now warn if it is missing.
- Improve the validation and error reporting of buffer mappings by @nical in [#2848](https://github.com/gfx-rs/wgpu/pull/2848)
- Fix compilation errors when using wgpu-core in isolation while targetting `wasm32-unknown-unknown` by @Seamooo in [#2922](https://github.com/gfx-rs/wgpu/pull/2922)
- Fixed opening of RenderDoc library by @abuffseagull in [#2930](https://github.com/gfx-rs/wgpu/pull/2930)
- Fixed `CommandEncoder` not being `Send` and `Sync` on web by @i509VCB in [#3025](https://github.com/gfx-rs/wgpu/pull/3025)
#### Metal
- Add the missing `msg_send![view, retain]` call within `from_view` by @jinleili in [#2976](https://github.com/gfx-rs/wgpu/pull/2976)

7
Cargo.lock generated
View File

@ -1919,6 +1919,12 @@ dependencies = [
"num-traits 0.2.15",
]
[[package]]
name = "static_assertions"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]]
name = "strsim"
version = "0.10.0"
@ -2365,6 +2371,7 @@ dependencies = [
"raw-window-handle 0.5.0",
"serde",
"smallvec",
"static_assertions",
"wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",

View File

@ -117,6 +117,7 @@ parking_lot = ">=0.11,<0.13"
raw-window-handle = "0.5"
serde = { version = "1", features = ["derive"], optional = true }
smallvec = "1"
static_assertions = "1.1.0"
[dev-dependencies]
bitflags = "1"

View File

@ -993,7 +993,7 @@ impl crate::Context for Context {
type PipelineLayoutId = Sendable<web_sys::GpuPipelineLayout>;
type RenderPipelineId = Sendable<web_sys::GpuRenderPipeline>;
type ComputePipelineId = Sendable<web_sys::GpuComputePipeline>;
type CommandEncoderId = web_sys::GpuCommandEncoder;
type CommandEncoderId = Sendable<web_sys::GpuCommandEncoder>;
type ComputePassId = ComputePass;
type RenderPassId = RenderPass;
type CommandBufferId = Sendable<web_sys::GpuCommandBuffer>;
@ -1719,9 +1719,11 @@ impl crate::Context for Context {
if let Some(label) = desc.label {
mapped_desc.label(label);
}
device
.0
.create_command_encoder_with_descriptor(&mapped_desc)
Sendable(
device
.0
.create_command_encoder_with_descriptor(&mapped_desc),
)
}
fn device_create_render_bundle_encoder(
@ -1951,7 +1953,7 @@ impl crate::Context for Context {
destination_offset: wgt::BufferAddress,
copy_size: wgt::BufferAddress,
) {
encoder.copy_buffer_to_buffer_with_f64_and_f64_and_f64(
encoder.0.copy_buffer_to_buffer_with_f64_and_f64_and_f64(
&source.0,
source_offset as f64,
&destination.0,
@ -1967,7 +1969,7 @@ impl crate::Context for Context {
destination: crate::ImageCopyTexture,
copy_size: wgt::Extent3d,
) {
encoder.copy_buffer_to_texture_with_gpu_extent_3d_dict(
encoder.0.copy_buffer_to_texture_with_gpu_extent_3d_dict(
&map_buffer_copy_view(source),
&map_texture_copy_view(destination),
&map_extent_3d(copy_size),
@ -1981,7 +1983,7 @@ impl crate::Context for Context {
destination: crate::ImageCopyBuffer,
copy_size: wgt::Extent3d,
) {
encoder.copy_texture_to_buffer_with_gpu_extent_3d_dict(
encoder.0.copy_texture_to_buffer_with_gpu_extent_3d_dict(
&map_texture_copy_view(source),
&map_buffer_copy_view(destination),
&map_extent_3d(copy_size),
@ -1995,7 +1997,7 @@ impl crate::Context for Context {
destination: crate::ImageCopyTexture,
copy_size: wgt::Extent3d,
) {
encoder.copy_texture_to_texture_with_gpu_extent_3d_dict(
encoder.0.copy_texture_to_texture_with_gpu_extent_3d_dict(
&map_texture_copy_view(source),
&map_texture_copy_view(destination),
&map_extent_3d(copy_size),
@ -2011,7 +2013,7 @@ impl crate::Context for Context {
if let Some(label) = desc.label {
mapped_desc.label(label);
}
ComputePass(encoder.begin_compute_pass_with_descriptor(&mapped_desc))
ComputePass(encoder.0.begin_compute_pass_with_descriptor(&mapped_desc))
}
fn command_encoder_end_compute_pass(
@ -2106,7 +2108,7 @@ impl crate::Context for Context {
mapped_desc.depth_stencil_attachment(&mapped_depth_stencil_attachment);
}
RenderPass(encoder.begin_render_pass(&mapped_desc))
RenderPass(encoder.0.begin_render_pass(&mapped_desc))
}
fn command_encoder_end_render_pass(
@ -2118,13 +2120,13 @@ impl crate::Context for Context {
}
fn command_encoder_finish(&self, encoder: Self::CommandEncoderId) -> Self::CommandBufferId {
let label = encoder.label();
let label = encoder.0.label();
Sendable(if label.is_empty() {
encoder.finish()
encoder.0.finish()
} else {
let mut mapped_desc = web_sys::GpuCommandBufferDescriptor::new();
mapped_desc.label(&label);
encoder.finish_with_descriptor(&mapped_desc)
encoder.0.finish_with_descriptor(&mapped_desc)
})
}

View File

@ -53,6 +53,7 @@ pub enum ErrorFilter {
/// Catch only validation errors.
Validation,
}
static_assertions::assert_impl_all!(ErrorFilter: Send, Sync);
trait ComputePassInner<Ctx: Context> {
fn set_pipeline(&mut self, pipeline: &Ctx::ComputePipelineId);
@ -547,6 +548,7 @@ trait Context: Debug + Send + Sized + Sync {
pub struct Instance {
context: Arc<C>,
}
static_assertions::assert_impl_all!(Instance: Send, Sync);
/// Handle to a physical graphics and/or compute device.
///
@ -561,6 +563,7 @@ pub struct Adapter {
context: Arc<C>,
id: <C as Context>::AdapterId,
}
static_assertions::assert_impl_all!(Adapter: Send, Sync);
impl Drop for Adapter {
fn drop(&mut self) {
@ -583,12 +586,14 @@ pub struct Device {
context: Arc<C>,
id: <C as Context>::DeviceId,
}
static_assertions::assert_impl_all!(Device: Send, Sync);
/// Identifier for a particular call to [`Queue::submit`]. Can be used
/// as part of an argument to [`Device::poll`] to block for a particular
/// submission to finish.
#[derive(Debug, Copy, Clone)]
pub struct SubmissionIndex(<C as Context>::SubmissionIndex);
static_assertions::assert_impl_all!(SubmissionIndex: Send, Sync);
/// The main purpose of this struct is to resolve mapped ranges (convert sizes
/// to end points), and to ensure that the sub-ranges don't intersect.
@ -663,6 +668,7 @@ pub struct Buffer {
size: wgt::BufferAddress,
usage: BufferUsages,
}
static_assertions::assert_impl_all!(Buffer: Send, Sync);
/// Slice into a [`Buffer`].
///
@ -675,6 +681,7 @@ pub struct BufferSlice<'a> {
offset: BufferAddress,
size: Option<BufferSize>,
}
static_assertions::assert_impl_all!(BufferSlice: Send, Sync);
/// Handle to a texture on the GPU.
///
@ -687,6 +694,7 @@ pub struct Texture {
id: <C as Context>::TextureId,
owned: bool,
}
static_assertions::assert_impl_all!(Texture: Send, Sync);
/// Handle to a texture view.
///
@ -699,6 +707,7 @@ pub struct TextureView {
context: Arc<C>,
id: <C as Context>::TextureViewId,
}
static_assertions::assert_impl_all!(TextureView: Send, Sync);
/// Handle to a sampler.
///
@ -714,6 +723,7 @@ pub struct Sampler {
context: Arc<C>,
id: <C as Context>::SamplerId,
}
static_assertions::assert_impl_all!(Sampler: Send, Sync);
impl Drop for Sampler {
fn drop(&mut self) {
@ -732,6 +742,7 @@ pub struct Surface {
context: Arc<C>,
id: <C as Context>::SurfaceId,
}
static_assertions::assert_impl_all!(Surface: Send, Sync);
impl Drop for Surface {
fn drop(&mut self) {
@ -757,6 +768,7 @@ pub struct BindGroupLayout {
context: Arc<C>,
id: <C as Context>::BindGroupLayoutId,
}
static_assertions::assert_impl_all!(BindGroupLayout: Send, Sync);
impl Drop for BindGroupLayout {
fn drop(&mut self) {
@ -779,6 +791,7 @@ pub struct BindGroup {
context: Arc<C>,
id: <C as Context>::BindGroupId,
}
static_assertions::assert_impl_all!(BindGroup: Send, Sync);
impl Drop for BindGroup {
fn drop(&mut self) {
@ -801,6 +814,7 @@ pub struct ShaderModule {
context: Arc<C>,
id: <C as Context>::ShaderModuleId,
}
static_assertions::assert_impl_all!(ShaderModule: Send, Sync);
impl Drop for ShaderModule {
fn drop(&mut self) {
@ -844,6 +858,7 @@ pub enum ShaderSource<'a> {
#[cfg_attr(docsrs, doc(cfg(feature = "naga")))]
Naga(naga::Module),
}
static_assertions::assert_impl_all!(ShaderSource: Send, Sync);
/// Descriptor for use with [`Device::create_shader_module`].
///
@ -855,6 +870,7 @@ pub struct ShaderModuleDescriptor<'a> {
/// Source code for the shader.
pub source: ShaderSource<'a>,
}
static_assertions::assert_impl_all!(ShaderModuleDescriptor: Send, Sync);
/// Descriptor for a shader module given by SPIR-V binary.
pub struct ShaderModuleDescriptorSpirV<'a> {
@ -863,6 +879,7 @@ pub struct ShaderModuleDescriptorSpirV<'a> {
/// Binary SPIR-V data, in 4-byte words.
pub source: Cow<'a, [u32]>,
}
static_assertions::assert_impl_all!(ShaderModuleDescriptorSpirV: Send, Sync);
/// Handle to a pipeline layout.
///
@ -875,6 +892,7 @@ pub struct PipelineLayout {
context: Arc<C>,
id: <C as Context>::PipelineLayoutId,
}
static_assertions::assert_impl_all!(PipelineLayout: Send, Sync);
impl Drop for PipelineLayout {
fn drop(&mut self) {
@ -895,6 +913,7 @@ pub struct RenderPipeline {
context: Arc<C>,
id: <C as Context>::RenderPipelineId,
}
static_assertions::assert_impl_all!(RenderPipeline: Send, Sync);
impl Drop for RenderPipeline {
fn drop(&mut self) {
@ -928,6 +947,7 @@ pub struct ComputePipeline {
context: Arc<C>,
id: <C as Context>::ComputePipelineId,
}
static_assertions::assert_impl_all!(ComputePipeline: Send, Sync);
impl Drop for ComputePipeline {
fn drop(&mut self) {
@ -962,6 +982,7 @@ pub struct CommandBuffer {
context: Arc<C>,
id: Option<<C as Context>::CommandBufferId>,
}
static_assertions::assert_impl_all!(CommandBuffer: Send, Sync);
impl Drop for CommandBuffer {
fn drop(&mut self) {
@ -987,6 +1008,7 @@ pub struct CommandEncoder {
context: Arc<C>,
id: Option<<C as Context>::CommandEncoderId>,
}
static_assertions::assert_impl_all!(CommandEncoder: Send, Sync);
impl Drop for CommandEncoder {
fn drop(&mut self) {
@ -1042,6 +1064,7 @@ pub struct RenderBundleEncoder<'a> {
/// command buffer.
_p: PhantomData<*const u8>,
}
static_assertions::assert_not_impl_any!(RenderBundleEncoder<'_>: Send, Sync);
/// Pre-prepared reusable bundle of GPU operations.
///
@ -1057,6 +1080,7 @@ pub struct RenderBundle {
context: Arc<C>,
id: <C as Context>::RenderBundleId,
}
static_assertions::assert_impl_all!(RenderBundle: Send, Sync);
impl Drop for RenderBundle {
fn drop(&mut self) {
@ -1075,6 +1099,7 @@ pub struct QuerySet {
context: Arc<C>,
id: <C as Context>::QuerySetId,
}
static_assertions::assert_impl_all!(QuerySet: Send, Sync);
impl Drop for QuerySet {
fn drop(&mut self) {
@ -1096,6 +1121,7 @@ pub struct Queue {
context: Arc<C>,
id: <C as Context>::QueueId,
}
static_assertions::assert_impl_all!(Queue: Send, Sync);
/// Resource that can be bound to a pipeline.
///
@ -1140,6 +1166,7 @@ pub enum BindingResource<'a> {
/// [`BindGroupLayoutEntry::count`] set to Some.
TextureViewArray(&'a [&'a TextureView]),
}
static_assertions::assert_impl_all!(BindingResource: Send, Sync);
/// Describes the segment of a buffer to bind.
///
@ -1158,6 +1185,7 @@ pub struct BufferBinding<'a> {
/// Size of the binding, or `None` for using the rest of the buffer.
pub size: Option<BufferSize>,
}
static_assertions::assert_impl_all!(BufferBinding: Send, Sync);
/// Operation to perform to the output attachment at the start of a renderpass.
///
@ -1215,6 +1243,7 @@ pub struct RenderPassColorAttachment<'tex> {
/// What operations will be performed on this color attachment.
pub ops: Operations<Color>,
}
static_assertions::assert_impl_all!(RenderPassColorAttachment: Send, Sync);
/// Describes a depth/stencil attachment to a [`RenderPass`].
///
@ -1231,6 +1260,7 @@ pub struct RenderPassDepthStencilAttachment<'tex> {
/// What operations will be performed on the stencil part of the attachment.
pub stencil_ops: Option<Operations<u32>>,
}
static_assertions::assert_impl_all!(RenderPassDepthStencilAttachment: Send, Sync);
// The underlying types are also exported so that documentation shows up for them
@ -1244,6 +1274,7 @@ pub use wgt::RequestAdapterOptions as RequestAdapterOptionsBase;
/// Corresponds to [WebGPU `GPURequestAdapterOptions`](
/// https://gpuweb.github.io/gpuweb/#dictdef-gpurequestadapteroptions).
pub type RequestAdapterOptions<'a> = RequestAdapterOptionsBase<&'a Surface>;
static_assertions::assert_impl_all!(RequestAdapterOptions: Send, Sync);
/// Describes a [`Device`].
///
/// For use with [`Adapter::request_device`].
@ -1251,6 +1282,7 @@ pub type RequestAdapterOptions<'a> = RequestAdapterOptionsBase<&'a Surface>;
/// Corresponds to [WebGPU `GPUDeviceDescriptor`](
/// https://gpuweb.github.io/gpuweb/#dictdef-gpudevicedescriptor).
pub type DeviceDescriptor<'a> = wgt::DeviceDescriptor<Label<'a>>;
static_assertions::assert_impl_all!(DeviceDescriptor: Send, Sync);
/// Describes a [`Buffer`].
///
/// For use with [`Device::create_buffer`].
@ -1258,6 +1290,7 @@ pub type DeviceDescriptor<'a> = wgt::DeviceDescriptor<Label<'a>>;
/// Corresponds to [WebGPU `GPUBufferDescriptor`](
/// https://gpuweb.github.io/gpuweb/#dictdef-gpubufferdescriptor).
pub type BufferDescriptor<'a> = wgt::BufferDescriptor<Label<'a>>;
static_assertions::assert_impl_all!(BufferDescriptor: Send, Sync);
/// Describes a [`CommandEncoder`].
///
/// For use with [`Device::create_command_encoder`].
@ -1265,6 +1298,7 @@ pub type BufferDescriptor<'a> = wgt::BufferDescriptor<Label<'a>>;
/// Corresponds to [WebGPU `GPUCommandEncoderDescriptor`](
/// https://gpuweb.github.io/gpuweb/#dictdef-gpucommandencoderdescriptor).
pub type CommandEncoderDescriptor<'a> = wgt::CommandEncoderDescriptor<Label<'a>>;
static_assertions::assert_impl_all!(CommandEncoderDescriptor: Send, Sync);
/// Describes a [`RenderBundle`].
///
/// For use with [`RenderBundleEncoder::finish`].
@ -1272,6 +1306,7 @@ pub type CommandEncoderDescriptor<'a> = wgt::CommandEncoderDescriptor<Label<'a>>
/// Corresponds to [WebGPU `GPURenderBundleDescriptor`](
/// https://gpuweb.github.io/gpuweb/#dictdef-gpurenderbundledescriptor).
pub type RenderBundleDescriptor<'a> = wgt::RenderBundleDescriptor<Label<'a>>;
static_assertions::assert_impl_all!(RenderBundleDescriptor: Send, Sync);
/// Describes a [`Texture`].
///
/// For use with [`Device::create_texture`].
@ -1279,6 +1314,7 @@ pub type RenderBundleDescriptor<'a> = wgt::RenderBundleDescriptor<Label<'a>>;
/// Corresponds to [WebGPU `GPUTextureDescriptor`](
/// https://gpuweb.github.io/gpuweb/#dictdef-gputexturedescriptor).
pub type TextureDescriptor<'a> = wgt::TextureDescriptor<Label<'a>>;
static_assertions::assert_impl_all!(TextureDescriptor: Send, Sync);
/// Describes a [`QuerySet`].
///
/// For use with [`Device::create_query_set`].
@ -1286,9 +1322,11 @@ pub type TextureDescriptor<'a> = wgt::TextureDescriptor<Label<'a>>;
/// Corresponds to [WebGPU `GPUQuerySetDescriptor`](
/// https://gpuweb.github.io/gpuweb/#dictdef-gpuquerysetdescriptor).
pub type QuerySetDescriptor<'a> = wgt::QuerySetDescriptor<Label<'a>>;
static_assertions::assert_impl_all!(QuerySetDescriptor: Send, Sync);
pub use wgt::Maintain as MaintainBase;
/// Passed to [`Device::poll`] to control how and if it should block.
pub type Maintain = wgt::Maintain<SubmissionIndex>;
static_assertions::assert_impl_all!(Maintain: Send, Sync);
/// Describes a [`TextureView`].
///
@ -1320,6 +1358,7 @@ pub struct TextureViewDescriptor<'a> {
/// If `None`, considered to include the rest of the array layers, but at least 1 in total.
pub array_layer_count: Option<NonZeroU32>,
}
static_assertions::assert_impl_all!(TextureViewDescriptor: Send, Sync);
/// Describes a [`PipelineLayout`].
///
@ -1341,6 +1380,7 @@ pub struct PipelineLayoutDescriptor<'a> {
/// If this array is non-empty, the [`Features::PUSH_CONSTANTS`] must be enabled.
pub push_constant_ranges: &'a [PushConstantRange],
}
static_assertions::assert_impl_all!(PipelineLayoutDescriptor: Send, Sync);
/// Describes a [`Sampler`].
///
@ -1375,6 +1415,7 @@ pub struct SamplerDescriptor<'a> {
/// Border color to use when address_mode is [`AddressMode::ClampToBorder`]
pub border_color: Option<SamplerBorderColor>,
}
static_assertions::assert_impl_all!(SamplerDescriptor: Send, Sync);
impl Default for SamplerDescriptor<'_> {
fn default() -> Self {
@ -1408,6 +1449,7 @@ pub struct BindGroupEntry<'a> {
/// Resource to attach to the binding
pub resource: BindingResource<'a>,
}
static_assertions::assert_impl_all!(BindGroupEntry: Send, Sync);
/// Describes a group of bindings and the resources to be bound.
///
@ -1424,6 +1466,7 @@ pub struct BindGroupDescriptor<'a> {
/// The resources to bind to this bind group.
pub entries: &'a [BindGroupEntry<'a>],
}
static_assertions::assert_impl_all!(BindGroupDescriptor: Send, Sync);
/// Describes the attachments of a render pass.
///
@ -1443,6 +1486,7 @@ pub struct RenderPassDescriptor<'tex, 'desc> {
/// The depth and stencil attachment of the render pass, if any.
pub depth_stencil_attachment: Option<RenderPassDepthStencilAttachment<'tex>>,
}
static_assertions::assert_impl_all!(RenderPassDescriptor: Send, Sync);
/// Describes how the vertex buffer is interpreted.
///
@ -1459,6 +1503,7 @@ pub struct VertexBufferLayout<'a> {
/// The list of attributes which comprise a single vertex.
pub attributes: &'a [VertexAttribute],
}
static_assertions::assert_impl_all!(VertexBufferLayout: Send, Sync);
/// Describes the vertex processing in a render pipeline.
///
@ -1476,6 +1521,7 @@ pub struct VertexState<'a> {
/// The format of any vertex buffers used with this pipeline.
pub buffers: &'a [VertexBufferLayout<'a>],
}
static_assertions::assert_impl_all!(VertexState: Send, Sync);
/// Describes the fragment processing in a render pipeline.
///
@ -1493,6 +1539,7 @@ pub struct FragmentState<'a> {
/// The color state of the render targets.
pub targets: &'a [Option<ColorTargetState>],
}
static_assertions::assert_impl_all!(FragmentState: Send, Sync);
/// Describes a render (graphics) pipeline.
///
@ -1520,6 +1567,7 @@ pub struct RenderPipelineDescriptor<'a> {
/// layers the attachments will have.
pub multiview: Option<NonZeroU32>,
}
static_assertions::assert_impl_all!(RenderPipelineDescriptor: Send, Sync);
/// Describes the attachments of a compute pass.
///
@ -1532,6 +1580,7 @@ pub struct ComputePassDescriptor<'a> {
/// Debug label of the compute pass. This will show up in graphics debuggers for easy identification.
pub label: Label<'a>,
}
static_assertions::assert_impl_all!(ComputePassDescriptor: Send, Sync);
/// Describes a compute pipeline.
///
@ -1551,6 +1600,7 @@ pub struct ComputePipelineDescriptor<'a> {
/// and no return value in the shader.
pub entry_point: &'a str,
}
static_assertions::assert_impl_all!(ComputePipelineDescriptor: Send, Sync);
pub use wgt::ImageCopyBuffer as ImageCopyBufferBase;
/// View of a buffer which can be used to copy to/from a texture.
@ -1558,6 +1608,7 @@ pub use wgt::ImageCopyBuffer as ImageCopyBufferBase;
/// Corresponds to [WebGPU `GPUImageCopyBuffer`](
/// https://gpuweb.github.io/gpuweb/#dictdef-gpuimagecopybuffer).
pub type ImageCopyBuffer<'a> = ImageCopyBufferBase<&'a Buffer>;
static_assertions::assert_impl_all!(ImageCopyBuffer: Send, Sync);
pub use wgt::ImageCopyTexture as ImageCopyTextureBase;
/// View of a texture which can be used to copy to/from a buffer/texture.
@ -1565,6 +1616,7 @@ pub use wgt::ImageCopyTexture as ImageCopyTextureBase;
/// Corresponds to [WebGPU `GPUImageCopyTexture`](
/// https://gpuweb.github.io/gpuweb/#dictdef-gpuimagecopytexture).
pub type ImageCopyTexture<'a> = ImageCopyTextureBase<&'a Texture>;
static_assertions::assert_impl_all!(ImageCopyTexture: Send, Sync);
/// Describes a [`BindGroupLayout`].
///
@ -1580,6 +1632,7 @@ pub struct BindGroupLayoutDescriptor<'a> {
/// Array of entries in this BindGroupLayout
pub entries: &'a [BindGroupLayoutEntry],
}
static_assertions::assert_impl_all!(BindGroupLayoutDescriptor: Send, Sync);
/// Describes a [`RenderBundleEncoder`].
///
@ -1603,6 +1656,7 @@ pub struct RenderBundleEncoderDescriptor<'a> {
/// If this render bundle will rendering to multiple array layers in the attachments at the same time.
pub multiview: Option<NonZeroU32>,
}
static_assertions::assert_impl_all!(RenderBundleEncoderDescriptor: Send, Sync);
/// Surface texture that can be rendered to.
/// Result of a successful call to [`Surface::get_current_texture`].
@ -1616,6 +1670,7 @@ pub struct SurfaceTexture {
presented: bool,
detail: <C as Context>::SurfaceOutputDetail,
}
static_assertions::assert_impl_all!(SurfaceTexture: Send, Sync);
/// Result of an unsuccessful call to [`Surface::get_current_texture`].
#[derive(Clone, PartialEq, Eq, Debug)]
@ -1629,6 +1684,7 @@ pub enum SurfaceError {
/// There is no more memory left to allocate a new frame.
OutOfMemory,
}
static_assertions::assert_impl_all!(SurfaceError: Send, Sync);
impl Display for SurfaceError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
@ -2269,6 +2325,7 @@ impl Drop for Device {
/// Requesting a device failed.
#[derive(Clone, PartialEq, Eq, Debug)]
pub struct RequestDeviceError;
static_assertions::assert_impl_all!(RequestDeviceError: Send, Sync);
impl Display for RequestDeviceError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
@ -2281,6 +2338,7 @@ impl error::Error for RequestDeviceError {}
/// Error occurred when trying to async map a buffer.
#[derive(Clone, PartialEq, Eq, Debug)]
pub struct BufferAsyncError;
static_assertions::assert_impl_all!(BufferAsyncError: Send, Sync);
impl Display for BufferAsyncError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
@ -2298,6 +2356,7 @@ pub enum MapMode {
/// Map only for writing
Write,
}
static_assertions::assert_impl_all!(MapMode: Send, Sync);
fn range_to_offset_size<S: RangeBounds<BufferAddress>>(
bounds: S,
@ -3454,6 +3513,7 @@ pub struct QueueWriteBufferView<'a> {
offset: BufferAddress,
inner: QueueWriteBuffer,
}
static_assertions::assert_impl_all!(QueueWriteBufferView: Send, Sync);
impl<'a> std::ops::Deref for QueueWriteBufferView<'a> {
type Target = [u8];
@ -3682,6 +3742,7 @@ pub enum Error {
description: String,
},
}
static_assertions::assert_impl_all!(Error: Send);
impl error::Error for Error {
fn source(&self) -> Option<&(dyn error::Error + 'static)> {