mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
Improve the consistency of identifiers (#5108)
This commit is contained in:
@@ -94,7 +94,7 @@ use crate::{
|
||||
error::{ErrorFormatter, PrettyError},
|
||||
hal_api::HalApi,
|
||||
hub::Hub,
|
||||
id::{self, RenderBundleId},
|
||||
id,
|
||||
init_tracker::{BufferInitTrackerAction, MemoryInitKind, TextureInitTrackerAction},
|
||||
pipeline::{PipelineFlags, RenderPipeline, VertexStep},
|
||||
resource::{Resource, ResourceInfo, ResourceType},
|
||||
@@ -832,7 +832,7 @@ pub struct RenderBundle<A: HalApi> {
|
||||
pub(super) buffer_memory_init_actions: Vec<BufferInitTrackerAction<A>>,
|
||||
pub(super) texture_memory_init_actions: Vec<TextureInitTrackerAction<A>>,
|
||||
pub(super) context: RenderPassContext,
|
||||
pub(crate) info: ResourceInfo<RenderBundleId>,
|
||||
pub(crate) info: ResourceInfo<RenderBundle<A>>,
|
||||
discard_hal_labels: bool,
|
||||
}
|
||||
|
||||
@@ -1067,14 +1067,16 @@ impl<A: HalApi> RenderBundle<A> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<A: HalApi> Resource<RenderBundleId> for RenderBundle<A> {
|
||||
impl<A: HalApi> Resource for RenderBundle<A> {
|
||||
const TYPE: ResourceType = "RenderBundle";
|
||||
|
||||
fn as_info(&self) -> &ResourceInfo<RenderBundleId> {
|
||||
type Marker = crate::id::markers::RenderBundle;
|
||||
|
||||
fn as_info(&self) -> &ResourceInfo<Self> {
|
||||
&self.info
|
||||
}
|
||||
|
||||
fn as_info_mut(&mut self) -> &mut ResourceInfo<RenderBundleId> {
|
||||
fn as_info_mut(&mut self) -> &mut ResourceInfo<Self> {
|
||||
&mut self.info
|
||||
}
|
||||
}
|
||||
|
||||
@@ -305,7 +305,7 @@ impl<A: HalApi> State<A> {
|
||||
&mut self,
|
||||
raw_encoder: &mut A::CommandEncoder,
|
||||
base_trackers: &mut Tracker<A>,
|
||||
bind_group_guard: &Storage<BindGroup<A>, id::BindGroupId>,
|
||||
bind_group_guard: &Storage<BindGroup<A>>,
|
||||
indirect_buffer: Option<id::BufferId>,
|
||||
snatch_guard: &SnatchGuard,
|
||||
) -> Result<(), UsageConflict> {
|
||||
|
||||
@@ -140,7 +140,7 @@ pub struct CommandBuffer<A: HalApi> {
|
||||
pub(crate) device: Arc<Device<A>>,
|
||||
limits: wgt::Limits,
|
||||
support_clear_texture: bool,
|
||||
pub(crate) info: ResourceInfo<CommandBufferId>,
|
||||
pub(crate) info: ResourceInfo<CommandBuffer<A>>,
|
||||
pub(crate) data: Mutex<Option<CommandBufferMutable<A>>>,
|
||||
}
|
||||
|
||||
@@ -255,7 +255,7 @@ impl<A: HalApi> CommandBuffer<A> {
|
||||
id: id::CommandEncoderId,
|
||||
) -> Result<Arc<Self>, CommandEncoderError> {
|
||||
let storage = hub.command_buffers.read();
|
||||
match storage.get(id) {
|
||||
match storage.get(id.transmute()) {
|
||||
Ok(cmd_buf) => match cmd_buf.data.lock().as_ref().unwrap().status {
|
||||
CommandEncoderStatus::Recording => Ok(cmd_buf.clone()),
|
||||
CommandEncoderStatus::Finished => Err(CommandEncoderError::NotRecording),
|
||||
@@ -296,14 +296,16 @@ impl<A: HalApi> CommandBuffer<A> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<A: HalApi> Resource<CommandBufferId> for CommandBuffer<A> {
|
||||
impl<A: HalApi> Resource for CommandBuffer<A> {
|
||||
const TYPE: ResourceType = "CommandBuffer";
|
||||
|
||||
fn as_info(&self) -> &ResourceInfo<CommandBufferId> {
|
||||
type Marker = crate::id::markers::CommandBuffer;
|
||||
|
||||
fn as_info(&self) -> &ResourceInfo<Self> {
|
||||
&self.info
|
||||
}
|
||||
|
||||
fn as_info_mut(&mut self) -> &mut ResourceInfo<CommandBufferId> {
|
||||
fn as_info_mut(&mut self) -> &mut ResourceInfo<Self> {
|
||||
&mut self.info
|
||||
}
|
||||
|
||||
@@ -418,7 +420,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
|
||||
let hub = A::hub(self);
|
||||
|
||||
let error = match hub.command_buffers.get(encoder_id) {
|
||||
let error = match hub.command_buffers.get(encoder_id.transmute()) {
|
||||
Ok(cmd_buf) => {
|
||||
let mut cmd_buf_data = cmd_buf.data.lock();
|
||||
let cmd_buf_data = cmd_buf_data.as_mut().unwrap();
|
||||
@@ -444,7 +446,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
Err(_) => Some(CommandEncoderError::Invalid),
|
||||
};
|
||||
|
||||
(encoder_id, error)
|
||||
(encoder_id.transmute(), error)
|
||||
}
|
||||
|
||||
pub fn command_encoder_push_debug_group<A: HalApi>(
|
||||
@@ -700,7 +702,7 @@ impl PrettyError for PassErrorScope {
|
||||
// This error is not in the error chain, only notes are needed
|
||||
match *self {
|
||||
Self::Pass(id) => {
|
||||
fmt.command_buffer_label(&id);
|
||||
fmt.command_buffer_label(&id.transmute());
|
||||
}
|
||||
Self::SetBindGroup(id) => {
|
||||
fmt.bind_group_label(&id);
|
||||
|
||||
@@ -7,7 +7,7 @@ use crate::{
|
||||
device::DeviceError,
|
||||
global::Global,
|
||||
hal_api::HalApi,
|
||||
id::{self, Id, TypedId},
|
||||
id::{self, Id},
|
||||
identity::GlobalIdentityHandlerFactory,
|
||||
init_tracker::MemoryInitKind,
|
||||
resource::QuerySet,
|
||||
@@ -49,7 +49,7 @@ impl<A: HalApi> QueryResetMap<A> {
|
||||
pub fn reset_queries(
|
||||
&mut self,
|
||||
raw_encoder: &mut A::CommandEncoder,
|
||||
query_set_storage: &Storage<QuerySet<A>, id::QuerySetId>,
|
||||
query_set_storage: &Storage<QuerySet<A>>,
|
||||
backend: wgt::Backend,
|
||||
) -> Result<(), id::QuerySetId> {
|
||||
for (query_set_id, (state, epoch)) in self.map.drain() {
|
||||
@@ -314,7 +314,7 @@ impl<A: HalApi> QuerySet<A> {
|
||||
|
||||
pub(super) fn end_occlusion_query<A: HalApi>(
|
||||
raw_encoder: &mut A::CommandEncoder,
|
||||
storage: &Storage<QuerySet<A>, id::QuerySetId>,
|
||||
storage: &Storage<QuerySet<A>>,
|
||||
active_query: &mut Option<(id::QuerySetId, u32)>,
|
||||
) -> Result<(), QueryUseError> {
|
||||
if let Some((query_set_id, query_index)) = active_query.take() {
|
||||
@@ -331,7 +331,7 @@ pub(super) fn end_occlusion_query<A: HalApi>(
|
||||
|
||||
pub(super) fn end_pipeline_statistics_query<A: HalApi>(
|
||||
raw_encoder: &mut A::CommandEncoder,
|
||||
storage: &Storage<QuerySet<A>, id::QuerySetId>,
|
||||
storage: &Storage<QuerySet<A>>,
|
||||
active_query: &mut Option<(id::QuerySetId, u32)>,
|
||||
) -> Result<(), QueryUseError> {
|
||||
if let Some((query_set_id, query_index)) = active_query.take() {
|
||||
|
||||
@@ -784,10 +784,10 @@ impl<'a, A: HalApi> RenderPassInfo<'a, A> {
|
||||
trackers: &mut Tracker<A>,
|
||||
texture_memory_actions: &mut CommandBufferTextureMemoryActions<A>,
|
||||
pending_query_resets: &mut QueryResetMap<A>,
|
||||
view_guard: &'a Storage<TextureView<A>, id::TextureViewId>,
|
||||
buffer_guard: &'a Storage<Buffer<A>, id::BufferId>,
|
||||
texture_guard: &'a Storage<Texture<A>, id::TextureId>,
|
||||
query_set_guard: &'a Storage<QuerySet<A>, id::QuerySetId>,
|
||||
view_guard: &'a Storage<TextureView<A>>,
|
||||
buffer_guard: &'a Storage<Buffer<A>>,
|
||||
texture_guard: &'a Storage<Texture<A>>,
|
||||
query_set_guard: &'a Storage<QuerySet<A>>,
|
||||
snatch_guard: &SnatchGuard<'a>,
|
||||
) -> Result<Self, RenderPassErrorInner> {
|
||||
profiling::scope!("RenderPassInfo::start");
|
||||
@@ -2391,7 +2391,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
(trackers, pending_discard_init_fixups)
|
||||
};
|
||||
|
||||
let cmd_buf = hub.command_buffers.get(encoder_id).unwrap();
|
||||
let cmd_buf = hub.command_buffers.get(encoder_id.transmute()).unwrap();
|
||||
let mut cmd_buf_data = cmd_buf.data.lock();
|
||||
let cmd_buf_data = cmd_buf_data.as_mut().unwrap();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user