mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-20 14:31:08 +01:00
Small changes to facilitate fuzzing (#7970)
This commit is contained in:
1 parent
979487024e
commit
2c81896e85
3 files changed
+36
-12
No files matched your search
@@ -435,16 +435,20 @@ impl RenderBundleEncoder {
|
||||
.map_pass_err(scope)?;
|
||||
}
|
||||
RenderCommand::DrawIndirect { .. }
|
||||
| RenderCommand::MultiDrawIndirectCount { .. } => unimplemented!(),
|
||||
RenderCommand::PushDebugGroup { color: _, len: _ } => unimplemented!(),
|
||||
RenderCommand::InsertDebugMarker { color: _, len: _ } => unimplemented!(),
|
||||
RenderCommand::PopDebugGroup => unimplemented!(),
|
||||
| RenderCommand::MultiDrawIndirectCount { .. }
|
||||
| RenderCommand::PushDebugGroup { color: _, len: _ }
|
||||
| RenderCommand::InsertDebugMarker { color: _, len: _ }
|
||||
| RenderCommand::PopDebugGroup => {
|
||||
unimplemented!("not supported by a render bundle")
|
||||
}
|
||||
// Must check the TIMESTAMP_QUERY_INSIDE_PASSES feature
|
||||
RenderCommand::WriteTimestamp { .. }
|
||||
| RenderCommand::BeginOcclusionQuery { .. }
|
||||
| RenderCommand::EndOcclusionQuery
|
||||
| RenderCommand::BeginPipelineStatisticsQuery { .. }
|
||||
| RenderCommand::EndPipelineStatisticsQuery => unimplemented!(),
|
||||
| RenderCommand::EndPipelineStatisticsQuery => {
|
||||
unimplemented!("not supported by a render bundle")
|
||||
}
|
||||
RenderCommand::ExecuteBundle(_)
|
||||
| RenderCommand::SetBlendConstant(_)
|
||||
| RenderCommand::SetStencilReference(_)
|
||||
|
||||
+22
-6
@@ -34,16 +34,20 @@ const _: () = {
|
||||
#[cfg_attr(
|
||||
any(feature = "serde", feature = "replay"),
|
||||
derive(serde::Deserialize),
|
||||
serde(from = "SerialId")
|
||||
serde(try_from = "SerialId")
|
||||
)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
pub struct RawId(NonZeroU64);
|
||||
|
||||
impl RawId {
|
||||
/// Zip together an identifier and return its raw underlying representation.
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
/// If both ID components are zero.
|
||||
pub fn zip(index: Index, epoch: Epoch) -> RawId {
|
||||
let v = (index as u64) | ((epoch as u64) << 32);
|
||||
Self(NonZeroU64::new(v).unwrap())
|
||||
Self(NonZeroU64::new(v).expect("IDs may not be zero"))
|
||||
}
|
||||
|
||||
/// Unzip a raw identifier into its components.
|
||||
@@ -101,10 +105,22 @@ impl From<RawId> for SerialId {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<SerialId> for RawId {
|
||||
fn from(id: SerialId) -> Self {
|
||||
match id {
|
||||
SerialId::Id(index, epoch) => RawId::zip(index, epoch),
|
||||
pub struct ZeroIdError;
|
||||
|
||||
impl fmt::Display for ZeroIdError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "IDs may not be zero")
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<SerialId> for RawId {
|
||||
type Error = ZeroIdError;
|
||||
fn try_from(id: SerialId) -> Result<Self, ZeroIdError> {
|
||||
let SerialId::Id(index, epoch) = id;
|
||||
if index == 0 && epoch == 0 {
|
||||
Err(ZeroIdError)
|
||||
} else {
|
||||
Ok(RawId::zip(index, epoch))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +94,11 @@ where
|
||||
|
||||
pub(crate) fn remove(&mut self, id: Id<T::Marker>) -> T {
|
||||
let (index, epoch) = id.unzip();
|
||||
match mem::replace(&mut self.map[index as usize], Element::Vacant) {
|
||||
let stored = self
|
||||
.map
|
||||
.get_mut(index as usize)
|
||||
.unwrap_or_else(|| panic!("{}[{:?}] does not exist", self.kind, id));
|
||||
match mem::replace(stored, Element::Vacant) {
|
||||
Element::Occupied(value, storage_epoch) => {
|
||||
assert_eq!(epoch, storage_epoch, "id epoch mismatch");
|
||||
value
|
||||
|
||||
Reference in new issue
Block a user