mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-30 18:14:18 +01:00
[core] Move validity into Arc<BindGroup>
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
1 parent
52a280d631
commit
2a8304eef3
10 files changed
+257
-182
No files matched your search
@@ -117,8 +117,8 @@ use crate::{
|
||||
init_tracker::{BufferInitTrackerAction, MemoryInitKind, TextureInitTrackerAction},
|
||||
pipeline::{PipelineFlags, RenderPipeline},
|
||||
resource::{
|
||||
Buffer, DestroyedResourceError, Fallible, InvalidResourceError, Labeled, ParentDevice,
|
||||
RawResourceAccess, ResourceState, TrackingData,
|
||||
Buffer, DestroyedResourceError, InvalidOrDestroyedResourceError, InvalidResourceError,
|
||||
Labeled, ParentDevice, RawResourceAccess, ResourceState, TrackingData,
|
||||
},
|
||||
resource_log,
|
||||
snatch::SnatchGuard,
|
||||
@@ -842,7 +842,7 @@ impl RenderBundleEncoder {
|
||||
|
||||
fn set_bind_group(
|
||||
state: &mut State,
|
||||
bind_group_guard: &crate::storage::Storage<Fallible<BindGroup>>,
|
||||
bind_group_guard: &crate::storage::Storage<Arc<BindGroup>>,
|
||||
dynamic_offsets: &[u32],
|
||||
index: u32,
|
||||
num_dynamic_offsets: usize,
|
||||
@@ -867,7 +867,7 @@ fn set_bind_group(
|
||||
let bind_group = bind_group_id.map(|id| bind_group_guard.get(id));
|
||||
|
||||
if let Some(bind_group) = bind_group {
|
||||
let bind_group = bind_group.get()?;
|
||||
bind_group.check_is_valid()?;
|
||||
bind_group.same_device(&state.device)?;
|
||||
bind_group.validate_dynamic_bindings(index, offsets)?;
|
||||
|
||||
@@ -1295,10 +1295,21 @@ pub enum ExecutionError {
|
||||
Device(#[from] DeviceError),
|
||||
#[error(transparent)]
|
||||
DestroyedResource(#[from] DestroyedResourceError),
|
||||
#[error(transparent)]
|
||||
InvalidResource(#[from] InvalidResourceError),
|
||||
#[error("Using {0} in a render bundle is not implemented")]
|
||||
Unimplemented(&'static str),
|
||||
}
|
||||
|
||||
impl From<InvalidOrDestroyedResourceError> for ExecutionError {
|
||||
fn from(e: InvalidOrDestroyedResourceError) -> Self {
|
||||
match e {
|
||||
InvalidOrDestroyedResourceError::InvalidResource(e) => Self::InvalidResource(e),
|
||||
InvalidOrDestroyedResourceError::DestroyedResource(e) => Self::DestroyedResource(e),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub type RenderBundleDescriptor<'a> = wgt::RenderBundleDescriptor<Label<'a>>;
|
||||
|
||||
#[derive(Debug)]
|
||||
@@ -1866,8 +1877,6 @@ pub enum RenderBundleErrorInner {
|
||||
MissingDownlevelFlags(#[from] MissingDownlevelFlags),
|
||||
#[error(transparent)]
|
||||
Bind(#[from] BindError),
|
||||
#[error(transparent)]
|
||||
InvalidResource(#[from] InvalidResourceError),
|
||||
#[error("Render bundle encoder has already ended")]
|
||||
Ended,
|
||||
}
|
||||
@@ -1900,7 +1909,6 @@ impl WebGpuError for RenderBundleError {
|
||||
RenderBundleErrorInner::Draw(e) => e.webgpu_error_type(),
|
||||
RenderBundleErrorInner::MissingDownlevelFlags(e) => e.webgpu_error_type(),
|
||||
RenderBundleErrorInner::Bind(e) => e.webgpu_error_type(),
|
||||
RenderBundleErrorInner::InvalidResource(e) => e.webgpu_error_type(),
|
||||
RenderBundleErrorInner::Ended => ErrorType::Validation,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,8 +33,9 @@ use crate::{
|
||||
init_tracker::MemoryInitKind,
|
||||
pipeline::ComputePipeline,
|
||||
resource::{
|
||||
self, Buffer, DestroyedResourceError, InvalidResourceError, Labeled,
|
||||
MissingBufferUsageError, ParentDevice, RawResourceAccess, TextureView, Trackable,
|
||||
self, Buffer, DestroyedResourceError, InvalidOrDestroyedResourceError,
|
||||
InvalidResourceError, Labeled, MissingBufferUsageError, ParentDevice, RawResourceAccess,
|
||||
TextureView, Trackable,
|
||||
},
|
||||
track::{ResourceUsageCompatibilityError, TextureViewBindGroupState, Tracker},
|
||||
Label,
|
||||
@@ -204,6 +205,15 @@ pub enum ComputePassErrorInner {
|
||||
InvalidValuesOffset(#[from] pass::InvalidValuesOffset),
|
||||
}
|
||||
|
||||
impl From<InvalidOrDestroyedResourceError> for ComputePassErrorInner {
|
||||
fn from(value: InvalidOrDestroyedResourceError) -> Self {
|
||||
match value {
|
||||
InvalidOrDestroyedResourceError::InvalidResource(e) => Self::InvalidResource(e),
|
||||
InvalidOrDestroyedResourceError::DestroyedResource(e) => Self::DestroyedResource(e),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Error encountered when performing a compute pass, stored for later reporting
|
||||
/// when encoding ends.
|
||||
#[derive(Clone, Debug, Error)]
|
||||
@@ -1269,11 +1279,9 @@ impl Global {
|
||||
let mut bind_group = None;
|
||||
if let Some(bind_group_id) = bind_group_id {
|
||||
let hub = &self.hub;
|
||||
bind_group = Some(pass_try!(
|
||||
base,
|
||||
scope,
|
||||
hub.bind_groups.get(bind_group_id).get(),
|
||||
));
|
||||
let bg = hub.bind_groups.get(bind_group_id);
|
||||
pass_try!(base, scope, bg.check_is_valid());
|
||||
bind_group = Some(bg);
|
||||
}
|
||||
|
||||
base.commands.push(ArcComputeCommand::SetBindGroup {
|
||||
|
||||
@@ -6,6 +6,7 @@ use wgt::error::{ErrorType, WebGpuError};
|
||||
|
||||
use super::bind::BinderError;
|
||||
use crate::command::pass;
|
||||
use crate::resource::InvalidResourceError;
|
||||
use crate::validation::InvalidWorkgroupSizeError;
|
||||
use crate::{
|
||||
binding_model::{BindingError, ImmediateUploadError, LateMinBufferBindingSizeMismatch},
|
||||
@@ -110,6 +111,8 @@ pub enum RenderCommandError {
|
||||
#[error(transparent)]
|
||||
DestroyedResource(#[from] DestroyedResourceError),
|
||||
#[error(transparent)]
|
||||
InvalidResource(#[from] InvalidResourceError),
|
||||
#[error(transparent)]
|
||||
MissingBufferUsage(#[from] MissingBufferUsageError),
|
||||
#[error(transparent)]
|
||||
MissingTextureUsage(#[from] MissingTextureUsageError),
|
||||
@@ -135,6 +138,7 @@ impl WebGpuError for RenderCommandError {
|
||||
Self::IncompatiblePipelineTargets(e) => e.webgpu_error_type(),
|
||||
Self::ResourceUsageCompatibility(e) => e.webgpu_error_type(),
|
||||
Self::DestroyedResource(e) => e.webgpu_error_type(),
|
||||
Self::InvalidResource(e) => e.webgpu_error_type(),
|
||||
Self::MissingBufferUsage(e) => e.webgpu_error_type(),
|
||||
Self::MissingTextureUsage(e) => e.webgpu_error_type(),
|
||||
Self::ImmediateData(e) => e.webgpu_error_type(),
|
||||
|
||||
@@ -8,7 +8,9 @@ use crate::command::{
|
||||
};
|
||||
use crate::device::{Device, DeviceError, MissingFeatures};
|
||||
use crate::pipeline::LateSizedBufferGroup;
|
||||
use crate::resource::{DestroyedResourceError, Labeled, ParentDevice, QuerySet};
|
||||
use crate::resource::{
|
||||
DestroyedResourceError, InvalidOrDestroyedResourceError, Labeled, ParentDevice, QuerySet,
|
||||
};
|
||||
use crate::track::{ResourceUsageCompatibilityError, UsageScope};
|
||||
use crate::{api_log, binding_model};
|
||||
use alloc::sync::Arc;
|
||||
@@ -141,7 +143,9 @@ where
|
||||
///
|
||||
/// See the compute pass version of `State::flush_bindings` for an explanation
|
||||
/// of some differences in handling the two types of passes.
|
||||
pub(super) fn flush_bindings_helper(state: &mut PassState) -> Result<(), DestroyedResourceError> {
|
||||
pub(super) fn flush_bindings_helper(
|
||||
state: &mut PassState,
|
||||
) -> Result<(), InvalidOrDestroyedResourceError> {
|
||||
let start = state.binder.take_rebind_start_index();
|
||||
let entries = state.binder.list_valid_with_start(start);
|
||||
let pipeline_layout = state.binder.pipeline_layout.as_ref().unwrap();
|
||||
|
||||
@@ -40,9 +40,10 @@ use crate::{
|
||||
init_tracker::{MemoryInitKind, TextureInitRange, TextureInitTrackerAction},
|
||||
pipeline::{PipelineFlags, RenderPipeline, VertexStep},
|
||||
resource::{
|
||||
Buffer, DestroyedResourceError, InvalidResourceError, Labeled, MissingBufferUsageError,
|
||||
MissingTextureUsageError, ParentDevice, QuerySet, RawResourceAccess, ResourceErrorIdent,
|
||||
Texture, TextureView, TextureViewNotRenderableReason,
|
||||
Buffer, DestroyedResourceError, InvalidOrDestroyedResourceError, InvalidResourceError,
|
||||
Labeled, MissingBufferUsageError, MissingTextureUsageError, ParentDevice, QuerySet,
|
||||
RawResourceAccess, ResourceErrorIdent, Texture, TextureView,
|
||||
TextureViewNotRenderableReason,
|
||||
},
|
||||
snatch::SnatchGuard,
|
||||
track::{ResourceUsageCompatibilityError, Tracker, UsageScope},
|
||||
@@ -1025,6 +1026,15 @@ pub enum RenderPassErrorInner {
|
||||
TimestampWrites(#[from] TimestampWritesError),
|
||||
}
|
||||
|
||||
impl From<InvalidOrDestroyedResourceError> for RenderPassErrorInner {
|
||||
fn from(error: InvalidOrDestroyedResourceError) -> Self {
|
||||
match error {
|
||||
InvalidOrDestroyedResourceError::InvalidResource(e) => Self::InvalidResource(e),
|
||||
InvalidOrDestroyedResourceError::DestroyedResource(e) => Self::DestroyedResource(e),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<MissingBufferUsageError> for RenderPassErrorInner {
|
||||
fn from(error: MissingBufferUsageError) -> Self {
|
||||
Self::RenderCommand(error.into())
|
||||
@@ -3619,6 +3629,9 @@ fn execute_bundle(
|
||||
ExecutionError::DestroyedResource(e) => {
|
||||
RenderPassErrorInner::RenderCommand(RenderCommandError::DestroyedResource(e))
|
||||
}
|
||||
ExecutionError::InvalidResource(e) => {
|
||||
RenderPassErrorInner::RenderCommand(RenderCommandError::InvalidResource(e))
|
||||
}
|
||||
ExecutionError::Unimplemented(what) => {
|
||||
RenderPassErrorInner::RenderCommand(RenderCommandError::Unimplemented(what))
|
||||
}
|
||||
@@ -3670,11 +3683,9 @@ impl Global {
|
||||
let mut bind_group = None;
|
||||
if let Some(bind_group_id) = bind_group_id {
|
||||
let hub = &self.hub;
|
||||
bind_group = Some(pass_try!(
|
||||
base,
|
||||
scope,
|
||||
hub.bind_groups.get(bind_group_id).get(),
|
||||
));
|
||||
let bg = hub.bind_groups.get(bind_group_id);
|
||||
pass_try!(base, scope, bg.check_is_valid());
|
||||
bind_group = Some(bg);
|
||||
}
|
||||
|
||||
base.commands.push(ArcRenderCommand::SetBindGroup {
|
||||
|
||||
Reference in new issue
Block a user