Backed out changeset e0a5ed021a2c (bug 1808331) for causing linting failures.

This commit is contained in:
Stanca Serban 2023-01-04 18:36:53 +02:00
Родитель 848e2cfb4b
Коммит d46c924b0b
44 изменённых файлов: 223 добавлений и 980 удалений

Просмотреть файл

@ -27,7 +27,7 @@ replace-with = "vendored-sources"
[source."https://github.com/gfx-rs/wgpu"]
git = "https://github.com/gfx-rs/wgpu"
rev = "186a29c34d54d8628bbebb998a537210ac565b71"
rev = "f14bee67"
replace-with = "vendored-sources"
[source."https://github.com/hsivonen/chardetng"]

7
Cargo.lock сгенерированный
Просмотреть файл

@ -6289,7 +6289,7 @@ dependencies = [
[[package]]
name = "wgpu-core"
version = "0.14.0"
source = "git+https://github.com/gfx-rs/wgpu?rev=186a29c34d54d8628bbebb998a537210ac565b71#186a29c34d54d8628bbebb998a537210ac565b71"
source = "git+https://github.com/gfx-rs/wgpu?rev=f14bee67#f14bee6740b8755afa362c3be6ef4b225209871a"
dependencies = [
"arrayvec",
"bit-vec",
@ -6312,7 +6312,7 @@ dependencies = [
[[package]]
name = "wgpu-hal"
version = "0.14.0"
source = "git+https://github.com/gfx-rs/wgpu?rev=186a29c34d54d8628bbebb998a537210ac565b71#186a29c34d54d8628bbebb998a537210ac565b71"
source = "git+https://github.com/gfx-rs/wgpu?rev=f14bee67#f14bee6740b8755afa362c3be6ef4b225209871a"
dependencies = [
"android_system_properties",
"arrayvec",
@ -6328,7 +6328,6 @@ dependencies = [
"gpu-descriptor",
"js-sys",
"khronos-egl",
"libc",
"libloading",
"log",
"metal",
@ -6350,7 +6349,7 @@ dependencies = [
[[package]]
name = "wgpu-types"
version = "0.14.0"
source = "git+https://github.com/gfx-rs/wgpu?rev=186a29c34d54d8628bbebb998a537210ac565b71#186a29c34d54d8628bbebb998a537210ac565b71"
source = "git+https://github.com/gfx-rs/wgpu?rev=f14bee67#f14bee6740b8755afa362c3be6ef4b225209871a"
dependencies = [
"bitflags",
"serde",

Просмотреть файл

@ -17,7 +17,7 @@ default = []
[dependencies.wgc]
package = "wgpu-core"
git = "https://github.com/gfx-rs/wgpu"
rev = "186a29c34d54d8628bbebb998a537210ac565b71"
rev = "f14bee67"
#Note: "replay" shouldn't ideally be needed,
# but it allows us to serialize everything across IPC.
features = ["replay", "trace", "serial-pass", "strict_asserts", "wgsl", "renderdoc"]
@ -27,32 +27,32 @@ features = ["replay", "trace", "serial-pass", "strict_asserts", "wgsl", "renderd
[target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies.wgc]
package = "wgpu-core"
git = "https://github.com/gfx-rs/wgpu"
rev = "186a29c34d54d8628bbebb998a537210ac565b71"
rev = "f14bee67"
features = ["metal"]
# We want the wgpu-core Direct3D backends on Windows.
[target.'cfg(windows)'.dependencies.wgc]
package = "wgpu-core"
git = "https://github.com/gfx-rs/wgpu"
rev = "186a29c34d54d8628bbebb998a537210ac565b71"
rev = "f14bee67"
features = ["dx11", "dx12"]
# We want the wgpu-core Vulkan backend on Linux and Windows.
[target.'cfg(any(windows, all(unix, not(any(target_os = "macos", target_os = "ios")))))'.dependencies.wgc]
package = "wgpu-core"
git = "https://github.com/gfx-rs/wgpu"
rev = "186a29c34d54d8628bbebb998a537210ac565b71"
rev = "f14bee67"
features = ["vulkan"]
[dependencies.wgt]
package = "wgpu-types"
git = "https://github.com/gfx-rs/wgpu"
rev = "186a29c34d54d8628bbebb998a537210ac565b71"
rev = "f14bee67"
[dependencies.wgh]
package = "wgpu-hal"
git = "https://github.com/gfx-rs/wgpu"
rev = "186a29c34d54d8628bbebb998a537210ac565b71"
rev = "f14bee67"
[dependencies]
bincode = "1"

Просмотреть файл

@ -1 +1 @@
{"files":{"Cargo.toml":"70b60e663e9ad3847924f1a5aa12e88b634aae3a1dff92b691c1c7586e520b75","LICENSE.APACHE":"a6cba85bc92e0cff7a450b1d873c0eaa2e9fc96bf472df0247a26bec77bf3ff9","LICENSE.MIT":"c7fea58d1cfe49634cd92e54fc10a9d871f4b275321a4cd8c09e449122caaeb4","src/binding_model.rs":"3b9180c91a30ffaffaddaa734ee99e7a0e68b1da1bf3963eae447fa69cfae2ef","src/command/bind.rs":"88ca2bedfcd8392efc960f39ca8506024af495dcf1852cf16ae28fbadbdf748d","src/command/bundle.rs":"9420e25cf05f28170cce81df0d20e67f4dbe5b54588c0541e01008dde4bf7b45","src/command/clear.rs":"cc118937b7a0b05225a2417db2f11bb95a095b0ca63561db092a8dfab35d9158","src/command/compute.rs":"f2a08528e39e3cc7049757e9d63d591c8adc9bffa3af66d57eee0e6ab7bc3015","src/command/draw.rs":"ac3541fb46435dd1687b24b24d9896104adde8f662111f232b7b4e8e34a869ea","src/command/memory_init.rs":"347117a84f35927de91e7ab4cc69d19b5b4507a942596c0c725f27b50c428b1e","src/command/mod.rs":"31623431b6dc1c061dedcb838949d4c81d4e95d5516be47524d53b3d2faef3e6","src/command/query.rs":"2c107b22806a003808da2f886ecc74764b016851b7a6cec8caf21385a2e25dee","src/command/render.rs":"d62d2ec5344312f78714d294ffc53686f993accd84925af29700073dc1d1b117","src/command/transfer.rs":"5321de8440653e3c69970816d3df8e628ae31fc7c5a03125f1cc8ed244e13f68","src/conv.rs":"c4506a7f715461d67c2bcfef002f13d3e75d10b2e4f18b0ab9ea8d5bdeb7bc61","src/device/life.rs":"5f58817365cf8b0a76cab83fdb50b3ee69a15b2bd868bc3702c7c29f3189326c","src/device/mod.rs":"5019dcbdda406700b3e7121055eba7936b8cd403517e5711fabaf1421f8fd6a6","src/device/queue.rs":"883a0bd1c8d3cddc46393e9eeb76bedce9ce48d1467a767d9839db7934252ad9","src/device/trace.rs":"9c03f5ec06cae37f294179a2285e2af7a5497db8a5572bf1dbe50136943d69be","src/error.rs":"7e914b25a2b9578672eb4a8b52c778ad947e12e0f24b44a8453cda48a249b39c","src/hub.rs":"1be76bb6c1cae694e891d6798789ed9748535b42b042f44cad09d939dbc802c1","src/id.rs":"608dfbdc118905638762d0a16e4f69b0ecae16bbe20accead2d7d9b7e7281dda","src/init_tracker/buffer.rs":"a0ebf54a1e6d269c7b4aa0ac7bb8b04fd2cea3221a1d058ff33cb683b2aea3e9","src/init_tracker/mod.rs":"0867f79f83555390d0982d1dc6dcf0d4340e10cb89aa633d3c3ecc45deb3c78c","src/init_tracker/texture.rs":"11de3b1968829aec1f165930d9e4f946d6c02c7994ce32925a62f883820aa1e3","src/instance.rs":"12f4204755c67eaf82013142c4e6ff8e3ad4e74adf07c00f7d20caa1fd2a09e6","src/lib.rs":"206c07ef386628a9b8e0f8ad45415c9eb9b55418c3636cc9e6aba63eb6ed5978","src/pipeline.rs":"38e9fff13e7e152378e95dc13822dab62542d4b172f006a34d84eebb70bed0f7","src/present.rs":"7c00b8bc3475d9a100adf5c9e9d0af823aa14b626e923f87ec988022bd4766d1","src/resource.rs":"c23933592838688d86986a0f6c449df6eaefa8b770e10c512d849a7a497b92a7","src/track/buffer.rs":"0b7a8c6acfe55e3f45dd1e7ef1b3ee8bd4844f61bbabf62aa4f0c391b822803c","src/track/metadata.rs":"9565f700661e81fd534a751a0e3d26022238ad8784cc868333da7030b3571473","src/track/mod.rs":"995a8cd73499a26b593d0a419630681ea7942cec8db132ae8a13baf69fe13cdc","src/track/range.rs":"5bbfed6e103b3234d9de8e42057022da6d628c2cc1db6bb51b88f87f2d8adf8b","src/track/stateless.rs":"34942ecdf81b05b75892c891c87e065329870459ff8edfca1f99ec9533c334aa","src/track/texture.rs":"7d38b2f4e0cdb3e56ce1e777d8bca4d73ef40e21c56e11fedd69dc27e789256d","src/validation.rs":"03d3a99410c5f6ec937358206ea76eafff31823ebbe443ab71facf8a8b6a95e8"},"package":null}
{"files":{"Cargo.toml":"b5c08830288118487c291e001a92baf2f7b94241ceeb313ee8a7cf8ce3a76190","LICENSE.APACHE":"a6cba85bc92e0cff7a450b1d873c0eaa2e9fc96bf472df0247a26bec77bf3ff9","LICENSE.MIT":"c7fea58d1cfe49634cd92e54fc10a9d871f4b275321a4cd8c09e449122caaeb4","src/assertions.rs":"4dc5c47f6b141ab41c9d2fc3f3bbb502e84bf11391b92d1f4cf2015a1807e759","src/binding_model.rs":"3b9180c91a30ffaffaddaa734ee99e7a0e68b1da1bf3963eae447fa69cfae2ef","src/command/bind.rs":"88ca2bedfcd8392efc960f39ca8506024af495dcf1852cf16ae28fbadbdf748d","src/command/bundle.rs":"9420e25cf05f28170cce81df0d20e67f4dbe5b54588c0541e01008dde4bf7b45","src/command/clear.rs":"cc118937b7a0b05225a2417db2f11bb95a095b0ca63561db092a8dfab35d9158","src/command/compute.rs":"f2a08528e39e3cc7049757e9d63d591c8adc9bffa3af66d57eee0e6ab7bc3015","src/command/draw.rs":"ac3541fb46435dd1687b24b24d9896104adde8f662111f232b7b4e8e34a869ea","src/command/memory_init.rs":"347117a84f35927de91e7ab4cc69d19b5b4507a942596c0c725f27b50c428b1e","src/command/mod.rs":"31623431b6dc1c061dedcb838949d4c81d4e95d5516be47524d53b3d2faef3e6","src/command/query.rs":"2c107b22806a003808da2f886ecc74764b016851b7a6cec8caf21385a2e25dee","src/command/render.rs":"d62d2ec5344312f78714d294ffc53686f993accd84925af29700073dc1d1b117","src/command/transfer.rs":"9864350bf14b2cef1245bf1d47c304876455df41946c2017fd587642b6557733","src/conv.rs":"9c1f594360356c51a778126ead76479b1f717c203c11f9b9df899be5eb270d56","src/device/life.rs":"5f58817365cf8b0a76cab83fdb50b3ee69a15b2bd868bc3702c7c29f3189326c","src/device/mod.rs":"f1ced71a78e16fe89a3fc2bbbf83319a515a8b545b4ca41774cadd1da9c7989c","src/device/queue.rs":"e858403d24c0674b5858a10ec741e0b3bb224c20d7c683f65ef00d0a5898f09a","src/device/trace.rs":"9c03f5ec06cae37f294179a2285e2af7a5497db8a5572bf1dbe50136943d69be","src/error.rs":"7e914b25a2b9578672eb4a8b52c778ad947e12e0f24b44a8453cda48a249b39c","src/hub.rs":"1be76bb6c1cae694e891d6798789ed9748535b42b042f44cad09d939dbc802c1","src/id.rs":"cdb448ba7a8b6b9956102308a96925ecd35f9f5ee873c9df9bd8bca0190f1beb","src/init_tracker/buffer.rs":"a0ebf54a1e6d269c7b4aa0ac7bb8b04fd2cea3221a1d058ff33cb683b2aea3e9","src/init_tracker/mod.rs":"0867f79f83555390d0982d1dc6dcf0d4340e10cb89aa633d3c3ecc45deb3c78c","src/init_tracker/texture.rs":"11de3b1968829aec1f165930d9e4f946d6c02c7994ce32925a62f883820aa1e3","src/instance.rs":"ad0afe9a5ac4e83fe1f89cd7d4d9e92aa7cc44e1118e67c8d307494d5c6e6e5b","src/lib.rs":"f331035e56a596d49bd71f12714fced9e63c0a75cdc33bff4786949c1c6dbaa5","src/pipeline.rs":"38e9fff13e7e152378e95dc13822dab62542d4b172f006a34d84eebb70bed0f7","src/present.rs":"7c00b8bc3475d9a100adf5c9e9d0af823aa14b626e923f87ec988022bd4766d1","src/resource.rs":"c23933592838688d86986a0f6c449df6eaefa8b770e10c512d849a7a497b92a7","src/track/buffer.rs":"160b361c70344197a4edce91c9cbbf953f530cbf6abc47fe22d0e802be5b0b10","src/track/metadata.rs":"b3b163ad8f882ecca88e0c630d63ecd81c26de8f6cdce93912a26e2ee2824770","src/track/mod.rs":"6e26fbb902f8ad7b7ea068f24138e8f7c99db27e05e9c9ae56b39eb1e40149ac","src/track/range.rs":"5bbfed6e103b3234d9de8e42057022da6d628c2cc1db6bb51b88f87f2d8adf8b","src/track/stateless.rs":"34942ecdf81b05b75892c891c87e065329870459ff8edfca1f99ec9533c334aa","src/track/texture.rs":"b8e6d85a879ecf1b7e56cfe84bb6d5b5ca47ec302e467578b08b54997bbfd12f","src/validation.rs":"e3104c88e46eec6ee161c7dfb12df4f71616de63a27ebca1e2982c44a3705f8b"},"package":null}

2
third_party/rust/wgpu-core/Cargo.toml поставляемый
Просмотреть файл

@ -34,7 +34,7 @@ emscripten = ["hal/emscripten"]
# Apply run-time checks, even in release builds. These are in addition
# to the validation carried out at public APIs in all builds.
strict_asserts = ["wgt/strict_asserts"]
strict_asserts = []
angle = ["hal/gles"]
# Enable API tracing
trace = ["ron", "serde", "wgt/trace", "arrayvec/serde", "naga/serialize"]

60
third_party/rust/wgpu-core/src/assertions.rs поставляемый Normal file
Просмотреть файл

@ -0,0 +1,60 @@
//! Macros for validation internal to the resource tracker.
//!
//! This module defines assertion macros that respect `wgpu-core`'s
//! `"strict_asserts"` feature.
//!
//! Because `wgpu-core`'s public APIs validate their arguments in all
//! types of builds, for performance, the `track` module skips some of
//! Rust's usual run-time checks on its internal operations in release
//! builds. However, some `wgpu-core` applications have a strong
//! preference for robustness over performance. To accommodate them,
//! `wgpu-core`'s `"strict_asserts"` feature enables that validation
//! in both debug and release builds.
#[cfg(feature = "strict_asserts")]
#[macro_export]
macro_rules! strict_assert {
( $( $arg:tt )* ) => {
assert!( $( $arg )* )
}
}
#[cfg(feature = "strict_asserts")]
#[macro_export]
macro_rules! strict_assert_eq {
( $( $arg:tt )* ) => {
assert_eq!( $( $arg )* )
}
}
#[cfg(feature = "strict_asserts")]
#[macro_export]
macro_rules! strict_assert_ne {
( $( $arg:tt )* ) => {
assert_ne!( $( $arg )* )
}
}
#[cfg(not(feature = "strict_asserts"))]
#[macro_export]
macro_rules! strict_assert {
( $( $arg:tt )* ) => {
debug_assert!( $( $arg )* )
};
}
#[cfg(not(feature = "strict_asserts"))]
#[macro_export]
macro_rules! strict_assert_eq {
( $( $arg:tt )* ) => {
debug_assert_eq!( $( $arg )* )
};
}
#[cfg(not(feature = "strict_asserts"))]
#[macro_export]
macro_rules! strict_assert_ne {
( $( $arg:tt )* ) => {
debug_assert_ne!( $( $arg )* )
};
}

Просмотреть файл

@ -92,16 +92,10 @@ pub enum TransferError {
InvalidRowsPerImage,
#[error("source and destination layers have different aspects")]
MismatchedAspects,
#[error("copying from textures with format {format:?} and aspect {aspect:?} is forbidden")]
CopyFromForbiddenTextureFormat {
format: wgt::TextureFormat,
aspect: wgt::TextureAspect,
},
#[error("copying to textures with format {format:?} and aspect {aspect:?} is forbidden")]
CopyToForbiddenTextureFormat {
format: wgt::TextureFormat,
aspect: wgt::TextureAspect,
},
#[error("copying from textures with format {0:?} is forbidden")]
CopyFromForbiddenTextureFormat(wgt::TextureFormat),
#[error("copying to textures with format {0:?} is forbidden")]
CopyToForbiddenTextureFormat(wgt::TextureFormat),
#[error("the entire texture must be copied when copying from depth texture")]
InvalidDepthTextureExtent,
#[error(
@ -331,8 +325,8 @@ pub(crate) fn validate_texture_copy_range(
let extent = extent_virtual.physical_size(desc.format);
match desc.format {
wgt::TextureFormat::Stencil8
| wgt::TextureFormat::Depth16Unorm
//wgt::TextureFormat::Stencil8 |
wgt::TextureFormat::Depth16Unorm
| wgt::TextureFormat::Depth32Float
| wgt::TextureFormat::Depth32FloatStencil8
| wgt::TextureFormat::Depth24Plus
@ -777,12 +771,10 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
true,
)?;
if !conv::is_valid_copy_dst_texture_format(dst_texture.desc.format, destination.aspect) {
return Err(TransferError::CopyToForbiddenTextureFormat {
format: dst_texture.desc.format,
aspect: destination.aspect,
}
.into());
if !conv::is_valid_copy_dst_texture_format(dst_texture.desc.format) {
return Err(
TransferError::CopyToForbiddenTextureFormat(dst_texture.desc.format).into(),
);
}
cmd_buf
@ -925,12 +917,10 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
true,
)?;
if !conv::is_valid_copy_src_texture_format(src_texture.desc.format, source.aspect) {
return Err(TransferError::CopyFromForbiddenTextureFormat {
format: src_texture.desc.format,
aspect: source.aspect,
}
.into());
if !conv::is_valid_copy_src_texture_format(src_texture.desc.format) {
return Err(
TransferError::CopyFromForbiddenTextureFormat(src_texture.desc.format).into(),
);
}
if format_desc.sample_type == wgt::TextureSampleType::Depth

26
third_party/rust/wgpu-core/src/conv.rs поставляемый
Просмотреть файл

@ -8,27 +8,23 @@ pub fn is_power_of_two_u32(val: u32) -> bool {
val != 0 && (val & (val - 1)) == 0
}
pub fn is_valid_copy_src_texture_format(
format: wgt::TextureFormat,
aspect: wgt::TextureAspect,
) -> bool {
use wgt::TextureAspect as Ta;
pub fn is_valid_copy_src_texture_format(format: wgt::TextureFormat) -> bool {
use wgt::TextureFormat as Tf;
match (format, aspect) {
(Tf::Depth24Plus, _) | (Tf::Depth24PlusStencil8, Ta::DepthOnly) => false,
match format {
Tf::Depth24Plus | Tf::Depth24PlusStencil8 => false,
_ => true,
}
}
pub fn is_valid_copy_dst_texture_format(
format: wgt::TextureFormat,
aspect: wgt::TextureAspect,
) -> bool {
use wgt::TextureAspect as Ta;
pub fn is_valid_copy_dst_texture_format(format: wgt::TextureFormat) -> bool {
use wgt::TextureFormat as Tf;
match (format, aspect) {
(Tf::Depth24Plus | Tf::Depth32Float, _)
| (Tf::Depth24PlusStencil8 | Tf::Depth32FloatStencil8, Ta::DepthOnly) => false,
match format {
//Tf::Stencil8 |
Tf::Depth16Unorm
| Tf::Depth32Float
| Tf::Depth32FloatStencil8
| Tf::Depth24Plus
| Tf::Depth24PlusStencil8 => false,
_ => true,
}
}

Просмотреть файл

@ -2738,10 +2738,6 @@ impl<A: HalApi> Device<A> {
if let Some(e) = error {
return Err(pipeline::CreateRenderPipelineError::DepthStencilState(e));
}
if ds.bias.clamp != 0.0 {
self.require_downlevel_flags(wgt::DownlevelFlags::DEPTH_BIAS_CLAMP)?;
}
}
if desc.layout.is_none() {
@ -5246,7 +5242,8 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
};
let num_frames = present::DESIRED_NUM_FRAMES
.clamp(*caps.swap_chain_sizes.start(), *caps.swap_chain_sizes.end());
.max(*caps.swap_chain_sizes.start())
.min(*caps.swap_chain_sizes.end());
let mut hal_config = hal::SurfaceConfiguration {
swap_chain_size: num_frames,
present_mode: config.present_mode,

Просмотреть файл

@ -624,12 +624,8 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
false,
)?;
if !conv::is_valid_copy_dst_texture_format(texture_format, destination.aspect) {
return Err(TransferError::CopyToForbiddenTextureFormat {
format: texture_format,
aspect: destination.aspect,
}
.into());
if !conv::is_valid_copy_dst_texture_format(texture_format) {
return Err(TransferError::CopyToForbiddenTextureFormat(texture_format).into());
}
let (block_width, block_height) = format_desc.block_dimensions;
let width_blocks = size.width / block_width as u32;

12
third_party/rust/wgpu-core/src/id.rs поставляемый
Просмотреть файл

@ -93,13 +93,6 @@ impl<T> From<SerialId> for Id<T> {
}
impl<T> Id<T> {
/// # Safety
///
/// The raw id must be valid for the type.
pub unsafe fn from_raw(raw: NonZeroId) -> Self {
Self(raw, PhantomData)
}
#[allow(dead_code)]
pub(crate) fn dummy(index: u32) -> Valid<Self> {
Valid(Id::zip(index, 1, Backend::Empty))
@ -172,7 +165,6 @@ pub(crate) struct Valid<I>(pub I);
/// need to construct `Id` values directly, or access their components, like the
/// WGPU recording player, may use this trait to do so.
pub trait TypedId: Copy {
fn as_raw(&self) -> NonZeroId;
fn zip(index: Index, epoch: Epoch, backend: Backend) -> Self;
fn unzip(self) -> (Index, Epoch, Backend);
fn into_raw(self) -> NonZeroId;
@ -180,10 +172,6 @@ pub trait TypedId: Copy {
#[allow(trivial_numeric_casts)]
impl<T> TypedId for Id<T> {
fn as_raw(&self) -> NonZeroId {
self.0
}
fn zip(index: Index, epoch: Epoch, backend: Backend) -> Self {
assert_eq!(0, epoch >> EPOCH_BITS);
assert_eq!(0, (index as IdType) >> INDEX_BITS);

26
third_party/rust/wgpu-core/src/instance.rs поставляемый
Просмотреть файл

@ -176,19 +176,7 @@ pub struct Adapter<A: hal::Api> {
}
impl<A: HalApi> Adapter<A> {
fn new(mut raw: hal::ExposedAdapter<A>) -> Self {
// WebGPU requires this offset alignment as lower bound on all adapters.
const MIN_BUFFER_OFFSET_ALIGNMENT_LOWER_BOUND: u32 = 32;
let limits = &mut raw.capabilities.limits;
limits.min_uniform_buffer_offset_alignment = limits
.min_uniform_buffer_offset_alignment
.max(MIN_BUFFER_OFFSET_ALIGNMENT_LOWER_BOUND);
limits.min_storage_buffer_offset_alignment = limits
.min_storage_buffer_offset_alignment
.max(MIN_BUFFER_OFFSET_ALIGNMENT_LOWER_BOUND);
fn new(raw: hal::ExposedAdapter<A>) -> Self {
Self {
raw,
life_guard: LifeGuard::new("<Adapter>"),
@ -945,18 +933,6 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
.map_err(|_| InvalidAdapter)
}
pub fn adapter_get_presentation_timestamp<A: HalApi>(
&self,
adapter_id: AdapterId,
) -> Result<wgt::PresentationTimestamp, InvalidAdapter> {
let hub = A::hub(self);
let mut token = Token::root();
let (adapter_guard, _) = hub.adapters.read(&mut token);
let adapter = adapter_guard.get(adapter_id).map_err(|_| InvalidAdapter)?;
Ok(unsafe { adapter.raw.adapter.get_presentation_timestamp() })
}
pub fn adapter_drop<A: HalApi>(&self, adapter_id: AdapterId) {
profiling::scope!("Adapter::drop");

3
third_party/rust/wgpu-core/src/lib.rs поставляемый
Просмотреть файл

@ -35,6 +35,9 @@
clippy::pattern_type_mismatch,
)]
#[macro_use]
mod assertions;
pub mod binding_model;
pub mod command;
mod conv;

Просмотреть файл

@ -19,7 +19,6 @@ use crate::{
LifeGuard, RefCount,
};
use hal::BufferUses;
use wgt::{strict_assert, strict_assert_eq};
impl ResourceUses for BufferUses {
const EXCLUSIVE: Self = Self::EXCLUSIVE;

Просмотреть файл

@ -7,7 +7,6 @@ use crate::{
};
use bit_vec::BitVec;
use std::{borrow::Cow, marker::PhantomData, mem};
use wgt::strict_assert;
/// A set of resources, holding a [`RefCount`] and epoch for each member.
///

3
third_party/rust/wgpu-core/src/track/mod.rs поставляемый
Просмотреть файл

@ -81,7 +81,7 @@ This allows us to compose the operations to form the various kinds of tracker me
that need to happen in the codebase. For each resource in the given merger, the following
operation applies:
```text
```
UsageScope <- Resource = insert(scope, usage) OR merge(scope, usage)
UsageScope <- UsageScope = insert(scope, scope) OR merge(scope, scope)
CommandBuffer <- UsageScope = insert(buffer.start, buffer.end, scope)
@ -114,7 +114,6 @@ pub(crate) use stateless::{StatelessBindGroupSate, StatelessTracker};
pub(crate) use texture::{
TextureBindGroupState, TextureSelector, TextureTracker, TextureUsageScope,
};
use wgt::strict_assert_ne;
/// A structure containing all the information about a particular resource
/// transition. User code should be able to generate a pipeline barrier

Просмотреть файл

@ -34,7 +34,6 @@ use hal::TextureUses;
use arrayvec::ArrayVec;
use naga::FastHashMap;
use wgt::{strict_assert, strict_assert_eq};
use std::{borrow::Cow, iter, marker::PhantomData, ops::Range, vec::Drain};
@ -815,7 +814,7 @@ enum TextureStateProvider<'a> {
TextureSet { set: &'a TextureStateSet },
}
impl<'a> TextureStateProvider<'a> {
/// Convenience function turning `Option<Selector>` into this enum.
/// Convenience function turning Option<Selector> into this enum.
fn from_option(selector: Option<TextureSelector>, state: TextureUses) -> Self {
match selector {
Some(selector) => Self::Selector { selector, state },

Просмотреть файл

@ -705,8 +705,8 @@ impl NumericType {
(NumericDimension::Vector(Vs::Quad), Sk::Sint)
}
Tf::Rg11b10Float => (NumericDimension::Vector(Vs::Tri), Sk::Float),
Tf::Stencil8
| Tf::Depth16Unorm
//Tf::Stencil8 |
Tf::Depth16Unorm
| Tf::Depth32Float
| Tf::Depth32FloatStencil8
| Tf::Depth24Plus

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

8
third_party/rust/wgpu-hal/Cargo.toml поставляемый
Просмотреть файл

@ -33,8 +33,6 @@ vulkan = ["naga/spv-out", "ash", "gpu-alloc", "gpu-descriptor", "libloading", "s
gles = ["naga/glsl-out", "glow", "egl", "libloading"]
dx11 = ["naga/hlsl-out", "native", "libloading", "winapi/d3d11", "winapi/d3d11_1", "winapi/d3d11_2", "winapi/d3d11sdklayers", "winapi/dxgi1_6"]
dx12 = ["naga/hlsl-out", "native", "bit-set", "range-alloc", "winapi/d3d12", "winapi/d3d12shader", "winapi/d3d12sdklayers", "winapi/dxgi1_6"]
# TODO: This is a separate feature until Mozilla okays windows-rs, see https://github.com/gfx-rs/wgpu/issues/3207 for the tracking issue.
windows_rs = ["gpu-allocator"]
renderdoc = ["libloading", "renderdoc-sys"]
emscripten = ["gles"]
@ -74,7 +72,6 @@ glow = { git = "https://github.com/grovesNL/glow", rev = "c8a011fcd57a5c68cc917e
# backend: Dx12
bit-set = { version = "0.5", optional = true }
range-alloc = { version = "0.1", optional = true }
gpu-allocator = { version = "0.21", default_features = false, features = ["d3d12", "windows", "public-winapi"], optional = true }
[dependencies.wgt]
package = "wgpu-types"
@ -90,7 +87,7 @@ egl = { package = "khronos-egl", version = "4.1", features = ["static", "no-pkg-
libloading = { version = "0.7", optional = true }
[target.'cfg(windows)'.dependencies]
winapi = { version = "0.3", features = ["profileapi", "libloaderapi", "windef", "winuser", "dcomp"] }
winapi = { version = "0.3", features = ["libloaderapi", "windef", "winuser", "dcomp"] }
native = { package = "d3d12", version = "0.5.0", features = ["libloading"], optional = true }
[target.'cfg(any(target_os="macos", target_os="ios"))'.dependencies]
@ -103,9 +100,6 @@ wasm-bindgen = "0.2.83"
web-sys = { version = "0.3.60", features = ["Window", "HtmlCanvasElement", "WebGl2RenderingContext", "OffscreenCanvas"] }
js-sys = "0.3.60"
[target.'cfg(unix)'.dependencies]
libc = "0.2"
[target.'cfg(target_os = "android")'.dependencies]
android_system_properties = "0.1.1"

Просмотреть файл

@ -124,10 +124,9 @@ impl<A: hal::Api> Example<A> {
let window_size: (u32, u32) = window.inner_size().into();
let surface_config = hal::SurfaceConfiguration {
swap_chain_size: DESIRED_FRAMES.clamp(
*surface_caps.swap_chain_sizes.start(),
*surface_caps.swap_chain_sizes.end(),
),
swap_chain_size: DESIRED_FRAMES
.max(*surface_caps.swap_chain_sizes.start())
.min(*surface_caps.swap_chain_sizes.end()),
present_mode: wgt::PresentMode::Fifo,
composite_alpha_mode: wgt::CompositeAlphaMode::Opaque,
format: wgt::TextureFormat::Bgra8UnormSrgb,

Просмотреть файл

@ -47,7 +47,7 @@ pub fn map_texture_format_failable(format: wgt::TextureFormat) -> Option<dxgifor
Tf::Rgba32Uint => DXGI_FORMAT_R32G32B32A32_UINT,
Tf::Rgba32Sint => DXGI_FORMAT_R32G32B32A32_SINT,
Tf::Rgba32Float => DXGI_FORMAT_R32G32B32A32_FLOAT,
Tf::Stencil8 => DXGI_FORMAT_D24_UNORM_S8_UINT,
//Tf::Stencil8 => DXGI_FORMAT_R8_UNORM,
Tf::Depth16Unorm => DXGI_FORMAT_D16_UNORM,
Tf::Depth24Plus => DXGI_FORMAT_D24_UNORM_S8_UINT,
Tf::Depth24PlusStencil8 => DXGI_FORMAT_D24_UNORM_S8_UINT,
@ -101,17 +101,19 @@ pub fn map_texture_format_nosrgb(format: wgt::TextureFormat) -> dxgiformat::DXGI
}
}
// Note: SRV and UAV can't use the depth formats directly
//Note: SRV and UAV can't use the depth formats directly
//TODO: stencil views?
pub fn map_texture_format_nodepth(format: wgt::TextureFormat) -> dxgiformat::DXGI_FORMAT {
match format {
wgt::TextureFormat::Depth16Unorm => dxgiformat::DXGI_FORMAT_R16_UNORM,
//wgt::TextureFormat::Stencil8 => dxgiformat::DXGI_FORMAT_R8_UNORM,
wgt::TextureFormat::Depth16Unorm => dxgiformat::DXGI_FORMAT_D16_UNORM,
wgt::TextureFormat::Depth32Float => dxgiformat::DXGI_FORMAT_R32_FLOAT,
wgt::TextureFormat::Depth32FloatStencil8 => {
dxgiformat::DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS
}
wgt::TextureFormat::Stencil8
| wgt::TextureFormat::Depth24Plus
| wgt::TextureFormat::Depth24PlusStencil8 => dxgiformat::DXGI_FORMAT_R24_UNORM_X8_TYPELESS,
wgt::TextureFormat::Depth24Plus | wgt::TextureFormat::Depth24PlusStencil8 => {
dxgiformat::DXGI_FORMAT_R24_UNORM_X8_TYPELESS
}
_ => {
assert_eq!(
crate::FormatAspects::from(format),
@ -124,10 +126,10 @@ pub fn map_texture_format_nodepth(format: wgt::TextureFormat) -> dxgiformat::DXG
pub fn map_texture_format_depth_typeless(format: wgt::TextureFormat) -> dxgiformat::DXGI_FORMAT {
match format {
wgt::TextureFormat::Depth16Unorm => dxgiformat::DXGI_FORMAT_R16_TYPELESS,
//wgt::TextureFormat::Stencil8 => dxgiformat::DXGI_FORMAT_R8_UNORM,
wgt::TextureFormat::Depth16Unorm => dxgiformat::DXGI_FORMAT_D16_UNORM,
wgt::TextureFormat::Depth32Float => dxgiformat::DXGI_FORMAT_R32_TYPELESS,
wgt::TextureFormat::Depth32FloatStencil8 => dxgiformat::DXGI_FORMAT_R32G8X24_TYPELESS,
wgt::TextureFormat::Stencil8 => dxgiformat::DXGI_FORMAT_R24G8_TYPELESS,
wgt::TextureFormat::Depth24Plus | wgt::TextureFormat::Depth24PlusStencil8 => {
dxgiformat::DXGI_FORMAT_R24G8_TYPELESS
}

Просмотреть файл

@ -2,4 +2,3 @@ pub mod conv;
pub mod exception;
pub mod factory;
pub mod result;
pub mod time;

Просмотреть файл

@ -1,94 +0,0 @@
#![allow(dead_code)] // IPresentationManager is unused currently
use std::mem;
use winapi::um::{
profileapi::{QueryPerformanceCounter, QueryPerformanceFrequency},
winnt::LARGE_INTEGER,
};
pub enum PresentationTimer {
/// DXGI uses QueryPerformanceCounter
Dxgi {
/// How many ticks of QPC per second
frequency: u64,
},
/// IPresentationManager uses QueryInterruptTimePrecise
#[allow(non_snake_case)]
IPresentationManager {
fnQueryInterruptTimePrecise: unsafe extern "system" fn(*mut winapi::ctypes::c_ulonglong),
},
}
impl std::fmt::Debug for PresentationTimer {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match *self {
Self::Dxgi { frequency } => f
.debug_struct("DXGI")
.field("frequency", &frequency)
.finish(),
Self::IPresentationManager {
fnQueryInterruptTimePrecise,
} => f
.debug_struct("IPresentationManager")
.field(
"QueryInterruptTimePrecise",
&(fnQueryInterruptTimePrecise as usize),
)
.finish(),
}
}
}
impl PresentationTimer {
/// Create a presentation timer using QueryPerformanceFrequency (what DXGI uses for presentation times)
pub fn new_dxgi() -> Self {
let mut frequency: LARGE_INTEGER = unsafe { mem::zeroed() };
let success = unsafe { QueryPerformanceFrequency(&mut frequency) };
assert_ne!(success, 0);
Self::Dxgi {
frequency: unsafe { *frequency.QuadPart() } as u64,
}
}
/// Create a presentation timer using QueryInterruptTimePrecise (what IPresentationManager uses for presentation times)
///
/// Panics if QueryInterruptTimePrecise isn't found (below Win10)
pub fn new_ipresentation_manager() -> Self {
// We need to load this explicitly, as QueryInterruptTimePrecise is only available on Windows 10+
//
// Docs say it's in kernel32.dll, but it's actually in kernelbase.dll.
let kernelbase =
libloading::os::windows::Library::open_already_loaded("kernelbase.dll").unwrap();
// No concerns about lifetimes here as kernelbase is always there.
let ptr = unsafe { kernelbase.get(b"QueryInterruptTimePrecise").unwrap() };
Self::IPresentationManager {
fnQueryInterruptTimePrecise: *ptr,
}
}
/// Gets the current time in nanoseconds.
pub fn get_timestamp_ns(&self) -> u128 {
// Always do u128 math _after_ hitting the timing function.
match *self {
PresentationTimer::Dxgi { frequency } => {
let mut counter: LARGE_INTEGER = unsafe { mem::zeroed() };
let success = unsafe { QueryPerformanceCounter(&mut counter) };
assert_ne!(success, 0);
// counter * (1_000_000_000 / freq) but re-ordered to make more precise
(unsafe { *counter.QuadPart() } as u128 * 1_000_000_000) / frequency as u128
}
PresentationTimer::IPresentationManager {
fnQueryInterruptTimePrecise,
} => {
let mut counter = 0;
unsafe { fnQueryInterruptTimePrecise(&mut counter) };
// QueryInterruptTimePrecise uses units of 100ns for its tick.
counter as u128 * 100
}
}
}
}

Просмотреть файл

@ -24,10 +24,6 @@ impl crate::Adapter<super::Api> for super::Adapter {
) -> Option<crate::SurfaceCapabilities> {
todo!()
}
unsafe fn get_presentation_timestamp(&self) -> wgt::PresentationTimestamp {
todo!()
}
}
impl super::Adapter {
@ -114,8 +110,6 @@ impl super::Adapter {
downlevel |= wgt::DownlevelFlags::INDEPENDENT_BLEND;
// formally FL9_1 supports aniso 2, but we don't support that level of distinction
downlevel |= wgt::DownlevelFlags::ANISOTROPIC_FILTERING;
// this is actually the first FL that supports u32 at all
downlevel |= wgt::DownlevelFlags::FULL_DRAW_INDEX_UINT32;
}
if feature_level >= FL9_3 {
@ -126,7 +120,6 @@ impl super::Adapter {
downlevel |= wgt::DownlevelFlags::INDEPENDENT_BLEND;
downlevel |= wgt::DownlevelFlags::FRAGMENT_STORAGE;
downlevel |= wgt::DownlevelFlags::FRAGMENT_WRITABLE_STORAGE;
downlevel |= wgt::DownlevelFlags::DEPTH_BIAS_CLAMP;
features |= wgt::Features::DEPTH_CLIP_CONTROL;
features |= wgt::Features::TIMESTAMP_QUERY;
features |= wgt::Features::PIPELINE_STATISTICS_QUERY;

Просмотреть файл

@ -230,9 +230,6 @@ impl super::Adapter {
shader_model_support.HighestShaderModel >= d3d12::D3D_SHADER_MODEL_5_1,
);
// TODO: Determine if IPresentationManager is supported
let presentation_timer = auxil::dxgi::time::PresentationTimer::new_dxgi();
let base = wgt::Limits::default();
Some(crate::ExposedAdapter {
@ -241,7 +238,6 @@ impl super::Adapter {
device,
library: Arc::clone(library),
private_caps,
presentation_timer,
workarounds,
},
info,
@ -545,8 +541,4 @@ impl crate::Adapter<super::Api> for super::Adapter {
composite_alpha_modes: vec![wgt::CompositeAlphaMode::Opaque],
})
}
unsafe fn get_presentation_timestamp(&self) -> wgt::PresentationTimestamp {
wgt::PresentationTimestamp(self.presentation_timer.get_timestamp_ns())
}
}

112
third_party/rust/wgpu-hal/src/dx12/device.rs поставляемый
Просмотреть файл

@ -14,6 +14,8 @@ use winapi::{
// this has to match Naga's HLSL backend, and also needs to be null-terminated
const NAGA_LOCATION_SEMANTIC: &[u8] = b"LOC\0";
//TODO: find the exact value
const D3D12_HEAP_FLAG_CREATE_NOT_ZEROED: u32 = d3d12::D3D12_HEAP_FLAG_NONE;
impl super::Device {
pub(super) fn new(
@ -22,8 +24,6 @@ impl super::Device {
private_caps: super::PrivateCapabilities,
library: &Arc<native::D3D12Lib>,
) -> Result<Self, crate::DeviceError> {
let mem_allocator = super::suballocation::create_allocator_wrapper(&raw)?;
let mut idle_fence = native::Fence::null();
let hr = unsafe {
profiling::scope!("ID3D12Device::CreateFence");
@ -165,7 +165,6 @@ impl super::Device {
#[cfg(feature = "renderdoc")]
render_doc: Default::default(),
null_rtv_handle,
mem_allocator,
})
}
@ -313,13 +312,12 @@ impl super::Device {
size,
mip_level_count,
sample_count,
allocation: None,
}
}
}
impl crate::Device<super::Api> for super::Device {
unsafe fn exit(mut self, queue: super::Queue) {
unsafe fn exit(self, queue: super::Queue) {
self.rtv_pool.lock().free_handle(self.null_rtv_handle);
unsafe { self.rtv_pool.into_inner().destroy() };
unsafe { self.dsv_pool.into_inner().destroy() };
@ -327,7 +325,6 @@ impl crate::Device<super::Api> for super::Device {
unsafe { self.sampler_pool.into_inner().destroy() };
unsafe { self.shared.destroy() };
unsafe { self.idler.destroy() };
self.mem_allocator = None;
unsafe { queue.raw.destroy() };
}
@ -358,8 +355,43 @@ impl crate::Device<super::Api> for super::Device {
Flags: conv::map_buffer_usage_to_resource_flags(desc.usage),
};
let (hr, allocation) =
super::suballocation::create_buffer_resource(self, desc, raw_desc, &mut resource)?;
let is_cpu_read = desc.usage.contains(crate::BufferUses::MAP_READ);
let is_cpu_write = desc.usage.contains(crate::BufferUses::MAP_WRITE);
let heap_properties = d3d12::D3D12_HEAP_PROPERTIES {
Type: d3d12::D3D12_HEAP_TYPE_CUSTOM,
CPUPageProperty: if is_cpu_read {
d3d12::D3D12_CPU_PAGE_PROPERTY_WRITE_BACK
} else if is_cpu_write {
d3d12::D3D12_CPU_PAGE_PROPERTY_WRITE_COMBINE
} else {
d3d12::D3D12_CPU_PAGE_PROPERTY_NOT_AVAILABLE
},
MemoryPoolPreference: match self.private_caps.memory_architecture {
super::MemoryArchitecture::NonUnified if !is_cpu_read && !is_cpu_write => {
d3d12::D3D12_MEMORY_POOL_L1
}
_ => d3d12::D3D12_MEMORY_POOL_L0,
},
CreationNodeMask: 0,
VisibleNodeMask: 0,
};
let hr = unsafe {
self.raw.CreateCommittedResource(
&heap_properties,
if self.private_caps.heap_create_not_zeroed {
D3D12_HEAP_FLAG_CREATE_NOT_ZEROED
} else {
d3d12::D3D12_HEAP_FLAG_NONE
},
&raw_desc,
d3d12::D3D12_RESOURCE_STATE_COMMON,
ptr::null(),
&d3d12::ID3D12Resource::uuidof(),
resource.mut_void(),
)
};
hr.into_device_result("Buffer creation")?;
if let Some(label) = desc.label {
@ -367,48 +399,30 @@ impl crate::Device<super::Api> for super::Device {
unsafe { resource.SetName(cwstr.as_ptr()) };
}
Ok(super::Buffer {
resource,
size,
allocation,
})
Ok(super::Buffer { resource, size })
}
unsafe fn destroy_buffer(&self, mut buffer: super::Buffer) {
unsafe fn destroy_buffer(&self, buffer: super::Buffer) {
unsafe { buffer.resource.destroy() };
// Only happens when it's using the windows_rs feature and there's an allocation
if let Some(alloc) = buffer.allocation.take() {
super::suballocation::free_buffer_allocation(
alloc,
// SAFETY: for allocations to exist, the allocator must exist
unsafe { self.mem_allocator.as_ref().unwrap_unchecked() },
);
}
}
unsafe fn map_buffer(
&self,
buffer: &super::Buffer,
range: crate::MemoryRange,
) -> Result<crate::BufferMapping, crate::DeviceError> {
let mut ptr = ptr::null_mut();
// TODO: 0 for subresource should be fine here until map and unmap buffer is subresource aware?
let hr = unsafe { (*buffer.resource).Map(0, ptr::null(), &mut ptr) };
hr.into_device_result("Map buffer")?;
Ok(crate::BufferMapping {
ptr: ptr::NonNull::new(unsafe { ptr.offset(range.start as isize).cast::<u8>() })
.unwrap(),
ptr: ptr::NonNull::new(unsafe { ptr.offset(range.start as isize) } as *mut _).unwrap(),
//TODO: double-check this. Documentation is a bit misleading -
// it implies that Map/Unmap is needed to invalidate/flush memory.
is_coherent: true,
})
}
unsafe fn unmap_buffer(&self, buffer: &super::Buffer) -> Result<(), crate::DeviceError> {
unsafe { (*buffer.resource).Unmap(0, ptr::null()) };
Ok(())
}
unsafe fn flush_mapped_ranges<I>(&self, _buffer: &super::Buffer, _ranges: I) {}
unsafe fn invalidate_mapped_ranges<I>(&self, _buffer: &super::Buffer, _ranges: I) {}
@ -416,8 +430,6 @@ impl crate::Device<super::Api> for super::Device {
&self,
desc: &crate::TextureDescriptor,
) -> Result<super::Texture, crate::DeviceError> {
use super::suballocation::create_texture_resource;
let mut resource = native::Resource::null();
let raw_desc = d3d12::D3D12_RESOURCE_DESC {
@ -449,7 +461,32 @@ impl crate::Device<super::Api> for super::Device {
Flags: conv::map_texture_usage_to_resource_flags(desc.usage),
};
let (hr, allocation) = create_texture_resource(self, desc, raw_desc, &mut resource)?;
let heap_properties = d3d12::D3D12_HEAP_PROPERTIES {
Type: d3d12::D3D12_HEAP_TYPE_CUSTOM,
CPUPageProperty: d3d12::D3D12_CPU_PAGE_PROPERTY_NOT_AVAILABLE,
MemoryPoolPreference: match self.private_caps.memory_architecture {
super::MemoryArchitecture::NonUnified => d3d12::D3D12_MEMORY_POOL_L1,
super::MemoryArchitecture::Unified { .. } => d3d12::D3D12_MEMORY_POOL_L0,
},
CreationNodeMask: 0,
VisibleNodeMask: 0,
};
let hr = unsafe {
self.raw.CreateCommittedResource(
&heap_properties,
if self.private_caps.heap_create_not_zeroed {
D3D12_HEAP_FLAG_CREATE_NOT_ZEROED
} else {
d3d12::D3D12_HEAP_FLAG_NONE
},
&raw_desc,
d3d12::D3D12_RESOURCE_STATE_COMMON,
ptr::null(), // clear value
&d3d12::ID3D12Resource::uuidof(),
resource.mut_void(),
)
};
hr.into_device_result("Texture creation")?;
if let Some(label) = desc.label {
@ -464,19 +501,10 @@ impl crate::Device<super::Api> for super::Device {
size: desc.size,
mip_level_count: desc.mip_level_count,
sample_count: desc.sample_count,
allocation,
})
}
unsafe fn destroy_texture(&self, mut texture: super::Texture) {
unsafe fn destroy_texture(&self, texture: super::Texture) {
unsafe { texture.resource.destroy() };
if let Some(alloc) = texture.allocation.take() {
super::suballocation::free_texture_allocation(
alloc,
// SAFETY: for allocations to exist, the allocator must exist
unsafe { self.mem_allocator.as_ref().unwrap_unchecked() },
);
}
}
unsafe fn create_texture_view(

7
third_party/rust/wgpu-hal/src/dx12/mod.rs поставляемый
Просмотреть файл

@ -39,7 +39,6 @@ mod conv;
mod descriptor;
mod device;
mod instance;
mod suballocation;
mod view;
use crate::auxil::{self, dxgi::result::HResult as _};
@ -153,7 +152,6 @@ struct PrivateCapabilities {
#[allow(unused)]
heterogeneous_resource_heaps: bool,
memory_architecture: MemoryArchitecture,
#[allow(unused)] // TODO: Exists until windows-rs is standard, then it can probably be removed?
heap_create_not_zeroed: bool,
}
@ -169,7 +167,6 @@ pub struct Adapter {
device: native::Device,
library: Arc<native::D3D12Lib>,
private_caps: PrivateCapabilities,
presentation_timer: auxil::dxgi::time::PresentationTimer,
//Note: this isn't used right now, but we'll need it later.
#[allow(unused)]
workarounds: Workarounds,
@ -240,7 +237,6 @@ pub struct Device {
#[cfg(feature = "renderdoc")]
render_doc: crate::auxil::renderdoc::RenderDoc,
null_rtv_handle: descriptor::Handle,
mem_allocator: Option<Mutex<suballocation::GpuAllocatorWrapper>>,
}
unsafe impl Send for Device {}
@ -376,7 +372,6 @@ unsafe impl Sync for CommandBuffer {}
pub struct Buffer {
resource: native::Resource,
size: wgt::BufferAddress,
allocation: Option<suballocation::AllocationWrapper>,
}
unsafe impl Send for Buffer {}
@ -403,7 +398,6 @@ pub struct Texture {
size: wgt::Extent3d,
mip_level_count: u32,
sample_count: u32,
allocation: Option<suballocation::AllocationWrapper>,
}
unsafe impl Send for Texture {}
@ -770,7 +764,6 @@ impl crate::Surface<Api> for Surface {
size: sc.size,
mip_level_count: 1,
sample_count: 1,
allocation: None,
};
Ok(Some(crate::AcquiredSurfaceTexture {
texture,

Просмотреть файл

@ -1,331 +0,0 @@
pub(crate) use allocation::{
create_allocator_wrapper, create_buffer_resource, create_texture_resource,
free_buffer_allocation, free_texture_allocation, AllocationWrapper, GpuAllocatorWrapper,
};
// This exists to work around https://github.com/gfx-rs/wgpu/issues/3207
// Currently this will work the older, slower way if the windows_rs feature is disabled,
// and will use the fast path of suballocating buffers and textures using gpu_allocator if
// the windows_rs feature is enabled.
// This is the fast path using gpu_allocator to suballocate buffers and textures.
#[cfg(feature = "windows_rs")]
mod allocation {
use native::WeakPtr;
use parking_lot::Mutex;
use std::ptr;
use wgt::assertions::StrictAssertUnwrapExt;
use winapi::{
um::{
d3d12::{self, ID3D12Resource},
winnt::HRESULT,
},
Interface,
};
use gpu_allocator::{
d3d12::{AllocationCreateDesc, ToWinapi, ToWindows},
MemoryLocation,
};
#[derive(Debug)]
pub(crate) struct GpuAllocatorWrapper {
pub(crate) allocator: gpu_allocator::d3d12::Allocator,
}
#[derive(Debug)]
pub(crate) struct AllocationWrapper {
pub(crate) allocation: gpu_allocator::d3d12::Allocation,
}
pub(crate) fn create_allocator_wrapper(
raw: &native::Device,
) -> Result<Option<Mutex<GpuAllocatorWrapper>>, crate::DeviceError> {
let device = raw.as_ptr();
match gpu_allocator::d3d12::Allocator::new(&gpu_allocator::d3d12::AllocatorCreateDesc {
device: device.as_windows().clone(),
debug_settings: Default::default(),
}) {
Ok(allocator) => Ok(Some(Mutex::new(GpuAllocatorWrapper { allocator }))),
Err(e) => {
log::error!("Failed to create d3d12 allocator, error: {}", e);
Err(e)?
}
}
}
pub(crate) fn create_buffer_resource(
device: &crate::dx12::Device,
desc: &crate::BufferDescriptor,
raw_desc: d3d12::D3D12_RESOURCE_DESC,
resource: &mut WeakPtr<ID3D12Resource>,
) -> Result<(HRESULT, Option<AllocationWrapper>), crate::DeviceError> {
let is_cpu_read = desc.usage.contains(crate::BufferUses::MAP_READ);
let is_cpu_write = desc.usage.contains(crate::BufferUses::MAP_WRITE);
let location = match (is_cpu_read, is_cpu_write) {
(true, true) => MemoryLocation::CpuToGpu,
(true, false) => MemoryLocation::GpuToCpu,
(false, true) => MemoryLocation::CpuToGpu,
(false, false) => MemoryLocation::GpuOnly,
};
let name = desc.label.unwrap_or("Unlabeled buffer");
// SAFETY: allocator exists when the windows_rs feature is enabled
let mut allocator = unsafe {
device
.mem_allocator
.as_ref()
.strict_unwrap_unchecked()
.lock()
};
// let mut allocator = unsafe { device.mem_allocator.as_ref().unwrap_unchecked().lock() };
let allocation_desc = AllocationCreateDesc::from_winapi_d3d12_resource_desc(
allocator.allocator.device().as_winapi(),
&raw_desc,
name,
location,
);
let allocation = allocator.allocator.allocate(&allocation_desc)?;
let hr = unsafe {
device.raw.CreatePlacedResource(
allocation.heap().as_winapi() as *mut _,
allocation.offset(),
&raw_desc,
d3d12::D3D12_RESOURCE_STATE_COMMON,
ptr::null(),
&d3d12::ID3D12Resource::uuidof(),
resource.mut_void(),
)
};
Ok((hr, Some(AllocationWrapper { allocation })))
}
pub(crate) fn create_texture_resource(
device: &crate::dx12::Device,
desc: &crate::TextureDescriptor,
raw_desc: d3d12::D3D12_RESOURCE_DESC,
resource: &mut WeakPtr<ID3D12Resource>,
) -> Result<(HRESULT, Option<AllocationWrapper>), crate::DeviceError> {
let location = MemoryLocation::GpuOnly;
let name = desc.label.unwrap_or("Unlabeled texture");
// SAFETY: allocator exists when the windows_rs feature is enabled
let mut allocator = unsafe {
device
.mem_allocator
.as_ref()
.strict_unwrap_unchecked()
.lock()
};
let allocation_desc = AllocationCreateDesc::from_winapi_d3d12_resource_desc(
allocator.allocator.device().as_winapi(),
&raw_desc,
name,
location,
);
let allocation = allocator.allocator.allocate(&allocation_desc)?;
let hr = unsafe {
device.raw.CreatePlacedResource(
allocation.heap().as_winapi() as *mut _,
allocation.offset(),
&raw_desc,
d3d12::D3D12_RESOURCE_STATE_COMMON,
ptr::null(), // clear value
&d3d12::ID3D12Resource::uuidof(),
resource.mut_void(),
)
};
Ok((hr, Some(AllocationWrapper { allocation })))
}
pub(crate) fn free_buffer_allocation(
allocation: AllocationWrapper,
allocator: &Mutex<GpuAllocatorWrapper>,
) {
match allocator.lock().allocator.free(allocation.allocation) {
Ok(_) => (),
// TODO: Don't panic here
Err(e) => panic!("Failed to destroy dx12 buffer, {}", e),
};
}
pub(crate) fn free_texture_allocation(
allocation: AllocationWrapper,
allocator: &Mutex<GpuAllocatorWrapper>,
) {
match allocator.lock().allocator.free(allocation.allocation) {
Ok(_) => (),
// TODO: Don't panic here
Err(e) => panic!("Failed to destroy dx12 texture, {}", e),
};
}
#[cfg(feature = "windows_rs")]
impl From<gpu_allocator::AllocationError> for crate::DeviceError {
fn from(result: gpu_allocator::AllocationError) -> Self {
match result {
gpu_allocator::AllocationError::OutOfMemory => Self::OutOfMemory,
gpu_allocator::AllocationError::FailedToMap(e) => {
log::error!("DX12 gpu-allocator: Failed to map: {}", e);
Self::Lost
}
gpu_allocator::AllocationError::NoCompatibleMemoryTypeFound => {
log::error!("DX12 gpu-allocator: No Compatible Memory Type Found");
Self::Lost
}
gpu_allocator::AllocationError::InvalidAllocationCreateDesc => {
log::error!("DX12 gpu-allocator: Invalid Allocation Creation Description");
Self::Lost
}
gpu_allocator::AllocationError::InvalidAllocatorCreateDesc(e) => {
log::error!(
"DX12 gpu-allocator: Invalid Allocator Creation Description: {}",
e
);
Self::Lost
}
gpu_allocator::AllocationError::Internal(e) => {
log::error!("DX12 gpu-allocator: Internal Error: {}", e);
Self::Lost
}
}
}
}
}
// This is the older, slower path where it doesn't suballocate buffers.
// Tracking issue for when it can be removed: https://github.com/gfx-rs/wgpu/issues/3207
#[cfg(not(feature = "windows_rs"))]
mod allocation {
use native::WeakPtr;
use parking_lot::Mutex;
use std::ptr;
use winapi::{
um::{
d3d12::{self, ID3D12Resource},
winnt::HRESULT,
},
Interface,
};
const D3D12_HEAP_FLAG_CREATE_NOT_ZEROED: u32 = d3d12::D3D12_HEAP_FLAG_NONE; // TODO: find the exact value
// Allocator isn't needed when not suballocating with gpu_allocator
#[derive(Debug)]
pub(crate) struct GpuAllocatorWrapper {}
// Allocations aren't needed when not suballocating with gpu_allocator
#[derive(Debug)]
pub(crate) struct AllocationWrapper {}
pub(crate) fn create_allocator_wrapper(
_raw: &native::Device,
) -> Result<Option<Mutex<GpuAllocatorWrapper>>, crate::DeviceError> {
Ok(None)
}
pub(crate) fn create_buffer_resource(
device: &crate::dx12::Device,
desc: &crate::BufferDescriptor,
raw_desc: d3d12::D3D12_RESOURCE_DESC,
resource: &mut WeakPtr<ID3D12Resource>,
) -> Result<(HRESULT, Option<AllocationWrapper>), crate::DeviceError> {
let is_cpu_read = desc.usage.contains(crate::BufferUses::MAP_READ);
let is_cpu_write = desc.usage.contains(crate::BufferUses::MAP_WRITE);
let heap_properties = d3d12::D3D12_HEAP_PROPERTIES {
Type: d3d12::D3D12_HEAP_TYPE_CUSTOM,
CPUPageProperty: if is_cpu_read {
d3d12::D3D12_CPU_PAGE_PROPERTY_WRITE_BACK
} else if is_cpu_write {
d3d12::D3D12_CPU_PAGE_PROPERTY_WRITE_COMBINE
} else {
d3d12::D3D12_CPU_PAGE_PROPERTY_NOT_AVAILABLE
},
MemoryPoolPreference: match device.private_caps.memory_architecture {
crate::dx12::MemoryArchitecture::NonUnified if !is_cpu_read && !is_cpu_write => {
d3d12::D3D12_MEMORY_POOL_L1
}
_ => d3d12::D3D12_MEMORY_POOL_L0,
},
CreationNodeMask: 0,
VisibleNodeMask: 0,
};
let hr = unsafe {
device.raw.CreateCommittedResource(
&heap_properties,
if device.private_caps.heap_create_not_zeroed {
D3D12_HEAP_FLAG_CREATE_NOT_ZEROED
} else {
d3d12::D3D12_HEAP_FLAG_NONE
},
&raw_desc,
d3d12::D3D12_RESOURCE_STATE_COMMON,
ptr::null(),
&d3d12::ID3D12Resource::uuidof(),
resource.mut_void(),
)
};
Ok((hr, None))
}
pub(crate) fn create_texture_resource(
device: &crate::dx12::Device,
_desc: &crate::TextureDescriptor,
raw_desc: d3d12::D3D12_RESOURCE_DESC,
resource: &mut WeakPtr<ID3D12Resource>,
) -> Result<(HRESULT, Option<AllocationWrapper>), crate::DeviceError> {
let heap_properties = d3d12::D3D12_HEAP_PROPERTIES {
Type: d3d12::D3D12_HEAP_TYPE_CUSTOM,
CPUPageProperty: d3d12::D3D12_CPU_PAGE_PROPERTY_NOT_AVAILABLE,
MemoryPoolPreference: match device.private_caps.memory_architecture {
crate::dx12::MemoryArchitecture::NonUnified => d3d12::D3D12_MEMORY_POOL_L1,
crate::dx12::MemoryArchitecture::Unified { .. } => d3d12::D3D12_MEMORY_POOL_L0,
},
CreationNodeMask: 0,
VisibleNodeMask: 0,
};
let hr = unsafe {
device.raw.CreateCommittedResource(
&heap_properties,
if device.private_caps.heap_create_not_zeroed {
D3D12_HEAP_FLAG_CREATE_NOT_ZEROED
} else {
d3d12::D3D12_HEAP_FLAG_NONE
},
&raw_desc,
d3d12::D3D12_RESOURCE_STATE_COMMON,
ptr::null(), // clear value
&d3d12::ID3D12Resource::uuidof(),
resource.mut_void(),
)
};
Ok((hr, None))
}
pub(crate) fn free_buffer_allocation(
_allocation: AllocationWrapper,
_allocator: &Mutex<GpuAllocatorWrapper>,
) {
// No-op when not using gpu-allocator
}
pub(crate) fn free_texture_allocation(
_allocation: AllocationWrapper,
_allocator: &Mutex<GpuAllocatorWrapper>,
) {
// No-op when not using gpu-allocator
}
}

4
third_party/rust/wgpu-hal/src/empty.rs поставляемый
Просмотреть файл

@ -93,10 +93,6 @@ impl crate::Adapter<Api> for Context {
unsafe fn surface_capabilities(&self, surface: &Context) -> Option<crate::SurfaceCapabilities> {
None
}
unsafe fn get_presentation_timestamp(&self) -> wgt::PresentationTimestamp {
wgt::PresentationTimestamp::INVALID_TIMESTAMP
}
}
impl crate::Queue<Api> for Context {

13
third_party/rust/wgpu-hal/src/gles/adapter.rs поставляемый
Просмотреть файл

@ -255,7 +255,6 @@ impl super::Adapter {
} else {
0
};
let max_element_index = unsafe { gl.get_parameter_i32(glow::MAX_ELEMENT_INDEX) } as u32;
// WORKAROUND: In order to work around an issue with GL on RPI4 and similar, we ignore a
// zero vertex ssbo count if there are vertex sstos. (more info:
@ -317,10 +316,6 @@ impl super::Adapter {
wgt::DownlevelFlags::UNRESTRICTED_INDEX_BUFFER,
!cfg!(target_arch = "wasm32"),
);
downlevel_flags.set(
wgt::DownlevelFlags::FULL_DRAW_INDEX_UINT32,
max_element_index == u32::MAX,
);
let mut features = wgt::Features::empty()
| wgt::Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES
@ -786,8 +781,8 @@ impl crate::Adapter<super::Api> for super::Adapter {
Tf::Rgba32Uint => renderable | storage,
Tf::Rgba32Sint => renderable | storage,
Tf::Rgba32Float => unfilterable | storage | float_renderable | texture_float_linear,
Tf::Stencil8
| Tf::Depth16Unorm
//Tf::Stencil8 |
Tf::Depth16Unorm
| Tf::Depth32Float
| Tf::Depth32FloatStencil8
| Tf::Depth24Plus
@ -874,10 +869,6 @@ impl crate::Adapter<super::Api> for super::Adapter {
None
}
}
unsafe fn get_presentation_timestamp(&self) -> wgt::PresentationTimestamp {
wgt::PresentationTimestamp::INVALID_TIMESTAMP
}
}
impl super::AdapterShared {

6
third_party/rust/wgpu-hal/src/gles/conv.rs поставляемый
Просмотреть файл

@ -56,11 +56,7 @@ impl super::AdapterShared {
Tf::Rgba32Uint => (glow::RGBA32UI, glow::RGBA_INTEGER, glow::UNSIGNED_INT),
Tf::Rgba32Sint => (glow::RGBA32I, glow::RGBA_INTEGER, glow::INT),
Tf::Rgba32Float => (glow::RGBA32F, glow::RGBA, glow::FLOAT),
Tf::Stencil8 => (
glow::STENCIL_INDEX8,
glow::STENCIL_COMPONENTS,
glow::UNSIGNED_BYTE,
),
//Tf::Stencil8 => (glow::R8UI, glow::STENCIL_COMPONENTS, glow::UNSIGNED_BYTE),
Tf::Depth16Unorm => (
glow::DEPTH_COMPONENT16,
glow::DEPTH_COMPONENT,

7
third_party/rust/wgpu-hal/src/lib.rs поставляемый
Просмотреть файл

@ -242,11 +242,6 @@ pub trait Adapter<A: Api>: Send + Sync {
///
/// `None` means presentation is not supported for it.
unsafe fn surface_capabilities(&self, surface: &A::Surface) -> Option<SurfaceCapabilities>;
/// Creates a [`PresentationTimestamp`] using the adapter's WSI.
///
/// [`PresentationTimestamp`]: wgt::PresentationTimestamp
unsafe fn get_presentation_timestamp(&self) -> wgt::PresentationTimestamp;
}
pub trait Device<A: Api>: Send + Sync {
@ -636,7 +631,7 @@ impl From<wgt::TextureAspect> for FormatAspects {
impl From<wgt::TextureFormat> for FormatAspects {
fn from(format: wgt::TextureFormat) -> Self {
match format {
wgt::TextureFormat::Stencil8 => Self::STENCIL,
//wgt::TextureFormat::Stencil8 => Self::STENCIL,
wgt::TextureFormat::Depth16Unorm => Self::DEPTH,
wgt::TextureFormat::Depth32Float | wgt::TextureFormat::Depth24Plus => Self::DEPTH,
wgt::TextureFormat::Depth32FloatStencil8 | wgt::TextureFormat::Depth24PlusStencil8 => {

Просмотреть файл

@ -166,9 +166,13 @@ impl crate::Adapter<super::Api> for super::Adapter {
};
flags
}
Tf::Stencil8 => {
all_caps | Tfc::DEPTH_STENCIL_ATTACHMENT | msaa_count | msaa_resolve_apple3x_if
}
/*Tf::Stencil8 => {
let mut flags = all_caps
| Tfc::DEPTH_STENCIL_ATTACHMENT
| Tfc::MULTISAMPLE
| msaa_resolve_apple3x_if;
flags
}*/
Tf::Depth16Unorm => {
let mut flags =
Tfc::DEPTH_STENCIL_ATTACHMENT | msaa_count | msaa_resolve_apple3x_if;
@ -315,12 +319,6 @@ impl crate::Adapter<super::Api> for super::Adapter {
usage: crate::TextureUses::COLOR_TARGET | crate::TextureUses::COPY_DST, //TODO: expose more
})
}
unsafe fn get_presentation_timestamp(&self) -> wgt::PresentationTimestamp {
let timestamp = self.shared.presentation_timer.get_timestamp_ns();
wgt::PresentationTimestamp(timestamp)
}
}
const RESOURCE_HEAP_SUPPORT: &[MTLFeatureSet] = &[
@ -905,7 +903,7 @@ impl super::PrivateCapabilities {
Tf::Rgba32Uint => RGBA32Uint,
Tf::Rgba32Sint => RGBA32Sint,
Tf::Rgba32Float => RGBA32Float,
Tf::Stencil8 => Stencil8,
//Tf::Stencil8 => R8Unorm,
Tf::Depth16Unorm => Depth16Unorm,
Tf::Depth32Float => Depth32Float,
Tf::Depth32FloatStencil8 => Depth32Float_Stencil8,

13
third_party/rust/wgpu-hal/src/metal/device.rs поставляемый
Просмотреть файл

@ -358,13 +358,12 @@ impl crate::Device<super::Api> for super::Device {
conv::map_texture_view_dimension(desc.dimension)
};
let format_equal = raw_format == texture.raw_format;
let type_equal = raw_type == texture.raw_type;
let range_full_resource = desc
.range
.is_full_resource(texture.mip_levels, texture.array_layers);
let raw = if format_equal && type_equal && range_full_resource {
//Note: this doesn't check properly if the mipmap level count or array layer count
// is explicitly set to 1.
let raw = if raw_format == texture.raw_format
&& raw_type == texture.raw_type
&& desc.range == wgt::ImageSubresourceRange::default()
{
// Some images are marked as framebuffer-only, and we can't create aliases of them.
// Also helps working around Metal bugs with aliased array textures.
texture.raw.to_owned()

3
third_party/rust/wgpu-hal/src/metal/mod.rs поставляемый
Просмотреть файл

@ -18,7 +18,6 @@ mod command;
mod conv;
mod device;
mod surface;
mod time;
use std::{
fmt, iter, ops,
@ -254,7 +253,6 @@ struct AdapterShared {
disabilities: PrivateDisabilities,
private_caps: PrivateCapabilities,
settings: Settings,
presentation_timer: time::PresentationTimer,
}
unsafe impl Send for AdapterShared {}
@ -270,7 +268,6 @@ impl AdapterShared {
private_caps,
device: Mutex::new(device),
settings: Settings::default(),
presentation_timer: time::PresentationTimer::new(),
}
}
}

38
third_party/rust/wgpu-hal/src/metal/time.rs поставляемый
Просмотреть файл

@ -1,38 +0,0 @@
//! Handling of global timestamps.
#[repr(C)]
#[derive(Debug)]
struct MachTimebaseInfo {
numerator: u32,
denominator: u32,
}
extern "C" {
fn mach_timebase_info(out: *mut MachTimebaseInfo) -> u32;
fn mach_absolute_time() -> u64;
}
/// A timer which uses mach_absolute_time to get its time. This is what the metal callbacks use.
#[derive(Debug)]
pub struct PresentationTimer {
scale: MachTimebaseInfo,
}
impl PresentationTimer {
/// Generates a new timer.
pub fn new() -> Self {
// Default to 1 / 1 in case the call to timebase_info fails.
let mut scale = MachTimebaseInfo {
numerator: 1,
denominator: 1,
};
unsafe { mach_timebase_info(&mut scale) };
Self { scale }
}
/// Gets the current time in nanoseconds.
pub fn get_timestamp_ns(&self) -> u128 {
let time = unsafe { mach_absolute_time() };
(time as u128 * self.scale.numerator as u128) / self.scale.denominator as u128
}
}

Просмотреть файл

@ -316,19 +316,7 @@ impl PhysicalDeviceFeatures {
| F::WRITE_TIMESTAMP_INSIDE_PASSES
| F::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES
| F::CLEAR_TEXTURE;
let mut dl_flags = Df::COMPUTE_SHADERS
| Df::BASE_VERTEX
| Df::READ_ONLY_DEPTH_STENCIL
| Df::NON_POWER_OF_TWO_MIPMAPPED_TEXTURES
| Df::COMPARISON_SAMPLERS
| Df::VERTEX_STORAGE
| Df::FRAGMENT_STORAGE
| Df::DEPTH_TEXTURE_AND_BUFFER_COPIES
| Df::WEBGPU_TEXTURE_FORMAT_SUPPORT
| Df::BUFFER_BINDINGS_NOT_16_BYTE_ALIGNED
| Df::UNRESTRICTED_INDEX_BUFFER
| Df::INDIRECT_EXECUTION;
let mut dl_flags = Df::all();
dl_flags.set(Df::CUBE_ARRAY_TEXTURES, self.core.image_cube_array != 0);
dl_flags.set(Df::ANISOTROPIC_FILTERING, self.core.sampler_anisotropy != 0);
@ -338,11 +326,6 @@ impl PhysicalDeviceFeatures {
);
dl_flags.set(Df::MULTISAMPLED_SHADING, self.core.sample_rate_shading != 0);
dl_flags.set(Df::INDEPENDENT_BLEND, self.core.independent_blend != 0);
dl_flags.set(
Df::FULL_DRAW_INDEX_UINT32,
self.core.full_draw_index_uint32 != 0,
);
dl_flags.set(Df::DEPTH_BIAS_CLAMP, self.core.depth_bias_clamp != 0);
features.set(
F::INDIRECT_FIRST_INSTANCE,
@ -1016,13 +999,6 @@ impl super::Instance {
.optimal_tiling_features
.contains(vk::FormatFeatureFlags::DEPTH_STENCIL_ATTACHMENT)
},
texture_s8: unsafe {
self.shared
.raw
.get_physical_device_format_properties(phd, vk::Format::S8_UINT)
.optimal_tiling_features
.contains(vk::FormatFeatureFlags::DEPTH_STENCIL_ATTACHMENT)
},
non_coherent_map_mask: phd_capabilities.properties.limits.non_coherent_atom_size - 1,
can_present: true,
//TODO: make configurable
@ -1606,31 +1582,6 @@ impl crate::Adapter<super::Api> for super::Adapter {
composite_alpha_modes: conv::map_vk_composite_alpha(caps.supported_composite_alpha),
})
}
unsafe fn get_presentation_timestamp(&self) -> wgt::PresentationTimestamp {
// VK_GOOGLE_display_timing is the only way to get presentation
// timestamps on vulkan right now and it is only ever available
// on android and linux. This includes mac, but there's no alternative
// on mac, so this is fine.
#[cfg(unix)]
{
let mut timespec = libc::timespec {
tv_sec: 0,
tv_nsec: 0,
};
unsafe {
libc::clock_gettime(libc::CLOCK_MONOTONIC, &mut timespec);
}
wgt::PresentationTimestamp(
timespec.tv_sec as u128 * 1_000_000_000 + timespec.tv_nsec as u128,
)
}
#[cfg(not(unix))]
{
wgt::PresentationTimestamp::INVALID_TIMESTAMP
}
}
}
fn is_format_16bit_norm_supported(instance: &ash::Instance, phd: vk::PhysicalDevice) -> bool {

10
third_party/rust/wgpu-hal/src/vulkan/conv.rs поставляемый
Просмотреть файл

@ -64,15 +64,7 @@ impl super::PrivateCapabilities {
F::D32_SFLOAT_S8_UINT
}
}
Tf::Stencil8 => {
if self.texture_s8 {
F::S8_UINT
} else if self.texture_d24_s8 {
F::D24_UNORM_S8_UINT
} else {
F::D32_SFLOAT_S8_UINT
}
}
//Tf::Stencil8 => F::R8_UNORM,
Tf::Depth16Unorm => F::D16_UNORM,
Tf::Rgb9e5Ufloat => F::E5B9G9R9_UFLOAT_PACK32,
Tf::Bc1RgbaUnorm => F::BC1_RGBA_UNORM_BLOCK,

1
third_party/rust/wgpu-hal/src/vulkan/mod.rs поставляемый
Просмотреть файл

@ -160,7 +160,6 @@ struct PrivateCapabilities {
timeline_semaphores: bool,
texture_d24: bool,
texture_d24_s8: bool,
texture_s8: bool,
/// Ability to present contents to any screen. Only needed to work around broken platform configurations.
can_present: bool,
non_coherent_map_mask: wgt::BufferAddress,

Просмотреть файл

@ -1 +1 @@
{"files":{"Cargo.toml":"578dd177eb3fbce10c928d2800e3b433c36e092ff57305c916bdeb17602b8990","LICENSE.APACHE":"a6cba85bc92e0cff7a450b1d873c0eaa2e9fc96bf472df0247a26bec77bf3ff9","LICENSE.MIT":"c7fea58d1cfe49634cd92e54fc10a9d871f4b275321a4cd8c09e449122caaeb4","src/assertions.rs":"3fe98027aa73970c8ab7874a3e13dbfd6faa87df2081beb5c83aeec4c60f372f","src/lib.rs":"49b663315b42255315e393c7406de643525d9562219715634630db9b811c77c9"},"package":null}
{"files":{"Cargo.toml":"dcb6c697269807beb7604853e274915fba4a6a3192a23b18671df516a0cf2f43","LICENSE.APACHE":"a6cba85bc92e0cff7a450b1d873c0eaa2e9fc96bf472df0247a26bec77bf3ff9","LICENSE.MIT":"c7fea58d1cfe49634cd92e54fc10a9d871f4b275321a4cd8c09e449122caaeb4","src/lib.rs":"189d09f6ad5c46d0a92a042e1b7055517e6c1ef0a803d8ddffebdd3e14c21d1c"},"package":null}

2
third_party/rust/wgpu-types/Cargo.toml поставляемый
Просмотреть файл

@ -18,12 +18,10 @@ rustdoc-args = ["--cfg", "docsrs"]
[features]
trace = ["serde"]
replay = ["serde"]
strict_asserts = []
[dependencies]
bitflags = "1"
serde = { version = "1", features = ["serde_derive"], optional = true }
[dev-dependencies]
serde = { version = "1", features = ["serde_derive"] }
serde_json = "1.0.85"

92
third_party/rust/wgpu-types/src/assertions.rs поставляемый
Просмотреть файл

@ -1,92 +0,0 @@
//! Macros for validation internal to the wgpu.
//!
//! This module defines assertion macros that respect `wgpu-type`'s
//! `"strict_asserts"` feature.
//!
//! Because `wgpu-core`'s public APIs validate their arguments in all
//! types of builds, for performance, the `track` module skips some of
//! Rust's usual run-time checks on its internal operations in release
//! builds. However, some `wgpu-core` applications have a strong
//! preference for robustness over performance. To accommodate them,
//! `wgpu-core`'s `"strict_asserts"` feature enables that validation
//! in both debug and release builds.
/// This is equivalent to [`std::assert`] if the `strict_asserts` feature is activated, otherwise equal to [`std::debug_assert`].
#[cfg(feature = "strict_asserts")]
#[macro_export]
macro_rules! strict_assert {
( $( $arg:tt )* ) => {
assert!( $( $arg )* )
}
}
/// This is equivalent to [`std::assert_eq`] if the `strict_asserts` feature is activated, otherwise equal to [`std::debug_assert_eq`].
#[cfg(feature = "strict_asserts")]
#[macro_export]
macro_rules! strict_assert_eq {
( $( $arg:tt )* ) => {
assert_eq!( $( $arg )* )
}
}
/// This is equivalent to [`std::assert_ne`] if the `strict_asserts` feature is activated, otherwise equal to [`std::debug_assert_ne`].
#[cfg(feature = "strict_asserts")]
#[macro_export]
macro_rules! strict_assert_ne {
( $( $arg:tt )* ) => {
assert_ne!( $( $arg )* )
}
}
/// This is equivalent to [`std::assert`] if the `strict_asserts` feature is activated, otherwise equal to [`std::debug_assert`]
#[cfg(not(feature = "strict_asserts"))]
#[macro_export]
macro_rules! strict_assert {
( $( $arg:tt )* ) => {
debug_assert!( $( $arg )* )
};
}
/// This is equivalent to [`std::assert_eq`] if the `strict_asserts` feature is activated, otherwise equal to [`std::debug_assert_eq`]
#[cfg(not(feature = "strict_asserts"))]
#[macro_export]
macro_rules! strict_assert_eq {
( $( $arg:tt )* ) => {
debug_assert_eq!( $( $arg )* )
};
}
/// This is equivalent to [`std::assert_ne`] if the `strict_asserts` feature is activated, otherwise equal to [`std::debug_assert_ne`]
#[cfg(not(feature = "strict_asserts"))]
#[macro_export]
macro_rules! strict_assert_ne {
( $( $arg:tt )* ) => {
debug_assert_ne!( $( $arg )* )
};
}
/// Unwrapping using strict_asserts
pub trait StrictAssertUnwrapExt<T> {
/// Unchecked unwrap, with a [`strict_assert`] backed assertion of validitly.
///
/// # Safety
///
/// It _must_ be valid to call unwrap_unchecked on this value.
unsafe fn strict_unwrap_unchecked(self) -> T;
}
impl<T> StrictAssertUnwrapExt<T> for Option<T> {
unsafe fn strict_unwrap_unchecked(self) -> T {
strict_assert!(self.is_some(), "Called strict_unwrap_unchecked on None");
// SAFETY: Checked by above assert, or by assertion by unsafe.
unsafe { self.unwrap_unchecked() }
}
}
impl<T, E> StrictAssertUnwrapExt<T> for Result<T, E> {
unsafe fn strict_unwrap_unchecked(self) -> T {
strict_assert!(self.is_ok(), "Called strict_unwrap_unchecked on Err");
// SAFETY: Checked by above assert, or by assertion by unsafe.
unsafe { self.unwrap_unchecked() }
}
}

131
third_party/rust/wgpu-types/src/lib.rs поставляемый
Просмотреть файл

@ -9,13 +9,11 @@
)]
#![warn(missing_docs, unsafe_op_in_unsafe_fn)]
#[cfg(any(feature = "serde", test))]
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
use std::hash::{Hash, Hasher};
use std::{num::NonZeroU32, ops::Range};
pub mod assertions;
// Use this macro instead of the one provided by the bitflags_serde_shim crate
// because the latter produces an error when deserializing bits that are not
// specified in the bitflags, while we want deserialization to succeed and
@ -1129,16 +1127,6 @@ bitflags::bitflags! {
///
/// WebGL doesn't support this.
const UNRESTRICTED_INDEX_BUFFER = 1 << 16;
/// Supports full 32-bit range indices (2^32-1 as opposed to 2^24-1 without this flag)
///
/// Corresponds to Vulkan's `VkPhysicalDeviceFeatures.fullDrawIndexUint32`
const FULL_DRAW_INDEX_UINT32 = 1 << 17;
/// Supports depth bias clamping
///
/// Corresponds to Vulkan's `VkPhysicalDeviceFeatures.depthBiasClamp`
const DEPTH_BIAS_CLAMP = 1 << 18;
}
}
@ -1929,7 +1917,7 @@ pub enum TextureFormat {
// Depth and stencil formats
/// Stencil format with 8 bit integer stencil.
Stencil8,
//Stencil8,
/// Special depth format with 16 bit integer depth.
Depth16Unorm,
/// Special depth format with at least 24 bit integer depth.
@ -2103,7 +2091,7 @@ pub enum TextureFormat {
},
}
#[cfg(any(feature = "serde", test))]
#[cfg(feature = "serde")]
impl<'de> Deserialize<'de> for TextureFormat {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
@ -2163,7 +2151,6 @@ impl<'de> Deserialize<'de> for TextureFormat {
"rgba32uint" => TextureFormat::Rgba32Uint,
"rgba32sint" => TextureFormat::Rgba32Sint,
"rgba32float" => TextureFormat::Rgba32Float,
"stencil8" => TextureFormat::Stencil8,
"depth32float" => TextureFormat::Depth32Float,
"depth32float-stencil8" => TextureFormat::Depth32FloatStencil8,
"depth16unorm" => TextureFormat::Depth16Unorm,
@ -2240,7 +2227,7 @@ impl<'de> Deserialize<'de> for TextureFormat {
}
}
#[cfg(any(feature = "serde", test))]
#[cfg(feature = "serde")]
impl Serialize for TextureFormat {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
@ -2289,7 +2276,6 @@ impl Serialize for TextureFormat {
TextureFormat::Rgba32Uint => "rgba32uint",
TextureFormat::Rgba32Sint => "rgba32sint",
TextureFormat::Rgba32Float => "rgba32float",
TextureFormat::Stencil8 => "stencil8",
TextureFormat::Depth32Float => "depth32float",
TextureFormat::Depth16Unorm => "depth16unorm",
TextureFormat::Depth32FloatStencil8 => "depth32float-stencil8",
@ -2405,7 +2391,7 @@ impl TextureFormat {
) = match self {
// Normal 8 bit textures
Self::R8Unorm => ( native, float, linear, msaa_resolve, (1, 1), 1, attachment, 1),
Self::R8Snorm => ( native, float, linear, noaa, (1, 1), 1, basic, 1),
Self::R8Snorm => ( native, float, linear, msaa, (1, 1), 1, basic, 1),
Self::R8Uint => ( native, uint, linear, msaa, (1, 1), 1, attachment, 1),
Self::R8Sint => ( native, sint, linear, msaa, (1, 1), 1, attachment, 1),
// Normal 16 bit textures
@ -2413,9 +2399,9 @@ impl TextureFormat {
Self::R16Sint => ( native, sint, linear, msaa, (1, 1), 2, attachment, 1),
Self::R16Float => ( native, float, linear, msaa_resolve, (1, 1), 2, attachment, 1),
Self::Rg8Unorm => ( native, float, linear, msaa_resolve, (1, 1), 2, attachment, 2),
Self::Rg8Snorm => ( native, float, linear, noaa, (1, 1), 2, basic, 2),
Self::Rg8Snorm => ( native, float, linear, msaa, (1, 1), 2, attachment, 2),
Self::Rg8Uint => ( native, uint, linear, msaa, (1, 1), 2, attachment, 2),
Self::Rg8Sint => ( native, sint, linear, msaa, (1, 1), 2, attachment, 2),
Self::Rg8Sint => ( native, sint, linear, msaa, (1, 1), 2, basic, 2),
// Normal 32 bit textures
Self::R32Uint => ( native, uint, linear, noaa, (1, 1), 4, all_flags, 1),
Self::R32Sint => ( native, sint, linear, noaa, (1, 1), 4, all_flags, 1),
@ -2425,7 +2411,7 @@ impl TextureFormat {
Self::Rg16Float => ( native, float, linear, msaa_resolve, (1, 1), 4, attachment, 2),
Self::Rgba8Unorm => ( native, float, linear, msaa_resolve, (1, 1), 4, all_flags, 4),
Self::Rgba8UnormSrgb => ( native, float, corrected, msaa_resolve, (1, 1), 4, attachment, 4),
Self::Rgba8Snorm => ( native, float, linear, noaa, (1, 1), 4, storage, 4),
Self::Rgba8Snorm => ( native, float, linear, msaa, (1, 1), 4, storage, 4),
Self::Rgba8Uint => ( native, uint, linear, msaa, (1, 1), 4, all_flags, 4),
Self::Rgba8Sint => ( native, sint, linear, msaa, (1, 1), 4, all_flags, 4),
Self::Bgra8Unorm => ( native, float, linear, msaa_resolve, (1, 1), 4, attachment, 4),
@ -2445,7 +2431,6 @@ impl TextureFormat {
Self::Rgba32Sint => ( native, sint, linear, noaa, (1, 1), 16, all_flags, 4),
Self::Rgba32Float => ( native, nearest, linear, noaa, (1, 1), 16, all_flags, 4),
// Depth-stencil textures
Self::Stencil8 => ( native, depth, linear, msaa, (1, 1), 2, attachment, 1),
Self::Depth16Unorm => ( native, depth, linear, msaa, (1, 1), 2, attachment, 1),
Self::Depth24Plus => ( native, depth, linear, msaa, (1, 1), 4, attachment, 1),
Self::Depth24PlusStencil8 => ( native, depth, linear, msaa, (1, 1), 4, attachment, 2),
@ -2705,10 +2690,6 @@ fn texture_format_serialize() {
serde_json::to_string(&TextureFormat::Rgba32Float).unwrap(),
"\"rgba32float\"".to_string()
);
assert_eq!(
serde_json::to_string(&TextureFormat::Stencil8).unwrap(),
"\"stencil8\"".to_string()
);
assert_eq!(
serde_json::to_string(&TextureFormat::Depth32Float).unwrap(),
"\"depth32float\"".to_string()
@ -2997,10 +2978,6 @@ fn texture_format_deserialize() {
serde_json::from_str::<TextureFormat>("\"rgba32float\"").unwrap(),
TextureFormat::Rgba32Float
);
assert_eq!(
serde_json::from_str::<TextureFormat>("\"stencil8\"").unwrap(),
TextureFormat::Stencil8
);
assert_eq!(
serde_json::from_str::<TextureFormat>("\"depth32float\"").unwrap(),
TextureFormat::Depth32Float
@ -3976,43 +3953,6 @@ pub enum SurfaceStatus {
Lost,
}
/// Nanosecond timestamp used by the presentation engine.
///
/// The specific clock depends on the window system integration (WSI) API used.
///
/// <table>
/// <tr>
/// <td>WSI
/// <td>Clock
/// <tr>
/// <td>IDXGISwapchain
/// <td><a href="https://docs.microsoft.com/en-us/windows/win32/api/profileapi/nf-profileapi-queryperformancecounter">QueryPerformanceCounter</a>
/// <tr>
/// <td>IPresentationManager
/// <td><a href="https://docs.microsoft.com/en-us/windows/win32/api/realtimeapiset/nf-realtimeapiset-queryinterrupttimeprecise">QueryInterruptTimePrecise</a>
/// <tr>
/// <td>CAMetalLayer
/// <td><a href="https://developer.apple.com/documentation/kernel/1462446-mach_absolute_time">mach_absolute_time</a>
/// <tr>
/// <td>VK_GOOGLE_display_timing
/// <td><a href="https://linux.die.net/man/3/clock_gettime">clock_gettime(CLOCK_MONOTONIC)</a>
/// </table>
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
pub struct PresentationTimestamp(
/// Timestamp in nanoseconds.
pub u128,
);
impl PresentationTimestamp {
/// A timestamp that is invalid due to the platform not having a timestamp system.
pub const INVALID_TIMESTAMP: Self = Self(u128::MAX);
/// Returns true if this timestamp is the invalid timestamp.
pub fn is_invalid(self) -> bool {
self == Self::INVALID_TIMESTAMP
}
}
/// RGBA double precision color.
///
/// This is not to be used as a generic color type, only for specific wgpu interfaces.
@ -5030,61 +4970,6 @@ pub struct ImageSubresourceRange {
}
impl ImageSubresourceRange {
/// Returns if the given range represents a full resource, with a texture of the given
/// layer count and mip count.
///
/// ```rust
/// # use wgpu_types as wgpu;
/// use std::num::NonZeroU32;
///
/// let range_none = wgpu::ImageSubresourceRange {
/// aspect: wgpu::TextureAspect::All,
/// base_mip_level: 0,
/// mip_level_count: None,
/// base_array_layer: 0,
/// array_layer_count: None,
/// };
/// assert_eq!(range_none.is_full_resource(5, 10), true);
///
/// let range_some = wgpu::ImageSubresourceRange {
/// aspect: wgpu::TextureAspect::All,
/// base_mip_level: 0,
/// mip_level_count: NonZeroU32::new(5),
/// base_array_layer: 0,
/// array_layer_count: NonZeroU32::new(10),
/// };
/// assert_eq!(range_some.is_full_resource(5, 10), true);
///
/// let range_mixed = wgpu::ImageSubresourceRange {
/// aspect: wgpu::TextureAspect::All,
/// base_mip_level: 0,
/// // Only partial resource
/// mip_level_count: NonZeroU32::new(3),
/// base_array_layer: 0,
/// array_layer_count: None,
/// };
/// assert_eq!(range_mixed.is_full_resource(5, 10), false);
/// ```
pub fn is_full_resource(&self, mip_levels: u32, array_layers: u32) -> bool {
// Mip level count and array layer count need to deal with both the None and Some(count) case.
let mip_level_count = self.mip_level_count.map_or(mip_levels, NonZeroU32::get);
let array_layer_count = self.array_layer_count.map_or(array_layers, NonZeroU32::get);
let aspect_eq = self.aspect == TextureAspect::All;
let base_mip_level_eq = self.base_mip_level == 0;
let mip_level_count_eq = mip_level_count == mip_levels;
let base_array_layer_eq = self.base_array_layer == 0;
let array_layer_count_eq = array_layer_count == array_layers;
aspect_eq
&& base_mip_level_eq
&& mip_level_count_eq
&& base_array_layer_eq
&& array_layer_count_eq
}
/// Returns the mip level range of a subresource range describes for a specific texture.
pub fn mip_range<L>(&self, texture_desc: &TextureDescriptor<L>) -> Range<u32> {
self.base_mip_level..match self.mip_level_count {