From 0bdccf2ff696d30c8af4fffd4d13cc7bcad1d612 Mon Sep 17 00:00:00 2001 From: i509VCB Date: Fri, 9 Dec 2022 18:14:41 -0600 Subject: [PATCH] fix ci again --- wgpu/src/backend/direct.rs | 25 +------------------------ wgpu/src/backend/web.rs | 26 ++++---------------------- wgpu/src/context.rs | 23 ++++++++++++++++++++++- 3 files changed, 27 insertions(+), 47 deletions(-) diff --git a/wgpu/src/backend/direct.rs b/wgpu/src/backend/direct.rs index 5759343aa3..962ce1c634 100644 --- a/wgpu/src/backend/direct.rs +++ b/wgpu/src/backend/direct.rs @@ -1,5 +1,5 @@ use crate::{ - context::ObjectId, AdapterInfo, BindGroupDescriptor, BindGroupLayoutDescriptor, + context::{ObjectId, Unused}, AdapterInfo, BindGroupDescriptor, BindGroupLayoutDescriptor, BindingResource, BufferBinding, CommandEncoderDescriptor, ComputePassDescriptor, ComputePipelineDescriptor, DownlevelCapabilities, Features, Label, Limits, LoadOp, MapMode, Operations, PipelineLayoutDescriptor, RenderBundleEncoderDescriptor, RenderPipelineDescriptor, @@ -16,14 +16,12 @@ use std::{ error::Error, fmt, future::{ready, Ready}, - num::NonZeroU128, ops::Range, slice, sync::Arc, }; use wgc::command::{bundle_ffi::*, compute_ffi::*, render_ffi::*}; use wgc::id::TypedId; -use wgt::strict_assert_eq; const LABEL: &str = "label"; @@ -452,27 +450,6 @@ pub struct CommandEncoder { open: bool, } -/// Representation of an object id that is not used. -/// -/// This may be used as the id type when only a the data associated type is used for a specific type of object. -#[derive(Debug, Clone, Copy)] -pub struct Unused; - -const UNUSED_SENTINEL: Option = NonZeroU128::new(u128::MAX); - -impl From for Unused { - fn from(id: ObjectId) -> Self { - strict_assert_eq!(Some(NonZeroU128::from(id)), UNUSED_SENTINEL); - Self - } -} - -impl From for ObjectId { - fn from(_: Unused) -> Self { - ObjectId::from(UNUSED_SENTINEL.expect("This should never panic")) - } -} - impl crate::Context for Context { type AdapterId = wgc::id::AdapterId; type AdapterData = (); diff --git a/wgpu/src/backend/web.rs b/wgpu/src/backend/web.rs index 9f58a68684..a12b81e59d 100644 --- a/wgpu/src/backend/web.rs +++ b/wgpu/src/backend/web.rs @@ -19,7 +19,7 @@ use wasm_bindgen::{ }; use crate::{ - context::{ObjectId, QueueWriteBuffer}, + context::{ObjectId, QueueWriteBuffer, Unused}, UncapturedErrorHandler, }; @@ -52,7 +52,7 @@ impl + JsCast> From for Identified { // // This assumption we sadly have to assume to prevent littering the code with unsafe blocks. let wasm = unsafe { JsValue::from_abi(raw.get() as u32) }; - strict_assert!(wasm.is_instance_of::()); + wgt::strict_assert!(wasm.is_instance_of::()); // SAFETY: The ABI of the type must be a u32, and strict asserts ensure the right type is used. Self(wasm.unchecked_into(), global_id) } @@ -695,24 +695,6 @@ extern "C" { fn worker(this: &Global) -> JsValue; } -// The web doesn't provide any way to identify specific queue -// submissions. But Clippy gets concerned if we pass around `()` as if -// it were meaningful. -#[derive(Debug, Clone, Copy)] -pub struct SubmissionIndex; - -impl From for SubmissionIndex { - fn from(_: ObjectId) -> Self { - Self - } -} - -impl From for ObjectId { - fn from(_: SubmissionIndex) -> Self { - Self::dummy() - } -} - impl crate::context::Context for Context { type AdapterId = Identified; type AdapterData = (); @@ -758,7 +740,7 @@ impl crate::context::Context for Context { type SurfaceData = (); type SurfaceOutputDetail = SurfaceOutputDetail; - type SubmissionIndex = SubmissionIndex; + type SubmissionIndex = Unused; type SubmissionIndexData = (); type RequestAdapterFuture = MakeSendFuture< @@ -2364,7 +2346,7 @@ impl crate::context::Context for Context { queue.0.submit(&temp_command_buffers); - (SubmissionIndex, ()) + (Unused, ()) } fn queue_get_timestamp_period( diff --git a/wgpu/src/context.rs b/wgpu/src/context.rs index 0f99dc1e63..f6a167b491 100644 --- a/wgpu/src/context.rs +++ b/wgpu/src/context.rs @@ -5,7 +5,7 @@ use std::{ use wgt::{ strict_assert, AdapterInfo, BufferAddress, BufferSize, Color, DownlevelCapabilities, DynamicOffset, Extent3d, Features, ImageDataLayout, ImageSubresourceRange, IndexFormat, Limits, - ShaderStages, SurfaceConfiguration, SurfaceStatus, TextureFormat, TextureFormatFeatures, + ShaderStages, SurfaceConfiguration, SurfaceStatus, TextureFormat, TextureFormatFeatures, strict_assert_eq, }; use crate::{ @@ -1017,6 +1017,27 @@ fn downcast_mut(data: &mut crate::Data) -> &mu unsafe { &mut *(data as *mut dyn Any as *mut T) } } +/// Representation of an object id that is not used. +/// +/// This may be used as the id type when only a the data associated type is used for a specific type of object. +#[derive(Debug, Clone, Copy)] +pub struct Unused; + +const UNUSED_SENTINEL: Option = NonZeroU128::new(u128::MAX); + +impl From for Unused { + fn from(id: ObjectId) -> Self { + strict_assert_eq!(Some(NonZeroU128::from(id)), UNUSED_SENTINEL); + Self + } +} + +impl From for ObjectId { + fn from(_: Unused) -> Self { + ObjectId::from(UNUSED_SENTINEL.expect("This should never panic")) + } +} + pub(crate) struct DeviceRequest { pub device_id: ObjectId, pub device_data: Box,