Bug 1868672 - Update `wgpu` to revision ff7b2c399301cca9bcbc5b19a869feb3c29ef785. r=webgpu-reviewers,supply-chain-reviewers,jimb

# Changelog

 * #4807 Bump wasm-bindgen-test from 0.3.38 to 0.3.39
   By dependabot[bot] in https://github.com/gfx-rs/wgpu/pull/4807
 * #4830 Use Display instead of Debug to log errors.
   By nical in https://github.com/gfx-rs/wgpu/pull/4830
 * #4755 [naga wgsl-in] Automatic conversions for `var` initializers.
   By jimblandy in https://github.com/gfx-rs/wgpu/pull/4755
 * #4755 [naga wgsl-in] Automatic conversions for `var` initializers.
   By jimblandy in https://github.com/gfx-rs/wgpu/pull/4755
 * #4755 [naga wgsl-in] Automatic conversions for `var` initializers.
   By jimblandy in https://github.com/gfx-rs/wgpu/pull/4755
 * #4832 vulkan: fix multi-planar texture creation
   By xiaopengli89 in https://github.com/gfx-rs/wgpu/pull/4832
 * #4758 [vk] remove (old) unused blocklist for dual source blending
   By teoxoy in https://github.com/gfx-rs/wgpu/pull/4758
 * #4828 Remove DX11 backend
   By valaphee in https://github.com/gfx-rs/wgpu/pull/4828
 * #4836 [gl] add support for line and point polygon modes
   By valaphee in https://github.com/gfx-rs/wgpu/pull/4836
 * #4820 Bump futures-lite from 2.0.1 to 2.1.0
   By dependabot[bot] in https://github.com/gfx-rs/wgpu/pull/4820
 * #4811 Expose shader validation
   By daxpedda in https://github.com/gfx-rs/wgpu/pull/4811
 * #3507 [wgpu-hal] Inline RayQuery Support
   By daniel-keitel in https://github.com/gfx-rs/wgpu/pull/3507
 * #4726 Fix Javascript exception on repeated `BufferSlice::get_mapped_range` calls
   By DouglasDwyer in https://github.com/gfx-rs/wgpu/pull/4726
 * #4841 Remove `expose-ids` Feature
   By cwfitzgerald in https://github.com/gfx-rs/wgpu/pull/4841
 * #4843 Some Minor `wgpu-core` Cleanups
   By cwfitzgerald in https://github.com/gfx-rs/wgpu/pull/4843
 * #4844 Work around cbindgen issue
   By nical in https://github.com/gfx-rs/wgpu/pull/4844

Differential Revision: https://phabricator.services.mozilla.com/D195735
This commit is contained in:
Nicolas Silva 2023-12-08 17:49:34 +00:00
Родитель 81781dffbf
Коммит b58a1a65c6
59 изменённых файлов: 2518 добавлений и 1437 удалений

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

@ -25,9 +25,9 @@ git = "https://github.com/franziskuskiefer/cose-rust"
rev = "43c22248d136c8b38fe42ea709d08da6355cf04b"
replace-with = "vendored-sources"
[source."git+https://github.com/gfx-rs/wgpu?rev=767ac03245ee937d3dc552edc13fe7ab0a860eec"]
[source."git+https://github.com/gfx-rs/wgpu?rev=ff7b2c399301cca9bcbc5b19a869feb3c29ef785"]
git = "https://github.com/gfx-rs/wgpu"
rev = "767ac03245ee937d3dc552edc13fe7ab0a860eec"
rev = "ff7b2c399301cca9bcbc5b19a869feb3c29ef785"
replace-with = "vendored-sources"
[source."git+https://github.com/hsivonen/chardetng?rev=3484d3e3ebdc8931493aa5df4d7ee9360a90e76b"]

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

@ -1157,7 +1157,7 @@ dependencies = [
[[package]]
name = "d3d12"
version = "0.7.0"
source = "git+https://github.com/gfx-rs/wgpu?rev=767ac03245ee937d3dc552edc13fe7ab0a860eec#767ac03245ee937d3dc552edc13fe7ab0a860eec"
source = "git+https://github.com/gfx-rs/wgpu?rev=ff7b2c399301cca9bcbc5b19a869feb3c29ef785#ff7b2c399301cca9bcbc5b19a869feb3c29ef785"
dependencies = [
"bitflags 2.4.0",
"libloading",
@ -3793,7 +3793,7 @@ checksum = "a2983372caf4480544083767bf2d27defafe32af49ab4df3a0b7fc90793a3664"
[[package]]
name = "naga"
version = "0.14.0"
source = "git+https://github.com/gfx-rs/wgpu?rev=767ac03245ee937d3dc552edc13fe7ab0a860eec#767ac03245ee937d3dc552edc13fe7ab0a860eec"
source = "git+https://github.com/gfx-rs/wgpu?rev=ff7b2c399301cca9bcbc5b19a869feb3c29ef785#ff7b2c399301cca9bcbc5b19a869feb3c29ef785"
dependencies = [
"bit-set",
"bitflags 2.4.0",
@ -6395,7 +6395,7 @@ dependencies = [
[[package]]
name = "wgpu-core"
version = "0.18.0"
source = "git+https://github.com/gfx-rs/wgpu?rev=767ac03245ee937d3dc552edc13fe7ab0a860eec#767ac03245ee937d3dc552edc13fe7ab0a860eec"
source = "git+https://github.com/gfx-rs/wgpu?rev=ff7b2c399301cca9bcbc5b19a869feb3c29ef785#ff7b2c399301cca9bcbc5b19a869feb3c29ef785"
dependencies = [
"arrayvec",
"bit-vec",
@ -6418,7 +6418,7 @@ dependencies = [
[[package]]
name = "wgpu-hal"
version = "0.18.0"
source = "git+https://github.com/gfx-rs/wgpu?rev=767ac03245ee937d3dc552edc13fe7ab0a860eec#767ac03245ee937d3dc552edc13fe7ab0a860eec"
source = "git+https://github.com/gfx-rs/wgpu?rev=ff7b2c399301cca9bcbc5b19a869feb3c29ef785#ff7b2c399301cca9bcbc5b19a869feb3c29ef785"
dependencies = [
"android_system_properties",
"arrayvec",
@ -6455,7 +6455,7 @@ dependencies = [
[[package]]
name = "wgpu-types"
version = "0.18.0"
source = "git+https://github.com/gfx-rs/wgpu?rev=767ac03245ee937d3dc552edc13fe7ab0a860eec#767ac03245ee937d3dc552edc13fe7ab0a860eec"
source = "git+https://github.com/gfx-rs/wgpu?rev=ff7b2c399301cca9bcbc5b19a869feb3c29ef785#ff7b2c399301cca9bcbc5b19a869feb3c29ef785"
dependencies = [
"bitflags 2.4.0",
"js-sys",

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

@ -77,9 +77,6 @@ void AdapterInfo::GetWgpuBackend(nsString& s) const {
case ffi::WGPUBackend_Dx12:
s.AssignLiteral("Dx12");
return;
case ffi::WGPUBackend_Dx11:
s.AssignLiteral("Dx11");
return;
case ffi::WGPUBackend_Gl:
s.AssignLiteral("Gl");
return;

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

@ -17,7 +17,7 @@ default = []
[dependencies.wgc]
package = "wgpu-core"
git = "https://github.com/gfx-rs/wgpu"
rev = "767ac03245ee937d3dc552edc13fe7ab0a860eec"
rev = "ff7b2c399301cca9bcbc5b19a869feb3c29ef785"
#Note: "replay" shouldn't ideally be needed,
# but it allows us to serialize everything across IPC.
features = ["replay", "trace", "serial-pass", "strict_asserts", "wgsl", "api_log_info"]
@ -27,36 +27,36 @@ features = ["replay", "trace", "serial-pass", "strict_asserts", "wgsl", "api_log
[target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies.wgc]
package = "wgpu-core"
git = "https://github.com/gfx-rs/wgpu"
rev = "767ac03245ee937d3dc552edc13fe7ab0a860eec"
rev = "ff7b2c399301cca9bcbc5b19a869feb3c29ef785"
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 = "767ac03245ee937d3dc552edc13fe7ab0a860eec"
rev = "ff7b2c399301cca9bcbc5b19a869feb3c29ef785"
features = ["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 = "767ac03245ee937d3dc552edc13fe7ab0a860eec"
rev = "ff7b2c399301cca9bcbc5b19a869feb3c29ef785"
features = ["vulkan"]
[dependencies.wgt]
package = "wgpu-types"
git = "https://github.com/gfx-rs/wgpu"
rev = "767ac03245ee937d3dc552edc13fe7ab0a860eec"
rev = "ff7b2c399301cca9bcbc5b19a869feb3c29ef785"
[dependencies.wgh]
package = "wgpu-hal"
git = "https://github.com/gfx-rs/wgpu"
rev = "767ac03245ee937d3dc552edc13fe7ab0a860eec"
rev = "ff7b2c399301cca9bcbc5b19a869feb3c29ef785"
[target.'cfg(windows)'.dependencies.d3d12]
git = "https://github.com/gfx-rs/wgpu"
rev = "767ac03245ee937d3dc552edc13fe7ab0a860eec"
rev = "ff7b2c399301cca9bcbc5b19a869feb3c29ef785"
[target.'cfg(windows)'.dependencies]
winapi = "0.3"

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

@ -20,11 +20,11 @@ origin:
# Human-readable identifier for this version/release
# Generally "version NNN", "tag SSS", "bookmark SSS"
release: commit 767ac03245ee937d3dc552edc13fe7ab0a860eec
release: commit ff7b2c399301cca9bcbc5b19a869feb3c29ef785
# Revision to pull in
# Must be a long or short commit SHA (long preferred)
revision: 767ac03245ee937d3dc552edc13fe7ab0a860eec
revision: ff7b2c399301cca9bcbc5b19a869feb3c29ef785
license: ['MIT', 'Apache-2.0']

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

@ -1201,6 +1201,11 @@ who = "Erich Gubler <egubler@mozilla.com>"
criteria = "safe-to-deploy"
delta = "0.7.0@git:6e21f7a9291db4395192d6b510d906978ae2d251 -> 0.7.0@git:a820a3ffba468cbb87c2a7e7bbe37065ed5207ee"
[[audits.d3d12]]
who = "Nicolas Silva <nical@fastmail.com>"
criteria = "safe-to-deploy"
delta = "0.7.0@git:767ac03245ee937d3dc552edc13fe7ab0a860eec -> 0.7.0@git:ff7b2c399301cca9bcbc5b19a869feb3c29ef785"
[[audits.d3d12]]
who = "Nicolas Silva <nical@fastmail.com>"
criteria = "safe-to-deploy"
@ -2497,6 +2502,11 @@ who = "Erich Gubler <egubler@mozilla.com>"
criteria = "safe-to-deploy"
delta = "0.14.0@git:6e21f7a9291db4395192d6b510d906978ae2d251 -> 0.14.0@git:a820a3ffba468cbb87c2a7e7bbe37065ed5207ee"
[[audits.naga]]
who = "Nicolas Silva <nical@fastmail.com>"
criteria = "safe-to-deploy"
delta = "0.14.0@git:767ac03245ee937d3dc552edc13fe7ab0a860eec -> 0.14.0@git:ff7b2c399301cca9bcbc5b19a869feb3c29ef785"
[[audits.naga]]
who = "Nicolas Silva <nical@fastmail.com>"
criteria = "safe-to-deploy"
@ -4270,6 +4280,11 @@ who = "Erich Gubler <egubler@mozilla.com>"
criteria = "safe-to-deploy"
delta = "0.18.0@git:6e21f7a9291db4395192d6b510d906978ae2d251 -> 0.18.0@git:a820a3ffba468cbb87c2a7e7bbe37065ed5207ee"
[[audits.wgpu-core]]
who = "Nicolas Silva <nical@fastmail.com>"
criteria = "safe-to-deploy"
delta = "0.18.0@git:767ac03245ee937d3dc552edc13fe7ab0a860eec -> 0.18.0@git:ff7b2c399301cca9bcbc5b19a869feb3c29ef785"
[[audits.wgpu-core]]
who = "Nicolas Silva <nical@fastmail.com>"
criteria = "safe-to-deploy"
@ -4343,6 +4358,11 @@ who = "Erich Gubler <egubler@mozilla.com>"
criteria = "safe-to-deploy"
delta = "0.18.0@git:6e21f7a9291db4395192d6b510d906978ae2d251 -> 0.18.0@git:a820a3ffba468cbb87c2a7e7bbe37065ed5207ee"
[[audits.wgpu-hal]]
who = "Nicolas Silva <nical@fastmail.com>"
criteria = "safe-to-deploy"
delta = "0.18.0@git:767ac03245ee937d3dc552edc13fe7ab0a860eec -> 0.18.0@git:ff7b2c399301cca9bcbc5b19a869feb3c29ef785"
[[audits.wgpu-hal]]
who = "Nicolas Silva <nical@fastmail.com>"
criteria = "safe-to-deploy"
@ -4416,6 +4436,11 @@ who = "Erich Gubler <egubler@mozilla.com>"
criteria = "safe-to-deploy"
delta = "0.18.0@git:6e21f7a9291db4395192d6b510d906978ae2d251 -> 0.18.0@git:a820a3ffba468cbb87c2a7e7bbe37065ed5207ee"
[[audits.wgpu-types]]
who = "Nicolas Silva <nical@fastmail.com>"
criteria = "safe-to-deploy"
delta = "0.18.0@git:767ac03245ee937d3dc552edc13fe7ab0a860eec -> 0.18.0@git:ff7b2c399301cca9bcbc5b19a869feb3c29ef785"
[[audits.wgpu-types]]
who = "Nicolas Silva <nical@fastmail.com>"
criteria = "safe-to-deploy"

2
third_party/rust/naga/.cargo-checksum.json поставляемый

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

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

@ -875,10 +875,30 @@ impl<'source, 'temp> Lowerer<'source, 'temp> {
ast::GlobalDeclKind::Var(ref v) => {
let ty = self.resolve_ast_type(v.ty, &mut ctx)?;
let init = v
.init
.map(|init| self.expression(init, &mut ctx.as_const()))
.transpose()?;
let init;
if let Some(init_ast) = v.init {
let mut ectx = ctx.as_const();
let lowered = self.expression_for_abstract(init_ast, &mut ectx)?;
let ty_res = crate::proc::TypeResolution::Handle(ty);
let converted = ectx
.try_automatic_conversions(lowered, &ty_res, v.name.span)
.map_err(|error| match error {
Error::AutoConversion {
dest_span: _,
dest_type,
source_span: _,
source_type,
} => Error::InitializationTypeMismatch {
name: v.name.span,
expected: dest_type,
got: source_type,
},
other => other,
})?;
init = Some(converted);
} else {
init = None;
}
let binding = if let Some(ref binding) = v.binding {
Some(crate::ResourceBinding {
@ -1142,45 +1162,49 @@ impl<'source, 'temp> Lowerer<'source, 'temp> {
return Ok(());
}
ast::LocalDecl::Var(ref v) => {
let mut emitter = Emitter::default();
emitter.start(&ctx.function.expressions);
let initializer = match v.init {
Some(init) => Some(
self.expression(init, &mut ctx.as_expression(block, &mut emitter))?,
),
None => None,
};
let explicit_ty =
v.ty.map(|ty| self.resolve_ast_type(ty, &mut ctx.as_global()))
v.ty.map(|ast| self.resolve_ast_type(ast, &mut ctx.as_global()))
.transpose()?;
let ty = match (explicit_ty, initializer) {
(Some(explicit), Some(initializer)) => {
let mut ctx = ctx.as_expression(block, &mut emitter);
let initializer_ty = resolve_inner!(ctx, initializer);
if !ctx.module.types[explicit]
.inner
.equivalent(initializer_ty, &ctx.module.types)
{
let gctx = &ctx.module.to_ctx();
return Err(Error::InitializationTypeMismatch {
let mut emitter = Emitter::default();
emitter.start(&ctx.function.expressions);
let mut ectx = ctx.as_expression(block, &mut emitter);
let ty;
let initializer;
match (v.init, explicit_ty) {
(Some(init), Some(explicit_ty)) => {
let init = self.expression_for_abstract(init, &mut ectx)?;
let ty_res = crate::proc::TypeResolution::Handle(explicit_ty);
let init = ectx
.try_automatic_conversions(init, &ty_res, v.name.span)
.map_err(|error| match error {
Error::AutoConversion {
dest_span: _,
dest_type,
source_span: _,
source_type,
} => Error::InitializationTypeMismatch {
name: v.name.span,
expected: explicit.to_wgsl(gctx),
got: initializer_ty.to_wgsl(gctx),
});
}
explicit
expected: dest_type,
got: source_type,
},
other => other,
})?;
ty = explicit_ty;
initializer = Some(init);
}
(Some(explicit), None) => explicit,
(None, Some(initializer)) => ctx
.as_expression(block, &mut emitter)
.register_type(initializer)?,
(None, None) => {
return Err(Error::MissingType(v.name.span));
(Some(init), None) => {
let concretized = self.expression(init, &mut ectx)?;
ty = ectx.register_type(concretized)?;
initializer = Some(concretized);
}
};
(None, Some(explicit_ty)) => {
ty = explicit_ty;
initializer = None;
}
(None, None) => return Err(Error::MissingType(v.name.span)),
}
let (const_initializer, initializer) = {
match initializer {

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

@ -1 +1 @@
{"files":{"Cargo.toml":"5119648ea52e97ad3fa2f0f24cc30e0b305fe81f710a33396bdadaf7397d41b9","LICENSE.APACHE":"a6cba85bc92e0cff7a450b1d873c0eaa2e9fc96bf472df0247a26bec77bf3ff9","LICENSE.MIT":"c7fea58d1cfe49634cd92e54fc10a9d871f4b275321a4cd8c09e449122caaeb4","src/any_surface.rs":"1afed4e5e2cc1726c9887bfbf8805f9141f859615c1eaf90f4ef3e49850caf06","src/binding_model.rs":"b709658ed6b9af2ed07ff77b8da64912cd26a9d7caaecee26c77a92efdc615d4","src/command/bind.rs":"85bbab812222f9bc11893059304cac850616818b00857fadac4885b978e4cfe2","src/command/bundle.rs":"7836b3740ad32168fdfb4241dbc91839d695c019abd3c38e3decec332b7e82c2","src/command/clear.rs":"8929095abd1508fdbc4b51db1bcfe513f77954fcfb269888c91b47c90b943c03","src/command/compute.rs":"296864d4f9e9a98f368d64910146480e38e2f895eee98a97d947dd593033f87c","src/command/draw.rs":"3687cbde422a29f28c1c3d17e132d912b3b4b2bcc98efca68d1ee0d563a5bf56","src/command/memory_init.rs":"ffe5c301f19a17285523ee8fd5e7bf5abd5e50e9a3716f5713ac99ab135d9f5e","src/command/mod.rs":"9ffa26b0306067ad63fc61fbde985ad98d495a2ad739f51bf54a39f702f45d3a","src/command/query.rs":"f31db3f1282109baa59e6dcd7b2e674c7858a2c64f58fc6eb3a4d0c546935af5","src/command/render.rs":"61a9f34d813700606b49224d9de19773c49eb3dd42fa4027357a334dc63e2579","src/command/transfer.rs":"60969f020bddfb88a0c3b459b72b94d3a9a96cc635d20e88d016765d0fb94ba5","src/conv.rs":"7e3ffe33b47a6fd3617aabf9f11cc68f1ccbee2c7343b8dbbcd0e8f3447e1ad8","src/device/any_device.rs":"2cb2be0fd078d65039692d309d8688cf4a02fb768579cf22c93cfa514d20ad7f","src/device/global.rs":"33c47e5aaa44ad4a485a996af52247e765bedfa18724ab7662ce34c78754448b","src/device/life.rs":"bbda212777bf5156feb9ee4c46d7c7621888c11544903a26bf86e7b708590f5a","src/device/mod.rs":"4ec88e037307e597fc661c85c9fa28f2d70a82a222a5fec5c97c450d33224f37","src/device/queue.rs":"9525b939e49b4c2860928c04a660a4556b34bfbed23e00318635a5ad46bce061","src/device/resource.rs":"a47f4d8b605c477fc6a63058e1340872590631c9a1a7f4e454bbbbe01aada757","src/device/trace.rs":"9a8ec674567a8866a6bd1ed2ad06e474bd2504ed91f228d3040cb6db18fe5f2b","src/error.rs":"32680e922acfb1f1d6842177179768d365c575a8baa402da9d5a43a2357b0dbf","src/global.rs":"9aa9448791477007b850c5eb1584e7c74c14fe43ac47ab3b5f29373850f463ee","src/hal_api.rs":"bb380df266fa9754c93d55c24b1a3535629710eb04bc6858a40c38a5f02aae68","src/hub.rs":"d9435f5b12f47e0b57599dce1d38e6eb4ef2477ab634806cfccefa4c1541f87b","src/id.rs":"0aa4258f93e05f6991385980a553e67892a0f1769e37624ae0466f83161af697","src/identity.rs":"0701f6f41e754dde2bebc567a87c25b353dfab40b79a322990dbfa477739ab8c","src/init_tracker/buffer.rs":"61eb9cfaa312135b7a937ff6a3117f531b5b7323fae6553a41d6de9bc106d7e0","src/init_tracker/mod.rs":"0867f79f83555390d0982d1dc6dcf0d4340e10cb89aa633d3c3ecc45deb3c78c","src/init_tracker/texture.rs":"030fd594bf9948fad391390d85c5e1fec7eaf67b6e812c60f2dd59bc4fda8fd5","src/instance.rs":"46b13911e15310a7ced4e5f13eeaa5d2cde7762b8ffa282a28d0c812e7036458","src/lib.rs":"9408b33250c7062599045cc11dd1f52d6036415f0e5c568b37c73348b330bb7c","src/pipeline.rs":"1d615e582254cfa108dd1925df7b6b0ae0c9845714b1351b8bcd4c7aa4b4dd69","src/present.rs":"1c28d6dbc3125b5eebd12265013618d8585d5c90f3fd1d3529c20e41e1ddecb3","src/registry.rs":"e93369ae372b133649b554a3d0338d74823cfded8b7e84d01bf1f000b670f471","src/resource.rs":"be6b9b648911c2277d9f88ca9e9a2811ec28fdf8118e009a47de0c16179f28aa","src/storage.rs":"6ba6416522ba2f1d2a279c220960aabdfb071c4e0ade888c8cbc2b91325c4203","src/track/buffer.rs":"a6762fad8bf5b257d37fb8844f0ee44ecb04f052c58655404b8af0036ac929e5","src/track/metadata.rs":"f8994ad91db7f3bb1b7f8b8b0f6884753d733ce28238b36f31da2230706f848e","src/track/mod.rs":"5fdef0bcf20999fda97342e261341809394dcad3ee97e2bc2429c5a1e41d48d5","src/track/range.rs":"5bbfed6e103b3234d9de8e42057022da6d628c2cc1db6bb51b88f87f2d8adf8b","src/track/stateless.rs":"65142de8e8425eee26e32bfef8169af3ed0e98455d5e470517717a3c15e8036c","src/track/texture.rs":"d4e92ef3400cf48b2e76d8b7c1e4c6a1cef0d3d060c6abdb46b9a3b386bc9dc9","src/validation.rs":"4bd36b7b02ad0122fda719790d40cc68058e0f8e3ba3cd622f1d76db377320f9"},"package":null}
{"files":{"Cargo.toml":"7d8b06bcc217e1e9a23ad63e2e9d9403f2ef58ab257c222233403c3e57a642e7","LICENSE.APACHE":"a6cba85bc92e0cff7a450b1d873c0eaa2e9fc96bf472df0247a26bec77bf3ff9","LICENSE.MIT":"c7fea58d1cfe49634cd92e54fc10a9d871f4b275321a4cd8c09e449122caaeb4","src/any_surface.rs":"c5e961783be28548681c3c38579ea0b5724c5336848216a423e83a0db2208ece","src/binding_model.rs":"ba1849e89e7dae7cd29635b57dc3140e47389e7aa38732b03c4cad693444680c","src/command/bind.rs":"85bbab812222f9bc11893059304cac850616818b00857fadac4885b978e4cfe2","src/command/bundle.rs":"7836b3740ad32168fdfb4241dbc91839d695c019abd3c38e3decec332b7e82c2","src/command/clear.rs":"8929095abd1508fdbc4b51db1bcfe513f77954fcfb269888c91b47c90b943c03","src/command/compute.rs":"296864d4f9e9a98f368d64910146480e38e2f895eee98a97d947dd593033f87c","src/command/draw.rs":"3687cbde422a29f28c1c3d17e132d912b3b4b2bcc98efca68d1ee0d563a5bf56","src/command/memory_init.rs":"ffe5c301f19a17285523ee8fd5e7bf5abd5e50e9a3716f5713ac99ab135d9f5e","src/command/mod.rs":"9ffa26b0306067ad63fc61fbde985ad98d495a2ad739f51bf54a39f702f45d3a","src/command/query.rs":"f31db3f1282109baa59e6dcd7b2e674c7858a2c64f58fc6eb3a4d0c546935af5","src/command/render.rs":"61a9f34d813700606b49224d9de19773c49eb3dd42fa4027357a334dc63e2579","src/command/transfer.rs":"60969f020bddfb88a0c3b459b72b94d3a9a96cc635d20e88d016765d0fb94ba5","src/conv.rs":"7e3ffe33b47a6fd3617aabf9f11cc68f1ccbee2c7343b8dbbcd0e8f3447e1ad8","src/device/any_device.rs":"2cb2be0fd078d65039692d309d8688cf4a02fb768579cf22c93cfa514d20ad7f","src/device/global.rs":"634619218859faa1dbd789b79a9ae2186cef950c50e3f9b1c4850d36bd1c8f16","src/device/life.rs":"a3d52432d7aff41d9f5bcf3b2da70d73f28847516d5909894328b78d2867b7ee","src/device/mod.rs":"d6a8ce711b8891c469c4b47348a3ce48d84ea4a356c0b05ec7e128d21a440562","src/device/queue.rs":"9525b939e49b4c2860928c04a660a4556b34bfbed23e00318635a5ad46bce061","src/device/resource.rs":"26f2681c2539b0fa6e242690ebafc6664e08a501a98bdf15e13555ac5f8769b1","src/device/trace.rs":"9a8ec674567a8866a6bd1ed2ad06e474bd2504ed91f228d3040cb6db18fe5f2b","src/error.rs":"32680e922acfb1f1d6842177179768d365c575a8baa402da9d5a43a2357b0dbf","src/global.rs":"c0a590e0136bf19a63ddc87dd3f0bbfbe24bcb810d0ccfc6c5f26631750d63ea","src/hal_api.rs":"3ee0f5e66b313fd1b8c79b3d73f0f1dbde88676b651d79518fa2dc5aff0ab856","src/hub.rs":"4cec8de74a661bb628040ff457d38faf8c92d0824c4d5a4955834d56ebd25926","src/id.rs":"76f6fbff7ac094b2d81e98e198b9d8785f11885e42015208fc362c368298c41f","src/identity.rs":"0701f6f41e754dde2bebc567a87c25b353dfab40b79a322990dbfa477739ab8c","src/init_tracker/buffer.rs":"61eb9cfaa312135b7a937ff6a3117f531b5b7323fae6553a41d6de9bc106d7e0","src/init_tracker/mod.rs":"0867f79f83555390d0982d1dc6dcf0d4340e10cb89aa633d3c3ecc45deb3c78c","src/init_tracker/texture.rs":"030fd594bf9948fad391390d85c5e1fec7eaf67b6e812c60f2dd59bc4fda8fd5","src/instance.rs":"e1d4af51bb445850d9e2d7d12b239413bb555f07f95d3a1851cc73443c5c18f0","src/lib.rs":"a7c46d675920b64284bf0494b749a9ffd3661a8c3ce6d4e00c399e5414dbf12d","src/pipeline.rs":"2ae1c803ba37d2114a31aa87a515555e7fc42b337f169f7a1cd7ce4568f92f30","src/present.rs":"1c28d6dbc3125b5eebd12265013618d8585d5c90f3fd1d3529c20e41e1ddecb3","src/registry.rs":"c259ca61dd5f2b632ff2ee871f82727921fa48dee15253872799af1dda77484b","src/resource.rs":"f3ad01be1943793fa2a469056388d0e14b3cf869f610fac11f556f5bc7ee8f86","src/storage.rs":"6ba6416522ba2f1d2a279c220960aabdfb071c4e0ade888c8cbc2b91325c4203","src/track/buffer.rs":"a6762fad8bf5b257d37fb8844f0ee44ecb04f052c58655404b8af0036ac929e5","src/track/metadata.rs":"f8994ad91db7f3bb1b7f8b8b0f6884753d733ce28238b36f31da2230706f848e","src/track/mod.rs":"5fdef0bcf20999fda97342e261341809394dcad3ee97e2bc2429c5a1e41d48d5","src/track/range.rs":"5bbfed6e103b3234d9de8e42057022da6d628c2cc1db6bb51b88f87f2d8adf8b","src/track/stateless.rs":"65142de8e8425eee26e32bfef8169af3ed0e98455d5e470517717a3c15e8036c","src/track/texture.rs":"d4e92ef3400cf48b2e76d8b7c1e4c6a1cef0d3d060c6abdb46b9a3b386bc9dc9","src/validation.rs":"4bd36b7b02ad0122fda719790d40cc68058e0f8e3ba3cd622f1d76db377320f9"},"package":null}

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

@ -83,7 +83,6 @@ package = "wgpu-types"
[features]
api_log_info = []
default = ["link"]
dx11 = ["hal/dx11"]
dx12 = ["hal/dx12"]
fragile-send-sync-non-atomic-wasm = [
"hal/fragile-send-sync-non-atomic-wasm",

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

@ -35,10 +35,6 @@ impl AnySurface {
if self.downcast_ref::<hal::api::Dx12>().is_some() {
return Backend::Dx12;
}
#[cfg(all(feature = "dx11", windows))]
if self.downcast_ref::<hal::api::Dx11>().is_some() {
return Backend::Dx11;
}
#[cfg(feature = "gles")]
if self.downcast_ref::<hal::api::Gles>().is_some() {
return Backend::Gl;

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

@ -341,6 +341,7 @@ impl BindingTypeMaxCountValidator {
wgt::BindingType::StorageTexture { .. } => {
self.storage_textures.add(binding.visibility, count);
}
wgt::BindingType::AccelerationStructure => todo!(),
}
}
@ -460,7 +461,6 @@ pub struct BindGroupLayout<A: HalApi> {
pub(crate) dynamic_count: usize,
pub(crate) count_validator: BindingTypeMaxCountValidator,
pub(crate) info: ResourceInfo<BindGroupLayoutId>,
#[cfg(debug_assertions)]
pub(crate) label: String,
}
@ -488,10 +488,7 @@ impl<A: HalApi> Resource<BindGroupLayoutId> for BindGroupLayout<A> {
}
fn label(&self) -> String {
#[cfg(debug_assertions)]
return self.label.clone();
#[cfg(not(debug_assertions))]
return String::new();
self.label.clone()
}
}
impl<A: HalApi> BindGroupLayout<A> {

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

@ -4,7 +4,7 @@ use crate::{
api_log, binding_model, command, conv,
device::{
life::WaitIdleError, map_buffer, queue, DeviceError, DeviceLostClosure, HostMap,
IMPLICIT_FAILURE,
IMPLICIT_BIND_GROUP_LAYOUT_ERROR_LABEL,
},
global::Global,
hal_api::HalApi,
@ -526,7 +526,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
if wait {
match device.wait_for_submit(last_submit_index) {
Ok(()) => (),
Err(e) => log::error!("Failed to wait for buffer {:?}: {:?}", buffer_id, e),
Err(e) => log::error!("Failed to wait for buffer {:?}: {}", buffer_id, e),
}
}
}
@ -574,7 +574,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
return (id, None);
};
log::error!("Device::create_texture error {error:?}");
log::error!("Device::create_texture error: {error}");
let id = fid.assign_error(desc.label.borrow_or_default());
(id, Some(error))
@ -648,7 +648,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
return (id, None);
};
log::error!("Device::create_texture error {error:?}");
log::error!("Device::create_texture error: {error}");
let id = fid.assign_error(desc.label.borrow_or_default());
(id, Some(error))
@ -702,7 +702,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
return (id, None);
};
log::error!("Device::create_buffer error {error:?}");
log::error!("Device::create_buffer error: {error}");
let id = fid.assign_error(desc.label.borrow_or_default());
(id, Some(error))
@ -790,7 +790,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
if wait {
match device.wait_for_submit(last_submit_index) {
Ok(()) => (),
Err(e) => log::error!("Failed to wait for texture {:?}: {:?}", texture_id, e),
Err(e) => log::error!("Failed to wait for texture {texture_id:?}: {e}"),
}
}
}
@ -835,7 +835,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
return (id, None);
};
log::error!("Texture::create_view({texture_id:?}) error {error:?}");
log::error!("Texture::create_view({texture_id:?}) error: {error}");
let id = fid.assign_error(desc.label.borrow_or_default());
(id, Some(error))
}
@ -865,11 +865,9 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
if wait {
match view.device.wait_for_submit(last_submit_index) {
Ok(()) => (),
Err(e) => log::error!(
"Failed to wait for texture view {:?}: {:?}",
texture_view_id,
e
),
Err(e) => {
log::error!("Failed to wait for texture view {texture_view_id:?}: {e}")
}
}
}
}
@ -1217,7 +1215,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
return (id, None);
};
log::error!("Device::create_shader_module error: {error:?}");
log::error!("Device::create_shader_module error: {error}");
let id = fid.assign_error(desc.label.borrow_or_default());
(id, Some(error))
@ -1274,7 +1272,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
return (id, None);
};
log::error!("Device::create_shader_module_spirv error: {error:?}");
log::error!("Device::create_shader_module_spirv error: {error}");
let id = fid.assign_error(desc.label.borrow_or_default());
(id, Some(error))
@ -1589,16 +1587,16 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
if pipeline_layout_guard.contains(ids.root_id) {
pipeline_layout_guard.remove(ids.root_id);
}
pipeline_layout_guard.insert_error(ids.root_id, IMPLICIT_FAILURE);
pipeline_layout_guard.insert_error(ids.root_id, IMPLICIT_BIND_GROUP_LAYOUT_ERROR_LABEL);
for &bgl_id in ids.group_ids.iter() {
if bgl_guard.contains(bgl_id) {
bgl_guard.remove(bgl_id);
}
bgl_guard.insert_error(bgl_id, IMPLICIT_FAILURE);
bgl_guard.insert_error(bgl_id, IMPLICIT_BIND_GROUP_LAYOUT_ERROR_LABEL);
}
}
log::error!("Device::create_render_pipeline error {error:?}");
log::error!("Device::create_render_pipeline error: {error}");
(id, Some(error))
}
@ -1723,12 +1721,12 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
if pipeline_layout_guard.contains(ids.root_id) {
pipeline_layout_guard.remove(ids.root_id);
}
pipeline_layout_guard.insert_error(ids.root_id, IMPLICIT_FAILURE);
pipeline_layout_guard.insert_error(ids.root_id, IMPLICIT_BIND_GROUP_LAYOUT_ERROR_LABEL);
for &bgl_id in ids.group_ids.iter() {
if bgl_guard.contains(bgl_id) {
bgl_guard.remove(bgl_id);
}
bgl_guard.insert_error(bgl_id, IMPLICIT_FAILURE);
bgl_guard.insert_error(bgl_id, IMPLICIT_BIND_GROUP_LAYOUT_ERROR_LABEL);
}
}
(id, Some(error))
@ -2180,11 +2178,6 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
all_queue_empty =
self.poll_device::<hal::api::Dx12>(force_wait, &mut closures)? && all_queue_empty;
}
#[cfg(all(feature = "dx11", windows))]
{
all_queue_empty =
self.poll_device::<hal::api::Dx11>(force_wait, &mut closures)? && all_queue_empty;
}
#[cfg(feature = "gles")]
{
all_queue_empty =
@ -2321,7 +2314,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
if let Some(callback) = operation.callback.take() {
callback.call(Err(err.clone()));
}
log::error!("Buffer::map_async error {err:?}");
log::error!("Buffer::map_async error: {err}");
return Err(err);
}

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

@ -930,7 +930,7 @@ impl<A: HalApi> LifetimeTracker<A> {
Ok(())
}
Err(e) => {
log::error!("Mapping failed {:?}", e);
log::error!("Mapping failed: {e}");
Err(e)
}
}

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

@ -27,15 +27,15 @@ pub mod resource;
pub mod trace;
pub use {life::WaitIdleError, resource::Device};
pub const SHADER_STAGE_COUNT: usize = 3;
pub const SHADER_STAGE_COUNT: usize = hal::MAX_CONCURRENT_SHADER_STAGES;
// Should be large enough for the largest possible texture row. This
// value is enough for a 16k texture with float4 format.
pub(crate) const ZERO_BUFFER_SIZE: BufferAddress = 512 << 10;
const CLEANUP_WAIT_MS: u32 = 5000;
const IMPLICIT_FAILURE: &str = "failed implicit";
const EP_FAILURE: &str = "EP is invalid";
const IMPLICIT_BIND_GROUP_LAYOUT_ERROR_LABEL: &str = "Implicit BindGroupLayout in the Error State";
const ENTRYPOINT_FAILURE_ERROR: &str = "The given EntryPoint is Invalid";
pub type DeviceDescriptor<'a> = wgt::DeviceDescriptor<Label<'a>>;

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

@ -53,8 +53,8 @@ use std::{
use super::{
life::{self, ResourceMaps},
queue::{self},
DeviceDescriptor, DeviceError, ImplicitPipelineContext, UserClosures, EP_FAILURE,
IMPLICIT_FAILURE, ZERO_BUFFER_SIZE,
DeviceDescriptor, DeviceError, ImplicitPipelineContext, UserClosures, ENTRYPOINT_FAILURE_ERROR,
IMPLICIT_BIND_GROUP_LAYOUT_ERROR_LABEL, ZERO_BUFFER_SIZE,
};
/// Structure describing a logical device. Some members are internally mutable,
@ -268,7 +268,7 @@ impl<A: HalApi> Device<A> {
Some(trace)
}
Err(e) => {
log::error!("Unable to start a trace in '{:?}': {:?}", path, e);
log::error!("Unable to start a trace in '{path:?}': {e}");
None
}
})),
@ -1422,7 +1422,6 @@ impl<A: HalApi> Device<A> {
device: self.clone(),
interface: Some(interface),
info: ResourceInfo::new(desc.label.borrow_or_default()),
#[cfg(debug_assertions)]
label: desc.label.borrow_or_default().to_string(),
})
}
@ -1464,7 +1463,6 @@ impl<A: HalApi> Device<A> {
device: self.clone(),
interface: None,
info: ResourceInfo::new(desc.label.borrow_or_default()),
#[cfg(debug_assertions)]
label: desc.label.borrow_or_default().to_string(),
})
}
@ -1642,6 +1640,7 @@ impl<A: HalApi> Device<A> {
},
)
}
Bt::AccelerationStructure => todo!(),
};
// Validate the count parameter
@ -1723,14 +1722,13 @@ impl<A: HalApi> Device<A> {
Ok(BindGroupLayout {
raw: Some(raw),
device: self.clone(),
info: ResourceInfo::new(label.unwrap_or("<BindGroupLayoyt>")),
info: ResourceInfo::new(label.unwrap_or("<BindGroupLayout>")),
dynamic_count: entry_map
.values()
.filter(|b| b.ty.has_dynamic_offset())
.count(),
count_validator,
entries: entry_map,
#[cfg(debug_assertions)]
label: label.unwrap_or_default().to_string(),
})
}
@ -2136,6 +2134,7 @@ impl<A: HalApi> Device<A> {
buffers: &hal_buffers,
samplers: &hal_samplers,
textures: &hal_textures,
acceleration_structures: &[],
};
let raw = unsafe {
self.raw
@ -2491,10 +2490,10 @@ impl<A: HalApi> Device<A> {
// that are not even in the storage.
if let Some(ref ids) = implicit_context {
let mut pipeline_layout_guard = hub.pipeline_layouts.write();
pipeline_layout_guard.insert_error(ids.root_id, IMPLICIT_FAILURE);
pipeline_layout_guard.insert_error(ids.root_id, IMPLICIT_BIND_GROUP_LAYOUT_ERROR_LABEL);
let mut bgl_guard = hub.bind_group_layouts.write();
for &bgl_id in ids.group_ids.iter() {
bgl_guard.insert_error(bgl_id, IMPLICIT_FAILURE);
bgl_guard.insert_error(bgl_id, IMPLICIT_BIND_GROUP_LAYOUT_ERROR_LABEL);
}
}
@ -2588,7 +2587,7 @@ impl<A: HalApi> Device<A> {
pipeline::CreateComputePipelineError::Internal(msg)
}
hal::PipelineError::EntryPoint(_stage) => {
pipeline::CreateComputePipelineError::Internal(EP_FAILURE.to_string())
pipeline::CreateComputePipelineError::Internal(ENTRYPOINT_FAILURE_ERROR.to_string())
}
})?;
@ -2620,9 +2619,9 @@ impl<A: HalApi> Device<A> {
//TODO: only lock mutable if the layout is derived
let mut pipeline_layout_guard = hub.pipeline_layouts.write();
let mut bgl_guard = hub.bind_group_layouts.write();
pipeline_layout_guard.insert_error(ids.root_id, IMPLICIT_FAILURE);
pipeline_layout_guard.insert_error(ids.root_id, IMPLICIT_BIND_GROUP_LAYOUT_ERROR_LABEL);
for &bgl_id in ids.group_ids.iter() {
bgl_guard.insert_error(bgl_id, IMPLICIT_FAILURE);
bgl_guard.insert_error(bgl_id, IMPLICIT_BIND_GROUP_LAYOUT_ERROR_LABEL);
}
}
@ -3146,7 +3145,7 @@ impl<A: HalApi> Device<A> {
hal::PipelineError::EntryPoint(stage) => {
pipeline::CreateRenderPipelineError::Internal {
stage: hal::auxil::map_naga_stage(stage),
error: EP_FAILURE.to_string(),
error: ENTRYPOINT_FAILURE_ERROR.to_string(),
}
}
})?;
@ -3358,7 +3357,7 @@ impl<A: HalApi> Device<A> {
.unwrap()
.wait(fence, current_index, CLEANUP_WAIT_MS)
} {
log::error!("failed to wait for the device: {:?}", error);
log::error!("failed to wait for the device: {error}");
}
let mut life_tracker = self.lock_life();
let _ = life_tracker.triage_submissions(

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

@ -22,8 +22,6 @@ pub struct GlobalReport {
pub metal: Option<HubReport>,
#[cfg(all(feature = "dx12", windows))]
pub dx12: Option<HubReport>,
#[cfg(all(feature = "dx11", windows))]
pub dx11: Option<HubReport>,
#[cfg(feature = "gles")]
pub gl: Option<HubReport>,
}
@ -40,8 +38,6 @@ impl GlobalReport {
Backend::Metal => self.metal.as_ref().unwrap(),
#[cfg(all(feature = "dx12", windows))]
Backend::Dx12 => self.dx12.as_ref().unwrap(),
#[cfg(all(feature = "dx11", windows))]
Backend::Dx11 => self.dx11.as_ref().unwrap(),
#[cfg(feature = "gles")]
Backend::Gl => self.gl.as_ref().unwrap(),
_ => panic!("HubReport is not supported on this backend"),
@ -132,12 +128,6 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
} else {
None
},
#[cfg(all(feature = "dx11", windows))]
dx11: if self.instance.dx11.is_some() {
Some(self.hubs.dx11.generate_report())
} else {
None
},
#[cfg(feature = "gles")]
gl: if self.instance.gl.is_some() {
Some(self.hubs.gl.generate_report())
@ -167,10 +157,6 @@ impl<G: GlobalIdentityHandlerFactory> Drop for Global<G> {
{
self.hubs.dx12.clear(&surfaces_locked, true);
}
#[cfg(all(feature = "dx11", windows))]
{
self.hubs.dx11.clear(&surfaces_locked, true);
}
#[cfg(feature = "gles")]
{
self.hubs.gl.clear(&surfaces_locked, true);

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

@ -94,27 +94,6 @@ impl HalApi for hal::api::Dx12 {
}
}
#[cfg(all(feature = "dx11", windows))]
impl HalApi for hal::api::Dx11 {
const VARIANT: Backend = Backend::Dx11;
fn create_instance_from_hal(name: &str, hal_instance: Self::Instance) -> Instance {
Instance {
name: name.to_owned(),
dx11: Some(hal_instance),
..Default::default()
}
}
fn instance_as_hal(instance: &Instance) -> Option<&Self::Instance> {
instance.dx11.as_ref()
}
fn hub<G: GlobalIdentityHandlerFactory>(global: &Global<G>) -> &Hub<Self> {
&global.hubs.dx11
}
fn get_surface(surface: &Surface) -> Option<&HalSurface<Self>> {
surface.raw.downcast_ref()
}
}
#[cfg(feature = "gles")]
impl HalApi for hal::api::Gles {
const VARIANT: Backend = Backend::Gl;

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

@ -308,15 +308,12 @@ pub struct Hubs {
pub(crate) metal: Hub<hal::api::Metal>,
#[cfg(all(feature = "dx12", windows))]
pub(crate) dx12: Hub<hal::api::Dx12>,
#[cfg(all(feature = "dx11", windows))]
pub(crate) dx11: Hub<hal::api::Dx11>,
#[cfg(feature = "gles")]
pub(crate) gl: Hub<hal::api::Gles>,
#[cfg(all(
not(all(feature = "vulkan", not(target_arch = "wasm32"))),
not(all(feature = "metal", any(target_os = "macos", target_os = "ios"))),
not(all(feature = "dx12", windows)),
not(all(feature = "dx11", windows)),
not(feature = "gles"),
))]
pub(crate) empty: Hub<hal::api::Empty>,
@ -331,15 +328,12 @@ impl Hubs {
metal: Hub::new(factory),
#[cfg(all(feature = "dx12", windows))]
dx12: Hub::new(factory),
#[cfg(all(feature = "dx11", windows))]
dx11: Hub::new(factory),
#[cfg(feature = "gles")]
gl: Hub::new(factory),
#[cfg(all(
not(all(feature = "vulkan", not(target_arch = "wasm32"))),
not(all(feature = "metal", any(target_os = "macos", target_os = "ios"))),
not(all(feature = "dx12", windows)),
not(all(feature = "dx11", windows)),
not(feature = "gles"),
))]
empty: Hub::new(factory),

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

@ -131,8 +131,7 @@ where
1 => Backend::Vulkan,
2 => Backend::Metal,
3 => Backend::Dx12,
4 => Backend::Dx11,
5 => Backend::Gl,
4 => Backend::Gl,
_ => unreachable!(),
}
}
@ -156,13 +155,12 @@ where
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
let (index, epoch, backend) = self.unzip();
let backend = match backend {
Backend::Empty => "_",
Backend::Vulkan => "vk",
Backend::Metal => "mtl",
Backend::Dx12 => "d3d12",
Backend::Dx11 => "d3d11",
Backend::Gl => "gl",
Backend::BrowserWebGpu => "webgpu",
Backend::Empty => "_",
};
write!(formatter, "Id({index},{epoch},{backend})")?;
Ok(())
@ -280,7 +278,6 @@ fn test_id_backend() {
Backend::Vulkan,
Backend::Metal,
Backend::Dx12,
Backend::Dx11,
Backend::Gl,
] {
let id: Id<()> = Id::zip(1, 0, b);
@ -300,7 +297,6 @@ fn test_id() {
Backend::Vulkan,
Backend::Metal,
Backend::Dx12,
Backend::Dx11,
Backend::Gl,
];
for &i in &indexes {

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

@ -68,8 +68,6 @@ pub struct Instance {
pub metal: Option<HalInstance<hal::api::Metal>>,
#[cfg(all(feature = "dx12", windows))]
pub dx12: Option<HalInstance<hal::api::Dx12>>,
#[cfg(all(feature = "dx11", windows))]
pub dx11: Option<HalInstance<hal::api::Dx11>>,
#[cfg(feature = "gles")]
pub gl: Option<HalInstance<hal::api::Gles>>,
pub flags: wgt::InstanceFlags,
@ -113,8 +111,6 @@ impl Instance {
metal: init(hal::api::Metal, &instance_desc),
#[cfg(all(feature = "dx12", windows))]
dx12: init(hal::api::Dx12, &instance_desc),
#[cfg(all(feature = "dx11", windows))]
dx11: init(hal::api::Dx11, &instance_desc),
#[cfg(feature = "gles")]
gl: init(hal::api::Gles, &instance_desc),
flags: instance_desc.flags,
@ -144,8 +140,6 @@ impl Instance {
Backend::Metal => destroy(hal::api::Metal, &self.metal, surface.raw),
#[cfg(all(feature = "dx12", windows))]
Backend::Dx12 => destroy(hal::api::Dx12, &self.dx12, surface.raw),
#[cfg(all(feature = "dx11", windows))]
Backend::Dx11 => destroy(hal::api::Dx11, &self.dx11, surface.raw),
#[cfg(feature = "gles")]
Backend::Gl => destroy(hal::api::Gles, &self.gl, surface.raw),
_ => unreachable!(),
@ -531,13 +525,6 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
display_handle,
window_handle,
);
#[cfg(all(feature = "dx11", windows))]
init::<hal::api::Dx11>(
&mut hal_surface,
&self.instance.dx11,
display_handle,
window_handle,
);
#[cfg(feature = "gles")]
init::<hal::api::Gles>(
&mut hal_surface,
@ -787,8 +774,6 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
unconfigure::<_, hal::api::Metal>(self, &surface.raw, &present);
#[cfg(all(feature = "dx12", windows))]
unconfigure::<_, hal::api::Dx12>(self, &surface.raw, &present);
#[cfg(all(feature = "dx11", windows))]
unconfigure::<_, hal::api::Dx11>(self, &surface.raw, &present);
#[cfg(feature = "gles")]
unconfigure::<_, hal::api::Gles>(self, &surface.raw, &present);
}
@ -849,8 +834,6 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
);
#[cfg(all(feature = "dx12", windows))]
self.enumerate(hal::api::Dx12, &self.instance.dx12, &inputs, &mut adapters);
#[cfg(all(feature = "dx11", windows))]
self.enumerate(hal::api::Dx11, &self.instance.dx11, &inputs, &mut adapters);
#[cfg(feature = "gles")]
self.enumerate(hal::api::Gles, &self.instance.gl, &inputs, &mut adapters);
@ -960,15 +943,6 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
desc.force_fallback_adapter,
&mut device_types,
);
#[cfg(all(feature = "dx11", windows))]
let (id_dx11, adapters_dx11) = gather(
hal::api::Dx11,
self.instance.dx11.as_ref(),
&inputs,
compatible_surface,
desc.force_fallback_adapter,
&mut device_types,
);
#[cfg(feature = "gles")]
let (id_gl, adapters_gl) = gather(
hal::api::Gles,
@ -1042,10 +1016,6 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
if let Some(id) = self.select(&mut selected, id_dx12, adapters_dx12) {
return Ok(id);
}
#[cfg(all(feature = "dx11", windows))]
if let Some(id) = self.select(&mut selected, id_dx11, adapters_dx11) {
return Ok(id);
}
#[cfg(feature = "gles")]
if let Some(id) = self.select(&mut selected, id_gl, adapters_gl) {
return Ok(id);
@ -1076,8 +1046,6 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
Backend::Metal => fid.assign(Adapter::new(hal_adapter)),
#[cfg(all(feature = "dx12", windows))]
Backend::Dx12 => fid.assign(Adapter::new(hal_adapter)),
#[cfg(all(feature = "dx11", windows))]
Backend::Dx11 => fid.assign(Adapter::new(hal_adapter)),
#[cfg(feature = "gles")]
Backend::Gl => fid.assign(Adapter::new(hal_adapter)),
_ => unreachable!(),
@ -1283,7 +1251,6 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
/// Names:
/// - vulkan = "vulkan" or "vk"
/// - dx12 = "dx12" or "d3d12"
/// - dx11 = "dx11" or "d3d11"
/// - metal = "metal" or "mtl"
/// - gles = "opengl" or "gles" or "gl"
/// - webgpu = "webgpu"
@ -1293,7 +1260,6 @@ pub fn parse_backends_from_comma_list(string: &str) -> Backends {
backends |= match backend.trim() {
"vulkan" | "vk" => Backends::VULKAN,
"dx12" | "d3d12" => Backends::DX12,
"dx11" | "d3d11" => Backends::DX11,
"metal" | "mtl" => Backends::METAL,
"opengl" | "gles" | "gl" => Backends::GL,
"webgpu" => Backends::BROWSER_WEBGPU,

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

@ -9,7 +9,6 @@
not(all(feature = "vulkan", not(target_arch = "wasm32"))),
not(all(feature = "metal", any(target_os = "macos", target_os = "ios"))),
not(all(feature = "dx12", windows)),
not(all(feature = "dx11", windows)),
not(feature = "gles"),
),
allow(unused, clippy::let_and_return)
@ -67,7 +66,11 @@ pub mod registry;
pub mod resource;
pub mod storage;
mod track;
mod validation;
// This is public for users who pre-compile shaders while still wanting to
// preserve all run-time checks that `wgpu-core` does.
// See <https://github.com/gfx-rs/wgpu/issues/3103>, after which this can be
// made private again.
pub mod validation;
pub use hal::{api, MAX_BIND_GROUPS, MAX_COLOR_ATTACHMENTS, MAX_VERTEX_BUFFERS};
@ -217,7 +220,6 @@ macro_rules! define_backend_caller {
define_backend_caller! { gfx_if_vulkan, gfx_if_vulkan_hidden, "vulkan" if all(feature = "vulkan", not(target_arch = "wasm32")) }
define_backend_caller! { gfx_if_metal, gfx_if_metal_hidden, "metal" if all(feature = "metal", any(target_os = "macos", target_os = "ios")) }
define_backend_caller! { gfx_if_dx12, gfx_if_dx12_hidden, "dx12" if all(feature = "dx12", windows) }
define_backend_caller! { gfx_if_dx11, gfx_if_dx11_hidden, "dx11" if all(feature = "dx11", windows) }
define_backend_caller! { gfx_if_gles, gfx_if_gles_hidden, "gles" if feature = "gles" }
/// Dispatch on an [`Id`]'s backend to a backend-generic method.
@ -272,7 +274,6 @@ macro_rules! gfx_select {
wgt::Backend::Vulkan => $crate::gfx_if_vulkan!($global.$method::<$crate::api::Vulkan>( $($param),* )),
wgt::Backend::Metal => $crate::gfx_if_metal!($global.$method::<$crate::api::Metal>( $($param),* )),
wgt::Backend::Dx12 => $crate::gfx_if_dx12!($global.$method::<$crate::api::Dx12>( $($param),* )),
wgt::Backend::Dx11 => $crate::gfx_if_dx11!($global.$method::<$crate::api::Dx11>( $($param),* )),
wgt::Backend::Gl => $crate::gfx_if_gles!($global.$method::<$crate::api::Gles>( $($param),+ )),
other => panic!("Unexpected backend {:?}", other),
}

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

@ -48,7 +48,6 @@ pub struct ShaderModule<A: HalApi> {
pub(crate) device: Arc<Device<A>>,
pub(crate) interface: Option<validation::Interface>,
pub(crate) info: ResourceInfo<ShaderModuleId>,
#[cfg(debug_assertions)]
pub(crate) label: String,
}
@ -80,10 +79,7 @@ impl<A: HalApi> Resource<ShaderModuleId> for ShaderModule<A> {
}
fn label(&self) -> String {
#[cfg(debug_assertions)]
return self.label.clone();
#[cfg(not(debug_assertions))]
return String::new();
self.label.clone()
}
}

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

@ -88,7 +88,6 @@ impl<I: id::TypedId + Copy, T: Resource<I>> FutureId<'_, I, T> {
pub fn assign_existing(self, value: &Arc<T>) -> I {
let mut data = self.data.write();
#[cfg(debug_assertions)]
debug_assert!(!data.contains(self.id));
data.insert(self.id, value.clone());
self.id

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

@ -70,7 +70,6 @@ pub struct ResourceInfo<Id: TypedId> {
submission_index: AtomicUsize,
/// The `label` from the descriptor used to create the resource.
#[cfg(debug_assertions)]
pub(crate) label: String,
}
@ -90,25 +89,19 @@ impl<Id: TypedId> ResourceInfo<Id> {
id: None,
identity: None,
submission_index: AtomicUsize::new(0),
#[cfg(debug_assertions)]
label: label.to_string(),
}
}
#[allow(unused_assignments)]
pub(crate) fn label(&self) -> String
where
Id: Debug,
{
let mut label = String::new();
#[cfg(debug_assertions)]
{
label = format!("[{}] ", self.label);
}
if let Some(id) = self.id.as_ref() {
label.push_str(format!("{:?}", id).as_str());
format!("[{}] {:?}", self.label, id)
} else {
format!("[{}]", self.label)
}
label
}
pub(crate) fn id(&self) -> Id {
@ -139,10 +132,7 @@ pub trait Resource<Id: TypedId>: 'static + WasmNotSendSync {
fn as_info(&self) -> &ResourceInfo<Id>;
fn as_info_mut(&mut self) -> &mut ResourceInfo<Id>;
fn label(&self) -> String {
#[cfg(debug_assertions)]
return self.as_info().label.clone();
#[cfg(not(debug_assertions))]
return String::new();
self.as_info().label.clone()
}
fn ref_count(self: &Arc<Self>) -> usize {
Arc::strong_count(self)

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

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

@ -81,6 +81,7 @@ package = "wgpu-types"
[dev-dependencies]
cfg-if = "1"
env_logger = "0.10"
glam = "0.24.2"
[dev-dependencies.naga]
version = "0.14.0"
@ -93,17 +94,6 @@ features = ["android-native-activity"]
[features]
default = ["link"]
dx11 = [
"naga/hlsl-out",
"d3d12",
"libloading",
"winapi/d3d11",
"winapi/std",
"winapi/d3d11_1",
"winapi/d3d11_2",
"winapi/d3d11sdklayers",
"winapi/dxgi1_6",
]
dx12 = [
"naga/hlsl-out",
"d3d12",

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

@ -442,6 +442,7 @@ impl<A: hal::Api> Example<A> {
buffers: &[global_buffer_binding],
samplers: &[&sampler],
textures: &[texture_binding],
acceleration_structures: &[],
entries: &[
hal::BindGroupEntry {
binding: 0,
@ -475,6 +476,7 @@ impl<A: hal::Api> Example<A> {
buffers: &[local_buffer_binding],
samplers: &[],
textures: &[],
acceleration_structures: &[],
entries: &[hal::BindGroupEntry {
binding: 0,
resource_index: 0,

1113
third_party/rust/wgpu-hal/examples/ray-traced-triangle/main.rs поставляемый Normal file

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -0,0 +1,37 @@
struct Uniforms {
view_inv: mat4x4<f32>,
proj_inv: mat4x4<f32>,
};
@group(0) @binding(0)
var<uniform> uniforms: Uniforms;
@group(0) @binding(1)
var output: texture_storage_2d<rgba8unorm, write>;
@group(0) @binding(2)
var acc_struct: acceleration_structure;
@compute @workgroup_size(8, 8)
fn main(@builtin(global_invocation_id) global_id: vec3<u32>) {
let target_size = textureDimensions(output);
let pixel_center = vec2<f32>(global_id.xy) + vec2<f32>(0.5);
let in_uv = pixel_center / vec2<f32>(target_size.xy);
let d = in_uv * 2.0 - 1.0;
let origin = (uniforms.view_inv * vec4<f32>(0.0, 0.0, 0.0, 1.0)).xyz;
let temp = uniforms.proj_inv * vec4<f32>(d.x, d.y, 1.0, 1.0);
let direction = (uniforms.view_inv * vec4<f32>(normalize(temp.xyz), 0.0)).xyz;
var rq: ray_query;
rayQueryInitialize(&rq, acc_struct, RayDesc(0u, 0xFFu, 0.1, 200.0, origin, direction));
rayQueryProceed(&rq);
var color = vec4<f32>(0.0, 0.0, 0.0, 1.0);
let intersection = rayQueryGetCommittedIntersection(&rq);
if intersection.kind != RAY_QUERY_INTERSECTION_NONE {
color = vec4<f32>(intersection.barycentrics, 1.0 - intersection.barycentrics.x - intersection.barycentrics.y, 1.0);
}
textureStore(output, global_id.xy, color);
}

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

@ -1,4 +1,4 @@
#[cfg(all(any(feature = "dx11", feature = "dx12"), windows))]
#[cfg(all(feature = "dx12", windows))]
pub(super) mod dxgi;
#[cfg(all(not(target_arch = "wasm32"), feature = "renderdoc"))]

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

@ -1,303 +0,0 @@
use std::num::NonZeroU64;
use winapi::um::{d3d11, d3dcommon};
impl crate::Adapter<super::Api> for super::Adapter {
unsafe fn open(
&self,
features: wgt::Features,
limits: &wgt::Limits,
) -> Result<crate::OpenDevice<super::Api>, crate::DeviceError> {
todo!()
}
unsafe fn texture_format_capabilities(
&self,
format: wgt::TextureFormat,
) -> crate::TextureFormatCapabilities {
todo!()
}
unsafe fn surface_capabilities(
&self,
surface: &super::Surface,
) -> Option<crate::SurfaceCapabilities> {
todo!()
}
unsafe fn get_presentation_timestamp(&self) -> wgt::PresentationTimestamp {
todo!()
}
}
impl super::Adapter {
pub(super) fn expose(
instance: &super::library::D3D11Lib,
adapter: d3d12::DxgiAdapter,
) -> Option<crate::ExposedAdapter<super::Api>> {
use d3dcommon::{
D3D_FEATURE_LEVEL_10_0 as FL10_0, D3D_FEATURE_LEVEL_10_1 as FL10_1,
D3D_FEATURE_LEVEL_11_0 as FL11_0, D3D_FEATURE_LEVEL_11_1 as FL11_1,
D3D_FEATURE_LEVEL_9_1 as FL9_1, D3D_FEATURE_LEVEL_9_2 as FL9_2,
D3D_FEATURE_LEVEL_9_3 as FL9_3,
};
let (device, feature_level) = instance.create_device(adapter)?;
//
// Query Features from d3d11
//
let d3d9_features = unsafe {
device.check_feature_support::<d3d11::D3D11_FEATURE_DATA_D3D9_OPTIONS1>(
d3d11::D3D11_FEATURE_D3D9_OPTIONS1,
)
};
let d3d10_features = unsafe {
device.check_feature_support::<d3d11::D3D11_FEATURE_DATA_D3D10_X_HARDWARE_OPTIONS>(
d3d11::D3D11_FEATURE_D3D10_X_HARDWARE_OPTIONS,
)
};
let d3d11_features = unsafe {
device.check_feature_support::<d3d11::D3D11_FEATURE_DATA_D3D11_OPTIONS>(
d3d11::D3D11_FEATURE_D3D11_OPTIONS,
)
};
let d3d11_features1 = unsafe {
device.check_feature_support::<d3d11::D3D11_FEATURE_DATA_D3D11_OPTIONS1>(
d3d11::D3D11_FEATURE_D3D11_OPTIONS1,
)
};
let d3d11_features2 = unsafe {
device.check_feature_support::<d3d11::D3D11_FEATURE_DATA_D3D11_OPTIONS2>(
d3d11::D3D11_FEATURE_D3D11_OPTIONS2,
)
};
let d3d11_features3 = unsafe {
device.check_feature_support::<d3d11::D3D11_FEATURE_DATA_D3D11_OPTIONS3>(
d3d11::D3D11_FEATURE_D3D11_OPTIONS3,
)
};
//
// Fill out features and downlevel features
//
// TODO(cwfitzgerald): Needed downlevel features: 3D dispatch
let mut features = wgt::Features::DEPTH_CLIP_CONTROL
| wgt::Features::PUSH_CONSTANTS
| wgt::Features::POLYGON_MODE_LINE
| wgt::Features::CLEAR_TEXTURE
| wgt::Features::TEXTURE_FORMAT_16BIT_NORM
| wgt::Features::ADDRESS_MODE_CLAMP_TO_ZERO
| wgt::Features::ADDRESS_MODE_CLAMP_TO_BORDER;
let mut downlevel = wgt::DownlevelFlags::BASE_VERTEX
| wgt::DownlevelFlags::READ_ONLY_DEPTH_STENCIL
| wgt::DownlevelFlags::UNRESTRICTED_INDEX_BUFFER
| wgt::DownlevelFlags::UNRESTRICTED_EXTERNAL_TEXTURE_COPIES;
// Features from queries
downlevel.set(
wgt::DownlevelFlags::NON_POWER_OF_TWO_MIPMAPPED_TEXTURES,
d3d9_features.FullNonPow2TextureSupported == 1,
);
downlevel.set(
wgt::DownlevelFlags::COMPUTE_SHADERS,
d3d10_features.ComputeShaders_Plus_RawAndStructuredBuffers_Via_Shader_4_x == 1,
);
// Features from feature level
if feature_level >= FL9_2 {
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 {
downlevel |= wgt::DownlevelFlags::COMPARISON_SAMPLERS;
}
if feature_level >= FL10_0 {
downlevel |= wgt::DownlevelFlags::FRAGMENT_STORAGE;
downlevel |= wgt::DownlevelFlags::FRAGMENT_WRITABLE_STORAGE;
downlevel |= wgt::DownlevelFlags::DEPTH_BIAS_CLAMP;
downlevel |= wgt::DownlevelFlags::VERTEX_STORAGE;
features |= wgt::Features::DEPTH_CLIP_CONTROL;
features |= wgt::Features::TIMESTAMP_QUERY;
features |= wgt::Features::PIPELINE_STATISTICS_QUERY;
features |= wgt::Features::SHADER_PRIMITIVE_INDEX;
features |= wgt::Features::DEPTH32FLOAT_STENCIL8;
features |= wgt::Features::RG11B10UFLOAT_RENDERABLE;
}
if feature_level >= FL10_1 {
downlevel |= wgt::DownlevelFlags::CUBE_ARRAY_TEXTURES;
downlevel |= wgt::DownlevelFlags::MULTISAMPLED_SHADING;
}
if feature_level >= FL11_0 {
downlevel |= wgt::DownlevelFlags::INDIRECT_EXECUTION;
downlevel |= wgt::DownlevelFlags::WEBGPU_TEXTURE_FORMAT_SUPPORT;
features |= wgt::Features::TEXTURE_COMPRESSION_BC;
}
if feature_level >= FL11_1 {
features |= wgt::Features::VERTEX_WRITABLE_STORAGE;
}
// bgra8unorm-storage is never supported on dx11 according to:
// https://learn.microsoft.com/en-us/windows/win32/direct3ddxgi/format-support-for-direct3d-11-0-feature-level-hardware#dxgi_format_b8g8r8a8_unormfcs-87
// float32-filterable should always be available on dx11
// https://learn.microsoft.com/en-us/windows/win32/direct3ddxgi/format-support-for-direct3d-11-0-feature-level-hardware#dxgi_format_r32g32b32a32_floatfcs-2
features.set(wgt::Features::FLOAT32_FILTERABLE, true);
//
// Fill out limits and alignments
//
let max_texture_dimension_2d = match feature_level {
FL9_1 | FL9_2 => 2048,
FL9_3 => 4096,
FL10_0 | FL10_1 => 8192,
_ => d3d11::D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION,
};
let max_texture_dimension_3d = match feature_level {
FL9_1..=FL9_3 => 256,
_ => d3d11::D3D11_REQ_TEXTURE3D_U_V_OR_W_DIMENSION,
};
let max_vertex_buffers = match feature_level {
FL9_1..=FL9_3 => 16,
_ => 32,
}
.min(crate::MAX_VERTEX_BUFFERS as u32);
let max_compute_workgroup_storage_size = match feature_level {
FL9_1..=FL9_3 => 0,
FL10_0 | FL10_1 => 4096 * 4, // This doesn't have an equiv SM4 constant :\
_ => d3d11::D3D11_CS_TGSM_REGISTER_COUNT * 4,
};
let max_workgroup_size_xy = match feature_level {
FL9_1..=FL9_3 => 0,
FL10_0 | FL10_1 => d3d11::D3D11_CS_4_X_THREAD_GROUP_MAX_X,
_ => d3d11::D3D11_CS_THREAD_GROUP_MAX_X,
};
let max_workgroup_size_z = match feature_level {
FL9_1..=FL9_3 => 0,
FL10_0 | FL10_1 => 1,
_ => d3d11::D3D11_CS_THREAD_GROUP_MAX_Z,
};
// let max_workgroup_count_z = match feature_level {
// FL9_1..=FL9_3 => 0,
// FL10_0 | FL10_1 => 1,
// _ => d3d11::D3D11_CS_THREAD_GROUP_MAX_Z,
// };
let max_sampled_textures = d3d11::D3D11_COMMONSHADER_INPUT_RESOURCE_REGISTER_COUNT;
let max_samplers = d3d11::D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT;
let max_constant_buffers = d3d11::D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1;
let max_uavs = if device.as_device1().is_some() {
d3d11::D3D11_1_UAV_SLOT_COUNT
} else {
d3d11::D3D11_PS_CS_UAV_REGISTER_COUNT
};
let max_output_registers = d3d11::D3D11_VS_OUTPUT_REGISTER_COMPONENTS;
let max_compute_invocations_per_workgroup =
d3d11::D3D11_CS_THREAD_GROUP_MAX_THREADS_PER_GROUP;
let max_compute_workgroups_per_dimension =
d3d11::D3D11_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION;
let limits = wgt::Limits {
max_texture_dimension_1d: max_texture_dimension_2d,
max_texture_dimension_2d,
max_texture_dimension_3d,
max_texture_array_layers: max_texture_dimension_3d,
max_bind_groups: u32::MAX,
max_bindings_per_bind_group: 65535,
max_dynamic_uniform_buffers_per_pipeline_layout: max_constant_buffers,
max_dynamic_storage_buffers_per_pipeline_layout: 0,
max_sampled_textures_per_shader_stage: max_sampled_textures,
max_samplers_per_shader_stage: max_samplers,
max_storage_buffers_per_shader_stage: max_uavs,
max_storage_textures_per_shader_stage: max_uavs,
max_uniform_buffers_per_shader_stage: max_constant_buffers,
max_uniform_buffer_binding_size: 1 << 16,
max_storage_buffer_binding_size: u32::MAX,
max_vertex_buffers,
max_vertex_attributes: max_vertex_buffers,
max_vertex_buffer_array_stride: u32::MAX,
max_push_constant_size: 1 << 16,
min_uniform_buffer_offset_alignment: 256,
min_storage_buffer_offset_alignment: 1,
max_inter_stage_shader_components: max_output_registers,
max_compute_workgroup_storage_size,
max_compute_invocations_per_workgroup,
max_compute_workgroup_size_x: max_workgroup_size_xy,
max_compute_workgroup_size_y: max_workgroup_size_xy,
max_compute_workgroup_size_z: max_workgroup_size_z,
max_compute_workgroups_per_dimension,
// D3D11_BUFFER_DESC represents the buffer size as a 32 bit int.
max_buffer_size: u32::MAX as u64,
max_non_sampler_bindings: u32::MAX,
};
//
// Other capabilities
//
let shader_model = match feature_level {
FL9_1..=FL9_3 => wgt::ShaderModel::Sm2,
FL10_0 | FL10_1 => wgt::ShaderModel::Sm4,
_ => wgt::ShaderModel::Sm5,
};
let device_info = wgt::AdapterInfo {
name: String::new(),
vendor: 0,
device: 0,
device_type: match d3d11_features2.UnifiedMemoryArchitecture {
0 => wgt::DeviceType::DiscreteGpu,
1 => wgt::DeviceType::IntegratedGpu,
_ => unreachable!(),
},
driver: String::new(),
driver_info: String::new(),
backend: wgt::Backend::Dx11,
};
//
// Build up the structs
//
let api_adapter = super::Adapter { device };
let alignments = crate::Alignments {
buffer_copy_offset: NonZeroU64::new(1).unwrap(), // todo
buffer_copy_pitch: NonZeroU64::new(1).unwrap(), // todo
};
let capabilities = crate::Capabilities {
limits,
alignments,
downlevel: wgt::DownlevelCapabilities {
flags: downlevel,
limits: wgt::DownlevelLimits {},
shader_model,
},
};
Some(crate::ExposedAdapter {
adapter: api_adapter,
info: device_info,
features,
capabilities,
})
}
}

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

@ -1,271 +0,0 @@
impl crate::CommandEncoder<super::Api> for super::CommandEncoder {
unsafe fn begin_encoding(&mut self, label: crate::Label) -> Result<(), crate::DeviceError> {
todo!()
}
unsafe fn discard_encoding(&mut self) {
todo!()
}
unsafe fn end_encoding(&mut self) -> Result<super::CommandBuffer, crate::DeviceError> {
todo!()
}
unsafe fn reset_all<I>(&mut self, command_buffers: I)
where
I: Iterator<Item = super::CommandBuffer>,
{
todo!()
}
unsafe fn transition_buffers<'a, T>(&mut self, barriers: T)
where
T: Iterator<Item = crate::BufferBarrier<'a, super::Api>>,
{
todo!()
}
unsafe fn transition_textures<'a, T>(&mut self, barriers: T)
where
T: Iterator<Item = crate::TextureBarrier<'a, super::Api>>,
{
todo!()
}
unsafe fn clear_buffer(&mut self, buffer: &super::Buffer, range: crate::MemoryRange) {
todo!()
}
unsafe fn copy_buffer_to_buffer<T>(
&mut self,
src: &super::Buffer,
dst: &super::Buffer,
regions: T,
) where
T: Iterator<Item = crate::BufferCopy>,
{
todo!()
}
unsafe fn copy_texture_to_texture<T>(
&mut self,
src: &super::Texture,
src_usage: crate::TextureUses,
dst: &super::Texture,
regions: T,
) where
T: Iterator<Item = crate::TextureCopy>,
{
todo!()
}
unsafe fn copy_buffer_to_texture<T>(
&mut self,
src: &super::Buffer,
dst: &super::Texture,
regions: T,
) where
T: Iterator<Item = crate::BufferTextureCopy>,
{
todo!()
}
unsafe fn copy_texture_to_buffer<T>(
&mut self,
src: &super::Texture,
src_usage: crate::TextureUses,
dst: &super::Buffer,
regions: T,
) where
T: Iterator<Item = crate::BufferTextureCopy>,
{
todo!()
}
unsafe fn set_bind_group(
&mut self,
layout: &super::PipelineLayout,
index: u32,
group: &super::BindGroup,
dynamic_offsets: &[wgt::DynamicOffset],
) {
todo!()
}
unsafe fn set_push_constants(
&mut self,
layout: &super::PipelineLayout,
stages: wgt::ShaderStages,
offset_bytes: u32,
data: &[u32],
) {
todo!()
}
unsafe fn insert_debug_marker(&mut self, label: &str) {
todo!()
}
unsafe fn begin_debug_marker(&mut self, group_label: &str) {
todo!()
}
unsafe fn end_debug_marker(&mut self) {
todo!()
}
unsafe fn begin_query(&mut self, set: &super::QuerySet, index: u32) {
todo!()
}
unsafe fn end_query(&mut self, set: &super::QuerySet, index: u32) {
todo!()
}
unsafe fn write_timestamp(&mut self, set: &super::QuerySet, index: u32) {
todo!()
}
unsafe fn reset_queries(&mut self, set: &super::QuerySet, range: std::ops::Range<u32>) {
todo!()
}
unsafe fn copy_query_results(
&mut self,
set: &super::QuerySet,
range: std::ops::Range<u32>,
buffer: &super::Buffer,
offset: wgt::BufferAddress,
stride: wgt::BufferSize,
) {
todo!()
}
unsafe fn begin_render_pass(&mut self, desc: &crate::RenderPassDescriptor<super::Api>) {
todo!()
}
unsafe fn end_render_pass(&mut self) {
todo!()
}
unsafe fn set_render_pipeline(&mut self, pipeline: &super::RenderPipeline) {
todo!()
}
unsafe fn set_index_buffer<'a>(
&mut self,
binding: crate::BufferBinding<'a, super::Api>,
format: wgt::IndexFormat,
) {
todo!()
}
unsafe fn set_vertex_buffer<'a>(
&mut self,
index: u32,
binding: crate::BufferBinding<'a, super::Api>,
) {
todo!()
}
unsafe fn set_viewport(&mut self, rect: &crate::Rect<f32>, depth_range: std::ops::Range<f32>) {
todo!()
}
unsafe fn set_scissor_rect(&mut self, rect: &crate::Rect<u32>) {
todo!()
}
unsafe fn set_stencil_reference(&mut self, value: u32) {
todo!()
}
unsafe fn set_blend_constants(&mut self, color: &[f32; 4]) {
todo!()
}
unsafe fn draw(
&mut self,
first_vertex: u32,
vertex_count: u32,
first_instance: u32,
instance_count: u32,
) {
todo!()
}
unsafe fn draw_indexed(
&mut self,
first_index: u32,
index_count: u32,
base_vertex: i32,
first_instance: u32,
instance_count: u32,
) {
todo!()
}
unsafe fn draw_indirect(
&mut self,
buffer: &super::Buffer,
offset: wgt::BufferAddress,
draw_count: u32,
) {
todo!()
}
unsafe fn draw_indexed_indirect(
&mut self,
buffer: &super::Buffer,
offset: wgt::BufferAddress,
draw_count: u32,
) {
todo!()
}
unsafe fn draw_indirect_count(
&mut self,
buffer: &super::Buffer,
offset: wgt::BufferAddress,
count_buffer: &super::Buffer,
count_offset: wgt::BufferAddress,
max_count: u32,
) {
todo!()
}
unsafe fn draw_indexed_indirect_count(
&mut self,
buffer: &super::Buffer,
offset: wgt::BufferAddress,
count_buffer: &super::Buffer,
count_offset: wgt::BufferAddress,
max_count: u32,
) {
todo!()
}
unsafe fn begin_compute_pass<'a>(
&mut self,
desc: &crate::ComputePassDescriptor<'a, super::Api>,
) {
todo!()
}
unsafe fn end_compute_pass(&mut self) {
todo!()
}
unsafe fn set_compute_pipeline(&mut self, pipeline: &super::ComputePipeline) {
todo!()
}
unsafe fn dispatch(&mut self, count: [u32; 3]) {
todo!()
}
unsafe fn dispatch_indirect(&mut self, buffer: &super::Buffer, offset: wgt::BufferAddress) {
todo!()
}
}

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

@ -1,242 +0,0 @@
use std::{ffi::c_void, mem};
use winapi::um::d3d11;
use crate::auxil::dxgi::result::HResult;
impl crate::Device<super::Api> for super::Device {
unsafe fn exit(self, queue: super::Queue) {
todo!()
}
unsafe fn create_buffer(
&self,
desc: &crate::BufferDescriptor,
) -> Result<super::Buffer, crate::DeviceError> {
todo!()
}
unsafe fn destroy_buffer(&self, buffer: super::Buffer) {
todo!()
}
unsafe fn map_buffer(
&self,
buffer: &super::Buffer,
range: crate::MemoryRange,
) -> Result<crate::BufferMapping, crate::DeviceError> {
todo!()
}
unsafe fn unmap_buffer(&self, buffer: &super::Buffer) -> Result<(), crate::DeviceError> {
todo!()
}
unsafe fn flush_mapped_ranges<I>(&self, buffer: &super::Buffer, ranges: I)
where
I: Iterator<Item = crate::MemoryRange>,
{
todo!()
}
unsafe fn invalidate_mapped_ranges<I>(&self, buffer: &super::Buffer, ranges: I)
where
I: Iterator<Item = crate::MemoryRange>,
{
todo!()
}
unsafe fn create_texture(
&self,
desc: &crate::TextureDescriptor,
) -> Result<super::Texture, crate::DeviceError> {
todo!()
}
unsafe fn destroy_texture(&self, texture: super::Texture) {
todo!()
}
unsafe fn create_texture_view(
&self,
texture: &super::Texture,
desc: &crate::TextureViewDescriptor,
) -> Result<super::TextureView, crate::DeviceError> {
todo!()
}
unsafe fn destroy_texture_view(&self, view: super::TextureView) {
todo!()
}
unsafe fn create_sampler(
&self,
desc: &crate::SamplerDescriptor,
) -> Result<super::Sampler, crate::DeviceError> {
todo!()
}
unsafe fn destroy_sampler(&self, sampler: super::Sampler) {
todo!()
}
unsafe fn create_command_encoder(
&self,
desc: &crate::CommandEncoderDescriptor<super::Api>,
) -> Result<super::CommandEncoder, crate::DeviceError> {
todo!()
}
unsafe fn destroy_command_encoder(&self, pool: super::CommandEncoder) {
todo!()
}
unsafe fn create_bind_group_layout(
&self,
desc: &crate::BindGroupLayoutDescriptor,
) -> Result<super::BindGroupLayout, crate::DeviceError> {
todo!()
}
unsafe fn destroy_bind_group_layout(&self, bg_layout: super::BindGroupLayout) {
todo!()
}
unsafe fn create_pipeline_layout(
&self,
desc: &crate::PipelineLayoutDescriptor<super::Api>,
) -> Result<super::PipelineLayout, crate::DeviceError> {
todo!()
}
unsafe fn destroy_pipeline_layout(&self, pipeline_layout: super::PipelineLayout) {
todo!()
}
unsafe fn create_bind_group(
&self,
desc: &crate::BindGroupDescriptor<super::Api>,
) -> Result<super::BindGroup, crate::DeviceError> {
todo!()
}
unsafe fn destroy_bind_group(&self, group: super::BindGroup) {
todo!()
}
unsafe fn create_shader_module(
&self,
desc: &crate::ShaderModuleDescriptor,
shader: crate::ShaderInput,
) -> Result<super::ShaderModule, crate::ShaderError> {
todo!()
}
unsafe fn destroy_shader_module(&self, module: super::ShaderModule) {
todo!()
}
unsafe fn create_render_pipeline(
&self,
desc: &crate::RenderPipelineDescriptor<super::Api>,
) -> Result<super::RenderPipeline, crate::PipelineError> {
todo!()
}
unsafe fn destroy_render_pipeline(&self, pipeline: super::RenderPipeline) {
todo!()
}
unsafe fn create_compute_pipeline(
&self,
desc: &crate::ComputePipelineDescriptor<super::Api>,
) -> Result<super::ComputePipeline, crate::PipelineError> {
todo!()
}
unsafe fn destroy_compute_pipeline(&self, pipeline: super::ComputePipeline) {
todo!()
}
unsafe fn create_query_set(
&self,
desc: &wgt::QuerySetDescriptor<crate::Label>,
) -> Result<super::QuerySet, crate::DeviceError> {
todo!()
}
unsafe fn destroy_query_set(&self, set: super::QuerySet) {
todo!()
}
unsafe fn create_fence(&self) -> Result<super::Fence, crate::DeviceError> {
todo!()
}
unsafe fn destroy_fence(&self, fence: super::Fence) {
todo!()
}
unsafe fn get_fence_value(
&self,
fence: &super::Fence,
) -> Result<crate::FenceValue, crate::DeviceError> {
todo!()
}
unsafe fn wait(
&self,
fence: &super::Fence,
value: crate::FenceValue,
timeout_ms: u32,
) -> Result<bool, crate::DeviceError> {
todo!()
}
unsafe fn start_capture(&self) -> bool {
todo!()
}
unsafe fn stop_capture(&self) {
todo!()
}
}
impl crate::Queue<super::Api> for super::Queue {
unsafe fn submit(
&self,
command_buffers: &[&super::CommandBuffer],
signal_fence: Option<(&mut super::Fence, crate::FenceValue)>,
) -> Result<(), crate::DeviceError> {
todo!()
}
unsafe fn present(
&self,
surface: &super::Surface,
texture: super::SurfaceTexture,
) -> Result<(), crate::SurfaceError> {
todo!()
}
unsafe fn get_timestamp_period(&self) -> f32 {
todo!()
}
}
impl super::D3D11Device {
#[allow(trivial_casts)] // come on
pub unsafe fn check_feature_support<T>(&self, feature: d3d11::D3D11_FEATURE) -> T {
unsafe {
let mut value = mem::zeroed::<T>();
let ret = self.CheckFeatureSupport(
feature,
&mut value as *mut T as *mut c_void,
mem::size_of::<T>() as u32,
);
assert_eq!(ret.into_result(), Ok(()));
value
}
}
}

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

@ -1,53 +0,0 @@
use crate::auxil;
impl crate::Instance<super::Api> for super::Instance {
unsafe fn init(desc: &crate::InstanceDescriptor) -> Result<Self, crate::InstanceError> {
profiling::scope!("Init DX11 Backend");
let enable_dx11 = match std::env::var("WGPU_UNSTABLE_DX11_BACKEND") {
Ok(string) => string == "1" || string == "true",
Err(_) => false,
};
if !enable_dx11 {
return Err(crate::InstanceError::new(String::from(
"DX11 support is unstable; set WGPU_UNSTABLE_DX11_BACKEND=1 to enable anyway",
)));
}
let lib_d3d11 = super::library::D3D11Lib::new()
.ok_or_else(|| crate::InstanceError::new(String::from("failed to load d3d11.dll")))?;
let (lib_dxgi, factory) = auxil::dxgi::factory::create_factory(
auxil::dxgi::factory::DxgiFactoryType::Factory1,
desc.flags,
)?;
Ok(super::Instance {
lib_d3d11,
lib_dxgi,
factory,
})
}
unsafe fn create_surface(
&self,
display_handle: raw_window_handle::RawDisplayHandle,
window_handle: raw_window_handle::RawWindowHandle,
) -> Result<super::Surface, crate::InstanceError> {
todo!()
}
unsafe fn destroy_surface(&self, surface: super::Surface) {
todo!()
}
unsafe fn enumerate_adapters(&self) -> Vec<crate::ExposedAdapter<super::Api>> {
let adapters = auxil::dxgi::factory::enumerate_adapters(self.factory.clone());
adapters
.into_iter()
.filter_map(|adapter| super::Adapter::expose(&self.lib_d3d11, adapter))
.collect()
}
}

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

@ -1,142 +0,0 @@
use std::ptr;
use winapi::{
shared::{
dxgi,
minwindef::{HMODULE, UINT},
winerror,
},
um::{d3d11, d3d11_1, d3d11_2, d3dcommon},
};
use crate::auxil::dxgi::result::HResult;
type D3D11CreateDeviceFun = unsafe extern "system" fn(
*mut dxgi::IDXGIAdapter,
d3dcommon::D3D_DRIVER_TYPE,
HMODULE,
UINT,
*const d3dcommon::D3D_FEATURE_LEVEL,
UINT,
UINT,
*mut *mut d3d11::ID3D11Device,
*mut d3dcommon::D3D_FEATURE_LEVEL,
*mut *mut d3d11::ID3D11DeviceContext,
) -> d3d12::HRESULT;
pub(super) struct D3D11Lib {
// We use the os specific symbol to drop the lifetime parameter.
//
// SAFETY: we must ensure this outlives the Library.
d3d11_create_device: libloading::os::windows::Symbol<D3D11CreateDeviceFun>,
lib: libloading::Library,
}
impl D3D11Lib {
pub fn new() -> Option<Self> {
unsafe {
let lib = libloading::Library::new("d3d11.dll").ok()?;
let d3d11_create_device = lib
.get::<D3D11CreateDeviceFun>(b"D3D11CreateDevice")
.ok()?
.into_raw();
Some(Self {
lib,
d3d11_create_device,
})
}
}
pub fn create_device(
&self,
adapter: d3d12::DxgiAdapter,
) -> Option<(super::D3D11Device, d3dcommon::D3D_FEATURE_LEVEL)> {
let feature_levels = [
d3dcommon::D3D_FEATURE_LEVEL_11_1,
d3dcommon::D3D_FEATURE_LEVEL_11_0,
d3dcommon::D3D_FEATURE_LEVEL_10_1,
d3dcommon::D3D_FEATURE_LEVEL_10_0,
d3dcommon::D3D_FEATURE_LEVEL_9_3,
d3dcommon::D3D_FEATURE_LEVEL_9_2,
d3dcommon::D3D_FEATURE_LEVEL_9_1,
];
let mut device = d3d12::ComPtr::<d3d11::ID3D11Device>::null();
let mut feature_level: d3dcommon::D3D_FEATURE_LEVEL = 0;
// We need to try this twice. If the first time fails due to E_INVALIDARG
// we are running on a machine without a D3D11.1 runtime, and need to
// retry without the feature level 11_1 feature level.
//
// Why they thought this was a good API, who knows.
let mut hr = unsafe {
(self.d3d11_create_device)(
adapter.as_mut_ptr() as *mut _,
d3dcommon::D3D_DRIVER_TYPE_UNKNOWN,
ptr::null_mut(), // software implementation DLL???
0, // flags
feature_levels.as_ptr(),
feature_levels.len() as u32,
d3d11::D3D11_SDK_VERSION,
device.mut_self(),
&mut feature_level,
ptr::null_mut(), // device context
)
};
// Try again without FL11_1
if hr == winerror::E_INVALIDARG {
hr = unsafe {
(self.d3d11_create_device)(
adapter.as_mut_ptr() as *mut _,
d3dcommon::D3D_DRIVER_TYPE_UNKNOWN,
ptr::null_mut(), // software implementation DLL???
0, // flags
feature_levels[1..].as_ptr(),
feature_levels[1..].len() as u32,
d3d11::D3D11_SDK_VERSION,
device.mut_self(),
&mut feature_level,
ptr::null_mut(), // device context
)
};
}
// Any errors here are real and we should complain about
if let Err(err) = hr.into_result() {
log::error!("Failed to make a D3D11 device: {}", err);
return None;
}
// We always try to upcast in highest -> lowest order
// Device -> Device2
unsafe {
match device.cast::<d3d11_2::ID3D11Device2>().into_result() {
Ok(device2) => {
return Some((super::D3D11Device::Device2(device2), feature_level));
}
Err(hr) => {
log::warn!("Failed to cast device to ID3D11Device2: {}", hr)
}
}
}
// Device -> Device1
unsafe {
match device.cast::<d3d11_1::ID3D11Device1>().into_result() {
Ok(device1) => {
return Some((super::D3D11Device::Device1(device1), feature_level));
}
Err(hr) => {
log::warn!("Failed to cast device to ID3D11Device1: {}", hr)
}
}
}
Some((super::D3D11Device::Device(device), feature_level))
}
}

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

@ -1,139 +0,0 @@
#![allow(dead_code)]
#![allow(unused_variables)]
use winapi::um::{d3d11, d3d11_1, d3d11_2};
mod adapter;
mod command;
mod device;
mod instance;
mod library;
#[derive(Clone, Debug)]
pub struct Api;
impl crate::Api for Api {
type Instance = Instance;
type Surface = Surface;
type Adapter = Adapter;
type Device = Device;
type Queue = Queue;
type CommandEncoder = CommandEncoder;
type CommandBuffer = CommandBuffer;
type Buffer = Buffer;
type Texture = Texture;
type SurfaceTexture = SurfaceTexture;
type TextureView = TextureView;
type Sampler = Sampler;
type QuerySet = QuerySet;
type Fence = Fence;
type BindGroupLayout = BindGroupLayout;
type BindGroup = BindGroup;
type PipelineLayout = PipelineLayout;
type ShaderModule = ShaderModule;
type RenderPipeline = RenderPipeline;
type ComputePipeline = ComputePipeline;
}
pub struct Instance {
lib_d3d11: library::D3D11Lib,
lib_dxgi: d3d12::DxgiLib,
factory: d3d12::DxgiFactory,
}
unsafe impl Send for Instance {}
unsafe impl Sync for Instance {}
pub struct Surface {}
pub struct Adapter {
device: D3D11Device,
}
unsafe impl Send for Adapter {}
unsafe impl Sync for Adapter {}
d3d12::weak_com_inheritance_chain! {
#[derive(Debug, Clone, PartialEq)]
enum D3D11Device {
Device(d3d11::ID3D11Device), from_device, as_device, device;
Device1(d3d11_1::ID3D11Device1), from_device1, as_device1, unwrap_device1;
Device2(d3d11_2::ID3D11Device2), from_device2, as_device2, unwrap_device2;
}
}
pub struct Device {}
unsafe impl Send for Device {}
unsafe impl Sync for Device {}
pub struct Queue {}
#[derive(Debug)]
pub struct CommandEncoder {}
#[derive(Debug)]
pub struct CommandBuffer {}
#[derive(Debug)]
pub struct Buffer {}
#[derive(Debug)]
pub struct Texture {}
#[derive(Debug)]
pub struct SurfaceTexture {}
impl std::borrow::Borrow<Texture> for SurfaceTexture {
fn borrow(&self) -> &Texture {
todo!()
}
}
#[derive(Debug)]
pub struct TextureView {}
#[derive(Debug)]
pub struct Sampler {}
#[derive(Debug)]
pub struct QuerySet {}
#[derive(Debug)]
pub struct Fence {}
#[derive(Debug)]
pub struct BindGroupLayout {}
#[derive(Debug)]
pub struct BindGroup {}
#[derive(Debug)]
pub struct PipelineLayout {}
#[derive(Debug)]
pub struct ShaderModule {}
#[derive(Debug)]
pub struct RenderPipeline {}
#[derive(Debug)]
pub struct ComputePipeline {}
impl crate::Surface<Api> for Surface {
unsafe fn configure(
&self,
device: &Device,
config: &crate::SurfaceConfiguration,
) -> Result<(), crate::SurfaceError> {
todo!()
}
unsafe fn unconfigure(&self, device: &Device) {
todo!()
}
unsafe fn acquire_texture(
&self,
_timeout: Option<std::time::Duration>,
) -> Result<Option<crate::AcquiredSurfaceTexture<Api>>, crate::SurfaceError> {
todo!()
}
unsafe fn discard_texture(&self, texture: SurfaceTexture) {
todo!()
}
}

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

@ -1192,4 +1192,24 @@ impl crate::CommandEncoder<super::Api> for super::CommandEncoder {
)
};
}
unsafe fn build_acceleration_structures<'a, T>(
&mut self,
_descriptor_count: u32,
_descriptors: T,
) where
super::Api: 'a,
T: IntoIterator<Item = crate::BuildAccelerationStructureDescriptor<'a, super::Api>>,
{
// Implement using `BuildRaytracingAccelerationStructure`:
// https://microsoft.github.io/DirectX-Specs/d3d/Raytracing.html#buildraytracingaccelerationstructure
todo!()
}
unsafe fn place_acceleration_structure_barrier(
&mut self,
_barriers: crate::AccelerationStructureBarrier,
) {
todo!()
}
}

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

@ -112,6 +112,7 @@ pub fn map_binding_type(ty: &wgt::BindingType) -> d3d12::DescriptorRangeType {
..
}
| Bt::StorageTexture { .. } => d3d12::DescriptorRangeType::UAV,
Bt::AccelerationStructure => todo!(),
}
}

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

@ -673,6 +673,7 @@ impl crate::Device<super::Api> for super::Device {
num_texture_views += count
}
wgt::BindingType::Sampler { .. } => num_samplers += count,
wgt::BindingType::AccelerationStructure => todo!(),
}
}
@ -1194,6 +1195,7 @@ impl crate::Device<super::Api> for super::Device {
cpu_samplers.as_mut().unwrap().stage.push(data.handle.raw);
}
}
wgt::BindingType::AccelerationStructure => todo!(),
}
}
@ -1573,4 +1575,38 @@ impl crate::Device<super::Api> for super::Device {
.end_frame_capture(self.raw.as_mut_ptr() as *mut _, ptr::null_mut())
}
}
unsafe fn get_acceleration_structure_build_sizes<'a>(
&self,
_desc: &crate::GetAccelerationStructureBuildSizesDescriptor<'a, super::Api>,
) -> crate::AccelerationStructureBuildSizes {
// Implement using `GetRaytracingAccelerationStructurePrebuildInfo`:
// https://microsoft.github.io/DirectX-Specs/d3d/Raytracing.html#getraytracingaccelerationstructureprebuildinfo
todo!()
}
unsafe fn get_acceleration_structure_device_address(
&self,
_acceleration_structure: &super::AccelerationStructure,
) -> wgt::BufferAddress {
// Implement using `GetGPUVirtualAddress`:
// https://docs.microsoft.com/en-us/windows/win32/api/d3d12/nf-d3d12-id3d12resource-getgpuvirtualaddress
todo!()
}
unsafe fn create_acceleration_structure(
&self,
_desc: &crate::AccelerationStructureDescriptor,
) -> Result<super::AccelerationStructure, crate::DeviceError> {
// Create a D3D12 resource as per-usual.
todo!()
}
unsafe fn destroy_acceleration_structure(
&self,
_acceleration_structure: super::AccelerationStructure,
) {
// Destroy a D3D12 resource as per-usual.
todo!()
}
}

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

@ -82,6 +82,8 @@ impl crate::Api for Api {
type ShaderModule = ShaderModule;
type RenderPipeline = RenderPipeline;
type ComputePipeline = ComputePipeline;
type AccelerationStructure = AccelerationStructure;
}
// Limited by D3D12's root signature size of 64. Each element takes 1 or 2 entries.
@ -600,6 +602,9 @@ pub struct ComputePipeline {
unsafe impl Send for ComputePipeline {}
unsafe impl Sync for ComputePipeline {}
#[derive(Debug)]
pub struct AccelerationStructure {}
impl SwapChain {
unsafe fn release_resources(self) -> d3d12::ComPtr<dxgi1_4::IDXGISwapChain3> {
self.raw

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

@ -29,6 +29,7 @@ impl crate::Api for Api {
type Sampler = Resource;
type QuerySet = Resource;
type Fence = Resource;
type AccelerationStructure = Resource;
type BindGroupLayout = Resource;
type BindGroup = Resource;
@ -236,6 +237,25 @@ impl crate::Device<Api> for Context {
false
}
unsafe fn stop_capture(&self) {}
unsafe fn create_acceleration_structure(
&self,
desc: &crate::AccelerationStructureDescriptor,
) -> DeviceResult<Resource> {
Ok(Resource)
}
unsafe fn get_acceleration_structure_build_sizes<'a>(
&self,
_desc: &crate::GetAccelerationStructureBuildSizesDescriptor<'a, Api>,
) -> crate::AccelerationStructureBuildSizes {
Default::default()
}
unsafe fn get_acceleration_structure_device_address(
&self,
_acceleration_structure: &Resource,
) -> wgt::BufferAddress {
Default::default()
}
unsafe fn destroy_acceleration_structure(&self, _acceleration_structure: Resource) {}
}
impl crate::CommandEncoder<Api> for Encoder {
@ -410,4 +430,20 @@ impl crate::CommandEncoder<Api> for Encoder {
unsafe fn dispatch(&mut self, count: [u32; 3]) {}
unsafe fn dispatch_indirect(&mut self, buffer: &Resource, offset: wgt::BufferAddress) {}
unsafe fn build_acceleration_structures<'a, T>(
&mut self,
_descriptor_count: u32,
descriptors: T,
) where
Api: 'a,
T: IntoIterator<Item = crate::BuildAccelerationStructureDescriptor<'a, Api>>,
{
}
unsafe fn place_acceleration_structure_barrier(
&mut self,
_barriers: crate::AccelerationStructureBarrier,
) {
}
}

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

@ -219,10 +219,7 @@ impl super::Adapter {
log::debug!("Version: {}", version);
let full_ver = Self::parse_full_version(&version).ok();
let es_ver = full_ver
.is_none()
.then_some(())
.and_then(|_| Self::parse_version(&version).ok());
let es_ver = full_ver.map_or_else(|| Self::parse_version(&version).ok(), |_| None);
let web_gl = cfg!(target_arch = "wasm32");
if let Some(full_ver) = full_ver {
@ -556,6 +553,10 @@ impl super::Adapter {
|| extensions.contains("OES_texture_float_linear"),
);
if es_ver.is_none() {
features |= wgt::Features::POLYGON_MODE_LINE | wgt::Features::POLYGON_MODE_POINT;
}
// We *might* be able to emulate bgra8unorm-storage but currently don't attempt to.
let mut private_caps = super::PrivateCapabilities::empty();

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

@ -1166,4 +1166,22 @@ impl crate::CommandEncoder<super::Api> for super::CommandEncoder {
indirect_offset: offset,
});
}
unsafe fn build_acceleration_structures<'a, T>(
&mut self,
_descriptor_count: u32,
_descriptors: T,
) where
super::Api: 'a,
T: IntoIterator<Item = crate::BuildAccelerationStructureDescriptor<'a, super::Api>>,
{
unimplemented!()
}
unsafe fn place_acceleration_structure_barrier(
&mut self,
_barriers: crate::AccelerationStructureBarrier,
) {
unimplemented!()
}
}

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

@ -285,18 +285,6 @@ pub fn map_primitive_topology(topology: wgt::PrimitiveTopology) -> u32 {
}
pub(super) fn map_primitive_state(state: &wgt::PrimitiveState) -> super::PrimitiveState {
match state.polygon_mode {
wgt::PolygonMode::Fill => {}
wgt::PolygonMode::Line => panic!(
"{:?} is not enabled for this backend",
wgt::Features::POLYGON_MODE_LINE
),
wgt::PolygonMode::Point => panic!(
"{:?} is not enabled for this backend",
wgt::Features::POLYGON_MODE_POINT
),
}
super::PrimitiveState {
//Note: we are flipping the front face, so that
// the Y-flip in the generated GLSL keeps the same visibility.
@ -311,6 +299,11 @@ pub(super) fn map_primitive_state(state: &wgt::PrimitiveState) -> super::Primiti
None => 0,
},
unclipped_depth: state.unclipped_depth,
polygon_mode: match state.polygon_mode {
wgt::PolygonMode::Fill => glow::FILL,
wgt::PolygonMode::Line => glow::LINE,
wgt::PolygonMode::Point => glow::POINT,
},
}
}

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

@ -1125,6 +1125,7 @@ impl crate::Device<super::Api> for super::Device {
ty: wgt::BufferBindingType::Storage { .. },
..
} => &mut num_storage_buffers,
wgt::BindingType::AccelerationStructure => unimplemented!(),
};
binding_to_slot[entry.binding as usize] = *counter;
@ -1211,6 +1212,7 @@ impl crate::Device<super::Api> for super::Device {
format: format_desc.internal,
})
}
wgt::BindingType::AccelerationStructure => unimplemented!(),
};
contents.push(binding);
}
@ -1458,6 +1460,25 @@ impl crate::Device<super::Api> for super::Device {
.end_frame_capture(ptr::null_mut(), ptr::null_mut())
}
}
unsafe fn create_acceleration_structure(
&self,
_desc: &crate::AccelerationStructureDescriptor,
) -> Result<(), crate::DeviceError> {
unimplemented!()
}
unsafe fn get_acceleration_structure_build_sizes<'a>(
&self,
_desc: &crate::GetAccelerationStructureBuildSizesDescriptor<'a, super::Api>,
) -> crate::AccelerationStructureBuildSizes {
unimplemented!()
}
unsafe fn get_acceleration_structure_device_address(
&self,
_acceleration_structure: &(),
) -> wgt::BufferAddress {
unimplemented!()
}
unsafe fn destroy_acceleration_structure(&self, _acceleration_structure: ()) {}
}
#[cfg(all(

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

@ -153,6 +153,7 @@ impl crate::Api for Api {
type Sampler = Sampler;
type QuerySet = QuerySet;
type Fence = Fence;
type AccelerationStructure = ();
type BindGroupLayout = BindGroupLayout;
type BindGroup = BindGroup;
@ -736,6 +737,7 @@ struct PrimitiveState {
front_face: u32,
cull_face: u32,
unclipped_depth: bool,
polygon_mode: u32,
}
type InvalidatedAttachments = ArrayVec<u32, { crate::MAX_COLOR_ATTACHMENTS + 2 }>;

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

@ -1330,6 +1330,10 @@ impl super::Queue {
unsafe { gl.disable(glow::DEPTH_CLAMP) };
}
}
// POLYGON_MODE_LINE also implies POLYGON_MODE_POINT
if self.features.contains(wgt::Features::POLYGON_MODE_LINE) {
unsafe { gl.polygon_mode(glow::FRONT_AND_BACK, state.polygon_mode) };
}
}
C::SetBlendConstant(c) => {
unsafe { gl.blend_color(c[0], c[1], c[2], c[3]) };

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

@ -11,7 +11,7 @@
* General design direction is to follow the majority by the following weights:
* - wgpu-core: 1.5
* - primary backends (Vulkan/Metal/DX12): 1.0 each
* - secondary backends (DX11/GLES): 0.5 each
* - secondary backend (GLES): 0.5
*/
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
@ -51,9 +51,6 @@
clippy::pattern_type_mismatch,
)]
/// DirectX11 API internals.
#[cfg(all(feature = "dx11", windows))]
pub mod dx11;
/// DirectX12 API internals.
#[cfg(all(feature = "dx12", windows))]
pub mod dx12;
@ -71,8 +68,6 @@ pub mod vulkan;
pub mod auxil;
pub mod api {
#[cfg(all(feature = "dx11", windows))]
pub use super::dx11::Api as Dx11;
#[cfg(all(feature = "dx12", windows))]
pub use super::dx12::Api as Dx12;
pub use super::empty::Api as Empty;
@ -217,6 +212,8 @@ pub trait Api: Clone + fmt::Debug + Sized {
type ShaderModule: fmt::Debug + WasmNotSendSync;
type RenderPipeline: fmt::Debug + WasmNotSendSync;
type ComputePipeline: fmt::Debug + WasmNotSendSync;
type AccelerationStructure: fmt::Debug + WasmNotSendSync + 'static;
}
pub trait Instance<A: Api>: Sized + WasmNotSendSync {
@ -390,6 +387,23 @@ pub trait Device<A: Api>: WasmNotSendSync {
unsafe fn start_capture(&self) -> bool;
unsafe fn stop_capture(&self);
unsafe fn create_acceleration_structure(
&self,
desc: &AccelerationStructureDescriptor,
) -> Result<A::AccelerationStructure, DeviceError>;
unsafe fn get_acceleration_structure_build_sizes(
&self,
desc: &GetAccelerationStructureBuildSizesDescriptor<A>,
) -> AccelerationStructureBuildSizes;
unsafe fn get_acceleration_structure_device_address(
&self,
acceleration_structure: &A::AccelerationStructure,
) -> wgt::BufferAddress;
unsafe fn destroy_acceleration_structure(
&self,
acceleration_structure: A::AccelerationStructure,
);
}
pub trait Queue<A: Api>: WasmNotSendSync {
@ -618,6 +632,26 @@ pub trait CommandEncoder<A: Api>: WasmNotSendSync + fmt::Debug {
unsafe fn dispatch(&mut self, count: [u32; 3]);
unsafe fn dispatch_indirect(&mut self, buffer: &A::Buffer, offset: wgt::BufferAddress);
/// To get the required sizes for the buffer allocations use `get_acceleration_structure_build_sizes` per descriptor
/// All buffers must be synchronized externally
/// All buffer regions, which are written to may only be passed once per function call,
/// with the exception of updates in the same descriptor.
/// Consequences of this limitation:
/// - scratch buffers need to be unique
/// - a tlas can't be build in the same call with a blas it contains
unsafe fn build_acceleration_structures<'a, T>(
&mut self,
descriptor_count: u32,
descriptors: T,
) where
A: 'a,
T: IntoIterator<Item = BuildAccelerationStructureDescriptor<'a, A>>;
unsafe fn place_acceleration_structure_barrier(
&mut self,
barrier: AccelerationStructureBarrier,
);
}
bitflags!(
@ -778,12 +812,15 @@ bitflags::bitflags! {
const INDIRECT = 1 << 9;
/// A buffer used to store query results.
const QUERY_RESOLVE = 1 << 10;
const ACCELERATION_STRUCTURE_SCRATCH = 1 << 11;
const BOTTOM_LEVEL_ACCELERATION_STRUCTURE_INPUT = 1 << 12;
const TOP_LEVEL_ACCELERATION_STRUCTURE_INPUT = 1 << 13;
/// The combination of states that a buffer may be in _at the same time_.
const INCLUSIVE = Self::MAP_READ.bits() | Self::COPY_SRC.bits() |
Self::INDEX.bits() | Self::VERTEX.bits() | Self::UNIFORM.bits() |
Self::STORAGE_READ.bits() | Self::INDIRECT.bits();
Self::STORAGE_READ.bits() | Self::INDIRECT.bits() | Self::BOTTOM_LEVEL_ACCELERATION_STRUCTURE_INPUT.bits() | Self::TOP_LEVEL_ACCELERATION_STRUCTURE_INPUT.bits();
/// The combination of states that a buffer must exclusively be in.
const EXCLUSIVE = Self::MAP_WRITE.bits() | Self::COPY_DST.bits() | Self::STORAGE_READ_WRITE.bits();
const EXCLUSIVE = Self::MAP_WRITE.bits() | Self::COPY_DST.bits() | Self::STORAGE_READ_WRITE.bits() | Self::ACCELERATION_STRUCTURE_SCRATCH.bits();
/// The combination of all usages that the are guaranteed to be be ordered by the hardware.
/// If a usage is ordered, then if the buffer state doesn't change between draw calls, there
/// are no barriers needed for synchronization.
@ -1091,6 +1128,7 @@ pub struct BindGroupDescriptor<'a, A: Api> {
pub samplers: &'a [&'a A::Sampler],
pub textures: &'a [TextureBinding<'a, A>],
pub entries: &'a [BindGroupEntry],
pub acceleration_structures: &'a [&'a A::AccelerationStructure],
}
#[derive(Clone, Debug)]
@ -1422,3 +1460,134 @@ fn test_default_limits() {
let limits = wgt::Limits::default();
assert!(limits.max_bind_groups <= MAX_BIND_GROUPS as u32);
}
#[derive(Clone, Debug)]
pub struct AccelerationStructureDescriptor<'a> {
pub label: Label<'a>,
pub size: wgt::BufferAddress,
pub format: AccelerationStructureFormat,
}
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
pub enum AccelerationStructureFormat {
TopLevel,
BottomLevel,
}
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
pub enum AccelerationStructureBuildMode {
Build,
Update,
}
/// Information of the required size for a corresponding entries struct (+ flags)
#[derive(Copy, Clone, Debug, Default, Eq, PartialEq)]
pub struct AccelerationStructureBuildSizes {
pub acceleration_structure_size: wgt::BufferAddress,
pub update_scratch_size: wgt::BufferAddress,
pub build_scratch_size: wgt::BufferAddress,
}
/// Updates use source_acceleration_structure if present, else the update will be performed in place.
/// For updates, only the data is allowed to change (not the meta data or sizes).
#[derive(Clone, Debug)]
pub struct BuildAccelerationStructureDescriptor<'a, A: Api> {
pub entries: &'a AccelerationStructureEntries<'a, A>,
pub mode: AccelerationStructureBuildMode,
pub flags: AccelerationStructureBuildFlags,
pub source_acceleration_structure: Option<&'a A::AccelerationStructure>,
pub destination_acceleration_structure: &'a A::AccelerationStructure,
pub scratch_buffer: &'a A::Buffer,
pub scratch_buffer_offset: wgt::BufferAddress,
}
/// - All buffers, buffer addresses and offsets will be ignored.
/// - The build mode will be ignored.
/// - Reducing the amount of Instances, Triangle groups or AABB groups (or the number of Triangles/AABBs in corresponding groups),
/// may result in reduced size requirements.
/// - Any other change may result in a bigger or smaller size requirement.
#[derive(Clone, Debug)]
pub struct GetAccelerationStructureBuildSizesDescriptor<'a, A: Api> {
pub entries: &'a AccelerationStructureEntries<'a, A>,
pub flags: AccelerationStructureBuildFlags,
}
/// Entries for a single descriptor
/// * `Instances` - Multiple instances for a top level acceleration structure
/// * `Triangles` - Multiple triangle meshes for a bottom level acceleration structure
/// * `AABBs` - List of list of axis aligned bounding boxes for a bottom level acceleration structure
#[derive(Debug)]
pub enum AccelerationStructureEntries<'a, A: Api> {
Instances(AccelerationStructureInstances<'a, A>),
Triangles(Vec<AccelerationStructureTriangles<'a, A>>),
AABBs(Vec<AccelerationStructureAABBs<'a, A>>),
}
/// * `first_vertex` - offset in the vertex buffer (as number of vertices)
/// * `indices` - optional index buffer with attributes
/// * `transform` - optional transform
#[derive(Clone, Debug)]
pub struct AccelerationStructureTriangles<'a, A: Api> {
pub vertex_buffer: Option<&'a A::Buffer>,
pub vertex_format: wgt::VertexFormat,
pub first_vertex: u32,
pub vertex_count: u32,
pub vertex_stride: wgt::BufferAddress,
pub indices: Option<AccelerationStructureTriangleIndices<'a, A>>,
pub transform: Option<AccelerationStructureTriangleTransform<'a, A>>,
pub flags: AccelerationStructureGeometryFlags,
}
/// * `offset` - offset in bytes
#[derive(Clone, Debug)]
pub struct AccelerationStructureAABBs<'a, A: Api> {
pub buffer: Option<&'a A::Buffer>,
pub offset: u32,
pub count: u32,
pub stride: wgt::BufferAddress,
pub flags: AccelerationStructureGeometryFlags,
}
/// * `offset` - offset in bytes
#[derive(Clone, Debug)]
pub struct AccelerationStructureInstances<'a, A: Api> {
pub buffer: Option<&'a A::Buffer>,
pub offset: u32,
pub count: u32,
}
/// * `offset` - offset in bytes
#[derive(Clone, Debug)]
pub struct AccelerationStructureTriangleIndices<'a, A: Api> {
pub format: wgt::IndexFormat,
pub buffer: Option<&'a A::Buffer>,
pub offset: u32,
pub count: u32,
}
/// * `offset` - offset in bytes
#[derive(Clone, Debug)]
pub struct AccelerationStructureTriangleTransform<'a, A: Api> {
pub buffer: &'a A::Buffer,
pub offset: u32,
}
pub use wgt::AccelerationStructureFlags as AccelerationStructureBuildFlags;
pub use wgt::AccelerationStructureGeometryFlags;
bitflags::bitflags! {
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct AccelerationStructureUses: u8 {
// For blas used as input for tlas
const BUILD_INPUT = 1 << 0;
// Target for acceleration structure build
const BUILD_OUTPUT = 1 << 1;
// Tlas used in a shader
const SHADER_INPUT = 1 << 2;
}
}
#[derive(Debug, Clone)]
pub struct AccelerationStructureBarrier {
pub usage: Range<AccelerationStructureUses>,
}

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

@ -1216,6 +1216,24 @@ impl crate::CommandEncoder<super::Api> for super::CommandEncoder {
let encoder = self.state.compute.as_ref().unwrap();
encoder.dispatch_thread_groups_indirect(&buffer.raw, offset, self.state.raw_wg_size);
}
unsafe fn build_acceleration_structures<'a, T>(
&mut self,
_descriptor_count: u32,
_descriptors: T,
) where
super::Api: 'a,
T: IntoIterator<Item = crate::BuildAccelerationStructureDescriptor<'a, super::Api>>,
{
unimplemented!()
}
unsafe fn place_acceleration_structure_barrier(
&mut self,
_barriers: crate::AccelerationStructureBarrier,
) {
unimplemented!()
}
}
impl Drop for super::CommandEncoder {

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

@ -637,6 +637,7 @@ impl crate::Device<super::Api> for super::Device {
wgt::StorageTextureAccess::ReadWrite => true,
};
}
wgt::BindingType::AccelerationStructure => unimplemented!(),
}
let br = naga::ResourceBinding {
@ -768,6 +769,7 @@ impl crate::Device<super::Api> for super::Device {
);
counter.textures += size;
}
wgt::BindingType::AccelerationStructure => unimplemented!(),
}
}
}
@ -1218,4 +1220,32 @@ impl crate::Device<super::Api> for super::Device {
}
shared_capture_manager.stop_capture();
}
unsafe fn get_acceleration_structure_build_sizes(
&self,
_desc: &crate::GetAccelerationStructureBuildSizesDescriptor<super::Api>,
) -> crate::AccelerationStructureBuildSizes {
unimplemented!()
}
unsafe fn get_acceleration_structure_device_address(
&self,
_acceleration_structure: &super::AccelerationStructure,
) -> wgt::BufferAddress {
unimplemented!()
}
unsafe fn create_acceleration_structure(
&self,
_desc: &crate::AccelerationStructureDescriptor,
) -> Result<super::AccelerationStructure, crate::DeviceError> {
unimplemented!()
}
unsafe fn destroy_acceleration_structure(
&self,
_acceleration_structure: super::AccelerationStructure,
) {
unimplemented!()
}
}

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

@ -66,6 +66,8 @@ impl crate::Api for Api {
type ShaderModule = ShaderModule;
type RenderPipeline = RenderPipeline;
type ComputePipeline = ComputePipeline;
type AccelerationStructure = AccelerationStructure;
}
pub struct Instance {
@ -844,3 +846,6 @@ pub struct CommandBuffer {
unsafe impl Send for CommandBuffer {}
unsafe impl Sync for CommandBuffer {}
#[derive(Debug)]
pub struct AccelerationStructure;

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

@ -35,6 +35,9 @@ pub struct PhysicalDeviceFeatures {
vk::PhysicalDeviceShaderFloat16Int8Features,
vk::PhysicalDevice16BitStorageFeatures,
)>,
acceleration_structure: Option<vk::PhysicalDeviceAccelerationStructureFeaturesKHR>,
buffer_device_address: Option<vk::PhysicalDeviceBufferDeviceAddressFeaturesKHR>,
ray_query: Option<vk::PhysicalDeviceRayQueryFeaturesKHR>,
zero_initialize_workgroup_memory:
Option<vk::PhysicalDeviceZeroInitializeWorkgroupMemoryFeatures>,
}
@ -75,6 +78,15 @@ impl PhysicalDeviceFeatures {
if let Some(ref mut feature) = self.zero_initialize_workgroup_memory {
info = info.push_next(feature);
}
if let Some(ref mut feature) = self.acceleration_structure {
info = info.push_next(feature);
}
if let Some(ref mut feature) = self.buffer_device_address {
info = info.push_next(feature);
}
if let Some(ref mut feature) = self.ray_query {
info = info.push_next(feature);
}
info
}
@ -283,6 +295,37 @@ impl PhysicalDeviceFeatures {
} else {
None
},
acceleration_structure: if enabled_extensions
.contains(&vk::KhrAccelerationStructureFn::name())
{
Some(
vk::PhysicalDeviceAccelerationStructureFeaturesKHR::builder()
.acceleration_structure(true)
.build(),
)
} else {
None
},
buffer_device_address: if enabled_extensions
.contains(&vk::KhrBufferDeviceAddressFn::name())
{
Some(
vk::PhysicalDeviceBufferDeviceAddressFeaturesKHR::builder()
.buffer_device_address(true)
.build(),
)
} else {
None
},
ray_query: if enabled_extensions.contains(&vk::KhrRayQueryFn::name()) {
Some(
vk::PhysicalDeviceRayQueryFeaturesKHR::builder()
.ray_query(true)
.build(),
)
} else {
None
},
zero_initialize_workgroup_memory: if device_api_version >= vk::API_VERSION_1_3
|| enabled_extensions.contains(&vk::KhrZeroInitializeWorkgroupMemoryFn::name())
{
@ -520,6 +563,18 @@ impl PhysicalDeviceFeatures {
features.set(F::DEPTH32FLOAT_STENCIL8, texture_d32_s8);
features.set(
F::RAY_TRACING_ACCELERATION_STRUCTURE,
caps.supports_extension(vk::KhrDeferredHostOperationsFn::name())
&& caps.supports_extension(vk::KhrAccelerationStructureFn::name())
&& caps.supports_extension(vk::KhrBufferDeviceAddressFn::name()),
);
features.set(
F::RAY_QUERY,
caps.supports_extension(vk::KhrRayQueryFn::name()),
);
let rg11b10ufloat_renderable = supports_format(
instance,
phd,
@ -570,12 +625,13 @@ impl PhysicalDeviceFeatures {
}
/// Information gathered about a physical device capabilities.
#[derive(Default)]
#[derive(Default, Debug)]
pub struct PhysicalDeviceCapabilities {
supported_extensions: Vec<vk::ExtensionProperties>,
properties: vk::PhysicalDeviceProperties,
maintenance_3: Option<vk::PhysicalDeviceMaintenance3Properties>,
descriptor_indexing: Option<vk::PhysicalDeviceDescriptorIndexingPropertiesEXT>,
acceleration_structure: Option<vk::PhysicalDeviceAccelerationStructurePropertiesKHR>,
driver: Option<vk::PhysicalDeviceDriverPropertiesKHR>,
/// The device API version.
///
@ -706,6 +762,18 @@ impl PhysicalDeviceCapabilities {
extensions.push(vk::KhrDrawIndirectCountFn::name());
}
// Require `VK_KHR_deferred_host_operations`, `VK_KHR_acceleration_structure` and `VK_KHR_buffer_device_address` if the feature `RAY_TRACING` was requested
if requested_features.contains(wgt::Features::RAY_TRACING_ACCELERATION_STRUCTURE) {
extensions.push(vk::KhrDeferredHostOperationsFn::name());
extensions.push(vk::KhrAccelerationStructureFn::name());
extensions.push(vk::KhrBufferDeviceAddressFn::name());
}
// Require `VK_KHR_ray_query` if the associated feature was requested
if requested_features.contains(wgt::Features::RAY_QUERY) {
extensions.push(vk::KhrRayQueryFn::name());
}
// Require `VK_EXT_conservative_rasterization` if the associated feature was requested
if requested_features.contains(wgt::Features::CONSERVATIVE_RASTERIZATION) {
extensions.push(vk::ExtConservativeRasterizationFn::name());
@ -821,6 +889,9 @@ impl super::InstanceShared {
>= vk::API_VERSION_1_2
|| capabilities.supports_extension(vk::KhrDriverPropertiesFn::name());
let supports_acceleration_structure =
capabilities.supports_extension(vk::KhrAccelerationStructureFn::name());
let mut builder = vk::PhysicalDeviceProperties2KHR::builder();
if supports_maintenance3 {
capabilities.maintenance_3 =
@ -835,6 +906,13 @@ impl super::InstanceShared {
builder = builder.push_next(next);
}
if supports_acceleration_structure {
let next = capabilities
.acceleration_structure
.insert(vk::PhysicalDeviceAccelerationStructurePropertiesKHR::default());
builder = builder.push_next(next);
}
if supports_driver_properties {
let next = capabilities
.driver
@ -917,6 +995,12 @@ impl super::InstanceShared {
builder = builder.push_next(&mut next.0);
builder = builder.push_next(&mut next.1);
}
if capabilities.supports_extension(vk::KhrAccelerationStructureFn::name()) {
let next = features
.acceleration_structure
.insert(vk::PhysicalDeviceAccelerationStructureFeaturesKHR::default());
builder = builder.push_next(next);
}
// `VK_KHR_zero_initialize_workgroup_memory` is promoted to 1.3
if capabilities.device_api_version >= vk::API_VERSION_1_3
@ -993,13 +1077,6 @@ impl super::Instance {
phd_features.to_wgpu(&info, &self.shared.raw, phd, &phd_capabilities);
let mut workarounds = super::Workarounds::empty();
{
// see https://github.com/gfx-rs/gfx/issues/1930
let _is_windows_intel_dual_src_bug = cfg!(windows)
&& phd_capabilities.properties.vendor_id == db::intel::VENDOR
&& (phd_capabilities.properties.device_id & db::intel::DEVICE_KABY_LAKE_MASK
== db::intel::DEVICE_KABY_LAKE_MASK
|| phd_capabilities.properties.device_id & db::intel::DEVICE_SKY_LAKE_MASK
== db::intel::DEVICE_SKY_LAKE_MASK);
// TODO: only enable for particular devices
workarounds |= super::Workarounds::SEPARATE_ENTRY_POINTS;
workarounds.set(
@ -1259,6 +1336,22 @@ impl super::Adapter {
} else {
None
};
let ray_tracing_fns = if enabled_extensions.contains(&khr::AccelerationStructure::name())
&& enabled_extensions.contains(&khr::BufferDeviceAddress::name())
{
Some(super::RayTracingDeviceExtensionFunctions {
acceleration_structure: khr::AccelerationStructure::new(
&self.instance.raw,
&raw_device,
),
buffer_device_address: khr::BufferDeviceAddress::new(
&self.instance.raw,
&raw_device,
),
})
} else {
None
};
let naga_options = {
use naga::back::spv;
@ -1307,6 +1400,10 @@ impl super::Adapter {
capabilities.push(spv::Capability::StorageImageWriteWithoutFormat);
}
if features.contains(wgt::Features::RAY_QUERY) {
capabilities.push(spv::Capability::RayQueryKHR);
}
let mut flags = spv::WriterFlags::empty();
flags.set(
spv::WriterFlags::DEBUG,
@ -1374,6 +1471,7 @@ impl super::Adapter {
extension_fns: super::DeviceExtensionFunctions {
draw_indirect_count: indirect_count_fn,
timeline_semaphore: timeline_semaphore_fn,
ray_tracing: ray_tracing_fns,
},
vendor_id: self.phd_capabilities.properties.vendor_id,
timestamp_period: self.phd_capabilities.properties.limits.timestamp_period,
@ -1428,7 +1526,8 @@ impl super::Adapter {
size: memory_heap.size,
})
.collect(),
buffer_device_address: false,
buffer_device_address: enabled_extensions
.contains(&khr::BufferDeviceAddress::name()),
};
gpu_alloc::GpuAllocator::new(config, properties)
};

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

@ -414,6 +414,243 @@ impl crate::CommandEncoder<super::Api> for super::CommandEncoder {
};
}
unsafe fn build_acceleration_structures<'a, T>(&mut self, descriptor_count: u32, descriptors: T)
where
super::Api: 'a,
T: IntoIterator<Item = crate::BuildAccelerationStructureDescriptor<'a, super::Api>>,
{
const CAPACITY_OUTER: usize = 8;
const CAPACITY_INNER: usize = 1;
let descriptor_count = descriptor_count as usize;
let ray_tracing_functions = self
.device
.extension_fns
.ray_tracing
.as_ref()
.expect("Feature `RAY_TRACING` not enabled");
let get_device_address = |buffer: Option<&super::Buffer>| unsafe {
match buffer {
Some(buffer) => ray_tracing_functions
.buffer_device_address
.get_buffer_device_address(
&vk::BufferDeviceAddressInfo::builder().buffer(buffer.raw),
),
None => panic!("Buffers are required to build acceleration structures"),
}
};
// storage to all the data required for cmd_build_acceleration_structures
let mut ranges_storage = smallvec::SmallVec::<
[smallvec::SmallVec<[vk::AccelerationStructureBuildRangeInfoKHR; CAPACITY_INNER]>;
CAPACITY_OUTER],
>::with_capacity(descriptor_count);
let mut geometries_storage = smallvec::SmallVec::<
[smallvec::SmallVec<[vk::AccelerationStructureGeometryKHR; CAPACITY_INNER]>;
CAPACITY_OUTER],
>::with_capacity(descriptor_count);
// pointers to all the data required for cmd_build_acceleration_structures
let mut geometry_infos = smallvec::SmallVec::<
[vk::AccelerationStructureBuildGeometryInfoKHR; CAPACITY_OUTER],
>::with_capacity(descriptor_count);
let mut ranges_ptrs = smallvec::SmallVec::<
[&[vk::AccelerationStructureBuildRangeInfoKHR]; CAPACITY_OUTER],
>::with_capacity(descriptor_count);
for desc in descriptors {
let (geometries, ranges) = match *desc.entries {
crate::AccelerationStructureEntries::Instances(ref instances) => {
let instance_data = vk::AccelerationStructureGeometryInstancesDataKHR::builder(
)
.data(vk::DeviceOrHostAddressConstKHR {
device_address: get_device_address(instances.buffer),
});
let geometry = vk::AccelerationStructureGeometryKHR::builder()
.geometry_type(vk::GeometryTypeKHR::INSTANCES)
.geometry(vk::AccelerationStructureGeometryDataKHR {
instances: *instance_data,
});
let range = vk::AccelerationStructureBuildRangeInfoKHR::builder()
.primitive_count(instances.count)
.primitive_offset(instances.offset);
(smallvec::smallvec![*geometry], smallvec::smallvec![*range])
}
crate::AccelerationStructureEntries::Triangles(ref in_geometries) => {
let mut ranges = smallvec::SmallVec::<
[vk::AccelerationStructureBuildRangeInfoKHR; CAPACITY_INNER],
>::with_capacity(in_geometries.len());
let mut geometries = smallvec::SmallVec::<
[vk::AccelerationStructureGeometryKHR; CAPACITY_INNER],
>::with_capacity(in_geometries.len());
for triangles in in_geometries {
let mut triangle_data =
vk::AccelerationStructureGeometryTrianglesDataKHR::builder()
.vertex_data(vk::DeviceOrHostAddressConstKHR {
device_address: get_device_address(triangles.vertex_buffer),
})
.vertex_format(conv::map_vertex_format(triangles.vertex_format))
.max_vertex(triangles.vertex_count)
.vertex_stride(triangles.vertex_stride);
let mut range = vk::AccelerationStructureBuildRangeInfoKHR::builder();
if let Some(ref indices) = triangles.indices {
triangle_data = triangle_data
.index_data(vk::DeviceOrHostAddressConstKHR {
device_address: get_device_address(indices.buffer),
})
.index_type(conv::map_index_format(indices.format));
range = range
.primitive_count(indices.count / 3)
.primitive_offset(indices.offset)
.first_vertex(triangles.first_vertex);
} else {
range = range
.primitive_count(triangles.vertex_count)
.first_vertex(triangles.first_vertex);
}
if let Some(ref transform) = triangles.transform {
let transform_device_address = unsafe {
ray_tracing_functions
.buffer_device_address
.get_buffer_device_address(
&vk::BufferDeviceAddressInfo::builder()
.buffer(transform.buffer.raw),
)
};
triangle_data =
triangle_data.transform_data(vk::DeviceOrHostAddressConstKHR {
device_address: transform_device_address,
});
range = range.transform_offset(transform.offset);
}
let geometry = vk::AccelerationStructureGeometryKHR::builder()
.geometry_type(vk::GeometryTypeKHR::TRIANGLES)
.geometry(vk::AccelerationStructureGeometryDataKHR {
triangles: *triangle_data,
})
.flags(conv::map_acceleration_structure_geomety_flags(
triangles.flags,
));
geometries.push(*geometry);
ranges.push(*range);
}
(geometries, ranges)
}
crate::AccelerationStructureEntries::AABBs(ref in_geometries) => {
let mut ranges = smallvec::SmallVec::<
[vk::AccelerationStructureBuildRangeInfoKHR; CAPACITY_INNER],
>::with_capacity(in_geometries.len());
let mut geometries = smallvec::SmallVec::<
[vk::AccelerationStructureGeometryKHR; CAPACITY_INNER],
>::with_capacity(in_geometries.len());
for aabb in in_geometries {
let aabbs_data = vk::AccelerationStructureGeometryAabbsDataKHR::builder()
.data(vk::DeviceOrHostAddressConstKHR {
device_address: get_device_address(aabb.buffer),
})
.stride(aabb.stride);
let range = vk::AccelerationStructureBuildRangeInfoKHR::builder()
.primitive_count(aabb.count)
.primitive_offset(aabb.offset);
let geometry = vk::AccelerationStructureGeometryKHR::builder()
.geometry_type(vk::GeometryTypeKHR::AABBS)
.geometry(vk::AccelerationStructureGeometryDataKHR {
aabbs: *aabbs_data,
})
.flags(conv::map_acceleration_structure_geomety_flags(aabb.flags));
geometries.push(*geometry);
ranges.push(*range);
}
(geometries, ranges)
}
};
ranges_storage.push(ranges);
geometries_storage.push(geometries);
let scratch_device_address = unsafe {
ray_tracing_functions
.buffer_device_address
.get_buffer_device_address(
&vk::BufferDeviceAddressInfo::builder().buffer(desc.scratch_buffer.raw),
)
};
let ty = match *desc.entries {
crate::AccelerationStructureEntries::Instances(_) => {
vk::AccelerationStructureTypeKHR::TOP_LEVEL
}
_ => vk::AccelerationStructureTypeKHR::BOTTOM_LEVEL,
};
let mut geometry_info = vk::AccelerationStructureBuildGeometryInfoKHR::builder()
.ty(ty)
.mode(conv::map_acceleration_structure_build_mode(desc.mode))
.flags(conv::map_acceleration_structure_flags(desc.flags))
.dst_acceleration_structure(desc.destination_acceleration_structure.raw)
.scratch_data(vk::DeviceOrHostAddressKHR {
device_address: scratch_device_address + desc.scratch_buffer_offset,
});
if desc.mode == crate::AccelerationStructureBuildMode::Update {
geometry_info.src_acceleration_structure = desc
.source_acceleration_structure
.unwrap_or(desc.destination_acceleration_structure)
.raw;
}
geometry_infos.push(*geometry_info);
}
for (i, geometry_info) in geometry_infos.iter_mut().enumerate() {
geometry_info.geometry_count = geometries_storage[i].len() as u32;
geometry_info.p_geometries = geometries_storage[i].as_ptr();
ranges_ptrs.push(&ranges_storage[i]);
}
unsafe {
ray_tracing_functions
.acceleration_structure
.cmd_build_acceleration_structures(self.active, &geometry_infos, &ranges_ptrs);
}
}
unsafe fn place_acceleration_structure_barrier(
&mut self,
barrier: crate::AccelerationStructureBarrier,
) {
let (src_stage, src_access) =
conv::map_acceleration_structure_usage_to_barrier(barrier.usage.start);
let (dst_stage, dst_access) =
conv::map_acceleration_structure_usage_to_barrier(barrier.usage.end);
unsafe {
self.device.raw.cmd_pipeline_barrier(
self.active,
src_stage | vk::PipelineStageFlags::TOP_OF_PIPE,
dst_stage | vk::PipelineStageFlags::BOTTOM_OF_PIPE,
vk::DependencyFlags::empty(),
&[vk::MemoryBarrier::builder()
.src_access_mask(src_access)
.dst_access_mask(dst_access)
.build()],
&[],
&[],
)
};
}
// render
unsafe fn begin_render_pass(&mut self, desc: &crate::RenderPassDescriptor<super::Api>) {

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

@ -517,6 +517,16 @@ pub fn map_buffer_usage(usage: crate::BufferUses) -> vk::BufferUsageFlags {
if usage.contains(crate::BufferUses::INDIRECT) {
flags |= vk::BufferUsageFlags::INDIRECT_BUFFER;
}
if usage.contains(crate::BufferUses::ACCELERATION_STRUCTURE_SCRATCH) {
flags |= vk::BufferUsageFlags::STORAGE_BUFFER | vk::BufferUsageFlags::SHADER_DEVICE_ADDRESS;
}
if usage.intersects(
crate::BufferUses::BOTTOM_LEVEL_ACCELERATION_STRUCTURE_INPUT
| crate::BufferUses::TOP_LEVEL_ACCELERATION_STRUCTURE_INPUT,
) {
flags |= vk::BufferUsageFlags::ACCELERATION_STRUCTURE_BUILD_INPUT_READ_ONLY_KHR
| vk::BufferUsageFlags::SHADER_DEVICE_ADDRESS;
}
flags
}
@ -569,6 +579,15 @@ pub fn map_buffer_usage_to_barrier(
stages |= vk::PipelineStageFlags::DRAW_INDIRECT;
access |= vk::AccessFlags::INDIRECT_COMMAND_READ;
}
if usage.intersects(
crate::BufferUses::BOTTOM_LEVEL_ACCELERATION_STRUCTURE_INPUT
| crate::BufferUses::TOP_LEVEL_ACCELERATION_STRUCTURE_INPUT
| crate::BufferUses::ACCELERATION_STRUCTURE_SCRATCH,
) {
stages |= vk::PipelineStageFlags::ACCELERATION_STRUCTURE_BUILD_KHR;
access |= vk::AccessFlags::ACCELERATION_STRUCTURE_READ_KHR
| vk::AccessFlags::ACCELERATION_STRUCTURE_WRITE_KHR;
}
(stages, access)
}
@ -720,6 +739,7 @@ pub fn map_binding_type(ty: wgt::BindingType) -> vk::DescriptorType {
wgt::BindingType::Sampler { .. } => vk::DescriptorType::SAMPLER,
wgt::BindingType::Texture { .. } => vk::DescriptorType::SAMPLED_IMAGE,
wgt::BindingType::StorageTexture { .. } => vk::DescriptorType::STORAGE_IMAGE,
wgt::BindingType::AccelerationStructure => vk::DescriptorType::ACCELERATION_STRUCTURE_KHR,
}
}
@ -851,3 +871,95 @@ pub fn map_pipeline_statistics(
}
flags
}
pub fn map_acceleration_structure_format(
format: crate::AccelerationStructureFormat,
) -> vk::AccelerationStructureTypeKHR {
match format {
crate::AccelerationStructureFormat::TopLevel => vk::AccelerationStructureTypeKHR::TOP_LEVEL,
crate::AccelerationStructureFormat::BottomLevel => {
vk::AccelerationStructureTypeKHR::BOTTOM_LEVEL
}
}
}
pub fn map_acceleration_structure_build_mode(
format: crate::AccelerationStructureBuildMode,
) -> vk::BuildAccelerationStructureModeKHR {
match format {
crate::AccelerationStructureBuildMode::Build => {
vk::BuildAccelerationStructureModeKHR::BUILD
}
crate::AccelerationStructureBuildMode::Update => {
vk::BuildAccelerationStructureModeKHR::UPDATE
}
}
}
pub fn map_acceleration_structure_flags(
flags: crate::AccelerationStructureBuildFlags,
) -> vk::BuildAccelerationStructureFlagsKHR {
let mut vk_flags = vk::BuildAccelerationStructureFlagsKHR::empty();
if flags.contains(crate::AccelerationStructureBuildFlags::PREFER_FAST_TRACE) {
vk_flags |= vk::BuildAccelerationStructureFlagsKHR::PREFER_FAST_TRACE;
}
if flags.contains(crate::AccelerationStructureBuildFlags::PREFER_FAST_BUILD) {
vk_flags |= vk::BuildAccelerationStructureFlagsKHR::PREFER_FAST_BUILD;
}
if flags.contains(crate::AccelerationStructureBuildFlags::ALLOW_UPDATE) {
vk_flags |= vk::BuildAccelerationStructureFlagsKHR::ALLOW_UPDATE;
}
if flags.contains(crate::AccelerationStructureBuildFlags::LOW_MEMORY) {
vk_flags |= vk::BuildAccelerationStructureFlagsKHR::LOW_MEMORY;
}
if flags.contains(crate::AccelerationStructureBuildFlags::ALLOW_COMPACTION) {
vk_flags |= vk::BuildAccelerationStructureFlagsKHR::ALLOW_COMPACTION
}
vk_flags
}
pub fn map_acceleration_structure_geomety_flags(
flags: crate::AccelerationStructureGeometryFlags,
) -> vk::GeometryFlagsKHR {
let mut vk_flags = vk::GeometryFlagsKHR::empty();
if flags.contains(crate::AccelerationStructureGeometryFlags::OPAQUE) {
vk_flags |= vk::GeometryFlagsKHR::OPAQUE;
}
if flags.contains(crate::AccelerationStructureGeometryFlags::NO_DUPLICATE_ANY_HIT_INVOCATION) {
vk_flags |= vk::GeometryFlagsKHR::NO_DUPLICATE_ANY_HIT_INVOCATION;
}
vk_flags
}
pub fn map_acceleration_structure_usage_to_barrier(
usage: crate::AccelerationStructureUses,
) -> (vk::PipelineStageFlags, vk::AccessFlags) {
let mut stages = vk::PipelineStageFlags::empty();
let mut access = vk::AccessFlags::empty();
if usage.contains(crate::AccelerationStructureUses::BUILD_INPUT) {
stages |= vk::PipelineStageFlags::ACCELERATION_STRUCTURE_BUILD_KHR;
access |= vk::AccessFlags::ACCELERATION_STRUCTURE_READ_KHR;
}
if usage.contains(crate::AccelerationStructureUses::BUILD_OUTPUT) {
stages |= vk::PipelineStageFlags::ACCELERATION_STRUCTURE_BUILD_KHR;
access |= vk::AccessFlags::ACCELERATION_STRUCTURE_WRITE_KHR;
}
if usage.contains(crate::AccelerationStructureUses::SHADER_INPUT) {
stages |= vk::PipelineStageFlags::VERTEX_SHADER
| vk::PipelineStageFlags::FRAGMENT_SHADER
| vk::PipelineStageFlags::COMPUTE_SHADER;
access |= vk::AccessFlags::ACCELERATION_STRUCTURE_READ_KHR;
}
(stages, access)
}

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

@ -863,12 +863,21 @@ impl crate::Device<super::Api> for super::Device {
desc.memory_flags.contains(crate::MemoryFlags::TRANSIENT),
);
let alignment_mask = if desc.usage.intersects(
crate::BufferUses::TOP_LEVEL_ACCELERATION_STRUCTURE_INPUT
| crate::BufferUses::BOTTOM_LEVEL_ACCELERATION_STRUCTURE_INPUT,
) {
16
} else {
req.alignment
} - 1;
let block = unsafe {
self.mem_allocator.lock().alloc(
&*self.shared,
gpu_alloc::Request {
size: req.size,
align_mask: req.alignment - 1,
align_mask: alignment_mask,
usage: alloc_usage,
memory_types: req.memory_type_bits & self.valid_ash_memory_types,
},
@ -980,7 +989,7 @@ impl crate::Device<super::Api> for super::Device {
wgt_view_formats = desc.view_formats.clone();
wgt_view_formats.push(desc.format);
if self.shared.private_caps.image_format_list {
if self.shared.private_caps.image_format_list && !desc.format.is_multi_planar_format() {
vk_view_formats = desc
.view_formats
.iter()
@ -1256,6 +1265,9 @@ impl crate::Device<super::Api> for super::Device {
wgt::BindingType::StorageTexture { .. } => {
desc_count.storage_image += count;
}
wgt::BindingType::AccelerationStructure => {
desc_count.acceleration_structure += count;
}
}
}
@ -1430,6 +1442,10 @@ impl crate::Device<super::Api> for super::Device {
let mut buffer_infos = Vec::with_capacity(desc.buffers.len());
let mut sampler_infos = Vec::with_capacity(desc.samplers.len());
let mut image_infos = Vec::with_capacity(desc.textures.len());
let mut acceleration_structure_infos =
Vec::with_capacity(desc.acceleration_structures.len());
let mut raw_acceleration_structures =
Vec::with_capacity(desc.acceleration_structures.len());
for entry in desc.entries {
let (ty, size) = desc.layout.types[entry.binding as usize];
if size == 0 {
@ -1439,6 +1455,9 @@ impl crate::Device<super::Api> for super::Device {
.dst_set(*set.raw())
.dst_binding(entry.binding)
.descriptor_type(ty);
let mut extra_descriptor_count = 0;
write = match ty {
vk::DescriptorType::SAMPLER => {
let index = sampler_infos.len();
@ -1489,9 +1508,44 @@ impl crate::Device<super::Api> for super::Device {
));
write.buffer_info(&buffer_infos[index..])
}
vk::DescriptorType::ACCELERATION_STRUCTURE_KHR => {
let index = acceleration_structure_infos.len();
let start = entry.resource_index;
let end = start + entry.count;
let raw_start = raw_acceleration_structures.len();
raw_acceleration_structures.extend(
desc.acceleration_structures[start as usize..end as usize]
.iter()
.map(|acceleration_structure| acceleration_structure.raw),
);
let acceleration_structure_info =
vk::WriteDescriptorSetAccelerationStructureKHR::builder()
.acceleration_structures(&raw_acceleration_structures[raw_start..]);
// todo: Dereference the struct to get around lifetime issues. Safe as long as we never resize
// `raw_acceleration_structures`.
let acceleration_structure_info: vk::WriteDescriptorSetAccelerationStructureKHR = *acceleration_structure_info;
assert!(
index < desc.acceleration_structures.len(),
"Encountered more acceleration structures then expected"
);
acceleration_structure_infos.push(acceleration_structure_info);
extra_descriptor_count += 1;
write.push_next(&mut acceleration_structure_infos[index])
}
_ => unreachable!(),
};
writes.push(write.build());
let mut write = write.build();
write.descriptor_count += extra_descriptor_count;
writes.push(write);
}
unsafe { self.shared.raw.update_descriptor_sets(&writes, &[]) };
@ -2024,6 +2078,231 @@ impl crate::Device<super::Api> for super::Device {
}
}
}
unsafe fn get_acceleration_structure_build_sizes<'a>(
&self,
desc: &crate::GetAccelerationStructureBuildSizesDescriptor<'a, super::Api>,
) -> crate::AccelerationStructureBuildSizes {
const CAPACITY: usize = 8;
let ray_tracing_functions = self
.shared
.extension_fns
.ray_tracing
.as_ref()
.expect("Feature `RAY_TRACING` not enabled");
let (geometries, primitive_counts) = match *desc.entries {
crate::AccelerationStructureEntries::Instances(ref instances) => {
let instance_data = vk::AccelerationStructureGeometryInstancesDataKHR::default();
let geometry = vk::AccelerationStructureGeometryKHR::builder()
.geometry_type(vk::GeometryTypeKHR::INSTANCES)
.geometry(vk::AccelerationStructureGeometryDataKHR {
instances: instance_data,
});
(
smallvec::smallvec![*geometry],
smallvec::smallvec![instances.count],
)
}
crate::AccelerationStructureEntries::Triangles(ref in_geometries) => {
let mut primitive_counts =
smallvec::SmallVec::<[u32; CAPACITY]>::with_capacity(in_geometries.len());
let mut geometries = smallvec::SmallVec::<
[vk::AccelerationStructureGeometryKHR; CAPACITY],
>::with_capacity(in_geometries.len());
for triangles in in_geometries {
let mut triangle_data =
vk::AccelerationStructureGeometryTrianglesDataKHR::builder()
.vertex_format(conv::map_vertex_format(triangles.vertex_format))
.max_vertex(triangles.vertex_count)
.vertex_stride(triangles.vertex_stride);
let pritive_count = if let Some(ref indices) = triangles.indices {
triangle_data =
triangle_data.index_type(conv::map_index_format(indices.format));
indices.count / 3
} else {
triangles.vertex_count
};
let geometry = vk::AccelerationStructureGeometryKHR::builder()
.geometry_type(vk::GeometryTypeKHR::TRIANGLES)
.geometry(vk::AccelerationStructureGeometryDataKHR {
triangles: *triangle_data,
})
.flags(conv::map_acceleration_structure_geomety_flags(
triangles.flags,
));
geometries.push(*geometry);
primitive_counts.push(pritive_count);
}
(geometries, primitive_counts)
}
crate::AccelerationStructureEntries::AABBs(ref in_geometries) => {
let mut primitive_counts =
smallvec::SmallVec::<[u32; CAPACITY]>::with_capacity(in_geometries.len());
let mut geometries = smallvec::SmallVec::<
[vk::AccelerationStructureGeometryKHR; CAPACITY],
>::with_capacity(in_geometries.len());
for aabb in in_geometries {
let aabbs_data = vk::AccelerationStructureGeometryAabbsDataKHR::builder()
.stride(aabb.stride);
let geometry = vk::AccelerationStructureGeometryKHR::builder()
.geometry_type(vk::GeometryTypeKHR::AABBS)
.geometry(vk::AccelerationStructureGeometryDataKHR { aabbs: *aabbs_data })
.flags(conv::map_acceleration_structure_geomety_flags(aabb.flags));
geometries.push(*geometry);
primitive_counts.push(aabb.count);
}
(geometries, primitive_counts)
}
};
let ty = match *desc.entries {
crate::AccelerationStructureEntries::Instances(_) => {
vk::AccelerationStructureTypeKHR::TOP_LEVEL
}
_ => vk::AccelerationStructureTypeKHR::BOTTOM_LEVEL,
};
let geometry_info = vk::AccelerationStructureBuildGeometryInfoKHR::builder()
.ty(ty)
.flags(conv::map_acceleration_structure_flags(desc.flags))
.geometries(&geometries);
let raw = unsafe {
ray_tracing_functions
.acceleration_structure
.get_acceleration_structure_build_sizes(
vk::AccelerationStructureBuildTypeKHR::DEVICE,
&geometry_info,
&primitive_counts,
)
};
crate::AccelerationStructureBuildSizes {
acceleration_structure_size: raw.acceleration_structure_size,
update_scratch_size: raw.update_scratch_size,
build_scratch_size: raw.build_scratch_size,
}
}
unsafe fn get_acceleration_structure_device_address(
&self,
acceleration_structure: &super::AccelerationStructure,
) -> wgt::BufferAddress {
let ray_tracing_functions = self
.shared
.extension_fns
.ray_tracing
.as_ref()
.expect("Feature `RAY_TRACING` not enabled");
unsafe {
ray_tracing_functions
.acceleration_structure
.get_acceleration_structure_device_address(
&vk::AccelerationStructureDeviceAddressInfoKHR::builder()
.acceleration_structure(acceleration_structure.raw),
)
}
}
unsafe fn create_acceleration_structure(
&self,
desc: &crate::AccelerationStructureDescriptor,
) -> Result<super::AccelerationStructure, crate::DeviceError> {
let ray_tracing_functions = self
.shared
.extension_fns
.ray_tracing
.as_ref()
.expect("Feature `RAY_TRACING` not enabled");
let vk_buffer_info = vk::BufferCreateInfo::builder()
.size(desc.size)
.usage(vk::BufferUsageFlags::ACCELERATION_STRUCTURE_STORAGE_KHR)
.sharing_mode(vk::SharingMode::EXCLUSIVE);
unsafe {
let raw_buffer = self.shared.raw.create_buffer(&vk_buffer_info, None)?;
let req = self.shared.raw.get_buffer_memory_requirements(raw_buffer);
let block = self.mem_allocator.lock().alloc(
&*self.shared,
gpu_alloc::Request {
size: req.size,
align_mask: req.alignment - 1,
usage: gpu_alloc::UsageFlags::FAST_DEVICE_ACCESS,
memory_types: req.memory_type_bits & self.valid_ash_memory_types,
},
)?;
self.shared
.raw
.bind_buffer_memory(raw_buffer, *block.memory(), block.offset())?;
if let Some(label) = desc.label {
self.shared
.set_object_name(vk::ObjectType::BUFFER, raw_buffer, label);
}
let vk_info = vk::AccelerationStructureCreateInfoKHR::builder()
.buffer(raw_buffer)
.offset(0)
.size(desc.size)
.ty(conv::map_acceleration_structure_format(desc.format));
let raw_acceleration_structure = ray_tracing_functions
.acceleration_structure
.create_acceleration_structure(&vk_info, None)?;
if let Some(label) = desc.label {
self.shared.set_object_name(
vk::ObjectType::ACCELERATION_STRUCTURE_KHR,
raw_acceleration_structure,
label,
);
}
Ok(super::AccelerationStructure {
raw: raw_acceleration_structure,
buffer: raw_buffer,
block: Mutex::new(block),
})
}
}
unsafe fn destroy_acceleration_structure(
&self,
acceleration_structure: super::AccelerationStructure,
) {
let ray_tracing_functions = self
.shared
.extension_fns
.ray_tracing
.as_ref()
.expect("Feature `RAY_TRACING` not enabled");
unsafe {
ray_tracing_functions
.acceleration_structure
.destroy_acceleration_structure(acceleration_structure.raw, None);
self.shared
.raw
.destroy_buffer(acceleration_structure.buffer, None);
self.mem_allocator
.lock()
.dealloc(&*self.shared, acceleration_structure.block.into_inner());
}
}
}
impl From<gpu_alloc::AllocationError> for crate::DeviceError {

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

@ -72,6 +72,7 @@ impl crate::Api for Api {
type Sampler = Sampler;
type QuerySet = QuerySet;
type Fence = Fence;
type AccelerationStructure = AccelerationStructure;
type BindGroupLayout = BindGroupLayout;
type BindGroup = BindGroup;
@ -193,6 +194,12 @@ enum ExtensionFn<T> {
struct DeviceExtensionFunctions {
draw_indirect_count: Option<khr::DrawIndirectCount>,
timeline_semaphore: Option<ExtensionFn<khr::TimelineSemaphore>>,
ray_tracing: Option<RayTracingDeviceExtensionFunctions>,
}
struct RayTracingDeviceExtensionFunctions {
acceleration_structure: khr::AccelerationStructure,
buffer_device_address: khr::BufferDeviceAddress,
}
/// Set of internal capabilities, which don't show up in the exposed
@ -358,6 +365,13 @@ pub struct Buffer {
block: Option<Mutex<gpu_alloc::MemoryBlock<vk::DeviceMemory>>>,
}
#[derive(Debug)]
pub struct AccelerationStructure {
raw: vk::AccelerationStructureKHR,
buffer: vk::Buffer,
block: Mutex<gpu_alloc::MemoryBlock<vk::DeviceMemory>>,
}
#[derive(Debug)]
pub struct Texture {
raw: vk::Image,

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

@ -1 +1 @@
{"files":{"Cargo.toml":"18549fb7d7de2ea2481f30292dca63889856a33bd1b3698e16cee6631ab65df4","LICENSE.APACHE":"a6cba85bc92e0cff7a450b1d873c0eaa2e9fc96bf472df0247a26bec77bf3ff9","LICENSE.MIT":"c7fea58d1cfe49634cd92e54fc10a9d871f4b275321a4cd8c09e449122caaeb4","src/assertions.rs":"3fe98027aa73970c8ab7874a3e13dbfd6faa87df2081beb5c83aeec4c60f372f","src/lib.rs":"61f4f46533468f82e3d22e42d6e8b3d8b68504ccd4f9b4b9ea67b0664c42a34e","src/math.rs":"4d03039736dd6926feb139bc68734cb59df34ede310427bbf059e5c925e0af3b"},"package":null}
{"files":{"Cargo.toml":"18549fb7d7de2ea2481f30292dca63889856a33bd1b3698e16cee6631ab65df4","LICENSE.APACHE":"a6cba85bc92e0cff7a450b1d873c0eaa2e9fc96bf472df0247a26bec77bf3ff9","LICENSE.MIT":"c7fea58d1cfe49634cd92e54fc10a9d871f4b275321a4cd8c09e449122caaeb4","src/assertions.rs":"3fe98027aa73970c8ab7874a3e13dbfd6faa87df2081beb5c83aeec4c60f372f","src/lib.rs":"b115dcd6a14eac6fe5a2a13ede5c7becdfd741e25695c4cc2c12cfa1202887fd","src/math.rs":"4d03039736dd6926feb139bc68734cb59df34ede310427bbf059e5c925e0af3b"},"package":null}

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

@ -102,12 +102,10 @@ pub enum Backend {
Metal = 2,
/// Direct3D-12 (Windows)
Dx12 = 3,
/// Direct3D-11 (Windows)
Dx11 = 4,
/// OpenGL ES-3 (Linux, Android)
Gl = 5,
Gl = 4,
/// WebGPU in the browser
BrowserWebGpu = 6,
BrowserWebGpu = 5,
}
impl Backend {
@ -118,7 +116,6 @@ impl Backend {
Backend::Vulkan => "vulkan",
Backend::Metal => "metal",
Backend::Dx12 => "dx12",
Backend::Dx11 => "dx11",
Backend::Gl => "gl",
Backend::BrowserWebGpu => "webgpu",
}
@ -158,8 +155,6 @@ bitflags::bitflags! {
const METAL = 1 << Backend::Metal as u32;
/// Supported on Windows 10
const DX12 = 1 << Backend::Dx12 as u32;
/// Supported on Windows 7+
const DX11 = 1 << Backend::Dx11 as u32;
/// Supported when targeting the web through webassembly
const BROWSER_WEBGPU = 1 << Backend::BrowserWebGpu as u32;
/// All the apis that wgpu offers first tier of support for.
@ -172,8 +167,8 @@ bitflags::bitflags! {
/// All the apis that wgpu offers second tier of support for. These may
/// be unsupported/still experimental.
///
/// OpenGL + DX11
const SECONDARY = Self::GL.bits() | Self::DX11.bits();
/// OpenGL
const SECONDARY = Self::GL.bits();
}
}
@ -665,7 +660,6 @@ bitflags::bitflags! {
/// - DX12
/// - Vulkan
/// - Metal
/// - DX11 (emulated with uniforms)
/// - OpenGL (emulated with uniforms)
///
/// This is a native only feature.
@ -681,7 +675,6 @@ bitflags::bitflags! {
/// - DX12
/// - Vulkan
/// - Metal
/// - DX11
/// - OpenGL
///
/// This is a native only feature.
@ -693,7 +686,6 @@ bitflags::bitflags! {
/// - DX12
/// - Vulkan
/// - Metal (macOS 10.12+ only)
/// - DX11
/// - OpenGL
///
/// This is a native only feature.
@ -772,7 +764,6 @@ bitflags::bitflags! {
///
/// This is a native only feature.
const VERTEX_ATTRIBUTE_64BIT = 1 << 53;
/// Allows vertex shaders to have outputs which are not consumed
/// by the fragment shader.
///
@ -781,7 +772,6 @@ bitflags::bitflags! {
/// - Metal
/// - OpenGL
const SHADER_UNUSED_VERTEX_OUTPUT = 1 << 54;
/// Allows for creation of textures of format [`TextureFormat::NV12`]
///
/// Supported platforms:
@ -790,11 +780,25 @@ bitflags::bitflags! {
///
/// This is a native only feature.
const TEXTURE_FORMAT_NV12 = 1 << 55;
/// Allows for the creation of ray-tracing acceleration structures.
///
/// Supported platforms:
/// - Vulkan
///
/// This is a native-only feature.
const RAY_TRACING_ACCELERATION_STRUCTURE = 1 << 56;
// 55..59 available
// 57 available
// Shader:
/// Allows for the creation of ray-tracing queries within shaders.
///
/// Supported platforms:
/// - Vulkan
///
/// This is a native-only feature.
const RAY_QUERY = 1 << 58;
/// Enables 64-bit floating point types in SPIR-V shaders.
///
/// Note: even when supported by GPU hardware, 64-bit floating point operations are
@ -820,7 +824,6 @@ bitflags::bitflags! {
///
/// Supported platforms:
/// - Vulkan
/// - DX11 (feature level 10+)
/// - DX12
/// - Metal (some)
/// - OpenGL (some)
@ -834,7 +837,6 @@ bitflags::bitflags! {
///
/// This is a native only feature.
const SHADER_EARLY_DEPTH_TEST = 1 << 62;
/// Allows two outputs from a shader to be used for blending.
/// Note that dual-source blending doesn't support multiple render targets.
///
@ -1076,7 +1078,7 @@ pub struct Limits {
/// - Vulkan: 128-256 bytes
/// - DX12: 256 bytes
/// - Metal: 4096 bytes
/// - DX11 & OpenGL don't natively support push constants, and are emulated with uniforms,
/// - OpenGL doesn't natively support push constants, and are emulated with uniforms,
/// so this number is less useful but likely 256.
pub max_push_constant_size: u32,
@ -1421,13 +1423,13 @@ bitflags::bitflags! {
pub struct DownlevelFlags: u32 {
/// The device supports compiling and using compute shaders.
///
/// DX11 on FL10 level hardware, WebGL2, and GLES3.0 devices do not support compute.
/// WebGL2, and GLES3.0 devices do not support compute.
const COMPUTE_SHADERS = 1 << 0;
/// Supports binding storage buffers and textures to fragment shaders.
const FRAGMENT_WRITABLE_STORAGE = 1 << 1;
/// Supports indirect drawing and dispatching.
///
/// DX11 on FL10 level hardware, WebGL2, GLES 3.0, and Metal on Apple1/Apple2 GPUs do not support indirect.
/// WebGL2, GLES 3.0, and Metal on Apple1/Apple2 GPUs do not support indirect.
const INDIRECT_EXECUTION = 1 << 2;
/// Supports non-zero `base_vertex` parameter to direct indexed draw calls.
///
@ -2890,6 +2892,11 @@ impl TextureFormat {
}
}
/// Returns `true` if the format is a multi-planar format
pub fn is_multi_planar_format(&self) -> bool {
matches!(*self, Self::NV12)
}
/// Returns `true` if the format has a color aspect
pub fn has_color_aspect(&self) -> bool {
!self.is_depth_stencil_format()
@ -4927,7 +4934,7 @@ pub enum PresentMode {
///
/// No tearing will be observed.
///
/// Supported on DX11/12 on Windows 10, NVidia on Vulkan and Wayland on Vulkan.
/// Supported on DX12 on Windows 10, NVidia on Vulkan and Wayland on Vulkan.
///
/// This is traditionally called "Fast Vsync"
Mailbox = 5,
@ -6179,6 +6186,21 @@ pub enum BindingType {
/// Dimension of the texture view that is going to be sampled.
view_dimension: TextureViewDimension,
},
/// A ray-tracing acceleration structure binding.
///
/// Example WGSL syntax:
/// ```rust,ignore
/// @group(0) @binding(0)
/// var as: acceleration_structure;
/// ```
///
/// Example GLSL syntax:
/// ```cpp,ignore
/// layout(binding = 0)
/// uniform accelerationStructureEXT as;
/// ```
AccelerationStructure,
}
impl BindingType {
@ -6829,6 +6851,36 @@ impl Default for InstanceDescriptor {
}
}
bitflags::bitflags!(
/// Flags for acceleration structures
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct AccelerationStructureFlags: u8 {
/// Allow for incremental updates (no change in size)
const ALLOW_UPDATE = 1 << 0;
/// Allow the acceleration structure to be compacted in a copy operation
const ALLOW_COMPACTION = 1 << 1;
/// Optimize for fast ray tracing performance
const PREFER_FAST_TRACE = 1 << 2;
/// Optimize for fast build time
const PREFER_FAST_BUILD = 1 << 3;
/// Optimize for low memory footprint (scratch and output)
const LOW_MEMORY = 1 << 4;
}
);
impl_bitflags!(AccelerationStructureFlags);
bitflags::bitflags!(
/// Flags for acceleration structure geometries
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct AccelerationStructureGeometryFlags: u8 {
/// Is OPAQUE
const OPAQUE = 1 << 0;
/// NO_DUPLICATE_ANY_HIT_INVOCATION
const NO_DUPLICATE_ANY_HIT_INVOCATION = 1 << 1;
}
);
impl_bitflags!(AccelerationStructureGeometryFlags);
pub use send_sync::*;
#[doc(hidden)]