mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-21 22:33:49 +00:00
remove usage of Texture IDs in clear code
This commit is contained in:
parent
2a7f09aebc
commit
8465a64104
@ -11,7 +11,7 @@ use crate::{
|
||||
hal_api::HalApi,
|
||||
id::{BufferId, CommandEncoderId, TextureId},
|
||||
init_tracker::{MemoryInitKind, TextureInitRange},
|
||||
resource::{ParentDevice, Resource, Texture, TextureClearMode},
|
||||
resource::{ParentDevice, Resource, ResourceErrorIdent, Texture, TextureClearMode},
|
||||
snatch::SnatchGuard,
|
||||
track::{TextureSelector, TextureTracker},
|
||||
};
|
||||
@ -28,10 +28,12 @@ pub enum ClearError {
|
||||
MissingClearTextureFeature,
|
||||
#[error("Buffer {0:?} is invalid or destroyed")]
|
||||
InvalidBuffer(BufferId),
|
||||
#[error("Texture {0:?} is invalid or destroyed")]
|
||||
InvalidTexture(TextureId),
|
||||
#[error("Texture {0:?} can not be cleared")]
|
||||
NoValidTextureClearMode(TextureId),
|
||||
#[error("TextureId {0:?} is invalid")]
|
||||
InvalidTextureId(TextureId),
|
||||
#[error("{0} has been destroyed")]
|
||||
Destroyed(ResourceErrorIdent),
|
||||
#[error("{0} can not be cleared")]
|
||||
NoValidTextureClearMode(ResourceErrorIdent),
|
||||
#[error("Buffer clear size {0:?} is not a multiple of `COPY_BUFFER_ALIGNMENT`")]
|
||||
UnalignedFillSize(BufferAddress),
|
||||
#[error("Buffer offset {0:?} is not a multiple of `COPY_BUFFER_ALIGNMENT`")]
|
||||
@ -197,7 +199,7 @@ impl Global {
|
||||
let dst_texture = hub
|
||||
.textures
|
||||
.get(dst)
|
||||
.map_err(|_| ClearError::InvalidTexture(dst))?;
|
||||
.map_err(|_| ClearError::InvalidTextureId(dst))?;
|
||||
|
||||
dst_texture.same_device_as(cmd_buf.as_ref())?;
|
||||
|
||||
@ -266,7 +268,7 @@ pub(crate) fn clear_texture<A: HalApi>(
|
||||
) -> Result<(), ClearError> {
|
||||
let dst_raw = dst_texture
|
||||
.raw(snatch_guard)
|
||||
.ok_or_else(|| ClearError::InvalidTexture(dst_texture.as_info().id()))?;
|
||||
.ok_or_else(|| ClearError::Destroyed(dst_texture.error_ident()))?;
|
||||
|
||||
// Issue the right barrier.
|
||||
let clear_usage = match *dst_texture.clear_mode.read() {
|
||||
@ -279,7 +281,7 @@ pub(crate) fn clear_texture<A: HalApi>(
|
||||
}
|
||||
TextureClearMode::None => {
|
||||
return Err(ClearError::NoValidTextureClearMode(
|
||||
dst_texture.as_info().id(),
|
||||
dst_texture.error_ident(),
|
||||
));
|
||||
}
|
||||
};
|
||||
@ -328,7 +330,7 @@ pub(crate) fn clear_texture<A: HalApi>(
|
||||
}
|
||||
TextureClearMode::None => {
|
||||
return Err(ClearError::NoValidTextureClearMode(
|
||||
dst_texture.as_info().id(),
|
||||
dst_texture.error_ident(),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -324,8 +324,8 @@ impl<A: HalApi> BakedCommands<A> {
|
||||
// A Texture can be destroyed between the command recording
|
||||
// and now, this is out of our control so we have to handle
|
||||
// it gracefully.
|
||||
if let Err(ClearError::InvalidTexture(id)) = clear_result {
|
||||
return Err(DestroyedTextureError(id));
|
||||
if let Err(ClearError::Destroyed(ident)) = clear_result {
|
||||
return Err(DestroyedTextureError(ident));
|
||||
}
|
||||
|
||||
// Other errors are unexpected.
|
||||
|
@ -29,7 +29,7 @@ use crate::lock::{rank, Mutex};
|
||||
use crate::snatch::SnatchGuard;
|
||||
|
||||
use crate::init_tracker::BufferInitTrackerAction;
|
||||
use crate::resource::{ParentDevice, Resource, ResourceInfo, ResourceType};
|
||||
use crate::resource::{ParentDevice, Resource, ResourceErrorIdent, ResourceInfo, ResourceType};
|
||||
use crate::track::{Tracker, UsageScope};
|
||||
use crate::{api_log, global::Global, hal_api::HalApi, id, resource_log, Label};
|
||||
|
||||
@ -244,7 +244,7 @@ pub(crate) struct BakedCommands<A: HalApi> {
|
||||
}
|
||||
|
||||
pub(crate) struct DestroyedBufferError(pub id::BufferId);
|
||||
pub(crate) struct DestroyedTextureError(pub id::TextureId);
|
||||
pub(crate) struct DestroyedTextureError(pub ResourceErrorIdent);
|
||||
|
||||
/// The mutable state of a [`CommandBuffer`].
|
||||
pub struct CommandBufferMutable<A: HalApi> {
|
||||
|
@ -17,7 +17,8 @@ use crate::{
|
||||
lock::{rank, Mutex, RwLockWriteGuard},
|
||||
resource::{
|
||||
Buffer, BufferAccessError, BufferMapState, DestroyedBuffer, DestroyedTexture, ParentDevice,
|
||||
Resource, ResourceInfo, ResourceType, StagingBuffer, Texture, TextureInner,
|
||||
Resource, ResourceErrorIdent, ResourceInfo, ResourceType, StagingBuffer, Texture,
|
||||
TextureInner,
|
||||
},
|
||||
resource_log, track, FastHashMap, SubmissionIndex,
|
||||
};
|
||||
@ -373,8 +374,8 @@ pub enum QueueSubmitError {
|
||||
Queue(#[from] DeviceError),
|
||||
#[error("Buffer {0:?} is destroyed")]
|
||||
DestroyedBuffer(id::BufferId),
|
||||
#[error("Texture {0:?} is destroyed")]
|
||||
DestroyedTexture(id::TextureId),
|
||||
#[error("{0} has been destroyed")]
|
||||
DestroyedTexture(ResourceErrorIdent),
|
||||
#[error(transparent)]
|
||||
Unmap(#[from] BufferAccessError),
|
||||
#[error("Buffer {0:?} is still mapped")]
|
||||
@ -1242,7 +1243,7 @@ impl Global {
|
||||
let should_extend = match texture.inner.get(&snatch_guard) {
|
||||
None => {
|
||||
return Err(QueueSubmitError::DestroyedTexture(
|
||||
texture.info.id(),
|
||||
texture.error_ident(),
|
||||
));
|
||||
}
|
||||
Some(TextureInner::Native { .. }) => false,
|
||||
@ -1421,10 +1422,10 @@ impl Global {
|
||||
|
||||
{
|
||||
used_surface_textures.set_size(hub.textures.read().len());
|
||||
for (&id, texture) in pending_writes.dst_textures.iter() {
|
||||
for texture in pending_writes.dst_textures.values() {
|
||||
match texture.inner.get(&snatch_guard) {
|
||||
None => {
|
||||
return Err(QueueSubmitError::DestroyedTexture(id));
|
||||
return Err(QueueSubmitError::DestroyedTexture(texture.error_ident()));
|
||||
}
|
||||
Some(TextureInner::Native { .. }) => {}
|
||||
Some(TextureInner::Surface { ref raw, .. }) => {
|
||||
|
Loading…
Reference in New Issue
Block a user