зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 5 changesets (bug 1908573) for causing rust vendor linting. CLOSED TREE
Backed out changeset fcd4b742e900 (bug 1908573) Backed out changeset 8713aa05b027 (bug 1908573) Backed out changeset d5f1aa514a62 (bug 1908573) Backed out changeset 3603c3ce8c6f (bug 1908573) Backed out changeset 208fb58a4f24 (bug 1908573)
This commit is contained in:
Родитель
3833aefaab
Коммит
a5149c093d
|
@ -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=aeb2067e8120c1ff480625c00b9571db8d01d5a4"]
|
||||
[source."git+https://github.com/gfx-rs/wgpu?rev=a0c185a28c232ee2ab63f72d6fd3a63a3f787309"]
|
||||
git = "https://github.com/gfx-rs/wgpu"
|
||||
rev = "aeb2067e8120c1ff480625c00b9571db8d01d5a4"
|
||||
rev = "a0c185a28c232ee2ab63f72d6fd3a63a3f787309"
|
||||
replace-with = "vendored-sources"
|
||||
|
||||
[source."git+https://github.com/glandium/mio?rev=9a2ef335c366044ffe73b1c4acabe50a1daefe05"]
|
||||
|
|
|
@ -1240,7 +1240,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "d3d12"
|
||||
version = "0.20.0"
|
||||
source = "git+https://github.com/gfx-rs/wgpu?rev=aeb2067e8120c1ff480625c00b9571db8d01d5a4#aeb2067e8120c1ff480625c00b9571db8d01d5a4"
|
||||
source = "git+https://github.com/gfx-rs/wgpu?rev=a0c185a28c232ee2ab63f72d6fd3a63a3f787309#a0c185a28c232ee2ab63f72d6fd3a63a3f787309"
|
||||
dependencies = [
|
||||
"bitflags 2.6.0",
|
||||
"libloading",
|
||||
|
@ -1525,9 +1525,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "document-features"
|
||||
version = "0.2.10"
|
||||
version = "0.2.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cb6969eaabd2421f8a2775cfd2471a2b634372b4a25d41e3bd647b79912850a0"
|
||||
checksum = "ef5282ad69563b5fc40319526ba27e0e7363d552a896f0297d54f767717f9b95"
|
||||
dependencies = [
|
||||
"litrs",
|
||||
]
|
||||
|
@ -3660,9 +3660,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "metal"
|
||||
version = "0.29.0"
|
||||
version = "0.28.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7ecfd3296f8c56b7c1f6fbac3c71cefa9d78ce009850c45000015f206dc7fa21"
|
||||
checksum = "5637e166ea14be6063a3f8ba5ccb9a4159df7d8f6d61c02fc3d480b1f90dcfcb"
|
||||
dependencies = [
|
||||
"bitflags 2.6.0",
|
||||
"block",
|
||||
|
@ -4032,7 +4032,7 @@ checksum = "a2983372caf4480544083767bf2d27defafe32af49ab4df3a0b7fc90793a3664"
|
|||
[[package]]
|
||||
name = "naga"
|
||||
version = "0.20.0"
|
||||
source = "git+https://github.com/gfx-rs/wgpu?rev=aeb2067e8120c1ff480625c00b9571db8d01d5a4#aeb2067e8120c1ff480625c00b9571db8d01d5a4"
|
||||
source = "git+https://github.com/gfx-rs/wgpu?rev=a0c185a28c232ee2ab63f72d6fd3a63a3f787309#a0c185a28c232ee2ab63f72d6fd3a63a3f787309"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"bit-set",
|
||||
|
@ -5234,9 +5234,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.204"
|
||||
version = "1.0.203"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12"
|
||||
checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
@ -5262,9 +5262,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.204"
|
||||
version = "1.0.203"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222"
|
||||
checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -5843,18 +5843,18 @@ checksum = "aac81b6fd6beb5884b0cf3321b8117e6e5d47ecb6fc89f414cfdcca8b2fe2dd8"
|
|||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.63"
|
||||
version = "1.0.61"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724"
|
||||
checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709"
|
||||
dependencies = [
|
||||
"thiserror-impl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror-impl"
|
||||
version = "1.0.63"
|
||||
version = "1.0.61"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261"
|
||||
checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -6770,7 +6770,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "wgpu-core"
|
||||
version = "0.20.0"
|
||||
source = "git+https://github.com/gfx-rs/wgpu?rev=aeb2067e8120c1ff480625c00b9571db8d01d5a4#aeb2067e8120c1ff480625c00b9571db8d01d5a4"
|
||||
source = "git+https://github.com/gfx-rs/wgpu?rev=a0c185a28c232ee2ab63f72d6fd3a63a3f787309#a0c185a28c232ee2ab63f72d6fd3a63a3f787309"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"bit-vec",
|
||||
|
@ -6795,7 +6795,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "wgpu-hal"
|
||||
version = "0.20.0"
|
||||
source = "git+https://github.com/gfx-rs/wgpu?rev=aeb2067e8120c1ff480625c00b9571db8d01d5a4#aeb2067e8120c1ff480625c00b9571db8d01d5a4"
|
||||
source = "git+https://github.com/gfx-rs/wgpu?rev=a0c185a28c232ee2ab63f72d6fd3a63a3f787309#a0c185a28c232ee2ab63f72d6fd3a63a3f787309"
|
||||
dependencies = [
|
||||
"android_system_properties",
|
||||
"arrayvec",
|
||||
|
@ -6834,7 +6834,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "wgpu-types"
|
||||
version = "0.20.0"
|
||||
source = "git+https://github.com/gfx-rs/wgpu?rev=aeb2067e8120c1ff480625c00b9571db8d01d5a4#aeb2067e8120c1ff480625c00b9571db8d01d5a4"
|
||||
source = "git+https://github.com/gfx-rs/wgpu?rev=a0c185a28c232ee2ab63f72d6fd3a63a3f787309#a0c185a28c232ee2ab63f72d6fd3a63a3f787309"
|
||||
dependencies = [
|
||||
"bitflags 2.6.0",
|
||||
"js-sys",
|
||||
|
|
|
@ -17,7 +17,7 @@ default = []
|
|||
[dependencies.wgc]
|
||||
package = "wgpu-core"
|
||||
git = "https://github.com/gfx-rs/wgpu"
|
||||
rev = "aeb2067e8120c1ff480625c00b9571db8d01d5a4"
|
||||
rev = "a0c185a28c232ee2ab63f72d6fd3a63a3f787309"
|
||||
# TODO: remove the replay feature on the next update containing https://github.com/gfx-rs/wgpu/pull/5182
|
||||
features = ["serde", "replay", "trace", "strict_asserts", "wgsl", "api_log_info"]
|
||||
|
||||
|
@ -26,37 +26,37 @@ features = ["serde", "replay", "trace", "strict_asserts", "wgsl", "api_log_info"
|
|||
[target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies.wgc]
|
||||
package = "wgpu-core"
|
||||
git = "https://github.com/gfx-rs/wgpu"
|
||||
rev = "aeb2067e8120c1ff480625c00b9571db8d01d5a4"
|
||||
rev = "a0c185a28c232ee2ab63f72d6fd3a63a3f787309"
|
||||
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 = "aeb2067e8120c1ff480625c00b9571db8d01d5a4"
|
||||
rev = "a0c185a28c232ee2ab63f72d6fd3a63a3f787309"
|
||||
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 = "aeb2067e8120c1ff480625c00b9571db8d01d5a4"
|
||||
rev = "a0c185a28c232ee2ab63f72d6fd3a63a3f787309"
|
||||
features = ["vulkan"]
|
||||
|
||||
[dependencies.wgt]
|
||||
package = "wgpu-types"
|
||||
git = "https://github.com/gfx-rs/wgpu"
|
||||
rev = "aeb2067e8120c1ff480625c00b9571db8d01d5a4"
|
||||
rev = "a0c185a28c232ee2ab63f72d6fd3a63a3f787309"
|
||||
|
||||
[dependencies.wgh]
|
||||
package = "wgpu-hal"
|
||||
git = "https://github.com/gfx-rs/wgpu"
|
||||
rev = "aeb2067e8120c1ff480625c00b9571db8d01d5a4"
|
||||
rev = "a0c185a28c232ee2ab63f72d6fd3a63a3f787309"
|
||||
features = ["windows_rs", "oom_panic", "device_lost_panic", "internal_error_panic"]
|
||||
|
||||
[target.'cfg(windows)'.dependencies.d3d12]
|
||||
git = "https://github.com/gfx-rs/wgpu"
|
||||
rev = "aeb2067e8120c1ff480625c00b9571db8d01d5a4"
|
||||
rev = "a0c185a28c232ee2ab63f72d6fd3a63a3f787309"
|
||||
|
||||
[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: aeb2067e8120c1ff480625c00b9571db8d01d5a4 (2024-07-17T23:11:04Z).
|
||||
release: commit a0c185a28c232ee2ab63f72d6fd3a63a3f787309
|
||||
|
||||
# Revision to pull in
|
||||
# Must be a long or short commit SHA (long preferred)
|
||||
revision: aeb2067e8120c1ff480625c00b9571db8d01d5a4
|
||||
revision: a0c185a28c232ee2ab63f72d6fd3a63a3f787309
|
||||
|
||||
license: ['MIT', 'Apache-2.0']
|
||||
|
||||
|
|
|
@ -331,7 +331,7 @@ impl ImplicitLayout<'_> {
|
|||
pipeline: identities.pipeline_layouts.process(backend),
|
||||
bind_groups: Cow::Owned(
|
||||
(0..8) // hal::MAX_BIND_GROUPS
|
||||
.map(|_| identities.bind_group_layouts.process(backend))
|
||||
.map(|_| Some(identities.bind_group_layouts.process(backend)))
|
||||
.collect(),
|
||||
),
|
||||
}
|
||||
|
@ -1276,7 +1276,7 @@ pub unsafe extern "C" fn wgpu_client_create_compute_pipeline(
|
|||
let implicit = ImplicitLayout::new(identities.select(backend), backend);
|
||||
ptr::write(implicit_pipeline_layout_id, Some(implicit.pipeline));
|
||||
for (i, bgl_id) in implicit.bind_groups.iter().enumerate() {
|
||||
*implicit_bind_group_layout_ids.add(i) = Some(*bgl_id);
|
||||
*implicit_bind_group_layout_ids.add(i) = *bgl_id;
|
||||
}
|
||||
Some(implicit)
|
||||
}
|
||||
|
@ -1331,7 +1331,7 @@ pub unsafe extern "C" fn wgpu_client_create_render_pipeline(
|
|||
let implicit = ImplicitLayout::new(identities.select(backend), backend);
|
||||
ptr::write(implicit_pipeline_layout_id, Some(implicit.pipeline));
|
||||
for (i, bgl_id) in implicit.bind_groups.iter().enumerate() {
|
||||
*implicit_bind_group_layout_ids.add(i) = Some(*bgl_id);
|
||||
*implicit_bind_group_layout_ids.add(i) = *bgl_id;
|
||||
}
|
||||
Some(implicit)
|
||||
}
|
||||
|
|
|
@ -109,7 +109,7 @@ pub struct AdapterInformation<S> {
|
|||
#[derive(serde::Serialize, serde::Deserialize)]
|
||||
struct ImplicitLayout<'a> {
|
||||
pipeline: id::PipelineLayoutId,
|
||||
bind_groups: Cow<'a, [id::BindGroupLayoutId]>,
|
||||
bind_groups: Cow<'a, [Option<id::BindGroupLayoutId>]>,
|
||||
}
|
||||
|
||||
#[derive(serde::Serialize, serde::Deserialize)]
|
||||
|
|
|
@ -848,7 +848,7 @@ impl Global {
|
|||
let implicit_ids = implicit
|
||||
.as_ref()
|
||||
.map(|imp| wgc::device::ImplicitPipelineIds {
|
||||
root_id: imp.pipeline,
|
||||
root_id: Some(imp.pipeline),
|
||||
group_ids: &imp.bind_groups,
|
||||
});
|
||||
let (_, error) = self.device_create_compute_pipeline::<A>(
|
||||
|
@ -865,7 +865,7 @@ impl Global {
|
|||
let implicit_ids = implicit
|
||||
.as_ref()
|
||||
.map(|imp| wgc::device::ImplicitPipelineIds {
|
||||
root_id: imp.pipeline,
|
||||
root_id: Some(imp.pipeline),
|
||||
group_ids: &imp.bind_groups,
|
||||
});
|
||||
let (_, error) =
|
||||
|
|
|
@ -1474,11 +1474,11 @@ delta = "0.19.0 -> 0.20.0"
|
|||
[[audits.d3d12]]
|
||||
who = [
|
||||
"Jim Blandy <jimb@red-bean.com>",
|
||||
"Teodor Tanasoaia <ttanasoaia@mozilla.com>",
|
||||
"Erich Gubler <erichdongubler@gmail.com>",
|
||||
"Teodor Tanasoaia <ttanasoaia@mozilla.com>",
|
||||
]
|
||||
criteria = "safe-to-deploy"
|
||||
delta = "0.20.0 -> 0.20.0@git:aeb2067e8120c1ff480625c00b9571db8d01d5a4"
|
||||
delta = "0.20.0 -> 0.20.0@git:a0c185a28c232ee2ab63f72d6fd3a63a3f787309"
|
||||
importable = false
|
||||
|
||||
[[audits.darling]]
|
||||
|
@ -1675,16 +1675,6 @@ who = "Erich Gubler <erichdongubler@gmail.com>"
|
|||
criteria = "safe-to-deploy"
|
||||
version = "0.2.8"
|
||||
|
||||
[[audits.document-features]]
|
||||
who = "Erich Gubler <erichdongubler@gmail.com>"
|
||||
criteria = "safe-to-deploy"
|
||||
delta = "0.2.8 -> 0.2.9"
|
||||
|
||||
[[audits.document-features]]
|
||||
who = "Erich Gubler <erichdongubler@gmail.com>"
|
||||
criteria = "safe-to-deploy"
|
||||
delta = "0.2.9 -> 0.2.10"
|
||||
|
||||
[[audits.dogear]]
|
||||
who = "Sammy Khamis <skhamis@mozilla.com>"
|
||||
criteria = "safe-to-deploy"
|
||||
|
@ -2912,11 +2902,6 @@ criteria = "safe-to-deploy"
|
|||
delta = "0.27.0 -> 0.28.0"
|
||||
notes = "No significantly changed functionality. Some warnings resolved, bumped `core-graphics-types`, newer versions of Metal supported."
|
||||
|
||||
[[audits.metal]]
|
||||
who = "Erich Gubler <erichdongubler@gmail.com>"
|
||||
criteria = "safe-to-deploy"
|
||||
delta = "0.28.0 -> 0.29.0"
|
||||
|
||||
[[audits.midir]]
|
||||
who = "Bobby Holley <bobbyholley@gmail.com>"
|
||||
criteria = "safe-to-deploy"
|
||||
|
@ -3077,11 +3062,11 @@ delta = "0.19.2 -> 0.20.0"
|
|||
[[audits.naga]]
|
||||
who = [
|
||||
"Jim Blandy <jimb@red-bean.com>",
|
||||
"Teodor Tanasoaia <ttanasoaia@mozilla.com>",
|
||||
"Erich Gubler <erichdongubler@gmail.com>",
|
||||
"Teodor Tanasoaia <ttanasoaia@mozilla.com>",
|
||||
]
|
||||
criteria = "safe-to-deploy"
|
||||
delta = "0.20.0 -> 0.20.0@git:aeb2067e8120c1ff480625c00b9571db8d01d5a4"
|
||||
delta = "0.20.0 -> 0.20.0@git:a0c185a28c232ee2ab63f72d6fd3a63a3f787309"
|
||||
importable = false
|
||||
|
||||
[[audits.net2]]
|
||||
|
@ -5030,11 +5015,11 @@ delta = "0.19.3 -> 0.20.0"
|
|||
[[audits.wgpu-core]]
|
||||
who = [
|
||||
"Jim Blandy <jimb@red-bean.com>",
|
||||
"Teodor Tanasoaia <ttanasoaia@mozilla.com>",
|
||||
"Erich Gubler <erichdongubler@gmail.com>",
|
||||
"Teodor Tanasoaia <ttanasoaia@mozilla.com>",
|
||||
]
|
||||
criteria = "safe-to-deploy"
|
||||
delta = "0.20.0 -> 0.20.0@git:aeb2067e8120c1ff480625c00b9571db8d01d5a4"
|
||||
delta = "0.20.0 -> 0.20.0@git:a0c185a28c232ee2ab63f72d6fd3a63a3f787309"
|
||||
importable = false
|
||||
|
||||
[[audits.wgpu-hal]]
|
||||
|
@ -5098,11 +5083,11 @@ delta = "0.19.3 -> 0.20.0"
|
|||
[[audits.wgpu-hal]]
|
||||
who = [
|
||||
"Jim Blandy <jimb@red-bean.com>",
|
||||
"Teodor Tanasoaia <ttanasoaia@mozilla.com>",
|
||||
"Erich Gubler <erichdongubler@gmail.com>",
|
||||
"Teodor Tanasoaia <ttanasoaia@mozilla.com>",
|
||||
]
|
||||
criteria = "safe-to-deploy"
|
||||
delta = "0.20.0 -> 0.20.0@git:aeb2067e8120c1ff480625c00b9571db8d01d5a4"
|
||||
delta = "0.20.0 -> 0.20.0@git:a0c185a28c232ee2ab63f72d6fd3a63a3f787309"
|
||||
importable = false
|
||||
|
||||
[[audits.wgpu-types]]
|
||||
|
@ -5166,11 +5151,11 @@ delta = "0.19.2 -> 0.20.0"
|
|||
[[audits.wgpu-types]]
|
||||
who = [
|
||||
"Jim Blandy <jimb@red-bean.com>",
|
||||
"Teodor Tanasoaia <ttanasoaia@mozilla.com>",
|
||||
"Erich Gubler <erichdongubler@gmail.com>",
|
||||
"Teodor Tanasoaia <ttanasoaia@mozilla.com>",
|
||||
]
|
||||
criteria = "safe-to-deploy"
|
||||
delta = "0.20.0 -> 0.20.0@git:aeb2067e8120c1ff480625c00b9571db8d01d5a4"
|
||||
delta = "0.20.0 -> 0.20.0@git:a0c185a28c232ee2ab63f72d6fd3a63a3f787309"
|
||||
importable = false
|
||||
|
||||
[[audits.whatsys]]
|
||||
|
|
|
@ -607,13 +607,6 @@ user-id = 3618
|
|||
user-login = "dtolnay"
|
||||
user-name = "David Tolnay"
|
||||
|
||||
[[publisher.serde]]
|
||||
version = "1.0.204"
|
||||
when = "2024-07-06"
|
||||
user-id = 3618
|
||||
user-login = "dtolnay"
|
||||
user-name = "David Tolnay"
|
||||
|
||||
[[publisher.serde_bytes]]
|
||||
version = "0.11.9"
|
||||
when = "2023-02-05"
|
||||
|
@ -649,13 +642,6 @@ user-id = 3618
|
|||
user-login = "dtolnay"
|
||||
user-name = "David Tolnay"
|
||||
|
||||
[[publisher.serde_derive]]
|
||||
version = "1.0.204"
|
||||
when = "2024-07-06"
|
||||
user-id = 3618
|
||||
user-login = "dtolnay"
|
||||
user-name = "David Tolnay"
|
||||
|
||||
[[publisher.serde_json]]
|
||||
version = "1.0.116"
|
||||
when = "2024-04-16"
|
||||
|
@ -726,13 +712,6 @@ user-id = 3618
|
|||
user-login = "dtolnay"
|
||||
user-name = "David Tolnay"
|
||||
|
||||
[[publisher.thiserror]]
|
||||
version = "1.0.63"
|
||||
when = "2024-07-17"
|
||||
user-id = 3618
|
||||
user-login = "dtolnay"
|
||||
user-name = "David Tolnay"
|
||||
|
||||
[[publisher.thiserror-impl]]
|
||||
version = "1.0.59"
|
||||
when = "2024-04-20"
|
||||
|
@ -747,13 +726,6 @@ user-id = 3618
|
|||
user-login = "dtolnay"
|
||||
user-name = "David Tolnay"
|
||||
|
||||
[[publisher.thiserror-impl]]
|
||||
version = "1.0.63"
|
||||
when = "2024-07-17"
|
||||
user-id = 3618
|
||||
user-login = "dtolnay"
|
||||
user-name = "David Tolnay"
|
||||
|
||||
[[publisher.threadbound]]
|
||||
version = "0.1.5"
|
||||
when = "2022-12-17"
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"files":{"CHANGELOG.md":"45fa76b0e5bc51721887147000e9e78a5934cb04d1ad628e501ef2082763d353","Cargo.toml":"9938addd7ce2c7785a9ca11eb0049271317f9b05fdf0d7330d4a80f0e07ab500","README.md":"76cee3209f773a62535de6c9724b53f158406359f35b4d48b17ac3747b6c102e","src/com.rs":"cfd6556a7abf38cba57559038f9f2cf86274418448fb2745436c251a99575e05","src/command_allocator.rs":"ef01059a661749470f3772d188fe0fab0f002e1d154facdab4b9b2932f4b2d93","src/command_list.rs":"8723f3b755b721e0dbb234bd604956c1b7922a2368231197495daa3fa6548e63","src/debug.rs":"aa33b98f7c3e71cba75fc42c6ca9af72d96b45122422c16e48525e24590c57bf","src/descriptor.rs":"fea0b820de1566b54d17d8d0c67e6f5a2126eda19526397eb710ff7d6db9db9e","src/device.rs":"c1dd479aabd22bced0d407523d60629ad1da439fb47ad89fe7b48bae1c4b23e5","src/dxgi.rs":"1516186845b91bf3df813a29b4a0e00a85ca5649fb7a2755da43fba984c41a42","src/heap.rs":"dae2380684896c97e97ed022929f79ce2cc4f5418a3ec34883086f7c88f423d0","src/lib.rs":"612e2f471b84502d219da3fb86ee13f3cbd6faf17d77407bab6c84e51ec424d0","src/pso.rs":"ff819c321536695e34a3be9a6051cf3e57765049a4a2035db6ab27add5a7978a","src/query.rs":"b046b922f48e817fe252d9b2f859c036f54635779e84103ca53d1b2ca9c18e02","src/queue.rs":"bd32813d0b8a3bedf3223b69ade9f9c799a138a9e27d970f86435d9ce32d1557","src/resource.rs":"931c255c845eb621fc1b9e807b0effd92a2cd20e624c2beaa88506019a7a43a4","src/sync.rs":"5c287fb7498242a397eb1f08887be9cff9b48dc7cb13af5792cce5f7182b55f8"},"package":null}
|
||||
{"files":{"CHANGELOG.md":"45fa76b0e5bc51721887147000e9e78a5934cb04d1ad628e501ef2082763d353","Cargo.toml":"9938addd7ce2c7785a9ca11eb0049271317f9b05fdf0d7330d4a80f0e07ab500","README.md":"76cee3209f773a62535de6c9724b53f158406359f35b4d48b17ac3747b6c102e","src/com.rs":"cfd6556a7abf38cba57559038f9f2cf86274418448fb2745436c251a99575e05","src/command_allocator.rs":"ef01059a661749470f3772d188fe0fab0f002e1d154facdab4b9b2932f4b2d93","src/command_list.rs":"8723f3b755b721e0dbb234bd604956c1b7922a2368231197495daa3fa6548e63","src/debug.rs":"aa33b98f7c3e71cba75fc42c6ca9af72d96b45122422c16e48525e24590c57bf","src/descriptor.rs":"fea0b820de1566b54d17d8d0c67e6f5a2126eda19526397eb710ff7d6db9db9e","src/device.rs":"c1dd479aabd22bced0d407523d60629ad1da439fb47ad89fe7b48bae1c4b23e5","src/dxgi.rs":"1516186845b91bf3df813a29b4a0e00a85ca5649fb7a2755da43fba984c41a42","src/heap.rs":"dae2380684896c97e97ed022929f79ce2cc4f5418a3ec34883086f7c88f423d0","src/lib.rs":"612e2f471b84502d219da3fb86ee13f3cbd6faf17d77407bab6c84e51ec424d0","src/pso.rs":"ff819c321536695e34a3be9a6051cf3e57765049a4a2035db6ab27add5a7978a","src/query.rs":"ff61a2b76a108afc1f082724bb9b07ac8b52afbe97356e0fcf6df0ff7e53e07d","src/queue.rs":"bd32813d0b8a3bedf3223b69ade9f9c799a138a9e27d970f86435d9ce32d1557","src/resource.rs":"931c255c845eb621fc1b9e807b0effd92a2cd20e624c2beaa88506019a7a43a4","src/sync.rs":"5c287fb7498242a397eb1f08887be9cff9b48dc7cb13af5792cce5f7182b55f8"},"package":null}
|
|
@ -8,7 +8,7 @@ pub enum QueryHeapType {
|
|||
Timestamp = d3d12::D3D12_QUERY_HEAP_TYPE_TIMESTAMP,
|
||||
PipelineStatistics = d3d12::D3D12_QUERY_HEAP_TYPE_PIPELINE_STATISTICS,
|
||||
SOStatistics = d3d12::D3D12_QUERY_HEAP_TYPE_SO_STATISTICS,
|
||||
// VideoDecodeStatistics = d3d12::D3D12_QUERY_HEAP_TYPE_VIDEO_DECODE_STATISTICS,
|
||||
// VideoDecodeStatistcs = d3d12::D3D12_QUERY_HEAP_TYPE_VIDEO_DECODE_STATISTICS,
|
||||
// CopyQueueTimestamp = d3d12::D3D12_QUERY_HEAP_TYPE_COPY_QUEUE_TIMESTAMP,
|
||||
}
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"files":{"CHANGELOG.md":"4a628703d5fc4ce692f255732a077d6d611aff64d2fddc3b2b4cd6c1bcc35bcf","Cargo.toml":"6e4dc75115db673e743d41149144c638ad8e11da7cfb5435d55e60ea61bd2016","LICENSE-APACHE":"074e6e32c86a4c0ef8b3ed25b721ca23aca83df277cd88106ef7177c354615ff","LICENSE-MIT":"aa893340d14b9844625be6a50ac644169a01b52f0211cbf81b09e1874c8cd81d","README.md":"89a83c4acc6891e5651772fc78a1d6362070774eaa6c5b5d4bfbe9e57a957be9","lib.rs":"f7915d9cd43170ce74f4551b51c39b7a91acbe244ede6ab3ca2fa1c50d505040","rustfmt.toml":"f74204a6f92aa7422a16ecb2ffe2d5bae0f123b778d08b5db1a398a3c9ca4306","tests/self-doc.rs":"24bbda93f3b323c0b7c543c1df3bf45522b8026283103211805f070de66abadc"},"package":"cb6969eaabd2421f8a2775cfd2471a2b634372b4a25d41e3bd647b79912850a0"}
|
||||
{"files":{"CHANGELOG.md":"c1ccf4587ca168b3baa54580469c5dcc776decac0d996d3bb31d2341b47efa11","Cargo.toml":"390d32c2b791a6745c075c474e6d57c65d5f77f0e7190ff8a8c5342fbb40722a","LICENSE-APACHE":"074e6e32c86a4c0ef8b3ed25b721ca23aca83df277cd88106ef7177c354615ff","LICENSE-MIT":"aa893340d14b9844625be6a50ac644169a01b52f0211cbf81b09e1874c8cd81d","README.md":"89a83c4acc6891e5651772fc78a1d6362070774eaa6c5b5d4bfbe9e57a957be9","lib.rs":"2f4ede9d0619d85449891d9055605188db681d57b405e40e529831266e014ee5","rustfmt.toml":"f74204a6f92aa7422a16ecb2ffe2d5bae0f123b778d08b5db1a398a3c9ca4306","tests/self-doc.rs":"24bbda93f3b323c0b7c543c1df3bf45522b8026283103211805f070de66abadc"},"package":"ef5282ad69563b5fc40319526ba27e0e7363d552a896f0297d54f767717f9b95"}
|
|
@ -1,17 +1,7 @@
|
|||
# Changelog
|
||||
|
||||
## 0.2.1O - 2024-07-12
|
||||
|
||||
* Revert parsing of multi-lines string while parsing features
|
||||
(Keep parsing of multi-lines string when detecting if we need to use Cargo.toml.orig)
|
||||
|
||||
## 0.2.9 - 2024-07-11
|
||||
|
||||
* Fix parsing of multi-lines string (#25)
|
||||
* Fix `out_of_scope_macro_calls` compatibility warning
|
||||
* Fix documentation having too many `#` (#22)
|
||||
|
||||
## 0.2.8 - 2023-12-29
|
||||
## 0.2.7 - 2023-12-29
|
||||
|
||||
* Remove `\n` between features (#17)
|
||||
* Don't throw an error when there is no features in Cargo.toml (#20)
|
||||
|
|
|
@ -12,10 +12,10 @@
|
|||
[package]
|
||||
edition = "2018"
|
||||
name = "document-features"
|
||||
version = "0.2.10"
|
||||
authors = ["Slint Developers <info@slint.dev>"]
|
||||
version = "0.2.8"
|
||||
authors = ["Slint Developers <info@slint-ui.com>"]
|
||||
description = "Extract documentation for the feature flags from comments in Cargo.toml"
|
||||
homepage = "https://slint.rs"
|
||||
homepage = "https://slint-ui.com"
|
||||
readme = "README.md"
|
||||
keywords = [
|
||||
"documentation",
|
||||
|
|
|
@ -41,38 +41,40 @@ in where they occur. Use them to group features, for example.
|
|||
## Examples:
|
||||
|
||||
*/
|
||||
// Note: because rustdoc escapes the first `#` of a line starting with `#`,
|
||||
// these docs comments have one more `#` ,
|
||||
#![doc = self_test!(/**
|
||||
[package]
|
||||
name = "..."
|
||||
# ...
|
||||
## ...
|
||||
|
||||
[features]
|
||||
default = ["foo"]
|
||||
#! This comments goes on top
|
||||
##! This comments goes on top
|
||||
|
||||
## The foo feature enables the `foo` functions
|
||||
### The foo feature enables the `foo` functions
|
||||
foo = []
|
||||
|
||||
## The bar feature enables the bar module
|
||||
### The bar feature enables the bar module
|
||||
bar = []
|
||||
|
||||
#! ### Experimental features
|
||||
#! The following features are experimental
|
||||
##! ### Experimental features
|
||||
##! The following features are experimental
|
||||
|
||||
## Enable the fusion reactor
|
||||
##
|
||||
## ⚠️ Can lead to explosions
|
||||
### Enable the fusion reactor
|
||||
###
|
||||
### ⚠️ Can lead to explosions
|
||||
fusion = []
|
||||
|
||||
[dependencies]
|
||||
document-features = "0.2"
|
||||
|
||||
#! ### Optional dependencies
|
||||
##! ### Optional dependencies
|
||||
|
||||
## Enable this feature to implement the trait for the types from the genial crate
|
||||
### Enable this feature to implement the trait for the types from the genial crate
|
||||
genial = { version = "0.2", optional = true }
|
||||
|
||||
## This awesome dependency is specified in its own table
|
||||
### This awesome dependency is specified in its own table
|
||||
[dependencies.awesome]
|
||||
version = "1.3.5"
|
||||
optional = true
|
||||
|
@ -254,11 +256,11 @@ fn document_features_impl(args: &Args) -> Result<TokenStream, TokenStream> {
|
|||
let mut cargo_toml = std::fs::read_to_string(Path::new(&path).join("Cargo.toml"))
|
||||
.map_err(|e| error(&format!("Can't open Cargo.toml: {:?}", e)))?;
|
||||
|
||||
if !has_doc_comments(&cargo_toml) {
|
||||
if !cargo_toml.contains("\n##") && !cargo_toml.contains("\n#!") {
|
||||
// On crates.io, Cargo.toml is usually "normalized" and stripped of all comments.
|
||||
// The original Cargo.toml has been renamed Cargo.toml.orig
|
||||
if let Ok(orig) = std::fs::read_to_string(Path::new(&path).join("Cargo.toml.orig")) {
|
||||
if has_doc_comments(&orig) {
|
||||
if orig.contains("##") || orig.contains("#!") {
|
||||
cargo_toml = orig;
|
||||
}
|
||||
}
|
||||
|
@ -268,109 +270,6 @@ fn document_features_impl(args: &Args) -> Result<TokenStream, TokenStream> {
|
|||
Ok(std::iter::once(proc_macro::TokenTree::from(proc_macro::Literal::string(&result))).collect())
|
||||
}
|
||||
|
||||
/// Check if the Cargo.toml has comments that looks like doc comments.
|
||||
fn has_doc_comments(cargo_toml: &str) -> bool {
|
||||
let mut lines = cargo_toml.lines().map(str::trim);
|
||||
while let Some(line) = lines.next() {
|
||||
if line.starts_with("## ") || line.starts_with("#! ") {
|
||||
return true;
|
||||
}
|
||||
let before_coment = line.split_once('#').map_or(line, |(before, _)| before);
|
||||
if line.starts_with("#") {
|
||||
continue;
|
||||
}
|
||||
if let Some((_, mut quote)) = before_coment.split_once("\"\"\"") {
|
||||
loop {
|
||||
// skip slashes.
|
||||
if let Some((_, s)) = quote.split_once('\\') {
|
||||
quote = s.strip_prefix('\\').or_else(|| s.strip_prefix('"')).unwrap_or(s);
|
||||
continue;
|
||||
}
|
||||
// skip quotes.
|
||||
if let Some((_, out_quote)) = quote.split_once("\"\"\"") {
|
||||
let out_quote = out_quote.trim_start_matches('"');
|
||||
let out_quote =
|
||||
out_quote.split_once('#').map_or(out_quote, |(before, _)| before);
|
||||
if let Some((_, q)) = out_quote.split_once("\"\"\"") {
|
||||
quote = q;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
};
|
||||
match lines.next() {
|
||||
Some(l) => quote = l,
|
||||
None => return false,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_has_doc_coment() {
|
||||
assert!(has_doc_comments("foo\nbar\n## comment\nddd"));
|
||||
assert!(!has_doc_comments("foo\nbar\n#comment\nddd"));
|
||||
assert!(!has_doc_comments(
|
||||
r#"
|
||||
[[package.metadata.release.pre-release-replacements]]
|
||||
exactly = 1 # not a doc comment
|
||||
file = "CHANGELOG.md"
|
||||
replace = """
|
||||
<!-- next-header -->
|
||||
## [Unreleased] - ReleaseDate
|
||||
"""
|
||||
search = "<!-- next-header -->"
|
||||
array = ["""foo""", """
|
||||
bar""", """eee
|
||||
## not a comment
|
||||
"""]
|
||||
"#
|
||||
));
|
||||
assert!(has_doc_comments(
|
||||
r#"
|
||||
[[package.metadata.release.pre-release-replacements]]
|
||||
exactly = 1 # """
|
||||
file = "CHANGELOG.md"
|
||||
replace = """
|
||||
<!-- next-header -->
|
||||
## [Unreleased] - ReleaseDate
|
||||
"""
|
||||
search = "<!-- next-header -->"
|
||||
array = ["""foo""", """
|
||||
bar""", """eee
|
||||
## not a comment
|
||||
"""]
|
||||
## This is a comment
|
||||
feature = "45"
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(!has_doc_comments(
|
||||
r#"
|
||||
[[package.metadata.release.pre-release-replacements]]
|
||||
value = """" string \"""
|
||||
## within the string
|
||||
\""""
|
||||
another_string = """"" # """
|
||||
## also within"""
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(has_doc_comments(
|
||||
r#"
|
||||
[[package.metadata.release.pre-release-replacements]]
|
||||
value = """" string \"""
|
||||
## within the string
|
||||
\""""
|
||||
another_string = """"" # """
|
||||
## also within"""
|
||||
## out of the string
|
||||
foo = bar
|
||||
"#
|
||||
));
|
||||
}
|
||||
|
||||
fn process_toml(cargo_toml: &str, args: &Args) -> Result<String, String> {
|
||||
// Get all lines between the "[features]" and the next block
|
||||
let mut lines = cargo_toml
|
||||
|
@ -566,20 +465,14 @@ fn test_get_balanced() {
|
|||
#[doc(hidden)]
|
||||
/// Helper macro for the tests. Do not use
|
||||
pub fn self_test_helper(input: TokenStream) -> TokenStream {
|
||||
let mut code = String::new();
|
||||
for line in (&input).to_string().trim_matches(|c| c == '"' || c == '#').lines() {
|
||||
// Rustdoc removes the lines that starts with `# ` and removes one `#` from lines that starts with # followed by space.
|
||||
// We need to re-add the `#` that was removed by rustdoc to get the original.
|
||||
if line.strip_prefix('#').map_or(false, |x| x.is_empty() || x.starts_with(' ')) {
|
||||
code += "#";
|
||||
}
|
||||
code += line;
|
||||
code += "\n";
|
||||
}
|
||||
process_toml(&code, &Args::default()).map_or_else(
|
||||
|e| error(&e),
|
||||
|r| std::iter::once(proc_macro::TokenTree::from(proc_macro::Literal::string(&r))).collect(),
|
||||
)
|
||||
process_toml((&input).to_string().trim_matches(|c| c == '"' || c == '#'), &Args::default())
|
||||
.map_or_else(
|
||||
|e| error(&e),
|
||||
|r| {
|
||||
std::iter::once(proc_macro::TokenTree::from(proc_macro::Literal::string(&r)))
|
||||
.collect()
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(feature = "self-test")]
|
||||
|
@ -614,8 +507,6 @@ macro_rules! self_test {
|
|||
};
|
||||
}
|
||||
|
||||
use self_test;
|
||||
|
||||
// The following struct is inserted only during generation of the documentation in order to exploit doc-tests.
|
||||
// These doc-tests are used to check that invalid arguments to the `document_features!` macro cause a compile time error.
|
||||
// For a more principled way of testing compilation error, maybe investigate <https://docs.rs/trybuild>.
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -12,7 +12,7 @@
|
|||
[package]
|
||||
edition = "2021"
|
||||
name = "metal"
|
||||
version = "0.29.0"
|
||||
version = "0.28.0"
|
||||
authors = ["gfx-rs developers"]
|
||||
exclude = [
|
||||
"guide/**/*",
|
||||
|
@ -34,13 +34,7 @@ license = "MIT OR Apache-2.0"
|
|||
repository = "https://github.com/gfx-rs/metal-rs"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
targets = [
|
||||
"aarch64-apple-darwin",
|
||||
"aarch64-apple-ios",
|
||||
"aarch64-apple-ios-sim",
|
||||
"x86_64-apple-darwin",
|
||||
"x86_64-apple-ios",
|
||||
]
|
||||
default-target = "x86_64-apple-darwin"
|
||||
|
||||
[[example]]
|
||||
name = "window"
|
||||
|
@ -122,13 +116,13 @@ version = "0.2.4"
|
|||
version = "1"
|
||||
|
||||
[dev-dependencies.cocoa]
|
||||
version = "0.25.0"
|
||||
version = "0.24.0"
|
||||
|
||||
[dev-dependencies.cty]
|
||||
version = "0.2.1"
|
||||
|
||||
[dev-dependencies.glam]
|
||||
version = "0.27"
|
||||
version = "0.22"
|
||||
|
||||
[dev-dependencies.png]
|
||||
version = "0.17"
|
||||
|
@ -140,7 +134,7 @@ version = "0.8"
|
|||
version = "0.1.4"
|
||||
|
||||
[dev-dependencies.winit]
|
||||
version = "0.29"
|
||||
version = "0.27"
|
||||
|
||||
[features]
|
||||
default = ["link"]
|
||||
|
|
|
@ -3,7 +3,7 @@ use metal::*;
|
|||
use winit::{
|
||||
event::{Event, WindowEvent},
|
||||
event_loop::{ControlFlow, EventLoop},
|
||||
raw_window_handle::{HasWindowHandle, RawWindowHandle},
|
||||
platform::macos::WindowExtMacOS,
|
||||
};
|
||||
|
||||
use cocoa::{appkit::NSView, base::id as cocoa_id};
|
||||
|
@ -33,7 +33,7 @@ pub struct AAPLVertex {
|
|||
|
||||
fn main() {
|
||||
// Create a window for viewing the content
|
||||
let event_loop = EventLoop::new().unwrap();
|
||||
let event_loop = EventLoop::new();
|
||||
let size = winit::dpi::LogicalSize::new(800, 600);
|
||||
|
||||
let window = winit::window::WindowBuilder::new()
|
||||
|
@ -100,11 +100,9 @@ fn main() {
|
|||
layer.set_presents_with_transaction(false);
|
||||
|
||||
unsafe {
|
||||
if let Ok(RawWindowHandle::AppKit(rw)) = window.window_handle().map(|wh| wh.as_raw()) {
|
||||
let view = rw.ns_view.as_ptr() as cocoa_id;
|
||||
view.setWantsLayer(YES);
|
||||
view.setLayer(mem::transmute(layer.as_ref()));
|
||||
}
|
||||
let view = window.ns_view() as cocoa_id;
|
||||
view.setWantsLayer(YES);
|
||||
view.setLayer(mem::transmute(layer.as_ref()));
|
||||
}
|
||||
|
||||
let draw_size = window.inner_size();
|
||||
|
@ -121,87 +119,80 @@ fn main() {
|
|||
)
|
||||
};
|
||||
|
||||
event_loop
|
||||
.run(move |event, event_loop| {
|
||||
autoreleasepool(|| {
|
||||
// ControlFlow::Wait pauses the event loop if no events are available to process.
|
||||
// This is ideal for non-game applications that only update in response to user
|
||||
// input, and uses significantly less power/CPU time than ControlFlow::Poll.
|
||||
event_loop.set_control_flow(ControlFlow::Wait);
|
||||
event_loop.run(move |event, _, control_flow| {
|
||||
autoreleasepool(|| {
|
||||
// ControlFlow::Wait pauses the event loop if no events are available to process.
|
||||
// This is ideal for non-game applications that only update in response to user
|
||||
// input, and uses significantly less power/CPU time than ControlFlow::Poll.
|
||||
*control_flow = ControlFlow::Wait;
|
||||
|
||||
match event {
|
||||
Event::AboutToWait => window.request_redraw(),
|
||||
Event::WindowEvent { event, .. } => {
|
||||
match event {
|
||||
WindowEvent::CloseRequested => {
|
||||
println!("The close button was pressed; stopping");
|
||||
event_loop.exit();
|
||||
}
|
||||
WindowEvent::RedrawRequested => {
|
||||
// It's preferrable to render in this event rather than in MainEventsCleared, since
|
||||
// rendering in here allows the program to gracefully handle redraws requested
|
||||
// by the OS.
|
||||
let drawable = match layer.next_drawable() {
|
||||
Some(drawable) => drawable,
|
||||
None => return,
|
||||
};
|
||||
|
||||
// Create a new command buffer for each render pass to the current drawable
|
||||
let command_buffer = command_queue.new_command_buffer();
|
||||
|
||||
// Obtain a renderPassDescriptor generated from the view's drawable textures.
|
||||
let render_pass_descriptor = RenderPassDescriptor::new();
|
||||
handle_render_pass_color_attachment(
|
||||
&render_pass_descriptor,
|
||||
drawable.texture(),
|
||||
);
|
||||
handle_render_pass_sample_buffer_attachment(
|
||||
&render_pass_descriptor,
|
||||
&counter_sample_buffer,
|
||||
);
|
||||
|
||||
// Create a render command encoder.
|
||||
let encoder = command_buffer
|
||||
.new_render_command_encoder(&render_pass_descriptor);
|
||||
encoder.set_render_pipeline_state(&pipeline_state);
|
||||
// Pass in the parameter data.
|
||||
encoder.set_vertex_buffer(0, Some(&vbuf), 0);
|
||||
// Draw the triangles which will eventually form the circle.
|
||||
encoder.draw_primitives(MTLPrimitiveType::TriangleStrip, 0, 1080);
|
||||
encoder.end_encoding();
|
||||
|
||||
resolve_samples_into_buffer(
|
||||
&command_buffer,
|
||||
&counter_sample_buffer,
|
||||
&destination_buffer,
|
||||
);
|
||||
|
||||
// Schedule a present once the framebuffer is complete using the current drawable.
|
||||
command_buffer.present_drawable(&drawable);
|
||||
|
||||
// Finalize rendering here & push the command buffer to the GPU.
|
||||
command_buffer.commit();
|
||||
command_buffer.wait_until_completed();
|
||||
|
||||
let mut cpu_end = 0;
|
||||
let mut gpu_end = 0;
|
||||
device.sample_timestamps(&mut cpu_end, &mut gpu_end);
|
||||
handle_timestamps(
|
||||
&destination_buffer,
|
||||
cpu_start,
|
||||
cpu_end,
|
||||
gpu_start,
|
||||
gpu_end,
|
||||
);
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
_ => (),
|
||||
match event {
|
||||
Event::WindowEvent {
|
||||
event: WindowEvent::CloseRequested,
|
||||
..
|
||||
} => {
|
||||
println!("The close button was pressed; stopping");
|
||||
*control_flow = ControlFlow::Exit
|
||||
}
|
||||
});
|
||||
})
|
||||
.unwrap();
|
||||
Event::MainEventsCleared => {
|
||||
// Queue a RedrawRequested event.
|
||||
window.request_redraw();
|
||||
}
|
||||
Event::RedrawRequested(_) => {
|
||||
// It's preferrable to render in this event rather than in MainEventsCleared, since
|
||||
// rendering in here allows the program to gracefully handle redraws requested
|
||||
// by the OS.
|
||||
let drawable = match layer.next_drawable() {
|
||||
Some(drawable) => drawable,
|
||||
None => return,
|
||||
};
|
||||
|
||||
// Create a new command buffer for each render pass to the current drawable
|
||||
let command_buffer = command_queue.new_command_buffer();
|
||||
|
||||
// Obtain a renderPassDescriptor generated from the view's drawable textures.
|
||||
let render_pass_descriptor = RenderPassDescriptor::new();
|
||||
handle_render_pass_color_attachment(
|
||||
&render_pass_descriptor,
|
||||
drawable.texture(),
|
||||
);
|
||||
handle_render_pass_sample_buffer_attachment(
|
||||
&render_pass_descriptor,
|
||||
&counter_sample_buffer,
|
||||
);
|
||||
|
||||
// Create a render command encoder.
|
||||
let encoder =
|
||||
command_buffer.new_render_command_encoder(&render_pass_descriptor);
|
||||
encoder.set_render_pipeline_state(&pipeline_state);
|
||||
// Pass in the parameter data.
|
||||
encoder.set_vertex_buffer(0, Some(&vbuf), 0);
|
||||
// Draw the triangles which will eventually form the circle.
|
||||
encoder.draw_primitives(MTLPrimitiveType::TriangleStrip, 0, 1080);
|
||||
encoder.end_encoding();
|
||||
|
||||
resolve_samples_into_buffer(
|
||||
&command_buffer,
|
||||
&counter_sample_buffer,
|
||||
&destination_buffer,
|
||||
);
|
||||
|
||||
// Schedule a present once the framebuffer is complete using the current drawable.
|
||||
command_buffer.present_drawable(&drawable);
|
||||
|
||||
// Finalize rendering here & push the command buffer to the GPU.
|
||||
command_buffer.commit();
|
||||
command_buffer.wait_until_completed();
|
||||
|
||||
let mut cpu_end = 0;
|
||||
let mut gpu_end = 0;
|
||||
device.sample_timestamps(&mut cpu_end, &mut gpu_end);
|
||||
handle_timestamps(&destination_buffer, cpu_start, cpu_end, gpu_start, gpu_end);
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// If we want to draw a circle, we need to draw it out of the three primitive
|
||||
|
|
|
@ -6,11 +6,11 @@ use core_graphics_types::geometry::CGSize;
|
|||
use metal::*;
|
||||
use objc::{rc::autoreleasepool, runtime::YES};
|
||||
use std::mem;
|
||||
use winit::platform::macos::WindowExtMacOS;
|
||||
|
||||
use winit::{
|
||||
event::{Event, WindowEvent},
|
||||
event_loop::ControlFlow,
|
||||
raw_window_handle::{HasWindowHandle, RawWindowHandle},
|
||||
};
|
||||
|
||||
fn prepare_render_pass_descriptor(descriptor: &RenderPassDescriptorRef, texture: &TextureRef) {
|
||||
|
@ -23,13 +23,13 @@ fn prepare_render_pass_descriptor(descriptor: &RenderPassDescriptorRef, texture:
|
|||
}
|
||||
|
||||
fn main() {
|
||||
let event_loop = winit::event_loop::EventLoop::new().unwrap();
|
||||
let events_loop = winit::event_loop::EventLoop::new();
|
||||
let size = winit::dpi::LogicalSize::new(800, 600);
|
||||
|
||||
let window = winit::window::WindowBuilder::new()
|
||||
.with_inner_size(size)
|
||||
.with_title("Metal Mesh Shader Example".to_string())
|
||||
.build(&event_loop)
|
||||
.build(&events_loop)
|
||||
.unwrap();
|
||||
|
||||
let device = Device::system_default().expect("no device found");
|
||||
|
@ -40,11 +40,9 @@ fn main() {
|
|||
layer.set_presents_with_transaction(false);
|
||||
|
||||
unsafe {
|
||||
if let Ok(RawWindowHandle::AppKit(rw)) = window.window_handle().map(|wh| wh.as_raw()) {
|
||||
let view = rw.ns_view.as_ptr() as cocoa_id;
|
||||
view.setWantsLayer(YES);
|
||||
view.setLayer(mem::transmute(layer.as_ref()));
|
||||
}
|
||||
let view = window.ns_view() as cocoa_id;
|
||||
view.setWantsLayer(YES);
|
||||
view.setLayer(mem::transmute(layer.as_ref()));
|
||||
}
|
||||
|
||||
let draw_size = window.inner_size();
|
||||
|
@ -72,57 +70,49 @@ fn main() {
|
|||
|
||||
let command_queue = device.new_command_queue();
|
||||
|
||||
event_loop
|
||||
.run(move |event, event_loop| {
|
||||
autoreleasepool(|| {
|
||||
event_loop.set_control_flow(ControlFlow::Poll);
|
||||
events_loop.run(move |event, _, control_flow| {
|
||||
autoreleasepool(|| {
|
||||
*control_flow = ControlFlow::Poll;
|
||||
|
||||
match event {
|
||||
Event::AboutToWait => {
|
||||
window.request_redraw();
|
||||
match event {
|
||||
Event::WindowEvent { event, .. } => match event {
|
||||
WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit,
|
||||
WindowEvent::Resized(size) => {
|
||||
layer.set_drawable_size(CGSize::new(size.width as f64, size.height as f64));
|
||||
}
|
||||
Event::WindowEvent { event, .. } => match event {
|
||||
WindowEvent::CloseRequested => event_loop.exit(),
|
||||
WindowEvent::Resized(size) => {
|
||||
layer.set_drawable_size(CGSize::new(
|
||||
size.width as f64,
|
||||
size.height as f64,
|
||||
));
|
||||
}
|
||||
WindowEvent::RedrawRequested => {
|
||||
let drawable = match layer.next_drawable() {
|
||||
Some(drawable) => drawable,
|
||||
None => return,
|
||||
};
|
||||
|
||||
let render_pass_descriptor = RenderPassDescriptor::new();
|
||||
|
||||
prepare_render_pass_descriptor(
|
||||
&render_pass_descriptor,
|
||||
drawable.texture(),
|
||||
);
|
||||
|
||||
let command_buffer = command_queue.new_command_buffer();
|
||||
let encoder =
|
||||
command_buffer.new_render_command_encoder(&render_pass_descriptor);
|
||||
|
||||
encoder.set_render_pipeline_state(&pipeline_state);
|
||||
encoder.draw_mesh_threads(
|
||||
MTLSize::new(1, 1, 1),
|
||||
MTLSize::new(1, 1, 1),
|
||||
MTLSize::new(1, 1, 1),
|
||||
);
|
||||
|
||||
encoder.end_encoding();
|
||||
|
||||
command_buffer.present_drawable(&drawable);
|
||||
command_buffer.commit();
|
||||
}
|
||||
_ => (),
|
||||
},
|
||||
_ => {}
|
||||
_ => (),
|
||||
},
|
||||
Event::MainEventsCleared => {
|
||||
window.request_redraw();
|
||||
}
|
||||
});
|
||||
})
|
||||
.unwrap();
|
||||
Event::RedrawRequested(_) => {
|
||||
let drawable = match layer.next_drawable() {
|
||||
Some(drawable) => drawable,
|
||||
None => return,
|
||||
};
|
||||
|
||||
let render_pass_descriptor = RenderPassDescriptor::new();
|
||||
|
||||
prepare_render_pass_descriptor(&render_pass_descriptor, drawable.texture());
|
||||
|
||||
let command_buffer = command_queue.new_command_buffer();
|
||||
let encoder =
|
||||
command_buffer.new_render_command_encoder(&render_pass_descriptor);
|
||||
|
||||
encoder.set_render_pipeline_state(&pipeline_state);
|
||||
encoder.draw_mesh_threads(
|
||||
MTLSize::new(1, 1, 1),
|
||||
MTLSize::new(1, 1, 1),
|
||||
MTLSize::new(1, 1, 1),
|
||||
);
|
||||
|
||||
encoder.end_encoding();
|
||||
|
||||
command_buffer.present_drawable(&drawable);
|
||||
command_buffer.commit();
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ use std::mem;
|
|||
use winit::{
|
||||
event::{Event, WindowEvent},
|
||||
event_loop::ControlFlow,
|
||||
raw_window_handle::{HasWindowHandle, RawWindowHandle},
|
||||
platform::macos::WindowExtMacOS,
|
||||
};
|
||||
|
||||
pub mod camera;
|
||||
|
@ -31,13 +31,13 @@ fn find_raytracing_supporting_device() -> Device {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
let event_loop = winit::event_loop::EventLoop::new().unwrap();
|
||||
let events_loop = winit::event_loop::EventLoop::new();
|
||||
let size = winit::dpi::LogicalSize::new(800, 600);
|
||||
|
||||
let window = winit::window::WindowBuilder::new()
|
||||
.with_inner_size(size)
|
||||
.with_title("Metal Raytracing Example".to_string())
|
||||
.build(&event_loop)
|
||||
.build(&events_loop)
|
||||
.unwrap();
|
||||
|
||||
let device = find_raytracing_supporting_device();
|
||||
|
@ -48,11 +48,9 @@ fn main() {
|
|||
layer.set_presents_with_transaction(false);
|
||||
|
||||
unsafe {
|
||||
if let Ok(RawWindowHandle::AppKit(rw)) = window.window_handle().map(|wh| wh.as_raw()) {
|
||||
let view = rw.ns_view.as_ptr() as cocoa_id;
|
||||
view.setWantsLayer(YES);
|
||||
view.setLayer(mem::transmute(layer.as_ref()));
|
||||
}
|
||||
let view = window.ns_view() as cocoa_id;
|
||||
view.setWantsLayer(YES);
|
||||
view.setLayer(mem::transmute(layer.as_ref()));
|
||||
}
|
||||
|
||||
let draw_size = window.inner_size();
|
||||
|
@ -62,28 +60,28 @@ fn main() {
|
|||
let mut renderer = renderer::Renderer::new(device);
|
||||
renderer.window_resized(cg_size);
|
||||
|
||||
event_loop
|
||||
.run(move |event, event_loop| {
|
||||
autoreleasepool(|| {
|
||||
event_loop.set_control_flow(ControlFlow::Poll);
|
||||
events_loop.run(move |event, _, control_flow| {
|
||||
autoreleasepool(|| {
|
||||
*control_flow = ControlFlow::Poll;
|
||||
|
||||
match event {
|
||||
Event::AboutToWait => window.request_redraw(),
|
||||
Event::WindowEvent { event, .. } => match event {
|
||||
WindowEvent::CloseRequested => event_loop.exit(),
|
||||
WindowEvent::Resized(size) => {
|
||||
let size = CGSize::new(size.width as f64, size.height as f64);
|
||||
layer.set_drawable_size(size);
|
||||
renderer.window_resized(size);
|
||||
}
|
||||
WindowEvent::RedrawRequested => {
|
||||
renderer.draw(&layer);
|
||||
}
|
||||
_ => (),
|
||||
},
|
||||
_ => {}
|
||||
match event {
|
||||
Event::WindowEvent { event, .. } => match event {
|
||||
WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit,
|
||||
WindowEvent::Resized(size) => {
|
||||
let size = CGSize::new(size.width as f64, size.height as f64);
|
||||
layer.set_drawable_size(size);
|
||||
renderer.window_resized(size);
|
||||
}
|
||||
_ => (),
|
||||
},
|
||||
Event::MainEventsCleared => {
|
||||
window.request_redraw();
|
||||
}
|
||||
});
|
||||
})
|
||||
.unwrap();
|
||||
Event::RedrawRequested(_) => {
|
||||
renderer.draw(&layer);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ use objc::{rc::autoreleasepool, runtime::YES};
|
|||
use winit::{
|
||||
event::{Event, WindowEvent},
|
||||
event_loop::ControlFlow,
|
||||
raw_window_handle::{HasWindowHandle, RawWindowHandle},
|
||||
platform::macos::WindowExtMacOS,
|
||||
};
|
||||
|
||||
use std::mem;
|
||||
|
@ -43,11 +43,9 @@ impl App {
|
|||
layer.set_presents_with_transaction(false);
|
||||
layer.set_framebuffer_only(false);
|
||||
unsafe {
|
||||
if let Ok(RawWindowHandle::AppKit(rw)) = window.window_handle().map(|wh| wh.as_raw()) {
|
||||
let view = rw.ns_view.as_ptr() as cocoa_id;
|
||||
view.setWantsLayer(YES);
|
||||
view.setLayer(mem::transmute(layer.as_ref()));
|
||||
}
|
||||
let view = window.ns_view() as cocoa_id;
|
||||
view.setWantsLayer(YES);
|
||||
view.setLayer(mem::transmute(layer.as_ref()));
|
||||
}
|
||||
let draw_size = window.inner_size();
|
||||
layer.set_drawable_size(CGSize::new(draw_size.width as f64, draw_size.height as f64));
|
||||
|
@ -143,37 +141,37 @@ impl App {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
let event_loop = winit::event_loop::EventLoop::new().unwrap();
|
||||
let events_loop = winit::event_loop::EventLoop::new();
|
||||
let size = winit::dpi::LogicalSize::new(800, 600);
|
||||
|
||||
let window = winit::window::WindowBuilder::new()
|
||||
.with_inner_size(size)
|
||||
.with_title("Metal Shader Dylib Example".to_string())
|
||||
.build(&event_loop)
|
||||
.build(&events_loop)
|
||||
.unwrap();
|
||||
|
||||
let mut app = App::new(&window);
|
||||
|
||||
event_loop
|
||||
.run(move |event, event_loop| {
|
||||
autoreleasepool(|| {
|
||||
event_loop.set_control_flow(ControlFlow::Poll);
|
||||
events_loop.run(move |event, _, control_flow| {
|
||||
autoreleasepool(|| {
|
||||
*control_flow = ControlFlow::Poll;
|
||||
|
||||
match event {
|
||||
Event::AboutToWait => window.request_redraw(),
|
||||
Event::WindowEvent { event, .. } => match event {
|
||||
WindowEvent::CloseRequested => event_loop.exit(),
|
||||
WindowEvent::Resized(size) => {
|
||||
app.resize(size.width, size.height);
|
||||
}
|
||||
WindowEvent::RedrawRequested => {
|
||||
app.draw();
|
||||
}
|
||||
_ => (),
|
||||
},
|
||||
_ => {}
|
||||
match event {
|
||||
Event::WindowEvent { event, .. } => match event {
|
||||
WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit,
|
||||
WindowEvent::Resized(size) => {
|
||||
app.resize(size.width, size.height);
|
||||
}
|
||||
_ => (),
|
||||
},
|
||||
Event::MainEventsCleared => {
|
||||
window.request_redraw();
|
||||
}
|
||||
});
|
||||
})
|
||||
.unwrap();
|
||||
Event::RedrawRequested(_) => {
|
||||
app.draw();
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -13,11 +13,11 @@ use core_graphics_types::geometry::CGSize;
|
|||
use metal::*;
|
||||
use objc::{rc::autoreleasepool, runtime::YES};
|
||||
use std::mem;
|
||||
use winit::platform::macos::WindowExtMacOS;
|
||||
|
||||
use winit::{
|
||||
event::{Event, WindowEvent},
|
||||
event_loop::ControlFlow,
|
||||
raw_window_handle::{HasWindowHandle, RawWindowHandle},
|
||||
};
|
||||
|
||||
#[repr(C)]
|
||||
|
@ -85,13 +85,13 @@ fn prepare_render_pass_descriptor(descriptor: &RenderPassDescriptorRef, texture:
|
|||
}
|
||||
|
||||
fn main() {
|
||||
let event_loop = winit::event_loop::EventLoop::new().unwrap();
|
||||
let events_loop = winit::event_loop::EventLoop::new();
|
||||
let size = winit::dpi::LogicalSize::new(800, 600);
|
||||
|
||||
let window = winit::window::WindowBuilder::new()
|
||||
.with_inner_size(size)
|
||||
.with_title("Metal Window Example".to_string())
|
||||
.build(&event_loop)
|
||||
.build(&events_loop)
|
||||
.unwrap();
|
||||
|
||||
let device = Device::system_default().expect("no device found");
|
||||
|
@ -102,11 +102,9 @@ fn main() {
|
|||
layer.set_presents_with_transaction(false);
|
||||
|
||||
unsafe {
|
||||
if let Ok(RawWindowHandle::AppKit(rw)) = window.window_handle().map(|wh| wh.as_raw()) {
|
||||
let view = rw.ns_view.as_ptr() as cocoa_id;
|
||||
view.setWantsLayer(YES);
|
||||
view.setLayer(mem::transmute(layer.as_ref()));
|
||||
}
|
||||
let view = window.ns_view() as cocoa_id;
|
||||
view.setWantsLayer(YES);
|
||||
view.setLayer(mem::transmute(layer.as_ref()));
|
||||
}
|
||||
|
||||
let draw_size = window.inner_size();
|
||||
|
@ -163,107 +161,101 @@ fn main() {
|
|||
MTLResourceOptions::CPUCacheModeDefaultCache | MTLResourceOptions::StorageModeManaged,
|
||||
);
|
||||
|
||||
event_loop
|
||||
.run(move |event, event_loop| {
|
||||
autoreleasepool(|| {
|
||||
event_loop.set_control_flow(ControlFlow::Poll);
|
||||
events_loop.run(move |event, _, control_flow| {
|
||||
autoreleasepool(|| {
|
||||
*control_flow = ControlFlow::Poll;
|
||||
|
||||
match event {
|
||||
Event::AboutToWait => window.request_redraw(),
|
||||
Event::WindowEvent { event, .. } => match event {
|
||||
WindowEvent::CloseRequested => event_loop.exit(),
|
||||
WindowEvent::Resized(size) => {
|
||||
layer.set_drawable_size(CGSize::new(
|
||||
size.width as f64,
|
||||
size.height as f64,
|
||||
));
|
||||
}
|
||||
WindowEvent::RedrawRequested => {
|
||||
let p = vbuf.contents();
|
||||
let vertex_data = [
|
||||
0.0f32,
|
||||
0.5,
|
||||
1.0,
|
||||
0.0,
|
||||
0.0,
|
||||
-0.5 + (r.cos() / 2. + 0.5),
|
||||
-0.5,
|
||||
0.0,
|
||||
1.0,
|
||||
0.0,
|
||||
0.5 - (r.cos() / 2. + 0.5),
|
||||
-0.5,
|
||||
0.0,
|
||||
0.0,
|
||||
1.0,
|
||||
];
|
||||
|
||||
unsafe {
|
||||
std::ptr::copy(
|
||||
vertex_data.as_ptr(),
|
||||
p as *mut f32,
|
||||
(vertex_data.len() * mem::size_of::<f32>()) as usize,
|
||||
);
|
||||
}
|
||||
|
||||
vbuf.did_modify_range(crate::NSRange::new(
|
||||
0 as u64,
|
||||
(vertex_data.len() * mem::size_of::<f32>()) as u64,
|
||||
));
|
||||
|
||||
let drawable = match layer.next_drawable() {
|
||||
Some(drawable) => drawable,
|
||||
None => return,
|
||||
};
|
||||
|
||||
let render_pass_descriptor = RenderPassDescriptor::new();
|
||||
|
||||
prepare_render_pass_descriptor(
|
||||
&render_pass_descriptor,
|
||||
drawable.texture(),
|
||||
);
|
||||
|
||||
let command_buffer = command_queue.new_command_buffer();
|
||||
let encoder =
|
||||
command_buffer.new_render_command_encoder(&render_pass_descriptor);
|
||||
|
||||
encoder.set_scissor_rect(MTLScissorRect {
|
||||
x: 20,
|
||||
y: 20,
|
||||
width: 100,
|
||||
height: 100,
|
||||
});
|
||||
encoder.set_render_pipeline_state(&clear_rect_pipeline_state);
|
||||
encoder.set_vertex_buffer(0, Some(&clear_rect_buffer), 0);
|
||||
encoder.draw_primitives_instanced(
|
||||
metal::MTLPrimitiveType::TriangleStrip,
|
||||
0,
|
||||
4,
|
||||
1,
|
||||
);
|
||||
let physical_size = window.inner_size();
|
||||
encoder.set_scissor_rect(MTLScissorRect {
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: physical_size.width as _,
|
||||
height: physical_size.height as _,
|
||||
});
|
||||
|
||||
encoder.set_render_pipeline_state(&triangle_pipeline_state);
|
||||
encoder.set_vertex_buffer(0, Some(&vbuf), 0);
|
||||
encoder.draw_primitives(MTLPrimitiveType::Triangle, 0, 3);
|
||||
encoder.end_encoding();
|
||||
|
||||
command_buffer.present_drawable(&drawable);
|
||||
command_buffer.commit();
|
||||
|
||||
r += 0.01f32;
|
||||
}
|
||||
_ => (),
|
||||
},
|
||||
_ => {}
|
||||
match event {
|
||||
Event::WindowEvent { event, .. } => match event {
|
||||
WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit,
|
||||
WindowEvent::Resized(size) => {
|
||||
layer.set_drawable_size(CGSize::new(size.width as f64, size.height as f64));
|
||||
}
|
||||
_ => (),
|
||||
},
|
||||
Event::MainEventsCleared => {
|
||||
window.request_redraw();
|
||||
}
|
||||
});
|
||||
})
|
||||
.unwrap();
|
||||
Event::RedrawRequested(_) => {
|
||||
let p = vbuf.contents();
|
||||
let vertex_data = [
|
||||
0.0f32,
|
||||
0.5,
|
||||
1.0,
|
||||
0.0,
|
||||
0.0,
|
||||
-0.5 + (r.cos() / 2. + 0.5),
|
||||
-0.5,
|
||||
0.0,
|
||||
1.0,
|
||||
0.0,
|
||||
0.5 - (r.cos() / 2. + 0.5),
|
||||
-0.5,
|
||||
0.0,
|
||||
0.0,
|
||||
1.0,
|
||||
];
|
||||
|
||||
unsafe {
|
||||
std::ptr::copy(
|
||||
vertex_data.as_ptr(),
|
||||
p as *mut f32,
|
||||
(vertex_data.len() * mem::size_of::<f32>()) as usize,
|
||||
);
|
||||
}
|
||||
|
||||
vbuf.did_modify_range(crate::NSRange::new(
|
||||
0 as u64,
|
||||
(vertex_data.len() * mem::size_of::<f32>()) as u64,
|
||||
));
|
||||
|
||||
let drawable = match layer.next_drawable() {
|
||||
Some(drawable) => drawable,
|
||||
None => return,
|
||||
};
|
||||
|
||||
let render_pass_descriptor = RenderPassDescriptor::new();
|
||||
|
||||
prepare_render_pass_descriptor(&render_pass_descriptor, drawable.texture());
|
||||
|
||||
let command_buffer = command_queue.new_command_buffer();
|
||||
let encoder =
|
||||
command_buffer.new_render_command_encoder(&render_pass_descriptor);
|
||||
|
||||
encoder.set_scissor_rect(MTLScissorRect {
|
||||
x: 20,
|
||||
y: 20,
|
||||
width: 100,
|
||||
height: 100,
|
||||
});
|
||||
encoder.set_render_pipeline_state(&clear_rect_pipeline_state);
|
||||
encoder.set_vertex_buffer(0, Some(&clear_rect_buffer), 0);
|
||||
encoder.draw_primitives_instanced(
|
||||
metal::MTLPrimitiveType::TriangleStrip,
|
||||
0,
|
||||
4,
|
||||
1,
|
||||
);
|
||||
let physical_size = window.inner_size();
|
||||
encoder.set_scissor_rect(MTLScissorRect {
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: physical_size.width as _,
|
||||
height: physical_size.height as _,
|
||||
});
|
||||
|
||||
encoder.set_render_pipeline_state(&triangle_pipeline_state);
|
||||
encoder.set_vertex_buffer(0, Some(&vbuf), 0);
|
||||
encoder.draw_primitives(MTLPrimitiveType::Triangle, 0, 3);
|
||||
encoder.end_encoding();
|
||||
|
||||
command_buffer.present_drawable(&drawable);
|
||||
command_buffer.commit();
|
||||
|
||||
r += 0.01f32;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
use super::*;
|
||||
|
||||
bitflags::bitflags! {
|
||||
bitflags! {
|
||||
#[derive(Copy, Clone, Debug, Default, Hash, PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub struct MTLAccelerationStructureInstanceOptions: u32 {
|
||||
const None = 0;
|
||||
|
@ -26,7 +26,6 @@ pub enum MTLAccelerationStructureInstanceDescriptorType {
|
|||
Default = 0,
|
||||
UserID = 1,
|
||||
Motion = 2,
|
||||
Indirect = 3,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Debug, Default)]
|
||||
|
@ -50,17 +49,6 @@ pub struct MTLAccelerationStructureUserIDInstanceDescriptor {
|
|||
pub user_id: u32,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Debug, Default)]
|
||||
#[repr(C)]
|
||||
pub struct MTLIndirectAccelerationStructureInstanceDescriptor {
|
||||
pub transformation_matrix: [[f32; 3]; 4],
|
||||
pub options: MTLAccelerationStructureInstanceOptions,
|
||||
pub mask: u32,
|
||||
pub intersection_function_table_offset: u32,
|
||||
pub user_id: u32,
|
||||
pub acceleration_structure_id: u64,
|
||||
}
|
||||
|
||||
pub enum MTLAccelerationStructureDescriptor {}
|
||||
|
||||
foreign_obj_type! {
|
||||
|
@ -81,9 +69,7 @@ impl PrimitiveAccelerationStructureDescriptor {
|
|||
pub fn descriptor() -> Self {
|
||||
unsafe {
|
||||
let class = class!(MTLPrimitiveAccelerationStructureDescriptor);
|
||||
let ptr: *mut Object = msg_send![class, descriptor];
|
||||
let ptr: *mut Object = msg_send![ptr, retain];
|
||||
Self::from_ptr(ptr as _)
|
||||
msg_send![class, descriptor]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -105,12 +91,6 @@ foreign_obj_type! {
|
|||
type ParentType = Resource;
|
||||
}
|
||||
|
||||
impl AccelerationStructureRef {
|
||||
pub fn gpu_resource_id(&self) -> MTLResourceID {
|
||||
unsafe { msg_send![self, gpuResourceID] }
|
||||
}
|
||||
}
|
||||
|
||||
pub enum MTLAccelerationStructureGeometryDescriptor {}
|
||||
|
||||
foreign_obj_type! {
|
||||
|
@ -152,9 +132,7 @@ impl AccelerationStructureTriangleGeometryDescriptor {
|
|||
pub fn descriptor() -> Self {
|
||||
unsafe {
|
||||
let class = class!(MTLAccelerationStructureTriangleGeometryDescriptor);
|
||||
let ptr: *mut Object = msg_send![class, descriptor];
|
||||
let ptr: *mut Object = msg_send![ptr, retain];
|
||||
Self::from_ptr(ptr as _)
|
||||
msg_send![class, descriptor]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -213,9 +191,7 @@ impl AccelerationStructureBoundingBoxGeometryDescriptor {
|
|||
pub fn descriptor() -> Self {
|
||||
unsafe {
|
||||
let class = class!(MTLAccelerationStructureBoundingBoxGeometryDescriptor);
|
||||
let ptr: *mut Object = msg_send![class, descriptor];
|
||||
let ptr: *mut Object = msg_send![ptr, retain];
|
||||
Self::from_ptr(ptr as _)
|
||||
msg_send![class, descriptor]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -228,14 +204,6 @@ impl AccelerationStructureBoundingBoxGeometryDescriptorRef {
|
|||
pub fn set_bounding_box_count(&self, count: NSUInteger) {
|
||||
unsafe { msg_send![self, setBoundingBoxCount: count] }
|
||||
}
|
||||
|
||||
pub fn set_bounding_box_stride(&self, stride: NSUInteger) {
|
||||
unsafe { msg_send![self, setBoundingBoxStride: stride] }
|
||||
}
|
||||
|
||||
pub fn set_bounding_box_buffer_offset(&self, offset: NSUInteger) {
|
||||
unsafe { msg_send![self, setBoundingBoxBufferOffset: offset] }
|
||||
}
|
||||
}
|
||||
|
||||
pub enum MTLInstanceAccelerationStructureDescriptor {}
|
||||
|
@ -250,9 +218,7 @@ impl InstanceAccelerationStructureDescriptor {
|
|||
pub fn descriptor() -> Self {
|
||||
unsafe {
|
||||
let class = class!(MTLInstanceAccelerationStructureDescriptor);
|
||||
let ptr: *mut Object = msg_send![class, descriptor];
|
||||
let ptr: *mut Object = msg_send![ptr, retain];
|
||||
Self::from_ptr(ptr as _)
|
||||
msg_send![class, descriptor]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -286,75 +252,6 @@ impl InstanceAccelerationStructureDescriptorRef {
|
|||
}
|
||||
}
|
||||
|
||||
pub enum MTLIndirectInstanceAccelerationStructureDescriptor {}
|
||||
|
||||
foreign_obj_type! {
|
||||
type CType = MTLIndirectInstanceAccelerationStructureDescriptor;
|
||||
pub struct IndirectInstanceAccelerationStructureDescriptor;
|
||||
type ParentType = AccelerationStructureDescriptor;
|
||||
}
|
||||
|
||||
impl IndirectInstanceAccelerationStructureDescriptor {
|
||||
pub fn descriptor() -> Self {
|
||||
unsafe {
|
||||
let class = class!(MTLIndirectInstanceAccelerationStructureDescriptor);
|
||||
let ptr: *mut Object = msg_send![class, descriptor];
|
||||
let ptr: *mut Object = msg_send![ptr, retain];
|
||||
Self::from_ptr(ptr as _)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl IndirectInstanceAccelerationStructureDescriptorRef {
|
||||
pub fn set_instance_descriptor_buffer(&self, buffer: &BufferRef) {
|
||||
unsafe { msg_send![self, setInstanceDescriptorBuffer: buffer] }
|
||||
}
|
||||
|
||||
pub fn set_instance_descriptor_buffer_offset(&self, offset: NSUInteger) {
|
||||
unsafe { msg_send![self, setInstanceDescriptorBufferOffset: offset] }
|
||||
}
|
||||
|
||||
pub fn set_instance_descriptor_stride(&self, stride: NSUInteger) {
|
||||
unsafe { msg_send![self, setInstanceDescriptorStride: stride] }
|
||||
}
|
||||
|
||||
pub fn set_max_instance_count(&self, count: NSUInteger) {
|
||||
unsafe { msg_send![self, setMaxInstanceCount: count] }
|
||||
}
|
||||
|
||||
pub fn set_instance_count_buffer(&self, buffer: &BufferRef) {
|
||||
unsafe { msg_send![self, setInstanceCountBuffer: buffer] }
|
||||
}
|
||||
|
||||
pub fn set_instance_count_buffer_offset(&self, offset: NSUInteger) {
|
||||
unsafe { msg_send![self, setInstanceCountBufferOffset: offset] }
|
||||
}
|
||||
|
||||
pub fn set_instance_descriptor_type(&self, ty: MTLAccelerationStructureInstanceDescriptorType) {
|
||||
unsafe { msg_send![self, setInstanceDescriptorType: ty] }
|
||||
}
|
||||
|
||||
pub fn set_motion_transform_buffer(&self, buffer: &BufferRef) {
|
||||
unsafe { msg_send![self, setMotionTransformBuffer: buffer] }
|
||||
}
|
||||
|
||||
pub fn set_motion_transform_buffer_offset(&self, offset: NSUInteger) {
|
||||
unsafe { msg_send![self, setMotionTransformBufferOffset: offset] }
|
||||
}
|
||||
|
||||
pub fn set_max_motion_transform_count(&self, count: NSUInteger) {
|
||||
unsafe { msg_send![self, setMaxMotionTransformCount: count] }
|
||||
}
|
||||
|
||||
pub fn set_motion_transform_count_buffer(&self, buffer: &BufferRef) {
|
||||
unsafe { msg_send![self, setMotionTransformCountBuffer: buffer] }
|
||||
}
|
||||
|
||||
pub fn set_motion_transform_count_buffer_offset(&self, offset: NSUInteger) {
|
||||
unsafe { msg_send![self, setMotionTransformCountBufferOffset: offset] }
|
||||
}
|
||||
}
|
||||
|
||||
pub enum MTLAccelerationStructureCommandEncoder {}
|
||||
|
||||
foreign_obj_type! {
|
||||
|
@ -373,26 +270,11 @@ impl AccelerationStructureCommandEncoderRef {
|
|||
) {
|
||||
unsafe {
|
||||
msg_send![
|
||||
self,
|
||||
buildAccelerationStructure: acceleration_structure
|
||||
descriptor: descriptor
|
||||
scratchBuffer: scratch_buffer
|
||||
scratchBufferOffset: scratch_buffer_offset
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
pub fn copy_acceleration_structure(
|
||||
&self,
|
||||
source_acceleration_structure: &AccelerationStructureRef,
|
||||
destination_acceleration_structure: &AccelerationStructureRef,
|
||||
) {
|
||||
unsafe {
|
||||
msg_send![
|
||||
self,
|
||||
copyAccelerationStructure: source_acceleration_structure
|
||||
toAccelerationStructure: destination_acceleration_structure
|
||||
]
|
||||
self,
|
||||
buildAccelerationStructure: acceleration_structure
|
||||
descriptor: descriptor
|
||||
scratchBuffer: scratch_buffer
|
||||
scratchBufferOffset: scratch_buffer_offset]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -412,24 +294,6 @@ impl AccelerationStructureCommandEncoderRef {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn write_compacted_acceleration_structure_size_with_type(
|
||||
&self,
|
||||
acceleration_structure: &AccelerationStructureRef,
|
||||
to_buffer: &BufferRef,
|
||||
offset: NSUInteger,
|
||||
size_data_type: MTLDataType,
|
||||
) {
|
||||
unsafe {
|
||||
msg_send![
|
||||
self,
|
||||
writeCompactedAccelerationStructureSize: acceleration_structure
|
||||
toBuffer: to_buffer
|
||||
offset: offset
|
||||
sizeDataType: size_data_type
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
pub fn copy_and_compact_acceleration_structure(
|
||||
&self,
|
||||
source: &AccelerationStructureRef,
|
||||
|
@ -443,81 +307,6 @@ impl AccelerationStructureCommandEncoderRef {
|
|||
]
|
||||
}
|
||||
}
|
||||
|
||||
pub fn refit_acceleration_structure(
|
||||
&self,
|
||||
source_acceleration_structure: &AccelerationStructureRef,
|
||||
descriptor: &self::AccelerationStructureDescriptorRef,
|
||||
destination_acceleration_structure: Option<&AccelerationStructureRef>,
|
||||
scratch_buffer: &BufferRef,
|
||||
scratch_buffer_offset: NSUInteger,
|
||||
) {
|
||||
unsafe {
|
||||
msg_send![
|
||||
self,
|
||||
refitAccelerationStructure: source_acceleration_structure
|
||||
descriptor: descriptor
|
||||
destination: destination_acceleration_structure
|
||||
scratchBuffer: scratch_buffer
|
||||
scratchBufferOffset: scratch_buffer_offset
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
pub fn update_fence(&self, fence: &FenceRef) {
|
||||
unsafe { msg_send![self, updateFence: fence] }
|
||||
}
|
||||
|
||||
pub fn wait_for_fence(&self, fence: &FenceRef) {
|
||||
unsafe { msg_send![self, waitForFence: fence] }
|
||||
}
|
||||
|
||||
pub fn use_heap(&self, heap: &HeapRef) {
|
||||
unsafe { msg_send![self, useHeap: heap] }
|
||||
}
|
||||
|
||||
pub fn use_heaps(&self, heaps: &[&HeapRef]) {
|
||||
unsafe {
|
||||
msg_send![self,
|
||||
useHeaps: heaps.as_ptr()
|
||||
count: heaps.len() as NSUInteger
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
pub fn use_resource(&self, resource: &ResourceRef, usage: MTLResourceUsage) {
|
||||
unsafe {
|
||||
msg_send![self,
|
||||
useResource: resource
|
||||
usage: usage
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
pub fn use_resources(&self, resources: &[&ResourceRef], usage: MTLResourceUsage) {
|
||||
unsafe {
|
||||
msg_send![self,
|
||||
useResources: resources.as_ptr()
|
||||
count: resources.len() as NSUInteger
|
||||
usage: usage
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
pub fn sample_counters_in_buffer(
|
||||
&self,
|
||||
sample_buffer: &CounterSampleBufferRef,
|
||||
sample_index: NSUInteger,
|
||||
with_barrier: bool,
|
||||
) {
|
||||
unsafe {
|
||||
msg_send![self,
|
||||
sampleCountersInBuffer: sample_buffer
|
||||
atSampleIndex: sample_index
|
||||
withBarrier: with_barrier
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub enum MTLIntersectionFunctionTableDescriptor {}
|
||||
|
@ -556,112 +345,4 @@ impl IntersectionFunctionTableRef {
|
|||
pub fn set_function(&self, function: &FunctionHandleRef, index: NSUInteger) {
|
||||
unsafe { msg_send![self, setFunction: function atIndex: index] }
|
||||
}
|
||||
|
||||
pub fn set_functions(&self, functions: &[&FunctionHandleRef], start_index: NSUInteger) {
|
||||
unsafe {
|
||||
msg_send![self, setFunctions: functions.as_ptr() withRange: NSRange { location: start_index, length: functions.len() as _ }]
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_buffer(&self, index: NSUInteger, buffer: Option<&BufferRef>, offset: NSUInteger) {
|
||||
unsafe { msg_send![self, setBuffer:buffer offset:offset atIndex:index] }
|
||||
}
|
||||
|
||||
pub fn set_buffers(
|
||||
&self,
|
||||
start_index: NSUInteger,
|
||||
data: &[Option<&BufferRef>],
|
||||
offsets: &[NSUInteger],
|
||||
) {
|
||||
debug_assert_eq!(offsets.len(), data.len());
|
||||
unsafe {
|
||||
msg_send![self,
|
||||
setBuffers: data.as_ptr()
|
||||
offsets: offsets.as_ptr()
|
||||
withRange: NSRange {
|
||||
location: start_index,
|
||||
length: data.len() as _,
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_visible_function_table(
|
||||
&self,
|
||||
buffer_index: NSUInteger,
|
||||
visible_function_table: Option<&VisibleFunctionTableRef>,
|
||||
) {
|
||||
unsafe {
|
||||
msg_send![self,
|
||||
setVisibleFunctionTable:visible_function_table
|
||||
atBufferIndex:buffer_index]
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_visible_function_tables(
|
||||
&self,
|
||||
buffer_start_index: NSUInteger,
|
||||
visible_function_tables: &[&VisibleFunctionTableRef],
|
||||
) {
|
||||
unsafe {
|
||||
msg_send![self,
|
||||
setVisibleFunctionTables:visible_function_tables.as_ptr()
|
||||
withBufferRange: NSRange {
|
||||
location: buffer_start_index,
|
||||
length: visible_function_tables.len() as _,
|
||||
}]
|
||||
}
|
||||
}
|
||||
|
||||
pub fn gpu_resource_id(&self) -> MTLResourceID {
|
||||
unsafe { msg_send![self, gpuResourceID] }
|
||||
}
|
||||
}
|
||||
|
||||
/// See <https://developer.apple.com/documentation/metal/mtlvisiblefunctiontabledescriptor>
|
||||
pub enum MTLVisibleFunctionTableDescriptor {}
|
||||
|
||||
foreign_obj_type! {
|
||||
type CType = MTLVisibleFunctionTableDescriptor;
|
||||
pub struct VisibleFunctionTableDescriptor;
|
||||
type ParentType = NsObject;
|
||||
}
|
||||
|
||||
impl VisibleFunctionTableDescriptor {
|
||||
pub fn new() -> Self {
|
||||
unsafe {
|
||||
let class = class!(MTLVisibleFunctionTableDescriptor);
|
||||
msg_send![class, new]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl VisibleFunctionTableDescriptorRef {
|
||||
pub fn set_function_count(&self, count: NSUInteger) {
|
||||
unsafe { msg_send![self, setFunctionCount: count] }
|
||||
}
|
||||
}
|
||||
|
||||
/// See <https://developer.apple.com/documentation/metal/mtlvisiblefunctiontable>
|
||||
pub enum MTLVisibleFunctionTable {}
|
||||
|
||||
foreign_obj_type! {
|
||||
type CType = MTLVisibleFunctionTable;
|
||||
pub struct VisibleFunctionTable;
|
||||
type ParentType = Resource;
|
||||
}
|
||||
|
||||
impl VisibleFunctionTableRef {
|
||||
pub fn set_functions(&self, functions: &[&FunctionRef]) {
|
||||
let ns_array = Array::<Function>::from_slice(functions);
|
||||
unsafe { msg_send![self, setFunctions: ns_array] }
|
||||
}
|
||||
|
||||
pub fn set_function(&self, index: NSUInteger, function: &FunctionHandleRef) {
|
||||
unsafe { msg_send![self, setFunction: function atIndex: index] }
|
||||
}
|
||||
|
||||
pub fn gpu_resource_id(&self) -> MTLResourceID {
|
||||
unsafe { msg_send![self, gpuResourceID] }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -106,30 +106,6 @@ pub enum MTLDataType {
|
|||
RGB10A2Unorm = 75,
|
||||
RG11B10Float = 76,
|
||||
RGB9E5Float = 77,
|
||||
|
||||
RenderPipeline = 78,
|
||||
ComputePipeline = 79,
|
||||
IndirectCommandBuffer = 80,
|
||||
|
||||
Long = 81,
|
||||
Long2 = 82,
|
||||
Long3 = 83,
|
||||
Long4 = 84,
|
||||
|
||||
ULong = 85,
|
||||
ULong2 = 86,
|
||||
ULong3 = 87,
|
||||
ULong4 = 88,
|
||||
|
||||
VisibleFunctionTable = 115,
|
||||
IntersectionFunctionTable = 116,
|
||||
PrimitiveAccelerationStructure = 117,
|
||||
InstanceAccelerationStructure = 118,
|
||||
|
||||
BFloat = 121,
|
||||
BFloat2 = 122,
|
||||
BFloat3 = 123,
|
||||
BFloat4 = 124,
|
||||
}
|
||||
|
||||
/// See <https://developer.apple.com/documentation/metal/mtlargumenttype>
|
||||
|
|
|
@ -7,8 +7,7 @@
|
|||
|
||||
use super::*;
|
||||
|
||||
use block::Block;
|
||||
use log::warn;
|
||||
use block::{Block, ConcreteBlock};
|
||||
use objc::runtime::{NO, YES};
|
||||
|
||||
use std::{ffi::CStr, os::raw::c_char, path::Path, ptr};
|
||||
|
@ -93,7 +92,7 @@ pub enum MTLDeviceLocation {
|
|||
Unspecified = u64::MAX,
|
||||
}
|
||||
|
||||
bitflags::bitflags! {
|
||||
bitflags! {
|
||||
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub struct PixelFormatCapabilities: u32 {
|
||||
const Filter = 1 << 0;
|
||||
|
@ -1431,7 +1430,7 @@ pub enum MTLSparseTextureRegionAlignmentMode {
|
|||
Inward = 1,
|
||||
}
|
||||
|
||||
bitflags::bitflags! {
|
||||
bitflags! {
|
||||
/// Options that determine how Metal prepares the pipeline.
|
||||
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub struct MTLPipelineOption: NSUInteger {
|
||||
|
@ -1472,8 +1471,6 @@ pub type dispatch_queue_t = *mut Object;
|
|||
#[allow(non_camel_case_types)]
|
||||
type dispatch_block_t = *const Block<(), ()>;
|
||||
|
||||
const DISPATCH_DATA_DESTRUCTOR_DEFAULT: dispatch_block_t = ptr::null();
|
||||
|
||||
#[cfg_attr(
|
||||
all(feature = "link", any(target_os = "macos", target_os = "ios")),
|
||||
link(name = "System", kind = "dylib")
|
||||
|
@ -1707,20 +1704,12 @@ impl DeviceRef {
|
|||
|
||||
pub fn new_library_with_data(&self, library_data: &[u8]) -> Result<Library, String> {
|
||||
unsafe {
|
||||
// SAFETY:
|
||||
// `library_data` does not necessarily outlive the dispatch data
|
||||
// in which it will be contained (since the dispatch data will be
|
||||
// contained in the MTLLibrary returned by this function).
|
||||
//
|
||||
// To prevent the MTLLibrary from referencing the data outside of
|
||||
// its lifetime, we use DISPATCH_DATA_DESTRUCTOR_DEFAULT as the
|
||||
// destructor block, which will make `dispatch_data_create` copy
|
||||
// the buffer for us automatically.
|
||||
let destructor_block = ConcreteBlock::new(|| {}).copy();
|
||||
let data = dispatch_data_create(
|
||||
library_data.as_ptr() as *const std::ffi::c_void,
|
||||
library_data.len() as crate::c_size_t,
|
||||
&_dispatch_main_q as *const _ as dispatch_queue_t,
|
||||
DISPATCH_DATA_DESTRUCTOR_DEFAULT,
|
||||
&*destructor_block.deref(),
|
||||
);
|
||||
|
||||
let library: *mut MTLLibrary = try_objc! { err =>
|
||||
|
@ -2060,14 +2049,6 @@ impl DeviceRef {
|
|||
unsafe { msg_send![self, heapBufferSizeAndAlignWithLength: length options: options] }
|
||||
}
|
||||
|
||||
/// Only available on macos(13.0), ios(16.0)
|
||||
pub fn heap_acceleration_structure_size_and_align_with_size(
|
||||
&self,
|
||||
size: NSUInteger,
|
||||
) -> MTLSizeAndAlign {
|
||||
unsafe { msg_send![self, heapAccelerationStructureSizeAndAlignWithSize: size] }
|
||||
}
|
||||
|
||||
pub fn heap_texture_size_and_align(
|
||||
&self,
|
||||
descriptor: &TextureDescriptorRef,
|
||||
|
|
|
@ -5,13 +5,8 @@
|
|||
// http://opensource.org/licenses/MIT>, at your option. This file may not be
|
||||
// copied, modified, or distributed except according to those terms.
|
||||
|
||||
use block::Block;
|
||||
|
||||
use super::NSUInteger;
|
||||
|
||||
type DrawablePresentedHandler<'a> = Block<(&'a DrawableRef,), ()>;
|
||||
type CFTimeInterval = f64;
|
||||
|
||||
/// See <https://developer.apple.com/documentation/metal/mtldrawable>
|
||||
pub enum MTLDrawable {}
|
||||
|
||||
|
@ -28,12 +23,4 @@ impl DrawableRef {
|
|||
pub fn drawable_id(&self) -> NSUInteger {
|
||||
unsafe { msg_send![self, drawableID] }
|
||||
}
|
||||
|
||||
pub fn add_presented_handler(&self, block: &DrawablePresentedHandler) {
|
||||
unsafe { msg_send![self, addPresentedHandler: block] }
|
||||
}
|
||||
|
||||
pub fn presented_time(&self) -> CFTimeInterval {
|
||||
unsafe { msg_send![self, presentedTime] }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ pub enum MTLTriangleFillMode {
|
|||
Lines = 1,
|
||||
}
|
||||
|
||||
bitflags::bitflags! {
|
||||
bitflags! {
|
||||
/// https://developer.apple.com/documentation/metal/mtlblitoption
|
||||
#[allow(non_upper_case_globals)]
|
||||
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
|
||||
|
@ -444,34 +444,6 @@ impl RenderCommandEncoderRef {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn set_vertex_visible_function_table(
|
||||
&self,
|
||||
buffer_index: NSUInteger,
|
||||
visible_function_table: Option<&VisibleFunctionTableRef>,
|
||||
) {
|
||||
unsafe {
|
||||
msg_send![self,
|
||||
setVertexVisibleFunctionTable:visible_function_table
|
||||
atBufferIndex:buffer_index]
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_vertex_visible_function_tables(
|
||||
&self,
|
||||
buffer_start_index: NSUInteger,
|
||||
visible_function_tables: &[&VisibleFunctionTableRef],
|
||||
) {
|
||||
unsafe {
|
||||
msg_send![self,
|
||||
setVertexVisibleFunctionTables:visible_function_tables.as_ptr()
|
||||
withBufferRange: NSRange {
|
||||
location: buffer_start_index,
|
||||
length: visible_function_tables.len() as _,
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
// Specifying Resources for a Object Shader Function
|
||||
|
||||
/// Only available in (macos(13.0), ios(16.0))
|
||||
|
@ -894,34 +866,6 @@ impl RenderCommandEncoderRef {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn set_fragment_visible_function_table(
|
||||
&self,
|
||||
buffer_index: NSUInteger,
|
||||
visible_function_table: Option<&VisibleFunctionTableRef>,
|
||||
) {
|
||||
unsafe {
|
||||
msg_send![self,
|
||||
setFragmentVisibleFunctionTable:visible_function_table
|
||||
atBufferIndex:buffer_index]
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_fragment_visible_function_tables(
|
||||
&self,
|
||||
buffer_start_index: NSUInteger,
|
||||
visible_function_tables: &[&VisibleFunctionTableRef],
|
||||
) {
|
||||
unsafe {
|
||||
msg_send![self,
|
||||
setFragmentVisibleFunctionTables:visible_function_tables.as_ptr()
|
||||
withBufferRange: NSRange {
|
||||
location: buffer_start_index,
|
||||
length: visible_function_tables.len() as _,
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
// Drawing Geometric Primitives
|
||||
|
||||
pub fn draw_primitives(
|
||||
|
@ -1650,34 +1594,6 @@ impl ComputeCommandEncoderRef {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn set_visible_function_table(
|
||||
&self,
|
||||
buffer_index: NSUInteger,
|
||||
visible_function_table: Option<&VisibleFunctionTableRef>,
|
||||
) {
|
||||
unsafe {
|
||||
msg_send![self,
|
||||
setVisibleFunctionTable:visible_function_table
|
||||
atBufferIndex:buffer_index]
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_visible_function_tables(
|
||||
&self,
|
||||
buffer_start_index: NSUInteger,
|
||||
visible_function_tables: &[&VisibleFunctionTableRef],
|
||||
) {
|
||||
unsafe {
|
||||
msg_send![self,
|
||||
setVisibleFunctionTables:visible_function_tables.as_ptr()
|
||||
withBufferRange: NSRange {
|
||||
location: buffer_start_index,
|
||||
length: visible_function_tables.len() as _,
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
pub fn dispatch_thread_groups(
|
||||
&self,
|
||||
thread_groups_count: MTLSize,
|
||||
|
|
|
@ -148,69 +148,6 @@ impl HeapRef {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Only available on macOS 13.0+ & iOS 16.0+
|
||||
pub fn new_acceleration_structure_with_descriptor(
|
||||
&self,
|
||||
descriptor: &AccelerationStructureDescriptorRef,
|
||||
) -> Option<AccelerationStructure> {
|
||||
unsafe {
|
||||
let ptr: *mut MTLAccelerationStructure =
|
||||
msg_send![self, newAccelerationStructureWithDescriptor: descriptor];
|
||||
if !ptr.is_null() {
|
||||
Some(AccelerationStructure::from_ptr(ptr))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Only available on macOS 13.0+ & iOS 16.0+
|
||||
pub fn new_acceleration_structure_with_descriptor_offset(
|
||||
&self,
|
||||
descriptor: &AccelerationStructureDescriptorRef,
|
||||
offset: u64,
|
||||
) -> Option<AccelerationStructure> {
|
||||
unsafe {
|
||||
let ptr: *mut MTLAccelerationStructure = msg_send![self, newAccelerationStructureWithDescriptor:descriptor
|
||||
offset:offset];
|
||||
if !ptr.is_null() {
|
||||
Some(AccelerationStructure::from_ptr(ptr))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Only available on macOS 13.0+ & iOS 16.0+
|
||||
pub fn new_acceleration_structure_with_size(&self, size: u64) -> Option<AccelerationStructure> {
|
||||
unsafe {
|
||||
let ptr: *mut MTLAccelerationStructure =
|
||||
msg_send![self, newAccelerationStructureWithSize:size];
|
||||
if !ptr.is_null() {
|
||||
Some(AccelerationStructure::from_ptr(ptr))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Only available on macOS 13.0+ & iOS 16.0+
|
||||
pub fn new_acceleration_structure_with_size_offset(
|
||||
&self,
|
||||
size: u64,
|
||||
offset: u64,
|
||||
) -> Option<AccelerationStructure> {
|
||||
unsafe {
|
||||
let ptr: *mut MTLAccelerationStructure = msg_send![self, newAccelerationStructureWithSize:size
|
||||
offset:offset];
|
||||
if !ptr.is_null() {
|
||||
Some(AccelerationStructure::from_ptr(ptr))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// See <https://developer.apple.com/documentation/metal/mtlheapdescriptor/>
|
||||
|
@ -260,11 +197,6 @@ impl HeapDescriptorRef {
|
|||
unsafe { msg_send![self, hazardTrackingMode] }
|
||||
}
|
||||
|
||||
/// Only available on macos(10.15), ios(13.0)
|
||||
pub fn set_hazard_tracking_mode(&self, hazard_tracking_mode: MTLHazardTrackingMode) {
|
||||
unsafe { msg_send![self, setHazardTrackingMode: hazard_tracking_mode] }
|
||||
}
|
||||
|
||||
/// Only available on macos(10.15), ios(13.0)
|
||||
pub fn resource_options(&self) -> MTLResourceOptions {
|
||||
unsafe { msg_send![self, resourceOptions] }
|
||||
|
@ -274,8 +206,4 @@ impl HeapDescriptorRef {
|
|||
pub fn heap_type(&self) -> MTLHeapType {
|
||||
unsafe { msg_send![self, type] }
|
||||
}
|
||||
/// Only available on macos(10.15), ios(13.0)
|
||||
pub fn set_heap_type(&self, type_: MTLHeapType) {
|
||||
unsafe { msg_send![self, setType: type_] }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use super::*;
|
||||
|
||||
bitflags::bitflags! {
|
||||
bitflags! {
|
||||
/// See <https://developer.apple.com/documentation/metal/mtlindirectcommandtype/>
|
||||
#[allow(non_upper_case_globals)]
|
||||
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
|
||||
|
|
|
@ -9,6 +9,10 @@
|
|||
#![allow(non_snake_case)]
|
||||
#![allow(non_upper_case_globals)]
|
||||
|
||||
#[macro_use]
|
||||
pub extern crate bitflags;
|
||||
#[macro_use]
|
||||
pub extern crate log;
|
||||
#[macro_use]
|
||||
pub extern crate objc;
|
||||
#[macro_use]
|
||||
|
|
|
@ -148,7 +148,7 @@ impl FunctionConstantRef {
|
|||
}
|
||||
}
|
||||
|
||||
bitflags::bitflags! {
|
||||
bitflags! {
|
||||
/// Only available on (macos(11.0), ios(14.0))
|
||||
///
|
||||
/// See <https://developer.apple.com/documentation/metal/mtlfunctionoptions/>
|
||||
|
@ -263,6 +263,8 @@ impl FunctionHandleRef {
|
|||
}
|
||||
|
||||
// TODO:
|
||||
// MTLVisibleFunctionTableDescriptor
|
||||
// MTLVisibleFunctionTable
|
||||
// MTLIntersectionFunctionSignature
|
||||
// MTLIntersectionFunctionTableDescriptor
|
||||
// MTLIntersectionFunctionTable
|
||||
|
|
|
@ -40,7 +40,7 @@ pub enum MPSRayDataType {
|
|||
OriginMaskDirectionMaxDistance = 2,
|
||||
}
|
||||
|
||||
bitflags::bitflags! {
|
||||
bitflags! {
|
||||
/// See <https://developer.apple.com/documentation/metalperformanceshaders/mpsraymaskoptions>
|
||||
#[allow(non_upper_case_globals)]
|
||||
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
|
||||
|
@ -116,7 +116,7 @@ pub enum MPSAccelerationStructureStatus {
|
|||
Built = 1,
|
||||
}
|
||||
|
||||
bitflags::bitflags! {
|
||||
bitflags! {
|
||||
/// See <https://developer.apple.com/documentation/metalperformanceshaders/mpsaccelerationstructureusage>
|
||||
#[allow(non_upper_case_globals)]
|
||||
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
|
||||
|
|
|
@ -303,12 +303,8 @@ impl ComputePipelineStateRef {
|
|||
// - (nullable id <MTLComputePipelineState>)newComputePipelineStateWithAdditionalBinaryFunctions:(nonnull NSArray<id<MTLFunction>> *)functions error:(__autoreleasing NSError **)error
|
||||
|
||||
// API_AVAILABLE(macos(11.0), ios(14.0));
|
||||
pub fn new_visible_function_table_with_descriptor(
|
||||
&self,
|
||||
descriptor: &VisibleFunctionTableDescriptorRef,
|
||||
) -> VisibleFunctionTable {
|
||||
unsafe { msg_send![self, newVisibleFunctionTableWithDescriptor: descriptor ] }
|
||||
}
|
||||
// TODO: newVisibleFunctionTableWithDescriptor
|
||||
// - (nullable id<MTLVisibleFunctionTable>)newVisibleFunctionTableWithDescriptor:(MTLVisibleFunctionTableDescriptor * __nonnull)descriptor
|
||||
|
||||
/// Only available on (macos(11.0), ios(14.0))
|
||||
pub fn new_intersection_function_table_with_descriptor(
|
||||
|
|
|
@ -47,7 +47,7 @@ pub enum MTLBlendOperation {
|
|||
Max = 4,
|
||||
}
|
||||
|
||||
bitflags::bitflags! {
|
||||
bitflags! {
|
||||
/// See <https://developer.apple.com/documentation/metal/mtlcolorwritemask>
|
||||
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub struct MTLColorWriteMask: NSUInteger {
|
||||
|
@ -664,16 +664,6 @@ impl RenderPipelineDescriptorRef {
|
|||
unsafe { msg_send![self, setBinaryArchives: ns_array] }
|
||||
}
|
||||
|
||||
/// API_AVAILABLE(macos(11.0), ios(14.0));
|
||||
pub fn fragment_linked_functions(&self) -> &LinkedFunctionsRef {
|
||||
unsafe { msg_send![self, fragmentLinkedFunctions] }
|
||||
}
|
||||
|
||||
/// API_AVAILABLE(macos(11.0), ios(14.0));
|
||||
pub fn set_fragment_linked_functions(&self, functions: &LinkedFunctionsRef) {
|
||||
unsafe { msg_send![self, setFragmentLinkedFunctions: functions] }
|
||||
}
|
||||
|
||||
pub fn reset(&self) {
|
||||
unsafe { msg_send![self, reset] }
|
||||
}
|
||||
|
@ -698,39 +688,6 @@ impl RenderPipelineStateRef {
|
|||
crate::nsstring_as_str(label)
|
||||
}
|
||||
}
|
||||
|
||||
/// Only available on (macos(11.0), ios(14.0))
|
||||
pub fn new_intersection_function_table_with_descriptor(
|
||||
&self,
|
||||
descriptor: &IntersectionFunctionTableDescriptorRef,
|
||||
stage: MTLRenderStages,
|
||||
) -> IntersectionFunctionTable {
|
||||
unsafe {
|
||||
msg_send![self, newIntersectionFunctionTableWithDescriptor: descriptor
|
||||
stage:stage]
|
||||
}
|
||||
}
|
||||
|
||||
/// Only available on (macos(11.0), ios(14.0))
|
||||
pub fn function_handle_with_function(
|
||||
&self,
|
||||
function: &FunctionRef,
|
||||
stage: MTLRenderStages,
|
||||
) -> Option<&FunctionHandleRef> {
|
||||
unsafe {
|
||||
msg_send![self, functionHandleWithFunction: function
|
||||
stage:stage]
|
||||
}
|
||||
}
|
||||
|
||||
/// Only available on (macos(11.0), ios(14.0))
|
||||
pub fn new_visible_function_table_with_descriptor(
|
||||
&self,
|
||||
descriptor: &VisibleFunctionTableDescriptorRef,
|
||||
stage: MTLRenderStages,
|
||||
) -> VisibleFunctionTable {
|
||||
unsafe { msg_send![self, newVisibleFunctionTableWithDescriptor: descriptor stage:stage] }
|
||||
}
|
||||
}
|
||||
|
||||
/// See <https://developer.apple.com/documentation/metal/mtlrenderpipelinecolorattachmentdescriptorarray>
|
||||
|
|
|
@ -55,7 +55,7 @@ pub const MTLResourceStorageModeMask: NSUInteger = 0xf << MTLResourceStorageMode
|
|||
pub const MTLResourceHazardTrackingModeShift: NSUInteger = 8;
|
||||
pub const MTLResourceHazardTrackingModeMask: NSUInteger = 0x3 << MTLResourceHazardTrackingModeShift;
|
||||
|
||||
bitflags::bitflags! {
|
||||
bitflags! {
|
||||
/// See <https://developer.apple.com/documentation/metal/mtlresourceoptions>
|
||||
#[allow(non_upper_case_globals)]
|
||||
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
|
||||
|
@ -77,7 +77,7 @@ bitflags::bitflags! {
|
|||
}
|
||||
}
|
||||
|
||||
bitflags::bitflags! {
|
||||
bitflags! {
|
||||
/// Options that describe how a graphics or compute function uses an argument buffer’s resource.
|
||||
///
|
||||
/// Enabling certain options for certain resources determines whether the Metal driver should
|
||||
|
|
|
@ -9,7 +9,7 @@ use super::*;
|
|||
use block::{Block, RcBlock};
|
||||
use std::ptr;
|
||||
|
||||
#[cfg(feature = "dispatch")]
|
||||
#[cfg(feature = "dispatch_queue")]
|
||||
use dispatch;
|
||||
|
||||
/// See <https://developer.apple.com/documentation/metal/mtlsharedeventnotificationblock>
|
||||
|
@ -136,7 +136,7 @@ impl FenceRef {
|
|||
}
|
||||
}
|
||||
|
||||
bitflags::bitflags! {
|
||||
bitflags! {
|
||||
/// The render stages at which a synchronization command is triggered.
|
||||
///
|
||||
/// Render stages provide finer control for specifying when synchronization must occur,
|
||||
|
|
|
@ -33,7 +33,7 @@ pub enum MTLTextureCompressionType {
|
|||
Lossy = 1,
|
||||
}
|
||||
|
||||
bitflags::bitflags! {
|
||||
bitflags! {
|
||||
/// See <https://developer.apple.com/documentation/metal/mtltextureusage>
|
||||
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub struct MTLTextureUsage: NSUInteger {
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -47,7 +47,7 @@ bit-set = "0.6"
|
|||
bitflags = "2.6"
|
||||
log = "0.4"
|
||||
rustc-hash = "1.1.0"
|
||||
thiserror = "1.0.62"
|
||||
thiserror = "1.0.61"
|
||||
|
||||
[dependencies.arbitrary]
|
||||
version = "1.3"
|
||||
|
@ -74,7 +74,7 @@ version = "0.2.1"
|
|||
optional = true
|
||||
|
||||
[dependencies.serde]
|
||||
version = "1.0.204"
|
||||
version = "1.0.203"
|
||||
features = ["derive"]
|
||||
optional = true
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ use super::{
|
|||
use crate::{
|
||||
back::{self, Baked},
|
||||
proc::{self, NameKey},
|
||||
valid, Handle, Module, Scalar, ScalarKind, ShaderStage, TypeInner,
|
||||
valid, Handle, Module, ScalarKind, ShaderStage, TypeInner,
|
||||
};
|
||||
use std::{fmt, mem};
|
||||
|
||||
|
@ -2013,11 +2013,7 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {
|
|||
// ownership of our reusable access chain buffer.
|
||||
let chain = mem::take(&mut self.temp_access_chain);
|
||||
let var_name = &self.names[&NameKey::GlobalVariable(var_handle)];
|
||||
let width = match func_ctx.resolve_type(value, &module.types) {
|
||||
&TypeInner::Scalar(Scalar { width: 8, .. }) => "64",
|
||||
_ => "",
|
||||
};
|
||||
write!(self.out, "{var_name}.Interlocked{fun_str}{width}(")?;
|
||||
write!(self.out, "{var_name}.Interlocked{fun_str}(")?;
|
||||
self.write_storage_address(module, &chain, func_ctx)?;
|
||||
self.temp_access_chain = chain;
|
||||
}
|
||||
|
@ -2856,7 +2852,7 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {
|
|||
let inner = func_ctx.resolve_type(expr, &module.types);
|
||||
let close_paren = match convert {
|
||||
Some(dst_width) => {
|
||||
let scalar = Scalar {
|
||||
let scalar = crate::Scalar {
|
||||
kind,
|
||||
width: dst_width,
|
||||
};
|
||||
|
@ -3217,7 +3213,7 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {
|
|||
// as non-32bit types are DXC only.
|
||||
Function::MissingIntOverload(fun_name) => {
|
||||
let scalar_kind = func_ctx.resolve_type(arg, &module.types).scalar();
|
||||
if let Some(Scalar {
|
||||
if let Some(crate::Scalar {
|
||||
kind: ScalarKind::Sint,
|
||||
width: 4,
|
||||
}) = scalar_kind
|
||||
|
@ -3235,7 +3231,7 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {
|
|||
// as non-32bit types are DXC only.
|
||||
Function::MissingIntReturnType(fun_name) => {
|
||||
let scalar_kind = func_ctx.resolve_type(arg, &module.types).scalar();
|
||||
if let Some(Scalar {
|
||||
if let Some(crate::Scalar {
|
||||
kind: ScalarKind::Sint,
|
||||
width: 4,
|
||||
}) = scalar_kind
|
||||
|
|
|
@ -254,9 +254,7 @@ impl crate::TypeInner {
|
|||
/// Returns true if this is a handle to a type rather than the type directly.
|
||||
pub const fn is_handle(&self) -> bool {
|
||||
match *self {
|
||||
crate::TypeInner::Image { .. }
|
||||
| crate::TypeInner::Sampler { .. }
|
||||
| crate::TypeInner::AccelerationStructure { .. } => true,
|
||||
crate::TypeInner::Image { .. } | crate::TypeInner::Sampler { .. } => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2482,10 +2482,6 @@ impl<'source, 'temp> Lowerer<'source, 'temp> {
|
|||
crate::TypeInner::Scalar(crate::Scalar { width: 8, .. })
|
||||
);
|
||||
let result = if is_64_bit_min_max && is_statement {
|
||||
let rctx = ctx.runtime_expression_ctx(span)?;
|
||||
rctx.block
|
||||
.extend(rctx.emitter.finish(&rctx.function.expressions));
|
||||
rctx.emitter.start(&rctx.function.expressions);
|
||||
None
|
||||
} else {
|
||||
let ty = ctx.register_type(value)?;
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"files":{"Cargo.toml":"6b40380126ab2211b022d13517df15542bea1ac3bc92c4ab91243d2519df6d57","LICENSE-APACHE":"62c7a1e35f56406896d7aa7ca52d0cc0d272ac022b5d2796e7d6905db8a3636a","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","README.md":"731c044fc5f98b37a89e9049c9214267db98763309cb63146b45c029640f82a3","build.rs":"8653bc5c754a533b55849c29ccb0e75f06758d415cd768c94c3e08e790c2e953","crates-io.md":"407d92b2932923f8708aaf31db266fd7db32e2b0afa6c569d134b680b74a1920","src/de/format.rs":"c85071b016df643b161859682d21ce34fa0ebf2a3bdbeeea69859da48f5d934f","src/de/ignored_any.rs":"6480f2b2a83dc4764d01b2eec7309729eef2492eede2e5ee98d23a60b05198eb","src/de/impls.rs":"f1d691a1bd4f0404c590eb217bab1d07c7d56ff9e874da6ab28d4affa7fef94c","src/de/mod.rs":"14880617db97f5bd68f991248051c0327098730e6e0f15c763fc0f0048ce3dbe","src/de/seed.rs":"045d890712a04eb33ffc5a021e5d948a63c89402b8ffeea749df2171b7484f8f","src/de/size_hint.rs":"fff83dc39d30e75e8e611991f9c5399188a1aad23a6462dbca2c8b62655cfedb","src/de/value.rs":"0c485908b1f755e4750af0aefa2132460dadbcf30919c15c06ca795a92d96430","src/integer128.rs":"29ef30b7d94507b34807090e68173767cdc7aff62edccd38affe69e75338dddc","src/lib.rs":"6ce2ce1f1e818af0302fc3b21460678d7f4d5f1214114ce6e63665deba4c9bbe","src/macros.rs":"0d4b392ed6fe529fda2c5439c8547fe9717e64f528bfd01f633bb725f98b53cd","src/private/de.rs":"9255ecf2d5c52f0f52b4e0dbf85bdd8c140bc2c1ac96086ee395589e0521aeb4","src/private/doc.rs":"b222decb40321190155209e1b8a5a52e3adfaa470047e379e664b71e0320655a","src/private/mod.rs":"b8f0c348621d91dd9da3db83d8877e70bc61ad0a2dc2d6fb57c6fc2c2cbafa26","src/private/ser.rs":"73577607e779e1b42713c51b9bc7136f99daccf473b4a641c99ceebe46708d47","src/ser/fmt.rs":"d1cfd9623605413e45a23ef778d97f0ac4da4adaed23739f1f9d7414b30e384b","src/ser/impls.rs":"585908d859fc89adcc1c6a7acc8f12467feba7daeb8c44ae28d25fd40d140f2c","src/ser/impossible.rs":"5c325da8e0370ab22abe1e15d8af1dc7a1707b127508f61e720cd7f0caa80593","src/ser/mod.rs":"eee3a4ecfc09993677df0be4772c1c7edde43ec9591be0b5595cb113a548a8a2","src/std_error.rs":"25a07149e2e468747ffa5a58051c7f93d7b3c0fa0372f012a96c97ec8ab03b97"},"package":"bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12"}
|
||||
{"files":{"Cargo.toml":"99245e2dcef3d674a06780d28d779d902dc95891aeeae9362811146e2dbc23f2","LICENSE-APACHE":"62c7a1e35f56406896d7aa7ca52d0cc0d272ac022b5d2796e7d6905db8a3636a","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","README.md":"731c044fc5f98b37a89e9049c9214267db98763309cb63146b45c029640f82a3","build.rs":"fd90532b83c6cf71c8aaf6ef7bedfdab85aac6bc06fc2d578ca7dd99195b8622","crates-io.md":"56e988ac4944c45f5bf5051e3827892ed8fb817853d99d9df1fff6621108e270","src/de/format.rs":"c85071b016df643b161859682d21ce34fa0ebf2a3bdbeeea69859da48f5d934f","src/de/ignored_any.rs":"6480f2b2a83dc4764d01b2eec7309729eef2492eede2e5ee98d23a60b05198eb","src/de/impls.rs":"f1d691a1bd4f0404c590eb217bab1d07c7d56ff9e874da6ab28d4affa7fef94c","src/de/mod.rs":"342de5aa92c54ebfcf30213f86a8626839ab132dc7fd1300a47ab40d5faf0dba","src/de/seed.rs":"045d890712a04eb33ffc5a021e5d948a63c89402b8ffeea749df2171b7484f8f","src/de/size_hint.rs":"fff83dc39d30e75e8e611991f9c5399188a1aad23a6462dbca2c8b62655cfedb","src/de/value.rs":"0c485908b1f755e4750af0aefa2132460dadbcf30919c15c06ca795a92d96430","src/integer128.rs":"29ef30b7d94507b34807090e68173767cdc7aff62edccd38affe69e75338dddc","src/lib.rs":"6e8f95df70fe4c797d86d9596dccf3efa547aa322eddffe3f777822eb7fe29bb","src/macros.rs":"0d4b392ed6fe529fda2c5439c8547fe9717e64f528bfd01f633bb725f98b53cd","src/private/de.rs":"9255ecf2d5c52f0f52b4e0dbf85bdd8c140bc2c1ac96086ee395589e0521aeb4","src/private/doc.rs":"b222decb40321190155209e1b8a5a52e3adfaa470047e379e664b71e0320655a","src/private/mod.rs":"b8f0c348621d91dd9da3db83d8877e70bc61ad0a2dc2d6fb57c6fc2c2cbafa26","src/private/ser.rs":"73577607e779e1b42713c51b9bc7136f99daccf473b4a641c99ceebe46708d47","src/ser/fmt.rs":"d1cfd9623605413e45a23ef778d97f0ac4da4adaed23739f1f9d7414b30e384b","src/ser/impls.rs":"585908d859fc89adcc1c6a7acc8f12467feba7daeb8c44ae28d25fd40d140f2c","src/ser/impossible.rs":"5c325da8e0370ab22abe1e15d8af1dc7a1707b127508f61e720cd7f0caa80593","src/ser/mod.rs":"a92d4ce0a6c68eb22a24a61574a5d2e9b0b463b284ff08e62298b8f7ae1a7464","src/std_error.rs":"25a07149e2e468747ffa5a58051c7f93d7b3c0fa0372f012a96c97ec8ab03b97"},"package":"7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094"}
|
|
@ -13,7 +13,7 @@
|
|||
edition = "2018"
|
||||
rust-version = "1.31"
|
||||
name = "serde"
|
||||
version = "1.0.204"
|
||||
version = "1.0.203"
|
||||
authors = [
|
||||
"Erick Tryzelaar <erick.tryzelaar@gmail.com>",
|
||||
"David Tolnay <dtolnay@gmail.com>",
|
||||
|
@ -76,4 +76,4 @@ std = []
|
|||
unstable = []
|
||||
|
||||
[target."cfg(any())".dependencies.serde_derive]
|
||||
version = "=1.0.204"
|
||||
version = "=1.0.203"
|
||||
|
|
|
@ -17,7 +17,6 @@ fn main() {
|
|||
println!("cargo:rustc-check-cfg=cfg(no_core_cstr)");
|
||||
println!("cargo:rustc-check-cfg=cfg(no_core_num_saturating)");
|
||||
println!("cargo:rustc-check-cfg=cfg(no_core_try_from)");
|
||||
println!("cargo:rustc-check-cfg=cfg(no_diagnostic_namespace)");
|
||||
println!("cargo:rustc-check-cfg=cfg(no_float_copysign)");
|
||||
println!("cargo:rustc-check-cfg=cfg(no_num_nonzero_signed)");
|
||||
println!("cargo:rustc-check-cfg=cfg(no_relaxed_trait_bounds)");
|
||||
|
@ -85,12 +84,6 @@ fn main() {
|
|||
if minor < 74 {
|
||||
println!("cargo:rustc-cfg=no_core_num_saturating");
|
||||
}
|
||||
|
||||
// Support for the `#[diagnostic]` tool attribute namespace
|
||||
// https://blog.rust-lang.org/2024/05/02/Rust-1.78.0.html#diagnostic-attributes
|
||||
if minor < 78 {
|
||||
println!("cargo:rustc-cfg=no_diagnostic_namespace");
|
||||
}
|
||||
}
|
||||
|
||||
fn rustc_minor_version() -> Option<u32> {
|
||||
|
|
|
@ -46,8 +46,8 @@ fn main() {
|
|||
Serde is one of the most widely used Rust libraries so any place that Rustaceans
|
||||
congregate will be able to help you out. For chat, consider trying the
|
||||
[#rust-questions] or [#rust-beginners] channels of the unofficial community
|
||||
Discord (invite: <https://discord.gg/rust-lang-community>), the [#rust-usage]
|
||||
or [#beginners] channels of the official Rust Project Discord (invite:
|
||||
Discord (invite: <https://discord.gg/rust-lang-community>, the [#rust-usage] or
|
||||
[#beginners] channels of the official Rust Project Discord (invite:
|
||||
<https://discord.gg/rust-lang>), or the [#general][zulip] stream in Zulip. For
|
||||
asynchronous, consider the [\[rust\] tag on StackOverflow][stackoverflow], the
|
||||
[/r/rust] subreddit which has a pinned weekly easy questions post, or the Rust
|
||||
|
|
|
@ -532,13 +532,6 @@ impl<'a> Display for Expected + 'a {
|
|||
/// deserializer lifetimes] for a more detailed explanation of these lifetimes.
|
||||
///
|
||||
/// [Understanding deserializer lifetimes]: https://serde.rs/lifetimes.html
|
||||
#[cfg_attr(
|
||||
not(no_diagnostic_namespace),
|
||||
diagnostic::on_unimplemented(
|
||||
note = "for local types consider adding `#[derive(serde::Deserialize)]` to your `{Self}` type",
|
||||
note = "for types from other crates check whether the crate offers a `serde` feature flag",
|
||||
)
|
||||
)]
|
||||
pub trait Deserialize<'de>: Sized {
|
||||
/// Deserialize this value from the given Serde deserializer.
|
||||
///
|
||||
|
|
|
@ -95,7 +95,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Serde types in rustdoc of other crates get linked to here.
|
||||
#![doc(html_root_url = "https://docs.rs/serde/1.0.204")]
|
||||
#![doc(html_root_url = "https://docs.rs/serde/1.0.203")]
|
||||
// Support using Serde without the standard library!
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
// Show which crate feature enables conditionally compiled APIs in documentation.
|
||||
|
@ -105,7 +105,7 @@
|
|||
// discussion of these features please refer to this issue:
|
||||
//
|
||||
// https://github.com/serde-rs/serde/issues/812
|
||||
#![cfg_attr(feature = "unstable", feature(never_type))]
|
||||
#![cfg_attr(feature = "unstable", feature(error_in_core, never_type))]
|
||||
#![allow(unknown_lints, bare_trait_objects, deprecated)]
|
||||
// Ignored clippy and clippy_pedantic lints
|
||||
#![allow(
|
||||
|
|
|
@ -215,13 +215,6 @@ declare_error_trait!(Error: Sized + Debug + Display);
|
|||
/// [`linked-hash-map`]: https://crates.io/crates/linked-hash-map
|
||||
/// [`serde_derive`]: https://crates.io/crates/serde_derive
|
||||
/// [derive section of the manual]: https://serde.rs/derive.html
|
||||
#[cfg_attr(
|
||||
not(no_diagnostic_namespace),
|
||||
diagnostic::on_unimplemented(
|
||||
note = "for local types consider adding `#[derive(serde::Serialize)]` to your `{Self}` type",
|
||||
note = "for types from other crates check whether the crate offers a `serde` feature flag",
|
||||
)
|
||||
)]
|
||||
pub trait Serialize {
|
||||
/// Serialize this value into the given Serde serializer.
|
||||
///
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"files":{"Cargo.toml":"48e4da0b01e15c60435819448bc28dc126547da15c14c5f200b0b9fc9cf5a9ab","LICENSE-APACHE":"62c7a1e35f56406896d7aa7ca52d0cc0d272ac022b5d2796e7d6905db8a3636a","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","README.md":"731c044fc5f98b37a89e9049c9214267db98763309cb63146b45c029640f82a3","crates-io.md":"407d92b2932923f8708aaf31db266fd7db32e2b0afa6c569d134b680b74a1920","src/bound.rs":"6c5c20785ac95af9480f8d0de35a7e844cc36a16012f6468db148acd03cb15c2","src/de.rs":"c221ab2b94a5d80dccff74a37f3448b3d695656552b452595dc289c73b12fb2b","src/dummy.rs":"9533dfee23f20d92ea75734c739022820c2787ded0d54f459feacdeb770ec912","src/fragment.rs":"6757cb4c3131d4300f093572efc273c4ab5a20e3e1efb54a311dcfa52d0bd6eb","src/internals/ast.rs":"7dc997e4090033bbd1d0bdd870e8bb87b096b7f66cfd02047f6b85ebdd569b12","src/internals/attr.rs":"50b3fca6e7ae1ea23cbe35b3b26b139f0860aa3201aa6ea6fc12db1c17dffeb2","src/internals/case.rs":"10c8dda2b32d8c6c6b63cf09cdc63d02375af7e95ecefe8fecb34f93b65191bb","src/internals/check.rs":"d842eb9912fd29311060b67f3bc62c438eb7b5d86093355acb4de7eee02a0ef8","src/internals/ctxt.rs":"83a4e6fbe0e439d578478883594407e03f2f340541be479bdf0b04a202633a37","src/internals/mod.rs":"ed021ca635c18132a0e5c3d90f21b7f65def0a61e946421a30200b5b9ab6ad43","src/internals/receiver.rs":"710f875da3bad3e2a7fc1df40ab6805bb5e971b6a2a04c1b643b8a0aa29e8496","src/internals/respan.rs":"899753859c58ce5f532a3ec4584796a52f13ed5a0533191e48c953ba5c1b52ff","src/internals/symbol.rs":"d619e88caa3c7a09b03014257f2b349ee922290062d9b97b4dd19d0e64532690","src/lib.rs":"943369fa9c7c2793bc4016b0d8e763c7dc0f4b2fb4f4589aa37b39fe52330378","src/pretend.rs":"7facc10a5b805564dd95735ae11118ec17ca6adcc49a59764e7c920e27b9fc4a","src/ser.rs":"a5638fa1b42b2a0d23cc12649f9180d4132f4cb7cf9edace1a1caed483f609e9","src/this.rs":"87818dc80cbb521b51938a653d09daf10aafc220bb10425948de82ad670fcb85"},"package":"e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222"}
|
||||
{"files":{"Cargo.toml":"165df5f0c76b7421141def7245508ce2b77fcb469582ba6d02d9c911d502cf43","LICENSE-APACHE":"62c7a1e35f56406896d7aa7ca52d0cc0d272ac022b5d2796e7d6905db8a3636a","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","README.md":"731c044fc5f98b37a89e9049c9214267db98763309cb63146b45c029640f82a3","crates-io.md":"56e988ac4944c45f5bf5051e3827892ed8fb817853d99d9df1fff6621108e270","src/bound.rs":"6c5c20785ac95af9480f8d0de35a7e844cc36a16012f6468db148acd03cb15c2","src/de.rs":"c221ab2b94a5d80dccff74a37f3448b3d695656552b452595dc289c73b12fb2b","src/dummy.rs":"9533dfee23f20d92ea75734c739022820c2787ded0d54f459feacdeb770ec912","src/fragment.rs":"6757cb4c3131d4300f093572efc273c4ab5a20e3e1efb54a311dcfa52d0bd6eb","src/internals/ast.rs":"7dc997e4090033bbd1d0bdd870e8bb87b096b7f66cfd02047f6b85ebdd569b12","src/internals/attr.rs":"50b3fca6e7ae1ea23cbe35b3b26b139f0860aa3201aa6ea6fc12db1c17dffeb2","src/internals/case.rs":"10c8dda2b32d8c6c6b63cf09cdc63d02375af7e95ecefe8fecb34f93b65191bb","src/internals/check.rs":"d842eb9912fd29311060b67f3bc62c438eb7b5d86093355acb4de7eee02a0ef8","src/internals/ctxt.rs":"83a4e6fbe0e439d578478883594407e03f2f340541be479bdf0b04a202633a37","src/internals/mod.rs":"ed021ca635c18132a0e5c3d90f21b7f65def0a61e946421a30200b5b9ab6ad43","src/internals/receiver.rs":"710f875da3bad3e2a7fc1df40ab6805bb5e971b6a2a04c1b643b8a0aa29e8496","src/internals/respan.rs":"899753859c58ce5f532a3ec4584796a52f13ed5a0533191e48c953ba5c1b52ff","src/internals/symbol.rs":"d619e88caa3c7a09b03014257f2b349ee922290062d9b97b4dd19d0e64532690","src/lib.rs":"fd26edb1f03ff548a6cc86dc4e43c0b567c1bc0e5e54bb6d13cdc1b60fdcc26e","src/pretend.rs":"7facc10a5b805564dd95735ae11118ec17ca6adcc49a59764e7c920e27b9fc4a","src/ser.rs":"a5638fa1b42b2a0d23cc12649f9180d4132f4cb7cf9edace1a1caed483f609e9","src/this.rs":"87818dc80cbb521b51938a653d09daf10aafc220bb10425948de82ad670fcb85"},"package":"500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba"}
|
|
@ -13,7 +13,7 @@
|
|||
edition = "2015"
|
||||
rust-version = "1.56"
|
||||
name = "serde_derive"
|
||||
version = "1.0.204"
|
||||
version = "1.0.203"
|
||||
authors = [
|
||||
"Erick Tryzelaar <erick.tryzelaar@gmail.com>",
|
||||
"David Tolnay <dtolnay@gmail.com>",
|
||||
|
|
|
@ -46,8 +46,8 @@ fn main() {
|
|||
Serde is one of the most widely used Rust libraries so any place that Rustaceans
|
||||
congregate will be able to help you out. For chat, consider trying the
|
||||
[#rust-questions] or [#rust-beginners] channels of the unofficial community
|
||||
Discord (invite: <https://discord.gg/rust-lang-community>), the [#rust-usage]
|
||||
or [#beginners] channels of the official Rust Project Discord (invite:
|
||||
Discord (invite: <https://discord.gg/rust-lang-community>, the [#rust-usage] or
|
||||
[#beginners] channels of the official Rust Project Discord (invite:
|
||||
<https://discord.gg/rust-lang>), or the [#general][zulip] stream in Zulip. For
|
||||
asynchronous, consider the [\[rust\] tag on StackOverflow][stackoverflow], the
|
||||
[/r/rust] subreddit which has a pinned weekly easy questions post, or the Rust
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
//!
|
||||
//! [https://serde.rs/derive.html]: https://serde.rs/derive.html
|
||||
|
||||
#![doc(html_root_url = "https://docs.rs/serde_derive/1.0.204")]
|
||||
#![doc(html_root_url = "https://docs.rs/serde_derive/1.0.203")]
|
||||
#![cfg_attr(not(check_cfg), allow(unexpected_cfgs))]
|
||||
// Ignored clippy lints
|
||||
#![allow(
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"files":{"Cargo.toml":"8f4acbe57979cf65fdca303b08b8ba7bda1d71b73dbdf699b5b765842103fd6c","LICENSE-APACHE":"62c7a1e35f56406896d7aa7ca52d0cc0d272ac022b5d2796e7d6905db8a3636a","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","src/ast.rs":"9b6cd6b1553483c99cd7e36aa422d37f4353c99b15da55534d28822f7fa7fd08","src/attr.rs":"d662f37c1a892aac6ab652ba6111335121748df728e49399aff736b654d5dd1c","src/expand.rs":"2736a714372a4b81ac5438783dd2c0f656d624bec5cc4089af96ceecaeee011e","src/fmt.rs":"5d1cefc012403c2d4ff7ab2513c0ec559166df4271d5983a6463939b5ec8c3e1","src/generics.rs":"2076cde22271be355a8131a77add4b93f83ab0af4317cd2df5471fffa4f95c66","src/lib.rs":"5eea86c771e643328ad9bc3b881cce4bf9d50adae1b33e0d07645bdd9044003d","src/prop.rs":"5ba613e38430831259f20b258f33d57dcb783fbaeeb49e5faffa7b2a7be99e67","src/span.rs":"430460a4fa0d1fa9c627c1ddd575d2b101778fea84217591e1a93a5f6a2a0132","src/valid.rs":"ac95253944fd360d3578d0643a7baabb2cfa6bf9fbced7a6ce1f7b0529a3bb98"},"package":"a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261"}
|
||||
{"files":{"Cargo.toml":"2b8cbe5e37d52d2d639a9506834c3c41044ccddb39420f0b7a30c14a1d26bc5f","LICENSE-APACHE":"62c7a1e35f56406896d7aa7ca52d0cc0d272ac022b5d2796e7d6905db8a3636a","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","src/ast.rs":"9b6cd6b1553483c99cd7e36aa422d37f4353c99b15da55534d28822f7fa7fd08","src/attr.rs":"99fca8c65a1907ee2f43f7ec28ce465bae22336c529bd7148738f9ce35375101","src/expand.rs":"2736a714372a4b81ac5438783dd2c0f656d624bec5cc4089af96ceecaeee011e","src/fmt.rs":"5d1cefc012403c2d4ff7ab2513c0ec559166df4271d5983a6463939b5ec8c3e1","src/generics.rs":"2076cde22271be355a8131a77add4b93f83ab0af4317cd2df5471fffa4f95c66","src/lib.rs":"5eea86c771e643328ad9bc3b881cce4bf9d50adae1b33e0d07645bdd9044003d","src/prop.rs":"5ba613e38430831259f20b258f33d57dcb783fbaeeb49e5faffa7b2a7be99e67","src/span.rs":"430460a4fa0d1fa9c627c1ddd575d2b101778fea84217591e1a93a5f6a2a0132","src/valid.rs":"ac95253944fd360d3578d0643a7baabb2cfa6bf9fbced7a6ce1f7b0529a3bb98"},"package":"46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533"}
|
|
@ -13,7 +13,7 @@
|
|||
edition = "2021"
|
||||
rust-version = "1.56"
|
||||
name = "thiserror-impl"
|
||||
version = "1.0.63"
|
||||
version = "1.0.61"
|
||||
authors = ["David Tolnay <dtolnay@gmail.com>"]
|
||||
build = false
|
||||
autobins = false
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
use proc_macro2::{Delimiter, Group, Literal, Punct, Spacing, Span, TokenStream, TokenTree};
|
||||
use proc_macro2::{Delimiter, Group, Span, TokenStream, TokenTree};
|
||||
use quote::{format_ident, quote, ToTokens};
|
||||
use std::collections::BTreeSet as Set;
|
||||
use syn::parse::discouraged::Speculative;
|
||||
use syn::parse::ParseStream;
|
||||
use syn::{
|
||||
braced, bracketed, parenthesized, token, Attribute, Error, Ident, Index, LitFloat, LitInt,
|
||||
LitStr, Meta, Result, Token,
|
||||
braced, bracketed, parenthesized, token, Attribute, Error, Ident, Index, LitInt, LitStr, Meta,
|
||||
Result, Token,
|
||||
};
|
||||
|
||||
pub struct Attrs<'a> {
|
||||
|
@ -145,42 +145,14 @@ fn parse_token_expr(input: ParseStream, mut begin_expr: bool) -> Result<TokenStr
|
|||
input.parse::<Token![.]>()?;
|
||||
begin_expr = false;
|
||||
continue;
|
||||
} else if input.peek2(LitInt) {
|
||||
}
|
||||
if input.peek2(LitInt) {
|
||||
input.parse::<Token![.]>()?;
|
||||
let int: Index = input.parse()?;
|
||||
tokens.push({
|
||||
let ident = format_ident!("_{}", int.index, span = int.span);
|
||||
TokenTree::Ident(ident)
|
||||
});
|
||||
let ident = format_ident!("_{}", int.index, span = int.span);
|
||||
tokens.push(TokenTree::Ident(ident));
|
||||
begin_expr = false;
|
||||
continue;
|
||||
} else if input.peek2(LitFloat) {
|
||||
let ahead = input.fork();
|
||||
ahead.parse::<Token![.]>()?;
|
||||
let float: LitFloat = ahead.parse()?;
|
||||
let repr = float.to_string();
|
||||
let mut indices = repr.split('.').map(syn::parse_str::<Index>);
|
||||
if let (Some(Ok(first)), Some(Ok(second)), None) =
|
||||
(indices.next(), indices.next(), indices.next())
|
||||
{
|
||||
input.advance_to(&ahead);
|
||||
tokens.push({
|
||||
let ident = format_ident!("_{}", first, span = float.span());
|
||||
TokenTree::Ident(ident)
|
||||
});
|
||||
tokens.push({
|
||||
let mut punct = Punct::new('.', Spacing::Alone);
|
||||
punct.set_span(float.span());
|
||||
TokenTree::Punct(punct)
|
||||
});
|
||||
tokens.push({
|
||||
let mut literal = Literal::u32_unsuffixed(second.index);
|
||||
literal.set_span(float.span());
|
||||
TokenTree::Literal(literal)
|
||||
});
|
||||
begin_expr = false;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -13,7 +13,7 @@
|
|||
edition = "2021"
|
||||
rust-version = "1.56"
|
||||
name = "thiserror"
|
||||
version = "1.0.63"
|
||||
version = "1.0.61"
|
||||
authors = ["David Tolnay <dtolnay@gmail.com>"]
|
||||
build = "build.rs"
|
||||
autobins = false
|
||||
|
@ -41,13 +41,41 @@ name = "thiserror"
|
|||
path = "src/lib.rs"
|
||||
|
||||
[[test]]
|
||||
name = "compiletest"
|
||||
path = "tests/compiletest.rs"
|
||||
name = "test_error"
|
||||
path = "tests/test_error.rs"
|
||||
|
||||
[[test]]
|
||||
name = "test_source"
|
||||
path = "tests/test_source.rs"
|
||||
|
||||
[[test]]
|
||||
name = "test_generics"
|
||||
path = "tests/test_generics.rs"
|
||||
|
||||
[[test]]
|
||||
name = "test_from"
|
||||
path = "tests/test_from.rs"
|
||||
|
||||
[[test]]
|
||||
name = "test_lints"
|
||||
path = "tests/test_lints.rs"
|
||||
|
||||
[[test]]
|
||||
name = "test_transparent"
|
||||
path = "tests/test_transparent.rs"
|
||||
|
||||
[[test]]
|
||||
name = "test_backtrace"
|
||||
path = "tests/test_backtrace.rs"
|
||||
|
||||
[[test]]
|
||||
name = "test_path"
|
||||
path = "tests/test_path.rs"
|
||||
|
||||
[[test]]
|
||||
name = "compiletest"
|
||||
path = "tests/compiletest.rs"
|
||||
|
||||
[[test]]
|
||||
name = "test_deprecated"
|
||||
path = "tests/test_deprecated.rs"
|
||||
|
@ -57,43 +85,15 @@ name = "test_display"
|
|||
path = "tests/test_display.rs"
|
||||
|
||||
[[test]]
|
||||
name = "test_error"
|
||||
path = "tests/test_error.rs"
|
||||
name = "test_option"
|
||||
path = "tests/test_option.rs"
|
||||
|
||||
[[test]]
|
||||
name = "test_expr"
|
||||
path = "tests/test_expr.rs"
|
||||
|
||||
[[test]]
|
||||
name = "test_from"
|
||||
path = "tests/test_from.rs"
|
||||
|
||||
[[test]]
|
||||
name = "test_generics"
|
||||
path = "tests/test_generics.rs"
|
||||
|
||||
[[test]]
|
||||
name = "test_lints"
|
||||
path = "tests/test_lints.rs"
|
||||
|
||||
[[test]]
|
||||
name = "test_option"
|
||||
path = "tests/test_option.rs"
|
||||
|
||||
[[test]]
|
||||
name = "test_path"
|
||||
path = "tests/test_path.rs"
|
||||
|
||||
[[test]]
|
||||
name = "test_source"
|
||||
path = "tests/test_source.rs"
|
||||
|
||||
[[test]]
|
||||
name = "test_transparent"
|
||||
path = "tests/test_transparent.rs"
|
||||
|
||||
[dependencies.thiserror-impl]
|
||||
version = "=1.0.63"
|
||||
version = "=1.0.61"
|
||||
|
||||
[dev-dependencies.anyhow]
|
||||
version = "1.0.73"
|
||||
|
|
|
@ -88,18 +88,20 @@ pub enum DataStoreError {
|
|||
}
|
||||
```
|
||||
|
||||
- A `From` impl is generated for each variant that contains a `#[from]`
|
||||
attribute.
|
||||
- A `From` impl is generated for each variant containing a `#[from]` attribute.
|
||||
|
||||
The variant using `#[from]` must not contain any other fields beyond the
|
||||
source error (and possibly a backtrace — see below). Usually `#[from]`
|
||||
fields are unnamed, but `#[from]` is allowed on a named field too.
|
||||
Note that the variant must not contain any other fields beyond the source
|
||||
error and possibly a backtrace. A backtrace is captured from within the `From`
|
||||
impl if there is a field for it.
|
||||
|
||||
```rust
|
||||
#[derive(Error, Debug)]
|
||||
pub enum MyError {
|
||||
Io(#[from] io::Error),
|
||||
Glob(#[from] globset::Error),
|
||||
Io {
|
||||
#[from]
|
||||
source: io::Error,
|
||||
backtrace: Backtrace,
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -123,9 +125,7 @@ pub enum DataStoreError {
|
|||
```
|
||||
|
||||
- The Error trait's `provide()` method is implemented to provide whichever field
|
||||
has a type named `Backtrace`, if any, as a `std::backtrace::Backtrace`. Using
|
||||
`Backtrace` in errors requires a nightly compiler with Rust version 1.73 or
|
||||
newer.
|
||||
has a type named `Backtrace`, if any, as a `std::backtrace::Backtrace`.
|
||||
|
||||
```rust
|
||||
use std::backtrace::Backtrace;
|
||||
|
@ -140,9 +140,7 @@ pub enum DataStoreError {
|
|||
- If a field is both a source (named `source`, or has `#[source]` or `#[from]`
|
||||
attribute) *and* is marked `#[backtrace]`, then the Error trait's `provide()`
|
||||
method is forwarded to the source's `provide` so that both layers of the error
|
||||
share the same backtrace. The `#[backtrace]` attribute requires a nightly
|
||||
compiler with Rust version 1.73 or newer.
|
||||
|
||||
share the same backtrace.
|
||||
|
||||
```rust
|
||||
#[derive(Error, Debug)]
|
||||
|
@ -154,20 +152,6 @@ pub enum DataStoreError {
|
|||
}
|
||||
```
|
||||
|
||||
- For variants that use `#[from]` and also contain a `Backtrace` field, a
|
||||
backtrace is captured from within the `From` impl.
|
||||
|
||||
```rust
|
||||
#[derive(Error, Debug)]
|
||||
pub enum MyError {
|
||||
Io {
|
||||
#[from]
|
||||
source: io::Error,
|
||||
backtrace: Backtrace,
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
- Errors may use `error(transparent)` to forward the source and Display methods
|
||||
straight through to an underlying error without adding an additional message.
|
||||
This would be appropriate for enums that need an "anything else" variant.
|
||||
|
|
|
@ -98,36 +98,24 @@
|
|||
//! }
|
||||
//! ```
|
||||
//!
|
||||
//! - A `From` impl is generated for each variant that contains a `#[from]`
|
||||
//! - A `From` impl is generated for each variant containing a `#[from]`
|
||||
//! attribute.
|
||||
//!
|
||||
//! The variant using `#[from]` must not contain any other fields beyond the
|
||||
//! source error (and possibly a backtrace — see below). Usually
|
||||
//! `#[from]` fields are unnamed, but `#[from]` is allowed on a named field
|
||||
//! too.
|
||||
//! Note that the variant must not contain any other fields beyond the source
|
||||
//! error and possibly a backtrace. A backtrace is captured from within the
|
||||
//! `From` impl if there is a field for it.
|
||||
//!
|
||||
//! ```rust
|
||||
//! # use core::fmt::{self, Display};
|
||||
//! # use std::io;
|
||||
//! # use thiserror::Error;
|
||||
//! #
|
||||
//! # mod globset {
|
||||
//! # #[derive(thiserror::Error, Debug)]
|
||||
//! # #[error("...")]
|
||||
//! # pub struct Error;
|
||||
//! # }
|
||||
//! #
|
||||
//! # const IGNORE: &str = stringify! {
|
||||
//! #[derive(Error, Debug)]
|
||||
//! pub enum MyError {
|
||||
//! Io(#[from] io::Error),
|
||||
//! Glob(#[from] globset::Error),
|
||||
//! Io {
|
||||
//! #[from]
|
||||
//! source: io::Error,
|
||||
//! backtrace: Backtrace,
|
||||
//! },
|
||||
//! }
|
||||
//! #
|
||||
//! # impl Display for MyError {
|
||||
//! # fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||
//! # unimplemented!()
|
||||
//! # }
|
||||
//! # }
|
||||
//! # };
|
||||
//! ```
|
||||
//!
|
||||
//! - The Error trait's `source()` method is implemented to return whichever
|
||||
|
@ -160,8 +148,7 @@
|
|||
//!
|
||||
//! - The Error trait's `provide()` method is implemented to provide whichever
|
||||
//! field has a type named `Backtrace`, if any, as a
|
||||
//! `std::backtrace::Backtrace`. Using `Backtrace` in errors requires a
|
||||
//! nightly compiler with Rust version 1.73 or newer.
|
||||
//! `std::backtrace::Backtrace`.
|
||||
//!
|
||||
//! ```rust
|
||||
//! # const IGNORE: &str = stringify! {
|
||||
|
@ -178,8 +165,7 @@
|
|||
//! - If a field is both a source (named `source`, or has `#[source]` or
|
||||
//! `#[from]` attribute) *and* is marked `#[backtrace]`, then the Error
|
||||
//! trait's `provide()` method is forwarded to the source's `provide` so that
|
||||
//! both layers of the error share the same backtrace. The `#[backtrace]`
|
||||
//! attribute requires a nightly compiler with Rust version 1.73 or newer.
|
||||
//! both layers of the error share the same backtrace.
|
||||
//!
|
||||
//! ```rust
|
||||
//! # const IGNORE: &str = stringify! {
|
||||
|
@ -193,22 +179,6 @@
|
|||
//! # };
|
||||
//! ```
|
||||
//!
|
||||
//! - For variants that use `#[from]` and also contain a `Backtrace` field, a
|
||||
//! backtrace is captured from within the `From` impl.
|
||||
//!
|
||||
//! ```rust
|
||||
//! # const IGNORE: &str = stringify! {
|
||||
//! #[derive(Error, Debug)]
|
||||
//! pub enum MyError {
|
||||
//! Io {
|
||||
//! #[from]
|
||||
//! source: io::Error,
|
||||
//! backtrace: Backtrace,
|
||||
//! },
|
||||
//! }
|
||||
//! # };
|
||||
//! ```
|
||||
//!
|
||||
//! - Errors may use `error(transparent)` to forward the source and Display
|
||||
//! methods straight through to an underlying error without adding an
|
||||
//! additional message. This would be appropriate for enums that need an
|
||||
|
@ -258,7 +228,7 @@
|
|||
//!
|
||||
//! [`anyhow`]: https://github.com/dtolnay/anyhow
|
||||
|
||||
#![doc(html_root_url = "https://docs.rs/thiserror/1.0.63")]
|
||||
#![doc(html_root_url = "https://docs.rs/thiserror/1.0.61")]
|
||||
#![allow(
|
||||
clippy::module_name_repetitions,
|
||||
clippy::needless_lifetimes,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#[rustversion::attr(not(nightly), ignore = "requires nightly")]
|
||||
#[cfg_attr(miri, ignore = "incompatible with miri")]
|
||||
#[rustversion::attr(not(nightly), ignore)]
|
||||
#[cfg_attr(miri, ignore)]
|
||||
#[test]
|
||||
fn ui() {
|
||||
let t = trybuild::TestCases::new();
|
||||
|
|
|
@ -270,8 +270,5 @@ pub mod enums {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg_attr(
|
||||
not(thiserror_nightly_testing),
|
||||
ignore = "requires `--cfg=thiserror_nightly_testing`"
|
||||
)]
|
||||
#[cfg_attr(not(thiserror_nightly_testing), ignore)]
|
||||
fn test_backtrace() {}
|
||||
|
|
|
@ -234,18 +234,6 @@ fn test_field() {
|
|||
assert("0", Error(Inner { data: 0 }));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_nested_tuple_field() {
|
||||
#[derive(Debug)]
|
||||
struct Inner(usize);
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[error("{}", .0.0)]
|
||||
struct Error(Inner);
|
||||
|
||||
assert("0", Error(Inner(0)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_macro_rules() {
|
||||
// Regression test for https://github.com/dtolnay/thiserror/issues/86
|
||||
|
|
|
@ -9,39 +9,39 @@ pub mod structs {
|
|||
#[error("...")]
|
||||
pub struct OptSourceNoBacktrace {
|
||||
#[source]
|
||||
pub source: Option<anyhow::Error>,
|
||||
source: Option<anyhow::Error>,
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[error("...")]
|
||||
pub struct OptSourceAlwaysBacktrace {
|
||||
#[source]
|
||||
pub source: Option<anyhow::Error>,
|
||||
pub backtrace: Backtrace,
|
||||
source: Option<anyhow::Error>,
|
||||
backtrace: Backtrace,
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[error("...")]
|
||||
pub struct NoSourceOptBacktrace {
|
||||
#[backtrace]
|
||||
pub backtrace: Option<Backtrace>,
|
||||
backtrace: Option<Backtrace>,
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[error("...")]
|
||||
pub struct AlwaysSourceOptBacktrace {
|
||||
pub source: anyhow::Error,
|
||||
source: anyhow::Error,
|
||||
#[backtrace]
|
||||
pub backtrace: Option<Backtrace>,
|
||||
backtrace: Option<Backtrace>,
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[error("...")]
|
||||
pub struct OptSourceOptBacktrace {
|
||||
#[source]
|
||||
pub source: Option<anyhow::Error>,
|
||||
source: Option<anyhow::Error>,
|
||||
#[backtrace]
|
||||
pub backtrace: Option<Backtrace>,
|
||||
backtrace: Option<Backtrace>,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -101,8 +101,5 @@ pub mod enums {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg_attr(
|
||||
not(thiserror_nightly_testing),
|
||||
ignore = "requires `--cfg=thiserror_nightly_testing`"
|
||||
)]
|
||||
#[cfg_attr(not(thiserror_nightly_testing), ignore)]
|
||||
fn test_option() {}
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -43,7 +43,7 @@ targets = [
|
|||
arrayvec = "0.7"
|
||||
bit-vec = "0.7"
|
||||
bitflags = "2"
|
||||
document-features = "0.2.10"
|
||||
document-features = "0.2.8"
|
||||
indexmap = "2"
|
||||
log = "0.4"
|
||||
once_cell = "1"
|
||||
|
|
|
@ -66,7 +66,7 @@ pub enum CreateBindGroupLayoutError {
|
|||
},
|
||||
#[error(transparent)]
|
||||
TooManyBindings(BindingTypeMaxCountError),
|
||||
#[error("Binding index {binding} is greater than the maximum number {maximum}")]
|
||||
#[error("Binding index {binding} is greater than the maximum index {maximum}")]
|
||||
InvalidBindingIndex { binding: u32, maximum: u32 },
|
||||
#[error("Invalid visibility {0:?}")]
|
||||
InvalidVisibility(wgt::ShaderStages),
|
||||
|
|
|
@ -321,7 +321,10 @@ impl Global {
|
|||
.raw()
|
||||
.flush_mapped_ranges(raw_buf, iter::once(offset..offset + data.len() as u64));
|
||||
}
|
||||
device.raw().unmap_buffer(raw_buf);
|
||||
device
|
||||
.raw()
|
||||
.unmap_buffer(raw_buf)
|
||||
.map_err(DeviceError::from)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
@ -367,7 +370,10 @@ impl Global {
|
|||
);
|
||||
}
|
||||
ptr::copy_nonoverlapping(mapping.ptr.as_ptr(), data.as_mut_ptr(), data.len());
|
||||
device.raw().unmap_buffer(raw_buf);
|
||||
device
|
||||
.raw()
|
||||
.unmap_buffer(raw_buf)
|
||||
.map_err(DeviceError::from)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
@ -1385,18 +1391,12 @@ impl Global {
|
|||
|
||||
let hub = A::hub(self);
|
||||
|
||||
let missing_implicit_pipeline_ids =
|
||||
desc.layout.is_none() && id_in.is_some() && implicit_pipeline_ids.is_none();
|
||||
|
||||
let fid = hub.render_pipelines.prepare(id_in);
|
||||
let implicit_context = implicit_pipeline_ids.map(|ipi| ipi.prepare(hub));
|
||||
|
||||
let error = 'error: {
|
||||
if missing_implicit_pipeline_ids {
|
||||
// TODO: categorize this error as API misuse
|
||||
break 'error pipeline::ImplicitLayoutError::MissingImplicitPipelineIds.into();
|
||||
}
|
||||
let is_auto_layout = desc.layout.is_none();
|
||||
|
||||
let error = 'error: {
|
||||
let device = match hub.devices.get(device_id) {
|
||||
Ok(device) => device,
|
||||
Err(_) => break 'error DeviceError::InvalidDeviceId.into(),
|
||||
|
@ -1511,18 +1511,23 @@ impl Global {
|
|||
Err(e) => break 'error e,
|
||||
};
|
||||
|
||||
if let Some(ids) = implicit_context.as_ref() {
|
||||
let group_count = pipeline.layout.bind_group_layouts.len();
|
||||
if ids.group_ids.len() < group_count {
|
||||
log::error!(
|
||||
"Not enough bind group IDs ({}) specified for the implicit layout ({})",
|
||||
ids.group_ids.len(),
|
||||
group_count
|
||||
);
|
||||
// TODO: categorize this error as API misuse
|
||||
break 'error pipeline::ImplicitLayoutError::MissingIds(group_count as _)
|
||||
.into();
|
||||
}
|
||||
if is_auto_layout {
|
||||
// TODO: categorize the errors below as API misuse
|
||||
let ids = if let Some(ids) = implicit_context.as_ref() {
|
||||
let group_count = pipeline.layout.bind_group_layouts.len();
|
||||
if ids.group_ids.len() < group_count {
|
||||
log::error!(
|
||||
"Not enough bind group IDs ({}) specified for the implicit layout ({})",
|
||||
ids.group_ids.len(),
|
||||
group_count
|
||||
);
|
||||
break 'error pipeline::ImplicitLayoutError::MissingIds(group_count as _)
|
||||
.into();
|
||||
}
|
||||
ids
|
||||
} else {
|
||||
break 'error pipeline::ImplicitLayoutError::MissingIds(0).into();
|
||||
};
|
||||
|
||||
let mut pipeline_layout_guard = hub.pipeline_layouts.write();
|
||||
let mut bgl_guard = hub.bind_group_layouts.write();
|
||||
|
@ -1553,14 +1558,16 @@ impl Global {
|
|||
|
||||
let id = fid.assign_error();
|
||||
|
||||
// We also need to assign errors to the implicit pipeline layout and the
|
||||
// implicit bind group layouts.
|
||||
if let Some(ids) = implicit_context {
|
||||
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);
|
||||
for bgl_id in ids.group_ids {
|
||||
bgl_guard.insert_error(bgl_id);
|
||||
if is_auto_layout {
|
||||
// We also need to assign errors to the implicit pipeline layout and the
|
||||
// implicit bind group layouts.
|
||||
if let Some(ids) = implicit_context {
|
||||
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);
|
||||
for bgl_id in ids.group_ids {
|
||||
bgl_guard.insert_error(bgl_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1628,18 +1635,12 @@ impl Global {
|
|||
|
||||
let hub = A::hub(self);
|
||||
|
||||
let missing_implicit_pipeline_ids =
|
||||
desc.layout.is_none() && id_in.is_some() && implicit_pipeline_ids.is_none();
|
||||
|
||||
let fid = hub.compute_pipelines.prepare(id_in);
|
||||
let implicit_context = implicit_pipeline_ids.map(|ipi| ipi.prepare(hub));
|
||||
|
||||
let error = 'error: {
|
||||
if missing_implicit_pipeline_ids {
|
||||
// TODO: categorize this error as API misuse
|
||||
break 'error pipeline::ImplicitLayoutError::MissingImplicitPipelineIds.into();
|
||||
}
|
||||
let is_auto_layout = desc.layout.is_none();
|
||||
|
||||
let error = 'error: {
|
||||
let device = match hub.devices.get(device_id) {
|
||||
Ok(device) => device,
|
||||
Err(_) => break 'error DeviceError::InvalidDeviceId.into(),
|
||||
|
@ -1708,18 +1709,23 @@ impl Global {
|
|||
Err(e) => break 'error e,
|
||||
};
|
||||
|
||||
if let Some(ids) = implicit_context.as_ref() {
|
||||
let group_count = pipeline.layout.bind_group_layouts.len();
|
||||
if ids.group_ids.len() < group_count {
|
||||
log::error!(
|
||||
"Not enough bind group IDs ({}) specified for the implicit layout ({})",
|
||||
ids.group_ids.len(),
|
||||
group_count
|
||||
);
|
||||
// TODO: categorize this error as API misuse
|
||||
break 'error pipeline::ImplicitLayoutError::MissingIds(group_count as _)
|
||||
.into();
|
||||
}
|
||||
if is_auto_layout {
|
||||
// TODO: categorize the errors below as API misuse
|
||||
let ids = if let Some(ids) = implicit_context.as_ref() {
|
||||
let group_count = pipeline.layout.bind_group_layouts.len();
|
||||
if ids.group_ids.len() < group_count {
|
||||
log::error!(
|
||||
"Not enough bind group IDs ({}) specified for the implicit layout ({})",
|
||||
ids.group_ids.len(),
|
||||
group_count
|
||||
);
|
||||
break 'error pipeline::ImplicitLayoutError::MissingIds(group_count as _)
|
||||
.into();
|
||||
}
|
||||
ids
|
||||
} else {
|
||||
break 'error pipeline::ImplicitLayoutError::MissingIds(0).into();
|
||||
};
|
||||
|
||||
let mut pipeline_layout_guard = hub.pipeline_layouts.write();
|
||||
let mut bgl_guard = hub.bind_group_layouts.write();
|
||||
|
@ -1750,14 +1756,16 @@ impl Global {
|
|||
|
||||
let id = fid.assign_error();
|
||||
|
||||
// We also need to assign errors to the implicit pipeline layout and the
|
||||
// implicit bind group layouts.
|
||||
if let Some(ids) = implicit_context {
|
||||
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);
|
||||
for bgl_id in ids.group_ids {
|
||||
bgl_guard.insert_error(bgl_id);
|
||||
if is_auto_layout {
|
||||
// We also need to assign errors to the implicit pipeline layout and the
|
||||
// implicit bind group layouts.
|
||||
if let Some(ids) = implicit_context {
|
||||
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);
|
||||
for bgl_id in ids.group_ids {
|
||||
bgl_guard.insert_error(bgl_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2517,7 +2525,7 @@ impl Global {
|
|||
}
|
||||
let map_state = &*buffer.map_state.lock();
|
||||
match *map_state {
|
||||
resource::BufferMapState::Init { ref staging_buffer } => {
|
||||
resource::BufferMapState::Init { ref ptr, .. } => {
|
||||
// offset (u64) can not be < 0, so no need to validate the lower bound
|
||||
if offset + range_size > buffer.size {
|
||||
return Err(BufferAccessError::OutOfBoundsOverrun {
|
||||
|
@ -2525,9 +2533,12 @@ impl Global {
|
|||
max: buffer.size,
|
||||
});
|
||||
}
|
||||
let ptr = unsafe { staging_buffer.ptr() };
|
||||
let ptr = unsafe { NonNull::new_unchecked(ptr.as_ptr().offset(offset as isize)) };
|
||||
Ok((ptr, range_size))
|
||||
unsafe {
|
||||
Ok((
|
||||
NonNull::new_unchecked(ptr.as_ptr().offset(offset as isize)),
|
||||
range_size,
|
||||
))
|
||||
}
|
||||
}
|
||||
resource::BufferMapState::Active {
|
||||
ref ptr, ref range, ..
|
||||
|
|
|
@ -95,14 +95,15 @@ pub enum WaitIdleError {
|
|||
/// submission index.
|
||||
///
|
||||
/// 3) `handle_mapping` drains `self.ready_to_map` and actually maps the
|
||||
/// buffers, collecting a list of notification closures to call.
|
||||
/// buffers, collecting a list of notification closures to call. But any
|
||||
/// buffers that were dropped by the user get moved to
|
||||
/// `self.free_resources`.
|
||||
///
|
||||
/// Only calling `Global::buffer_map_async` clones a new `Arc` for the
|
||||
/// buffer. This new `Arc` is only dropped by `handle_mapping`.
|
||||
pub(crate) struct LifetimeTracker<A: HalApi> {
|
||||
/// Buffers for which a call to [`Buffer::map_async`] has succeeded, but
|
||||
/// which haven't been examined by `triage_mapped` yet to decide when they
|
||||
/// can be mapped.
|
||||
/// Resources that the user has requested be mapped, but which are used by
|
||||
/// queue submissions still in flight.
|
||||
mapped: Vec<Arc<Buffer<A>>>,
|
||||
|
||||
/// Resources used by queue submissions still in flight. One entry per
|
||||
|
|
|
@ -433,18 +433,18 @@ pub struct ImplicitPipelineContext {
|
|||
}
|
||||
|
||||
pub struct ImplicitPipelineIds<'a> {
|
||||
pub root_id: PipelineLayoutId,
|
||||
pub group_ids: &'a [BindGroupLayoutId],
|
||||
pub root_id: Option<PipelineLayoutId>,
|
||||
pub group_ids: &'a [Option<BindGroupLayoutId>],
|
||||
}
|
||||
|
||||
impl ImplicitPipelineIds<'_> {
|
||||
fn prepare<A: HalApi>(self, hub: &Hub<A>) -> ImplicitPipelineContext {
|
||||
ImplicitPipelineContext {
|
||||
root_id: hub.pipeline_layouts.prepare(Some(self.root_id)).into_id(),
|
||||
root_id: hub.pipeline_layouts.prepare(self.root_id).into_id(),
|
||||
group_ids: self
|
||||
.group_ids
|
||||
.iter()
|
||||
.map(|id_in| hub.bind_group_layouts.prepare(Some(*id_in)).into_id())
|
||||
.map(|id_in| hub.bind_group_layouts.prepare(*id_in).into_id())
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,11 +14,11 @@ use crate::{
|
|||
hal_label,
|
||||
id::{self, QueueId},
|
||||
init_tracker::{has_copy_partial_init_tracker_coverage, TextureInitRange},
|
||||
lock::RwLockWriteGuard,
|
||||
lock::{rank, Mutex, RwLockWriteGuard},
|
||||
resource::{
|
||||
Buffer, BufferAccessError, BufferMapState, DestroyedBuffer, DestroyedResourceError,
|
||||
DestroyedTexture, FlushedStagingBuffer, Labeled, ParentDevice, ResourceErrorIdent,
|
||||
StagingBuffer, Texture, TextureInner, Trackable,
|
||||
DestroyedTexture, Labeled, ParentDevice, ResourceErrorIdent, StagingBuffer, Texture,
|
||||
TextureInner, Trackable,
|
||||
},
|
||||
resource_log,
|
||||
track::{self, Tracker, TrackerIndex},
|
||||
|
@ -29,9 +29,8 @@ use hal::{CommandEncoder as _, Device as _, Queue as _};
|
|||
use smallvec::SmallVec;
|
||||
|
||||
use std::{
|
||||
iter,
|
||||
mem::{self},
|
||||
ptr::NonNull,
|
||||
iter, mem,
|
||||
ptr::{self, NonNull},
|
||||
sync::{atomic::Ordering, Arc},
|
||||
};
|
||||
use thiserror::Error;
|
||||
|
@ -136,7 +135,7 @@ pub struct WrappedSubmissionIndex {
|
|||
/// submission, to be freed when it completes
|
||||
#[derive(Debug)]
|
||||
pub enum TempResource<A: HalApi> {
|
||||
StagingBuffer(FlushedStagingBuffer<A>),
|
||||
StagingBuffer(StagingBuffer<A>),
|
||||
DestroyedBuffer(DestroyedBuffer<A>),
|
||||
DestroyedTexture(DestroyedTexture<A>),
|
||||
}
|
||||
|
@ -256,7 +255,7 @@ impl<A: HalApi> PendingWrites<A> {
|
|||
self.temp_resources.push(resource);
|
||||
}
|
||||
|
||||
pub fn consume(&mut self, buffer: FlushedStagingBuffer<A>) {
|
||||
fn consume(&mut self, buffer: StagingBuffer<A>) {
|
||||
self.temp_resources
|
||||
.push(TempResource::StagingBuffer(buffer));
|
||||
}
|
||||
|
@ -313,6 +312,47 @@ impl<A: HalApi> PendingWrites<A> {
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) fn prepare_staging_buffer<A: HalApi>(
|
||||
device: &Arc<Device<A>>,
|
||||
size: wgt::BufferSize,
|
||||
instance_flags: wgt::InstanceFlags,
|
||||
) -> Result<(StagingBuffer<A>, NonNull<u8>), DeviceError> {
|
||||
profiling::scope!("prepare_staging_buffer");
|
||||
let stage_desc = hal::BufferDescriptor {
|
||||
label: hal_label(Some("(wgpu internal) Staging"), instance_flags),
|
||||
size: size.get(),
|
||||
usage: hal::BufferUses::MAP_WRITE | hal::BufferUses::COPY_SRC,
|
||||
memory_flags: hal::MemoryFlags::TRANSIENT,
|
||||
};
|
||||
|
||||
let buffer = unsafe { device.raw().create_buffer(&stage_desc)? };
|
||||
let mapping = unsafe { device.raw().map_buffer(&buffer, 0..size.get()) }?;
|
||||
|
||||
let staging_buffer = StagingBuffer {
|
||||
raw: Mutex::new(rank::STAGING_BUFFER_RAW, Some(buffer)),
|
||||
device: device.clone(),
|
||||
size,
|
||||
is_coherent: mapping.is_coherent,
|
||||
};
|
||||
|
||||
Ok((staging_buffer, mapping.ptr))
|
||||
}
|
||||
|
||||
impl<A: HalApi> StagingBuffer<A> {
|
||||
unsafe fn flush(&self, device: &A::Device) -> Result<(), DeviceError> {
|
||||
if !self.is_coherent {
|
||||
unsafe {
|
||||
device.flush_mapped_ranges(
|
||||
self.raw.lock().as_ref().unwrap(),
|
||||
iter::once(0..self.size.get()),
|
||||
)
|
||||
};
|
||||
}
|
||||
unsafe { device.unmap_buffer(self.raw.lock().as_ref().unwrap())? };
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Error)]
|
||||
#[error("Queue is invalid")]
|
||||
pub struct InvalidQueue;
|
||||
|
@ -405,15 +445,23 @@ impl Global {
|
|||
// Platform validation requires that the staging buffer always be
|
||||
// freed, even if an error occurs. All paths from here must call
|
||||
// `device.pending_writes.consume`.
|
||||
let mut staging_buffer = StagingBuffer::new(device, data_size)?;
|
||||
let (staging_buffer, staging_buffer_ptr) =
|
||||
prepare_staging_buffer(device, data_size, device.instance_flags)?;
|
||||
let mut pending_writes = device.pending_writes.lock();
|
||||
let pending_writes = pending_writes.as_mut().unwrap();
|
||||
|
||||
let staging_buffer = {
|
||||
if let Err(flush_error) = unsafe {
|
||||
profiling::scope!("copy");
|
||||
staging_buffer.write(data);
|
||||
staging_buffer.flush()
|
||||
};
|
||||
ptr::copy_nonoverlapping(
|
||||
data.as_ptr(),
|
||||
staging_buffer_ptr.as_ptr(),
|
||||
data_size.get() as usize,
|
||||
);
|
||||
staging_buffer.flush(device.raw())
|
||||
} {
|
||||
pending_writes.consume(staging_buffer);
|
||||
return Err(flush_error.into());
|
||||
}
|
||||
|
||||
let result = self.queue_write_staging_buffer_impl(
|
||||
&queue,
|
||||
|
@ -444,14 +492,14 @@ impl Global {
|
|||
|
||||
let device = &queue.device;
|
||||
|
||||
let staging_buffer = StagingBuffer::new(device, buffer_size)?;
|
||||
let ptr = unsafe { staging_buffer.ptr() };
|
||||
let (staging_buffer, staging_buffer_ptr) =
|
||||
prepare_staging_buffer(device, buffer_size, device.instance_flags)?;
|
||||
|
||||
let fid = hub.staging_buffers.prepare(id_in);
|
||||
let id = fid.assign(Arc::new(staging_buffer));
|
||||
resource_log!("Queue::create_staging_buffer {id:?}");
|
||||
|
||||
Ok((id, ptr))
|
||||
Ok((id, staging_buffer_ptr))
|
||||
}
|
||||
|
||||
pub fn queue_write_staging_buffer<A: HalApi>(
|
||||
|
@ -484,7 +532,10 @@ impl Global {
|
|||
// user. Platform validation requires that the staging buffer always
|
||||
// be freed, even if an error occurs. All paths from here must call
|
||||
// `device.pending_writes.consume`.
|
||||
let staging_buffer = staging_buffer.flush();
|
||||
if let Err(flush_error) = unsafe { staging_buffer.flush(device.raw()) } {
|
||||
pending_writes.consume(staging_buffer);
|
||||
return Err(flush_error.into());
|
||||
}
|
||||
|
||||
let result = self.queue_write_staging_buffer_impl(
|
||||
&queue,
|
||||
|
@ -549,7 +600,7 @@ impl Global {
|
|||
queue: &Arc<Queue<A>>,
|
||||
device: &Arc<Device<A>>,
|
||||
pending_writes: &mut PendingWrites<A>,
|
||||
staging_buffer: &FlushedStagingBuffer<A>,
|
||||
staging_buffer: &StagingBuffer<A>,
|
||||
buffer_id: id::BufferId,
|
||||
buffer_offset: u64,
|
||||
) -> Result<(), QueueWriteError> {
|
||||
|
@ -579,15 +630,20 @@ impl Global {
|
|||
dst_offset: buffer_offset,
|
||||
size: staging_buffer.size,
|
||||
};
|
||||
let inner_buffer = staging_buffer.raw.lock();
|
||||
let barriers = iter::once(hal::BufferBarrier {
|
||||
buffer: staging_buffer.raw(),
|
||||
buffer: inner_buffer.as_ref().unwrap(),
|
||||
usage: hal::BufferUses::MAP_WRITE..hal::BufferUses::COPY_SRC,
|
||||
})
|
||||
.chain(transition.map(|pending| pending.into_hal(&dst, &snatch_guard)));
|
||||
let encoder = pending_writes.activate();
|
||||
unsafe {
|
||||
encoder.transition_buffers(barriers);
|
||||
encoder.copy_buffer_to_buffer(staging_buffer.raw(), dst_raw, iter::once(region));
|
||||
encoder.copy_buffer_to_buffer(
|
||||
inner_buffer.as_ref().unwrap(),
|
||||
dst_raw,
|
||||
iter::once(region),
|
||||
);
|
||||
}
|
||||
|
||||
pending_writes.insert_buffer(&dst);
|
||||
|
@ -776,17 +832,17 @@ impl Global {
|
|||
// Platform validation requires that the staging buffer always be
|
||||
// freed, even if an error occurs. All paths from here must call
|
||||
// `device.pending_writes.consume`.
|
||||
let mut staging_buffer = StagingBuffer::new(device, stage_size)?;
|
||||
let (staging_buffer, staging_buffer_ptr) =
|
||||
prepare_staging_buffer(device, stage_size, device.instance_flags)?;
|
||||
|
||||
if stage_bytes_per_row == bytes_per_row {
|
||||
profiling::scope!("copy aligned");
|
||||
// Fast path if the data is already being aligned optimally.
|
||||
unsafe {
|
||||
staging_buffer.write_with_offset(
|
||||
data,
|
||||
data_layout.offset as isize,
|
||||
0,
|
||||
(data.len() as u64 - data_layout.offset) as usize,
|
||||
ptr::copy_nonoverlapping(
|
||||
data.as_ptr().offset(data_layout.offset as isize),
|
||||
staging_buffer_ptr.as_ptr(),
|
||||
stage_size.get() as usize,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
|
@ -795,22 +851,27 @@ impl Global {
|
|||
let copy_bytes_per_row = stage_bytes_per_row.min(bytes_per_row) as usize;
|
||||
for layer in 0..size.depth_or_array_layers {
|
||||
let rows_offset = layer * block_rows_per_image;
|
||||
for row in rows_offset..rows_offset + height_blocks {
|
||||
let src_offset = data_layout.offset as u32 + row * bytes_per_row;
|
||||
let dst_offset = row * stage_bytes_per_row;
|
||||
for row in 0..height_blocks {
|
||||
unsafe {
|
||||
staging_buffer.write_with_offset(
|
||||
data,
|
||||
src_offset as isize,
|
||||
dst_offset as isize,
|
||||
ptr::copy_nonoverlapping(
|
||||
data.as_ptr().offset(
|
||||
data_layout.offset as isize
|
||||
+ (rows_offset + row) as isize * bytes_per_row as isize,
|
||||
),
|
||||
staging_buffer_ptr.as_ptr().offset(
|
||||
(rows_offset + row) as isize * stage_bytes_per_row as isize,
|
||||
),
|
||||
copy_bytes_per_row,
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let staging_buffer = staging_buffer.flush();
|
||||
if let Err(e) = unsafe { staging_buffer.flush(device.raw()) } {
|
||||
pending_writes.consume(staging_buffer);
|
||||
return Err(e.into());
|
||||
}
|
||||
|
||||
let regions = (0..array_layer_count).map(|rel_array_layer| {
|
||||
let mut texture_base = dst_base.clone();
|
||||
|
@ -829,8 +890,9 @@ impl Global {
|
|||
});
|
||||
|
||||
{
|
||||
let inner_buffer = staging_buffer.raw.lock();
|
||||
let barrier = hal::BufferBarrier {
|
||||
buffer: staging_buffer.raw(),
|
||||
buffer: inner_buffer.as_ref().unwrap(),
|
||||
usage: hal::BufferUses::MAP_WRITE..hal::BufferUses::COPY_SRC,
|
||||
};
|
||||
|
||||
|
@ -842,7 +904,7 @@ impl Global {
|
|||
unsafe {
|
||||
encoder.transition_textures(transition.map(|pending| pending.into_hal(dst_raw)));
|
||||
encoder.transition_buffers(iter::once(barrier));
|
||||
encoder.copy_buffer_to_texture(staging_buffer.raw(), dst_raw, regions);
|
||||
encoder.copy_buffer_to_texture(inner_buffer.as_ref().unwrap(), dst_raw, regions);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1069,7 +1131,7 @@ impl Global {
|
|||
let fence = fence_guard.as_mut().unwrap();
|
||||
let submit_index = device
|
||||
.active_submission_index
|
||||
.fetch_add(1, Ordering::SeqCst)
|
||||
.fetch_add(1, Ordering::Relaxed)
|
||||
+ 1;
|
||||
let mut active_executions = Vec::new();
|
||||
|
||||
|
@ -1392,11 +1454,6 @@ impl Global {
|
|||
)
|
||||
.map_err(DeviceError::from)?;
|
||||
}
|
||||
|
||||
// Advance the successful submission index.
|
||||
device
|
||||
.last_successful_submission_index
|
||||
.fetch_max(submit_index, Ordering::SeqCst);
|
||||
}
|
||||
|
||||
profiling::scope!("cleanup");
|
||||
|
|
|
@ -22,8 +22,8 @@ use crate::{
|
|||
pipeline,
|
||||
pool::ResourcePool,
|
||||
resource::{
|
||||
self, Buffer, Labeled, ParentDevice, QuerySet, Sampler, StagingBuffer, Texture,
|
||||
TextureView, TextureViewNotRenderableReason, TrackingData,
|
||||
self, Buffer, Labeled, ParentDevice, QuerySet, Sampler, Texture, TextureView,
|
||||
TextureViewNotRenderableReason, TrackingData,
|
||||
},
|
||||
resource_log,
|
||||
snatch::{SnatchGuard, SnatchLock, Snatchable},
|
||||
|
@ -88,27 +88,8 @@ pub struct Device<A: HalApi> {
|
|||
label: String,
|
||||
|
||||
pub(crate) command_allocator: command::CommandAllocator<A>,
|
||||
|
||||
/// The index of the last command submission that was attempted.
|
||||
///
|
||||
/// Note that `fence` may never be signalled with this value, if the command
|
||||
/// submission failed. If you need to wait for everything running on a
|
||||
/// `Queue` to complete, wait for [`last_successful_submission_index`].
|
||||
///
|
||||
/// [`last_successful_submission_index`]: Device::last_successful_submission_index
|
||||
pub(crate) active_submission_index: hal::AtomicFenceValue,
|
||||
|
||||
/// The index of the last successful submission to this device's
|
||||
/// [`hal::Queue`].
|
||||
///
|
||||
/// Unlike [`active_submission_index`], which is incremented each time
|
||||
/// submission is attempted, this is updated only when submission succeeds,
|
||||
/// so waiting for this value won't hang waiting for work that was never
|
||||
/// submitted.
|
||||
///
|
||||
/// [`active_submission_index`]: Device::active_submission_index
|
||||
pub(crate) last_successful_submission_index: hal::AtomicFenceValue,
|
||||
|
||||
//Note: The submission index here corresponds to the last submission that is done.
|
||||
pub(crate) active_submission_index: AtomicU64, //SubmissionIndex,
|
||||
// NOTE: if both are needed, the `snatchable_lock` must be consistently acquired before the
|
||||
// `fence` lock to avoid deadlocks.
|
||||
pub(crate) fence: RwLock<Option<A::Fence>>,
|
||||
|
@ -277,7 +258,6 @@ impl<A: HalApi> Device<A> {
|
|||
label: desc.label.to_string(),
|
||||
command_allocator,
|
||||
active_submission_index: AtomicU64::new(0),
|
||||
last_successful_submission_index: AtomicU64::new(0),
|
||||
fence: RwLock::new(rank::DEVICE_FENCE, Some(fence)),
|
||||
snatchable_lock: unsafe { SnatchLock::new(rank::DEVICE_SNATCHABLE_LOCK) },
|
||||
valid: AtomicBool::new(true),
|
||||
|
@ -408,41 +388,37 @@ impl<A: HalApi> Device<A> {
|
|||
profiling::scope!("Device::maintain");
|
||||
|
||||
let fence = fence_guard.as_ref().unwrap();
|
||||
|
||||
// Determine which submission index `maintain` represents.
|
||||
let submission_index = match maintain {
|
||||
wgt::Maintain::WaitForSubmissionIndex(submission_index) => {
|
||||
// We don't need to check to see if the queue id matches
|
||||
// as we already checked this from inside the poll call.
|
||||
submission_index.index
|
||||
}
|
||||
wgt::Maintain::Wait => self
|
||||
.last_successful_submission_index
|
||||
.load(Ordering::Acquire),
|
||||
wgt::Maintain::Poll => unsafe {
|
||||
let last_done_index = if maintain.is_wait() {
|
||||
let index_to_wait_for = match maintain {
|
||||
wgt::Maintain::WaitForSubmissionIndex(submission_index) => {
|
||||
// We don't need to check to see if the queue id matches
|
||||
// as we already checked this from inside the poll call.
|
||||
submission_index.index
|
||||
}
|
||||
_ => self.active_submission_index.load(Ordering::Relaxed),
|
||||
};
|
||||
unsafe {
|
||||
self.raw
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.wait(fence, index_to_wait_for, CLEANUP_WAIT_MS)
|
||||
.map_err(DeviceError::from)?
|
||||
};
|
||||
index_to_wait_for
|
||||
} else {
|
||||
unsafe {
|
||||
self.raw
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.get_fence_value(fence)
|
||||
.map_err(DeviceError::from)?
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
// If necessary, wait for that submission to complete.
|
||||
if maintain.is_wait() {
|
||||
unsafe {
|
||||
self.raw
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.wait(fence, submission_index, CLEANUP_WAIT_MS)
|
||||
.map_err(DeviceError::from)?
|
||||
};
|
||||
}
|
||||
log::info!("Device::maintain: waiting for submission index {submission_index}");
|
||||
log::info!("Device::maintain: last done index {last_done_index}");
|
||||
|
||||
let mut life_tracker = self.lock_life();
|
||||
let submission_closures =
|
||||
life_tracker.triage_submissions(submission_index, &self.command_allocator);
|
||||
life_tracker.triage_submissions(last_done_index, &self.command_allocator);
|
||||
|
||||
life_tracker.triage_mapped();
|
||||
|
||||
|
@ -615,15 +591,21 @@ impl<A: HalApi> Device<A> {
|
|||
};
|
||||
hal::BufferUses::MAP_WRITE
|
||||
} else {
|
||||
let mut staging_buffer =
|
||||
StagingBuffer::new(self, wgt::BufferSize::new(aligned_size).unwrap())?;
|
||||
let (staging_buffer, staging_buffer_ptr) = queue::prepare_staging_buffer(
|
||||
self,
|
||||
wgt::BufferSize::new(aligned_size).unwrap(),
|
||||
self.instance_flags,
|
||||
)?;
|
||||
|
||||
// Zero initialize memory and then mark the buffer as initialized
|
||||
// (it's guaranteed that this is the case by the time the buffer is usable)
|
||||
staging_buffer.write_zeros();
|
||||
unsafe { std::ptr::write_bytes(staging_buffer_ptr.as_ptr(), 0, aligned_size as usize) };
|
||||
buffer.initialization_status.write().drain(0..aligned_size);
|
||||
|
||||
*buffer.map_state.lock() = resource::BufferMapState::Init { staging_buffer };
|
||||
*buffer.map_state.lock() = resource::BufferMapState::Init {
|
||||
staging_buffer,
|
||||
ptr: staging_buffer_ptr,
|
||||
};
|
||||
hal::BufferUses::COPY_DST
|
||||
};
|
||||
|
||||
|
@ -1404,8 +1386,7 @@ impl<A: HalApi> Device<A> {
|
|||
tracking_data: TrackingData::new(self.tracker_indices.samplers.clone()),
|
||||
comparison: desc.compare.is_some(),
|
||||
filtering: desc.min_filter == wgt::FilterMode::Linear
|
||||
|| desc.mag_filter == wgt::FilterMode::Linear
|
||||
|| desc.mipmap_filter == wgt::FilterMode::Linear,
|
||||
|| desc.mag_filter == wgt::FilterMode::Linear,
|
||||
};
|
||||
|
||||
let sampler = Arc::new(sampler);
|
||||
|
@ -3611,9 +3592,7 @@ impl<A: HalApi> Device<A> {
|
|||
/// Wait for idle and remove resources that we can, before we die.
|
||||
pub(crate) fn prepare_to_die(&self) {
|
||||
self.pending_writes.lock().as_mut().unwrap().deactivate();
|
||||
let current_index = self
|
||||
.last_successful_submission_index
|
||||
.load(Ordering::Acquire);
|
||||
let current_index = self.active_submission_index.load(Ordering::Relaxed);
|
||||
if let Err(error) = unsafe {
|
||||
let fence = self.fence.read();
|
||||
let fence = fence.as_ref().unwrap();
|
||||
|
|
|
@ -77,6 +77,18 @@ impl RawId {
|
|||
}
|
||||
}
|
||||
|
||||
/// Coerce a slice of identifiers into a slice of optional raw identifiers.
|
||||
///
|
||||
/// There's two reasons why we know this is correct:
|
||||
/// * `Option<T>` is guaranteed to be niche-filled to 0's.
|
||||
/// * The `T` in `Option<T>` can inhabit any representation except 0's, since
|
||||
/// its underlying representation is `NonZero*`.
|
||||
pub fn as_option_slice<T: Marker>(ids: &[Id<T>]) -> &[Option<Id<T>>] {
|
||||
// SAFETY: Any Id<T> is repr(transparent) over `Option<RawId>`, since both
|
||||
// are backed by non-zero types.
|
||||
unsafe { std::slice::from_raw_parts(ids.as_ptr().cast(), ids.len()) }
|
||||
}
|
||||
|
||||
/// An identifier for a wgpu object.
|
||||
///
|
||||
/// An `Id<T>` value identifies a value stored in a [`Global`]'s [`Hub`].
|
||||
|
|
|
@ -143,6 +143,7 @@ define_lock_ranks! {
|
|||
rank RENDER_BUNDLE_SCOPE_QUERY_SETS "RenderBundleScope::query_sets" followed by { }
|
||||
rank RESOURCE_POOL_INNER "ResourcePool::inner" followed by { }
|
||||
rank SHARED_TRACKER_INDEX_ALLOCATOR_INNER "SharedTrackerIndexAllocator::inner" followed by { }
|
||||
rank STAGING_BUFFER_RAW "StagingBuffer::raw" followed by { }
|
||||
rank STATELESS_BIND_GROUP_STATE_RESOURCES "StatelessBindGroupState::resources" followed by { }
|
||||
rank SURFACE_PRESENTATION "Surface::presentation" followed by { }
|
||||
rank TEXTURE_BIND_GROUPS "Texture::bind_groups" followed by { }
|
||||
|
|
|
@ -186,8 +186,6 @@ pub type ImplicitBindGroupCount = u8;
|
|||
#[derive(Clone, Debug, Error)]
|
||||
#[non_exhaustive]
|
||||
pub enum ImplicitLayoutError {
|
||||
#[error("The implicit_pipeline_ids arg is required")]
|
||||
MissingImplicitPipelineIds,
|
||||
#[error("Missing IDs for deriving {0} bind groups")]
|
||||
MissingIds(ImplicitBindGroupCount),
|
||||
#[error("Unable to reflect the shader {0:?} interface")]
|
||||
|
|
|
@ -24,11 +24,13 @@ use thiserror::Error;
|
|||
use std::{
|
||||
borrow::Borrow,
|
||||
fmt::Debug,
|
||||
iter,
|
||||
mem::{self, ManuallyDrop},
|
||||
iter, mem,
|
||||
ops::Range,
|
||||
ptr::NonNull,
|
||||
sync::{atomic::Ordering, Arc, Weak},
|
||||
sync::{
|
||||
atomic::{AtomicUsize, Ordering},
|
||||
Arc, Weak,
|
||||
},
|
||||
};
|
||||
|
||||
/// Information about the wgpu-core resource.
|
||||
|
@ -61,7 +63,7 @@ pub(crate) struct TrackingData {
|
|||
/// sequentially. Thus, when a queue submission completes, we know any
|
||||
/// resources used in that submission and any lower-numbered submissions are
|
||||
/// no longer in use by the GPU.
|
||||
submission_index: hal::AtomicFenceValue,
|
||||
submission_index: AtomicUsize,
|
||||
}
|
||||
|
||||
impl Drop for TrackingData {
|
||||
|
@ -75,7 +77,7 @@ impl TrackingData {
|
|||
Self {
|
||||
tracker_index: tracker_indices.alloc(),
|
||||
tracker_indices,
|
||||
submission_index: hal::AtomicFenceValue::new(0),
|
||||
submission_index: AtomicUsize::new(0),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -86,11 +88,12 @@ impl TrackingData {
|
|||
/// Record that this resource will be used by the queue submission with the
|
||||
/// given index.
|
||||
pub(crate) fn use_at(&self, submit_index: SubmissionIndex) {
|
||||
self.submission_index.store(submit_index, Ordering::Release);
|
||||
self.submission_index
|
||||
.store(submit_index as _, Ordering::Release);
|
||||
}
|
||||
|
||||
pub(crate) fn submission_index(&self) -> SubmissionIndex {
|
||||
self.submission_index.load(Ordering::Acquire)
|
||||
self.submission_index.load(Ordering::Acquire) as _
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -252,7 +255,10 @@ pub enum BufferMapAsyncStatus {
|
|||
#[derive(Debug)]
|
||||
pub(crate) enum BufferMapState<A: HalApi> {
|
||||
/// Mapped at creation.
|
||||
Init { staging_buffer: StagingBuffer<A> },
|
||||
Init {
|
||||
staging_buffer: StagingBuffer<A>,
|
||||
ptr: NonNull<u8>,
|
||||
},
|
||||
/// Waiting for GPU to be done before mapping
|
||||
Waiting(BufferPendingMapping<A>),
|
||||
/// Mapped
|
||||
|
@ -644,10 +650,15 @@ impl<A: HalApi> Buffer<A> {
|
|||
let raw_buf = self.try_raw(&snatch_guard)?;
|
||||
log::debug!("{} map state -> Idle", self.error_ident());
|
||||
match mem::replace(&mut *self.map_state.lock(), BufferMapState::Idle) {
|
||||
BufferMapState::Init { staging_buffer } => {
|
||||
BufferMapState::Init {
|
||||
staging_buffer,
|
||||
ptr,
|
||||
} => {
|
||||
#[cfg(feature = "trace")]
|
||||
if let Some(ref mut trace) = *device.trace.lock() {
|
||||
let data = trace.make_binary("bin", staging_buffer.get_data());
|
||||
let data = trace.make_binary("bin", unsafe {
|
||||
std::slice::from_raw_parts(ptr.as_ptr(), self.size as usize)
|
||||
});
|
||||
trace.add(trace::Action::WriteBuffer {
|
||||
id: buffer_id,
|
||||
data,
|
||||
|
@ -655,11 +666,17 @@ impl<A: HalApi> Buffer<A> {
|
|||
queued: true,
|
||||
});
|
||||
}
|
||||
let _ = ptr;
|
||||
|
||||
let mut pending_writes = device.pending_writes.lock();
|
||||
let pending_writes = pending_writes.as_mut().unwrap();
|
||||
|
||||
let staging_buffer = staging_buffer.flush();
|
||||
let raw_staging_buffer_guard = staging_buffer.raw.lock();
|
||||
let raw_staging_buffer = raw_staging_buffer_guard.as_ref().unwrap();
|
||||
if !staging_buffer.is_coherent {
|
||||
unsafe {
|
||||
device
|
||||
.raw()
|
||||
.flush_mapped_ranges(raw_staging_buffer, iter::once(0..self.size));
|
||||
}
|
||||
}
|
||||
|
||||
self.use_at(device.active_submission_index.load(Ordering::Relaxed) + 1);
|
||||
let region = wgt::BufferSize::new(self.size).map(|size| hal::BufferCopy {
|
||||
|
@ -668,13 +685,15 @@ impl<A: HalApi> Buffer<A> {
|
|||
size,
|
||||
});
|
||||
let transition_src = hal::BufferBarrier {
|
||||
buffer: staging_buffer.raw(),
|
||||
buffer: raw_staging_buffer,
|
||||
usage: hal::BufferUses::MAP_WRITE..hal::BufferUses::COPY_SRC,
|
||||
};
|
||||
let transition_dst = hal::BufferBarrier {
|
||||
buffer: raw_buf,
|
||||
usage: hal::BufferUses::empty()..hal::BufferUses::COPY_DST,
|
||||
};
|
||||
let mut pending_writes = device.pending_writes.lock();
|
||||
let pending_writes = pending_writes.as_mut().unwrap();
|
||||
let encoder = pending_writes.activate();
|
||||
unsafe {
|
||||
encoder.transition_buffers(
|
||||
|
@ -682,13 +701,14 @@ impl<A: HalApi> Buffer<A> {
|
|||
);
|
||||
if self.size > 0 {
|
||||
encoder.copy_buffer_to_buffer(
|
||||
staging_buffer.raw(),
|
||||
raw_staging_buffer,
|
||||
raw_buf,
|
||||
region.into_iter(),
|
||||
);
|
||||
}
|
||||
}
|
||||
pending_writes.consume(staging_buffer);
|
||||
drop(raw_staging_buffer_guard);
|
||||
pending_writes.consume_temp(queue::TempResource::StagingBuffer(staging_buffer));
|
||||
pending_writes.insert_buffer(self);
|
||||
}
|
||||
BufferMapState::Idle => {
|
||||
|
@ -714,7 +734,12 @@ impl<A: HalApi> Buffer<A> {
|
|||
}
|
||||
let _ = (ptr, range);
|
||||
}
|
||||
unsafe { device.raw().unmap_buffer(raw_buf) };
|
||||
unsafe {
|
||||
device
|
||||
.raw()
|
||||
.unmap_buffer(raw_buf)
|
||||
.map_err(DeviceError::from)?
|
||||
};
|
||||
}
|
||||
}
|
||||
Ok(None)
|
||||
|
@ -819,11 +844,6 @@ impl<A: HalApi> Drop for DestroyedBuffer<A> {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(send_sync)]
|
||||
unsafe impl<A: HalApi> Send for StagingBuffer<A> {}
|
||||
#[cfg(send_sync)]
|
||||
unsafe impl<A: HalApi> Sync for StagingBuffer<A> {}
|
||||
|
||||
/// A temporary buffer, consumed by the command that uses it.
|
||||
///
|
||||
/// A [`StagingBuffer`] is designed for one-shot uploads of data to the GPU. It
|
||||
|
@ -845,129 +865,34 @@ unsafe impl<A: HalApi> Sync for StagingBuffer<A> {}
|
|||
/// [`Device::pending_writes`]: crate::device::Device
|
||||
#[derive(Debug)]
|
||||
pub struct StagingBuffer<A: HalApi> {
|
||||
raw: A::Buffer,
|
||||
device: Arc<Device<A>>,
|
||||
pub(crate) raw: Mutex<Option<A::Buffer>>,
|
||||
pub(crate) device: Arc<Device<A>>,
|
||||
pub(crate) size: wgt::BufferSize,
|
||||
is_coherent: bool,
|
||||
ptr: NonNull<u8>,
|
||||
pub(crate) is_coherent: bool,
|
||||
}
|
||||
|
||||
impl<A: HalApi> StagingBuffer<A> {
|
||||
pub(crate) fn new(device: &Arc<Device<A>>, size: wgt::BufferSize) -> Result<Self, DeviceError> {
|
||||
use hal::Device;
|
||||
profiling::scope!("StagingBuffer::new");
|
||||
let stage_desc = hal::BufferDescriptor {
|
||||
label: crate::hal_label(Some("(wgpu internal) Staging"), device.instance_flags),
|
||||
size: size.get(),
|
||||
usage: hal::BufferUses::MAP_WRITE | hal::BufferUses::COPY_SRC,
|
||||
memory_flags: hal::MemoryFlags::TRANSIENT,
|
||||
};
|
||||
|
||||
let raw = unsafe { device.raw().create_buffer(&stage_desc)? };
|
||||
let mapping = unsafe { device.raw().map_buffer(&raw, 0..size.get()) }?;
|
||||
|
||||
let staging_buffer = StagingBuffer {
|
||||
raw,
|
||||
device: device.clone(),
|
||||
size,
|
||||
is_coherent: mapping.is_coherent,
|
||||
ptr: mapping.ptr,
|
||||
};
|
||||
|
||||
Ok(staging_buffer)
|
||||
}
|
||||
|
||||
/// SAFETY: You must not call any functions of `self`
|
||||
/// until you stopped using the returned pointer.
|
||||
pub(crate) unsafe fn ptr(&self) -> NonNull<u8> {
|
||||
self.ptr
|
||||
}
|
||||
|
||||
#[cfg(feature = "trace")]
|
||||
pub(crate) fn get_data(&self) -> &[u8] {
|
||||
unsafe { std::slice::from_raw_parts(self.ptr.as_ptr(), self.size.get() as usize) }
|
||||
}
|
||||
|
||||
pub(crate) fn write_zeros(&mut self) {
|
||||
unsafe { core::ptr::write_bytes(self.ptr.as_ptr(), 0, self.size.get() as usize) };
|
||||
}
|
||||
|
||||
pub(crate) fn write(&mut self, data: &[u8]) {
|
||||
assert!(data.len() >= self.size.get() as usize);
|
||||
// SAFETY: With the assert above, all of `copy_nonoverlapping`'s
|
||||
// requirements are satisfied.
|
||||
unsafe {
|
||||
core::ptr::copy_nonoverlapping(
|
||||
data.as_ptr(),
|
||||
self.ptr.as_ptr(),
|
||||
self.size.get() as usize,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// SAFETY: The offsets and size must be in-bounds.
|
||||
pub(crate) unsafe fn write_with_offset(
|
||||
&mut self,
|
||||
data: &[u8],
|
||||
src_offset: isize,
|
||||
dst_offset: isize,
|
||||
size: usize,
|
||||
) {
|
||||
unsafe {
|
||||
core::ptr::copy_nonoverlapping(
|
||||
data.as_ptr().offset(src_offset),
|
||||
self.ptr.as_ptr().offset(dst_offset),
|
||||
size,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn flush(self) -> FlushedStagingBuffer<A> {
|
||||
use hal::Device;
|
||||
let device = self.device.raw();
|
||||
if !self.is_coherent {
|
||||
unsafe { device.flush_mapped_ranges(&self.raw, iter::once(0..self.size.get())) };
|
||||
}
|
||||
unsafe { device.unmap_buffer(&self.raw) };
|
||||
|
||||
let StagingBuffer {
|
||||
raw, device, size, ..
|
||||
} = self;
|
||||
|
||||
FlushedStagingBuffer {
|
||||
raw: ManuallyDrop::new(raw),
|
||||
device,
|
||||
size,
|
||||
impl<A: HalApi> Drop for StagingBuffer<A> {
|
||||
fn drop(&mut self) {
|
||||
if let Some(raw) = self.raw.lock().take() {
|
||||
resource_log!("Destroy raw {}", self.error_ident());
|
||||
unsafe {
|
||||
use hal::Device;
|
||||
self.device.raw().destroy_buffer(raw);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
crate::impl_resource_type!(StagingBuffer);
|
||||
// TODO: add label
|
||||
impl<A: HalApi> Labeled for StagingBuffer<A> {
|
||||
fn label(&self) -> &str {
|
||||
""
|
||||
}
|
||||
}
|
||||
crate::impl_parent_device!(StagingBuffer);
|
||||
crate::impl_storage_item!(StagingBuffer);
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct FlushedStagingBuffer<A: HalApi> {
|
||||
raw: ManuallyDrop<A::Buffer>,
|
||||
device: Arc<Device<A>>,
|
||||
pub(crate) size: wgt::BufferSize,
|
||||
}
|
||||
|
||||
impl<A: HalApi> FlushedStagingBuffer<A> {
|
||||
pub(crate) fn raw(&self) -> &A::Buffer {
|
||||
&self.raw
|
||||
}
|
||||
}
|
||||
|
||||
impl<A: HalApi> Drop for FlushedStagingBuffer<A> {
|
||||
fn drop(&mut self) {
|
||||
use hal::Device;
|
||||
resource_log!("Destroy raw StagingBuffer");
|
||||
// SAFETY: We are in the Drop impl and we don't use self.raw anymore after this point.
|
||||
let raw = unsafe { ManuallyDrop::take(&mut self.raw) };
|
||||
unsafe { self.device.raw().destroy_buffer(raw) };
|
||||
}
|
||||
}
|
||||
|
||||
pub type TextureDescriptor<'a> = wgt::TextureDescriptor<Label<'a>, Vec<wgt::TextureFormat>>;
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -81,7 +81,7 @@ package = "wgpu-types"
|
|||
[dev-dependencies]
|
||||
cfg-if = "1"
|
||||
env_logger = "0.11"
|
||||
glam = "0.28"
|
||||
glam = "0.27.0"
|
||||
|
||||
[dev-dependencies.naga]
|
||||
version = "0.20.0"
|
||||
|
@ -165,7 +165,7 @@ version = "0.1"
|
|||
optional = true
|
||||
|
||||
[target."cfg(any(target_os=\"macos\", target_os=\"ios\"))".dependencies.metal]
|
||||
version = "0.29.0"
|
||||
version = "0.28.0"
|
||||
|
||||
[target."cfg(not(target_arch = \"wasm32\"))".dependencies.ash]
|
||||
version = "0.38.0"
|
||||
|
|
|
@ -301,7 +301,7 @@ impl<A: hal::Api> Example<A> {
|
|||
mapping.ptr.as_ptr(),
|
||||
texture_data.len(),
|
||||
);
|
||||
device.unmap_buffer(&staging_buffer);
|
||||
device.unmap_buffer(&staging_buffer).unwrap();
|
||||
assert!(mapping.is_coherent);
|
||||
}
|
||||
|
||||
|
@ -410,7 +410,7 @@ impl<A: hal::Api> Example<A> {
|
|||
mapping.ptr.as_ptr(),
|
||||
mem::size_of::<Globals>(),
|
||||
);
|
||||
device.unmap_buffer(&buffer);
|
||||
device.unmap_buffer(&buffer).unwrap();
|
||||
assert!(mapping.is_coherent);
|
||||
buffer
|
||||
};
|
||||
|
@ -647,7 +647,7 @@ impl<A: hal::Api> Example<A> {
|
|||
size,
|
||||
);
|
||||
assert!(mapping.is_coherent);
|
||||
self.device.unmap_buffer(&self.local_buffer);
|
||||
self.device.unmap_buffer(&self.local_buffer).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -814,8 +814,6 @@ fn main() {
|
|||
let example_result = Example::<Api>::init(&window);
|
||||
let mut example = Some(example_result.expect("Selected backend is not supported"));
|
||||
|
||||
println!("Press space to spawn bunnies.");
|
||||
|
||||
let mut last_frame_inst = Instant::now();
|
||||
let (mut frame_count, mut accum_time) = (0, 0.0);
|
||||
|
||||
|
|
|
@ -413,7 +413,7 @@ impl<A: hal::Api> Example<A> {
|
|||
mapping.ptr.as_ptr(),
|
||||
vertices_size_in_bytes,
|
||||
);
|
||||
device.unmap_buffer(&vertices_buffer);
|
||||
device.unmap_buffer(&vertices_buffer).unwrap();
|
||||
assert!(mapping.is_coherent);
|
||||
|
||||
vertices_buffer
|
||||
|
@ -438,7 +438,7 @@ impl<A: hal::Api> Example<A> {
|
|||
mapping.ptr.as_ptr(),
|
||||
indices_size_in_bytes,
|
||||
);
|
||||
device.unmap_buffer(&indices_buffer);
|
||||
device.unmap_buffer(&indices_buffer).unwrap();
|
||||
assert!(mapping.is_coherent);
|
||||
|
||||
indices_buffer
|
||||
|
@ -537,7 +537,7 @@ impl<A: hal::Api> Example<A> {
|
|||
mapping.ptr.as_ptr(),
|
||||
uniforms_size,
|
||||
);
|
||||
device.unmap_buffer(&uniform_buffer);
|
||||
device.unmap_buffer(&uniform_buffer).unwrap();
|
||||
assert!(mapping.is_coherent);
|
||||
uniform_buffer
|
||||
};
|
||||
|
@ -680,7 +680,7 @@ impl<A: hal::Api> Example<A> {
|
|||
mapping.ptr.as_ptr(),
|
||||
instances_buffer_size,
|
||||
);
|
||||
device.unmap_buffer(&instances_buffer);
|
||||
device.unmap_buffer(&instances_buffer).unwrap();
|
||||
assert!(mapping.is_coherent);
|
||||
|
||||
instances_buffer
|
||||
|
@ -848,7 +848,7 @@ impl<A: hal::Api> Example<A> {
|
|||
mapping.ptr.as_ptr(),
|
||||
instances_buffer_size,
|
||||
);
|
||||
self.device.unmap_buffer(&self.instances_buffer);
|
||||
self.device.unmap_buffer(&self.instances_buffer).unwrap();
|
||||
assert!(mapping.is_coherent);
|
||||
}
|
||||
|
||||
|
|
|
@ -437,8 +437,9 @@ impl crate::Device for super::Device {
|
|||
})
|
||||
}
|
||||
|
||||
unsafe fn unmap_buffer(&self, buffer: &super::Buffer) {
|
||||
unsafe fn unmap_buffer(&self, buffer: &super::Buffer) -> Result<(), DeviceError> {
|
||||
unsafe { (*buffer.resource).Unmap(0, ptr::null()) };
|
||||
Ok(())
|
||||
}
|
||||
|
||||
unsafe fn flush_mapped_ranges<I>(&self, _buffer: &super::Buffer, _ranges: I) {}
|
||||
|
|
|
@ -151,7 +151,9 @@ impl crate::Device for Context {
|
|||
) -> DeviceResult<crate::BufferMapping> {
|
||||
Err(crate::DeviceError::Lost)
|
||||
}
|
||||
unsafe fn unmap_buffer(&self, buffer: &Resource) {}
|
||||
unsafe fn unmap_buffer(&self, buffer: &Resource) -> DeviceResult<()> {
|
||||
Ok(())
|
||||
}
|
||||
unsafe fn flush_mapped_ranges<I>(&self, buffer: &Resource, ranges: I) {}
|
||||
unsafe fn invalidate_mapped_ranges<I>(&self, buffer: &Resource, ranges: I) {}
|
||||
|
||||
|
|
|
@ -691,7 +691,7 @@ impl crate::Device for super::Device {
|
|||
is_coherent,
|
||||
})
|
||||
}
|
||||
unsafe fn unmap_buffer(&self, buffer: &super::Buffer) {
|
||||
unsafe fn unmap_buffer(&self, buffer: &super::Buffer) -> Result<(), crate::DeviceError> {
|
||||
if let Some(raw) = buffer.raw {
|
||||
if buffer.data.is_none() {
|
||||
let gl = &self.shared.context.lock();
|
||||
|
@ -700,6 +700,7 @@ impl crate::Device for super::Device {
|
|||
unsafe { gl.bind_buffer(buffer.target, None) };
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
unsafe fn flush_mapped_ranges<I>(&self, buffer: &super::Buffer, ranges: I)
|
||||
where
|
||||
|
|
|
@ -294,7 +294,6 @@ pub const QUERY_SIZE: wgt::BufferAddress = 8;
|
|||
pub type Label<'a> = Option<&'a str>;
|
||||
pub type MemoryRange = Range<wgt::BufferAddress>;
|
||||
pub type FenceValue = u64;
|
||||
pub type AtomicFenceValue = std::sync::atomic::AtomicU64;
|
||||
|
||||
/// Drop guard to signal wgpu-hal is no longer using an externally created object.
|
||||
pub type DropGuard = Box<dyn std::any::Any + Send + Sync>;
|
||||
|
@ -715,13 +714,9 @@ pub trait Device: WasmNotSendSync {
|
|||
/// be ordered, so it is meaningful to talk about what must occur
|
||||
/// "between" them.
|
||||
///
|
||||
/// - Zero-sized mappings are not allowed.
|
||||
///
|
||||
/// - The returned [`BufferMapping::ptr`] must not be used after a call to
|
||||
/// [`Device::unmap_buffer`].
|
||||
///
|
||||
/// [`MAP_READ`]: BufferUses::MAP_READ
|
||||
/// [`MAP_WRITE`]: BufferUses::MAP_WRITE
|
||||
//TODO: clarify if zero-sized mapping is allowed
|
||||
unsafe fn map_buffer(
|
||||
&self,
|
||||
buffer: &<Self::A as Api>::Buffer,
|
||||
|
@ -733,7 +728,7 @@ pub trait Device: WasmNotSendSync {
|
|||
/// # Safety
|
||||
///
|
||||
/// - The given `buffer` must be currently mapped.
|
||||
unsafe fn unmap_buffer(&self, buffer: &<Self::A as Api>::Buffer);
|
||||
unsafe fn unmap_buffer(&self, buffer: &<Self::A as Api>::Buffer) -> Result<(), DeviceError>;
|
||||
|
||||
/// Indicate that CPU writes to mapped buffer memory should be made visible to the GPU.
|
||||
///
|
||||
|
@ -956,9 +951,6 @@ pub trait Queue: WasmNotSendSync {
|
|||
/// - All calls to this function that include a given [`SurfaceTexture`][st]
|
||||
/// in `surface_textures` must use the same [`Fence`].
|
||||
///
|
||||
/// - The [`Fence`] passed as `signal_fence.0` must remain alive until
|
||||
/// all submissions that will signal it have completed.
|
||||
///
|
||||
/// [`Fence`]: Api::Fence
|
||||
/// [cb]: Api::CommandBuffer
|
||||
/// [ce]: Api::CommandEncoder
|
||||
|
|
|
@ -370,7 +370,9 @@ impl crate::Device for super::Device {
|
|||
})
|
||||
}
|
||||
|
||||
unsafe fn unmap_buffer(&self, _buffer: &super::Buffer) {}
|
||||
unsafe fn unmap_buffer(&self, _buffer: &super::Buffer) -> DeviceResult<()> {
|
||||
Ok(())
|
||||
}
|
||||
unsafe fn flush_mapped_ranges<I>(&self, _buffer: &super::Buffer, _ranges: I) {}
|
||||
unsafe fn invalidate_mapped_ranges<I>(&self, _buffer: &super::Buffer, _ranges: I) {}
|
||||
|
||||
|
|
|
@ -428,14 +428,12 @@ impl PhysicalDeviceFeatures {
|
|||
shader_atomic_int64: if device_api_version >= vk::API_VERSION_1_2
|
||||
|| enabled_extensions.contains(&khr::shader_atomic_int64::NAME)
|
||||
{
|
||||
let needed = requested_features.intersects(
|
||||
wgt::Features::SHADER_INT64_ATOMIC_ALL_OPS
|
||||
| wgt::Features::SHADER_INT64_ATOMIC_MIN_MAX,
|
||||
);
|
||||
Some(
|
||||
vk::PhysicalDeviceShaderAtomicInt64Features::default()
|
||||
.shader_buffer_int64_atomics(needed)
|
||||
.shader_shared_int64_atomics(needed),
|
||||
.shader_buffer_int64_atomics(requested_features.intersects(
|
||||
wgt::Features::SHADER_INT64_ATOMIC_ALL_OPS
|
||||
| wgt::Features::SHADER_INT64_ATOMIC_MIN_MAX,
|
||||
)),
|
||||
)
|
||||
} else {
|
||||
None
|
||||
|
@ -1233,17 +1231,6 @@ impl super::InstanceShared {
|
|||
features2 = features2.push_next(next);
|
||||
}
|
||||
|
||||
// `VK_KHR_shader_atomic_int64` is promoted to 1.2, but has no
|
||||
// changes, so we can keep using the extension unconditionally.
|
||||
if capabilities.device_api_version >= vk::API_VERSION_1_2
|
||||
|| capabilities.supports_extension(khr::shader_atomic_int64::NAME)
|
||||
{
|
||||
let next = features
|
||||
.shader_atomic_int64
|
||||
.insert(vk::PhysicalDeviceShaderAtomicInt64Features::default());
|
||||
features2 = features2.push_next(next);
|
||||
}
|
||||
|
||||
if capabilities.supports_extension(ext::image_robustness::NAME) {
|
||||
let next = features
|
||||
.image_robustness
|
||||
|
|
|
@ -951,10 +951,12 @@ impl crate::Device for super::Device {
|
|||
Err(crate::DeviceError::OutOfMemory)
|
||||
}
|
||||
}
|
||||
unsafe fn unmap_buffer(&self, buffer: &super::Buffer) {
|
||||
// We can only unmap the buffer if it was already mapped successfully.
|
||||
unsafe fn unmap_buffer(&self, buffer: &super::Buffer) -> Result<(), crate::DeviceError> {
|
||||
if let Some(ref block) = buffer.block {
|
||||
unsafe { block.lock().unmap(&*self.shared) };
|
||||
Ok(())
|
||||
} else {
|
||||
Err(crate::DeviceError::OutOfMemory)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"files":{"Cargo.toml":"38e52f274586168e438609dce611fbc639397c5860a0766cf2c1fdf9873a05cb","LICENSE.APACHE":"a6cba85bc92e0cff7a450b1d873c0eaa2e9fc96bf472df0247a26bec77bf3ff9","LICENSE.MIT":"c7fea58d1cfe49634cd92e54fc10a9d871f4b275321a4cd8c09e449122caaeb4","src/assertions.rs":"3fe98027aa73970c8ab7874a3e13dbfd6faa87df2081beb5c83aeec4c60f372f","src/counters.rs":"50184b482ae5a725c9bdedf4d21b737430eec07d3c0aaa5ca0c02617e649fc29","src/lib.rs":"9c333ed4794d1f8b184872f0fa016b87ce08472c71b7965aee18d0ce24686fda","src/math.rs":"4d03039736dd6926feb139bc68734cb59df34ede310427bbf059e5c925e0af3b"},"package":null}
|
||||
{"files":{"Cargo.toml":"9e0e1fdb813669f5ae21d090c115e11cc57ca0991928633a0b009aa1b5267291","LICENSE.APACHE":"a6cba85bc92e0cff7a450b1d873c0eaa2e9fc96bf472df0247a26bec77bf3ff9","LICENSE.MIT":"c7fea58d1cfe49634cd92e54fc10a9d871f4b275321a4cd8c09e449122caaeb4","src/assertions.rs":"3fe98027aa73970c8ab7874a3e13dbfd6faa87df2081beb5c83aeec4c60f372f","src/counters.rs":"50184b482ae5a725c9bdedf4d21b737430eec07d3c0aaa5ca0c02617e649fc29","src/lib.rs":"9c333ed4794d1f8b184872f0fa016b87ce08472c71b7965aee18d0ce24686fda","src/math.rs":"4d03039736dd6926feb139bc68734cb59df34ede310427bbf059e5c925e0af3b"},"package":null}
|
|
@ -45,7 +45,7 @@ features = ["derive"]
|
|||
optional = true
|
||||
|
||||
[dev-dependencies]
|
||||
serde_json = "1.0.120"
|
||||
serde_json = "1.0.119"
|
||||
|
||||
[dev-dependencies.serde]
|
||||
version = "1"
|
||||
|
|
Загрузка…
Ссылка в новой задаче