[core] Do not use IDs as default types in BindGroupDescriptor and BindGroupEntry

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
sagudev authored and Teodor Tanasoaia committed 2026-08-11 14:04:27 +02:00
1 parent 390f05b69a
commit 1d683f8b53
6 files changed
+50 -53

No files matched your search

+6 -7
View File
@@ -394,7 +394,7 @@ impl GPUDevice {
let entries = descriptor
.entries
.into_iter()
.map(|entry| wgpu_core::binding_model::ResolvedBindGroupEntry {
.map(|entry| wgpu_core::binding_model::BindGroupEntry {
binding: entry.binding,
resource: match entry.resource {
GPUBindingResource::Sampler(sampler) => {
@@ -429,12 +429,11 @@ impl GPUDevice {
})
.collect::<Vec<_>>();
let wgpu_descriptor =
wgpu_core::binding_model::ResolvedBindGroupDescriptor {
label: crate::transform_label(descriptor.label.clone()),
layout: descriptor.layout.wgpu_bind_group_layout.clone(),
entries: Cow::Owned(entries),
};
let wgpu_descriptor = wgpu_core::binding_model::BindGroupDescriptor {
label: crate::transform_label(descriptor.label.clone()),
layout: descriptor.layout.wgpu_bind_group_layout.clone(),
entries: Cow::Owned(entries),
};
let (wgpu_bind_group, err) =
self.wgpu_device.create_bind_group(&wgpu_descriptor);
+4 -4
View File
@@ -707,10 +707,10 @@ impl Player {
fn resolve_bind_group_descriptor<'a>(
&self,
desc: wgc::device::trace::TraceBindGroupDescriptor<'a>,
) -> wgc::binding_model::ResolvedBindGroupDescriptor<'a> {
) -> wgc::binding_model::BindGroupDescriptor<'a> {
let layout = self.resolve_bind_group_layout_id(desc.layout);
let entries: Vec<wgc::binding_model::ResolvedBindGroupEntry> = desc
let entries: Vec<wgc::binding_model::BindGroupEntry> = desc
.entries
.to_vec()
.into_iter()
@@ -794,14 +794,14 @@ impl Player {
}
};
wgc::binding_model::ResolvedBindGroupEntry {
wgc::binding_model::BindGroupEntry {
binding: entry.binding,
resource,
}
})
.collect();
wgc::binding_model::ResolvedBindGroupDescriptor {
wgc::binding_model::BindGroupDescriptor {
label: desc.label.clone(),
layout,
entries: entries.into(),
+13 -33
View File
@@ -20,7 +20,7 @@ use wgt::error::{ErrorType, WebGpuError};
use crate::{
api_log,
device::{bgl, Device, DeviceError, MissingDownlevelFlags, MissingFeatures},
id::{BindGroupLayoutId, BufferId, ExternalTextureId, SamplerId, TextureViewId, TlasId},
id::{BufferId, ExternalTextureId, SamplerId, TextureViewId, TlasId},
init_tracker::{BufferInitTrackerAction, TextureInitTrackerAction},
pipeline::{ComputePipeline, RenderPipeline},
resource::{
@@ -645,11 +645,11 @@ impl BindingTypeMaxCountValidator {
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct BindGroupEntry<
'a,
B = BufferId,
S = SamplerId,
TV = TextureViewId,
TLAS = TlasId,
ET = ExternalTextureId,
B = Arc<Buffer>,
S = Arc<Sampler>,
TV = Arc<TextureView>,
TLAS = Arc<Tlas>,
ET = Arc<ExternalTexture>,
> where
[BufferBinding<B>]: ToOwned,
[S]: ToOwned,
@@ -671,27 +671,18 @@ pub struct BindGroupEntry<
pub resource: BindingResource<'a, B, S, TV, TLAS, ET>,
}
/// cbindgen:ignore
pub type ResolvedBindGroupEntry<'a> = BindGroupEntry<
'a,
Arc<Buffer>,
Arc<Sampler>,
Arc<TextureView>,
Arc<Tlas>,
Arc<ExternalTexture>,
>;
/// Describes a group of bindings and the resources to be bound.
#[derive(Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
/// cbindgen:ignore
pub struct BindGroupDescriptor<
'a,
BGL = BindGroupLayoutId,
B = BufferId,
S = SamplerId,
TV = TextureViewId,
TLAS = TlasId,
ET = ExternalTextureId,
BGL = Arc<BindGroupLayout>,
B = Arc<Buffer>,
S = Arc<Sampler>,
TV = Arc<TextureView>,
TLAS = Arc<Tlas>,
ET = Arc<ExternalTexture>,
> where
[BufferBinding<B>]: ToOwned,
[S]: ToOwned,
@@ -721,17 +712,6 @@ pub struct BindGroupDescriptor<
pub entries: Cow<'a, [BindGroupEntry<'a, B, S, TV, TLAS, ET>]>,
}
/// cbindgen:ignore
pub type ResolvedBindGroupDescriptor<'a> = BindGroupDescriptor<
'a,
Arc<BindGroupLayout>,
Arc<Buffer>,
Arc<Sampler>,
Arc<TextureView>,
Arc<Tlas>,
Arc<ExternalTexture>,
>;
/// Describes a [`BindGroupLayout`].
#[derive(Clone, Debug)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
+24 -6
View File
@@ -5,8 +5,7 @@ use core::ptr::NonNull;
use crate::device::trace;
use crate::{
binding_model::{
self, BindGroupEntry, BindingResource, BufferBinding, ResolvedBindGroupDescriptor,
ResolvedBindGroupEntry, ResolvedBindingResource, ResolvedBufferBinding,
self, BindingResource, BufferBinding, ResolvedBindingResource, ResolvedBufferBinding,
},
command,
device::{life::WaitIdleError, DeviceError, DeviceLostClosure},
@@ -28,6 +27,25 @@ use crate::{
use wgt::{BufferAddress, TextureFormat};
pub type BindGroupDescriptor<'a> = binding_model::BindGroupDescriptor<
'a,
id::BindGroupLayoutId,
id::BufferId,
id::SamplerId,
id::TextureViewId,
id::TlasId,
id::ExternalTextureId,
>;
pub type BindGroupEntry<'a> = binding_model::BindGroupEntry<
'a,
id::BufferId,
id::SamplerId,
id::TextureViewId,
id::TlasId,
id::ExternalTextureId,
>;
impl Global {
pub fn adapter_is_surface_supported(
&self,
@@ -493,7 +511,7 @@ impl Global {
pub fn device_create_bind_group(
&self,
device_id: DeviceId,
desc: &binding_model::BindGroupDescriptor,
desc: &BindGroupDescriptor,
id_in: Option<id::BindGroupId>,
) -> (id::BindGroupId, Option<binding_model::CreateBindGroupError>) {
let hub = &self.hub;
@@ -510,7 +528,7 @@ impl Global {
texture_view_storage: &Storage<Arc<resource::TextureView>>,
tlas_storage: &Storage<Arc<resource::Tlas>>,
external_texture_storage: &Storage<Arc<resource::ExternalTexture>>,
) -> ResolvedBindGroupEntry<'a> {
) -> binding_model::BindGroupEntry<'a> {
let resolve_buffer = |bb: &BufferBinding| {
let buffer = buffer_storage.get(bb.buffer);
ResolvedBufferBinding {
@@ -557,7 +575,7 @@ impl Global {
ResolvedBindingResource::ExternalTexture(resolve_external_texture(et))
}
};
ResolvedBindGroupEntry {
binding_model::BindGroupEntry {
binding: e.binding,
resource,
}
@@ -585,7 +603,7 @@ impl Global {
};
let entries = Cow::Owned(entries);
let desc = ResolvedBindGroupDescriptor {
let desc = binding_model::BindGroupDescriptor {
label: desc.label.clone(),
layout,
entries,
+2 -2
View File
@@ -3585,7 +3585,7 @@ impl Device {
pub fn create_bind_group(
self: &Arc<Self>,
desc: &binding_model::ResolvedBindGroupDescriptor,
desc: &binding_model::BindGroupDescriptor,
) -> (Arc<BindGroup>, Option<CreateBindGroupError>) {
profiling::scope!("Device::create_bind_group");
#[cfg(feature = "trace")]
@@ -3619,7 +3619,7 @@ impl Device {
// (not passing a duplicate) beforehand.
pub fn create_bind_group_inner(
self: &Arc<Self>,
desc: &binding_model::ResolvedBindGroupDescriptor,
desc: &binding_model::BindGroupDescriptor,
) -> Result<Arc<BindGroup>, CreateBindGroupError> {
use crate::binding_model::{CreateBindGroupError as Error, ResolvedBindingResource as Br};
+1 -1
View File
@@ -672,7 +672,7 @@ impl IntoTrace for crate::binding_model::PipelineLayoutDescriptor<'_> {
}
}
impl<'a> IntoTrace for &'_ crate::binding_model::ResolvedBindGroupDescriptor<'a> {
impl<'a> IntoTrace for &'_ crate::binding_model::BindGroupDescriptor<'a> {
type Output = TraceBindGroupDescriptor<'a>;
fn into_trace(self) -> Self::Output {