mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
Update to flag-based downlevel bools
This commit is contained in:
@@ -275,7 +275,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
});
|
||||
}
|
||||
|
||||
if !cmd_buf.downlevel.compute_shaders {
|
||||
if !cmd_buf.downlevel.flags.contains(wgt::DownlevelFlags::COMPUTE_SHADERS) {
|
||||
return Err(ComputePassError {
|
||||
scope: PassErrorScope::Pass(encoder_id),
|
||||
inner: ComputePassErrorInner::ComputeShadersUnsupported,
|
||||
|
||||
@@ -1861,7 +1861,7 @@ impl<B: GfxBackend> Device<B> {
|
||||
),
|
||||
pipeline::CreateComputePipelineError,
|
||||
> {
|
||||
if !self.downlevel.compute_shaders {
|
||||
if !self.downlevel.flags.contains(wgt::DownlevelFlags::COMPUTE_SHADERS) {
|
||||
return Err(pipeline::CreateComputePipelineError::ComputeShadersUnsupported);
|
||||
}
|
||||
|
||||
|
||||
@@ -275,20 +275,39 @@ impl<B: GfxBackend> Adapter<B> {
|
||||
.max(MIN_PUSH_CONSTANT_SIZE), // As an extension, the default is always 0, so define a separate minimum.
|
||||
};
|
||||
|
||||
let mut downlevel_flags = wgt::DownlevelFlags::empty();
|
||||
downlevel_flags.set(
|
||||
wgt::DownlevelFlags::COMPUTE_SHADERS,
|
||||
properties.downlevel.compute_shaders,
|
||||
);
|
||||
downlevel_flags.set(
|
||||
wgt::DownlevelFlags::STORAGE_IMAGES,
|
||||
properties.downlevel.storage_images,
|
||||
);
|
||||
downlevel_flags.set(
|
||||
wgt::DownlevelFlags::READ_ONLY_DEPTH_STENCIL,
|
||||
properties.downlevel.read_only_depth_stencil,
|
||||
);
|
||||
downlevel_flags.set(
|
||||
wgt::DownlevelFlags::DEVICE_LOCAL_IMAGE_COPIES,
|
||||
properties.downlevel.device_local_image_copies,
|
||||
);
|
||||
downlevel_flags.set(
|
||||
wgt::DownlevelFlags::NON_POWER_OF_TWO_MIPMAPPED_TEXTURES,
|
||||
properties.downlevel.non_power_of_two_mipmapped_textures,
|
||||
);
|
||||
downlevel_flags.set(
|
||||
wgt::DownlevelFlags::ANISOTROPIC_FILTERING,
|
||||
private_features.anisotropic_filtering,
|
||||
);
|
||||
|
||||
let downlevel = wgt::DownlevelProperties {
|
||||
compute_shaders: properties.downlevel.compute_shaders,
|
||||
flags: downlevel_flags,
|
||||
shader_model: match properties.downlevel.shader_model {
|
||||
hal::DownlevelShaderModel::ShaderModel2 => wgt::ShaderModel::Sm2,
|
||||
hal::DownlevelShaderModel::ShaderModel4 => wgt::ShaderModel::Sm4,
|
||||
hal::DownlevelShaderModel::ShaderModel5 => wgt::ShaderModel::Sm5,
|
||||
},
|
||||
storage_images: properties.downlevel.storage_images,
|
||||
read_only_depth_stencil: properties.downlevel.read_only_depth_stencil,
|
||||
device_local_image_copies: properties.downlevel.device_local_image_copies,
|
||||
non_power_of_two_mipmapped_textures: properties
|
||||
.downlevel
|
||||
.non_power_of_two_mipmapped_textures,
|
||||
anisotropic_filtering: private_features.anisotropic_filtering,
|
||||
};
|
||||
|
||||
Self {
|
||||
|
||||
@@ -241,12 +241,12 @@ const DOWNLEVEL_WARNING_MESSAGE: &str = "The underlying API or device in use doe
|
||||
support enough features to be a fully compliant implementation of WebGPU. A subset of the features can still be used. \
|
||||
If you are running this program on native and not in a browser and wish to limit the features you use to the supported subset, \
|
||||
call Adapter::downlevel_properties or Device::downlevel_properties to get a listing of the features the current \
|
||||
platform is supports.";
|
||||
platform supports.";
|
||||
const DOWNLEVEL_ERROR_WARNING_MESSAGE: &str = "This is not an invalid use of WebGPU: the underlying API or device does not \
|
||||
support enough features to be a fully compliant implementation. A subset of the features can still be used. \
|
||||
If you are running this program on native and not in a browser and wish to work around this issue, call \
|
||||
Adapter::downlevel_properties or Device::downlevel_properties to get a listing of the features the current \
|
||||
platform is supports.";
|
||||
platform supports.";
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! gfx_select {
|
||||
|
||||
@@ -541,22 +541,10 @@ impl Default for Limits {
|
||||
/// Lists various ways the underlying platform does not conform to the WebGPU standard.
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
pub struct DownlevelProperties {
|
||||
/// The device supports compiling and using compute shaders.
|
||||
pub compute_shaders: bool,
|
||||
/// Combined boolean flags.
|
||||
pub flags: DownlevelFlags,
|
||||
/// Which collections of features shaders support. Defined in terms of D3D's shader models.
|
||||
pub shader_model: ShaderModel,
|
||||
/// Supports creating storage images.
|
||||
pub storage_images: bool,
|
||||
/// Supports reading from a depth/stencil buffer while using as a read-only depth/stencil attachment.
|
||||
pub read_only_depth_stencil: bool,
|
||||
/// Supports:
|
||||
/// - copy_image_to_image
|
||||
/// - copy_buffer_to_image and copy_image_to_buffer with a buffer without a MAP_* usage
|
||||
pub device_local_image_copies: bool,
|
||||
/// Supports textures with mipmaps which have a non power of two size.
|
||||
pub non_power_of_two_mipmapped_textures: bool,
|
||||
/// Supports samplers with anisotropic filtering
|
||||
pub anisotropic_filtering: bool,
|
||||
}
|
||||
|
||||
impl Default for DownlevelProperties {
|
||||
@@ -564,13 +552,8 @@ impl Default for DownlevelProperties {
|
||||
// gfx-hal's equivalent structure defaults to all off.
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
compute_shaders: true,
|
||||
flags: DownlevelFlags::COMPLIANT,
|
||||
shader_model: ShaderModel::Sm5,
|
||||
storage_images: true,
|
||||
read_only_depth_stencil: true,
|
||||
device_local_image_copies: true,
|
||||
non_power_of_two_mipmapped_textures: true,
|
||||
anisotropic_filtering: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -585,6 +568,28 @@ impl DownlevelProperties {
|
||||
}
|
||||
}
|
||||
|
||||
bitflags::bitflags! {
|
||||
/// Binary flags listing various ways the underlying platform does not conform to the WebGPU standard.
|
||||
pub struct DownlevelFlags: u32 {
|
||||
/// The device supports compiling and using compute shaders.
|
||||
const COMPUTE_SHADERS = 0x0000_0001;
|
||||
/// Supports creating storage images.
|
||||
const STORAGE_IMAGES = 0x0000_0002;
|
||||
/// Supports reading from a depth/stencil buffer while using as a read-only depth/stencil attachment.
|
||||
const READ_ONLY_DEPTH_STENCIL = 0x0000_0004;
|
||||
/// Supports:
|
||||
/// - copy_image_to_image
|
||||
/// - copy_buffer_to_image and copy_image_to_buffer with a buffer without a MAP_* usage
|
||||
const DEVICE_LOCAL_IMAGE_COPIES = 0x0000_0008;
|
||||
/// Supports textures with mipmaps which have a non power of two size.
|
||||
const NON_POWER_OF_TWO_MIPMAPPED_TEXTURES = 0x0000_0010;
|
||||
/// Supports samplers with anisotropic filtering
|
||||
const ANISOTROPIC_FILTERING = 0x0000_0020;
|
||||
/// All flags are in their compliant state.
|
||||
const COMPLIANT = 0x0000_003F;
|
||||
}
|
||||
}
|
||||
|
||||
/// Collections of shader features a device supports if they support less than WebGPU normally allows.
|
||||
// TODO: Fill out the differences between shader models more completely
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
|
||||
Reference in New Issue
Block a user