mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-24 16:31:11 +01:00
[error] bind groups and layouts creation
This commit is contained in:
1 parent
fccbca28bd
commit
ad824de268
9 files changed
+683
-630
No files matched your search
@@ -84,16 +84,19 @@ fn main() {
|
||||
|
||||
let info = gfx_select!(adapter => global.adapter_get_info(adapter)).unwrap();
|
||||
log::info!("Picked '{}'", info.name);
|
||||
gfx_select!(adapter => global.adapter_request_device(
|
||||
let id = wgc::id::TypedId::zip(1, 0, wgt::Backend::Empty);
|
||||
let (_, error) = gfx_select!(adapter => global.adapter_request_device(
|
||||
adapter,
|
||||
&desc,
|
||||
None,
|
||||
wgc::id::TypedId::zip(1, 0, wgt::Backend::Empty)
|
||||
))
|
||||
.expect("Failed to request device")
|
||||
id
|
||||
));
|
||||
assert_eq!(error, None);
|
||||
id
|
||||
}
|
||||
_ => panic!("Expected Action::Init"),
|
||||
};
|
||||
|
||||
log::info!("Executing actions");
|
||||
#[cfg(not(feature = "winit"))]
|
||||
{
|
||||
|
||||
+6
-6
@@ -186,24 +186,24 @@ impl GlobalPlay for wgc::hub::Global<IdentityPassThroughFactory> {
|
||||
}
|
||||
}
|
||||
A::CreateBindGroupLayout(id, desc) => {
|
||||
self.device_create_bind_group_layout::<B>(device, &desc, id)
|
||||
.unwrap();
|
||||
let (_, error) = self.device_create_bind_group_layout::<B>(device, &desc, id);
|
||||
assert_eq!(error, None);
|
||||
}
|
||||
A::DestroyBindGroupLayout(id) => {
|
||||
self.bind_group_layout_drop::<B>(id);
|
||||
}
|
||||
A::CreatePipelineLayout(id, desc) => {
|
||||
self.device_maintain_ids::<B>(device).unwrap();
|
||||
self.device_create_pipeline_layout::<B>(device, &desc, id)
|
||||
.unwrap();
|
||||
let (_, error) = self.device_create_pipeline_layout::<B>(device, &desc, id);
|
||||
assert_eq!(error, None);
|
||||
}
|
||||
A::DestroyPipelineLayout(id) => {
|
||||
self.pipeline_layout_drop::<B>(id);
|
||||
}
|
||||
A::CreateBindGroup(id, desc) => {
|
||||
self.device_maintain_ids::<B>(device).unwrap();
|
||||
self.device_create_bind_group::<B>(device, &desc, id)
|
||||
.unwrap();
|
||||
let (_, error) = self.device_create_bind_group::<B>(device, &desc, id);
|
||||
assert_eq!(error, None);
|
||||
}
|
||||
A::DestroyBindGroup(id) => {
|
||||
self.bind_group_drop::<B>(id);
|
||||
|
||||
@@ -86,17 +86,19 @@ impl Test<'_> {
|
||||
test_num: u32,
|
||||
) {
|
||||
let backend = adapter.backend();
|
||||
let device = gfx_select!(adapter => global.adapter_request_device(
|
||||
let device = wgc::id::TypedId::zip(test_num, 0, backend);
|
||||
let (_, error) = gfx_select!(adapter => global.adapter_request_device(
|
||||
adapter,
|
||||
&wgt::DeviceDescriptor {
|
||||
label: None,
|
||||
features: self.features | wgt::Features::MAPPABLE_PRIMARY_BUFFERS,
|
||||
limits: wgt::Limits::default(),
|
||||
shader_validation: true,
|
||||
},
|
||||
None,
|
||||
wgc::id::TypedId::zip(test_num, 0, backend)
|
||||
))
|
||||
.unwrap();
|
||||
device
|
||||
));
|
||||
assert_eq!(error, None);
|
||||
|
||||
let mut command_buffer_id_manager = wgc::hub::IdentityManager::default();
|
||||
println!("\t\t\tRunning...");
|
||||
|
||||
@@ -26,7 +26,7 @@ use std::{
|
||||
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Clone, Debug, Error)]
|
||||
#[derive(Clone, Debug, Error, PartialEq)]
|
||||
pub enum CreateBindGroupLayoutError {
|
||||
#[error(transparent)]
|
||||
Device(#[from] DeviceError),
|
||||
@@ -40,7 +40,7 @@ pub enum CreateBindGroupLayoutError {
|
||||
TooManyBindings(BindingTypeMaxCountError),
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Error)]
|
||||
#[derive(Clone, Debug, Error, PartialEq)]
|
||||
pub enum CreateBindGroupError {
|
||||
#[error(transparent)]
|
||||
Device(#[from] DeviceError),
|
||||
@@ -96,7 +96,7 @@ pub enum CreateBindGroupError {
|
||||
DepthStencilAspect,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Error)]
|
||||
#[derive(Clone, Debug, Error, PartialEq)]
|
||||
pub enum BindingZone {
|
||||
#[error("stage {0:?}")]
|
||||
Stage(wgt::ShaderStage),
|
||||
@@ -104,7 +104,7 @@ pub enum BindingZone {
|
||||
Pipeline,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Error)]
|
||||
#[derive(Clone, Debug, Error, PartialEq)]
|
||||
#[error("too many bindings of type {kind:?} in {zone}, limit is {count}")]
|
||||
pub struct BindingTypeMaxCountError {
|
||||
pub kind: BindingTypeMaxCountErrorKind,
|
||||
@@ -112,7 +112,7 @@ pub struct BindingTypeMaxCountError {
|
||||
pub count: u32,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub enum BindingTypeMaxCountErrorKind {
|
||||
DynamicUniformBuffers,
|
||||
DynamicStorageBuffers,
|
||||
@@ -336,7 +336,7 @@ impl<B: hal::Backend> Resource for BindGroupLayout<B> {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Error)]
|
||||
#[derive(Clone, Debug, Error, PartialEq)]
|
||||
pub enum CreatePipelineLayoutError {
|
||||
#[error(transparent)]
|
||||
Device(#[from] DeviceError),
|
||||
|
||||
+478
-464
File diff suppressed because it is too large.
Load diff
@@ -31,7 +31,7 @@ pub(crate) fn new_render_bundle_encoder_descriptor<'a>(
|
||||
#[cfg_attr(feature = "replay", derive(serde::Deserialize))]
|
||||
pub enum Action<'a> {
|
||||
Init {
|
||||
desc: wgt::DeviceDescriptor,
|
||||
desc: crate::device::DeviceDescriptor<'a>,
|
||||
backend: wgt::Backend,
|
||||
},
|
||||
CreateBuffer(id::BufferId, crate::resource::BufferDescriptor<'a>),
|
||||
|
||||
+164
-143
@@ -4,13 +4,13 @@
|
||||
|
||||
use crate::{
|
||||
backend,
|
||||
device::Device,
|
||||
device::{Device, DeviceDescriptor},
|
||||
hub::{GfxBackend, Global, GlobalIdentityHandlerFactory, Input, Token},
|
||||
id::{AdapterId, DeviceId, SurfaceId, Valid},
|
||||
span, LifeGuard, PrivateFeatures, Stored, MAX_BIND_GROUPS,
|
||||
span, LabelHelpers, LifeGuard, PrivateFeatures, Stored, MAX_BIND_GROUPS,
|
||||
};
|
||||
|
||||
use wgt::{Backend, BackendBit, DeviceDescriptor, PowerPreference, BIND_BUFFER_ALIGNMENT};
|
||||
use wgt::{Backend, BackendBit, PowerPreference, BIND_BUFFER_ALIGNMENT};
|
||||
|
||||
use hal::{
|
||||
adapter::{AdapterInfo as HalAdapterInfo, DeviceType as HalDeviceType, PhysicalDevice as _},
|
||||
@@ -127,7 +127,7 @@ pub struct Adapter<B: hal::Backend> {
|
||||
life_guard: LifeGuard,
|
||||
}
|
||||
|
||||
impl<B: hal::Backend> Adapter<B> {
|
||||
impl<B: GfxBackend> Adapter<B> {
|
||||
fn new(raw: hal::adapter::Adapter<B>) -> Self {
|
||||
span!(_guard, INFO, "Adapter::new");
|
||||
|
||||
@@ -227,6 +227,150 @@ impl<B: hal::Backend> Adapter<B> {
|
||||
life_guard: LifeGuard::new("<Adapter>"),
|
||||
}
|
||||
}
|
||||
|
||||
fn create_device(
|
||||
&self,
|
||||
self_id: AdapterId,
|
||||
desc: &DeviceDescriptor,
|
||||
trace_path: Option<&std::path::Path>,
|
||||
) -> Result<Device<B>, RequestDeviceError> {
|
||||
// Verify all features were exposed by the adapter
|
||||
if !self.features.contains(desc.features) {
|
||||
return Err(RequestDeviceError::UnsupportedFeature(
|
||||
desc.features - self.features,
|
||||
));
|
||||
}
|
||||
|
||||
// Verify feature preconditions
|
||||
if desc
|
||||
.features
|
||||
.contains(wgt::Features::MAPPABLE_PRIMARY_BUFFERS)
|
||||
&& self.raw.info.device_type == hal::adapter::DeviceType::DiscreteGpu
|
||||
{
|
||||
tracing::warn!("Feature MAPPABLE_PRIMARY_BUFFERS enabled on a discrete gpu. This is a massive performance footgun and likely not what you wanted");
|
||||
}
|
||||
|
||||
let phd = &self.raw.physical_device;
|
||||
let available_features = phd.features();
|
||||
|
||||
// Check features that are always needed
|
||||
let wishful_features = hal::Features::ROBUST_BUFFER_ACCESS
|
||||
| hal::Features::VERTEX_STORES_AND_ATOMICS
|
||||
| hal::Features::FRAGMENT_STORES_AND_ATOMICS
|
||||
| hal::Features::NDC_Y_UP
|
||||
| hal::Features::INDEPENDENT_BLENDING
|
||||
| hal::Features::SAMPLER_ANISOTROPY
|
||||
| hal::Features::IMAGE_CUBE_ARRAY;
|
||||
let mut enabled_features = available_features & wishful_features;
|
||||
if enabled_features != wishful_features {
|
||||
tracing::warn!(
|
||||
"Missing internal features: {:?}",
|
||||
wishful_features - enabled_features
|
||||
);
|
||||
}
|
||||
|
||||
// Features
|
||||
enabled_features.set(
|
||||
hal::Features::TEXTURE_DESCRIPTOR_ARRAY,
|
||||
desc.features
|
||||
.contains(wgt::Features::SAMPLED_TEXTURE_BINDING_ARRAY),
|
||||
);
|
||||
enabled_features.set(
|
||||
hal::Features::SHADER_SAMPLED_IMAGE_ARRAY_DYNAMIC_INDEXING,
|
||||
desc.features
|
||||
.contains(wgt::Features::SAMPLED_TEXTURE_ARRAY_DYNAMIC_INDEXING),
|
||||
);
|
||||
enabled_features.set(
|
||||
hal::Features::SAMPLED_TEXTURE_DESCRIPTOR_INDEXING,
|
||||
desc.features
|
||||
.contains(wgt::Features::SAMPLED_TEXTURE_ARRAY_NON_UNIFORM_INDEXING),
|
||||
);
|
||||
enabled_features.set(
|
||||
hal::Features::UNSIZED_DESCRIPTOR_ARRAY,
|
||||
desc.features.contains(wgt::Features::UNSIZED_BINDING_ARRAY),
|
||||
);
|
||||
enabled_features.set(
|
||||
hal::Features::MULTI_DRAW_INDIRECT,
|
||||
desc.features.contains(wgt::Features::MULTI_DRAW_INDIRECT),
|
||||
);
|
||||
enabled_features.set(
|
||||
hal::Features::DRAW_INDIRECT_COUNT,
|
||||
desc.features
|
||||
.contains(wgt::Features::MULTI_DRAW_INDIRECT_COUNT),
|
||||
);
|
||||
enabled_features.set(
|
||||
hal::Features::NON_FILL_POLYGON_MODE,
|
||||
desc.features.contains(wgt::Features::NON_FILL_POLYGON_MODE),
|
||||
);
|
||||
|
||||
let family = self
|
||||
.raw
|
||||
.queue_families
|
||||
.iter()
|
||||
.find(|family| family.queue_type().supports_graphics())
|
||||
.ok_or(RequestDeviceError::NoGraphicsQueue)?;
|
||||
let mut gpu =
|
||||
unsafe { phd.open(&[(family, &[1.0])], enabled_features) }.map_err(|err| {
|
||||
use hal::device::CreationError::*;
|
||||
match err {
|
||||
DeviceLost => RequestDeviceError::DeviceLost,
|
||||
InitializationFailed => RequestDeviceError::Internal,
|
||||
OutOfMemory(_) => RequestDeviceError::OutOfMemory,
|
||||
_ => panic!("failed to create `gfx-hal` device: {}", err),
|
||||
}
|
||||
})?;
|
||||
|
||||
if let Some(_) = desc.label {
|
||||
//TODO
|
||||
}
|
||||
|
||||
let limits = phd.limits();
|
||||
assert_eq!(
|
||||
0,
|
||||
BIND_BUFFER_ALIGNMENT % limits.min_storage_buffer_offset_alignment,
|
||||
"Adapter storage buffer offset alignment not compatible with WGPU"
|
||||
);
|
||||
assert_eq!(
|
||||
0,
|
||||
BIND_BUFFER_ALIGNMENT % limits.min_uniform_buffer_offset_alignment,
|
||||
"Adapter uniform buffer offset alignment not compatible with WGPU"
|
||||
);
|
||||
if self.limits < desc.limits {
|
||||
return Err(RequestDeviceError::LimitsExceeded);
|
||||
}
|
||||
|
||||
let mem_props = phd.memory_properties();
|
||||
if !desc.shader_validation {
|
||||
tracing::warn!("Shader validation is disabled");
|
||||
}
|
||||
let private_features = PrivateFeatures {
|
||||
shader_validation: desc.shader_validation,
|
||||
anisotropic_filtering: enabled_features.contains(hal::Features::SAMPLER_ANISOTROPY),
|
||||
texture_d24: phd
|
||||
.format_properties(Some(hal::format::Format::X8D24Unorm))
|
||||
.optimal_tiling
|
||||
.contains(hal::format::ImageFeature::DEPTH_STENCIL_ATTACHMENT),
|
||||
texture_d24_s8: phd
|
||||
.format_properties(Some(hal::format::Format::D24UnormS8Uint))
|
||||
.optimal_tiling
|
||||
.contains(hal::format::ImageFeature::DEPTH_STENCIL_ATTACHMENT),
|
||||
};
|
||||
|
||||
Device::new(
|
||||
gpu.device,
|
||||
Stored {
|
||||
value: Valid(self_id),
|
||||
ref_count: self.life_guard.add_ref(),
|
||||
},
|
||||
gpu.queue_groups.swap_remove(0),
|
||||
mem_props,
|
||||
limits,
|
||||
private_features,
|
||||
desc,
|
||||
trace_path,
|
||||
)
|
||||
.or(Err(RequestDeviceError::OutOfMemory))
|
||||
}
|
||||
}
|
||||
|
||||
impl<B: hal::Backend> crate::hub::Resource for Adapter<B> {
|
||||
@@ -668,152 +812,29 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
desc: &DeviceDescriptor,
|
||||
trace_path: Option<&std::path::Path>,
|
||||
id_in: Input<G, DeviceId>,
|
||||
) -> Result<DeviceId, RequestDeviceError> {
|
||||
) -> (DeviceId, Option<RequestDeviceError>) {
|
||||
span!(_guard, INFO, "Adapter::request_device");
|
||||
|
||||
let hub = B::hub(self);
|
||||
let mut token = Token::root();
|
||||
let device = {
|
||||
let (adapter_guard, _) = hub.adapters.read(&mut token);
|
||||
let adapter = adapter_guard
|
||||
.get(adapter_id)
|
||||
.map_err(|_| RequestDeviceError::InvalidAdapter)?;
|
||||
let phd = &adapter.raw.physical_device;
|
||||
|
||||
// Verify all features were exposed by the adapter
|
||||
if !adapter.features.contains(desc.features) {
|
||||
return Err(RequestDeviceError::UnsupportedFeature(
|
||||
desc.features - adapter.features,
|
||||
));
|
||||
}
|
||||
|
||||
// Verify feature preconditions
|
||||
if desc
|
||||
.features
|
||||
.contains(wgt::Features::MAPPABLE_PRIMARY_BUFFERS)
|
||||
&& adapter.raw.info.device_type == hal::adapter::DeviceType::DiscreteGpu
|
||||
{
|
||||
tracing::warn!("Feature MAPPABLE_PRIMARY_BUFFERS enabled on a discrete gpu. This is a massive performance footgun and likely not what you wanted");
|
||||
}
|
||||
|
||||
let available_features = adapter.raw.physical_device.features();
|
||||
|
||||
// Check features that are always needed
|
||||
let wishful_features = hal::Features::ROBUST_BUFFER_ACCESS
|
||||
| hal::Features::VERTEX_STORES_AND_ATOMICS
|
||||
| hal::Features::FRAGMENT_STORES_AND_ATOMICS
|
||||
| hal::Features::NDC_Y_UP
|
||||
| hal::Features::INDEPENDENT_BLENDING
|
||||
| hal::Features::SAMPLER_ANISOTROPY
|
||||
| hal::Features::IMAGE_CUBE_ARRAY;
|
||||
let mut enabled_features = available_features & wishful_features;
|
||||
if enabled_features != wishful_features {
|
||||
tracing::warn!(
|
||||
"Missing internal features: {:?}",
|
||||
wishful_features - enabled_features
|
||||
);
|
||||
}
|
||||
|
||||
// Features
|
||||
enabled_features.set(
|
||||
hal::Features::TEXTURE_DESCRIPTOR_ARRAY,
|
||||
desc.features
|
||||
.contains(wgt::Features::SAMPLED_TEXTURE_BINDING_ARRAY),
|
||||
);
|
||||
enabled_features.set(
|
||||
hal::Features::SHADER_SAMPLED_IMAGE_ARRAY_DYNAMIC_INDEXING,
|
||||
desc.features
|
||||
.contains(wgt::Features::SAMPLED_TEXTURE_ARRAY_DYNAMIC_INDEXING),
|
||||
);
|
||||
enabled_features.set(
|
||||
hal::Features::SAMPLED_TEXTURE_DESCRIPTOR_INDEXING,
|
||||
desc.features
|
||||
.contains(wgt::Features::SAMPLED_TEXTURE_ARRAY_NON_UNIFORM_INDEXING),
|
||||
);
|
||||
enabled_features.set(
|
||||
hal::Features::UNSIZED_DESCRIPTOR_ARRAY,
|
||||
desc.features.contains(wgt::Features::UNSIZED_BINDING_ARRAY),
|
||||
);
|
||||
enabled_features.set(
|
||||
hal::Features::MULTI_DRAW_INDIRECT,
|
||||
desc.features.contains(wgt::Features::MULTI_DRAW_INDIRECT),
|
||||
);
|
||||
enabled_features.set(
|
||||
hal::Features::DRAW_INDIRECT_COUNT,
|
||||
desc.features
|
||||
.contains(wgt::Features::MULTI_DRAW_INDIRECT_COUNT),
|
||||
);
|
||||
enabled_features.set(
|
||||
hal::Features::NON_FILL_POLYGON_MODE,
|
||||
desc.features.contains(wgt::Features::NON_FILL_POLYGON_MODE),
|
||||
);
|
||||
|
||||
let family = adapter
|
||||
.raw
|
||||
.queue_families
|
||||
.iter()
|
||||
.find(|family| family.queue_type().supports_graphics())
|
||||
.ok_or(RequestDeviceError::NoGraphicsQueue)?;
|
||||
let mut gpu =
|
||||
unsafe { phd.open(&[(family, &[1.0])], enabled_features) }.map_err(|err| {
|
||||
use hal::device::CreationError::*;
|
||||
match err {
|
||||
DeviceLost => RequestDeviceError::DeviceLost,
|
||||
InitializationFailed => RequestDeviceError::Internal,
|
||||
OutOfMemory(_) => RequestDeviceError::OutOfMemory,
|
||||
_ => panic!("failed to create `gfx-hal` device: {}", err),
|
||||
}
|
||||
})?;
|
||||
|
||||
let limits = phd.limits();
|
||||
assert_eq!(
|
||||
0,
|
||||
BIND_BUFFER_ALIGNMENT % limits.min_storage_buffer_offset_alignment,
|
||||
"Adapter storage buffer offset alignment not compatible with WGPU"
|
||||
);
|
||||
assert_eq!(
|
||||
0,
|
||||
BIND_BUFFER_ALIGNMENT % limits.min_uniform_buffer_offset_alignment,
|
||||
"Adapter uniform buffer offset alignment not compatible with WGPU"
|
||||
);
|
||||
if adapter.limits < desc.limits {
|
||||
return Err(RequestDeviceError::LimitsExceeded);
|
||||
}
|
||||
|
||||
let mem_props = phd.memory_properties();
|
||||
if !desc.shader_validation {
|
||||
tracing::warn!("Shader validation is disabled");
|
||||
}
|
||||
let private_features = PrivateFeatures {
|
||||
shader_validation: desc.shader_validation,
|
||||
anisotropic_filtering: enabled_features.contains(hal::Features::SAMPLER_ANISOTROPY),
|
||||
texture_d24: phd
|
||||
.format_properties(Some(hal::format::Format::X8D24Unorm))
|
||||
.optimal_tiling
|
||||
.contains(hal::format::ImageFeature::DEPTH_STENCIL_ATTACHMENT),
|
||||
texture_d24_s8: phd
|
||||
.format_properties(Some(hal::format::Format::D24UnormS8Uint))
|
||||
.optimal_tiling
|
||||
.contains(hal::format::ImageFeature::DEPTH_STENCIL_ATTACHMENT),
|
||||
let error = loop {
|
||||
let (adapter_guard, mut token) = hub.adapters.read(&mut token);
|
||||
let adapter = match adapter_guard.get(adapter_id) {
|
||||
Ok(adapter) => adapter,
|
||||
Err(_) => break RequestDeviceError::InvalidAdapter,
|
||||
};
|
||||
|
||||
Device::new(
|
||||
gpu.device,
|
||||
Stored {
|
||||
value: Valid(adapter_id),
|
||||
ref_count: adapter.life_guard.add_ref(),
|
||||
},
|
||||
gpu.queue_groups.swap_remove(0),
|
||||
mem_props,
|
||||
limits,
|
||||
private_features,
|
||||
desc,
|
||||
trace_path,
|
||||
)
|
||||
.or(Err(RequestDeviceError::OutOfMemory))?
|
||||
let device = match adapter.create_device(adapter_id, desc, trace_path) {
|
||||
Ok(device) => device,
|
||||
Err(e) => break e,
|
||||
};
|
||||
let id = hub.devices.register_identity(id_in, device, &mut token);
|
||||
return (id.0, None);
|
||||
};
|
||||
|
||||
let id = hub.devices.register_identity(id_in, device, &mut token);
|
||||
Ok(id.0)
|
||||
let id = hub
|
||||
.devices
|
||||
.register_error(id_in, desc.label.borrow_or_default(), &mut token);
|
||||
(id, Some(error))
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,7 @@ pub fn check_buffer_usage(
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Error)]
|
||||
#[derive(Clone, Debug, Error, PartialEq)]
|
||||
#[error("texture usage is {actual:?} which does not contain required usage {expected:?}")]
|
||||
pub struct MissingTextureUsageError {
|
||||
pub(crate) actual: wgt::TextureUsage,
|
||||
|
||||
+14
-1
@@ -382,7 +382,9 @@ impl Default for Limits {
|
||||
#[derive(Clone, Debug, Default)]
|
||||
#[cfg_attr(feature = "trace", derive(Serialize))]
|
||||
#[cfg_attr(feature = "replay", derive(Deserialize))]
|
||||
pub struct DeviceDescriptor {
|
||||
pub struct DeviceDescriptor<L> {
|
||||
/// Debug label for the device.
|
||||
pub label: L,
|
||||
/// Features that the device should support. If any feature is not supported by
|
||||
/// the adapter, creating a device will panic.
|
||||
pub features: Features,
|
||||
@@ -394,6 +396,17 @@ pub struct DeviceDescriptor {
|
||||
pub shader_validation: bool,
|
||||
}
|
||||
|
||||
impl<L> DeviceDescriptor<L> {
|
||||
pub fn map_label<K>(&self, fun: impl FnOnce(&L) -> K) -> DeviceDescriptor<K> {
|
||||
DeviceDescriptor {
|
||||
label: fun(&self.label),
|
||||
features: self.features,
|
||||
limits: self.limits.clone(),
|
||||
shader_validation: self.shader_validation,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bitflags::bitflags! {
|
||||
/// Describes the shader stages that a binding will be visible from.
|
||||
///
|
||||
|
||||
Reference in new issue
Block a user