mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-22 06:44:14 +00:00
change BindGroup.raw
to BindGroup.try_raw
This commit is contained in:
parent
08f5eb82cd
commit
b0d2517bf4
@ -894,17 +894,24 @@ impl<A: HalApi> Drop for BindGroup<A> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<A: HalApi> BindGroup<A> {
|
impl<A: HalApi> BindGroup<A> {
|
||||||
pub(crate) fn raw(&self, guard: &SnatchGuard) -> Option<&A::BindGroup> {
|
pub(crate) fn try_raw<'a>(
|
||||||
|
&'a self,
|
||||||
|
guard: &'a SnatchGuard,
|
||||||
|
) -> Result<&A::BindGroup, DestroyedResourceError> {
|
||||||
// Clippy insist on writing it this way. The idea is to return None
|
// Clippy insist on writing it this way. The idea is to return None
|
||||||
// if any of the raw buffer is not valid anymore.
|
// if any of the raw buffer is not valid anymore.
|
||||||
for buffer in &self.used_buffer_ranges {
|
for buffer in &self.used_buffer_ranges {
|
||||||
let _ = buffer.buffer.raw(guard)?;
|
buffer.buffer.try_raw(guard)?;
|
||||||
}
|
}
|
||||||
for texture in &self.used_texture_ranges {
|
for texture in &self.used_texture_ranges {
|
||||||
let _ = texture.texture.raw(guard)?;
|
texture.texture.try_raw(guard)?;
|
||||||
}
|
}
|
||||||
self.raw.get(guard)
|
|
||||||
|
self.raw
|
||||||
|
.get(guard)
|
||||||
|
.ok_or_else(|| DestroyedResourceError(self.error_ident()))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn validate_dynamic_bindings(
|
pub(crate) fn validate_dynamic_bindings(
|
||||||
&self,
|
&self,
|
||||||
bind_group_index: u32,
|
bind_group_index: u32,
|
||||||
|
@ -412,7 +412,7 @@ impl RenderBundleEncoder {
|
|||||||
|
|
||||||
let bind_group = bind_group_guard
|
let bind_group = bind_group_guard
|
||||||
.get(bind_group_id)
|
.get(bind_group_id)
|
||||||
.map_err(|_| RenderCommandError::InvalidBindGroup(bind_group_id))
|
.map_err(|_| RenderCommandError::InvalidBindGroupId(bind_group_id))
|
||||||
.map_pass_err(scope)?;
|
.map_pass_err(scope)?;
|
||||||
|
|
||||||
state
|
state
|
||||||
@ -837,17 +837,12 @@ pub enum CreateRenderBundleError {
|
|||||||
pub enum ExecutionError {
|
pub enum ExecutionError {
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
DestroyedResource(#[from] DestroyedResourceError),
|
DestroyedResource(#[from] DestroyedResourceError),
|
||||||
#[error("BindGroup {0:?} is invalid")]
|
|
||||||
InvalidBindGroup(id::BindGroupId),
|
|
||||||
#[error("Using {0} in a render bundle is not implemented")]
|
#[error("Using {0} in a render bundle is not implemented")]
|
||||||
Unimplemented(&'static str),
|
Unimplemented(&'static str),
|
||||||
}
|
}
|
||||||
impl PrettyError for ExecutionError {
|
impl PrettyError for ExecutionError {
|
||||||
fn fmt_pretty(&self, fmt: &mut ErrorFormatter) {
|
fn fmt_pretty(&self, fmt: &mut ErrorFormatter) {
|
||||||
fmt.error(self);
|
fmt.error(self);
|
||||||
if let Self::InvalidBindGroup(id) = *self {
|
|
||||||
fmt.bind_group_label(&id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -919,9 +914,7 @@ impl<A: HalApi> RenderBundle<A> {
|
|||||||
num_dynamic_offsets,
|
num_dynamic_offsets,
|
||||||
bind_group,
|
bind_group,
|
||||||
} => {
|
} => {
|
||||||
let raw_bg = bind_group
|
let raw_bg = bind_group.try_raw(snatch_guard)?;
|
||||||
.raw(snatch_guard)
|
|
||||||
.ok_or(ExecutionError::InvalidBindGroup(bind_group.info.id()))?;
|
|
||||||
unsafe {
|
unsafe {
|
||||||
raw.set_bind_group(
|
raw.set_bind_group(
|
||||||
pipeline_layout.as_ref().unwrap().raw(),
|
pipeline_layout.as_ref().unwrap().raw(),
|
||||||
|
@ -158,8 +158,8 @@ pub enum ComputePassErrorInner {
|
|||||||
Encoder(#[from] CommandEncoderError),
|
Encoder(#[from] CommandEncoderError),
|
||||||
#[error("Parent encoder is invalid")]
|
#[error("Parent encoder is invalid")]
|
||||||
InvalidParentEncoder,
|
InvalidParentEncoder,
|
||||||
#[error("Bind group at index {0:?} is invalid")]
|
#[error("BindGroupId {0:?} is invalid")]
|
||||||
InvalidBindGroup(u32),
|
InvalidBindGroupId(id::BindGroupId),
|
||||||
#[error("Bind group index {index} is greater than the device's requested `max_bind_group` limit {max}")]
|
#[error("Bind group index {index} is greater than the device's requested `max_bind_group` limit {max}")]
|
||||||
BindGroupIndexOutOfRange { index: u32, max: u32 },
|
BindGroupIndexOutOfRange { index: u32, max: u32 },
|
||||||
#[error("Compute pipeline {0:?} is invalid")]
|
#[error("Compute pipeline {0:?} is invalid")]
|
||||||
@ -615,10 +615,7 @@ impl Global {
|
|||||||
let pipeline_layout = pipeline_layout.as_ref().unwrap().raw();
|
let pipeline_layout = pipeline_layout.as_ref().unwrap().raw();
|
||||||
for (i, e) in entries.iter().enumerate() {
|
for (i, e) in entries.iter().enumerate() {
|
||||||
if let Some(group) = e.group.as_ref() {
|
if let Some(group) = e.group.as_ref() {
|
||||||
let raw_bg = group
|
let raw_bg = group.try_raw(&snatch_guard).map_pass_err(scope)?;
|
||||||
.raw(&snatch_guard)
|
|
||||||
.ok_or(ComputePassErrorInner::InvalidBindGroup(i as u32))
|
|
||||||
.map_pass_err(scope)?;
|
|
||||||
unsafe {
|
unsafe {
|
||||||
raw.set_bind_group(
|
raw.set_bind_group(
|
||||||
pipeline_layout,
|
pipeline_layout,
|
||||||
@ -661,10 +658,8 @@ impl Global {
|
|||||||
if !entries.is_empty() {
|
if !entries.is_empty() {
|
||||||
for (i, e) in entries.iter().enumerate() {
|
for (i, e) in entries.iter().enumerate() {
|
||||||
if let Some(group) = e.group.as_ref() {
|
if let Some(group) = e.group.as_ref() {
|
||||||
let raw_bg = group
|
let raw_bg =
|
||||||
.raw(&snatch_guard)
|
group.try_raw(&snatch_guard).map_pass_err(scope)?;
|
||||||
.ok_or(ComputePassErrorInner::InvalidBindGroup(i as u32))
|
|
||||||
.map_pass_err(scope)?;
|
|
||||||
unsafe {
|
unsafe {
|
||||||
raw.set_bind_group(
|
raw.set_bind_group(
|
||||||
pipeline.layout.raw(),
|
pipeline.layout.raw(),
|
||||||
@ -972,7 +967,7 @@ impl Global {
|
|||||||
.bind_groups
|
.bind_groups
|
||||||
.read()
|
.read()
|
||||||
.get_owned(bind_group_id)
|
.get_owned(bind_group_id)
|
||||||
.map_err(|_| ComputePassErrorInner::InvalidBindGroup(index))
|
.map_err(|_| ComputePassErrorInner::InvalidBindGroupId(bind_group_id))
|
||||||
.map_pass_err(scope)?;
|
.map_pass_err(scope)?;
|
||||||
|
|
||||||
base.commands.push(ArcComputeCommand::SetBindGroup {
|
base.commands.push(ArcComputeCommand::SetBindGroup {
|
||||||
|
@ -98,7 +98,7 @@ impl ComputeCommand {
|
|||||||
bind_group: bind_group_guard.get_owned(bind_group_id).map_err(|_| {
|
bind_group: bind_group_guard.get_owned(bind_group_id).map_err(|_| {
|
||||||
ComputePassError {
|
ComputePassError {
|
||||||
scope: PassErrorScope::SetBindGroup(bind_group_id),
|
scope: PassErrorScope::SetBindGroup(bind_group_id),
|
||||||
inner: ComputePassErrorInner::InvalidBindGroup(index),
|
inner: ComputePassErrorInner::InvalidBindGroupId(bind_group_id),
|
||||||
}
|
}
|
||||||
})?,
|
})?,
|
||||||
},
|
},
|
||||||
|
@ -70,8 +70,8 @@ pub enum DrawError {
|
|||||||
#[derive(Clone, Debug, Error)]
|
#[derive(Clone, Debug, Error)]
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
pub enum RenderCommandError {
|
pub enum RenderCommandError {
|
||||||
#[error("Bind group {0:?} is invalid")]
|
#[error("BindGroupId {0:?} is invalid")]
|
||||||
InvalidBindGroup(id::BindGroupId),
|
InvalidBindGroupId(id::BindGroupId),
|
||||||
#[error("Render bundle {0:?} is invalid")]
|
#[error("Render bundle {0:?} is invalid")]
|
||||||
InvalidRenderBundle(id::RenderBundleId),
|
InvalidRenderBundle(id::RenderBundleId),
|
||||||
#[error("Bind group index {index} is greater than the device's requested `max_bind_group` limit {max}")]
|
#[error("Bind group index {index} is greater than the device's requested `max_bind_group` limit {max}")]
|
||||||
@ -113,7 +113,7 @@ impl crate::error::PrettyError for RenderCommandError {
|
|||||||
fn fmt_pretty(&self, fmt: &mut ErrorFormatter) {
|
fn fmt_pretty(&self, fmt: &mut ErrorFormatter) {
|
||||||
fmt.error(self);
|
fmt.error(self);
|
||||||
match *self {
|
match *self {
|
||||||
Self::InvalidBindGroup(id) => {
|
Self::InvalidBindGroupId(id) => {
|
||||||
fmt.bind_group_label(&id);
|
fmt.bind_group_label(&id);
|
||||||
}
|
}
|
||||||
Self::InvalidPipeline(id) => {
|
Self::InvalidPipeline(id) => {
|
||||||
|
@ -601,8 +601,6 @@ pub enum RenderPassErrorInner {
|
|||||||
SurfaceTextureDropped,
|
SurfaceTextureDropped,
|
||||||
#[error("Not enough memory left for render pass")]
|
#[error("Not enough memory left for render pass")]
|
||||||
OutOfMemory,
|
OutOfMemory,
|
||||||
#[error("The bind group at index {0:?} is invalid")]
|
|
||||||
InvalidBindGroup(usize),
|
|
||||||
#[error("Unable to clear non-present/read-only depth")]
|
#[error("Unable to clear non-present/read-only depth")]
|
||||||
InvalidDepthOps,
|
InvalidDepthOps,
|
||||||
#[error("Unable to clear non-present/read-only stencil")]
|
#[error("Unable to clear non-present/read-only stencil")]
|
||||||
@ -1471,7 +1469,7 @@ impl Global {
|
|||||||
|
|
||||||
let bind_group = bind_group_guard
|
let bind_group = bind_group_guard
|
||||||
.get(bind_group_id)
|
.get(bind_group_id)
|
||||||
.map_err(|_| RenderCommandError::InvalidBindGroup(bind_group_id))
|
.map_err(|_| RenderCommandError::InvalidBindGroupId(bind_group_id))
|
||||||
.map_pass_err(scope)?;
|
.map_pass_err(scope)?;
|
||||||
|
|
||||||
tracker.bind_groups.add_single(bind_group);
|
tracker.bind_groups.add_single(bind_group);
|
||||||
@ -1516,10 +1514,8 @@ impl Global {
|
|||||||
let pipeline_layout = pipeline_layout.as_ref().unwrap().raw();
|
let pipeline_layout = pipeline_layout.as_ref().unwrap().raw();
|
||||||
for (i, e) in entries.iter().enumerate() {
|
for (i, e) in entries.iter().enumerate() {
|
||||||
if let Some(group) = e.group.as_ref() {
|
if let Some(group) = e.group.as_ref() {
|
||||||
let raw_bg = group
|
let raw_bg =
|
||||||
.raw(&snatch_guard)
|
group.try_raw(&snatch_guard).map_pass_err(scope)?;
|
||||||
.ok_or(RenderPassErrorInner::InvalidBindGroup(i))
|
|
||||||
.map_pass_err(scope)?;
|
|
||||||
unsafe {
|
unsafe {
|
||||||
raw.set_bind_group(
|
raw.set_bind_group(
|
||||||
pipeline_layout,
|
pipeline_layout,
|
||||||
@ -1598,10 +1594,8 @@ impl Global {
|
|||||||
if !entries.is_empty() {
|
if !entries.is_empty() {
|
||||||
for (i, e) in entries.iter().enumerate() {
|
for (i, e) in entries.iter().enumerate() {
|
||||||
if let Some(group) = e.group.as_ref() {
|
if let Some(group) = e.group.as_ref() {
|
||||||
let raw_bg = group
|
let raw_bg =
|
||||||
.raw(&snatch_guard)
|
group.try_raw(&snatch_guard).map_pass_err(scope)?;
|
||||||
.ok_or(RenderPassErrorInner::InvalidBindGroup(i))
|
|
||||||
.map_pass_err(scope)?;
|
|
||||||
unsafe {
|
unsafe {
|
||||||
raw.set_bind_group(
|
raw.set_bind_group(
|
||||||
pipeline.layout.raw(),
|
pipeline.layout.raw(),
|
||||||
@ -2366,9 +2360,6 @@ impl Global {
|
|||||||
ExecutionError::DestroyedResource(e) => {
|
ExecutionError::DestroyedResource(e) => {
|
||||||
RenderCommandError::DestroyedResource(e)
|
RenderCommandError::DestroyedResource(e)
|
||||||
}
|
}
|
||||||
ExecutionError::InvalidBindGroup(id) => {
|
|
||||||
RenderCommandError::InvalidBindGroup(id)
|
|
||||||
}
|
|
||||||
ExecutionError::Unimplemented(what) => {
|
ExecutionError::Unimplemented(what) => {
|
||||||
RenderCommandError::Unimplemented(what)
|
RenderCommandError::Unimplemented(what)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user