зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 8b23c0858427 (bug 1838493) for causing webrender bustages CLOSED TREE
This commit is contained in:
Родитель
a2fcfe9c7a
Коммит
80b3affd34
|
@ -30,14 +30,14 @@ git = "https://github.com/gfx-rs/d3d12-rs"
|
|||
rev = "b940b1d71"
|
||||
replace-with = "vendored-sources"
|
||||
|
||||
[source."git+https://github.com/gfx-rs/naga?rev=76003dc0035d53a474d366dcdf49d2e4d12e921f"]
|
||||
[source."git+https://github.com/gfx-rs/naga?rev=b99d58ea435090e561377949f428bce2c18451bb"]
|
||||
git = "https://github.com/gfx-rs/naga"
|
||||
rev = "76003dc0035d53a474d366dcdf49d2e4d12e921f"
|
||||
rev = "b99d58ea435090e561377949f428bce2c18451bb"
|
||||
replace-with = "vendored-sources"
|
||||
|
||||
[source."git+https://github.com/gfx-rs/wgpu?rev=dcad7dfba92dd85c3ca21bb553a61834e01b04f5"]
|
||||
[source."git+https://github.com/gfx-rs/wgpu?rev=f71a1bc736fde37509262ca03e91d8f56a13aeb5"]
|
||||
git = "https://github.com/gfx-rs/wgpu"
|
||||
rev = "dcad7dfba92dd85c3ca21bb553a61834e01b04f5"
|
||||
rev = "f71a1bc736fde37509262ca03e91d8f56a13aeb5"
|
||||
replace-with = "vendored-sources"
|
||||
|
||||
[source."git+https://github.com/glandium/warp?rev=4af45fae95bc98b0eba1ef0db17e1dac471bb23d"]
|
||||
|
|
|
@ -140,9 +140,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "ash"
|
||||
version = "0.37.3+1.3.251"
|
||||
version = "0.37.2+1.3.238"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "39e9c3835d686b0a6084ab4234fcd1b07dbf6e4767dce60874b12356a25ecd4a"
|
||||
checksum = "28bf19c1f0a470be5fbf7522a308a05df06610252c5bcf5143e1b23f629a9a03"
|
||||
dependencies = [
|
||||
"libloading",
|
||||
]
|
||||
|
@ -831,9 +831,9 @@ checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc"
|
|||
|
||||
[[package]]
|
||||
name = "core-graphics"
|
||||
version = "0.23.0"
|
||||
version = "0.22.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "506752f2b58723339d41d013009be97e549860785a366e2a5e75dfbd9725b48e"
|
||||
checksum = "2581bbab3b8ffc6fcbd550bf46c355135d16e9ff2a6ea032ad6b9bf1d7efe4fb"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"core-foundation",
|
||||
|
@ -844,20 +844,21 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "core-graphics-types"
|
||||
version = "0.1.2"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2bb142d41022986c1d8ff29103a1411c8a3dfad3552f87a4f8dc50d61d4f4e33"
|
||||
checksum = "3a68b68b3446082644c91ac778bf50cd4104bfb002b5a6a7c44cca5a2c70788b"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"core-foundation",
|
||||
"foreign-types",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "core-text"
|
||||
version = "20.0.0"
|
||||
version = "19.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "02083d15989d6247553e1a63753561555a72b2038bba1e4239db70602a798742"
|
||||
checksum = "99d74ada66e07c1cefa18f8abfba765b486f250de2e4a999e5727fc0dd4b4a25"
|
||||
dependencies = [
|
||||
"core-foundation",
|
||||
"core-graphics",
|
||||
|
@ -1783,30 +1784,18 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "foreign-types"
|
||||
version = "0.5.0"
|
||||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d737d9aa519fb7b749cbc3b962edcf310a8dd1f4b67c91c4f83975dbdd17d965"
|
||||
checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"
|
||||
dependencies = [
|
||||
"foreign-types-macros",
|
||||
"foreign-types-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "foreign-types-macros"
|
||||
version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.18",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "foreign-types-shared"
|
||||
version = "0.3.1"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b"
|
||||
checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
|
||||
|
||||
[[package]]
|
||||
name = "form_urlencoded"
|
||||
|
@ -2323,21 +2312,21 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "gpu-alloc"
|
||||
version = "0.6.0"
|
||||
version = "0.5.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fbcd2dba93594b227a1f57ee09b8b9da8892c34d55aa332e034a228d0fe6a171"
|
||||
checksum = "7fc59e5f710e310e76e6707f86c561dd646f69a8876da9131703b2f717de818d"
|
||||
dependencies = [
|
||||
"bitflags 2.999.999",
|
||||
"bitflags 1.3.2",
|
||||
"gpu-alloc-types",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gpu-alloc-types"
|
||||
version = "0.3.0"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "98ff03b468aa837d70984d55f5d3f846f6ec31fe34bbb97c4f85219caeee1ca4"
|
||||
checksum = "54804d0d6bc9d7f26db4eaec1ad10def69b599315f487d32c334a80d1efe67a5"
|
||||
dependencies = [
|
||||
"bitflags 2.999.999",
|
||||
"bitflags 1.3.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -3181,9 +3170,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "metal"
|
||||
version = "0.25.0"
|
||||
version = "0.24.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "550b24b0cd4cf923f36bae78eca457b3a10d8a6a14a9c84cb2687b527e6a84af"
|
||||
checksum = "de11355d1f6781482d027a3b4d4de7825dcedb197bf573e0596d00008402d060"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"block",
|
||||
|
@ -3191,7 +3180,6 @@ dependencies = [
|
|||
"foreign-types",
|
||||
"log",
|
||||
"objc",
|
||||
"paste",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -3561,10 +3549,10 @@ checksum = "a2983372caf4480544083767bf2d27defafe32af49ab4df3a0b7fc90793a3664"
|
|||
[[package]]
|
||||
name = "naga"
|
||||
version = "0.12.0"
|
||||
source = "git+https://github.com/gfx-rs/naga?rev=76003dc0035d53a474d366dcdf49d2e4d12e921f#76003dc0035d53a474d366dcdf49d2e4d12e921f"
|
||||
source = "git+https://github.com/gfx-rs/naga?rev=b99d58ea435090e561377949f428bce2c18451bb#b99d58ea435090e561377949f428bce2c18451bb"
|
||||
dependencies = [
|
||||
"bit-set",
|
||||
"bitflags 2.999.999",
|
||||
"bitflags 1.3.2",
|
||||
"codespan-reporting",
|
||||
"hexf-parse",
|
||||
"indexmap",
|
||||
|
@ -6096,7 +6084,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "wgpu-core"
|
||||
version = "0.16.0"
|
||||
source = "git+https://github.com/gfx-rs/wgpu?rev=dcad7dfba92dd85c3ca21bb553a61834e01b04f5#dcad7dfba92dd85c3ca21bb553a61834e01b04f5"
|
||||
source = "git+https://github.com/gfx-rs/wgpu?rev=f71a1bc736fde37509262ca03e91d8f56a13aeb5#f71a1bc736fde37509262ca03e91d8f56a13aeb5"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"bit-vec",
|
||||
|
@ -6119,7 +6107,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "wgpu-hal"
|
||||
version = "0.16.0"
|
||||
source = "git+https://github.com/gfx-rs/wgpu?rev=dcad7dfba92dd85c3ca21bb553a61834e01b04f5#dcad7dfba92dd85c3ca21bb553a61834e01b04f5"
|
||||
source = "git+https://github.com/gfx-rs/wgpu?rev=f71a1bc736fde37509262ca03e91d8f56a13aeb5#f71a1bc736fde37509262ca03e91d8f56a13aeb5"
|
||||
dependencies = [
|
||||
"android_system_properties",
|
||||
"arrayvec",
|
||||
|
@ -6129,6 +6117,7 @@ dependencies = [
|
|||
"block",
|
||||
"core-graphics-types",
|
||||
"d3d12",
|
||||
"foreign-types",
|
||||
"gpu-alloc",
|
||||
"gpu-descriptor",
|
||||
"js-sys",
|
||||
|
@ -6155,7 +6144,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "wgpu-types"
|
||||
version = "0.16.0"
|
||||
source = "git+https://github.com/gfx-rs/wgpu?rev=dcad7dfba92dd85c3ca21bb553a61834e01b04f5#dcad7dfba92dd85c3ca21bb553a61834e01b04f5"
|
||||
source = "git+https://github.com/gfx-rs/wgpu?rev=f71a1bc736fde37509262ca03e91d8f56a13aeb5#f71a1bc736fde37509262ca03e91d8f56a13aeb5"
|
||||
dependencies = [
|
||||
"bitflags 2.999.999",
|
||||
"js-sys",
|
||||
|
|
|
@ -7,8 +7,5 @@ license = "MIT/Apache-2.0"
|
|||
[lib]
|
||||
path = "lib.rs"
|
||||
|
||||
[features]
|
||||
serde = []
|
||||
|
||||
[dependencies.bitflags]
|
||||
version = "1.0"
|
||||
|
|
|
@ -35,6 +35,6 @@ winapi = "0.3"
|
|||
|
||||
[target.'cfg(target_os = "macos")'.dependencies]
|
||||
core-foundation = "0.9"
|
||||
core-graphics = "0.23"
|
||||
foreign-types = "0.5.0"
|
||||
core-graphics = "0.22"
|
||||
foreign-types = "0.3.0"
|
||||
objc = "0.2"
|
||||
|
|
|
@ -17,7 +17,7 @@ default = []
|
|||
[dependencies.wgc]
|
||||
package = "wgpu-core"
|
||||
git = "https://github.com/gfx-rs/wgpu"
|
||||
rev = "dcad7dfba92dd85c3ca21bb553a61834e01b04f5"
|
||||
rev = "f71a1bc736fde37509262ca03e91d8f56a13aeb5"
|
||||
#Note: "replay" shouldn't ideally be needed,
|
||||
# but it allows us to serialize everything across IPC.
|
||||
features = ["replay", "trace", "serial-pass", "strict_asserts", "wgsl"]
|
||||
|
@ -27,32 +27,32 @@ features = ["replay", "trace", "serial-pass", "strict_asserts", "wgsl"]
|
|||
[target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies.wgc]
|
||||
package = "wgpu-core"
|
||||
git = "https://github.com/gfx-rs/wgpu"
|
||||
rev = "dcad7dfba92dd85c3ca21bb553a61834e01b04f5"
|
||||
rev = "f71a1bc736fde37509262ca03e91d8f56a13aeb5"
|
||||
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 = "dcad7dfba92dd85c3ca21bb553a61834e01b04f5"
|
||||
rev = "f71a1bc736fde37509262ca03e91d8f56a13aeb5"
|
||||
features = ["dx11", "dx12"]
|
||||
|
||||
# We want the wgpu-core Vulkan backend on Linux and Windows.
|
||||
[target.'cfg(any(windows, all(unix, not(any(target_os = "macos", target_os = "ios")))))'.dependencies.wgc]
|
||||
package = "wgpu-core"
|
||||
git = "https://github.com/gfx-rs/wgpu"
|
||||
rev = "dcad7dfba92dd85c3ca21bb553a61834e01b04f5"
|
||||
rev = "f71a1bc736fde37509262ca03e91d8f56a13aeb5"
|
||||
features = ["vulkan"]
|
||||
|
||||
[dependencies.wgt]
|
||||
package = "wgpu-types"
|
||||
git = "https://github.com/gfx-rs/wgpu"
|
||||
rev = "dcad7dfba92dd85c3ca21bb553a61834e01b04f5"
|
||||
rev = "f71a1bc736fde37509262ca03e91d8f56a13aeb5"
|
||||
|
||||
[dependencies.wgh]
|
||||
package = "wgpu-hal"
|
||||
git = "https://github.com/gfx-rs/wgpu"
|
||||
rev = "dcad7dfba92dd85c3ca21bb553a61834e01b04f5"
|
||||
rev = "f71a1bc736fde37509262ca03e91d8f56a13aeb5"
|
||||
|
||||
[dependencies]
|
||||
bincode = "1"
|
||||
|
|
|
@ -20,11 +20,11 @@ origin:
|
|||
|
||||
# Human-readable identifier for this version/release
|
||||
# Generally "version NNN", "tag SSS", "bookmark SSS"
|
||||
release: commit dcad7dfba92dd85c3ca21bb553a61834e01b04f5
|
||||
release: commit f71a1bc736fde37509262ca03e91d8f56a13aeb5
|
||||
|
||||
# Revision to pull in
|
||||
# Must be a long or short commit SHA (long preferred)
|
||||
revision: dcad7dfba92dd85c3ca21bb553a61834e01b04f5
|
||||
revision: f71a1bc736fde37509262ca03e91d8f56a13aeb5
|
||||
|
||||
license: ['MIT', 'Apache-2.0']
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ use crate::{
|
|||
DropAction, ImageDataLayout, ImplicitLayout, QueueWriteAction, RawString, TextureAction,
|
||||
};
|
||||
|
||||
use wgc::{identity::IdentityManager, id};
|
||||
use wgc::{hub::IdentityManager, id};
|
||||
use wgt::{Backend, TextureFormat};
|
||||
|
||||
pub use wgc::command::{compute_ffi::*, render_ffi::*};
|
||||
|
|
|
@ -13,7 +13,7 @@ pub struct IdentityRecycler<I> {
|
|||
kind: &'static str,
|
||||
}
|
||||
|
||||
impl<I: id::TypedId + Clone + std::fmt::Debug> wgc::identity::IdentityHandler<I>
|
||||
impl<I: id::TypedId + Clone + std::fmt::Debug> wgc::hub::IdentityHandler<I>
|
||||
for IdentityRecycler<I>
|
||||
{
|
||||
type Input = I;
|
||||
|
@ -51,7 +51,7 @@ pub struct IdentityRecyclerFactory {
|
|||
free_surface: extern "C" fn(id::SurfaceId, FactoryParam),
|
||||
}
|
||||
|
||||
impl wgc::identity::IdentityHandlerFactory<id::AdapterId> for IdentityRecyclerFactory {
|
||||
impl wgc::hub::IdentityHandlerFactory<id::AdapterId> for IdentityRecyclerFactory {
|
||||
type Filter = IdentityRecycler<id::AdapterId>;
|
||||
fn spawn(&self) -> Self::Filter {
|
||||
IdentityRecycler {
|
||||
|
@ -61,7 +61,7 @@ impl wgc::identity::IdentityHandlerFactory<id::AdapterId> for IdentityRecyclerFa
|
|||
}
|
||||
}
|
||||
}
|
||||
impl wgc::identity::IdentityHandlerFactory<id::DeviceId> for IdentityRecyclerFactory {
|
||||
impl wgc::hub::IdentityHandlerFactory<id::DeviceId> for IdentityRecyclerFactory {
|
||||
type Filter = IdentityRecycler<id::DeviceId>;
|
||||
fn spawn(&self) -> Self::Filter {
|
||||
IdentityRecycler {
|
||||
|
@ -71,7 +71,7 @@ impl wgc::identity::IdentityHandlerFactory<id::DeviceId> for IdentityRecyclerFac
|
|||
}
|
||||
}
|
||||
}
|
||||
impl wgc::identity::IdentityHandlerFactory<id::PipelineLayoutId> for IdentityRecyclerFactory {
|
||||
impl wgc::hub::IdentityHandlerFactory<id::PipelineLayoutId> for IdentityRecyclerFactory {
|
||||
type Filter = IdentityRecycler<id::PipelineLayoutId>;
|
||||
fn spawn(&self) -> Self::Filter {
|
||||
IdentityRecycler {
|
||||
|
@ -81,7 +81,7 @@ impl wgc::identity::IdentityHandlerFactory<id::PipelineLayoutId> for IdentityRec
|
|||
}
|
||||
}
|
||||
}
|
||||
impl wgc::identity::IdentityHandlerFactory<id::ShaderModuleId> for IdentityRecyclerFactory {
|
||||
impl wgc::hub::IdentityHandlerFactory<id::ShaderModuleId> for IdentityRecyclerFactory {
|
||||
type Filter = IdentityRecycler<id::ShaderModuleId>;
|
||||
fn spawn(&self) -> Self::Filter {
|
||||
IdentityRecycler {
|
||||
|
@ -91,7 +91,7 @@ impl wgc::identity::IdentityHandlerFactory<id::ShaderModuleId> for IdentityRecyc
|
|||
}
|
||||
}
|
||||
}
|
||||
impl wgc::identity::IdentityHandlerFactory<id::BindGroupLayoutId> for IdentityRecyclerFactory {
|
||||
impl wgc::hub::IdentityHandlerFactory<id::BindGroupLayoutId> for IdentityRecyclerFactory {
|
||||
type Filter = IdentityRecycler<id::BindGroupLayoutId>;
|
||||
fn spawn(&self) -> Self::Filter {
|
||||
IdentityRecycler {
|
||||
|
@ -101,7 +101,7 @@ impl wgc::identity::IdentityHandlerFactory<id::BindGroupLayoutId> for IdentityRe
|
|||
}
|
||||
}
|
||||
}
|
||||
impl wgc::identity::IdentityHandlerFactory<id::BindGroupId> for IdentityRecyclerFactory {
|
||||
impl wgc::hub::IdentityHandlerFactory<id::BindGroupId> for IdentityRecyclerFactory {
|
||||
type Filter = IdentityRecycler<id::BindGroupId>;
|
||||
fn spawn(&self) -> Self::Filter {
|
||||
IdentityRecycler {
|
||||
|
@ -111,7 +111,7 @@ impl wgc::identity::IdentityHandlerFactory<id::BindGroupId> for IdentityRecycler
|
|||
}
|
||||
}
|
||||
}
|
||||
impl wgc::identity::IdentityHandlerFactory<id::CommandBufferId> for IdentityRecyclerFactory {
|
||||
impl wgc::hub::IdentityHandlerFactory<id::CommandBufferId> for IdentityRecyclerFactory {
|
||||
type Filter = IdentityRecycler<id::CommandBufferId>;
|
||||
fn spawn(&self) -> Self::Filter {
|
||||
IdentityRecycler {
|
||||
|
@ -121,7 +121,7 @@ impl wgc::identity::IdentityHandlerFactory<id::CommandBufferId> for IdentityRecy
|
|||
}
|
||||
}
|
||||
}
|
||||
impl wgc::identity::IdentityHandlerFactory<id::RenderBundleId> for IdentityRecyclerFactory {
|
||||
impl wgc::hub::IdentityHandlerFactory<id::RenderBundleId> for IdentityRecyclerFactory {
|
||||
type Filter = IdentityRecycler<id::RenderBundleId>;
|
||||
fn spawn(&self) -> Self::Filter {
|
||||
IdentityRecycler {
|
||||
|
@ -131,7 +131,7 @@ impl wgc::identity::IdentityHandlerFactory<id::RenderBundleId> for IdentityRecyc
|
|||
}
|
||||
}
|
||||
}
|
||||
impl wgc::identity::IdentityHandlerFactory<id::RenderPipelineId> for IdentityRecyclerFactory {
|
||||
impl wgc::hub::IdentityHandlerFactory<id::RenderPipelineId> for IdentityRecyclerFactory {
|
||||
type Filter = IdentityRecycler<id::RenderPipelineId>;
|
||||
fn spawn(&self) -> Self::Filter {
|
||||
IdentityRecycler {
|
||||
|
@ -141,7 +141,7 @@ impl wgc::identity::IdentityHandlerFactory<id::RenderPipelineId> for IdentityRec
|
|||
}
|
||||
}
|
||||
}
|
||||
impl wgc::identity::IdentityHandlerFactory<id::ComputePipelineId> for IdentityRecyclerFactory {
|
||||
impl wgc::hub::IdentityHandlerFactory<id::ComputePipelineId> for IdentityRecyclerFactory {
|
||||
type Filter = IdentityRecycler<id::ComputePipelineId>;
|
||||
fn spawn(&self) -> Self::Filter {
|
||||
IdentityRecycler {
|
||||
|
@ -151,7 +151,7 @@ impl wgc::identity::IdentityHandlerFactory<id::ComputePipelineId> for IdentityRe
|
|||
}
|
||||
}
|
||||
}
|
||||
impl wgc::identity::IdentityHandlerFactory<id::QuerySetId> for IdentityRecyclerFactory {
|
||||
impl wgc::hub::IdentityHandlerFactory<id::QuerySetId> for IdentityRecyclerFactory {
|
||||
type Filter = IdentityRecycler<id::QuerySetId>;
|
||||
fn spawn(&self) -> Self::Filter {
|
||||
IdentityRecycler {
|
||||
|
@ -161,7 +161,7 @@ impl wgc::identity::IdentityHandlerFactory<id::QuerySetId> for IdentityRecyclerF
|
|||
}
|
||||
}
|
||||
}
|
||||
impl wgc::identity::IdentityHandlerFactory<id::BufferId> for IdentityRecyclerFactory {
|
||||
impl wgc::hub::IdentityHandlerFactory<id::BufferId> for IdentityRecyclerFactory {
|
||||
type Filter = IdentityRecycler<id::BufferId>;
|
||||
fn spawn(&self) -> Self::Filter {
|
||||
IdentityRecycler {
|
||||
|
@ -171,7 +171,7 @@ impl wgc::identity::IdentityHandlerFactory<id::BufferId> for IdentityRecyclerFac
|
|||
}
|
||||
}
|
||||
}
|
||||
impl wgc::identity::IdentityHandlerFactory<id::StagingBufferId> for IdentityRecyclerFactory {
|
||||
impl wgc::hub::IdentityHandlerFactory<id::StagingBufferId> for IdentityRecyclerFactory {
|
||||
type Filter = IdentityRecycler<id::StagingBufferId>;
|
||||
fn spawn(&self) -> Self::Filter {
|
||||
IdentityRecycler {
|
||||
|
@ -181,7 +181,7 @@ impl wgc::identity::IdentityHandlerFactory<id::StagingBufferId> for IdentityRecy
|
|||
}
|
||||
}
|
||||
}
|
||||
impl wgc::identity::IdentityHandlerFactory<id::TextureId> for IdentityRecyclerFactory {
|
||||
impl wgc::hub::IdentityHandlerFactory<id::TextureId> for IdentityRecyclerFactory {
|
||||
type Filter = IdentityRecycler<id::TextureId>;
|
||||
fn spawn(&self) -> Self::Filter {
|
||||
IdentityRecycler {
|
||||
|
@ -191,7 +191,7 @@ impl wgc::identity::IdentityHandlerFactory<id::TextureId> for IdentityRecyclerFa
|
|||
}
|
||||
}
|
||||
}
|
||||
impl wgc::identity::IdentityHandlerFactory<id::TextureViewId> for IdentityRecyclerFactory {
|
||||
impl wgc::hub::IdentityHandlerFactory<id::TextureViewId> for IdentityRecyclerFactory {
|
||||
type Filter = IdentityRecycler<id::TextureViewId>;
|
||||
fn spawn(&self) -> Self::Filter {
|
||||
IdentityRecycler {
|
||||
|
@ -201,7 +201,7 @@ impl wgc::identity::IdentityHandlerFactory<id::TextureViewId> for IdentityRecycl
|
|||
}
|
||||
}
|
||||
}
|
||||
impl wgc::identity::IdentityHandlerFactory<id::SamplerId> for IdentityRecyclerFactory {
|
||||
impl wgc::hub::IdentityHandlerFactory<id::SamplerId> for IdentityRecyclerFactory {
|
||||
type Filter = IdentityRecycler<id::SamplerId>;
|
||||
fn spawn(&self) -> Self::Filter {
|
||||
IdentityRecycler {
|
||||
|
@ -211,7 +211,7 @@ impl wgc::identity::IdentityHandlerFactory<id::SamplerId> for IdentityRecyclerFa
|
|||
}
|
||||
}
|
||||
}
|
||||
impl wgc::identity::IdentityHandlerFactory<id::SurfaceId> for IdentityRecyclerFactory {
|
||||
impl wgc::hub::IdentityHandlerFactory<id::SurfaceId> for IdentityRecyclerFactory {
|
||||
type Filter = IdentityRecycler<id::SurfaceId>;
|
||||
fn spawn(&self) -> Self::Filter {
|
||||
IdentityRecycler {
|
||||
|
@ -222,4 +222,4 @@ impl wgc::identity::IdentityHandlerFactory<id::SurfaceId> for IdentityRecyclerFa
|
|||
}
|
||||
}
|
||||
|
||||
impl wgc::identity::GlobalIdentityHandlerFactory for IdentityRecyclerFactory {}
|
||||
impl wgc::hub::GlobalIdentityHandlerFactory for IdentityRecyclerFactory {}
|
||||
|
|
|
@ -88,10 +88,10 @@ impl ErrorBuffer {
|
|||
}
|
||||
|
||||
// hide wgc's global in private
|
||||
pub struct Global(wgc::global::Global<IdentityRecyclerFactory>);
|
||||
pub struct Global(wgc::hub::Global<IdentityRecyclerFactory>);
|
||||
|
||||
impl std::ops::Deref for Global {
|
||||
type Target = wgc::global::Global<IdentityRecyclerFactory>;
|
||||
type Target = wgc::hub::Global<IdentityRecyclerFactory>;
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.0
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ pub extern "C" fn wgpu_server_new(factory: IdentityRecyclerFactory) -> *mut Glob
|
|||
);
|
||||
wgc::instance::parse_backends_from_comma_list(&backends_pref)
|
||||
};
|
||||
let global = Global(wgc::global::Global::new(
|
||||
let global = Global(wgc::hub::Global::new(
|
||||
"wgpu",
|
||||
factory,
|
||||
wgt::InstanceDescriptor {
|
||||
|
@ -448,7 +448,7 @@ pub extern "C" fn wgpu_server_buffer_drop(global: &Global, self_id: id::BufferId
|
|||
}
|
||||
|
||||
impl Global {
|
||||
fn device_action<A: wgc::hal_api::HalApi>(
|
||||
fn device_action<A: wgc::hub::HalApi>(
|
||||
&self,
|
||||
self_id: id::DeviceId,
|
||||
action: DeviceAction,
|
||||
|
@ -548,7 +548,7 @@ impl Global {
|
|||
}
|
||||
}
|
||||
|
||||
fn texture_action<A: wgc::hal_api::HalApi>(
|
||||
fn texture_action<A: wgc::hub::HalApi>(
|
||||
&self,
|
||||
self_id: id::TextureId,
|
||||
action: TextureAction,
|
||||
|
@ -564,7 +564,7 @@ impl Global {
|
|||
}
|
||||
}
|
||||
|
||||
fn command_encoder_action<A: wgc::hal_api::HalApi>(
|
||||
fn command_encoder_action<A: wgc::hub::HalApi>(
|
||||
&self,
|
||||
self_id: id::CommandEncoderId,
|
||||
action: CommandEncoderAction,
|
||||
|
|
|
@ -375,7 +375,7 @@ dependencies = [
|
|||
"cocoa-foundation",
|
||||
"core-foundation 0.9.2",
|
||||
"core-graphics 0.22.3",
|
||||
"foreign-types 0.3.2",
|
||||
"foreign-types",
|
||||
"libc",
|
||||
"objc",
|
||||
]
|
||||
|
@ -390,7 +390,7 @@ dependencies = [
|
|||
"block",
|
||||
"core-foundation 0.9.2",
|
||||
"core-graphics-types",
|
||||
"foreign-types 0.3.2",
|
||||
"foreign-types",
|
||||
"libc",
|
||||
"objc",
|
||||
]
|
||||
|
@ -466,7 +466,7 @@ checksum = "b3889374e6ea6ab25dba90bb5d96202f61108058361f6dc72e8b03e6f8bbe923"
|
|||
dependencies = [
|
||||
"bitflags",
|
||||
"core-foundation 0.7.0",
|
||||
"foreign-types 0.3.2",
|
||||
"foreign-types",
|
||||
"libc",
|
||||
]
|
||||
|
||||
|
@ -479,31 +479,19 @@ dependencies = [
|
|||
"bitflags",
|
||||
"core-foundation 0.9.2",
|
||||
"core-graphics-types",
|
||||
"foreign-types 0.3.2",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "core-graphics"
|
||||
version = "0.23.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "506752f2b58723339d41d013009be97e549860785a366e2a5e75dfbd9725b48e"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"core-foundation 0.9.2",
|
||||
"core-graphics-types",
|
||||
"foreign-types 0.5.0",
|
||||
"foreign-types",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "core-graphics-types"
|
||||
version = "0.1.2"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2bb142d41022986c1d8ff29103a1411c8a3dfad3552f87a4f8dc50d61d4f4e33"
|
||||
checksum = "e92f5d519093a4178296707dbaa3880eae85a5ef5386675f361a1cf25376e93c"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"core-foundation 0.9.2",
|
||||
"foreign-types",
|
||||
"libc",
|
||||
]
|
||||
|
||||
|
@ -515,19 +503,7 @@ checksum = "99d74ada66e07c1cefa18f8abfba765b486f250de2e4a999e5727fc0dd4b4a25"
|
|||
dependencies = [
|
||||
"core-foundation 0.9.2",
|
||||
"core-graphics 0.22.3",
|
||||
"foreign-types 0.3.2",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "core-text"
|
||||
version = "20.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "02083d15989d6247553e1a63753561555a72b2038bba1e4239db70602a798742"
|
||||
dependencies = [
|
||||
"core-foundation 0.9.2",
|
||||
"core-graphics 0.23.0",
|
||||
"foreign-types 0.5.0",
|
||||
"foreign-types",
|
||||
"libc",
|
||||
]
|
||||
|
||||
|
@ -841,7 +817,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "c49d6b4c11dca1a1dd931a34a9f397e2da91abe3de4110505f3530a80e560b52"
|
||||
dependencies = [
|
||||
"core-foundation 0.9.2",
|
||||
"core-text 19.2.0",
|
||||
"core-text",
|
||||
"libc",
|
||||
"servo-fontconfig",
|
||||
"winapi",
|
||||
|
@ -853,28 +829,7 @@ version = "0.3.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"
|
||||
dependencies = [
|
||||
"foreign-types-shared 0.1.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "foreign-types"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d737d9aa519fb7b749cbc3b962edcf310a8dd1f4b67c91c4f83975dbdd17d965"
|
||||
dependencies = [
|
||||
"foreign-types-macros",
|
||||
"foreign-types-shared 0.3.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "foreign-types-macros"
|
||||
version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.18",
|
||||
"foreign-types-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -883,12 +838,6 @@ version = "0.1.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
|
||||
|
||||
[[package]]
|
||||
name = "foreign-types-shared"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b"
|
||||
|
||||
[[package]]
|
||||
name = "form_urlencoded"
|
||||
version = "1.0.1"
|
||||
|
@ -3278,8 +3227,8 @@ name = "wr_glyph_rasterizer"
|
|||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"core-foundation 0.9.2",
|
||||
"core-graphics 0.23.0",
|
||||
"core-text 20.0.0",
|
||||
"core-graphics 0.22.3",
|
||||
"core-text",
|
||||
"dwrote",
|
||||
"env_logger",
|
||||
"euclid",
|
||||
|
@ -3319,7 +3268,7 @@ dependencies = [
|
|||
"chrono",
|
||||
"clap",
|
||||
"core-foundation 0.9.2",
|
||||
"core-graphics 0.23.0",
|
||||
"core-graphics 0.22.3",
|
||||
"crossbeam",
|
||||
"dwrote",
|
||||
"env_logger",
|
||||
|
|
|
@ -10,12 +10,6 @@ packages = [
|
|||
"core-foundation",
|
||||
"core-foundation-sys",
|
||||
"core-graphics",
|
||||
# requires a new version of font-loader, see https://github.com/matprec/rust-font-loader/pull/36
|
||||
"core-text",
|
||||
# requires updating winit to v0.28 and glutin to v0.30 (to get rid of cocoa v0.24)
|
||||
# AND also requires bumping the core-graphics dependency of winit (not present in v0.28)
|
||||
"foreign-types",
|
||||
"foreign-types-shared",
|
||||
"gl_generator",
|
||||
# Internal dependencies of glsl-lang (only used in wrench) require different versions.
|
||||
"hashbrown",
|
||||
|
|
|
@ -46,6 +46,6 @@ dwrote = "0.11"
|
|||
|
||||
[target.'cfg(target_os = "macos")'.dependencies]
|
||||
core-foundation = "0.9.2"
|
||||
core-graphics = "0.23"
|
||||
core-text = { version = "20", default-features = false }
|
||||
core-graphics = "0.22.3"
|
||||
core-text = { version = "19.2", default-features = false }
|
||||
objc = "0.2"
|
||||
|
|
|
@ -40,7 +40,7 @@ default-features = false
|
|||
features = ["png"]
|
||||
|
||||
[target.'cfg(target_os = "macos")'.dependencies]
|
||||
core-graphics = "0.23"
|
||||
core-graphics = "0.22"
|
||||
core-foundation = "0.9"
|
||||
|
||||
[features]
|
||||
|
|
|
@ -471,11 +471,6 @@ who = "Nicolas Silva <nical@fastmail.com>"
|
|||
criteria = "safe-to-deploy"
|
||||
delta = "0.37.1+1.3.235 -> 0.37.2+1.3.238"
|
||||
|
||||
[[audits.ash]]
|
||||
who = "Teodor Tanasoaia <ttanasoaia@mozilla.com>"
|
||||
criteria = "safe-to-deploy"
|
||||
delta = "0.37.2+1.3.238 -> 0.37.3+1.3.251"
|
||||
|
||||
[[audits.ashmem]]
|
||||
who = "Matthew Gregan <kinetik@flim.org>"
|
||||
criteria = "safe-to-deploy"
|
||||
|
@ -606,11 +601,6 @@ who = "Nicolas Silva <nical@fastmail.com>"
|
|||
criteria = "safe-to-deploy"
|
||||
delta = "2.0.2 -> 2.1.0"
|
||||
|
||||
[[audits.bitflags]]
|
||||
who = "Teodor Tanasoaia <ttanasoaia@mozilla.com>"
|
||||
criteria = "safe-to-deploy"
|
||||
delta = "2.2.1 -> 2.3.2"
|
||||
|
||||
[[audits.block-buffer]]
|
||||
who = "Mike Hommey <mh+mozilla@glandium.org>"
|
||||
criteria = "safe-to-deploy"
|
||||
|
@ -730,21 +720,6 @@ who = "Mike Hommey <mh+mozilla@glandium.org>"
|
|||
criteria = "safe-to-run"
|
||||
delta = "0.16.0 -> 0.16.2"
|
||||
|
||||
[[audits.core-graphics]]
|
||||
who = "Teodor Tanasoaia <ttanasoaia@mozilla.com>"
|
||||
criteria = "safe-to-deploy"
|
||||
delta = "0.22.3 -> 0.23.0"
|
||||
|
||||
[[audits.core-graphics-types]]
|
||||
who = "Teodor Tanasoaia <ttanasoaia@mozilla.com>"
|
||||
criteria = "safe-to-deploy"
|
||||
delta = "0.1.1 -> 0.1.2"
|
||||
|
||||
[[audits.core-text]]
|
||||
who = "Teodor Tanasoaia <ttanasoaia@mozilla.com>"
|
||||
criteria = "safe-to-deploy"
|
||||
delta = "19.2.0 -> 20.0.0"
|
||||
|
||||
[[audits.coreaudio-sys]]
|
||||
who = "Mike Hommey <mh+mozilla@glandium.org>"
|
||||
criteria = "safe-to-deploy"
|
||||
|
@ -1302,21 +1277,6 @@ criteria = "safe-to-deploy"
|
|||
version = "1.0.7"
|
||||
notes = "Simple hasher implementation with no unsafe code."
|
||||
|
||||
[[audits.foreign-types]]
|
||||
who = "Teodor Tanasoaia <ttanasoaia@mozilla.com>"
|
||||
criteria = "safe-to-deploy"
|
||||
delta = "0.3.2 -> 0.5.0"
|
||||
|
||||
[[audits.foreign-types-macros]]
|
||||
who = "Teodor Tanasoaia <ttanasoaia@mozilla.com>"
|
||||
criteria = "safe-to-deploy"
|
||||
version = "0.2.3"
|
||||
|
||||
[[audits.foreign-types-shared]]
|
||||
who = "Teodor Tanasoaia <ttanasoaia@mozilla.com>"
|
||||
criteria = "safe-to-deploy"
|
||||
delta = "0.1.1 -> 0.3.1"
|
||||
|
||||
[[audits.fs-err]]
|
||||
who = "Mike Hommey <mh+mozilla@glandium.org>"
|
||||
criteria = "safe-to-deploy"
|
||||
|
@ -1586,16 +1546,6 @@ criteria = "safe-to-deploy"
|
|||
delta = "0.5.4 -> 0.6.0"
|
||||
notes = "Mostly bug fixes and some added functionality"
|
||||
|
||||
[[audits.gpu-alloc]]
|
||||
who = "Teodor Tanasoaia <ttanasoaia@mozilla.com>"
|
||||
criteria = "safe-to-deploy"
|
||||
delta = "0.5.3 -> 0.6.0"
|
||||
|
||||
[[audits.gpu-alloc-types]]
|
||||
who = "Teodor Tanasoaia <ttanasoaia@mozilla.com>"
|
||||
criteria = "safe-to-deploy"
|
||||
delta = "0.2.0 -> 0.3.0"
|
||||
|
||||
[[audits.gpu-descriptor]]
|
||||
who = "Mike Hommey <mh+mozilla@glandium.org>"
|
||||
criteria = "safe-to-deploy"
|
||||
|
@ -1890,11 +1840,6 @@ criteria = "safe-to-deploy"
|
|||
delta = "0.23.1 -> 0.24.0"
|
||||
notes = "This audit treats Dzmitry Malyshau (kvark) as a trusted reviewer."
|
||||
|
||||
[[audits.metal]]
|
||||
who = "Teodor Tanasoaia <ttanasoaia@mozilla.com>"
|
||||
criteria = "safe-to-deploy"
|
||||
delta = "0.24.0 -> 0.25.0"
|
||||
|
||||
[[audits.midir]]
|
||||
who = "Bobby Holley <bobbyholley@gmail.com>"
|
||||
criteria = "safe-to-deploy"
|
||||
|
@ -2001,11 +1946,6 @@ who = "Nicolas Silva <nical@fastmail.com>"
|
|||
criteria = "safe-to-deploy"
|
||||
delta = "0.11.0@git:f59668ccfaf7bdb3a7e43d84363a21c77357b2fe -> 0.12.0@git:b99d58ea435090e561377949f428bce2c18451bb"
|
||||
|
||||
[[audits.naga]]
|
||||
who = "Teodor Tanasoaia <ttanasoaia@mozilla.com>"
|
||||
criteria = "safe-to-deploy"
|
||||
delta = "0.12.0@git:b99d58ea435090e561377949f428bce2c18451bb -> 0.12.0@git:76003dc0035d53a474d366dcdf49d2e4d12e921f"
|
||||
|
||||
[[audits.net2]]
|
||||
who = "Mike Hommey <mh+mozilla@glandium.org>"
|
||||
criteria = "safe-to-run"
|
||||
|
@ -3593,11 +3533,6 @@ who = "Erich Gubler <erichdongubler@gmail.com>"
|
|||
criteria = "safe-to-deploy"
|
||||
delta = "0.16.0@git:25cb9f61e9a6be572ee42536bbe57aa5f759a700 -> 0.16.0@git:f71a1bc736fde37509262ca03e91d8f56a13aeb5"
|
||||
|
||||
[[audits.wgpu-core]]
|
||||
who = "Teodor Tanasoaia <ttanasoaia@mozilla.com>"
|
||||
criteria = "safe-to-deploy"
|
||||
delta = "0.16.0@git:f71a1bc736fde37509262ca03e91d8f56a13aeb5 -> 0.16.0@git:dcad7dfba92dd85c3ca21bb553a61834e01b04f5"
|
||||
|
||||
[[audits.wgpu-hal]]
|
||||
who = "Dzmitry Malyshau <kvark@fastmail.com>"
|
||||
criteria = "safe-to-deploy"
|
||||
|
@ -3676,11 +3611,6 @@ who = "Erich Gubler <erichdongubler@gmail.com>"
|
|||
criteria = "safe-to-deploy"
|
||||
delta = "0.16.0@git:25cb9f61e9a6be572ee42536bbe57aa5f759a700 -> 0.16.0@git:f71a1bc736fde37509262ca03e91d8f56a13aeb5"
|
||||
|
||||
[[audits.wgpu-hal]]
|
||||
who = "Teodor Tanasoaia <ttanasoaia@mozilla.com>"
|
||||
criteria = "safe-to-deploy"
|
||||
delta = "0.16.0@git:f71a1bc736fde37509262ca03e91d8f56a13aeb5 -> 0.16.0@git:dcad7dfba92dd85c3ca21bb553a61834e01b04f5"
|
||||
|
||||
[[audits.wgpu-types]]
|
||||
who = "Dzmitry Malyshau <kvark@fastmail.com>"
|
||||
criteria = "safe-to-deploy"
|
||||
|
@ -3759,11 +3689,6 @@ who = "Erich Gubler <erichdongubler@gmail.com>"
|
|||
criteria = "safe-to-deploy"
|
||||
delta = "0.16.0@git:25cb9f61e9a6be572ee42536bbe57aa5f759a700 -> 0.16.0@git:f71a1bc736fde37509262ca03e91d8f56a13aeb5"
|
||||
|
||||
[[audits.wgpu-types]]
|
||||
who = "Teodor Tanasoaia <ttanasoaia@mozilla.com>"
|
||||
criteria = "safe-to-deploy"
|
||||
delta = "0.16.0@git:f71a1bc736fde37509262ca03e91d8f56a13aeb5 -> 0.16.0@git:dcad7dfba92dd85c3ca21bb553a61834e01b04f5"
|
||||
|
||||
[[audits.whatsys]]
|
||||
who = "Bobby Holley <bobbyholley@gmail.com>"
|
||||
criteria = "safe-to-deploy"
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -10,10 +10,10 @@
|
|||
# See Cargo.toml.orig for the original contents.
|
||||
|
||||
[package]
|
||||
edition = "2021"
|
||||
edition = "2018"
|
||||
rust-version = "1.59.0"
|
||||
name = "ash"
|
||||
version = "0.37.3+1.3.251"
|
||||
version = "0.37.2+1.3.238"
|
||||
authors = [
|
||||
"Maik Klein <maikklein@googlemail.com>",
|
||||
"Benjamin Saunders <ben.e.saunders@gmail.com>",
|
||||
|
@ -28,7 +28,9 @@ keywords = [
|
|||
]
|
||||
license = "MIT OR Apache-2.0"
|
||||
repository = "https://github.com/MaikKlein/ash"
|
||||
resolver = "1"
|
||||
|
||||
[package.metadata.release]
|
||||
no-dev-version = true
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
all-features = true
|
||||
|
@ -37,9 +39,6 @@ rustdoc-args = [
|
|||
"docsrs",
|
||||
]
|
||||
|
||||
[package.metadata.release]
|
||||
no-dev-version = true
|
||||
|
||||
[dependencies.libloading]
|
||||
version = "0.7"
|
||||
optional = true
|
||||
|
|
|
@ -8,7 +8,6 @@ A very lightweight wrapper around Vulkan
|
|||
[![LICENSE](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE-MIT)
|
||||
[![LICENSE](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](LICENSE-APACHE)
|
||||
[![Join the chat at https://gitter.im/MaikKlein/ash](https://badges.gitter.im/MaikKlein/ash.svg)](https://gitter.im/MaikKlein/ash?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
[![MSRV](https://img.shields.io/badge/rustc-1.60.0+-ab6000.svg)](https://blog.rust-lang.org/2022/04/07/Rust-1.60.0.html)
|
||||
|
||||
## Overview
|
||||
- [x] A true Vulkan API without compromises
|
||||
|
|
|
@ -13,12 +13,12 @@ fn main() {
|
|||
("windows", "64") => "Lib",
|
||||
_ => "lib",
|
||||
};
|
||||
println!("cargo:rustc-link-search={var}/{suffix}");
|
||||
println!("cargo:rustc-link-search={}/{}", var, suffix);
|
||||
}
|
||||
let lib = match &*target_family {
|
||||
"windows" => "vulkan-1",
|
||||
_ => "vulkan",
|
||||
};
|
||||
println!("cargo:rustc-link-lib={lib}");
|
||||
println!("cargo:rustc-link-lib={}", lib);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -465,42 +465,34 @@ impl Device {
|
|||
#[inline]
|
||||
pub unsafe fn get_device_buffer_memory_requirements(
|
||||
&self,
|
||||
memory_requirements: &vk::DeviceBufferMemoryRequirements,
|
||||
create_info: &vk::DeviceBufferMemoryRequirements,
|
||||
out: &mut vk::MemoryRequirements2,
|
||||
) {
|
||||
(self.device_fn_1_3.get_device_buffer_memory_requirements)(
|
||||
self.handle,
|
||||
memory_requirements,
|
||||
out,
|
||||
)
|
||||
(self.device_fn_1_3.get_device_buffer_memory_requirements)(self.handle, create_info, out)
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetDeviceImageMemoryRequirements.html>
|
||||
#[inline]
|
||||
pub unsafe fn get_device_image_memory_requirements(
|
||||
&self,
|
||||
memory_requirements: &vk::DeviceImageMemoryRequirements,
|
||||
create_info: &vk::DeviceImageMemoryRequirements,
|
||||
out: &mut vk::MemoryRequirements2,
|
||||
) {
|
||||
(self.device_fn_1_3.get_device_image_memory_requirements)(
|
||||
self.handle,
|
||||
memory_requirements,
|
||||
out,
|
||||
)
|
||||
(self.device_fn_1_3.get_device_image_memory_requirements)(self.handle, create_info, out)
|
||||
}
|
||||
|
||||
/// Retrieve the number of elements to pass to [`get_device_image_sparse_memory_requirements()`][Self::get_device_image_sparse_memory_requirements()]
|
||||
#[inline]
|
||||
pub unsafe fn get_device_image_sparse_memory_requirements_len(
|
||||
&self,
|
||||
memory_requirements: &vk::DeviceImageMemoryRequirements,
|
||||
create_info: &vk::DeviceImageMemoryRequirements,
|
||||
) -> usize {
|
||||
let mut count = 0;
|
||||
(self
|
||||
.device_fn_1_3
|
||||
.get_device_image_sparse_memory_requirements)(
|
||||
self.handle,
|
||||
memory_requirements,
|
||||
create_info,
|
||||
&mut count,
|
||||
std::ptr::null_mut(),
|
||||
);
|
||||
|
@ -514,7 +506,7 @@ impl Device {
|
|||
#[inline]
|
||||
pub unsafe fn get_device_image_sparse_memory_requirements(
|
||||
&self,
|
||||
memory_requirements: &vk::DeviceImageMemoryRequirements,
|
||||
create_info: &vk::DeviceImageMemoryRequirements,
|
||||
out: &mut [vk::SparseImageMemoryRequirements2],
|
||||
) {
|
||||
let mut count = out.len() as u32;
|
||||
|
@ -522,7 +514,7 @@ impl Device {
|
|||
.device_fn_1_3
|
||||
.get_device_image_sparse_memory_requirements)(
|
||||
self.handle,
|
||||
memory_requirements,
|
||||
create_info,
|
||||
&mut count,
|
||||
out.as_mut_ptr(),
|
||||
);
|
||||
|
@ -854,14 +846,6 @@ impl Device {
|
|||
(self.device_fn_1_1.trim_command_pool)(self.handle(), command_pool, flags);
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetDeviceQueue2.html>
|
||||
#[inline]
|
||||
pub unsafe fn get_device_queue2(&self, queue_info: &vk::DeviceQueueInfo2) -> vk::Queue {
|
||||
let mut queue = mem::zeroed();
|
||||
(self.device_fn_1_1.get_device_queue2)(self.handle(), queue_info, &mut queue);
|
||||
queue
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCreateSamplerYcbcrConversion.html>
|
||||
#[inline]
|
||||
pub unsafe fn create_sampler_ycbcr_conversion(
|
||||
|
@ -1515,17 +1499,17 @@ impl Device {
|
|||
#[inline]
|
||||
pub unsafe fn allocate_descriptor_sets(
|
||||
&self,
|
||||
allocate_info: &vk::DescriptorSetAllocateInfo,
|
||||
create_info: &vk::DescriptorSetAllocateInfo,
|
||||
) -> VkResult<Vec<vk::DescriptorSet>> {
|
||||
let mut desc_set = Vec::with_capacity(allocate_info.descriptor_set_count as usize);
|
||||
let mut desc_set = Vec::with_capacity(create_info.descriptor_set_count as usize);
|
||||
(self.device_fn_1_0.allocate_descriptor_sets)(
|
||||
self.handle(),
|
||||
allocate_info,
|
||||
create_info,
|
||||
desc_set.as_mut_ptr(),
|
||||
)
|
||||
.result()?;
|
||||
|
||||
desc_set.set_len(allocate_info.descriptor_set_count as usize);
|
||||
desc_set.set_len(create_info.descriptor_set_count as usize);
|
||||
Ok(desc_set)
|
||||
}
|
||||
|
||||
|
@ -1802,10 +1786,10 @@ impl Device {
|
|||
pub unsafe fn cmd_begin_render_pass(
|
||||
&self,
|
||||
command_buffer: vk::CommandBuffer,
|
||||
render_pass_begin: &vk::RenderPassBeginInfo,
|
||||
create_info: &vk::RenderPassBeginInfo,
|
||||
contents: vk::SubpassContents,
|
||||
) {
|
||||
(self.device_fn_1_0.cmd_begin_render_pass)(command_buffer, render_pass_begin, contents);
|
||||
(self.device_fn_1_0.cmd_begin_render_pass)(command_buffer, create_info, contents);
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdNextSubpass.html>
|
||||
|
@ -2504,16 +2488,16 @@ impl Device {
|
|||
#[inline]
|
||||
pub unsafe fn allocate_command_buffers(
|
||||
&self,
|
||||
allocate_info: &vk::CommandBufferAllocateInfo,
|
||||
create_info: &vk::CommandBufferAllocateInfo,
|
||||
) -> VkResult<Vec<vk::CommandBuffer>> {
|
||||
let mut buffers = Vec::with_capacity(allocate_info.command_buffer_count as usize);
|
||||
let mut buffers = Vec::with_capacity(create_info.command_buffer_count as usize);
|
||||
(self.device_fn_1_0.allocate_command_buffers)(
|
||||
self.handle(),
|
||||
allocate_info,
|
||||
create_info,
|
||||
buffers.as_mut_ptr(),
|
||||
)
|
||||
.result()?;
|
||||
buffers.set_len(allocate_info.command_buffer_count as usize);
|
||||
buffers.set_len(create_info.command_buffer_count as usize);
|
||||
Ok(buffers)
|
||||
}
|
||||
|
||||
|
@ -2608,13 +2592,13 @@ impl Device {
|
|||
#[inline]
|
||||
pub unsafe fn allocate_memory(
|
||||
&self,
|
||||
allocate_info: &vk::MemoryAllocateInfo,
|
||||
create_info: &vk::MemoryAllocateInfo,
|
||||
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
||||
) -> VkResult<vk::DeviceMemory> {
|
||||
let mut memory = mem::zeroed();
|
||||
(self.device_fn_1_0.allocate_memory)(
|
||||
self.handle(),
|
||||
allocate_info,
|
||||
create_info,
|
||||
allocation_callbacks.as_raw_ptr(),
|
||||
&mut memory,
|
||||
)
|
||||
|
|
|
@ -37,15 +37,9 @@ impl Entry {
|
|||
/// development packages installed (e.g. the Vulkan SDK, or Ubuntu's `libvulkan-dev`).
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// `dlopen`ing native libraries is inherently unsafe. The safety guidelines
|
||||
/// for [`Library::new()`] and [`Library::get()`] apply here.
|
||||
///
|
||||
/// No Vulkan functions loaded directly or indirectly from this [`Entry`]
|
||||
/// may be called after it is [dropped][drop()].
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```no_run
|
||||
/// use ash::{vk, Entry};
|
||||
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
@ -92,11 +86,6 @@ impl Entry {
|
|||
/// Note that instance/device functions are still fetched via `vkGetInstanceProcAddr` and
|
||||
/// `vkGetDeviceProcAddr` for maximum performance.
|
||||
///
|
||||
/// Any Vulkan function acquired directly or indirectly from this [`Entry`] may be called after it
|
||||
/// is [dropped][drop()].
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```no_run
|
||||
/// use ash::{vk, Entry};
|
||||
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
@ -127,12 +116,8 @@ impl Entry {
|
|||
/// Load Vulkan library at `path`
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// `dlopen`ing native libraries is inherently unsafe. The safety guidelines
|
||||
/// for [`Library::new()`] and [`Library::get()`] apply here.
|
||||
///
|
||||
/// No Vulkan functions loaded directly or indirectly from this [`Entry`]
|
||||
/// may be called after it is [dropped][drop()].
|
||||
#[cfg(feature = "loaded")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "loaded")))]
|
||||
pub unsafe fn load_from(path: impl AsRef<OsStr>) -> Result<Self, LoadingError> {
|
||||
|
@ -155,9 +140,8 @@ impl Entry {
|
|||
/// Load entry points based on an already-loaded [`vk::StaticFn`]
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// `static_fn` must contain valid function pointers that comply with the semantics specified
|
||||
/// by Vulkan 1.0, which must remain valid for at least the lifetime of the returned [`Entry`].
|
||||
/// `static_fn` must contain valid function pointers that comply with the semantics specified by
|
||||
/// Vulkan 1.0, which must remain valid for at least the lifetime of the returned [`Entry`].
|
||||
pub unsafe fn from_static_fn(static_fn: vk::StaticFn) -> Self {
|
||||
let load_fn = |name: &std::ffi::CStr| {
|
||||
mem::transmute((static_fn.get_instance_proc_addr)(
|
||||
|
@ -192,9 +176,6 @@ impl Entry {
|
|||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkEnumerateInstanceVersion.html>
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```no_run
|
||||
/// # use ash::{Entry, vk};
|
||||
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
@ -236,13 +217,9 @@ impl Entry {
|
|||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCreateInstance.html>
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// The resulting [`Instance`] and any function-pointer objects (e.g. [`Device`][crate::Device]
|
||||
/// and [extensions][crate::extensions]) loaded from it may not be used after this [`Entry`]
|
||||
/// object is dropped, unless it was crated using [`Entry::linked()`].
|
||||
///
|
||||
/// [`Instance`] does _not_ implement [drop][drop()] semantics and can only be destroyed via
|
||||
/// [`destroy_instance()`][Instance::destroy_instance()].
|
||||
/// In order for the created [`Instance`] to be valid for the duration of its
|
||||
/// usage, the [`Entry`](Self) this was called on must be dropped later than the
|
||||
/// resulting [`Instance`].
|
||||
#[inline]
|
||||
pub unsafe fn create_instance(
|
||||
&self,
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
use crate::prelude::*;
|
||||
use crate::vk;
|
||||
use crate::{Device, Entry, Instance};
|
||||
use crate::{Device, Instance};
|
||||
use std::ffi::CStr;
|
||||
use std::mem;
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_EXT_full_screen_exclusive.html>
|
||||
#[derive(Clone)]
|
||||
pub struct FullScreenExclusive {
|
||||
handle: vk::Device,
|
||||
|
@ -12,13 +11,6 @@ pub struct FullScreenExclusive {
|
|||
}
|
||||
|
||||
impl FullScreenExclusive {
|
||||
/// # Warning
|
||||
/// [`Instance`] functions cannot be loaded from a [`Device`] and will always panic when called:
|
||||
/// - [`Self::get_physical_device_surface_present_modes2()`]
|
||||
///
|
||||
/// Load this struct using an [`Instance`] instead via [`Self::new_from_instance()`] if the
|
||||
/// above [`Instance`] function is called. This will be solved in the next breaking `ash`
|
||||
/// release: <https://github.com/ash-rs/ash/issues/727>.
|
||||
pub fn new(instance: &Instance, device: &Device) -> Self {
|
||||
let handle = device.handle();
|
||||
let fp = vk::ExtFullScreenExclusiveFn::load(|name| unsafe {
|
||||
|
@ -27,19 +19,6 @@ impl FullScreenExclusive {
|
|||
Self { handle, fp }
|
||||
}
|
||||
|
||||
/// Loads all functions on the [`Instance`] instead of [`Device`]. This incurs an extra
|
||||
/// dispatch table for [`Device`] functions but also allows the [`Instance`] function to be
|
||||
/// loaded instead of always panicking. See also [`Self::new()`] for more details.
|
||||
///
|
||||
/// It is okay to pass [`vk::Device::null()`] when this struct is only used to call the
|
||||
/// [`Instance`] function.
|
||||
pub fn new_from_instance(entry: &Entry, instance: &Instance, device: vk::Device) -> Self {
|
||||
let fp = vk::ExtFullScreenExclusiveFn::load(|name| unsafe {
|
||||
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))
|
||||
});
|
||||
Self { handle: device, fp }
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkAcquireFullScreenExclusiveModeEXT.html>
|
||||
#[inline]
|
||||
pub unsafe fn acquire_full_screen_exclusive_mode(
|
||||
|
@ -50,10 +29,6 @@ impl FullScreenExclusive {
|
|||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceSurfacePresentModes2EXT.html>
|
||||
///
|
||||
/// # Warning
|
||||
///
|
||||
/// Function will always panic unless this struct is loaded via [`Self::new_from_instance()`].
|
||||
#[inline]
|
||||
pub unsafe fn get_physical_device_surface_present_modes2(
|
||||
&self,
|
||||
|
|
|
@ -17,10 +17,8 @@ pub use self::image_drm_format_modifier::ImageDrmFormatModifier;
|
|||
pub use self::mesh_shader::MeshShader;
|
||||
pub use self::metal_surface::MetalSurface;
|
||||
pub use self::physical_device_drm::PhysicalDeviceDrm;
|
||||
pub use self::pipeline_properties::PipelineProperties;
|
||||
pub use self::private_data::PrivateData;
|
||||
pub use self::sample_locations::SampleLocations;
|
||||
pub use self::shader_object::ShaderObject;
|
||||
pub use self::tooling_info::ToolingInfo;
|
||||
|
||||
mod acquire_drm_display;
|
||||
|
@ -42,8 +40,6 @@ mod image_drm_format_modifier;
|
|||
mod mesh_shader;
|
||||
mod metal_surface;
|
||||
mod physical_device_drm;
|
||||
mod pipeline_properties;
|
||||
mod private_data;
|
||||
mod sample_locations;
|
||||
mod shader_object;
|
||||
mod tooling_info;
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
use crate::prelude::*;
|
||||
use crate::vk;
|
||||
use crate::{Device, Instance};
|
||||
use std::ffi::CStr;
|
||||
use std::mem;
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_EXT_pipeline_properties.html>
|
||||
#[derive(Clone)]
|
||||
pub struct PipelineProperties {
|
||||
handle: vk::Device,
|
||||
fp: vk::ExtPipelinePropertiesFn,
|
||||
}
|
||||
|
||||
impl PipelineProperties {
|
||||
pub fn new(instance: &Instance, device: &Device) -> Self {
|
||||
let handle = device.handle();
|
||||
let fp = vk::ExtPipelinePropertiesFn::load(|name| unsafe {
|
||||
mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr()))
|
||||
});
|
||||
Self { handle, fp }
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPipelinePropertiesEXT.html>
|
||||
#[inline]
|
||||
pub unsafe fn get_pipeline_properties(
|
||||
&self,
|
||||
pipeline_info: &vk::PipelineInfoEXT,
|
||||
pipeline_properties: &mut impl vk::GetPipelinePropertiesEXTParamPipelineProperties,
|
||||
) -> VkResult<()> {
|
||||
(self.fp.get_pipeline_properties_ext)(
|
||||
self.handle,
|
||||
pipeline_info,
|
||||
<*mut _>::cast(pipeline_properties),
|
||||
)
|
||||
.result()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub const fn name() -> &'static CStr {
|
||||
vk::ExtPipelinePropertiesFn::name()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn fp(&self) -> &vk::ExtPipelinePropertiesFn {
|
||||
&self.fp
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn device(&self) -> vk::Device {
|
||||
self.handle
|
||||
}
|
||||
}
|
|
@ -1,719 +0,0 @@
|
|||
use crate::prelude::*;
|
||||
use crate::vk;
|
||||
use crate::RawPtr;
|
||||
use crate::{Device, Instance};
|
||||
use std::ffi::CStr;
|
||||
use std::mem;
|
||||
use std::ptr;
|
||||
|
||||
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_EXT_shader_object.html>
|
||||
#[derive(Clone)]
|
||||
pub struct ShaderObject {
|
||||
handle: vk::Device,
|
||||
fp: vk::ExtShaderObjectFn,
|
||||
}
|
||||
|
||||
impl ShaderObject {
|
||||
pub fn new(instance: &Instance, device: &Device) -> Self {
|
||||
let handle = device.handle();
|
||||
let fp = vk::ExtShaderObjectFn::load(|name| unsafe {
|
||||
mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr()))
|
||||
});
|
||||
Self { handle, fp }
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCreateShadersEXT.html>
|
||||
#[inline]
|
||||
pub unsafe fn create_shaders(
|
||||
&self,
|
||||
create_infos: &[vk::ShaderCreateInfoEXT],
|
||||
allocator: Option<&vk::AllocationCallbacks>,
|
||||
) -> VkResult<Vec<vk::ShaderEXT>> {
|
||||
let mut shaders = Vec::with_capacity(create_infos.len());
|
||||
(self.fp.create_shaders_ext)(
|
||||
self.handle,
|
||||
create_infos.len() as u32,
|
||||
create_infos.as_ptr(),
|
||||
allocator.as_raw_ptr(),
|
||||
shaders.as_mut_ptr(),
|
||||
)
|
||||
.result()?;
|
||||
shaders.set_len(create_infos.len());
|
||||
Ok(shaders)
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkDestroyShaderEXT.html>
|
||||
#[inline]
|
||||
pub unsafe fn destroy_shader(
|
||||
&self,
|
||||
shader: vk::ShaderEXT,
|
||||
allocator: Option<&vk::AllocationCallbacks>,
|
||||
) {
|
||||
(self.fp.destroy_shader_ext)(self.handle, shader, allocator.as_raw_ptr())
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetShaderBinaryDataEXT.html>
|
||||
#[inline]
|
||||
pub unsafe fn get_shader_binary_data(&self, shader: vk::ShaderEXT) -> VkResult<Vec<u8>> {
|
||||
read_into_uninitialized_vector(|count, data: *mut u8| {
|
||||
(self.fp.get_shader_binary_data_ext)(self.handle, shader, count, data.cast())
|
||||
})
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdBindShadersEXT.html>
|
||||
#[inline]
|
||||
pub unsafe fn cmd_bind_shaders(
|
||||
&self,
|
||||
command_buffer: vk::CommandBuffer,
|
||||
stages: &[vk::ShaderStageFlags],
|
||||
shaders: &[vk::ShaderEXT],
|
||||
) {
|
||||
assert_eq!(stages.len(), shaders.len());
|
||||
(self.fp.cmd_bind_shaders_ext)(
|
||||
command_buffer,
|
||||
stages.len() as u32,
|
||||
stages.as_ptr(),
|
||||
shaders.as_ptr(),
|
||||
)
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetVertexInputEXT.html>
|
||||
#[inline]
|
||||
pub unsafe fn cmd_set_vertex_input(
|
||||
&self,
|
||||
command_buffer: vk::CommandBuffer,
|
||||
vertex_binding_descriptions: &[vk::VertexInputBindingDescription2EXT],
|
||||
vertex_attribute_descriptions: &[vk::VertexInputAttributeDescription2EXT],
|
||||
) {
|
||||
(self.fp.cmd_set_vertex_input_ext)(
|
||||
command_buffer,
|
||||
vertex_binding_descriptions.len() as u32,
|
||||
vertex_binding_descriptions.as_ptr(),
|
||||
vertex_attribute_descriptions.len() as u32,
|
||||
vertex_attribute_descriptions.as_ptr(),
|
||||
)
|
||||
}
|
||||
|
||||
// --- extended_dynamic_state functions ---
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetCullModeEXT.html>
|
||||
#[inline]
|
||||
pub unsafe fn cmd_set_cull_mode(
|
||||
&self,
|
||||
command_buffer: vk::CommandBuffer,
|
||||
cull_mode: vk::CullModeFlags,
|
||||
) {
|
||||
(self.fp.cmd_set_cull_mode_ext)(command_buffer, cull_mode)
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetFrontFaceEXT.html>
|
||||
#[inline]
|
||||
pub unsafe fn cmd_set_front_face(
|
||||
&self,
|
||||
command_buffer: vk::CommandBuffer,
|
||||
front_face: vk::FrontFace,
|
||||
) {
|
||||
(self.fp.cmd_set_front_face_ext)(command_buffer, front_face)
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetPrimitiveTopologyEXT.html>
|
||||
#[inline]
|
||||
pub unsafe fn cmd_set_primitive_topology(
|
||||
&self,
|
||||
command_buffer: vk::CommandBuffer,
|
||||
primitive_topology: vk::PrimitiveTopology,
|
||||
) {
|
||||
(self.fp.cmd_set_primitive_topology_ext)(command_buffer, primitive_topology)
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetViewportWithCountEXT.html>
|
||||
#[inline]
|
||||
pub unsafe fn cmd_set_viewport_with_count(
|
||||
&self,
|
||||
command_buffer: vk::CommandBuffer,
|
||||
viewports: &[vk::Viewport],
|
||||
) {
|
||||
(self.fp.cmd_set_viewport_with_count_ext)(
|
||||
command_buffer,
|
||||
viewports.len() as u32,
|
||||
viewports.as_ptr(),
|
||||
)
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetScissorWithCountEXT.html>
|
||||
#[inline]
|
||||
pub unsafe fn cmd_set_scissor_with_count(
|
||||
&self,
|
||||
command_buffer: vk::CommandBuffer,
|
||||
scissors: &[vk::Rect2D],
|
||||
) {
|
||||
(self.fp.cmd_set_scissor_with_count_ext)(
|
||||
command_buffer,
|
||||
scissors.len() as u32,
|
||||
scissors.as_ptr(),
|
||||
)
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdBindVertexBuffers2EXT.html>
|
||||
#[inline]
|
||||
pub unsafe fn cmd_bind_vertex_buffers2(
|
||||
&self,
|
||||
command_buffer: vk::CommandBuffer,
|
||||
first_binding: u32,
|
||||
buffers: &[vk::Buffer],
|
||||
offsets: &[vk::DeviceSize],
|
||||
sizes: Option<&[vk::DeviceSize]>,
|
||||
strides: Option<&[vk::DeviceSize]>,
|
||||
) {
|
||||
assert_eq!(offsets.len(), buffers.len());
|
||||
let p_sizes = if let Some(sizes) = sizes {
|
||||
assert_eq!(sizes.len(), buffers.len());
|
||||
sizes.as_ptr()
|
||||
} else {
|
||||
ptr::null()
|
||||
};
|
||||
let p_strides = if let Some(strides) = strides {
|
||||
assert_eq!(strides.len(), buffers.len());
|
||||
strides.as_ptr()
|
||||
} else {
|
||||
ptr::null()
|
||||
};
|
||||
(self.fp.cmd_bind_vertex_buffers2_ext)(
|
||||
command_buffer,
|
||||
first_binding,
|
||||
buffers.len() as u32,
|
||||
buffers.as_ptr(),
|
||||
offsets.as_ptr(),
|
||||
p_sizes,
|
||||
p_strides,
|
||||
)
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetDepthTestEnableEXT.html>
|
||||
#[inline]
|
||||
pub unsafe fn cmd_set_depth_test_enable(
|
||||
&self,
|
||||
command_buffer: vk::CommandBuffer,
|
||||
depth_test_enable: bool,
|
||||
) {
|
||||
(self.fp.cmd_set_depth_test_enable_ext)(command_buffer, depth_test_enable.into())
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetDepthWriteEnableEXT.html>
|
||||
#[inline]
|
||||
pub unsafe fn cmd_set_depth_write_enable(
|
||||
&self,
|
||||
command_buffer: vk::CommandBuffer,
|
||||
depth_write_enable: bool,
|
||||
) {
|
||||
(self.fp.cmd_set_depth_write_enable_ext)(command_buffer, depth_write_enable.into())
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetDepthCompareOpEXT.html>
|
||||
#[inline]
|
||||
pub unsafe fn cmd_set_depth_compare_op(
|
||||
&self,
|
||||
command_buffer: vk::CommandBuffer,
|
||||
depth_compare_op: vk::CompareOp,
|
||||
) {
|
||||
(self.fp.cmd_set_depth_compare_op_ext)(command_buffer, depth_compare_op)
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetDepthBoundsTestEnableEXT.html>
|
||||
#[inline]
|
||||
pub unsafe fn cmd_set_depth_bounds_test_enable(
|
||||
&self,
|
||||
command_buffer: vk::CommandBuffer,
|
||||
depth_bounds_test_enable: bool,
|
||||
) {
|
||||
(self.fp.cmd_set_depth_bounds_test_enable_ext)(
|
||||
command_buffer,
|
||||
depth_bounds_test_enable.into(),
|
||||
)
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetStencilTestEnableEXT.html>
|
||||
#[inline]
|
||||
pub unsafe fn cmd_set_stencil_test_enable(
|
||||
&self,
|
||||
command_buffer: vk::CommandBuffer,
|
||||
stencil_test_enable: bool,
|
||||
) {
|
||||
(self.fp.cmd_set_stencil_test_enable_ext)(command_buffer, stencil_test_enable.into())
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetStencilOpEXT.html>
|
||||
#[inline]
|
||||
pub unsafe fn cmd_set_stencil_op(
|
||||
&self,
|
||||
command_buffer: vk::CommandBuffer,
|
||||
face_mask: vk::StencilFaceFlags,
|
||||
fail_op: vk::StencilOp,
|
||||
pass_op: vk::StencilOp,
|
||||
depth_fail_op: vk::StencilOp,
|
||||
compare_op: vk::CompareOp,
|
||||
) {
|
||||
(self.fp.cmd_set_stencil_op_ext)(
|
||||
command_buffer,
|
||||
face_mask,
|
||||
fail_op,
|
||||
pass_op,
|
||||
depth_fail_op,
|
||||
compare_op,
|
||||
)
|
||||
}
|
||||
|
||||
// --- extended_dynamic_state2 functions ---
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetPatchControlPointsEXT.html>
|
||||
#[inline]
|
||||
pub unsafe fn cmd_set_patch_control_points(
|
||||
&self,
|
||||
command_buffer: vk::CommandBuffer,
|
||||
patch_control_points: u32,
|
||||
) {
|
||||
(self.fp.cmd_set_patch_control_points_ext)(command_buffer, patch_control_points)
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetRasterizerDiscardEnableEXT.html>
|
||||
#[inline]
|
||||
pub unsafe fn cmd_set_rasterizer_discard_enable(
|
||||
&self,
|
||||
command_buffer: vk::CommandBuffer,
|
||||
rasterizer_discard_enable: bool,
|
||||
) {
|
||||
(self.fp.cmd_set_rasterizer_discard_enable_ext)(
|
||||
command_buffer,
|
||||
rasterizer_discard_enable.into(),
|
||||
)
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetDepthBiasEnableEXT.html>
|
||||
#[inline]
|
||||
pub unsafe fn cmd_set_depth_bias_enable(
|
||||
&self,
|
||||
command_buffer: vk::CommandBuffer,
|
||||
depth_bias_enable: bool,
|
||||
) {
|
||||
(self.fp.cmd_set_depth_bias_enable_ext)(command_buffer, depth_bias_enable.into())
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetLogicOpEXT.html>
|
||||
#[inline]
|
||||
pub unsafe fn cmd_set_logic_op(
|
||||
&self,
|
||||
command_buffer: vk::CommandBuffer,
|
||||
logic_op: vk::LogicOp,
|
||||
) {
|
||||
(self.fp.cmd_set_logic_op_ext)(command_buffer, logic_op)
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetPrimitiveRestartEnableEXT.html>
|
||||
#[inline]
|
||||
pub unsafe fn cmd_set_primitive_restart_enable(
|
||||
&self,
|
||||
command_buffer: vk::CommandBuffer,
|
||||
primitive_restart_enable: bool,
|
||||
) {
|
||||
(self.fp.cmd_set_primitive_restart_enable_ext)(
|
||||
command_buffer,
|
||||
primitive_restart_enable.into(),
|
||||
)
|
||||
}
|
||||
|
||||
// --- extended_dynamic_state3 functions ---
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetTessellationDomainOriginEXT.html>
|
||||
#[inline]
|
||||
pub unsafe fn cmd_set_tessellation_domain_origin(
|
||||
&self,
|
||||
command_buffer: vk::CommandBuffer,
|
||||
domain_origin: vk::TessellationDomainOrigin,
|
||||
) {
|
||||
(self.fp.cmd_set_tessellation_domain_origin_ext)(command_buffer, domain_origin)
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetDepthClampEnableEXT.html>
|
||||
#[inline]
|
||||
pub unsafe fn cmd_set_depth_clamp_enable(
|
||||
&self,
|
||||
command_buffer: vk::CommandBuffer,
|
||||
depth_clamp_enable: bool,
|
||||
) {
|
||||
(self.fp.cmd_set_depth_clamp_enable_ext)(command_buffer, depth_clamp_enable.into())
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetPolygonModeEXT.html>
|
||||
#[inline]
|
||||
pub unsafe fn cmd_set_polygon_mode(
|
||||
&self,
|
||||
command_buffer: vk::CommandBuffer,
|
||||
polygon_mode: vk::PolygonMode,
|
||||
) {
|
||||
(self.fp.cmd_set_polygon_mode_ext)(command_buffer, polygon_mode)
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetRasterizationSamplesEXT.html>
|
||||
#[inline]
|
||||
pub unsafe fn cmd_set_rasterization_samples(
|
||||
&self,
|
||||
command_buffer: vk::CommandBuffer,
|
||||
rasterization_samples: vk::SampleCountFlags,
|
||||
) {
|
||||
(self.fp.cmd_set_rasterization_samples_ext)(command_buffer, rasterization_samples)
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetSampleMaskEXT.html>
|
||||
#[inline]
|
||||
pub unsafe fn cmd_set_sample_mask(
|
||||
&self,
|
||||
command_buffer: vk::CommandBuffer,
|
||||
samples: vk::SampleCountFlags,
|
||||
sample_mask: &[vk::SampleMask],
|
||||
) {
|
||||
assert!(
|
||||
samples.as_raw().is_power_of_two(),
|
||||
"Only one SampleCount bit must be set"
|
||||
);
|
||||
assert_eq!(samples.as_raw() as usize / 32, sample_mask.len());
|
||||
(self.fp.cmd_set_sample_mask_ext)(command_buffer, samples, sample_mask.as_ptr())
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetAlphaToCoverageEnableEXT.html>
|
||||
#[inline]
|
||||
pub unsafe fn cmd_set_alpha_to_coverage_enable(
|
||||
&self,
|
||||
command_buffer: vk::CommandBuffer,
|
||||
alpha_to_coverage_enable: bool,
|
||||
) {
|
||||
(self.fp.cmd_set_alpha_to_coverage_enable_ext)(
|
||||
command_buffer,
|
||||
alpha_to_coverage_enable.into(),
|
||||
)
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetAlphaToOneEnableEXT.html>
|
||||
#[inline]
|
||||
pub unsafe fn cmd_set_alpha_to_one_enable(
|
||||
&self,
|
||||
command_buffer: vk::CommandBuffer,
|
||||
alpha_to_one_enable: bool,
|
||||
) {
|
||||
(self.fp.cmd_set_alpha_to_one_enable_ext)(command_buffer, alpha_to_one_enable.into())
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetLogicOpEnableEXT.html>
|
||||
#[inline]
|
||||
pub unsafe fn cmd_set_logic_op_enable(
|
||||
&self,
|
||||
command_buffer: vk::CommandBuffer,
|
||||
logic_op_enable: bool,
|
||||
) {
|
||||
(self.fp.cmd_set_logic_op_enable_ext)(command_buffer, logic_op_enable.into())
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetColorBlendEnableEXT.html>
|
||||
#[inline]
|
||||
pub unsafe fn cmd_set_color_blend_enable(
|
||||
&self,
|
||||
command_buffer: vk::CommandBuffer,
|
||||
first_attachment: u32,
|
||||
color_blend_enables: &[vk::Bool32],
|
||||
) {
|
||||
(self.fp.cmd_set_color_blend_enable_ext)(
|
||||
command_buffer,
|
||||
first_attachment,
|
||||
color_blend_enables.len() as u32,
|
||||
color_blend_enables.as_ptr(),
|
||||
)
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetColorBlendEquationEXT.html>
|
||||
#[inline]
|
||||
pub unsafe fn cmd_set_color_blend_equation(
|
||||
&self,
|
||||
command_buffer: vk::CommandBuffer,
|
||||
first_attachment: u32,
|
||||
color_blend_equations: &[vk::ColorBlendEquationEXT],
|
||||
) {
|
||||
(self.fp.cmd_set_color_blend_equation_ext)(
|
||||
command_buffer,
|
||||
first_attachment,
|
||||
color_blend_equations.len() as u32,
|
||||
color_blend_equations.as_ptr(),
|
||||
)
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetColorWriteMaskEXT.html>
|
||||
#[inline]
|
||||
pub unsafe fn cmd_set_color_write_mask(
|
||||
&self,
|
||||
command_buffer: vk::CommandBuffer,
|
||||
first_attachment: u32,
|
||||
color_write_masks: &[vk::ColorComponentFlags],
|
||||
) {
|
||||
(self.fp.cmd_set_color_write_mask_ext)(
|
||||
command_buffer,
|
||||
first_attachment,
|
||||
color_write_masks.len() as u32,
|
||||
color_write_masks.as_ptr(),
|
||||
)
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetRasterizationStreamEXT.html>
|
||||
#[inline]
|
||||
pub unsafe fn cmd_set_rasterization_stream(
|
||||
&self,
|
||||
command_buffer: vk::CommandBuffer,
|
||||
rasterization_stream: u32,
|
||||
) {
|
||||
(self.fp.cmd_set_rasterization_stream_ext)(command_buffer, rasterization_stream)
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetConservativeRasterizationModeEXT.html>
|
||||
#[inline]
|
||||
pub unsafe fn cmd_set_conservative_rasterization_mode(
|
||||
&self,
|
||||
command_buffer: vk::CommandBuffer,
|
||||
conservative_rasterization_mode: vk::ConservativeRasterizationModeEXT,
|
||||
) {
|
||||
(self.fp.cmd_set_conservative_rasterization_mode_ext)(
|
||||
command_buffer,
|
||||
conservative_rasterization_mode,
|
||||
)
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetExtraPrimitiveOverestimationSizeEXT.html>
|
||||
#[inline]
|
||||
pub unsafe fn cmd_set_extra_primitive_overestimation_size(
|
||||
&self,
|
||||
command_buffer: vk::CommandBuffer,
|
||||
extra_primitive_overestimation_size: f32,
|
||||
) {
|
||||
(self.fp.cmd_set_extra_primitive_overestimation_size_ext)(
|
||||
command_buffer,
|
||||
extra_primitive_overestimation_size,
|
||||
)
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetDepthClipEnableEXT.html>
|
||||
#[inline]
|
||||
pub unsafe fn cmd_set_depth_clip_enable(
|
||||
&self,
|
||||
command_buffer: vk::CommandBuffer,
|
||||
depth_clip_enable: bool,
|
||||
) {
|
||||
(self.fp.cmd_set_depth_clip_enable_ext)(command_buffer, depth_clip_enable.into())
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetSampleLocationsEnableEXT.html>
|
||||
#[inline]
|
||||
pub unsafe fn cmd_set_sample_locations_enable(
|
||||
&self,
|
||||
command_buffer: vk::CommandBuffer,
|
||||
sample_locations_enable: bool,
|
||||
) {
|
||||
(self.fp.cmd_set_sample_locations_enable_ext)(
|
||||
command_buffer,
|
||||
sample_locations_enable.into(),
|
||||
)
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetColorBlendAdvancedEXT.html>
|
||||
#[inline]
|
||||
pub unsafe fn cmd_set_color_blend_advanced(
|
||||
&self,
|
||||
command_buffer: vk::CommandBuffer,
|
||||
first_attachment: u32,
|
||||
color_blend_advanced: &[vk::ColorBlendAdvancedEXT],
|
||||
) {
|
||||
(self.fp.cmd_set_color_blend_advanced_ext)(
|
||||
command_buffer,
|
||||
first_attachment,
|
||||
color_blend_advanced.len() as u32,
|
||||
color_blend_advanced.as_ptr(),
|
||||
)
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetProvokingVertexModeEXT.html>
|
||||
#[inline]
|
||||
pub unsafe fn cmd_set_provoking_vertex_mode(
|
||||
&self,
|
||||
command_buffer: vk::CommandBuffer,
|
||||
provoking_vertex_mode: vk::ProvokingVertexModeEXT,
|
||||
) {
|
||||
(self.fp.cmd_set_provoking_vertex_mode_ext)(command_buffer, provoking_vertex_mode)
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetLineRasterizationModeEXT.html>
|
||||
#[inline]
|
||||
pub unsafe fn cmd_set_line_rasterization_mode(
|
||||
&self,
|
||||
command_buffer: vk::CommandBuffer,
|
||||
line_rasterization_mode: vk::LineRasterizationModeEXT,
|
||||
) {
|
||||
(self.fp.cmd_set_line_rasterization_mode_ext)(command_buffer, line_rasterization_mode)
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetLineStippleEnableEXT.html>
|
||||
#[inline]
|
||||
pub unsafe fn cmd_set_line_stipple_enable(
|
||||
&self,
|
||||
command_buffer: vk::CommandBuffer,
|
||||
stippled_line_enable: bool,
|
||||
) {
|
||||
(self.fp.cmd_set_line_stipple_enable_ext)(command_buffer, stippled_line_enable.into())
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetDepthClipNegativeOneToOneEXT.html>
|
||||
#[inline]
|
||||
pub unsafe fn cmd_set_depth_clip_negative_one_to_one(
|
||||
&self,
|
||||
command_buffer: vk::CommandBuffer,
|
||||
negative_one_to_one: bool,
|
||||
) {
|
||||
(self.fp.cmd_set_depth_clip_negative_one_to_one_ext)(
|
||||
command_buffer,
|
||||
negative_one_to_one.into(),
|
||||
)
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetViewportWScalingEnableNV.html>
|
||||
#[inline]
|
||||
pub unsafe fn cmd_set_viewport_w_scaling_enable_nv(
|
||||
&self,
|
||||
command_buffer: vk::CommandBuffer,
|
||||
viewport_w_scaling_enable: bool,
|
||||
) {
|
||||
(self.fp.cmd_set_viewport_w_scaling_enable_nv)(
|
||||
command_buffer,
|
||||
viewport_w_scaling_enable.into(),
|
||||
)
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetViewportSwizzleNV.html>
|
||||
#[inline]
|
||||
pub unsafe fn cmd_set_viewport_swizzle_nv(
|
||||
&self,
|
||||
command_buffer: vk::CommandBuffer,
|
||||
first_attachment: u32,
|
||||
viewport_swizzles: &[vk::ViewportSwizzleNV],
|
||||
) {
|
||||
(self.fp.cmd_set_viewport_swizzle_nv)(
|
||||
command_buffer,
|
||||
first_attachment,
|
||||
viewport_swizzles.len() as u32,
|
||||
viewport_swizzles.as_ptr(),
|
||||
)
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetCoverageToColorEnableNV.html>
|
||||
#[inline]
|
||||
pub unsafe fn cmd_set_coverage_to_color_enable_nv(
|
||||
&self,
|
||||
command_buffer: vk::CommandBuffer,
|
||||
coverage_to_color_enable: bool,
|
||||
) {
|
||||
(self.fp.cmd_set_coverage_to_color_enable_nv)(
|
||||
command_buffer,
|
||||
coverage_to_color_enable.into(),
|
||||
)
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetCoverageToColorLocationNV.html>
|
||||
#[inline]
|
||||
pub unsafe fn cmd_set_coverage_to_color_location_nv(
|
||||
&self,
|
||||
command_buffer: vk::CommandBuffer,
|
||||
coverage_to_color_location: u32,
|
||||
) {
|
||||
(self.fp.cmd_set_coverage_to_color_location_nv)(command_buffer, coverage_to_color_location)
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetCoverageModulationModeNV.html>
|
||||
#[inline]
|
||||
pub unsafe fn cmd_set_coverage_modulation_mode_nv(
|
||||
&self,
|
||||
command_buffer: vk::CommandBuffer,
|
||||
coverage_modulation_mode: vk::CoverageModulationModeNV,
|
||||
) {
|
||||
(self.fp.cmd_set_coverage_modulation_mode_nv)(command_buffer, coverage_modulation_mode)
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetCoverageModulationTableEnableNV.html>
|
||||
#[inline]
|
||||
pub unsafe fn cmd_set_coverage_modulation_table_enable_nv(
|
||||
&self,
|
||||
command_buffer: vk::CommandBuffer,
|
||||
coverage_modulation_table_enable: bool,
|
||||
) {
|
||||
(self.fp.cmd_set_coverage_modulation_table_enable_nv)(
|
||||
command_buffer,
|
||||
coverage_modulation_table_enable.into(),
|
||||
)
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetCoverageModulationTableNV.html>
|
||||
#[inline]
|
||||
pub unsafe fn cmd_set_coverage_modulation_table_nv(
|
||||
&self,
|
||||
command_buffer: vk::CommandBuffer,
|
||||
coverage_modulation_table: &[f32],
|
||||
) {
|
||||
(self.fp.cmd_set_coverage_modulation_table_nv)(
|
||||
command_buffer,
|
||||
coverage_modulation_table.len() as u32,
|
||||
coverage_modulation_table.as_ptr(),
|
||||
)
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetShadingRateImageEnableNV.html>
|
||||
#[inline]
|
||||
pub unsafe fn cmd_set_shading_rate_image_enable_nv(
|
||||
&self,
|
||||
command_buffer: vk::CommandBuffer,
|
||||
shading_rate_image_enable: bool,
|
||||
) {
|
||||
(self.fp.cmd_set_shading_rate_image_enable_nv)(
|
||||
command_buffer,
|
||||
shading_rate_image_enable.into(),
|
||||
)
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetRepresentativeFragmentTestEnableNV.html>
|
||||
#[inline]
|
||||
pub unsafe fn cmd_set_representative_fragment_test_enable_nv(
|
||||
&self,
|
||||
command_buffer: vk::CommandBuffer,
|
||||
representative_fragment_test_enable: bool,
|
||||
) {
|
||||
(self.fp.cmd_set_representative_fragment_test_enable_nv)(
|
||||
command_buffer,
|
||||
representative_fragment_test_enable.into(),
|
||||
)
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetCoverageReductionModeNV.html>
|
||||
#[inline]
|
||||
pub unsafe fn cmd_set_coverage_reduction_mode_nv(
|
||||
&self,
|
||||
command_buffer: vk::CommandBuffer,
|
||||
coverage_reduction_mode: vk::CoverageReductionModeNV,
|
||||
) {
|
||||
(self.fp.cmd_set_coverage_reduction_mode_nv)(command_buffer, coverage_reduction_mode)
|
||||
}
|
||||
|
||||
pub const fn name() -> &'static CStr {
|
||||
vk::ExtShaderObjectFn::name()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn fp(&self) -> &vk::ExtShaderObjectFn {
|
||||
&self.fp
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn device(&self) -> vk::Device {
|
||||
self.handle
|
||||
}
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
use super::Swapchain;
|
||||
use crate::prelude::*;
|
||||
use crate::vk;
|
||||
use crate::{Device, Entry, Instance};
|
||||
use crate::{Device, Instance};
|
||||
use std::ffi::CStr;
|
||||
use std::mem;
|
||||
|
||||
|
@ -14,13 +14,6 @@ pub struct DeviceGroup {
|
|||
}
|
||||
|
||||
impl DeviceGroup {
|
||||
/// # Warning
|
||||
/// [`Instance`] functions cannot be loaded from a [`Device`] and will always panic when called:
|
||||
/// - [`Self::get_physical_device_present_rectangles()`]
|
||||
///
|
||||
/// Load this struct using an [`Instance`] instead via [`Self::new_from_instance()`] if the
|
||||
/// above [`Instance`] function is called. This will be solved in the next breaking `ash`
|
||||
/// release: <https://github.com/ash-rs/ash/issues/727>.
|
||||
pub fn new(instance: &Instance, device: &Device) -> Self {
|
||||
let handle = device.handle();
|
||||
let fp = vk::KhrDeviceGroupFn::load(|name| unsafe {
|
||||
|
@ -29,19 +22,6 @@ impl DeviceGroup {
|
|||
Self { handle, fp }
|
||||
}
|
||||
|
||||
/// Loads all functions on the [`Instance`] instead of [`Device`]. This incurs an extra
|
||||
/// dispatch table for [`Device`] functions but also allows the [`Instance`] function to be
|
||||
/// loaded instead of always panicking. See also [`Self::new()`] for more details.
|
||||
///
|
||||
/// It is okay to pass [`vk::Device::null()`] when this struct is only used to call the
|
||||
/// [`Instance`] function.
|
||||
pub fn new_from_instance(entry: &Entry, instance: &Instance, device: vk::Device) -> Self {
|
||||
let fp = vk::KhrDeviceGroupFn::load(|name| unsafe {
|
||||
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))
|
||||
});
|
||||
Self { handle: device, fp }
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetDeviceGroupPeerMemoryFeaturesKHR.html>
|
||||
#[inline]
|
||||
pub unsafe fn get_device_group_peer_memory_features(
|
||||
|
@ -132,10 +112,6 @@ impl DeviceGroup {
|
|||
///
|
||||
/// [Vulkan 1.1]: https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_VERSION_1_1.html
|
||||
/// [`VK_KHR_surface`]: https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_KHR_surface.html
|
||||
///
|
||||
/// # Warning
|
||||
///
|
||||
/// Function will always panic unless this struct is loaded via [`Self::new_from_instance()`].
|
||||
#[inline]
|
||||
pub unsafe fn get_physical_device_present_rectangles(
|
||||
&self,
|
||||
|
|
|
@ -59,14 +59,8 @@ impl DeviceGroupCreation {
|
|||
&self.fp
|
||||
}
|
||||
|
||||
#[deprecated = "typo: this function is called `device()`, but returns an `Instance`."]
|
||||
#[inline]
|
||||
pub fn device(&self) -> vk::Instance {
|
||||
self.handle
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn instance(&self) -> vk::Instance {
|
||||
self.handle
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,9 +21,9 @@ impl ExternalMemoryFd {
|
|||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetMemoryFdKHR.html>
|
||||
#[inline]
|
||||
pub unsafe fn get_memory_fd(&self, get_fd_info: &vk::MemoryGetFdInfoKHR) -> VkResult<i32> {
|
||||
pub unsafe fn get_memory_fd(&self, create_info: &vk::MemoryGetFdInfoKHR) -> VkResult<i32> {
|
||||
let mut fd = -1;
|
||||
(self.fp.get_memory_fd_khr)(self.handle, get_fd_info, &mut fd).result_with_success(fd)
|
||||
(self.fp.get_memory_fd_khr)(self.handle, create_info, &mut fd).result_with_success(fd)
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetMemoryFdPropertiesKHR.html>
|
||||
|
|
|
@ -22,32 +22,32 @@ impl Maintenance4 {
|
|||
#[inline]
|
||||
pub unsafe fn get_device_buffer_memory_requirements(
|
||||
&self,
|
||||
memory_requirements: &vk::DeviceBufferMemoryRequirementsKHR,
|
||||
create_info: &vk::DeviceBufferMemoryRequirementsKHR,
|
||||
out: &mut vk::MemoryRequirements2,
|
||||
) {
|
||||
(self.fp.get_device_buffer_memory_requirements_khr)(self.handle, memory_requirements, out)
|
||||
(self.fp.get_device_buffer_memory_requirements_khr)(self.handle, create_info, out)
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetDeviceImageMemoryRequirementsKHR.html>
|
||||
#[inline]
|
||||
pub unsafe fn get_device_image_memory_requirements(
|
||||
&self,
|
||||
memory_requirements: &vk::DeviceImageMemoryRequirementsKHR,
|
||||
create_info: &vk::DeviceImageMemoryRequirementsKHR,
|
||||
out: &mut vk::MemoryRequirements2,
|
||||
) {
|
||||
(self.fp.get_device_image_memory_requirements_khr)(self.handle, memory_requirements, out)
|
||||
(self.fp.get_device_image_memory_requirements_khr)(self.handle, create_info, out)
|
||||
}
|
||||
|
||||
/// Retrieve the number of elements to pass to [`get_device_image_sparse_memory_requirements()`][Self::get_device_image_sparse_memory_requirements()]
|
||||
#[inline]
|
||||
pub unsafe fn get_device_image_sparse_memory_requirements_len(
|
||||
&self,
|
||||
memory_requirements: &vk::DeviceImageMemoryRequirementsKHR,
|
||||
create_info: &vk::DeviceImageMemoryRequirementsKHR,
|
||||
) -> usize {
|
||||
let mut count = 0;
|
||||
(self.fp.get_device_image_sparse_memory_requirements_khr)(
|
||||
self.handle,
|
||||
memory_requirements,
|
||||
create_info,
|
||||
&mut count,
|
||||
std::ptr::null_mut(),
|
||||
);
|
||||
|
@ -61,13 +61,13 @@ impl Maintenance4 {
|
|||
#[inline]
|
||||
pub unsafe fn get_device_image_sparse_memory_requirements(
|
||||
&self,
|
||||
memory_requirements: &vk::DeviceImageMemoryRequirementsKHR,
|
||||
create_info: &vk::DeviceImageMemoryRequirementsKHR,
|
||||
out: &mut [vk::SparseImageMemoryRequirements2],
|
||||
) {
|
||||
let mut count = out.len() as u32;
|
||||
(self.fp.get_device_image_sparse_memory_requirements_khr)(
|
||||
self.handle,
|
||||
memory_requirements,
|
||||
create_info,
|
||||
&mut count,
|
||||
out.as_mut_ptr(),
|
||||
);
|
||||
|
|
|
@ -22,7 +22,6 @@ pub use self::get_surface_capabilities2::GetSurfaceCapabilities2;
|
|||
pub use self::maintenance1::Maintenance1;
|
||||
pub use self::maintenance3::Maintenance3;
|
||||
pub use self::maintenance4::Maintenance4;
|
||||
pub use self::performance_query::PerformanceQuery;
|
||||
pub use self::pipeline_executable_properties::PipelineExecutableProperties;
|
||||
pub use self::present_wait::PresentWait;
|
||||
pub use self::push_descriptor::PushDescriptor;
|
||||
|
@ -61,7 +60,6 @@ mod get_surface_capabilities2;
|
|||
mod maintenance1;
|
||||
mod maintenance3;
|
||||
mod maintenance4;
|
||||
mod performance_query;
|
||||
mod pipeline_executable_properties;
|
||||
mod present_wait;
|
||||
mod push_descriptor;
|
||||
|
|
|
@ -1,121 +0,0 @@
|
|||
use crate::prelude::*;
|
||||
use crate::vk;
|
||||
use crate::{Entry, Instance};
|
||||
use std::ffi::CStr;
|
||||
use std::mem;
|
||||
use std::ptr;
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_KHR_performance_query.html>
|
||||
#[derive(Clone)]
|
||||
pub struct PerformanceQuery {
|
||||
handle: vk::Instance,
|
||||
fp: vk::KhrPerformanceQueryFn,
|
||||
}
|
||||
|
||||
impl PerformanceQuery {
|
||||
pub fn new(entry: &Entry, instance: &Instance) -> Self {
|
||||
let handle = instance.handle();
|
||||
let fp = vk::KhrPerformanceQueryFn::load(|name| unsafe {
|
||||
mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr()))
|
||||
});
|
||||
Self { handle, fp }
|
||||
}
|
||||
|
||||
/// Retrieve the number of elements to pass to [`enumerate_physical_device_queue_family_performance_query_counters()`][Self::enumerate_physical_device_queue_family_performance_query_counters()]
|
||||
#[inline]
|
||||
pub unsafe fn enumerate_physical_device_queue_family_performance_query_counters_len(
|
||||
&self,
|
||||
physical_device: vk::PhysicalDevice,
|
||||
queue_family_index: u32,
|
||||
) -> VkResult<usize> {
|
||||
let mut count = 0;
|
||||
(self
|
||||
.fp
|
||||
.enumerate_physical_device_queue_family_performance_query_counters_khr)(
|
||||
physical_device,
|
||||
queue_family_index,
|
||||
&mut count,
|
||||
ptr::null_mut(),
|
||||
ptr::null_mut(),
|
||||
)
|
||||
.result_with_success(count as usize)
|
||||
}
|
||||
|
||||
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR.html>
|
||||
///
|
||||
/// Call [`enumerate_physical_device_queue_family_performance_query_counters_len()`][Self::enumerate_physical_device_queue_family_performance_query_counters_len()] to query the number of elements to pass to `out_counters` and `out_counter_descriptions`.
|
||||
/// Be sure to [`Default::default()`]-initialize these elements and optionally set their `p_next` pointer.
|
||||
#[inline]
|
||||
pub unsafe fn enumerate_physical_device_queue_family_performance_query_counters(
|
||||
&self,
|
||||
physical_device: vk::PhysicalDevice,
|
||||
queue_family_index: u32,
|
||||
out_counters: &mut [vk::PerformanceCounterKHR],
|
||||
out_counter_descriptions: &mut [vk::PerformanceCounterDescriptionKHR],
|
||||
) -> VkResult<()> {
|
||||
assert_eq!(out_counters.len(), out_counter_descriptions.len());
|
||||
let mut count = out_counters.len() as u32;
|
||||
(self
|
||||
.fp
|
||||
.enumerate_physical_device_queue_family_performance_query_counters_khr)(
|
||||
physical_device,
|
||||
queue_family_index,
|
||||
&mut count,
|
||||
out_counters.as_mut_ptr(),
|
||||
out_counter_descriptions.as_mut_ptr(),
|
||||
)
|
||||
.result()?;
|
||||
assert_eq!(count as usize, out_counters.len());
|
||||
assert_eq!(count as usize, out_counter_descriptions.len());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR.html>
|
||||
#[inline]
|
||||
pub unsafe fn get_physical_device_queue_family_performance_query_passes(
|
||||
&self,
|
||||
physical_device: vk::PhysicalDevice,
|
||||
performance_query_create_info: &vk::QueryPoolPerformanceCreateInfoKHR,
|
||||
) -> u32 {
|
||||
let mut num_passes = 0;
|
||||
(self
|
||||
.fp
|
||||
.get_physical_device_queue_family_performance_query_passes_khr)(
|
||||
physical_device,
|
||||
performance_query_create_info,
|
||||
&mut num_passes,
|
||||
);
|
||||
num_passes
|
||||
}
|
||||
|
||||
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkAcquireProfilingLockKHR.html>
|
||||
#[inline]
|
||||
pub unsafe fn acquire_profiling_lock(
|
||||
&self,
|
||||
device: vk::Device,
|
||||
info: &vk::AcquireProfilingLockInfoKHR,
|
||||
) -> VkResult<()> {
|
||||
(self.fp.acquire_profiling_lock_khr)(device, info).result()
|
||||
}
|
||||
|
||||
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkReleaseProfilingLockKHR.html>
|
||||
#[inline]
|
||||
pub unsafe fn release_profiling_lock(&self, device: vk::Device) {
|
||||
(self.fp.release_profiling_lock_khr)(device)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub const fn name() -> &'static CStr {
|
||||
vk::KhrPerformanceQueryFn::name()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn fp(&self) -> &vk::KhrPerformanceQueryFn {
|
||||
&self.fp
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn instance(&self) -> vk::Instance {
|
||||
self.handle
|
||||
}
|
||||
}
|
|
@ -3,11 +3,10 @@ use super::DeviceGroup;
|
|||
use crate::prelude::*;
|
||||
use crate::vk;
|
||||
use crate::RawPtr;
|
||||
use crate::{Device, Entry, Instance};
|
||||
use crate::{Device, Instance};
|
||||
use std::ffi::CStr;
|
||||
use std::mem;
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_KHR_swapchain.html>
|
||||
#[derive(Clone)]
|
||||
pub struct Swapchain {
|
||||
handle: vk::Device,
|
||||
|
@ -15,13 +14,6 @@ pub struct Swapchain {
|
|||
}
|
||||
|
||||
impl Swapchain {
|
||||
/// # Warning
|
||||
/// [`Instance`] functions cannot be loaded from a [`Device`] and will always panic when called:
|
||||
/// - [`Self::get_physical_device_present_rectangles()`]
|
||||
///
|
||||
/// Load this struct using an [`Instance`] instead via [`Self::new_from_instance()`] if the
|
||||
/// above [`Instance`] function is called. This will be solved in the next breaking `ash`
|
||||
/// release: <https://github.com/ash-rs/ash/issues/727>.
|
||||
pub fn new(instance: &Instance, device: &Device) -> Self {
|
||||
let handle = device.handle();
|
||||
let fp = vk::KhrSwapchainFn::load(|name| unsafe {
|
||||
|
@ -30,19 +22,6 @@ impl Swapchain {
|
|||
Self { handle, fp }
|
||||
}
|
||||
|
||||
/// Loads all functions on the [`Instance`] instead of [`Device`]. This incurs an extra
|
||||
/// dispatch table for [`Device`] functions but also allows the [`Instance`] function to be
|
||||
/// loaded instead of always panicking. See also [`Self::new()`] for more details.
|
||||
///
|
||||
/// It is okay to pass [`vk::Device::null()`] when this struct is only used to call the
|
||||
/// [`Instance`] function.
|
||||
pub fn new_from_instance(entry: &Entry, instance: &Instance, device: vk::Device) -> Self {
|
||||
let fp = vk::KhrSwapchainFn::load(|name| unsafe {
|
||||
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))
|
||||
});
|
||||
Self { handle: device, fp }
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCreateSwapchainKHR.html>
|
||||
#[inline]
|
||||
pub unsafe fn create_swapchain(
|
||||
|
@ -174,10 +153,6 @@ impl Swapchain {
|
|||
///
|
||||
/// [Vulkan 1.1]: https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_VERSION_1_1.html
|
||||
/// [`VK_KHR_surface`]: https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_KHR_surface.html
|
||||
///
|
||||
/// # Warning
|
||||
///
|
||||
/// Function will always panic unless this struct is loaded via [`Self::new_from_instance()`].
|
||||
#[inline]
|
||||
pub unsafe fn get_physical_device_present_rectangles(
|
||||
&self,
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#[cfg(doc)]
|
||||
use super::Entry;
|
||||
use crate::device::Device;
|
||||
use crate::prelude::*;
|
||||
use crate::vk;
|
||||
|
@ -337,17 +335,9 @@ impl Instance {
|
|||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCreateDevice.html>
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// There is a [parent/child relation] between [`Instance`] and the resulting [`Device`]. The
|
||||
/// application must not [destroy][Instance::destroy_instance()] the parent [`Instance`] object
|
||||
/// before first [destroying][Device::destroy_device()] the returned [`Device`] child object.
|
||||
/// [`Device`] does _not_ implement [drop][drop()] semantics and can only be destroyed via
|
||||
/// [`destroy_device()`][Device::destroy_device()].
|
||||
///
|
||||
/// See the [`Entry::create_instance()`] documentation for more destruction ordering rules on
|
||||
/// [`Instance`].
|
||||
///
|
||||
/// [parent/child relation]: https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#fundamentals-objectmodel-lifetime
|
||||
/// In order for the created [`Device`] to be valid for the duration of its
|
||||
/// usage, the [`Instance`] this was called on must be dropped later than the
|
||||
/// resulting [`Device`].
|
||||
#[inline]
|
||||
pub unsafe fn create_device(
|
||||
&self,
|
||||
|
|
|
@ -26,12 +26,13 @@ impl vk::Result {
|
|||
}
|
||||
}
|
||||
|
||||
/// Repeatedly calls `f` until it does not return [`vk::Result::INCOMPLETE`] anymore, ensuring all
|
||||
/// available data has been read into the vector.
|
||||
/// Repeatedly calls `f` until it does not return [`vk::Result::INCOMPLETE`] anymore,
|
||||
/// ensuring all available data has been read into the vector.
|
||||
///
|
||||
/// See for example [`vkEnumerateInstanceExtensionProperties`]: the number of available items may
|
||||
/// change between calls; [`vk::Result::INCOMPLETE`] is returned when the count increased (and the
|
||||
/// vector is not large enough after querying the initial size), requiring Ash to try again.
|
||||
/// See for example [`vkEnumerateInstanceExtensionProperties`]: the number of available
|
||||
/// items may change between calls; [`vk::Result::INCOMPLETE`] is returned when the count
|
||||
/// increased (and the vector is not large enough after querying the initial size),
|
||||
/// requiring Ash to try again.
|
||||
///
|
||||
/// [`vkEnumerateInstanceExtensionProperties`]: https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkEnumerateInstanceExtensionProperties.html
|
||||
pub(crate) unsafe fn read_into_uninitialized_vector<N: Copy + Default + TryInto<usize>, T>(
|
||||
|
@ -55,17 +56,18 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
/// Repeatedly calls `f` until it does not return [`vk::Result::INCOMPLETE`] anymore, ensuring all
|
||||
/// available data has been read into the vector.
|
||||
/// Repeatedly calls `f` until it does not return [`vk::Result::INCOMPLETE`] anymore,
|
||||
/// ensuring all available data has been read into the vector.
|
||||
///
|
||||
/// Items in the target vector are [`default()`][Default::default()]-initialized which is required
|
||||
/// for [`vk::BaseOutStructure`]-like structs where [`vk::BaseOutStructure::s_type`] needs to be a
|
||||
/// valid type and [`vk::BaseOutStructure::p_next`] a valid or [`null`][std::ptr::null_mut()]
|
||||
/// pointer.
|
||||
/// Items in the target vector are [`default()`][`Default::default()`]-initialized which
|
||||
/// is required for [`vk::BaseOutStructure`]-like structs where [`vk::BaseOutStructure::s_type`]
|
||||
/// needs to be a valid type and [`vk::BaseOutStructure::p_next`] a valid or
|
||||
/// [`null`][`std::ptr::null_mut()`] pointer.
|
||||
///
|
||||
/// See for example [`vkEnumerateInstanceExtensionProperties`]: the number of available items may
|
||||
/// change between calls; [`vk::Result::INCOMPLETE`] is returned when the count increased (and the
|
||||
/// vector is not large enough after querying the initial size), requiring Ash to try again.
|
||||
/// See for example [`vkEnumerateInstanceExtensionProperties`]: the number of available
|
||||
/// items may change between calls; [`vk::Result::INCOMPLETE`] is returned when the count
|
||||
/// increased (and the vector is not large enough after querying the initial size),
|
||||
/// requiring Ash to try again.
|
||||
///
|
||||
/// [`vkEnumerateInstanceExtensionProperties`]: https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkEnumerateInstanceExtensionProperties.html
|
||||
pub(crate) unsafe fn read_into_defaulted_vector<
|
||||
|
@ -114,7 +116,7 @@ pub(crate) fn debug_flags<Value: Into<u64> + Copy>(
|
|||
if !first {
|
||||
f.write_str(" | ")?;
|
||||
}
|
||||
write!(f, "{accum:b}")?;
|
||||
write!(f, "{:b}", accum)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -104,9 +104,7 @@ impl<'a, T: Copy + 'a> Iterator for AlignIter<'a, T> {
|
|||
/// let words = ash::util::read_spv(&mut std::io::Cursor::new(&SPIRV[..])).unwrap();
|
||||
/// ```
|
||||
pub fn read_spv<R: io::Read + io::Seek>(x: &mut R) -> io::Result<Vec<u32>> {
|
||||
// TODO use stream_len() once it is stabilized and remove the subsequent rewind() call
|
||||
let size = x.seek(io::SeekFrom::End(0))?;
|
||||
x.rewind()?;
|
||||
if size % 4 != 0 {
|
||||
return Err(io::Error::new(
|
||||
io::ErrorKind::InvalidData,
|
||||
|
@ -121,6 +119,7 @@ pub fn read_spv<R: io::Read + io::Seek>(x: &mut R) -> io::Result<Vec<u32>> {
|
|||
// Zero-initialize the result to prevent read_exact from possibly
|
||||
// reading uninitialized memory.
|
||||
let mut result = vec![0u32; words];
|
||||
x.seek(io::SeekFrom::Start(0))?;
|
||||
x.read_exact(unsafe {
|
||||
slice::from_raw_parts_mut(result.as_mut_ptr().cast::<u8>(), words * 4)
|
||||
})?;
|
||||
|
|
|
@ -200,8 +200,6 @@ pub type PhysicalDeviceSubgroupSizeControlPropertiesEXT =
|
|||
PhysicalDeviceSubgroupSizeControlProperties;
|
||||
pub type PipelineShaderStageRequiredSubgroupSizeCreateInfoEXT =
|
||||
PipelineShaderStageRequiredSubgroupSizeCreateInfo;
|
||||
pub type ShaderRequiredSubgroupSizeCreateInfoEXT =
|
||||
PipelineShaderStageRequiredSubgroupSizeCreateInfo;
|
||||
pub type MemoryOpaqueCaptureAddressAllocateInfoKHR = MemoryOpaqueCaptureAddressAllocateInfo;
|
||||
pub type DeviceMemoryOpaqueCaptureAddressInfoKHR = DeviceMemoryOpaqueCaptureAddressInfo;
|
||||
pub type PhysicalDevicePipelineCreationCacheControlFeaturesEXT =
|
||||
|
|
|
@ -1280,23 +1280,13 @@ impl VideoEncodeCapabilityFlagsKHR {
|
|||
}
|
||||
#[repr(transparent)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VkVideoEncodeFeedbackFlagBitsKHR.html>"]
|
||||
pub struct VideoEncodeFeedbackFlagsKHR(pub(crate) Flags);
|
||||
vk_bitflags_wrapped!(VideoEncodeFeedbackFlagsKHR, Flags);
|
||||
impl VideoEncodeFeedbackFlagsKHR {
|
||||
pub const BITSTREAM_BUFFER_OFFSET: Self = Self(0b1);
|
||||
pub const BITSTREAM_BYTES_WRITTEN: Self = Self(0b10);
|
||||
}
|
||||
#[repr(transparent)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VkVideoEncodeRateControlModeFlagBitsKHR.html>"]
|
||||
pub struct VideoEncodeRateControlModeFlagsKHR(pub(crate) Flags);
|
||||
vk_bitflags_wrapped!(VideoEncodeRateControlModeFlagsKHR, Flags);
|
||||
impl VideoEncodeRateControlModeFlagsKHR {
|
||||
pub const DEFAULT: Self = Self(0);
|
||||
pub const DISABLED: Self = Self(0b1);
|
||||
pub const CBR: Self = Self(0b10);
|
||||
pub const VBR: Self = Self(0b100);
|
||||
pub const NONE: Self = Self(0);
|
||||
pub const CBR: Self = Self(1);
|
||||
pub const VBR: Self = Self(2);
|
||||
}
|
||||
#[repr(transparent)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
|
@ -1329,7 +1319,26 @@ impl VideoEncodeH264CapabilityFlagsEXT {
|
|||
pub const ROW_UNALIGNED_SLICE: Self = Self(0b100_0000_0000_0000_0000_0000);
|
||||
pub const DIFFERENT_SLICE_TYPE: Self = Self(0b1000_0000_0000_0000_0000_0000);
|
||||
pub const B_FRAME_IN_L1_LIST: Self = Self(0b1_0000_0000_0000_0000_0000_0000);
|
||||
pub const DIFFERENT_REFERENCE_FINAL_LISTS: Self = Self(0b10_0000_0000_0000_0000_0000_0000);
|
||||
}
|
||||
#[repr(transparent)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VkVideoEncodeH264InputModeFlagBitsEXT.html>"]
|
||||
pub struct VideoEncodeH264InputModeFlagsEXT(pub(crate) Flags);
|
||||
vk_bitflags_wrapped!(VideoEncodeH264InputModeFlagsEXT, Flags);
|
||||
impl VideoEncodeH264InputModeFlagsEXT {
|
||||
pub const FRAME: Self = Self(0b1);
|
||||
pub const SLICE: Self = Self(0b10);
|
||||
pub const NON_VCL: Self = Self(0b100);
|
||||
}
|
||||
#[repr(transparent)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VkVideoEncodeH264OutputModeFlagBitsEXT.html>"]
|
||||
pub struct VideoEncodeH264OutputModeFlagsEXT(pub(crate) Flags);
|
||||
vk_bitflags_wrapped!(VideoEncodeH264OutputModeFlagsEXT, Flags);
|
||||
impl VideoEncodeH264OutputModeFlagsEXT {
|
||||
pub const FRAME: Self = Self(0b1);
|
||||
pub const SLICE: Self = Self(0b10);
|
||||
pub const NON_VCL: Self = Self(0b100);
|
||||
}
|
||||
#[repr(transparent)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
|
@ -1465,7 +1474,26 @@ impl VideoEncodeH265CapabilityFlagsEXT {
|
|||
pub const DEPENDENT_SLICE_SEGMENT: Self = Self(0b1000_0000_0000_0000_0000_0000);
|
||||
pub const DIFFERENT_SLICE_TYPE: Self = Self(0b1_0000_0000_0000_0000_0000_0000);
|
||||
pub const B_FRAME_IN_L1_LIST: Self = Self(0b10_0000_0000_0000_0000_0000_0000);
|
||||
pub const DIFFERENT_REFERENCE_FINAL_LISTS: Self = Self(0b100_0000_0000_0000_0000_0000_0000);
|
||||
}
|
||||
#[repr(transparent)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VkVideoEncodeH265InputModeFlagBitsEXT.html>"]
|
||||
pub struct VideoEncodeH265InputModeFlagsEXT(pub(crate) Flags);
|
||||
vk_bitflags_wrapped!(VideoEncodeH265InputModeFlagsEXT, Flags);
|
||||
impl VideoEncodeH265InputModeFlagsEXT {
|
||||
pub const FRAME: Self = Self(0b1);
|
||||
pub const SLICE_SEGMENT: Self = Self(0b10);
|
||||
pub const NON_VCL: Self = Self(0b100);
|
||||
}
|
||||
#[repr(transparent)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VkVideoEncodeH265OutputModeFlagBitsEXT.html>"]
|
||||
pub struct VideoEncodeH265OutputModeFlagsEXT(pub(crate) Flags);
|
||||
vk_bitflags_wrapped!(VideoEncodeH265OutputModeFlagsEXT, Flags);
|
||||
impl VideoEncodeH265OutputModeFlagsEXT {
|
||||
pub const FRAME: Self = Self(0b1);
|
||||
pub const SLICE_SEGMENT: Self = Self(0b10);
|
||||
pub const NON_VCL: Self = Self(0b100);
|
||||
}
|
||||
#[repr(transparent)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
|
@ -1613,11 +1641,3 @@ vk_bitflags_wrapped!(MicromapCreateFlagsEXT, Flags);
|
|||
impl MicromapCreateFlagsEXT {
|
||||
pub const DEVICE_ADDRESS_CAPTURE_REPLAY: Self = Self(0b1);
|
||||
}
|
||||
#[repr(transparent)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VkShaderCreateFlagBitsEXT.html>"]
|
||||
pub struct ShaderCreateFlagsEXT(pub(crate) Flags);
|
||||
vk_bitflags_wrapped!(ShaderCreateFlagsEXT, Flags);
|
||||
impl ShaderCreateFlagsEXT {
|
||||
pub const LINK_STAGE: Self = Self(0b1);
|
||||
}
|
||||
|
|
|
@ -318,15 +318,11 @@ impl fmt::Debug for AccessFlags2 {
|
|||
),
|
||||
(AccessFlags2::MICROMAP_READ_EXT.0, "MICROMAP_READ_EXT"),
|
||||
(AccessFlags2::MICROMAP_WRITE_EXT.0, "MICROMAP_WRITE_EXT"),
|
||||
(AccessFlags2::RESERVED_49_ARM.0, "RESERVED_49_ARM"),
|
||||
(AccessFlags2::RESERVED_50_ARM.0, "RESERVED_50_ARM"),
|
||||
(AccessFlags2::OPTICAL_FLOW_READ_NV.0, "OPTICAL_FLOW_READ_NV"),
|
||||
(
|
||||
AccessFlags2::OPTICAL_FLOW_WRITE_NV.0,
|
||||
"OPTICAL_FLOW_WRITE_NV",
|
||||
),
|
||||
(AccessFlags2::RESERVED_47_EXT.0, "RESERVED_47_EXT"),
|
||||
(AccessFlags2::RESERVED_48_EXT.0, "RESERVED_48_EXT"),
|
||||
];
|
||||
debug_flags(f, KNOWN, self.0)
|
||||
}
|
||||
|
@ -519,7 +515,6 @@ impl fmt::Debug for BufferCreateFlags {
|
|||
BufferCreateFlags::DESCRIPTOR_BUFFER_CAPTURE_REPLAY_EXT.0,
|
||||
"DESCRIPTOR_BUFFER_CAPTURE_REPLAY_EXT",
|
||||
),
|
||||
(BufferCreateFlags::RESERVED_6_KHR.0, "RESERVED_6_KHR"),
|
||||
(BufferCreateFlags::PROTECTED.0, "PROTECTED"),
|
||||
(
|
||||
BufferCreateFlags::DEVICE_ADDRESS_CAPTURE_REPLAY.0,
|
||||
|
@ -660,12 +655,12 @@ impl fmt::Debug for BuildAccelerationStructureFlagsKHR {
|
|||
"ALLOW_OPACITY_MICROMAP_DATA_UPDATE_EXT",
|
||||
),
|
||||
(
|
||||
BuildAccelerationStructureFlagsKHR::ALLOW_DISPLACEMENT_MICROMAP_UPDATE_NV.0,
|
||||
"ALLOW_DISPLACEMENT_MICROMAP_UPDATE_NV",
|
||||
BuildAccelerationStructureFlagsKHR::RESERVED_9_NV.0,
|
||||
"RESERVED_9_NV",
|
||||
),
|
||||
(
|
||||
BuildAccelerationStructureFlagsKHR::ALLOW_DATA_ACCESS.0,
|
||||
"ALLOW_DATA_ACCESS",
|
||||
BuildAccelerationStructureFlagsKHR::RESERVED_10_NV.0,
|
||||
"RESERVED_10_NV",
|
||||
),
|
||||
];
|
||||
debug_flags(f, KNOWN, self.0)
|
||||
|
@ -1209,10 +1204,6 @@ impl fmt::Debug for DescriptorSetLayoutCreateFlags {
|
|||
DescriptorSetLayoutCreateFlags::HOST_ONLY_POOL_EXT.0,
|
||||
"HOST_ONLY_POOL_EXT",
|
||||
),
|
||||
(
|
||||
DescriptorSetLayoutCreateFlags::RESERVED_6_EXT.0,
|
||||
"RESERVED_6_EXT",
|
||||
),
|
||||
(
|
||||
DescriptorSetLayoutCreateFlags::UPDATE_AFTER_BIND_POOL.0,
|
||||
"UPDATE_AFTER_BIND_POOL",
|
||||
|
@ -1453,21 +1444,6 @@ impl fmt::Debug for DiscardRectangleModeEXT {
|
|||
}
|
||||
}
|
||||
}
|
||||
impl fmt::Debug for DisplacementMicromapFormatNV {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
let name = match *self {
|
||||
Self::TYPE_64_TRIANGLES_64_BYTES => Some("TYPE_64_TRIANGLES_64_BYTES"),
|
||||
Self::TYPE_256_TRIANGLES_128_BYTES => Some("TYPE_256_TRIANGLES_128_BYTES"),
|
||||
Self::TYPE_1024_TRIANGLES_128_BYTES => Some("TYPE_1024_TRIANGLES_128_BYTES"),
|
||||
_ => None,
|
||||
};
|
||||
if let Some(x) = name {
|
||||
f.write_str(x)
|
||||
} else {
|
||||
self.0.fmt(f)
|
||||
}
|
||||
}
|
||||
}
|
||||
impl fmt::Debug for DisplayEventTypeEXT {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
let name = match *self {
|
||||
|
@ -1549,7 +1525,6 @@ impl fmt::Debug for DriverId {
|
|||
Self::MESA_VENUS => Some("MESA_VENUS"),
|
||||
Self::MESA_DOZEN => Some("MESA_DOZEN"),
|
||||
Self::MESA_NVK => Some("MESA_NVK"),
|
||||
Self::IMAGINATION_OPEN_SOURCE_MESA => Some("IMAGINATION_OPEN_SOURCE_MESA"),
|
||||
_ => None,
|
||||
};
|
||||
if let Some(x) = name {
|
||||
|
@ -1573,15 +1548,12 @@ impl fmt::Debug for DynamicState {
|
|||
Self::STENCIL_REFERENCE => Some("STENCIL_REFERENCE"),
|
||||
Self::VIEWPORT_W_SCALING_NV => Some("VIEWPORT_W_SCALING_NV"),
|
||||
Self::DISCARD_RECTANGLE_EXT => Some("DISCARD_RECTANGLE_EXT"),
|
||||
Self::DISCARD_RECTANGLE_ENABLE_EXT => Some("DISCARD_RECTANGLE_ENABLE_EXT"),
|
||||
Self::DISCARD_RECTANGLE_MODE_EXT => Some("DISCARD_RECTANGLE_MODE_EXT"),
|
||||
Self::SAMPLE_LOCATIONS_EXT => Some("SAMPLE_LOCATIONS_EXT"),
|
||||
Self::RAY_TRACING_PIPELINE_STACK_SIZE_KHR => {
|
||||
Some("RAY_TRACING_PIPELINE_STACK_SIZE_KHR")
|
||||
}
|
||||
Self::VIEWPORT_SHADING_RATE_PALETTE_NV => Some("VIEWPORT_SHADING_RATE_PALETTE_NV"),
|
||||
Self::VIEWPORT_COARSE_SAMPLE_ORDER_NV => Some("VIEWPORT_COARSE_SAMPLE_ORDER_NV"),
|
||||
Self::EXCLUSIVE_SCISSOR_ENABLE_NV => Some("EXCLUSIVE_SCISSOR_ENABLE_NV"),
|
||||
Self::EXCLUSIVE_SCISSOR_NV => Some("EXCLUSIVE_SCISSOR_NV"),
|
||||
Self::FRAGMENT_SHADING_RATE_KHR => Some("FRAGMENT_SHADING_RATE_KHR"),
|
||||
Self::LINE_STIPPLE_EXT => Some("LINE_STIPPLE_EXT"),
|
||||
|
@ -1628,9 +1600,6 @@ impl fmt::Debug for DynamicState {
|
|||
Some("REPRESENTATIVE_FRAGMENT_TEST_ENABLE_NV")
|
||||
}
|
||||
Self::COVERAGE_REDUCTION_MODE_NV => Some("COVERAGE_REDUCTION_MODE_NV"),
|
||||
Self::ATTACHMENT_FEEDBACK_LOOP_ENABLE_EXT => {
|
||||
Some("ATTACHMENT_FEEDBACK_LOOP_ENABLE_EXT")
|
||||
}
|
||||
Self::CULL_MODE => Some("CULL_MODE"),
|
||||
Self::FRONT_FACE => Some("FRONT_FACE"),
|
||||
Self::PRIMITIVE_TOPOLOGY => Some("PRIMITIVE_TOPOLOGY"),
|
||||
|
@ -1711,6 +1680,14 @@ impl fmt::Debug for ExternalFenceHandleTypeFlags {
|
|||
"OPAQUE_WIN32_KMT",
|
||||
),
|
||||
(ExternalFenceHandleTypeFlags::SYNC_FD.0, "SYNC_FD"),
|
||||
(
|
||||
ExternalFenceHandleTypeFlags::RESERVED_4_NV.0,
|
||||
"RESERVED_4_NV",
|
||||
),
|
||||
(
|
||||
ExternalFenceHandleTypeFlags::RESERVED_5_NV.0,
|
||||
"RESERVED_5_NV",
|
||||
),
|
||||
];
|
||||
debug_flags(f, KNOWN, self.0)
|
||||
}
|
||||
|
@ -1788,8 +1765,8 @@ impl fmt::Debug for ExternalMemoryHandleTypeFlags {
|
|||
"RDMA_ADDRESS_NV",
|
||||
),
|
||||
(
|
||||
ExternalMemoryHandleTypeFlags::TYPE_530_QNX.0,
|
||||
"TYPE_530_QNX",
|
||||
ExternalMemoryHandleTypeFlags::RESERVED_13_NV.0,
|
||||
"RESERVED_13_NV",
|
||||
),
|
||||
];
|
||||
debug_flags(f, KNOWN, self.0)
|
||||
|
@ -1848,6 +1825,10 @@ impl fmt::Debug for ExternalSemaphoreHandleTypeFlags {
|
|||
ExternalSemaphoreHandleTypeFlags::ZIRCON_EVENT_FUCHSIA.0,
|
||||
"ZIRCON_EVENT_FUCHSIA",
|
||||
),
|
||||
(
|
||||
ExternalSemaphoreHandleTypeFlags::RESERVED_5_NV.0,
|
||||
"RESERVED_5_NV",
|
||||
),
|
||||
];
|
||||
debug_flags(f, KNOWN, self.0)
|
||||
}
|
||||
|
@ -2209,7 +2190,7 @@ impl fmt::Debug for FormatFeatureFlags {
|
|||
}
|
||||
impl fmt::Debug for FormatFeatureFlags2 {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
const KNOWN : & [(Flags64 , & str)] = & [(FormatFeatureFlags2 :: SAMPLED_IMAGE . 0 , "SAMPLED_IMAGE") , (FormatFeatureFlags2 :: STORAGE_IMAGE . 0 , "STORAGE_IMAGE") , (FormatFeatureFlags2 :: STORAGE_IMAGE_ATOMIC . 0 , "STORAGE_IMAGE_ATOMIC") , (FormatFeatureFlags2 :: UNIFORM_TEXEL_BUFFER . 0 , "UNIFORM_TEXEL_BUFFER") , (FormatFeatureFlags2 :: STORAGE_TEXEL_BUFFER . 0 , "STORAGE_TEXEL_BUFFER") , (FormatFeatureFlags2 :: STORAGE_TEXEL_BUFFER_ATOMIC . 0 , "STORAGE_TEXEL_BUFFER_ATOMIC") , (FormatFeatureFlags2 :: VERTEX_BUFFER . 0 , "VERTEX_BUFFER") , (FormatFeatureFlags2 :: COLOR_ATTACHMENT . 0 , "COLOR_ATTACHMENT") , (FormatFeatureFlags2 :: COLOR_ATTACHMENT_BLEND . 0 , "COLOR_ATTACHMENT_BLEND") , (FormatFeatureFlags2 :: DEPTH_STENCIL_ATTACHMENT . 0 , "DEPTH_STENCIL_ATTACHMENT") , (FormatFeatureFlags2 :: BLIT_SRC . 0 , "BLIT_SRC") , (FormatFeatureFlags2 :: BLIT_DST . 0 , "BLIT_DST") , (FormatFeatureFlags2 :: SAMPLED_IMAGE_FILTER_LINEAR . 0 , "SAMPLED_IMAGE_FILTER_LINEAR") , (FormatFeatureFlags2 :: SAMPLED_IMAGE_FILTER_CUBIC . 0 , "SAMPLED_IMAGE_FILTER_CUBIC") , (FormatFeatureFlags2 :: TRANSFER_SRC . 0 , "TRANSFER_SRC") , (FormatFeatureFlags2 :: TRANSFER_DST . 0 , "TRANSFER_DST") , (FormatFeatureFlags2 :: SAMPLED_IMAGE_FILTER_MINMAX . 0 , "SAMPLED_IMAGE_FILTER_MINMAX") , (FormatFeatureFlags2 :: MIDPOINT_CHROMA_SAMPLES . 0 , "MIDPOINT_CHROMA_SAMPLES") , (FormatFeatureFlags2 :: SAMPLED_IMAGE_YCBCR_CONVERSION_LINEAR_FILTER . 0 , "SAMPLED_IMAGE_YCBCR_CONVERSION_LINEAR_FILTER") , (FormatFeatureFlags2 :: SAMPLED_IMAGE_YCBCR_CONVERSION_SEPARATE_RECONSTRUCTION_FILTER . 0 , "SAMPLED_IMAGE_YCBCR_CONVERSION_SEPARATE_RECONSTRUCTION_FILTER") , (FormatFeatureFlags2 :: SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT . 0 , "SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT") , (FormatFeatureFlags2 :: SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT_FORCEABLE . 0 , "SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT_FORCEABLE") , (FormatFeatureFlags2 :: DISJOINT . 0 , "DISJOINT") , (FormatFeatureFlags2 :: COSITED_CHROMA_SAMPLES . 0 , "COSITED_CHROMA_SAMPLES") , (FormatFeatureFlags2 :: STORAGE_READ_WITHOUT_FORMAT . 0 , "STORAGE_READ_WITHOUT_FORMAT") , (FormatFeatureFlags2 :: STORAGE_WRITE_WITHOUT_FORMAT . 0 , "STORAGE_WRITE_WITHOUT_FORMAT") , (FormatFeatureFlags2 :: SAMPLED_IMAGE_DEPTH_COMPARISON . 0 , "SAMPLED_IMAGE_DEPTH_COMPARISON") , (FormatFeatureFlags2 :: VIDEO_DECODE_OUTPUT_KHR . 0 , "VIDEO_DECODE_OUTPUT_KHR") , (FormatFeatureFlags2 :: VIDEO_DECODE_DPB_KHR . 0 , "VIDEO_DECODE_DPB_KHR") , (FormatFeatureFlags2 :: ACCELERATION_STRUCTURE_VERTEX_BUFFER_KHR . 0 , "ACCELERATION_STRUCTURE_VERTEX_BUFFER_KHR") , (FormatFeatureFlags2 :: FRAGMENT_DENSITY_MAP_EXT . 0 , "FRAGMENT_DENSITY_MAP_EXT") , (FormatFeatureFlags2 :: FRAGMENT_SHADING_RATE_ATTACHMENT_KHR . 0 , "FRAGMENT_SHADING_RATE_ATTACHMENT_KHR") , (FormatFeatureFlags2 :: RESERVED_44_EXT . 0 , "RESERVED_44_EXT") , (FormatFeatureFlags2 :: RESERVED_45_EXT . 0 , "RESERVED_45_EXT") , (FormatFeatureFlags2 :: RESERVED_46_EXT . 0 , "RESERVED_46_EXT") , (FormatFeatureFlags2 :: VIDEO_ENCODE_INPUT_KHR . 0 , "VIDEO_ENCODE_INPUT_KHR") , (FormatFeatureFlags2 :: VIDEO_ENCODE_DPB_KHR . 0 , "VIDEO_ENCODE_DPB_KHR") , (FormatFeatureFlags2 :: LINEAR_COLOR_ATTACHMENT_NV . 0 , "LINEAR_COLOR_ATTACHMENT_NV") , (FormatFeatureFlags2 :: WEIGHT_IMAGE_QCOM . 0 , "WEIGHT_IMAGE_QCOM") , (FormatFeatureFlags2 :: WEIGHT_SAMPLED_IMAGE_QCOM . 0 , "WEIGHT_SAMPLED_IMAGE_QCOM") , (FormatFeatureFlags2 :: BLOCK_MATCHING_QCOM . 0 , "BLOCK_MATCHING_QCOM") , (FormatFeatureFlags2 :: BOX_FILTER_SAMPLED_QCOM . 0 , "BOX_FILTER_SAMPLED_QCOM") , (FormatFeatureFlags2 :: RESERVED_39_EXT . 0 , "RESERVED_39_EXT") , (FormatFeatureFlags2 :: OPTICAL_FLOW_IMAGE_NV . 0 , "OPTICAL_FLOW_IMAGE_NV") , (FormatFeatureFlags2 :: OPTICAL_FLOW_VECTOR_NV . 0 , "OPTICAL_FLOW_VECTOR_NV") , (FormatFeatureFlags2 :: OPTICAL_FLOW_COST_NV . 0 , "OPTICAL_FLOW_COST_NV")] ;
|
||||
const KNOWN : & [(Flags64 , & str)] = & [(FormatFeatureFlags2 :: SAMPLED_IMAGE . 0 , "SAMPLED_IMAGE") , (FormatFeatureFlags2 :: STORAGE_IMAGE . 0 , "STORAGE_IMAGE") , (FormatFeatureFlags2 :: STORAGE_IMAGE_ATOMIC . 0 , "STORAGE_IMAGE_ATOMIC") , (FormatFeatureFlags2 :: UNIFORM_TEXEL_BUFFER . 0 , "UNIFORM_TEXEL_BUFFER") , (FormatFeatureFlags2 :: STORAGE_TEXEL_BUFFER . 0 , "STORAGE_TEXEL_BUFFER") , (FormatFeatureFlags2 :: STORAGE_TEXEL_BUFFER_ATOMIC . 0 , "STORAGE_TEXEL_BUFFER_ATOMIC") , (FormatFeatureFlags2 :: VERTEX_BUFFER . 0 , "VERTEX_BUFFER") , (FormatFeatureFlags2 :: COLOR_ATTACHMENT . 0 , "COLOR_ATTACHMENT") , (FormatFeatureFlags2 :: COLOR_ATTACHMENT_BLEND . 0 , "COLOR_ATTACHMENT_BLEND") , (FormatFeatureFlags2 :: DEPTH_STENCIL_ATTACHMENT . 0 , "DEPTH_STENCIL_ATTACHMENT") , (FormatFeatureFlags2 :: BLIT_SRC . 0 , "BLIT_SRC") , (FormatFeatureFlags2 :: BLIT_DST . 0 , "BLIT_DST") , (FormatFeatureFlags2 :: SAMPLED_IMAGE_FILTER_LINEAR . 0 , "SAMPLED_IMAGE_FILTER_LINEAR") , (FormatFeatureFlags2 :: SAMPLED_IMAGE_FILTER_CUBIC . 0 , "SAMPLED_IMAGE_FILTER_CUBIC") , (FormatFeatureFlags2 :: TRANSFER_SRC . 0 , "TRANSFER_SRC") , (FormatFeatureFlags2 :: TRANSFER_DST . 0 , "TRANSFER_DST") , (FormatFeatureFlags2 :: SAMPLED_IMAGE_FILTER_MINMAX . 0 , "SAMPLED_IMAGE_FILTER_MINMAX") , (FormatFeatureFlags2 :: MIDPOINT_CHROMA_SAMPLES . 0 , "MIDPOINT_CHROMA_SAMPLES") , (FormatFeatureFlags2 :: SAMPLED_IMAGE_YCBCR_CONVERSION_LINEAR_FILTER . 0 , "SAMPLED_IMAGE_YCBCR_CONVERSION_LINEAR_FILTER") , (FormatFeatureFlags2 :: SAMPLED_IMAGE_YCBCR_CONVERSION_SEPARATE_RECONSTRUCTION_FILTER . 0 , "SAMPLED_IMAGE_YCBCR_CONVERSION_SEPARATE_RECONSTRUCTION_FILTER") , (FormatFeatureFlags2 :: SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT . 0 , "SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT") , (FormatFeatureFlags2 :: SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT_FORCEABLE . 0 , "SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT_FORCEABLE") , (FormatFeatureFlags2 :: DISJOINT . 0 , "DISJOINT") , (FormatFeatureFlags2 :: COSITED_CHROMA_SAMPLES . 0 , "COSITED_CHROMA_SAMPLES") , (FormatFeatureFlags2 :: STORAGE_READ_WITHOUT_FORMAT . 0 , "STORAGE_READ_WITHOUT_FORMAT") , (FormatFeatureFlags2 :: STORAGE_WRITE_WITHOUT_FORMAT . 0 , "STORAGE_WRITE_WITHOUT_FORMAT") , (FormatFeatureFlags2 :: SAMPLED_IMAGE_DEPTH_COMPARISON . 0 , "SAMPLED_IMAGE_DEPTH_COMPARISON") , (FormatFeatureFlags2 :: VIDEO_DECODE_OUTPUT_KHR . 0 , "VIDEO_DECODE_OUTPUT_KHR") , (FormatFeatureFlags2 :: VIDEO_DECODE_DPB_KHR . 0 , "VIDEO_DECODE_DPB_KHR") , (FormatFeatureFlags2 :: ACCELERATION_STRUCTURE_VERTEX_BUFFER_KHR . 0 , "ACCELERATION_STRUCTURE_VERTEX_BUFFER_KHR") , (FormatFeatureFlags2 :: FRAGMENT_DENSITY_MAP_EXT . 0 , "FRAGMENT_DENSITY_MAP_EXT") , (FormatFeatureFlags2 :: FRAGMENT_SHADING_RATE_ATTACHMENT_KHR . 0 , "FRAGMENT_SHADING_RATE_ATTACHMENT_KHR") , (FormatFeatureFlags2 :: RESERVED_44_EXT . 0 , "RESERVED_44_EXT") , (FormatFeatureFlags2 :: RESERVED_45_EXT . 0 , "RESERVED_45_EXT") , (FormatFeatureFlags2 :: VIDEO_ENCODE_INPUT_KHR . 0 , "VIDEO_ENCODE_INPUT_KHR") , (FormatFeatureFlags2 :: VIDEO_ENCODE_DPB_KHR . 0 , "VIDEO_ENCODE_DPB_KHR") , (FormatFeatureFlags2 :: LINEAR_COLOR_ATTACHMENT_NV . 0 , "LINEAR_COLOR_ATTACHMENT_NV") , (FormatFeatureFlags2 :: WEIGHT_IMAGE_QCOM . 0 , "WEIGHT_IMAGE_QCOM") , (FormatFeatureFlags2 :: WEIGHT_SAMPLED_IMAGE_QCOM . 0 , "WEIGHT_SAMPLED_IMAGE_QCOM") , (FormatFeatureFlags2 :: BLOCK_MATCHING_QCOM . 0 , "BLOCK_MATCHING_QCOM") , (FormatFeatureFlags2 :: BOX_FILTER_SAMPLED_QCOM . 0 , "BOX_FILTER_SAMPLED_QCOM") , (FormatFeatureFlags2 :: RESERVED_39_EXT . 0 , "RESERVED_39_EXT") , (FormatFeatureFlags2 :: OPTICAL_FLOW_IMAGE_NV . 0 , "OPTICAL_FLOW_IMAGE_NV") , (FormatFeatureFlags2 :: OPTICAL_FLOW_VECTOR_NV . 0 , "OPTICAL_FLOW_VECTOR_NV") , (FormatFeatureFlags2 :: OPTICAL_FLOW_COST_NV . 0 , "OPTICAL_FLOW_COST_NV")] ;
|
||||
debug_flags(f, KNOWN, self.0)
|
||||
}
|
||||
}
|
||||
|
@ -2565,7 +2546,6 @@ impl fmt::Debug for ImageCreateFlags {
|
|||
ImageCreateFlags::FRAGMENT_DENSITY_MAP_OFFSET_QCOM.0,
|
||||
"FRAGMENT_DENSITY_MAP_OFFSET_QCOM",
|
||||
),
|
||||
(ImageCreateFlags::RESERVED_20_KHR.0, "RESERVED_20_KHR"),
|
||||
(ImageCreateFlags::ALIAS.0, "ALIAS"),
|
||||
(
|
||||
ImageCreateFlags::SPLIT_INSTANCE_BIND_REGIONS.0,
|
||||
|
@ -2741,7 +2721,6 @@ impl fmt::Debug for ImageUsageFlags {
|
|||
ImageUsageFlags::SAMPLE_BLOCK_MATCH_QCOM.0,
|
||||
"SAMPLE_BLOCK_MATCH_QCOM",
|
||||
),
|
||||
(ImageUsageFlags::RESERVED_23_EXT.0, "RESERVED_23_EXT"),
|
||||
];
|
||||
debug_flags(f, KNOWN, self.0)
|
||||
}
|
||||
|
@ -2761,6 +2740,7 @@ impl fmt::Debug for ImageViewCreateFlags {
|
|||
ImageViewCreateFlags::FRAGMENT_DENSITY_MAP_DEFERRED_EXT.0,
|
||||
"FRAGMENT_DENSITY_MAP_DEFERRED_EXT",
|
||||
),
|
||||
(ImageViewCreateFlags::RESERVED_3_EXT.0, "RESERVED_3_EXT"),
|
||||
];
|
||||
debug_flags(f, KNOWN, self.0)
|
||||
}
|
||||
|
@ -2945,6 +2925,7 @@ impl fmt::Debug for MemoryHeapFlags {
|
|||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
const KNOWN: &[(Flags, &str)] = &[
|
||||
(MemoryHeapFlags::DEVICE_LOCAL.0, "DEVICE_LOCAL"),
|
||||
(MemoryHeapFlags::RESERVED_2_KHR.0, "RESERVED_2_KHR"),
|
||||
(MemoryHeapFlags::MULTI_INSTANCE.0, "MULTI_INSTANCE"),
|
||||
];
|
||||
debug_flags(f, KNOWN, self.0)
|
||||
|
@ -2993,12 +2974,6 @@ impl fmt::Debug for MemoryPropertyFlags {
|
|||
debug_flags(f, KNOWN, self.0)
|
||||
}
|
||||
}
|
||||
impl fmt::Debug for MemoryUnmapFlagsKHR {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
const KNOWN: &[(Flags, &str)] = &[];
|
||||
debug_flags(f, KNOWN, self.0)
|
||||
}
|
||||
}
|
||||
impl fmt::Debug for MetalSurfaceCreateFlagsEXT {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
const KNOWN: &[(Flags, &str)] = &[];
|
||||
|
@ -3018,7 +2993,6 @@ impl fmt::Debug for MicromapTypeEXT {
|
|||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
let name = match *self {
|
||||
Self::OPACITY_MICROMAP => Some("OPACITY_MICROMAP"),
|
||||
Self::DISPLACEMENT_MICROMAP_NV => Some("DISPLACEMENT_MICROMAP_NV"),
|
||||
_ => None,
|
||||
};
|
||||
if let Some(x) = name {
|
||||
|
@ -3333,10 +3307,14 @@ impl fmt::Debug for PipelineBindPoint {
|
|||
}
|
||||
impl fmt::Debug for PipelineCacheCreateFlags {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
const KNOWN: &[(Flags, &str)] = &[(
|
||||
const KNOWN: &[(Flags, &str)] = &[
|
||||
(PipelineCacheCreateFlags::RESERVED_1_EXT.0, "RESERVED_1_EXT"),
|
||||
(PipelineCacheCreateFlags::RESERVED_2_KHR.0, "RESERVED_2_KHR"),
|
||||
(
|
||||
PipelineCacheCreateFlags::EXTERNALLY_SYNCHRONIZED.0,
|
||||
"EXTERNALLY_SYNCHRONIZED",
|
||||
)];
|
||||
),
|
||||
];
|
||||
debug_flags(f, KNOWN, self.0)
|
||||
}
|
||||
}
|
||||
|
@ -3476,10 +3454,7 @@ impl fmt::Debug for PipelineCreateFlags {
|
|||
PipelineCreateFlags::RAY_TRACING_OPACITY_MICROMAP_EXT.0,
|
||||
"RAY_TRACING_OPACITY_MICROMAP_EXT",
|
||||
),
|
||||
(
|
||||
PipelineCreateFlags::RAY_TRACING_DISPLACEMENT_MICROMAP_NV.0,
|
||||
"RAY_TRACING_DISPLACEMENT_MICROMAP_NV",
|
||||
),
|
||||
(PipelineCreateFlags::RESERVED_28_NV.0, "RESERVED_28_NV"),
|
||||
(
|
||||
PipelineCreateFlags::NO_PROTECTED_ACCESS_EXT.0,
|
||||
"NO_PROTECTED_ACCESS_EXT",
|
||||
|
@ -3825,12 +3800,10 @@ impl fmt::Debug for PipelineStageFlags2 {
|
|||
"MICROMAP_BUILD_EXT",
|
||||
),
|
||||
(
|
||||
PipelineStageFlags2::CLUSTER_CULLING_SHADER_HUAWEI.0,
|
||||
"CLUSTER_CULLING_SHADER_HUAWEI",
|
||||
PipelineStageFlags2::RESEVED_41_HUAWEI.0,
|
||||
"RESEVED_41_HUAWEI",
|
||||
),
|
||||
(PipelineStageFlags2::RESERVED_43_ARM.0, "RESERVED_43_ARM"),
|
||||
(PipelineStageFlags2::OPTICAL_FLOW_NV.0, "OPTICAL_FLOW_NV"),
|
||||
(PipelineStageFlags2::RESERVED_42_EXT.0, "RESERVED_42_EXT"),
|
||||
];
|
||||
debug_flags(f, KNOWN, self.0)
|
||||
}
|
||||
|
@ -3955,8 +3928,7 @@ impl fmt::Debug for PrimitiveTopology {
|
|||
}
|
||||
impl fmt::Debug for PrivateDataSlotCreateFlags {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
const KNOWN: &[(Flags, &str)] =
|
||||
&[(PrivateDataSlotCreateFlags::RESERVED_0_NV.0, "RESERVED_0_NV")];
|
||||
const KNOWN: &[(Flags, &str)] = &[];
|
||||
debug_flags(f, KNOWN, self.0)
|
||||
}
|
||||
}
|
||||
|
@ -4035,10 +4007,6 @@ impl fmt::Debug for QueryPipelineStatisticFlags {
|
|||
QueryPipelineStatisticFlags::MESH_SHADER_INVOCATIONS_EXT.0,
|
||||
"MESH_SHADER_INVOCATIONS_EXT",
|
||||
),
|
||||
(
|
||||
QueryPipelineStatisticFlags::CLUSTER_CULLING_SHADER_INVOCATIONS_HUAWEI.0,
|
||||
"CLUSTER_CULLING_SHADER_INVOCATIONS_HUAWEI",
|
||||
),
|
||||
];
|
||||
debug_flags(f, KNOWN, self.0)
|
||||
}
|
||||
|
@ -4108,7 +4076,9 @@ impl fmt::Debug for QueryType {
|
|||
Some("ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV")
|
||||
}
|
||||
Self::PERFORMANCE_QUERY_INTEL => Some("PERFORMANCE_QUERY_INTEL"),
|
||||
Self::VIDEO_ENCODE_FEEDBACK_KHR => Some("VIDEO_ENCODE_FEEDBACK_KHR"),
|
||||
Self::VIDEO_ENCODESTREAM_BUFFER_RANGE_KHR => {
|
||||
Some("VIDEO_ENCODESTREAM_BUFFER_RANGE_KHR")
|
||||
}
|
||||
Self::MESH_PRIMITIVES_GENERATED_EXT => Some("MESH_PRIMITIVES_GENERATED_EXT"),
|
||||
Self::PRIMITIVES_GENERATED_EXT => Some("PRIMITIVES_GENERATED_EXT"),
|
||||
Self::ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR => {
|
||||
|
@ -4137,9 +4107,7 @@ impl fmt::Debug for QueueFlags {
|
|||
(QueueFlags::RESERVED_9_EXT.0, "RESERVED_9_EXT"),
|
||||
(QueueFlags::VIDEO_ENCODE_KHR.0, "VIDEO_ENCODE_KHR"),
|
||||
(QueueFlags::RESERVED_7_QCOM.0, "RESERVED_7_QCOM"),
|
||||
(QueueFlags::RESERVED_11_ARM.0, "RESERVED_11_ARM"),
|
||||
(QueueFlags::OPTICAL_FLOW_NV.0, "OPTICAL_FLOW_NV"),
|
||||
(QueueFlags::RESERVED_10_EXT.0, "RESERVED_10_EXT"),
|
||||
(QueueFlags::PROTECTED.0, "PROTECTED"),
|
||||
];
|
||||
debug_flags(f, KNOWN, self.0)
|
||||
|
@ -4238,10 +4206,6 @@ impl fmt::Debug for ResolveModeFlags {
|
|||
(ResolveModeFlags::AVERAGE.0, "AVERAGE"),
|
||||
(ResolveModeFlags::MIN.0, "MIN"),
|
||||
(ResolveModeFlags::MAX.0, "MAX"),
|
||||
(
|
||||
ResolveModeFlags::EXTENSION_469_FLAG_0.0,
|
||||
"EXTENSION_469_FLAG_0",
|
||||
),
|
||||
];
|
||||
debug_flags(f, KNOWN, self.0)
|
||||
}
|
||||
|
@ -4415,52 +4379,12 @@ impl fmt::Debug for SemaphoreWaitFlags {
|
|||
debug_flags(f, KNOWN, self.0)
|
||||
}
|
||||
}
|
||||
impl fmt::Debug for ShaderCodeTypeEXT {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
let name = match *self {
|
||||
Self::BINARY => Some("BINARY"),
|
||||
Self::SPIRV => Some("SPIRV"),
|
||||
_ => None,
|
||||
};
|
||||
if let Some(x) = name {
|
||||
f.write_str(x)
|
||||
} else {
|
||||
self.0.fmt(f)
|
||||
}
|
||||
}
|
||||
}
|
||||
impl fmt::Debug for ShaderCorePropertiesFlagsAMD {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
const KNOWN: &[(Flags, &str)] = &[];
|
||||
debug_flags(f, KNOWN, self.0)
|
||||
}
|
||||
}
|
||||
impl fmt::Debug for ShaderCreateFlagsEXT {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
const KNOWN: &[(Flags, &str)] = &[
|
||||
(ShaderCreateFlagsEXT::LINK_STAGE.0, "LINK_STAGE"),
|
||||
(
|
||||
ShaderCreateFlagsEXT::ALLOW_VARYING_SUBGROUP_SIZE.0,
|
||||
"ALLOW_VARYING_SUBGROUP_SIZE",
|
||||
),
|
||||
(
|
||||
ShaderCreateFlagsEXT::REQUIRE_FULL_SUBGROUPS.0,
|
||||
"REQUIRE_FULL_SUBGROUPS",
|
||||
),
|
||||
(ShaderCreateFlagsEXT::NO_TASK_SHADER.0, "NO_TASK_SHADER"),
|
||||
(ShaderCreateFlagsEXT::DISPATCH_BASE.0, "DISPATCH_BASE"),
|
||||
(
|
||||
ShaderCreateFlagsEXT::FRAGMENT_SHADING_RATE_ATTACHMENT.0,
|
||||
"FRAGMENT_SHADING_RATE_ATTACHMENT",
|
||||
),
|
||||
(
|
||||
ShaderCreateFlagsEXT::FRAGMENT_DENSITY_MAP_ATTACHMENT.0,
|
||||
"FRAGMENT_DENSITY_MAP_ATTACHMENT",
|
||||
),
|
||||
];
|
||||
debug_flags(f, KNOWN, self.0)
|
||||
}
|
||||
}
|
||||
impl fmt::Debug for ShaderFloatControlsIndependence {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
let name = match *self {
|
||||
|
@ -4542,10 +4466,10 @@ impl fmt::Debug for ShaderStageFlags {
|
|||
ShaderStageFlags::SUBPASS_SHADING_HUAWEI.0,
|
||||
"SUBPASS_SHADING_HUAWEI",
|
||||
),
|
||||
(
|
||||
ShaderStageFlags::CLUSTER_CULLING_HUAWEI.0,
|
||||
"CLUSTER_CULLING_HUAWEI",
|
||||
),
|
||||
(ShaderStageFlags::RESERVED_19_HUAWEI.0, "RESERVED_19_HUAWEI"),
|
||||
(ShaderStageFlags::EXT_483_RESERVE_15.0, "EXT_483_RESERVE_15"),
|
||||
(ShaderStageFlags::EXT_483_RESERVE_16.0, "EXT_483_RESERVE_16"),
|
||||
(ShaderStageFlags::EXT_483_RESERVE_17.0, "EXT_483_RESERVE_17"),
|
||||
];
|
||||
debug_flags(f, KNOWN, self.0)
|
||||
}
|
||||
|
@ -4821,6 +4745,9 @@ impl fmt::Debug for StructureType {
|
|||
Self::VIDEO_ENCODE_H264_NALU_SLICE_INFO_EXT => {
|
||||
Some("VIDEO_ENCODE_H264_NALU_SLICE_INFO_EXT")
|
||||
}
|
||||
Self::VIDEO_ENCODE_H264_EMIT_PICTURE_PARAMETERS_INFO_EXT => {
|
||||
Some("VIDEO_ENCODE_H264_EMIT_PICTURE_PARAMETERS_INFO_EXT")
|
||||
}
|
||||
Self::VIDEO_ENCODE_H264_PROFILE_INFO_EXT => Some("VIDEO_ENCODE_H264_PROFILE_INFO_EXT"),
|
||||
Self::VIDEO_ENCODE_H264_RATE_CONTROL_INFO_EXT => {
|
||||
Some("VIDEO_ENCODE_H264_RATE_CONTROL_INFO_EXT")
|
||||
|
@ -4828,6 +4755,9 @@ impl fmt::Debug for StructureType {
|
|||
Self::VIDEO_ENCODE_H264_RATE_CONTROL_LAYER_INFO_EXT => {
|
||||
Some("VIDEO_ENCODE_H264_RATE_CONTROL_LAYER_INFO_EXT")
|
||||
}
|
||||
Self::VIDEO_ENCODE_H264_REFERENCE_LISTS_INFO_EXT => {
|
||||
Some("VIDEO_ENCODE_H264_REFERENCE_LISTS_INFO_EXT")
|
||||
}
|
||||
Self::VIDEO_ENCODE_H265_CAPABILITIES_EXT => Some("VIDEO_ENCODE_H265_CAPABILITIES_EXT"),
|
||||
Self::VIDEO_ENCODE_H265_SESSION_PARAMETERS_CREATE_INFO_EXT => {
|
||||
Some("VIDEO_ENCODE_H265_SESSION_PARAMETERS_CREATE_INFO_EXT")
|
||||
|
@ -4844,7 +4774,13 @@ impl fmt::Debug for StructureType {
|
|||
Self::VIDEO_ENCODE_H265_NALU_SLICE_SEGMENT_INFO_EXT => {
|
||||
Some("VIDEO_ENCODE_H265_NALU_SLICE_SEGMENT_INFO_EXT")
|
||||
}
|
||||
Self::VIDEO_ENCODE_H265_EMIT_PICTURE_PARAMETERS_INFO_EXT => {
|
||||
Some("VIDEO_ENCODE_H265_EMIT_PICTURE_PARAMETERS_INFO_EXT")
|
||||
}
|
||||
Self::VIDEO_ENCODE_H265_PROFILE_INFO_EXT => Some("VIDEO_ENCODE_H265_PROFILE_INFO_EXT"),
|
||||
Self::VIDEO_ENCODE_H265_REFERENCE_LISTS_INFO_EXT => {
|
||||
Some("VIDEO_ENCODE_H265_REFERENCE_LISTS_INFO_EXT")
|
||||
}
|
||||
Self::VIDEO_ENCODE_H265_RATE_CONTROL_INFO_EXT => {
|
||||
Some("VIDEO_ENCODE_H265_RATE_CONTROL_INFO_EXT")
|
||||
}
|
||||
|
@ -5438,8 +5374,6 @@ impl fmt::Debug for StructureType {
|
|||
Self::PIPELINE_EXECUTABLE_INTERNAL_REPRESENTATION_KHR => {
|
||||
Some("PIPELINE_EXECUTABLE_INTERNAL_REPRESENTATION_KHR")
|
||||
}
|
||||
Self::MEMORY_MAP_INFO_KHR => Some("MEMORY_MAP_INFO_KHR"),
|
||||
Self::MEMORY_UNMAP_INFO_KHR => Some("MEMORY_UNMAP_INFO_KHR"),
|
||||
Self::PHYSICAL_DEVICE_SHADER_ATOMIC_FLOAT_2_FEATURES_EXT => {
|
||||
Some("PHYSICAL_DEVICE_SHADER_ATOMIC_FLOAT_2_FEATURES_EXT")
|
||||
}
|
||||
|
@ -5542,9 +5476,6 @@ impl fmt::Debug for StructureType {
|
|||
}
|
||||
Self::VIDEO_ENCODE_CAPABILITIES_KHR => Some("VIDEO_ENCODE_CAPABILITIES_KHR"),
|
||||
Self::VIDEO_ENCODE_USAGE_INFO_KHR => Some("VIDEO_ENCODE_USAGE_INFO_KHR"),
|
||||
Self::QUERY_POOL_VIDEO_ENCODE_FEEDBACK_CREATE_INFO_KHR => {
|
||||
Some("QUERY_POOL_VIDEO_ENCODE_FEEDBACK_CREATE_INFO_KHR")
|
||||
}
|
||||
Self::PHYSICAL_DEVICE_DIAGNOSTICS_CONFIG_FEATURES_NV => {
|
||||
Some("PHYSICAL_DEVICE_DIAGNOSTICS_CONFIG_FEATURES_NV")
|
||||
}
|
||||
|
@ -5552,7 +5483,6 @@ impl fmt::Debug for StructureType {
|
|||
Some("DEVICE_DIAGNOSTICS_CONFIG_CREATE_INFO_NV")
|
||||
}
|
||||
Self::RESERVED_QCOM => Some("RESERVED_QCOM"),
|
||||
Self::QUERY_LOW_LATENCY_SUPPORT_NV => Some("QUERY_LOW_LATENCY_SUPPORT_NV"),
|
||||
Self::EXPORT_METAL_OBJECT_CREATE_INFO_EXT => {
|
||||
Some("EXPORT_METAL_OBJECT_CREATE_INFO_EXT")
|
||||
}
|
||||
|
@ -5806,12 +5736,6 @@ impl fmt::Debug for StructureType {
|
|||
Self::PHYSICAL_DEVICE_IMAGE_2D_VIEW_OF_3D_FEATURES_EXT => {
|
||||
Some("PHYSICAL_DEVICE_IMAGE_2D_VIEW_OF_3D_FEATURES_EXT")
|
||||
}
|
||||
Self::PHYSICAL_DEVICE_SHADER_TILE_IMAGE_FEATURES_EXT => {
|
||||
Some("PHYSICAL_DEVICE_SHADER_TILE_IMAGE_FEATURES_EXT")
|
||||
}
|
||||
Self::PHYSICAL_DEVICE_SHADER_TILE_IMAGE_PROPERTIES_EXT => {
|
||||
Some("PHYSICAL_DEVICE_SHADER_TILE_IMAGE_PROPERTIES_EXT")
|
||||
}
|
||||
Self::MICROMAP_BUILD_INFO_EXT => Some("MICROMAP_BUILD_INFO_EXT"),
|
||||
Self::MICROMAP_VERSION_INFO_EXT => Some("MICROMAP_VERSION_INFO_EXT"),
|
||||
Self::COPY_MICROMAP_INFO_EXT => Some("COPY_MICROMAP_INFO_EXT"),
|
||||
|
@ -5828,21 +5752,6 @@ impl fmt::Debug for StructureType {
|
|||
Self::ACCELERATION_STRUCTURE_TRIANGLES_OPACITY_MICROMAP_EXT => {
|
||||
Some("ACCELERATION_STRUCTURE_TRIANGLES_OPACITY_MICROMAP_EXT")
|
||||
}
|
||||
Self::PHYSICAL_DEVICE_DISPLACEMENT_MICROMAP_FEATURES_NV => {
|
||||
Some("PHYSICAL_DEVICE_DISPLACEMENT_MICROMAP_FEATURES_NV")
|
||||
}
|
||||
Self::PHYSICAL_DEVICE_DISPLACEMENT_MICROMAP_PROPERTIES_NV => {
|
||||
Some("PHYSICAL_DEVICE_DISPLACEMENT_MICROMAP_PROPERTIES_NV")
|
||||
}
|
||||
Self::ACCELERATION_STRUCTURE_TRIANGLES_DISPLACEMENT_MICROMAP_NV => {
|
||||
Some("ACCELERATION_STRUCTURE_TRIANGLES_DISPLACEMENT_MICROMAP_NV")
|
||||
}
|
||||
Self::PHYSICAL_DEVICE_CLUSTER_CULLING_SHADER_FEATURES_HUAWEI => {
|
||||
Some("PHYSICAL_DEVICE_CLUSTER_CULLING_SHADER_FEATURES_HUAWEI")
|
||||
}
|
||||
Self::PHYSICAL_DEVICE_CLUSTER_CULLING_SHADER_PROPERTIES_HUAWEI => {
|
||||
Some("PHYSICAL_DEVICE_CLUSTER_CULLING_SHADER_PROPERTIES_HUAWEI")
|
||||
}
|
||||
Self::PHYSICAL_DEVICE_BORDER_COLOR_SWIZZLE_FEATURES_EXT => {
|
||||
Some("PHYSICAL_DEVICE_BORDER_COLOR_SWIZZLE_FEATURES_EXT")
|
||||
}
|
||||
|
@ -5852,13 +5761,6 @@ impl fmt::Debug for StructureType {
|
|||
Self::PHYSICAL_DEVICE_PAGEABLE_DEVICE_LOCAL_MEMORY_FEATURES_EXT => {
|
||||
Some("PHYSICAL_DEVICE_PAGEABLE_DEVICE_LOCAL_MEMORY_FEATURES_EXT")
|
||||
}
|
||||
Self::PHYSICAL_DEVICE_SHADER_CORE_PROPERTIES_ARM => {
|
||||
Some("PHYSICAL_DEVICE_SHADER_CORE_PROPERTIES_ARM")
|
||||
}
|
||||
Self::PHYSICAL_DEVICE_IMAGE_SLICED_VIEW_OF_3D_FEATURES_EXT => {
|
||||
Some("PHYSICAL_DEVICE_IMAGE_SLICED_VIEW_OF_3D_FEATURES_EXT")
|
||||
}
|
||||
Self::IMAGE_VIEW_SLICED_CREATE_INFO_EXT => Some("IMAGE_VIEW_SLICED_CREATE_INFO_EXT"),
|
||||
Self::PHYSICAL_DEVICE_DESCRIPTOR_SET_HOST_MAPPING_FEATURES_VALVE => {
|
||||
Some("PHYSICAL_DEVICE_DESCRIPTOR_SET_HOST_MAPPING_FEATURES_VALVE")
|
||||
}
|
||||
|
@ -5964,16 +5866,6 @@ impl fmt::Debug for StructureType {
|
|||
Self::PHYSICAL_DEVICE_PIPELINE_PROTECTED_ACCESS_FEATURES_EXT => {
|
||||
Some("PHYSICAL_DEVICE_PIPELINE_PROTECTED_ACCESS_FEATURES_EXT")
|
||||
}
|
||||
Self::PHYSICAL_DEVICE_RAY_TRACING_POSITION_FETCH_FEATURES_KHR => {
|
||||
Some("PHYSICAL_DEVICE_RAY_TRACING_POSITION_FETCH_FEATURES_KHR")
|
||||
}
|
||||
Self::PHYSICAL_DEVICE_SHADER_OBJECT_FEATURES_EXT => {
|
||||
Some("PHYSICAL_DEVICE_SHADER_OBJECT_FEATURES_EXT")
|
||||
}
|
||||
Self::PHYSICAL_DEVICE_SHADER_OBJECT_PROPERTIES_EXT => {
|
||||
Some("PHYSICAL_DEVICE_SHADER_OBJECT_PROPERTIES_EXT")
|
||||
}
|
||||
Self::SHADER_CREATE_INFO_EXT => Some("SHADER_CREATE_INFO_EXT"),
|
||||
Self::PHYSICAL_DEVICE_TILE_PROPERTIES_FEATURES_QCOM => {
|
||||
Some("PHYSICAL_DEVICE_TILE_PROPERTIES_FEATURES_QCOM")
|
||||
}
|
||||
|
@ -6003,21 +5895,6 @@ impl fmt::Debug for StructureType {
|
|||
Self::PHYSICAL_DEVICE_SHADER_CORE_BUILTINS_PROPERTIES_ARM => {
|
||||
Some("PHYSICAL_DEVICE_SHADER_CORE_BUILTINS_PROPERTIES_ARM")
|
||||
}
|
||||
Self::PHYSICAL_DEVICE_PIPELINE_LIBRARY_GROUP_HANDLES_FEATURES_EXT => {
|
||||
Some("PHYSICAL_DEVICE_PIPELINE_LIBRARY_GROUP_HANDLES_FEATURES_EXT")
|
||||
}
|
||||
Self::PHYSICAL_DEVICE_DYNAMIC_RENDERING_UNUSED_ATTACHMENTS_FEATURES_EXT => {
|
||||
Some("PHYSICAL_DEVICE_DYNAMIC_RENDERING_UNUSED_ATTACHMENTS_FEATURES_EXT")
|
||||
}
|
||||
Self::PHYSICAL_DEVICE_MULTIVIEW_PER_VIEW_RENDER_AREAS_FEATURES_QCOM => {
|
||||
Some("PHYSICAL_DEVICE_MULTIVIEW_PER_VIEW_RENDER_AREAS_FEATURES_QCOM")
|
||||
}
|
||||
Self::MULTIVIEW_PER_VIEW_RENDER_AREAS_RENDER_PASS_BEGIN_INFO_QCOM => {
|
||||
Some("MULTIVIEW_PER_VIEW_RENDER_AREAS_RENDER_PASS_BEGIN_INFO_QCOM")
|
||||
}
|
||||
Self::PHYSICAL_DEVICE_ATTACHMENT_FEEDBACK_LOOP_DYNAMIC_STATE_FEATURES_EXT => {
|
||||
Some("PHYSICAL_DEVICE_ATTACHMENT_FEEDBACK_LOOP_DYNAMIC_STATE_FEATURES_EXT")
|
||||
}
|
||||
Self::PHYSICAL_DEVICE_SUBGROUP_PROPERTIES => {
|
||||
Some("PHYSICAL_DEVICE_SUBGROUP_PROPERTIES")
|
||||
}
|
||||
|
@ -6673,7 +6550,6 @@ impl fmt::Debug for VendorId {
|
|||
Self::CODEPLAY => Some("CODEPLAY"),
|
||||
Self::MESA => Some("MESA"),
|
||||
Self::POCL => Some("POCL"),
|
||||
Self::MOBILEYE => Some("MOBILEYE"),
|
||||
_ => None,
|
||||
};
|
||||
if let Some(x) = name {
|
||||
|
@ -6852,21 +6728,6 @@ impl fmt::Debug for VideoEncodeContentFlagsKHR {
|
|||
debug_flags(f, KNOWN, self.0)
|
||||
}
|
||||
}
|
||||
impl fmt::Debug for VideoEncodeFeedbackFlagsKHR {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
const KNOWN: &[(Flags, &str)] = &[
|
||||
(
|
||||
VideoEncodeFeedbackFlagsKHR::BITSTREAM_BUFFER_OFFSET.0,
|
||||
"BITSTREAM_BUFFER_OFFSET",
|
||||
),
|
||||
(
|
||||
VideoEncodeFeedbackFlagsKHR::BITSTREAM_BYTES_WRITTEN.0,
|
||||
"BITSTREAM_BYTES_WRITTEN",
|
||||
),
|
||||
];
|
||||
debug_flags(f, KNOWN, self.0)
|
||||
}
|
||||
}
|
||||
impl fmt::Debug for VideoEncodeFlagsKHR {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
const KNOWN: &[(Flags, &str)] = &[];
|
||||
|
@ -6970,10 +6831,26 @@ impl fmt::Debug for VideoEncodeH264CapabilityFlagsEXT {
|
|||
VideoEncodeH264CapabilityFlagsEXT::B_FRAME_IN_L1_LIST.0,
|
||||
"B_FRAME_IN_L1_LIST",
|
||||
),
|
||||
(
|
||||
VideoEncodeH264CapabilityFlagsEXT::DIFFERENT_REFERENCE_FINAL_LISTS.0,
|
||||
"DIFFERENT_REFERENCE_FINAL_LISTS",
|
||||
),
|
||||
];
|
||||
debug_flags(f, KNOWN, self.0)
|
||||
}
|
||||
}
|
||||
impl fmt::Debug for VideoEncodeH264InputModeFlagsEXT {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
const KNOWN: &[(Flags, &str)] = &[
|
||||
(VideoEncodeH264InputModeFlagsEXT::FRAME.0, "FRAME"),
|
||||
(VideoEncodeH264InputModeFlagsEXT::SLICE.0, "SLICE"),
|
||||
(VideoEncodeH264InputModeFlagsEXT::NON_VCL.0, "NON_VCL"),
|
||||
];
|
||||
debug_flags(f, KNOWN, self.0)
|
||||
}
|
||||
}
|
||||
impl fmt::Debug for VideoEncodeH264OutputModeFlagsEXT {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
const KNOWN: &[(Flags, &str)] = &[
|
||||
(VideoEncodeH264OutputModeFlagsEXT::FRAME.0, "FRAME"),
|
||||
(VideoEncodeH264OutputModeFlagsEXT::SLICE.0, "SLICE"),
|
||||
(VideoEncodeH264OutputModeFlagsEXT::NON_VCL.0, "NON_VCL"),
|
||||
];
|
||||
debug_flags(f, KNOWN, self.0)
|
||||
}
|
||||
|
@ -7100,10 +6977,6 @@ impl fmt::Debug for VideoEncodeH265CapabilityFlagsEXT {
|
|||
VideoEncodeH265CapabilityFlagsEXT::B_FRAME_IN_L1_LIST.0,
|
||||
"B_FRAME_IN_L1_LIST",
|
||||
),
|
||||
(
|
||||
VideoEncodeH265CapabilityFlagsEXT::DIFFERENT_REFERENCE_FINAL_LISTS.0,
|
||||
"DIFFERENT_REFERENCE_FINAL_LISTS",
|
||||
),
|
||||
];
|
||||
debug_flags(f, KNOWN, self.0)
|
||||
}
|
||||
|
@ -7118,6 +6991,32 @@ impl fmt::Debug for VideoEncodeH265CtbSizeFlagsEXT {
|
|||
debug_flags(f, KNOWN, self.0)
|
||||
}
|
||||
}
|
||||
impl fmt::Debug for VideoEncodeH265InputModeFlagsEXT {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
const KNOWN: &[(Flags, &str)] = &[
|
||||
(VideoEncodeH265InputModeFlagsEXT::FRAME.0, "FRAME"),
|
||||
(
|
||||
VideoEncodeH265InputModeFlagsEXT::SLICE_SEGMENT.0,
|
||||
"SLICE_SEGMENT",
|
||||
),
|
||||
(VideoEncodeH265InputModeFlagsEXT::NON_VCL.0, "NON_VCL"),
|
||||
];
|
||||
debug_flags(f, KNOWN, self.0)
|
||||
}
|
||||
}
|
||||
impl fmt::Debug for VideoEncodeH265OutputModeFlagsEXT {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
const KNOWN: &[(Flags, &str)] = &[
|
||||
(VideoEncodeH265OutputModeFlagsEXT::FRAME.0, "FRAME"),
|
||||
(
|
||||
VideoEncodeH265OutputModeFlagsEXT::SLICE_SEGMENT.0,
|
||||
"SLICE_SEGMENT",
|
||||
),
|
||||
(VideoEncodeH265OutputModeFlagsEXT::NON_VCL.0, "NON_VCL"),
|
||||
];
|
||||
debug_flags(f, KNOWN, self.0)
|
||||
}
|
||||
}
|
||||
impl fmt::Debug for VideoEncodeH265RateControlStructureEXT {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
let name = match *self {
|
||||
|
@ -7165,8 +7064,7 @@ impl fmt::Debug for VideoEncodeRateControlFlagsKHR {
|
|||
impl fmt::Debug for VideoEncodeRateControlModeFlagsKHR {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
const KNOWN: &[(Flags, &str)] = &[
|
||||
(VideoEncodeRateControlModeFlagsKHR::DEFAULT.0, "DEFAULT"),
|
||||
(VideoEncodeRateControlModeFlagsKHR::DISABLED.0, "DISABLED"),
|
||||
(VideoEncodeRateControlModeFlagsKHR::NONE.0, "NONE"),
|
||||
(VideoEncodeRateControlModeFlagsKHR::CBR.0, "CBR"),
|
||||
(VideoEncodeRateControlModeFlagsKHR::VBR.0, "VBR"),
|
||||
];
|
||||
|
|
|
@ -10,7 +10,6 @@ pub const MAX_MEMORY_HEAPS: usize = 16;
|
|||
pub const LOD_CLAMP_NONE: f32 = 1000.00;
|
||||
pub const REMAINING_MIP_LEVELS: u32 = !0;
|
||||
pub const REMAINING_ARRAY_LAYERS: u32 = !0;
|
||||
pub const REMAINING_3D_SLICES_EXT: u32 = !0;
|
||||
pub const WHOLE_SIZE: u64 = !0;
|
||||
pub const ATTACHMENT_UNUSED: u32 = !0;
|
||||
pub const TRUE: Bool32 = 1;
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1744,8 +1744,6 @@ impl VendorId {
|
|||
pub const MESA: Self = Self(0x1_0005);
|
||||
#[doc = "PoCL vendor ID"]
|
||||
pub const POCL: Self = Self(0x1_0006);
|
||||
#[doc = "Mobileye vendor ID"]
|
||||
pub const MOBILEYE: Self = Self(0x1_0007);
|
||||
}
|
||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
|
||||
#[repr(transparent)]
|
||||
|
@ -1810,8 +1808,6 @@ impl DriverId {
|
|||
pub const MESA_DOZEN: Self = Self(23);
|
||||
#[doc = "Mesa open source project"]
|
||||
pub const MESA_NVK: Self = Self(24);
|
||||
#[doc = "Imagination Technologies"]
|
||||
pub const IMAGINATION_OPEN_SOURCE_MESA: Self = Self(25);
|
||||
}
|
||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
|
||||
#[repr(transparent)]
|
||||
|
@ -2784,43 +2780,6 @@ impl DeviceFaultVendorBinaryHeaderVersionEXT {
|
|||
impl DeviceFaultVendorBinaryHeaderVersionEXT {
|
||||
pub const ONE: Self = Self(1);
|
||||
}
|
||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
|
||||
#[repr(transparent)]
|
||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VkDisplacementMicromapFormatNV.html>"]
|
||||
pub struct DisplacementMicromapFormatNV(pub(crate) i32);
|
||||
impl DisplacementMicromapFormatNV {
|
||||
#[inline]
|
||||
pub const fn from_raw(x: i32) -> Self {
|
||||
Self(x)
|
||||
}
|
||||
#[inline]
|
||||
pub const fn as_raw(self) -> i32 {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
impl DisplacementMicromapFormatNV {
|
||||
pub const TYPE_64_TRIANGLES_64_BYTES: Self = Self(1);
|
||||
pub const TYPE_256_TRIANGLES_128_BYTES: Self = Self(2);
|
||||
pub const TYPE_1024_TRIANGLES_128_BYTES: Self = Self(3);
|
||||
}
|
||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
|
||||
#[repr(transparent)]
|
||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VkShaderCodeTypeEXT.html>"]
|
||||
pub struct ShaderCodeTypeEXT(pub(crate) i32);
|
||||
impl ShaderCodeTypeEXT {
|
||||
#[inline]
|
||||
pub const fn from_raw(x: i32) -> Self {
|
||||
Self(x)
|
||||
}
|
||||
#[inline]
|
||||
pub const fn as_raw(self) -> i32 {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
impl ShaderCodeTypeEXT {
|
||||
pub const BINARY: Self = Self(0);
|
||||
pub const SPIRV: Self = Self(1);
|
||||
}
|
||||
impl fmt::Debug for ObjectType {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
let name = match *self {
|
||||
|
@ -2869,7 +2828,6 @@ impl fmt::Debug for ObjectType {
|
|||
Self::BUFFER_COLLECTION_FUCHSIA => Some("BUFFER_COLLECTION_FUCHSIA"),
|
||||
Self::MICROMAP_EXT => Some("MICROMAP_EXT"),
|
||||
Self::OPTICAL_FLOW_SESSION_NV => Some("OPTICAL_FLOW_SESSION_NV"),
|
||||
Self::SHADER_EXT => Some("SHADER_EXT"),
|
||||
Self::SAMPLER_YCBCR_CONVERSION => Some("SAMPLER_YCBCR_CONVERSION"),
|
||||
Self::DESCRIPTOR_UPDATE_TEMPLATE => Some("DESCRIPTOR_UPDATE_TEMPLATE"),
|
||||
Self::PRIVATE_DATA_SLOT => Some("PRIVATE_DATA_SLOT"),
|
||||
|
@ -2940,13 +2898,7 @@ impl fmt::Debug for Result {
|
|||
Self::THREAD_DONE_KHR => Some("THREAD_DONE_KHR"),
|
||||
Self::OPERATION_DEFERRED_KHR => Some("OPERATION_DEFERRED_KHR"),
|
||||
Self::OPERATION_NOT_DEFERRED_KHR => Some("OPERATION_NOT_DEFERRED_KHR"),
|
||||
Self::ERROR_INVALID_VIDEO_STD_PARAMETERS_KHR => {
|
||||
Some("ERROR_INVALID_VIDEO_STD_PARAMETERS_KHR")
|
||||
}
|
||||
Self::ERROR_COMPRESSION_EXHAUSTED_EXT => Some("ERROR_COMPRESSION_EXHAUSTED_EXT"),
|
||||
Self::ERROR_INCOMPATIBLE_SHADER_BINARY_EXT => {
|
||||
Some("ERROR_INCOMPATIBLE_SHADER_BINARY_EXT")
|
||||
}
|
||||
Self::ERROR_OUT_OF_POOL_MEMORY => Some("ERROR_OUT_OF_POOL_MEMORY"),
|
||||
Self::ERROR_INVALID_EXTERNAL_HANDLE => Some("ERROR_INVALID_EXTERNAL_HANDLE"),
|
||||
Self::ERROR_FRAGMENTATION => Some("ERROR_FRAGMENTATION"),
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -999,7 +999,7 @@ pub type PFN_vkCmdSetDepthBias = unsafe extern "system" fn(
|
|||
);
|
||||
#[allow(non_camel_case_types)]
|
||||
pub type PFN_vkCmdSetBlendConstants =
|
||||
unsafe extern "system" fn(command_buffer: CommandBuffer, blend_constants: *const [f32; 4usize]);
|
||||
unsafe extern "system" fn(command_buffer: CommandBuffer, blend_constants: *const [f32; 4]);
|
||||
#[allow(non_camel_case_types)]
|
||||
pub type PFN_vkCmdSetDepthBounds = unsafe extern "system" fn(
|
||||
command_buffer: CommandBuffer,
|
||||
|
@ -2876,7 +2876,7 @@ impl DeviceFnV1_0 {
|
|||
cmd_set_blend_constants: unsafe {
|
||||
unsafe extern "system" fn cmd_set_blend_constants(
|
||||
_command_buffer: CommandBuffer,
|
||||
_blend_constants: *const [f32; 4usize],
|
||||
_blend_constants: *const [f32; 4],
|
||||
) {
|
||||
panic!(concat!(
|
||||
"Unable to load ",
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* automatically generated by rust-bindgen 0.64.0 */
|
||||
/* automatically generated by rust-bindgen 0.61.0 */
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
|
||||
|
@ -7050,48 +7050,42 @@ impl StdVideoEncodeH264ReferenceInfoFlags {
|
|||
#[repr(C)]
|
||||
#[repr(align(4))]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct StdVideoEncodeH264ReferenceListsInfoFlags {
|
||||
pub struct StdVideoEncodeH264RefMgmtFlags {
|
||||
pub _bitfield_align_1: [u8; 0],
|
||||
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>,
|
||||
pub __bindgen_padding_0: [u8; 3usize],
|
||||
}
|
||||
#[test]
|
||||
fn bindgen_test_layout_StdVideoEncodeH264ReferenceListsInfoFlags() {
|
||||
fn bindgen_test_layout_StdVideoEncodeH264RefMgmtFlags() {
|
||||
assert_eq!(
|
||||
::std::mem::size_of::<StdVideoEncodeH264ReferenceListsInfoFlags>(),
|
||||
::std::mem::size_of::<StdVideoEncodeH264RefMgmtFlags>(),
|
||||
4usize,
|
||||
concat!(
|
||||
"Size of: ",
|
||||
stringify!(StdVideoEncodeH264ReferenceListsInfoFlags)
|
||||
)
|
||||
concat!("Size of: ", stringify!(StdVideoEncodeH264RefMgmtFlags))
|
||||
);
|
||||
assert_eq!(
|
||||
::std::mem::align_of::<StdVideoEncodeH264ReferenceListsInfoFlags>(),
|
||||
::std::mem::align_of::<StdVideoEncodeH264RefMgmtFlags>(),
|
||||
4usize,
|
||||
concat!(
|
||||
"Alignment of ",
|
||||
stringify!(StdVideoEncodeH264ReferenceListsInfoFlags)
|
||||
)
|
||||
concat!("Alignment of ", stringify!(StdVideoEncodeH264RefMgmtFlags))
|
||||
);
|
||||
}
|
||||
impl StdVideoEncodeH264ReferenceListsInfoFlags {
|
||||
impl StdVideoEncodeH264RefMgmtFlags {
|
||||
#[inline]
|
||||
pub fn ref_pic_list_modification_flag_l0(&self) -> u32 {
|
||||
pub fn ref_pic_list_modification_l0_flag(&self) -> u32 {
|
||||
unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u32) }
|
||||
}
|
||||
#[inline]
|
||||
pub fn set_ref_pic_list_modification_flag_l0(&mut self, val: u32) {
|
||||
pub fn set_ref_pic_list_modification_l0_flag(&mut self, val: u32) {
|
||||
unsafe {
|
||||
let val: u32 = ::std::mem::transmute(val);
|
||||
self._bitfield_1.set(0usize, 1u8, val as u64)
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
pub fn ref_pic_list_modification_flag_l1(&self) -> u32 {
|
||||
pub fn ref_pic_list_modification_l1_flag(&self) -> u32 {
|
||||
unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u32) }
|
||||
}
|
||||
#[inline]
|
||||
pub fn set_ref_pic_list_modification_flag_l1(&mut self, val: u32) {
|
||||
pub fn set_ref_pic_list_modification_l1_flag(&mut self, val: u32) {
|
||||
unsafe {
|
||||
let val: u32 = ::std::mem::transmute(val);
|
||||
self._bitfield_1.set(1usize, 1u8, val as u64)
|
||||
|
@ -7099,19 +7093,19 @@ impl StdVideoEncodeH264ReferenceListsInfoFlags {
|
|||
}
|
||||
#[inline]
|
||||
pub fn new_bitfield_1(
|
||||
ref_pic_list_modification_flag_l0: u32,
|
||||
ref_pic_list_modification_flag_l1: u32,
|
||||
ref_pic_list_modification_l0_flag: u32,
|
||||
ref_pic_list_modification_l1_flag: u32,
|
||||
) -> __BindgenBitfieldUnit<[u8; 1usize]> {
|
||||
let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default();
|
||||
__bindgen_bitfield_unit.set(0usize, 1u8, {
|
||||
let ref_pic_list_modification_flag_l0: u32 =
|
||||
unsafe { ::std::mem::transmute(ref_pic_list_modification_flag_l0) };
|
||||
ref_pic_list_modification_flag_l0 as u64
|
||||
let ref_pic_list_modification_l0_flag: u32 =
|
||||
unsafe { ::std::mem::transmute(ref_pic_list_modification_l0_flag) };
|
||||
ref_pic_list_modification_l0_flag as u64
|
||||
});
|
||||
__bindgen_bitfield_unit.set(1usize, 1u8, {
|
||||
let ref_pic_list_modification_flag_l1: u32 =
|
||||
unsafe { ::std::mem::transmute(ref_pic_list_modification_flag_l1) };
|
||||
ref_pic_list_modification_flag_l1 as u64
|
||||
let ref_pic_list_modification_l1_flag: u32 =
|
||||
unsafe { ::std::mem::transmute(ref_pic_list_modification_l1_flag) };
|
||||
ref_pic_list_modification_l1_flag as u64
|
||||
});
|
||||
__bindgen_bitfield_unit
|
||||
}
|
||||
|
@ -7261,39 +7255,34 @@ fn bindgen_test_layout_StdVideoEncodeH264RefPicMarkingEntry() {
|
|||
}
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct StdVideoEncodeH264ReferenceListsInfo {
|
||||
pub flags: StdVideoEncodeH264ReferenceListsInfoFlags,
|
||||
pub refPicList0EntryCount: u8,
|
||||
pub refPicList1EntryCount: u8,
|
||||
pub struct StdVideoEncodeH264RefMemMgmtCtrlOperations {
|
||||
pub flags: StdVideoEncodeH264RefMgmtFlags,
|
||||
pub refList0ModOpCount: u8,
|
||||
pub refList1ModOpCount: u8,
|
||||
pub refPicMarkingOpCount: u8,
|
||||
pub reserved1: [u8; 7usize],
|
||||
pub pRefPicList0Entries: *const u8,
|
||||
pub pRefPicList1Entries: *const u8,
|
||||
pub pRefList0ModOperations: *const StdVideoEncodeH264RefListModEntry,
|
||||
pub refList1ModOpCount: u8,
|
||||
pub pRefList1ModOperations: *const StdVideoEncodeH264RefListModEntry,
|
||||
pub refPicMarkingOpCount: u8,
|
||||
pub pRefPicMarkingOperations: *const StdVideoEncodeH264RefPicMarkingEntry,
|
||||
}
|
||||
#[test]
|
||||
fn bindgen_test_layout_StdVideoEncodeH264ReferenceListsInfo() {
|
||||
const UNINIT: ::std::mem::MaybeUninit<StdVideoEncodeH264ReferenceListsInfo> =
|
||||
fn bindgen_test_layout_StdVideoEncodeH264RefMemMgmtCtrlOperations() {
|
||||
const UNINIT: ::std::mem::MaybeUninit<StdVideoEncodeH264RefMemMgmtCtrlOperations> =
|
||||
::std::mem::MaybeUninit::uninit();
|
||||
let ptr = UNINIT.as_ptr();
|
||||
assert_eq!(
|
||||
::std::mem::size_of::<StdVideoEncodeH264ReferenceListsInfo>(),
|
||||
56usize,
|
||||
::std::mem::size_of::<StdVideoEncodeH264RefMemMgmtCtrlOperations>(),
|
||||
48usize,
|
||||
concat!(
|
||||
"Size of: ",
|
||||
stringify!(StdVideoEncodeH264ReferenceListsInfo)
|
||||
stringify!(StdVideoEncodeH264RefMemMgmtCtrlOperations)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
::std::mem::align_of::<StdVideoEncodeH264ReferenceListsInfo>(),
|
||||
::std::mem::align_of::<StdVideoEncodeH264RefMemMgmtCtrlOperations>(),
|
||||
8usize,
|
||||
concat!(
|
||||
"Alignment of ",
|
||||
stringify!(StdVideoEncodeH264ReferenceListsInfo)
|
||||
stringify!(StdVideoEncodeH264RefMemMgmtCtrlOperations)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
|
@ -7301,117 +7290,67 @@ fn bindgen_test_layout_StdVideoEncodeH264ReferenceListsInfo() {
|
|||
0usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(StdVideoEncodeH264ReferenceListsInfo),
|
||||
stringify!(StdVideoEncodeH264RefMemMgmtCtrlOperations),
|
||||
"::",
|
||||
stringify!(flags)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe { ::std::ptr::addr_of!((*ptr).refPicList0EntryCount) as usize - ptr as usize },
|
||||
unsafe { ::std::ptr::addr_of!((*ptr).refList0ModOpCount) as usize - ptr as usize },
|
||||
4usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(StdVideoEncodeH264ReferenceListsInfo),
|
||||
"::",
|
||||
stringify!(refPicList0EntryCount)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe { ::std::ptr::addr_of!((*ptr).refPicList1EntryCount) as usize - ptr as usize },
|
||||
5usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(StdVideoEncodeH264ReferenceListsInfo),
|
||||
"::",
|
||||
stringify!(refPicList1EntryCount)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe { ::std::ptr::addr_of!((*ptr).refList0ModOpCount) as usize - ptr as usize },
|
||||
6usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(StdVideoEncodeH264ReferenceListsInfo),
|
||||
stringify!(StdVideoEncodeH264RefMemMgmtCtrlOperations),
|
||||
"::",
|
||||
stringify!(refList0ModOpCount)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe { ::std::ptr::addr_of!((*ptr).refList1ModOpCount) as usize - ptr as usize },
|
||||
7usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(StdVideoEncodeH264ReferenceListsInfo),
|
||||
"::",
|
||||
stringify!(refList1ModOpCount)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe { ::std::ptr::addr_of!((*ptr).refPicMarkingOpCount) as usize - ptr as usize },
|
||||
unsafe { ::std::ptr::addr_of!((*ptr).pRefList0ModOperations) as usize - ptr as usize },
|
||||
8usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(StdVideoEncodeH264ReferenceListsInfo),
|
||||
"::",
|
||||
stringify!(refPicMarkingOpCount)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe { ::std::ptr::addr_of!((*ptr).reserved1) as usize - ptr as usize },
|
||||
9usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(StdVideoEncodeH264ReferenceListsInfo),
|
||||
"::",
|
||||
stringify!(reserved1)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe { ::std::ptr::addr_of!((*ptr).pRefPicList0Entries) as usize - ptr as usize },
|
||||
16usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(StdVideoEncodeH264ReferenceListsInfo),
|
||||
"::",
|
||||
stringify!(pRefPicList0Entries)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe { ::std::ptr::addr_of!((*ptr).pRefPicList1Entries) as usize - ptr as usize },
|
||||
24usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(StdVideoEncodeH264ReferenceListsInfo),
|
||||
"::",
|
||||
stringify!(pRefPicList1Entries)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe { ::std::ptr::addr_of!((*ptr).pRefList0ModOperations) as usize - ptr as usize },
|
||||
32usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(StdVideoEncodeH264ReferenceListsInfo),
|
||||
stringify!(StdVideoEncodeH264RefMemMgmtCtrlOperations),
|
||||
"::",
|
||||
stringify!(pRefList0ModOperations)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe { ::std::ptr::addr_of!((*ptr).pRefList1ModOperations) as usize - ptr as usize },
|
||||
40usize,
|
||||
unsafe { ::std::ptr::addr_of!((*ptr).refList1ModOpCount) as usize - ptr as usize },
|
||||
16usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(StdVideoEncodeH264ReferenceListsInfo),
|
||||
stringify!(StdVideoEncodeH264RefMemMgmtCtrlOperations),
|
||||
"::",
|
||||
stringify!(refList1ModOpCount)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe { ::std::ptr::addr_of!((*ptr).pRefList1ModOperations) as usize - ptr as usize },
|
||||
24usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(StdVideoEncodeH264RefMemMgmtCtrlOperations),
|
||||
"::",
|
||||
stringify!(pRefList1ModOperations)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe { ::std::ptr::addr_of!((*ptr).pRefPicMarkingOperations) as usize - ptr as usize },
|
||||
48usize,
|
||||
unsafe { ::std::ptr::addr_of!((*ptr).refPicMarkingOpCount) as usize - ptr as usize },
|
||||
32usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(StdVideoEncodeH264ReferenceListsInfo),
|
||||
stringify!(StdVideoEncodeH264RefMemMgmtCtrlOperations),
|
||||
"::",
|
||||
stringify!(refPicMarkingOpCount)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe { ::std::ptr::addr_of!((*ptr).pRefPicMarkingOperations) as usize - ptr as usize },
|
||||
40usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(StdVideoEncodeH264RefMemMgmtCtrlOperations),
|
||||
"::",
|
||||
stringify!(pRefPicMarkingOperations)
|
||||
)
|
||||
|
@ -7423,7 +7362,6 @@ pub struct StdVideoEncodeH264PictureInfo {
|
|||
pub flags: StdVideoEncodeH264PictureInfoFlags,
|
||||
pub seq_parameter_set_id: u8,
|
||||
pub pic_parameter_set_id: u8,
|
||||
pub reserved1: u16,
|
||||
pub pictureType: StdVideoH264PictureType,
|
||||
pub frame_num: u32,
|
||||
pub PicOrderCnt: i32,
|
||||
|
@ -7473,16 +7411,6 @@ fn bindgen_test_layout_StdVideoEncodeH264PictureInfo() {
|
|||
stringify!(pic_parameter_set_id)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe { ::std::ptr::addr_of!((*ptr).reserved1) as usize - ptr as usize },
|
||||
6usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(StdVideoEncodeH264PictureInfo),
|
||||
"::",
|
||||
stringify!(reserved1)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe { ::std::ptr::addr_of!((*ptr).pictureType) as usize - ptr as usize },
|
||||
8usize,
|
||||
|
@ -7518,7 +7446,6 @@ fn bindgen_test_layout_StdVideoEncodeH264PictureInfo() {
|
|||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct StdVideoEncodeH264ReferenceInfo {
|
||||
pub flags: StdVideoEncodeH264ReferenceInfoFlags,
|
||||
pub pictureType: StdVideoH264PictureType,
|
||||
pub FrameNum: u32,
|
||||
pub PicOrderCnt: i32,
|
||||
pub long_term_pic_num: u16,
|
||||
|
@ -7531,7 +7458,7 @@ fn bindgen_test_layout_StdVideoEncodeH264ReferenceInfo() {
|
|||
let ptr = UNINIT.as_ptr();
|
||||
assert_eq!(
|
||||
::std::mem::size_of::<StdVideoEncodeH264ReferenceInfo>(),
|
||||
20usize,
|
||||
16usize,
|
||||
concat!("Size of: ", stringify!(StdVideoEncodeH264ReferenceInfo))
|
||||
);
|
||||
assert_eq!(
|
||||
|
@ -7549,19 +7476,9 @@ fn bindgen_test_layout_StdVideoEncodeH264ReferenceInfo() {
|
|||
stringify!(flags)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe { ::std::ptr::addr_of!((*ptr).pictureType) as usize - ptr as usize },
|
||||
4usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(StdVideoEncodeH264ReferenceInfo),
|
||||
"::",
|
||||
stringify!(pictureType)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe { ::std::ptr::addr_of!((*ptr).FrameNum) as usize - ptr as usize },
|
||||
8usize,
|
||||
4usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(StdVideoEncodeH264ReferenceInfo),
|
||||
|
@ -7571,7 +7488,7 @@ fn bindgen_test_layout_StdVideoEncodeH264ReferenceInfo() {
|
|||
);
|
||||
assert_eq!(
|
||||
unsafe { ::std::ptr::addr_of!((*ptr).PicOrderCnt) as usize - ptr as usize },
|
||||
12usize,
|
||||
8usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(StdVideoEncodeH264ReferenceInfo),
|
||||
|
@ -7581,7 +7498,7 @@ fn bindgen_test_layout_StdVideoEncodeH264ReferenceInfo() {
|
|||
);
|
||||
assert_eq!(
|
||||
unsafe { ::std::ptr::addr_of!((*ptr).long_term_pic_num) as usize - ptr as usize },
|
||||
16usize,
|
||||
12usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(StdVideoEncodeH264ReferenceInfo),
|
||||
|
@ -7591,7 +7508,7 @@ fn bindgen_test_layout_StdVideoEncodeH264ReferenceInfo() {
|
|||
);
|
||||
assert_eq!(
|
||||
unsafe { ::std::ptr::addr_of!((*ptr).long_term_frame_idx) as usize - ptr as usize },
|
||||
18usize,
|
||||
14usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(StdVideoEncodeH264ReferenceInfo),
|
||||
|
@ -7613,8 +7530,6 @@ pub struct StdVideoEncodeH264SliceHeader {
|
|||
pub disable_deblocking_filter_idc: StdVideoH264DisableDeblockingFilterIdc,
|
||||
pub slice_alpha_c0_offset_div2: i8,
|
||||
pub slice_beta_offset_div2: i8,
|
||||
pub reserved1: u16,
|
||||
pub reserved2: u32,
|
||||
pub pWeightTable: *const StdVideoEncodeH264WeightTable,
|
||||
}
|
||||
#[test]
|
||||
|
@ -7738,26 +7653,6 @@ fn bindgen_test_layout_StdVideoEncodeH264SliceHeader() {
|
|||
stringify!(slice_beta_offset_div2)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe { ::std::ptr::addr_of!((*ptr).reserved1) as usize - ptr as usize },
|
||||
26usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(StdVideoEncodeH264SliceHeader),
|
||||
"::",
|
||||
stringify!(reserved1)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe { ::std::ptr::addr_of!((*ptr).reserved2) as usize - ptr as usize },
|
||||
28usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(StdVideoEncodeH264SliceHeader),
|
||||
"::",
|
||||
stringify!(reserved2)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe { ::std::ptr::addr_of!((*ptr).pWeightTable) as usize - ptr as usize },
|
||||
32usize,
|
||||
|
@ -8616,31 +8511,31 @@ fn bindgen_test_layout_StdVideoEncodeH265SliceSegmentHeader() {
|
|||
#[repr(C)]
|
||||
#[repr(align(4))]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct StdVideoEncodeH265ReferenceListsInfoFlags {
|
||||
pub struct StdVideoEncodeH265ReferenceModificationFlags {
|
||||
pub _bitfield_align_1: [u8; 0],
|
||||
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>,
|
||||
pub __bindgen_padding_0: [u8; 3usize],
|
||||
}
|
||||
#[test]
|
||||
fn bindgen_test_layout_StdVideoEncodeH265ReferenceListsInfoFlags() {
|
||||
fn bindgen_test_layout_StdVideoEncodeH265ReferenceModificationFlags() {
|
||||
assert_eq!(
|
||||
::std::mem::size_of::<StdVideoEncodeH265ReferenceListsInfoFlags>(),
|
||||
::std::mem::size_of::<StdVideoEncodeH265ReferenceModificationFlags>(),
|
||||
4usize,
|
||||
concat!(
|
||||
"Size of: ",
|
||||
stringify!(StdVideoEncodeH265ReferenceListsInfoFlags)
|
||||
stringify!(StdVideoEncodeH265ReferenceModificationFlags)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
::std::mem::align_of::<StdVideoEncodeH265ReferenceListsInfoFlags>(),
|
||||
::std::mem::align_of::<StdVideoEncodeH265ReferenceModificationFlags>(),
|
||||
4usize,
|
||||
concat!(
|
||||
"Alignment of ",
|
||||
stringify!(StdVideoEncodeH265ReferenceListsInfoFlags)
|
||||
stringify!(StdVideoEncodeH265ReferenceModificationFlags)
|
||||
)
|
||||
);
|
||||
}
|
||||
impl StdVideoEncodeH265ReferenceListsInfoFlags {
|
||||
impl StdVideoEncodeH265ReferenceModificationFlags {
|
||||
#[inline]
|
||||
pub fn ref_pic_list_modification_flag_l0(&self) -> u32 {
|
||||
unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u32) }
|
||||
|
@ -8684,35 +8579,32 @@ impl StdVideoEncodeH265ReferenceListsInfoFlags {
|
|||
}
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct StdVideoEncodeH265ReferenceListsInfo {
|
||||
pub flags: StdVideoEncodeH265ReferenceListsInfoFlags,
|
||||
pub num_ref_idx_l0_active_minus1: u8,
|
||||
pub num_ref_idx_l1_active_minus1: u8,
|
||||
pub reserved1: u16,
|
||||
pub pRefPicList0Entries: *const u8,
|
||||
pub pRefPicList1Entries: *const u8,
|
||||
pub pRefList0Modifications: *const u8,
|
||||
pub pRefList1Modifications: *const u8,
|
||||
pub struct StdVideoEncodeH265ReferenceModifications {
|
||||
pub flags: StdVideoEncodeH265ReferenceModificationFlags,
|
||||
pub referenceList0ModificationsCount: u8,
|
||||
pub pReferenceList0Modifications: *const u8,
|
||||
pub referenceList1ModificationsCount: u8,
|
||||
pub pReferenceList1Modifications: *const u8,
|
||||
}
|
||||
#[test]
|
||||
fn bindgen_test_layout_StdVideoEncodeH265ReferenceListsInfo() {
|
||||
const UNINIT: ::std::mem::MaybeUninit<StdVideoEncodeH265ReferenceListsInfo> =
|
||||
fn bindgen_test_layout_StdVideoEncodeH265ReferenceModifications() {
|
||||
const UNINIT: ::std::mem::MaybeUninit<StdVideoEncodeH265ReferenceModifications> =
|
||||
::std::mem::MaybeUninit::uninit();
|
||||
let ptr = UNINIT.as_ptr();
|
||||
assert_eq!(
|
||||
::std::mem::size_of::<StdVideoEncodeH265ReferenceListsInfo>(),
|
||||
40usize,
|
||||
::std::mem::size_of::<StdVideoEncodeH265ReferenceModifications>(),
|
||||
32usize,
|
||||
concat!(
|
||||
"Size of: ",
|
||||
stringify!(StdVideoEncodeH265ReferenceListsInfo)
|
||||
stringify!(StdVideoEncodeH265ReferenceModifications)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
::std::mem::align_of::<StdVideoEncodeH265ReferenceListsInfo>(),
|
||||
::std::mem::align_of::<StdVideoEncodeH265ReferenceModifications>(),
|
||||
8usize,
|
||||
concat!(
|
||||
"Alignment of ",
|
||||
stringify!(StdVideoEncodeH265ReferenceListsInfo)
|
||||
stringify!(StdVideoEncodeH265ReferenceModifications)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
|
@ -8720,83 +8612,57 @@ fn bindgen_test_layout_StdVideoEncodeH265ReferenceListsInfo() {
|
|||
0usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(StdVideoEncodeH265ReferenceListsInfo),
|
||||
stringify!(StdVideoEncodeH265ReferenceModifications),
|
||||
"::",
|
||||
stringify!(flags)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe {
|
||||
::std::ptr::addr_of!((*ptr).num_ref_idx_l0_active_minus1) as usize - ptr as usize
|
||||
::std::ptr::addr_of!((*ptr).referenceList0ModificationsCount) as usize - ptr as usize
|
||||
},
|
||||
4usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(StdVideoEncodeH265ReferenceListsInfo),
|
||||
stringify!(StdVideoEncodeH265ReferenceModifications),
|
||||
"::",
|
||||
stringify!(num_ref_idx_l0_active_minus1)
|
||||
stringify!(referenceList0ModificationsCount)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe {
|
||||
::std::ptr::addr_of!((*ptr).num_ref_idx_l1_active_minus1) as usize - ptr as usize
|
||||
::std::ptr::addr_of!((*ptr).pReferenceList0Modifications) as usize - ptr as usize
|
||||
},
|
||||
5usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(StdVideoEncodeH265ReferenceListsInfo),
|
||||
"::",
|
||||
stringify!(num_ref_idx_l1_active_minus1)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe { ::std::ptr::addr_of!((*ptr).reserved1) as usize - ptr as usize },
|
||||
6usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(StdVideoEncodeH265ReferenceListsInfo),
|
||||
"::",
|
||||
stringify!(reserved1)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe { ::std::ptr::addr_of!((*ptr).pRefPicList0Entries) as usize - ptr as usize },
|
||||
8usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(StdVideoEncodeH265ReferenceListsInfo),
|
||||
stringify!(StdVideoEncodeH265ReferenceModifications),
|
||||
"::",
|
||||
stringify!(pRefPicList0Entries)
|
||||
stringify!(pReferenceList0Modifications)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe { ::std::ptr::addr_of!((*ptr).pRefPicList1Entries) as usize - ptr as usize },
|
||||
unsafe {
|
||||
::std::ptr::addr_of!((*ptr).referenceList1ModificationsCount) as usize - ptr as usize
|
||||
},
|
||||
16usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(StdVideoEncodeH265ReferenceListsInfo),
|
||||
stringify!(StdVideoEncodeH265ReferenceModifications),
|
||||
"::",
|
||||
stringify!(pRefPicList1Entries)
|
||||
stringify!(referenceList1ModificationsCount)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe { ::std::ptr::addr_of!((*ptr).pRefList0Modifications) as usize - ptr as usize },
|
||||
unsafe {
|
||||
::std::ptr::addr_of!((*ptr).pReferenceList1Modifications) as usize - ptr as usize
|
||||
},
|
||||
24usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(StdVideoEncodeH265ReferenceListsInfo),
|
||||
stringify!(StdVideoEncodeH265ReferenceModifications),
|
||||
"::",
|
||||
stringify!(pRefList0Modifications)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe { ::std::ptr::addr_of!((*ptr).pRefList1Modifications) as usize - ptr as usize },
|
||||
32usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(StdVideoEncodeH265ReferenceListsInfo),
|
||||
"::",
|
||||
stringify!(pRefList1Modifications)
|
||||
stringify!(pReferenceList1Modifications)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -8920,8 +8786,8 @@ pub struct StdVideoEncodeH265PictureInfo {
|
|||
pub sps_video_parameter_set_id: u8,
|
||||
pub pps_seq_parameter_set_id: u8,
|
||||
pub pps_pic_parameter_set_id: u8,
|
||||
pub TemporalId: u8,
|
||||
pub PicOrderCntVal: i32,
|
||||
pub TemporalId: u8,
|
||||
}
|
||||
#[test]
|
||||
fn bindgen_test_layout_StdVideoEncodeH265PictureInfo() {
|
||||
|
@ -8930,7 +8796,7 @@ fn bindgen_test_layout_StdVideoEncodeH265PictureInfo() {
|
|||
let ptr = UNINIT.as_ptr();
|
||||
assert_eq!(
|
||||
::std::mem::size_of::<StdVideoEncodeH265PictureInfo>(),
|
||||
16usize,
|
||||
20usize,
|
||||
concat!("Size of: ", stringify!(StdVideoEncodeH265PictureInfo))
|
||||
);
|
||||
assert_eq!(
|
||||
|
@ -8988,16 +8854,6 @@ fn bindgen_test_layout_StdVideoEncodeH265PictureInfo() {
|
|||
stringify!(pps_pic_parameter_set_id)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe { ::std::ptr::addr_of!((*ptr).TemporalId) as usize - ptr as usize },
|
||||
11usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(StdVideoEncodeH265PictureInfo),
|
||||
"::",
|
||||
stringify!(TemporalId)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe { ::std::ptr::addr_of!((*ptr).PicOrderCntVal) as usize - ptr as usize },
|
||||
12usize,
|
||||
|
@ -9008,6 +8864,16 @@ fn bindgen_test_layout_StdVideoEncodeH265PictureInfo() {
|
|||
stringify!(PicOrderCntVal)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe { ::std::ptr::addr_of!((*ptr).TemporalId) as usize - ptr as usize },
|
||||
16usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(StdVideoEncodeH265PictureInfo),
|
||||
"::",
|
||||
stringify!(TemporalId)
|
||||
)
|
||||
);
|
||||
}
|
||||
#[repr(C)]
|
||||
#[repr(align(4))]
|
||||
|
@ -9081,7 +8947,6 @@ impl StdVideoEncodeH265ReferenceInfoFlags {
|
|||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct StdVideoEncodeH265ReferenceInfo {
|
||||
pub flags: StdVideoEncodeH265ReferenceInfoFlags,
|
||||
pub PictureType: StdVideoH265PictureType,
|
||||
pub PicOrderCntVal: i32,
|
||||
pub TemporalId: u8,
|
||||
}
|
||||
|
@ -9092,7 +8957,7 @@ fn bindgen_test_layout_StdVideoEncodeH265ReferenceInfo() {
|
|||
let ptr = UNINIT.as_ptr();
|
||||
assert_eq!(
|
||||
::std::mem::size_of::<StdVideoEncodeH265ReferenceInfo>(),
|
||||
16usize,
|
||||
12usize,
|
||||
concat!("Size of: ", stringify!(StdVideoEncodeH265ReferenceInfo))
|
||||
);
|
||||
assert_eq!(
|
||||
|
@ -9110,19 +8975,9 @@ fn bindgen_test_layout_StdVideoEncodeH265ReferenceInfo() {
|
|||
stringify!(flags)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe { ::std::ptr::addr_of!((*ptr).PictureType) as usize - ptr as usize },
|
||||
4usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(StdVideoEncodeH265ReferenceInfo),
|
||||
"::",
|
||||
stringify!(PictureType)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe { ::std::ptr::addr_of!((*ptr).PicOrderCntVal) as usize - ptr as usize },
|
||||
8usize,
|
||||
4usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(StdVideoEncodeH265ReferenceInfo),
|
||||
|
@ -9132,7 +8987,7 @@ fn bindgen_test_layout_StdVideoEncodeH265ReferenceInfo() {
|
|||
);
|
||||
assert_eq!(
|
||||
unsafe { ::std::ptr::addr_of!((*ptr).TemporalId) as usize - ptr as usize },
|
||||
12usize,
|
||||
8usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(StdVideoEncodeH265ReferenceInfo),
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"files":{"Cargo.toml":"cac07dfd7a2fcbb169a0c471a8a139ade8da91f92b7fbc198f3f2185d9c94d16","src/base.rs":"561db031cc746eab35a10fe72e10c314615b11e13cd48366fcdb2223196308a7","src/geometry.rs":"4ed03b07a4c5ba0f090689d31ef6eab8ec5b8f6eb7fb4e04fdf65e5ad8cd70ea","src/lib.rs":"31700ac9508fd32005bafd1c12a86a6803d198e9b1a71166a7391e642c091cd1"},"package":"2bb142d41022986c1d8ff29103a1411c8a3dfad3552f87a4f8dc50d61d4f4e33"}
|
||||
{"files":{"Cargo.toml":"e2e38d84cf514ad088ebc1909123ef4f707db6855528f938eb57d1e06c5a23ef","src/base.rs":"3764010f0c416db49be8a9e191fffb6848e8287edbdd5b12972613e301720ded","src/geometry.rs":"b94e50a16b8540dc6f37bfe4b1549ac68974cd6ba6c0bbd9209559f8a46d86eb","src/lib.rs":"31700ac9508fd32005bafd1c12a86a6803d198e9b1a71166a7391e642c091cd1"},"package":"3a68b68b3446082644c91ac778bf50cd4104bfb002b5a6a7c44cca5a2c70788b"}
|
|
@ -3,29 +3,31 @@
|
|||
# When uploading crates to the registry Cargo will automatically
|
||||
# "normalize" Cargo.toml files for maximal compatibility
|
||||
# with all versions of Cargo and also rewrite `path` dependencies
|
||||
# to registry (e.g., crates.io) dependencies.
|
||||
# to registry (e.g., crates.io) dependencies
|
||||
#
|
||||
# If you are reading this file be aware that the original Cargo.toml
|
||||
# will likely look very different (and much more reasonable).
|
||||
# See Cargo.toml.orig for the original contents.
|
||||
# If you believe there's an error in this file please file an
|
||||
# issue against the rust-lang/cargo repository. If you're
|
||||
# editing this file be aware that the upstream Cargo.toml
|
||||
# will likely look very different (and much more reasonable)
|
||||
|
||||
[package]
|
||||
name = "core-graphics-types"
|
||||
version = "0.1.2"
|
||||
version = "0.1.1"
|
||||
authors = ["The Servo Project Developers"]
|
||||
description = "Bindings for some fundamental Core Graphics types"
|
||||
homepage = "https://github.com/servo/core-foundation-rs"
|
||||
license = "MIT OR Apache-2.0"
|
||||
license = "MIT / Apache-2.0"
|
||||
repository = "https://github.com/servo/core-foundation-rs"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
default-target = "x86_64-apple-darwin"
|
||||
|
||||
[dependencies.bitflags]
|
||||
version = "1.0"
|
||||
|
||||
[dependencies.core-foundation]
|
||||
version = "0.9"
|
||||
|
||||
[dependencies.foreign-types]
|
||||
version = "0.3.0"
|
||||
|
||||
[dependencies.libc]
|
||||
version = "0.2"
|
||||
|
|
|
@ -26,18 +26,7 @@ pub type CGFloat = libc::c_double;
|
|||
#[cfg(not(target_pointer_width = "64"))]
|
||||
pub type CGFloat = libc::c_float;
|
||||
|
||||
pub type CGError = i32;
|
||||
pub type CGError = libc::int32_t;
|
||||
|
||||
pub type CGGlyph = libc::c_ushort;
|
||||
|
||||
pub const kCGErrorSuccess: CGError = 0;
|
||||
pub const kCGErrorFailure: CGError = 1000;
|
||||
pub const kCGErrorIllegalArgument: CGError = 1001;
|
||||
pub const kCGErrorInvalidConnection: CGError = 1002;
|
||||
pub const kCGErrorInvalidContext: CGError = 1003;
|
||||
pub const kCGErrorCannotComplete: CGError = 1004;
|
||||
pub const kCGErrorNotImplemented: CGError = 1006;
|
||||
pub const kCGErrorRangeCheck: CGError = 1007;
|
||||
pub const kCGErrorTypeCheck: CGError = 1008;
|
||||
pub const kCGErrorInvalidOperation: CGError = 1010;
|
||||
pub const kCGErrorNoneAvailable: CGError = 1011;
|
||||
|
|
|
@ -138,11 +138,6 @@ impl CGRect {
|
|||
ffi::CGRectApplyAffineTransform(*self, *t)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn contains(&self, point: &CGPoint) -> bool {
|
||||
unsafe { ffi::CGRectContainsPoint(*self,*point) == 1 }
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
|
@ -195,8 +190,6 @@ mod ffi {
|
|||
pub fn CGPointApplyAffineTransform(point: CGPoint, t: CGAffineTransform) -> CGPoint;
|
||||
pub fn CGRectApplyAffineTransform(rect: CGRect, t: CGAffineTransform) -> CGRect;
|
||||
pub fn CGSizeApplyAffineTransform(size: CGSize, t: CGAffineTransform) -> CGSize;
|
||||
|
||||
pub fn CGRectContainsPoint(rect:CGRect, point: CGPoint) -> boolean_t;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"files":{"COPYRIGHT":"ec82b96487e9e778ee610c7ab245162464782cfa1f555c2299333f8dbe5c036a","Cargo.toml":"a0088b6d4f15d2f3abbd411834b84eaa7179b374133fb57b8d3d2048149cc494","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"62065228e42caebca7e7d7db1204cbb867033de5982ca4009928915e4095f3a3","README.md":"6745c3c38183d2eda9b1fa265fb0a95018db5c110cbabc00b32327d951bbe2ea","src/access.rs":"919937f8fe61966543c602e30d5d59d61e0b7313bb6b33c25aa600ec5e43345e","src/base.rs":"838683ff67253f4aff1d4b4177531210ca73d4e61f05c5d96a8f196b2a88c787","src/color.rs":"4c8ec4ab828cbc1b2a1538a34a51f5b380927f2f1daf187dff6f732f57a43656","src/color_space.rs":"6a0be06bb7ecdf9d20c461912359d22e0ffd7151c6977a8d9b3b0efdd7929442","src/context.rs":"93d543bd2b77ee6b3132b4378b1652576354fae9bb675cde63e0347d81fec334","src/data_provider.rs":"88e1cdd75c35cff44150f0aac75de6ac715acbf4328abef1b2f191b54401c650","src/display.rs":"391f24669ad1ad5dcd6d15b5e418b6b07731186d3c18d94c8c0935ab348fb3b9","src/event.rs":"7c2ce02fa67cd4613745709563846b57b12fdde105a65d16d29f7a300e9c0f7b","src/event_source.rs":"a81f8bbd41bf4c4e3e91d6a6eab31356728fbf08787aca899ed03259808dfe4a","src/font.rs":"43cad7dfcc49f5f2de408146c6e38843b2d0092b3f5880fbf80e43e18b100f25","src/geometry.rs":"8e12dc89835406bfa514de8fb58f5fd435724d1ddb97dc3a70392efbcf1c42ed","src/gradient.rs":"dd957f14b77d448fa1e51c2e67849364062aa1d5bd60405f060f9a094c628061","src/image.rs":"72076f34a805b1d2336e425cc29d2ec3583046b847e9284ef7413f7eca2acb9a","src/lib.rs":"ca6aabcc5f307a9b15cd3e531d7fb9f54bdf58d9717d38e007e4facf1ca8c9a4","src/path.rs":"9389719ee257d86f50075b294b1b9df8fb3fc93b3442deee868e188489613a2d","src/private.rs":"da3fd61338bab2d8e26aa5433b2e18ecd2a0a408c62e1ac2b33a0f87f2dad88a","src/sys.rs":"3077395beb77193530b713aa681cb61f7b86fa79e4e4060133b6d61cf9f47e09","src/window.rs":"2f6c3dc958ae2c0c9e2fc5033300b96e60ed0abee9823ea1f03797d64df0911a"},"package":"506752f2b58723339d41d013009be97e549860785a366e2a5e75dfbd9725b48e"}
|
||||
{"files":{"COPYRIGHT":"ec82b96487e9e778ee610c7ab245162464782cfa1f555c2299333f8dbe5c036a","Cargo.toml":"453b079ac8a6df8842e7e8a37222318c500f68e1605db7adbdf87337830df593","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"62065228e42caebca7e7d7db1204cbb867033de5982ca4009928915e4095f3a3","README.md":"6745c3c38183d2eda9b1fa265fb0a95018db5c110cbabc00b32327d951bbe2ea","src/base.rs":"838683ff67253f4aff1d4b4177531210ca73d4e61f05c5d96a8f196b2a88c787","src/color.rs":"4c8ec4ab828cbc1b2a1538a34a51f5b380927f2f1daf187dff6f732f57a43656","src/color_space.rs":"b3d7ee8a21703c789160867cb8eb2188bd1daa193e3d030f21adb6f1a6f872de","src/context.rs":"8bda7f9ecb5be768b09a29cc3b0a4f329f55d2a2ab74030d121610283862d833","src/data_provider.rs":"b25201fdea43ea1a019c68aa5e997725d04d0824a238354ddc9f2dd8a6835cc4","src/display.rs":"9db5e5440fd302849b13b48393cab4db95447df8d5057c4534a9d8be948ca480","src/event.rs":"17c601ca0b8a0d806fc576cc6cee63a784deaf4246793cf6ce3abcb562de15c5","src/event_source.rs":"d55a4f5b5e62789325028febc51bbf54c74b15ab1a4e70c6ad749a2f9753e081","src/font.rs":"2a7ac5024f17550dd2b6eb97f6971559f930c163eac3a6625d6d55703fd5e96e","src/geometry.rs":"8e12dc89835406bfa514de8fb58f5fd435724d1ddb97dc3a70392efbcf1c42ed","src/gradient.rs":"8ee8661706f36914d08e903840c4f07414b38ba40ea4a482d34b900ac6ac7cf9","src/image.rs":"a5a5df8c0f310455f038eeb16688015f481688cb417f8e8f424a4c1d2a1cdd57","src/lib.rs":"78264571227db6fc9194cb90d64beaff1738a501f88b5da55eb17ae42592d26f","src/path.rs":"c429afeaed999b02ac00f89a867b5fc64f1e223039079a4e0529306b734ff117","src/private.rs":"da3fd61338bab2d8e26aa5433b2e18ecd2a0a408c62e1ac2b33a0f87f2dad88a","src/sys.rs":"3077395beb77193530b713aa681cb61f7b86fa79e4e4060133b6d61cf9f47e09","src/window.rs":"2f6c3dc958ae2c0c9e2fc5033300b96e60ed0abee9823ea1f03797d64df0911a"},"package":"2581bbab3b8ffc6fcbd550bf46c355135d16e9ff2a6ea032ad6b9bf1d7efe4fb"}
|
|
@ -3,25 +3,23 @@
|
|||
# When uploading crates to the registry Cargo will automatically
|
||||
# "normalize" Cargo.toml files for maximal compatibility
|
||||
# with all versions of Cargo and also rewrite `path` dependencies
|
||||
# to registry (e.g., crates.io) dependencies.
|
||||
# to registry (e.g., crates.io) dependencies
|
||||
#
|
||||
# If you are reading this file be aware that the original Cargo.toml
|
||||
# will likely look very different (and much more reasonable).
|
||||
# See Cargo.toml.orig for the original contents.
|
||||
# If you believe there's an error in this file please file an
|
||||
# issue against the rust-lang/cargo repository. If you're
|
||||
# editing this file be aware that the upstream Cargo.toml
|
||||
# will likely look very different (and much more reasonable)
|
||||
|
||||
[package]
|
||||
name = "core-graphics"
|
||||
version = "0.23.0"
|
||||
version = "0.22.3"
|
||||
authors = ["The Servo Project Developers"]
|
||||
description = "Bindings to Core Graphics for macOS"
|
||||
homepage = "https://github.com/servo/core-foundation-rs"
|
||||
readme = "README.md"
|
||||
license = "MIT OR Apache-2.0"
|
||||
homepage = "https://github.com/servo/core-graphics-rs"
|
||||
license = "MIT / Apache-2.0"
|
||||
repository = "https://github.com/servo/core-foundation-rs"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
default-target = "x86_64-apple-darwin"
|
||||
|
||||
[dependencies.bitflags]
|
||||
version = "1.0"
|
||||
|
||||
|
@ -32,7 +30,7 @@ version = "0.9"
|
|||
version = "0.1"
|
||||
|
||||
[dependencies.foreign-types]
|
||||
version = "0.5.0"
|
||||
version = "0.3.0"
|
||||
|
||||
[dependencies.libc]
|
||||
version = "0.2"
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
pub use base::boolean_t;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct ScreenCaptureAccess;
|
||||
|
||||
impl ScreenCaptureAccess {
|
||||
/// If current app not in list, will open window.
|
||||
/// Return the same result as preflight.
|
||||
#[inline]
|
||||
pub fn request(&self) -> bool {
|
||||
unsafe { CGRequestScreenCaptureAccess() == 1 }
|
||||
}
|
||||
|
||||
/// Return true if has access
|
||||
#[inline]
|
||||
pub fn preflight(&self) -> bool {
|
||||
unsafe { CGPreflightScreenCaptureAccess() == 1 }
|
||||
}
|
||||
}
|
||||
|
||||
#[link(name = "CoreGraphics", kind = "framework")]
|
||||
extern "C" {
|
||||
// Screen Capture Access
|
||||
fn CGRequestScreenCaptureAccess() -> boolean_t;
|
||||
fn CGPreflightScreenCaptureAccess() -> boolean_t;
|
||||
}
|
|
@ -13,11 +13,11 @@ use foreign_types::ForeignType;
|
|||
|
||||
foreign_type! {
|
||||
#[doc(hidden)]
|
||||
pub unsafe type CGColorSpace {
|
||||
type CType = ::sys::CGColorSpace;
|
||||
fn drop = |p| CFRelease(p as *mut _);
|
||||
fn clone = |p| CFRetain(p as *const _) as *mut _;
|
||||
}
|
||||
pub struct CGColorSpace;
|
||||
pub struct CGColorSpaceRef;
|
||||
}
|
||||
|
||||
impl CGColorSpace {
|
||||
|
@ -53,61 +53,13 @@ impl CGColorSpace {
|
|||
|
||||
#[link(name = "CoreGraphics", kind = "framework")]
|
||||
extern {
|
||||
/// The Display P3 color space, created by Apple.
|
||||
pub static kCGColorSpaceDisplayP3: CFStringRef;
|
||||
/// The Display P3 color space, using the HLG transfer function.
|
||||
pub static kCGColorSpaceDisplayP3_HLG: CFStringRef;
|
||||
/// The Display P3 color space with a linear transfer function
|
||||
/// and extended-range values.
|
||||
pub static kCGColorSpaceExtendedLinearDisplayP3: CFStringRef;
|
||||
/// The standard Red Green Blue (sRGB) color space.
|
||||
pub static kCGColorSpaceSRGB: CFStringRef;
|
||||
/// The sRGB color space with a linear transfer function.
|
||||
pub static kCGColorSpaceLinearSRGB: CFStringRef;
|
||||
/// The extended sRGB color space.
|
||||
pub static kCGColorSpaceExtendedSRGB: CFStringRef;
|
||||
/// The sRGB color space with a linear transfer function and
|
||||
/// extended-range values.
|
||||
pub static kCGColorSpaceExtendedLinearSRGB: CFStringRef;
|
||||
/// The generic gray color space that has an exponential transfer
|
||||
/// function with a power of 2.2.
|
||||
pub static kCGColorSpaceGenericGrayGamma2_2: CFStringRef;
|
||||
/// The gray color space using a linear transfer function.
|
||||
pub static kCGColorSpaceLinearGray: CFStringRef;
|
||||
/// The extended gray color space.
|
||||
pub static kCGColorSpaceExtendedGray: CFStringRef;
|
||||
/// The extended gray color space with a linear transfer function.
|
||||
pub static kCGColorSpaceExtendedLinearGray: CFStringRef;
|
||||
/// The generic RGB color space with a linear transfer function.
|
||||
pub static kCGColorSpaceGenericRGBLinear: CFStringRef;
|
||||
/// The generic CMYK color space.
|
||||
pub static kCGColorSpaceGenericCMYK: CFStringRef;
|
||||
/// The XYZ color space, as defined by the CIE 1931 standard.
|
||||
pub static kCGColorSpaceGenericXYZ: CFStringRef;
|
||||
/// The generic LAB color space.
|
||||
pub static kCGColorSpaceGenericLab: CFStringRef;
|
||||
/// The ACEScg color space.
|
||||
pub static kCGColorSpaceACESCGLinear: CFStringRef;
|
||||
/// The Adobe RGB (1998) color space.
|
||||
pub static kCGColorSpaceAdobeRGB1998: CFStringRef;
|
||||
/// The DCI P3 color space, which is the digital cinema standard.
|
||||
pub static kCGColorSpaceDCIP3: CFStringRef;
|
||||
/// The recommendation of the International Telecommunication Union
|
||||
/// (ITU) Radiocommunication sector for the BT.709 color space.
|
||||
pub static kCGColorSpaceITUR_709: CFStringRef;
|
||||
/// The Reference Output Medium Metric (ROMM) RGB color space.
|
||||
pub static kCGColorSpaceROMMRGB: CFStringRef;
|
||||
/// The recommendation of the International Telecommunication Union
|
||||
/// (ITU) Radiocommunication sector for the BT.2020 color space.
|
||||
pub static kCGColorSpaceITUR_2020: CFStringRef;
|
||||
/// The recommendation of the International Telecommunication Union
|
||||
/// (ITU) Radiocommunication sector for the BT.2020 color space, with
|
||||
/// a linear transfer function and extended range values.
|
||||
pub static kCGColorSpaceExtendedLinearITUR_2020: CFStringRef;
|
||||
/// The name of the generic RGB color space.
|
||||
pub static kCGColorSpaceGenericRGB: CFStringRef;
|
||||
/// The name of the generic gray color space.
|
||||
pub static kCGColorSpaceGenericGray: CFStringRef;
|
||||
pub static kCGColorSpaceGenericRGB: CFStringRef;
|
||||
pub static kCGColorSpaceGenericCMYK: CFStringRef;
|
||||
pub static kCGColorSpaceGenericRGBLinear: CFStringRef;
|
||||
pub static kCGColorSpaceGenericGrayGamma2_2: CFStringRef;
|
||||
|
||||
fn CGColorSpaceCreateDeviceRGB() -> ::sys::CGColorSpaceRef;
|
||||
fn CGColorSpaceCreateDeviceGray() -> ::sys::CGColorSpaceRef;
|
||||
|
|
|
@ -109,11 +109,11 @@ pub enum CGInterpolationQuality {
|
|||
|
||||
foreign_type! {
|
||||
#[doc(hidden)]
|
||||
pub unsafe type CGContext {
|
||||
type CType = ::sys::CGContext;
|
||||
fn drop = |cs| CGContextRelease(cs);
|
||||
fn clone = |p| CGContextRetain(p);
|
||||
}
|
||||
pub struct CGContext;
|
||||
pub struct CGContextRef;
|
||||
}
|
||||
|
||||
impl CGContext {
|
||||
|
@ -389,12 +389,6 @@ impl CGContextRef {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn reset_clip(&self) {
|
||||
unsafe {
|
||||
CGContextResetClip(self.as_ptr());
|
||||
}
|
||||
}
|
||||
|
||||
pub fn draw_path(&self, mode: CGPathDrawingMode) {
|
||||
unsafe {
|
||||
CGContextDrawPath(self.as_ptr(), mode);
|
||||
|
@ -618,12 +612,6 @@ impl CGContextRef {
|
|||
CGContextSetShadowWithColor(self.as_ptr(), offset, blur, color.as_concrete_TypeRef());
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_alpha(&self, alpha: CGFloat) {
|
||||
unsafe {
|
||||
CGContextSetAlpha(self.as_ptr(), alpha);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -720,7 +708,6 @@ extern {
|
|||
fn CGContextEOFillPath(c: ::sys::CGContextRef);
|
||||
fn CGContextClip(c: ::sys::CGContextRef);
|
||||
fn CGContextEOClip(c: ::sys::CGContextRef);
|
||||
fn CGContextResetClip(c: ::sys::CGContextRef);
|
||||
fn CGContextStrokePath(c: ::sys::CGContextRef);
|
||||
fn CGContextSetRGBFillColor(context: ::sys::CGContextRef,
|
||||
red: CGFloat,
|
||||
|
@ -784,7 +771,5 @@ extern {
|
|||
|
||||
fn CGContextSetShadow(c: ::sys::CGContextRef, offset: CGSize, blur: CGFloat);
|
||||
fn CGContextSetShadowWithColor(c: ::sys::CGContextRef, offset: CGSize, blur: CGFloat, color: ::sys::CGColorRef);
|
||||
|
||||
fn CGContextSetAlpha(c: ::sys::CGContextRef, alpha: CGFloat);
|
||||
}
|
||||
|
||||
|
|
|
@ -32,11 +32,11 @@ pub type CGDataProviderGetBytesAtPositionCallback = Option<unsafe extern fn (*mu
|
|||
|
||||
foreign_type! {
|
||||
#[doc(hidden)]
|
||||
pub unsafe type CGDataProvider {
|
||||
type CType = ::sys::CGDataProvider;
|
||||
fn drop = |cs| CFRelease(cs as *mut _);
|
||||
fn clone = |p| CFRetain(p as *const _) as *mut _;
|
||||
}
|
||||
pub struct CGDataProvider;
|
||||
pub struct CGDataProviderRef;
|
||||
}
|
||||
|
||||
impl CGDataProvider {
|
||||
|
|
|
@ -23,7 +23,6 @@ use foreign_types::ForeignType;
|
|||
|
||||
pub type CGDirectDisplayID = u32;
|
||||
pub type CGWindowID = u32;
|
||||
pub type CGWindowLevel = i32;
|
||||
|
||||
pub const kCGNullWindowID: CGWindowID = 0 as CGWindowID;
|
||||
pub const kCGNullDirectDisplayID: CGDirectDisplayID = 0 as CGDirectDisplayID;
|
||||
|
@ -69,17 +68,6 @@ pub const kDisplayModeNativeFlag: u32 = 0x02000000;
|
|||
|
||||
pub const kDisplayModeSafetyFlags: u32 = 0x00000007;
|
||||
|
||||
pub type CGDisplayBlendFraction = f32;
|
||||
pub const kCGDisplayBlendNormal: CGDisplayBlendFraction = 0.0;
|
||||
pub const kCGDisplayBlendSolidColor: CGDisplayBlendFraction = 1.0;
|
||||
|
||||
pub type CGDisplayFadeReservationToken = u32;
|
||||
pub const kCGDisplayFadeReservationInvalidToken: CGDisplayFadeReservationToken = 0;
|
||||
|
||||
pub type CGDisplayFadeInterval = f32;
|
||||
pub type CGDisplayReservationInterval = f32;
|
||||
pub const kCGMaxDisplayReservationInterval: CGDisplayReservationInterval = 15.0;
|
||||
|
||||
pub const IO1BitIndexedPixels: &str = "P";
|
||||
pub const IO2BitIndexedPixels: &str = "PP";
|
||||
pub const IO4BitIndexedPixels: &str = "PPPP";
|
||||
|
@ -116,11 +104,11 @@ pub struct CGDisplay {
|
|||
|
||||
foreign_type! {
|
||||
#[doc(hidden)]
|
||||
pub unsafe type CGDisplayMode {
|
||||
type CType = ::sys::CGDisplayMode;
|
||||
fn drop = CGDisplayModeRelease;
|
||||
fn clone = |p| CFRetain(p as *const _) as *mut _;
|
||||
}
|
||||
pub struct CGDisplayMode;
|
||||
pub struct CGDisplayModeRef;
|
||||
}
|
||||
|
||||
impl CGDisplay {
|
||||
|
@ -261,19 +249,6 @@ impl CGDisplay {
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns an image containing the contents of a portion of the specified display.
|
||||
#[inline]
|
||||
pub fn image_for_rect(&self, bounds: CGRect) -> Option<CGImage> {
|
||||
unsafe {
|
||||
let image_ref = CGDisplayCreateImageForRect(self.id, bounds);
|
||||
if !image_ref.is_null() {
|
||||
Some(CGImage::from_ptr(image_ref))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns a composite image based on a dynamically generated list of
|
||||
/// windows.
|
||||
#[inline]
|
||||
|
@ -646,7 +621,6 @@ extern "C" {
|
|||
|
||||
pub static kCGDisplayShowDuplicateLowResolutionModes: CFStringRef;
|
||||
|
||||
pub fn CGDisplayModeRetain(mode: ::sys::CGDisplayModeRef);
|
||||
pub fn CGDisplayModeRelease(mode: ::sys::CGDisplayModeRef);
|
||||
|
||||
pub fn CGMainDisplayID() -> CGDirectDisplayID;
|
||||
|
@ -683,17 +657,7 @@ extern "C" {
|
|||
pub fn CGDisplayPixelsWide(display: CGDirectDisplayID) -> libc::size_t;
|
||||
pub fn CGDisplayBounds(display: CGDirectDisplayID) -> CGRect;
|
||||
pub fn CGDisplayCreateImage(display: CGDirectDisplayID) -> ::sys::CGImageRef;
|
||||
pub fn CGDisplayCreateImageForRect(
|
||||
display: CGDirectDisplayID,
|
||||
rect: CGRect,
|
||||
) -> ::sys::CGImageRef;
|
||||
|
||||
// Capturing and Releasing Displays
|
||||
pub fn CGDisplayCapture(display: CGDirectDisplayID) -> CGError;
|
||||
pub fn CGDisplayRelease(display: CGDirectDisplayID) -> CGError;
|
||||
pub fn CGShieldingWindowLevel() -> CGWindowLevel;
|
||||
|
||||
// Configuring Displays
|
||||
pub fn CGBeginDisplayConfiguration(config: *mut CGDisplayConfigRef) -> CGError;
|
||||
pub fn CGCancelDisplayConfiguration(config: CGDisplayConfigRef) -> CGError;
|
||||
pub fn CGCompleteDisplayConfiguration(
|
||||
|
@ -717,7 +681,6 @@ extern "C" {
|
|||
x: i32,
|
||||
y: i32,
|
||||
) -> CGError;
|
||||
pub fn CGRestorePermanentDisplayConfiguration();
|
||||
|
||||
pub fn CGDisplayCopyDisplayMode(display: CGDirectDisplayID) -> ::sys::CGDisplayModeRef;
|
||||
pub fn CGDisplayModeGetHeight(mode: ::sys::CGDisplayModeRef) -> libc::size_t;
|
||||
|
@ -733,11 +696,6 @@ extern "C" {
|
|||
display: CGDirectDisplayID,
|
||||
options: CFDictionaryRef,
|
||||
) -> CFArrayRef;
|
||||
pub fn CGDisplaySetDisplayMode(
|
||||
display: CGDirectDisplayID,
|
||||
mode: ::sys::CGDisplayModeRef,
|
||||
options: CFDictionaryRef,
|
||||
) -> CGError;
|
||||
|
||||
// mouse stuff
|
||||
pub fn CGDisplayHideCursor(display: CGDirectDisplayID) -> CGError;
|
||||
|
@ -746,32 +704,6 @@ extern "C" {
|
|||
pub fn CGWarpMouseCursorPosition(point: CGPoint) -> CGError;
|
||||
pub fn CGAssociateMouseAndMouseCursorPosition(connected: boolean_t) -> CGError;
|
||||
|
||||
// Display Fade Effects
|
||||
pub fn CGConfigureDisplayFadeEffect(
|
||||
config: CGDisplayConfigRef,
|
||||
fadeOutSeconds: CGDisplayFadeInterval,
|
||||
fadeInSeconds: CGDisplayFadeInterval,
|
||||
fadeRed: f32,
|
||||
fadeGreen: f32,
|
||||
fadeBlue: f32,
|
||||
) -> CGError;
|
||||
pub fn CGAcquireDisplayFadeReservation(
|
||||
seconds: CGDisplayReservationInterval,
|
||||
token: *mut CGDisplayFadeReservationToken,
|
||||
) -> CGError;
|
||||
pub fn CGDisplayFade(
|
||||
token: CGDisplayFadeReservationToken,
|
||||
duration: CGDisplayFadeInterval,
|
||||
startBlend: CGDisplayBlendFraction,
|
||||
endBlend: CGDisplayBlendFraction,
|
||||
redBlend: f32,
|
||||
greenBlend: f32,
|
||||
blueBlend: f32,
|
||||
synchronous: boolean_t,
|
||||
) -> CGError;
|
||||
// CGDisplayFadeOperationInProgress
|
||||
pub fn CGReleaseDisplayFadeReservation(token: CGDisplayFadeReservationToken) -> CGError;
|
||||
|
||||
// Window Services Reference
|
||||
pub fn CGWindowListCopyWindowInfo(
|
||||
option: CGWindowListOption,
|
||||
|
|
|
@ -505,7 +505,7 @@ impl<'tap_life> CGEventTap<'tap_life> {
|
|||
callback_ref: Box::from_raw(cbr),
|
||||
})
|
||||
} else {
|
||||
let _ = Box::from_raw(cbr);
|
||||
Box::from_raw(cbr);
|
||||
Err(())
|
||||
}
|
||||
}
|
||||
|
@ -518,11 +518,11 @@ impl<'tap_life> CGEventTap<'tap_life> {
|
|||
|
||||
foreign_type! {
|
||||
#[doc(hidden)]
|
||||
pub unsafe type CGEvent {
|
||||
type CType = ::sys::CGEvent;
|
||||
fn drop = |p| CFRelease(p as *mut _);
|
||||
fn clone = |p| CFRetain(p as *const _) as *mut _;
|
||||
}
|
||||
pub struct CGEvent;
|
||||
pub struct CGEventRef;
|
||||
}
|
||||
|
||||
impl CGEvent {
|
||||
|
@ -607,14 +607,10 @@ impl CGEvent {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn post_from_tap(&self, tap_proxy: CGEventTapProxy) {
|
||||
unsafe {
|
||||
CGEventTapPostEvent(tap_proxy, self.as_ptr());
|
||||
}
|
||||
}
|
||||
|
||||
pub fn location(&self) -> CGPoint {
|
||||
unsafe { CGEventGetLocation(self.as_ptr()) }
|
||||
unsafe {
|
||||
CGEventGetLocation(self.as_ptr())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "elcapitan")]
|
||||
|
@ -738,8 +734,6 @@ extern {
|
|||
/// taps.
|
||||
fn CGEventPost(tapLocation: CGEventTapLocation, event: ::sys::CGEventRef);
|
||||
|
||||
fn CGEventTapPostEvent(tapProxy: CGEventTapProxy, event: ::sys::CGEventRef);
|
||||
|
||||
#[cfg(feature = "elcapitan")]
|
||||
/// Post an event to a specified process ID
|
||||
fn CGEventPostToPid(pid: libc::pid_t, event: ::sys::CGEventRef);
|
||||
|
|
|
@ -12,11 +12,11 @@ pub enum CGEventSourceStateID {
|
|||
|
||||
foreign_type! {
|
||||
#[doc(hidden)]
|
||||
pub unsafe type CGEventSource {
|
||||
type CType = ::sys::CGEventSource;
|
||||
fn drop = |p| CFRelease(p as *mut _);
|
||||
fn clone = |p| CFRetain(p as *const _) as *mut _;
|
||||
}
|
||||
pub struct CGEventSource;
|
||||
pub struct CGEventSourceRef;
|
||||
}
|
||||
|
||||
impl CGEventSource {
|
||||
|
|
|
@ -15,7 +15,6 @@ use core_foundation::string::{CFString, CFStringRef};
|
|||
use core_foundation::dictionary::{CFDictionary, CFDictionaryRef};
|
||||
use data_provider::CGDataProvider;
|
||||
use geometry::CGRect;
|
||||
use std::ptr::NonNull;
|
||||
|
||||
use foreign_types::ForeignType;
|
||||
|
||||
|
@ -25,12 +24,15 @@ pub use core_graphics_types::base::CGGlyph;
|
|||
|
||||
foreign_type! {
|
||||
#[doc(hidden)]
|
||||
pub unsafe type CGFont: Send + Sync {
|
||||
type CType = ::sys::CGFont;
|
||||
fn drop = |p| CFRelease(p as *mut _);
|
||||
fn clone = |p| CFRetain(p as *const _) as *mut _;
|
||||
pub struct CGFont;
|
||||
pub struct CGFontRef;
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl Send for CGFont {}
|
||||
unsafe impl Sync for CGFont {}
|
||||
|
||||
impl CGFont {
|
||||
pub fn type_id() -> CFTypeID {
|
||||
|
@ -42,9 +44,10 @@ impl CGFont {
|
|||
pub fn from_data_provider(provider: CGDataProvider) -> Result<CGFont, ()> {
|
||||
unsafe {
|
||||
let font_ref = CGFontCreateWithDataProvider(provider.as_ptr());
|
||||
match NonNull::new(font_ref) {
|
||||
Some(font_ref) => Ok(CGFont(font_ref)),
|
||||
None => Err(()),
|
||||
if !font_ref.is_null() {
|
||||
Ok(CGFont::from_ptr(font_ref))
|
||||
} else {
|
||||
Err(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -52,9 +55,10 @@ impl CGFont {
|
|||
pub fn from_name(name: &CFString) -> Result<CGFont, ()> {
|
||||
unsafe {
|
||||
let font_ref = CGFontCreateWithFontName(name.as_concrete_TypeRef());
|
||||
match NonNull::new(font_ref) {
|
||||
Some(font_ref) => Ok(CGFont(font_ref)),
|
||||
None => Err(()),
|
||||
if !font_ref.is_null() {
|
||||
Ok(CGFont::from_ptr(font_ref))
|
||||
} else {
|
||||
Err(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -63,9 +67,10 @@ impl CGFont {
|
|||
unsafe {
|
||||
let font_ref = CGFontCreateCopyWithVariations(self.as_ptr(),
|
||||
vars.as_concrete_TypeRef());
|
||||
match NonNull::new(font_ref) {
|
||||
Some(font_ref) => Ok(CGFont(font_ref)),
|
||||
None => Err(()),
|
||||
if !font_ref.is_null() {
|
||||
Ok(CGFont::from_ptr(font_ref))
|
||||
} else {
|
||||
Err(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,11 +29,11 @@ bitflags! {
|
|||
|
||||
foreign_type! {
|
||||
#[doc(hidden)]
|
||||
pub unsafe type CGGradient {
|
||||
type CType = ::sys::CGGradient;
|
||||
fn drop = |p| CFRelease(p as *mut _);
|
||||
fn clone = |p| CFRetain(p as *const _) as *mut _;
|
||||
}
|
||||
pub struct CGGradient;
|
||||
pub struct CGGradientRef;
|
||||
}
|
||||
|
||||
impl CGGradient {
|
||||
|
|
|
@ -32,11 +32,11 @@ pub enum CGImageByteOrderInfo {
|
|||
|
||||
foreign_type! {
|
||||
#[doc(hidden)]
|
||||
pub unsafe type CGImage {
|
||||
type CType = ::sys::CGImage;
|
||||
fn drop = CGImageRelease;
|
||||
fn clone = |p| CFRetain(p as *const _) as *mut _;
|
||||
}
|
||||
pub struct CGImage;
|
||||
pub struct CGImageRef;
|
||||
}
|
||||
|
||||
impl CGImage {
|
||||
|
|
|
@ -41,5 +41,3 @@ pub mod private;
|
|||
pub mod image;
|
||||
pub mod path;
|
||||
pub mod sys;
|
||||
#[cfg(target_os = "macos")]
|
||||
pub mod access;
|
|
@ -21,11 +21,11 @@ use std::slice;
|
|||
|
||||
foreign_type! {
|
||||
#[doc(hidden)]
|
||||
pub unsafe type CGPath {
|
||||
type CType = ::sys::CGPath;
|
||||
fn drop = |p| CFRelease(p as *mut _);
|
||||
fn clone = |p| CFRetain(p as *const _) as *mut _;
|
||||
}
|
||||
pub struct CGPath;
|
||||
pub struct CGPathRef;
|
||||
}
|
||||
|
||||
impl CGPath {
|
||||
|
@ -35,7 +35,7 @@ impl CGPath {
|
|||
None => ptr::null(),
|
||||
Some(transform) => transform as *const CGAffineTransform,
|
||||
};
|
||||
CGPath::from_ptr(CGPathCreateWithRect(rect, transform))
|
||||
CGPath(CGPathCreateWithRect(rect, transform))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"files":{"COPYRIGHT":"ec82b96487e9e778ee610c7ab245162464782cfa1f555c2299333f8dbe5c036a","Cargo.toml":"7a776cd901d7f63a97ad6c1576b00f267ad782ef79ff4cdfbc2cb507a2c144d5","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"62065228e42caebca7e7d7db1204cbb867033de5982ca4009928915e4095f3a3","README.md":"98d25015857a430aac32f34bdc979a1a66e672a0ea42c5f92dd9cfe23c1fccfd","src/font.rs":"149d4646abc01a884e16d45dde77b44d3151cab27c301c65fa22dda638ff3c48","src/font_collection.rs":"02de0ce2a61683314897a521d31ab9cc572a8b10ceda2ac47181fbe18bf4f235","src/font_descriptor.rs":"43a2fec6bca9689d8172f363ab20ce8c633696974e1653cad2e072e3af776528","src/font_manager.rs":"6e5056a42868187e1f4e696c181ca247423308652d3c68867c708616031876e4","src/frame.rs":"ed1e2aad7be9dafc3e9729f2caecefd4214a9552f834932a414239146142069a","src/framesetter.rs":"13e34b4111cee5f023aa05e2220d2a6f102e96fd18c51a356992bffd6c9fc7c1","src/lib.rs":"1c662e51874eb43ff52a8a1af131d1b2fd84095c3d949a271dc895bf56fd0fc6","src/line.rs":"02fab7f07c3f6a003a7c35ffeb3d37546ae58e4da7fe05f26e520f283397a602","src/run.rs":"b86e9b9b39effe4a79c6002880d95f214742d448029a3111e288734abe75b827","src/string_attributes.rs":"ea0f854d64097d3626a03002323e2276e28affae7a698aaadd89dd6b744dd80f"},"package":"02083d15989d6247553e1a63753561555a72b2038bba1e4239db70602a798742"}
|
||||
{"files":{"COPYRIGHT":"ec82b96487e9e778ee610c7ab245162464782cfa1f555c2299333f8dbe5c036a","Cargo.toml":"26a527860e530d18a5ce446ffb595f63a178504506fb4a283993402295053afe","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"62065228e42caebca7e7d7db1204cbb867033de5982ca4009928915e4095f3a3","README.md":"98d25015857a430aac32f34bdc979a1a66e672a0ea42c5f92dd9cfe23c1fccfd","src/font.rs":"17d957510eee8d96ef2bc1b5bc97491917ac0336ad3dbf48416dda3685cef579","src/font_collection.rs":"02de0ce2a61683314897a521d31ab9cc572a8b10ceda2ac47181fbe18bf4f235","src/font_descriptor.rs":"43a2fec6bca9689d8172f363ab20ce8c633696974e1653cad2e072e3af776528","src/font_manager.rs":"6e5056a42868187e1f4e696c181ca247423308652d3c68867c708616031876e4","src/frame.rs":"ed1e2aad7be9dafc3e9729f2caecefd4214a9552f834932a414239146142069a","src/framesetter.rs":"13e34b4111cee5f023aa05e2220d2a6f102e96fd18c51a356992bffd6c9fc7c1","src/lib.rs":"1c662e51874eb43ff52a8a1af131d1b2fd84095c3d949a271dc895bf56fd0fc6","src/line.rs":"02fab7f07c3f6a003a7c35ffeb3d37546ae58e4da7fe05f26e520f283397a602","src/run.rs":"b86e9b9b39effe4a79c6002880d95f214742d448029a3111e288734abe75b827","src/string_attributes.rs":"ea0f854d64097d3626a03002323e2276e28affae7a698aaadd89dd6b744dd80f"},"package":"99d74ada66e07c1cefa18f8abfba765b486f250de2e4a999e5727fc0dd4b4a25"}
|
|
@ -3,32 +3,30 @@
|
|||
# When uploading crates to the registry Cargo will automatically
|
||||
# "normalize" Cargo.toml files for maximal compatibility
|
||||
# with all versions of Cargo and also rewrite `path` dependencies
|
||||
# to registry (e.g., crates.io) dependencies.
|
||||
# to registry (e.g., crates.io) dependencies
|
||||
#
|
||||
# If you are reading this file be aware that the original Cargo.toml
|
||||
# will likely look very different (and much more reasonable).
|
||||
# See Cargo.toml.orig for the original contents.
|
||||
# If you believe there's an error in this file please file an
|
||||
# issue against the rust-lang/cargo repository. If you're
|
||||
# editing this file be aware that the upstream Cargo.toml
|
||||
# will likely look very different (and much more reasonable)
|
||||
|
||||
[package]
|
||||
name = "core-text"
|
||||
version = "20.0.0"
|
||||
version = "19.2.0"
|
||||
authors = ["The Servo Project Developers"]
|
||||
description = "Bindings to the Core Text framework."
|
||||
readme = "README.md"
|
||||
license = "MIT OR Apache-2.0"
|
||||
license = "MIT/Apache-2.0"
|
||||
repository = "https://github.com/servo/core-foundation-rs"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
default-target = "x86_64-apple-darwin"
|
||||
|
||||
[dependencies.core-foundation]
|
||||
version = "0.9"
|
||||
|
||||
[dependencies.core-graphics]
|
||||
version = "0.23.0"
|
||||
version = "0.22.0"
|
||||
|
||||
[dependencies.foreign-types]
|
||||
version = "0.5"
|
||||
version = "0.3"
|
||||
|
||||
[dependencies.libc]
|
||||
version = "0.2"
|
||||
|
|
|
@ -78,54 +78,6 @@ pub const kCTFontOptionsDefault: CTFontOptions = 0;
|
|||
pub const kCTFontOptionsPreventAutoActivation: CTFontOptions = 1 << 0;
|
||||
pub const kCTFontOptionsPreferSystemFont: CTFontOptions = 1 << 2;
|
||||
|
||||
pub enum CTFontNameSpecifier {
|
||||
Copyright,
|
||||
Family,
|
||||
SubFamily,
|
||||
Style,
|
||||
Unique,
|
||||
Full,
|
||||
Version,
|
||||
PostScript,
|
||||
Trademark,
|
||||
Manufacturer,
|
||||
Designer,
|
||||
Description,
|
||||
VendorURL,
|
||||
DesignerURL,
|
||||
License,
|
||||
LicenseURL,
|
||||
SampleText,
|
||||
PostScriptCID,
|
||||
}
|
||||
|
||||
impl Into<CFStringRef> for CTFontNameSpecifier {
|
||||
fn into(self) -> CFStringRef {
|
||||
unsafe {
|
||||
match self {
|
||||
CTFontNameSpecifier::Copyright => kCTFontCopyrightNameKey,
|
||||
CTFontNameSpecifier::Family => kCTFontFamilyNameKey,
|
||||
CTFontNameSpecifier::SubFamily => kCTFontSubFamilyNameKey,
|
||||
CTFontNameSpecifier::Style => kCTFontStyleNameKey,
|
||||
CTFontNameSpecifier::Unique => kCTFontUniqueNameKey,
|
||||
CTFontNameSpecifier::Full => kCTFontFullNameKey,
|
||||
CTFontNameSpecifier::Version => kCTFontVersionNameKey,
|
||||
CTFontNameSpecifier::PostScript => kCTFontPostScriptNameKey,
|
||||
CTFontNameSpecifier::Trademark => kCTFontTrademarkNameKey,
|
||||
CTFontNameSpecifier::Manufacturer => kCTFontManufacturerNameKey,
|
||||
CTFontNameSpecifier::Designer => kCTFontDesignerNameKey,
|
||||
CTFontNameSpecifier::Description => kCTFontDescriptionNameKey,
|
||||
CTFontNameSpecifier::VendorURL => kCTFontVendorURLNameKey,
|
||||
CTFontNameSpecifier::DesignerURL => kCTFontDesignerURLNameKey,
|
||||
CTFontNameSpecifier::License => kCTFontLicenseNameKey,
|
||||
CTFontNameSpecifier::LicenseURL => kCTFontLicenseURLNameKey,
|
||||
CTFontNameSpecifier::SampleText => kCTFontSampleTextNameKey,
|
||||
CTFontNameSpecifier::PostScriptCID => kCTFontPostScriptCIDNameKey,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct __CTFont(c_void);
|
||||
|
||||
|
@ -192,29 +144,6 @@ pub fn new_from_name(name: &str, pt_size: f64) -> Result<CTFont, ()> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn new_ui_font_for_language(ui_type: CTFontUIFontType,
|
||||
size: f64,
|
||||
language: Option<CFString>)
|
||||
-> CTFont {
|
||||
unsafe {
|
||||
let font_ref = CTFontCreateUIFontForLanguage(
|
||||
ui_type,
|
||||
size,
|
||||
language.as_ref()
|
||||
.map(|x| x.as_concrete_TypeRef())
|
||||
.unwrap_or(std::ptr::null()),
|
||||
);
|
||||
if font_ref.is_null() {
|
||||
// CTFontCreateUIFontForLanguage can fail, but is unlikely to do so during
|
||||
// normal usage (if you pass a bad ui_type it will). To make things more
|
||||
// convenient, just panic if it fails.
|
||||
panic!();
|
||||
} else {
|
||||
CTFont::wrap_under_create_rule(font_ref)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CTFont {
|
||||
// Properties
|
||||
pub fn symbolic_traits(&self) -> CTFontSymbolicTraits {
|
||||
|
@ -269,46 +198,47 @@ impl CTFont {
|
|||
}
|
||||
|
||||
// Names
|
||||
pub fn get_string_by_name_key(&self, name_key: CTFontNameSpecifier) -> Option<String> {
|
||||
unsafe {
|
||||
let result = CTFontCopyName(self.as_concrete_TypeRef(), name_key.into());
|
||||
if result.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(CFString::wrap_under_create_rule(result).to_string())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn family_name(&self) -> String {
|
||||
let value = self.get_string_by_name_key(CTFontNameSpecifier::Family);
|
||||
unsafe {
|
||||
let value = get_string_by_name_key(self, kCTFontFamilyNameKey);
|
||||
value.expect("Fonts should always have a family name.")
|
||||
}
|
||||
}
|
||||
|
||||
pub fn face_name(&self) -> String {
|
||||
let value = self.get_string_by_name_key(CTFontNameSpecifier::SubFamily);
|
||||
unsafe {
|
||||
let value = get_string_by_name_key(self, kCTFontSubFamilyNameKey);
|
||||
value.expect("Fonts should always have a face name.")
|
||||
}
|
||||
}
|
||||
|
||||
pub fn unique_name(&self) -> String {
|
||||
let value = self.get_string_by_name_key(CTFontNameSpecifier::Unique);
|
||||
unsafe {
|
||||
let value = get_string_by_name_key(self, kCTFontUniqueNameKey);
|
||||
value.expect("Fonts should always have a unique name.")
|
||||
}
|
||||
}
|
||||
|
||||
pub fn postscript_name(&self) -> String {
|
||||
let value = self.get_string_by_name_key(CTFontNameSpecifier::PostScript);
|
||||
unsafe {
|
||||
let value = get_string_by_name_key(self, kCTFontPostScriptNameKey);
|
||||
value.expect("Fonts should always have a PostScript name.")
|
||||
}
|
||||
}
|
||||
|
||||
pub fn display_name(&self) -> String {
|
||||
let value = self.get_string_by_name_key(CTFontNameSpecifier::Full);
|
||||
unsafe {
|
||||
let value = get_string_by_name_key(self, kCTFontFullNameKey);
|
||||
value.expect("Fonts should always have a PostScript name.")
|
||||
}
|
||||
}
|
||||
|
||||
pub fn style_name(&self) -> String {
|
||||
let value = self.get_string_by_name_key(CTFontNameSpecifier::Style);
|
||||
unsafe {
|
||||
let value = get_string_by_name_key(self, kCTFontStyleNameKey);
|
||||
value.expect("Fonts should always have a style name.")
|
||||
}
|
||||
}
|
||||
|
||||
pub fn all_traits(&self) -> CTFontTraits {
|
||||
unsafe {
|
||||
|
@ -507,17 +437,30 @@ impl CTFont {
|
|||
}
|
||||
|
||||
// Helper methods
|
||||
pub fn debug_font_names(font: &CTFont) {
|
||||
fn get_key(font: &CTFont, key: CTFontNameSpecifier) -> String {
|
||||
font.get_string_by_name_key(key).unwrap()
|
||||
fn get_string_by_name_key(font: &CTFont, name_key: CFStringRef) -> Option<String> {
|
||||
unsafe {
|
||||
let result = CTFontCopyName(font.as_concrete_TypeRef(), name_key);
|
||||
if result.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(CFString::wrap_under_create_rule(result).to_string())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
println!("kCTFontFamilyNameKey: {}", get_key(font, CTFontNameSpecifier::Family));
|
||||
println!("kCTFontSubFamilyNameKey: {}", get_key(font, CTFontNameSpecifier::SubFamily));
|
||||
println!("kCTFontStyleNameKey: {}", get_key(font, CTFontNameSpecifier::Style));
|
||||
println!("kCTFontUniqueNameKey: {}", get_key(font, CTFontNameSpecifier::Unique));
|
||||
println!("kCTFontFullNameKey: {}", get_key(font, CTFontNameSpecifier::Full));
|
||||
println!("kCTFontPostScriptNameKey: {}", get_key(font, CTFontNameSpecifier::PostScript));
|
||||
pub fn debug_font_names(font: &CTFont) {
|
||||
fn get_key(font: &CTFont, key: CFStringRef) -> String {
|
||||
get_string_by_name_key(font, key).unwrap()
|
||||
}
|
||||
|
||||
unsafe {
|
||||
println!("kCTFontFamilyNameKey: {}", get_key(font, kCTFontFamilyNameKey));
|
||||
println!("kCTFontSubFamilyNameKey: {}", get_key(font, kCTFontSubFamilyNameKey));
|
||||
println!("kCTFontStyleNameKey: {}", get_key(font, kCTFontStyleNameKey));
|
||||
println!("kCTFontUniqueNameKey: {}", get_key(font, kCTFontUniqueNameKey));
|
||||
println!("kCTFontFullNameKey: {}", get_key(font, kCTFontFullNameKey));
|
||||
println!("kCTFontPostScriptNameKey: {}", get_key(font, kCTFontPostScriptNameKey));
|
||||
}
|
||||
}
|
||||
|
||||
pub fn debug_font_traits(font: &CTFont) {
|
||||
|
@ -551,30 +494,28 @@ extern {
|
|||
*/
|
||||
|
||||
/* Name Specifier Constants */
|
||||
static kCTFontCopyrightNameKey: CFStringRef;
|
||||
//static kCTFontCopyrightNameKey: CFStringRef;
|
||||
static kCTFontFamilyNameKey: CFStringRef;
|
||||
static kCTFontSubFamilyNameKey: CFStringRef;
|
||||
static kCTFontStyleNameKey: CFStringRef;
|
||||
static kCTFontUniqueNameKey: CFStringRef;
|
||||
static kCTFontFullNameKey: CFStringRef;
|
||||
static kCTFontVersionNameKey: CFStringRef;
|
||||
//static kCTFontVersionNameKey: CFStringRef;
|
||||
static kCTFontPostScriptNameKey: CFStringRef;
|
||||
static kCTFontTrademarkNameKey: CFStringRef;
|
||||
static kCTFontManufacturerNameKey: CFStringRef;
|
||||
static kCTFontDesignerNameKey: CFStringRef;
|
||||
static kCTFontDescriptionNameKey: CFStringRef;
|
||||
static kCTFontVendorURLNameKey: CFStringRef;
|
||||
static kCTFontDesignerURLNameKey: CFStringRef;
|
||||
static kCTFontLicenseNameKey: CFStringRef;
|
||||
static kCTFontLicenseURLNameKey: CFStringRef;
|
||||
static kCTFontSampleTextNameKey: CFStringRef;
|
||||
static kCTFontPostScriptCIDNameKey: CFStringRef;
|
||||
//static kCTFontTrademarkNameKey: CFStringRef;
|
||||
//static kCTFontManufacturerNameKey: CFStringRef;
|
||||
//static kCTFontDesignerNameKey: CFStringRef;
|
||||
//static kCTFontDescriptionNameKey: CFStringRef;
|
||||
//static kCTFontVendorURLNameKey: CFStringRef;
|
||||
//static kCTFontDesignerURLNameKey: CFStringRef;
|
||||
//static kCTFontLicenseNameKey: CFStringRef;
|
||||
//static kCTFontLicenseURLNameKey: CFStringRef;
|
||||
//static kCTFontSampleTextNameKey: CFStringRef;
|
||||
//static kCTFontPostScriptCIDNameKey: CFStringRef;
|
||||
|
||||
#[cfg(test)]
|
||||
static kCTFontVariationAxisIdentifierKey: CFStringRef;
|
||||
//static kCTFontVariationAxisIdentifierKey: CFStringRef;
|
||||
//static kCTFontVariationAxisMinimumValueKey: CFStringRef;
|
||||
#[cfg(test)]
|
||||
static kCTFontVariationAxisMaximumValueKey: CFStringRef;
|
||||
//static kCTFontVariationAxisMaximumValueKey: CFStringRef;
|
||||
//static kCTFontVariationAxisDefaultValueKey: CFStringRef;
|
||||
//static kCTFontVariationAxisNameKey: CFStringRef;
|
||||
|
||||
|
@ -598,6 +539,7 @@ extern {
|
|||
fn CTFontCreateWithFontDescriptor(descriptor: CTFontDescriptorRef, size: CGFloat,
|
||||
matrix: *const CGAffineTransform) -> CTFontRef;
|
||||
//fn CTFontCreateWithFontDescriptorAndOptions
|
||||
#[cfg(test)]
|
||||
fn CTFontCreateUIFontForLanguage(uiType: CTFontUIFontType, size: CGFloat, language: CFStringRef) -> CTFontRef;
|
||||
fn CTFontCreateCopyWithAttributes(font: CTFontRef, size: CGFloat, matrix: *const CGAffineTransform,
|
||||
attributes: CTFontDescriptorRef) -> CTFontRef;
|
||||
|
@ -749,9 +691,11 @@ fn macos_version() -> (i32, i32, i32) {
|
|||
|
||||
#[test]
|
||||
fn copy_system_font() {
|
||||
use crate::*;
|
||||
|
||||
let small = new_ui_font_for_language(kCTFontSystemDetailFontType, 19., None);
|
||||
let small = unsafe {
|
||||
CTFont::wrap_under_create_rule(
|
||||
CTFontCreateUIFontForLanguage(kCTFontSystemDetailFontType, 19., std::ptr::null())
|
||||
)
|
||||
};
|
||||
let big = small.clone_with_font_size(20.);
|
||||
|
||||
// ensure that we end up with different fonts for the different sizes before 10.15
|
||||
|
@ -768,12 +712,6 @@ fn copy_system_font() {
|
|||
let ctfont = new_from_descriptor(&desc, 20.);
|
||||
assert_eq!(big.postscript_name(), ctfont.postscript_name());
|
||||
|
||||
// check that we can construct a new version by attributes
|
||||
let attr = desc.attributes();
|
||||
let desc_from_attr = font_descriptor::new_from_attributes(&attr);
|
||||
let font_from_attr = new_from_descriptor(&desc_from_attr, 19.);
|
||||
assert_eq!(font_from_attr.postscript_name(), small.postscript_name());
|
||||
|
||||
// on newer versions of macos we can't construct by name anymore
|
||||
if macos_version() < (10, 13, 0) {
|
||||
let ui_font_by_name = new_from_name(&small.postscript_name(), 19.).unwrap();
|
||||
|
@ -804,164 +742,3 @@ fn copy_system_font() {
|
|||
|
||||
assert_eq!(small.postscript_name(), cgfont.postscript_name());
|
||||
}
|
||||
|
||||
// Tests what happens when variations have values not inbetween min and max
|
||||
#[test]
|
||||
fn out_of_range_variations() {
|
||||
use crate::*;
|
||||
|
||||
let small = new_ui_font_for_language(kCTFontSystemDetailFontType, 19., None);
|
||||
|
||||
let axes = small.get_variation_axes();
|
||||
if macos_version() < (10, 12, 0) {
|
||||
assert!(axes.is_none());
|
||||
return;
|
||||
}
|
||||
let axes = axes.unwrap();
|
||||
let mut vals = Vec::new();
|
||||
dbg!(&axes);
|
||||
for axis in axes.iter() {
|
||||
let tag = axis.find(unsafe { kCTFontVariationAxisIdentifierKey } )
|
||||
.unwrap().downcast::<CFNumber>().unwrap().to_i64().unwrap();
|
||||
let max = axis.find(unsafe { kCTFontVariationAxisMaximumValueKey } )
|
||||
.unwrap().downcast::<CFNumber>().unwrap().to_f64().unwrap();
|
||||
vals.push((CFNumber::from(tag), CFNumber::from(max + 1.)));
|
||||
|
||||
}
|
||||
let vals_dict = CFDictionary::from_CFType_pairs(&vals);
|
||||
let variation_attribute = unsafe { CFString::wrap_under_get_rule(font_descriptor::kCTFontVariationAttribute) };
|
||||
let attrs_dict = CFDictionary::from_CFType_pairs(&[(variation_attribute.clone(), vals_dict)]);
|
||||
let ct_var_font_desc = small.copy_descriptor().create_copy_with_attributes(attrs_dict.to_untyped()).unwrap();
|
||||
let variation_font = crate::font::new_from_descriptor(&ct_var_font_desc, 19.);
|
||||
let var_desc = variation_font.copy_descriptor();
|
||||
let var_attrs = var_desc.attributes();
|
||||
dbg!(&var_attrs);
|
||||
// attributes greater than max are dropped on macOS <= 11
|
||||
// on macOS 12 they seem to be preserved as is.
|
||||
let var_attrs = var_attrs.find(variation_attribute);
|
||||
if macos_version() >= (12, 0, 0) {
|
||||
let var_attrs = var_attrs.unwrap().downcast::<CFDictionary>().unwrap();
|
||||
assert!(!var_attrs.is_empty());
|
||||
let var_attrs: CFDictionary<CFType, CFType> = unsafe { std::mem::transmute(var_attrs) };
|
||||
// attributes greater than max remain
|
||||
for axis in axes.iter() {
|
||||
let tag = axis.find(unsafe { kCTFontVariationAxisIdentifierKey } )
|
||||
.unwrap();
|
||||
let max = axis.find(unsafe { kCTFontVariationAxisMaximumValueKey } )
|
||||
.unwrap().downcast::<CFNumber>().unwrap().to_f64().unwrap();
|
||||
let val = var_attrs.find(tag.clone()).unwrap().downcast::<CFNumber>().unwrap().to_f64().unwrap();
|
||||
assert_eq!(val, max + 1.);
|
||||
}
|
||||
} else if macos_version() >= (10, 15, 0) {
|
||||
assert!(var_attrs.is_none());
|
||||
} else {
|
||||
let var_attrs = var_attrs.unwrap().downcast::<CFDictionary>().unwrap();
|
||||
assert!(var_attrs.is_empty());
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn equal_descriptor_different_font() {
|
||||
use crate::*;
|
||||
|
||||
let variation_attribute = unsafe { CFString::wrap_under_get_rule(font_descriptor::kCTFontVariationAttribute) };
|
||||
let size_attribute = unsafe { CFString::wrap_under_get_rule(font_descriptor::kCTFontSizeAttribute) };
|
||||
|
||||
let sys_font = new_ui_font_for_language(kCTFontSystemDetailFontType, 19., None);
|
||||
|
||||
|
||||
// but we can still construct the CGFont by name
|
||||
let create_vars = |desc| {
|
||||
let mut vals: Vec<(CFNumber, CFNumber)> = Vec::new();
|
||||
vals.push((CFNumber::from(0x6f70737a), CFNumber::from(17.)));
|
||||
let vals_dict = CFDictionary::from_CFType_pairs(&vals);
|
||||
let attrs_dict = CFDictionary::from_CFType_pairs(&[(variation_attribute.clone(), vals_dict)]);
|
||||
let size_attrs_dict = CFDictionary::from_CFType_pairs(&[(size_attribute.clone(), CFNumber::from(120.))]);
|
||||
dbg!(&desc);
|
||||
let from_font_desc = new_from_descriptor(&desc, 120.).copy_descriptor();
|
||||
let resized_font_desc = desc.create_copy_with_attributes(size_attrs_dict.to_untyped()).unwrap();
|
||||
if macos_version() >= (11, 0, 0) {
|
||||
assert_eq!(from_font_desc, resized_font_desc);
|
||||
} else {
|
||||
// we won't have a name if we're using system font desc
|
||||
if from_font_desc.attributes().find(unsafe { font_descriptor::kCTFontNameAttribute }).is_none() {
|
||||
// it's surprising that desc's are the not equal but the attributes are
|
||||
assert_ne!(from_font_desc, resized_font_desc);
|
||||
assert_eq!(from_font_desc.attributes().to_untyped(), resized_font_desc.attributes().to_untyped());
|
||||
} else {
|
||||
if macos_version() >= (10, 13, 0) {
|
||||
// this is unsurprising
|
||||
assert_ne!(from_font_desc, resized_font_desc);
|
||||
assert_ne!(from_font_desc.attributes().to_untyped(), resized_font_desc.attributes().to_untyped());
|
||||
} else {
|
||||
assert_ne!(from_font_desc, resized_font_desc);
|
||||
assert_eq!(from_font_desc.attributes().to_untyped(), resized_font_desc.attributes().to_untyped());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let from_font_desc = from_font_desc.create_copy_with_attributes(attrs_dict.to_untyped()).unwrap();
|
||||
let resized_font_desc = resized_font_desc.create_copy_with_attributes(attrs_dict.to_untyped()).unwrap();
|
||||
(from_font_desc, resized_font_desc)
|
||||
};
|
||||
|
||||
// setting the variation works properly if we use system font desc
|
||||
let (from_font_desc, resized_font_desc) = create_vars(sys_font.copy_descriptor());
|
||||
assert_eq!(from_font_desc, resized_font_desc);
|
||||
assert!(resized_font_desc.attributes().find(variation_attribute.clone()).is_some());
|
||||
|
||||
// but doesn't if we refer to it by name
|
||||
let ps = sys_font.postscript_name();
|
||||
let cgfont = CGFont::from_name(&CFString::new(&ps)).unwrap();
|
||||
let ctfont = new_from_CGFont(&cgfont, 0.);
|
||||
|
||||
let (from_font_desc, resized_font_desc) = create_vars(ctfont.copy_descriptor());
|
||||
if macos_version() >= (10, 15, 0) {
|
||||
assert_ne!(from_font_desc, resized_font_desc);
|
||||
}
|
||||
|
||||
if macos_version() >= (10, 13, 0) {
|
||||
assert!(from_font_desc.attributes().find(variation_attribute.clone()).is_some());
|
||||
if macos_version() >= (11, 0, 0) {
|
||||
assert!(resized_font_desc.attributes().find(variation_attribute).is_none());
|
||||
} else {
|
||||
assert!(resized_font_desc.attributes().find(variation_attribute).is_some());
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn system_font_variation() {
|
||||
use crate::*;
|
||||
|
||||
let small = new_ui_font_for_language(kCTFontSystemDetailFontType, 19., None);
|
||||
|
||||
// but we can still construct the CGFont by name
|
||||
let ps = small.postscript_name();
|
||||
let cgfont = CGFont::from_name(&CFString::new(&ps)).unwrap();
|
||||
let cgfont = new_from_CGFont(&cgfont, 0.);
|
||||
let desc = cgfont.copy_descriptor();
|
||||
|
||||
let mut vals: Vec<(CFNumber, CFNumber)> = Vec::new();
|
||||
vals.push((CFNumber::from(0x6f70737a /* opsz */), CFNumber::from(17.)));
|
||||
let vals_dict = CFDictionary::from_CFType_pairs(&vals);
|
||||
let variation_attribute = unsafe { CFString::wrap_under_get_rule(font_descriptor::kCTFontVariationAttribute) };
|
||||
let attrs_dict = CFDictionary::from_CFType_pairs(&[(variation_attribute, vals_dict)]);
|
||||
let ct_var_font_desc = desc.create_copy_with_attributes(attrs_dict.to_untyped()).unwrap();
|
||||
let attrs = ct_var_font_desc.attributes();
|
||||
let var_attr = attrs.find(CFString::from_static_string("NSCTFontVariationAttribute"));
|
||||
if macos_version() >= (11, 0, 0) {
|
||||
// the variation goes away
|
||||
assert!(var_attr.is_none());
|
||||
} else {
|
||||
assert!(var_attr.is_some());
|
||||
}
|
||||
|
||||
dbg!(ct_var_font_desc);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ui_font() {
|
||||
// pass some garbagey inputs
|
||||
new_ui_font_for_language(kCTFontSystemDetailFontType, 10000009., Some(CFString::from("Gofld")));
|
||||
}
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
{"files":{"Cargo.toml":"829c9da0910b673669e0401c6affd6564c94c49cf9629740104ffabf46f54d08","LICENSE-APACHE":"c6596eb7be8581c18be736c846fb9173b69eccf6ef94c5135893ec56bd92ba08","LICENSE-MIT":"333ea3aaa3cadb819f4acd9f9153f9feee060a995ca8710f32bc5bd9a4b91734","src/build.rs":"bee8027592dff9052e1235a6b1bfd0ae715389265247131c3e1ed865e561ba40","src/lib.rs":"7bb43075bede4947ee8f07a05e4d1b00e0daedadbde15f1b386f97514853ad1c","src/parse.rs":"d8cc189b7108602dee81ff5436a9480dd45397101f7faad875027441e1477ef1"},"package":"1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742"}
|
|
@ -1,35 +0,0 @@
|
|||
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
|
||||
#
|
||||
# When uploading crates to the registry Cargo will automatically
|
||||
# "normalize" Cargo.toml files for maximal compatibility
|
||||
# with all versions of Cargo and also rewrite `path` dependencies
|
||||
# to registry (e.g., crates.io) dependencies.
|
||||
#
|
||||
# If you are reading this file be aware that the original Cargo.toml
|
||||
# will likely look very different (and much more reasonable).
|
||||
# See Cargo.toml.orig for the original contents.
|
||||
|
||||
[package]
|
||||
edition = "2018"
|
||||
name = "foreign-types-macros"
|
||||
version = "0.2.3"
|
||||
authors = ["Steven Fackler <sfackler@gmail.com>"]
|
||||
description = "An internal crate used by foreign-types"
|
||||
license = "MIT/Apache-2.0"
|
||||
repository = "https://github.com/sfackler/foreign-types"
|
||||
|
||||
[lib]
|
||||
proc-macro = true
|
||||
|
||||
[dependencies.proc-macro2]
|
||||
version = "1.0"
|
||||
|
||||
[dependencies.quote]
|
||||
version = "1.0"
|
||||
|
||||
[dependencies.syn]
|
||||
version = "2.0"
|
||||
features = ["full"]
|
||||
|
||||
[features]
|
||||
std = []
|
|
@ -1,202 +0,0 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright {yyyy} {name of copyright owner}
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
Copyright (c) 2017 The foreign-types Developers
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
|
@ -1,261 +0,0 @@
|
|||
use proc_macro2::TokenStream;
|
||||
use quote::quote;
|
||||
use syn::{Ident, Path};
|
||||
|
||||
use crate::parse::{ForeignType, Input};
|
||||
|
||||
fn ref_name(input: &ForeignType) -> Ident {
|
||||
Ident::new(&format!("{}Ref", input.name), input.name.span())
|
||||
}
|
||||
|
||||
pub fn build(input: Input) -> TokenStream {
|
||||
let types = input
|
||||
.types
|
||||
.iter()
|
||||
.map(|t| build_foreign_type(&input.crate_, t));
|
||||
quote! {
|
||||
#(#types)*
|
||||
}
|
||||
}
|
||||
|
||||
fn build_foreign_type(crate_: &Path, input: &ForeignType) -> TokenStream {
|
||||
let decls = build_decls(crate_, input);
|
||||
let oibits = build_oibits(crate_, input);
|
||||
let foreign_impls = build_foreign_impls(crate_, input);
|
||||
let drop_impl = build_drop_impl(crate_, input);
|
||||
let deref_impls = build_deref_impls(crate_, input);
|
||||
let borrow_impls = build_borrow_impls(crate_, input);
|
||||
let as_ref_impls = build_as_ref_impls(crate_, input);
|
||||
let clone_impl = build_clone_impl(crate_, input);
|
||||
let to_owned_impl = build_to_owned_impl(crate_, input);
|
||||
|
||||
quote! {
|
||||
#decls
|
||||
#oibits
|
||||
#foreign_impls
|
||||
#drop_impl
|
||||
#deref_impls
|
||||
#borrow_impls
|
||||
#as_ref_impls
|
||||
#clone_impl
|
||||
#to_owned_impl
|
||||
}
|
||||
}
|
||||
|
||||
fn build_decls(crate_: &Path, input: &ForeignType) -> TokenStream {
|
||||
let attrs = &input.attrs;
|
||||
let vis = &input.visibility;
|
||||
let name = &input.name;
|
||||
let generics = &input.generics;
|
||||
let ctype = &input.ctype;
|
||||
let phantom_data = input
|
||||
.phantom_data
|
||||
.as_ref()
|
||||
.map(|d| quote!(, #crate_::export::PhantomData<#d>));
|
||||
let ref_name = ref_name(input);
|
||||
let ref_docs = format!(
|
||||
"A borrowed reference to a [`{name}`](struct.{name}.html).",
|
||||
name = name
|
||||
);
|
||||
|
||||
quote! {
|
||||
#(#attrs)*
|
||||
#[repr(transparent)]
|
||||
#vis struct #name #generics(#crate_::export::NonNull<#ctype> #phantom_data);
|
||||
|
||||
#[doc = #ref_docs]
|
||||
#vis struct #ref_name #generics(#crate_::Opaque #phantom_data);
|
||||
}
|
||||
}
|
||||
|
||||
fn build_oibits(crate_: &Path, input: &ForeignType) -> TokenStream {
|
||||
let oibits = input.oibits.iter().map(|t| build_oibit(crate_, input, t));
|
||||
|
||||
quote! {
|
||||
#(#oibits)*
|
||||
}
|
||||
}
|
||||
|
||||
fn build_oibit(crate_: &Path, input: &ForeignType, oibit: &Ident) -> TokenStream {
|
||||
let name = &input.name;
|
||||
let ref_name = ref_name(input);
|
||||
let (impl_generics, ty_generics, _) = input.generics.split_for_impl();
|
||||
|
||||
quote! {
|
||||
unsafe impl #impl_generics #crate_::export::#oibit for #name #ty_generics {}
|
||||
unsafe impl #impl_generics #crate_::export::#oibit for #ref_name #ty_generics {}
|
||||
}
|
||||
}
|
||||
|
||||
fn build_foreign_impls(crate_: &Path, input: &ForeignType) -> TokenStream {
|
||||
let name = &input.name;
|
||||
let ctype = &input.ctype;
|
||||
let ref_name = ref_name(input);
|
||||
let (impl_generics, ty_generics, _) = input.generics.split_for_impl();
|
||||
let phantom_data = input
|
||||
.phantom_data
|
||||
.as_ref()
|
||||
.map(|_| quote!(, #crate_::export::PhantomData));
|
||||
|
||||
quote! {
|
||||
unsafe impl #impl_generics #crate_::ForeignType for #name #ty_generics {
|
||||
type CType = #ctype;
|
||||
type Ref = #ref_name #ty_generics;
|
||||
|
||||
#[inline]
|
||||
unsafe fn from_ptr(ptr: *mut #ctype) -> #name #ty_generics {
|
||||
debug_assert!(!ptr.is_null());
|
||||
#name(<#crate_::export::NonNull<_>>::new_unchecked(ptr) #phantom_data)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn as_ptr(&self) -> *mut #ctype {
|
||||
<#crate_::export::NonNull<_>>::as_ptr(self.0)
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl #impl_generics #crate_::ForeignTypeRef for #ref_name #ty_generics {
|
||||
type CType = #ctype;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn build_drop_impl(crate_: &Path, input: &ForeignType) -> TokenStream {
|
||||
let name = &input.name;
|
||||
let drop = &input.drop;
|
||||
let (impl_generics, ty_generics, _) = input.generics.split_for_impl();
|
||||
|
||||
quote! {
|
||||
impl #impl_generics #crate_::export::Drop for #name #ty_generics {
|
||||
#[inline]
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
(#drop)(#crate_::ForeignType::as_ptr(self));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn build_deref_impls(crate_: &Path, input: &ForeignType) -> TokenStream {
|
||||
let name = &input.name;
|
||||
let ref_name = ref_name(input);
|
||||
let (impl_generics, ty_generics, _) = input.generics.split_for_impl();
|
||||
|
||||
quote! {
|
||||
impl #impl_generics #crate_::export::Deref for #name #ty_generics {
|
||||
type Target = #ref_name #ty_generics;
|
||||
|
||||
#[inline]
|
||||
fn deref(&self) -> &#ref_name #ty_generics {
|
||||
unsafe {
|
||||
#crate_::ForeignTypeRef::from_ptr(#crate_::ForeignType::as_ptr(self))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl #impl_generics #crate_::export::DerefMut for #name #ty_generics {
|
||||
#[inline]
|
||||
fn deref_mut(&mut self) -> &mut #ref_name #ty_generics {
|
||||
unsafe {
|
||||
#crate_::ForeignTypeRef::from_ptr_mut(#crate_::ForeignType::as_ptr(self))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn build_borrow_impls(crate_: &Path, input: &ForeignType) -> TokenStream {
|
||||
let name = &input.name;
|
||||
let ref_name = ref_name(input);
|
||||
let (impl_generics, ty_generics, _) = input.generics.split_for_impl();
|
||||
|
||||
quote! {
|
||||
impl #impl_generics #crate_::export::Borrow<#ref_name #ty_generics> for #name #ty_generics {
|
||||
#[inline]
|
||||
fn borrow(&self) -> &#ref_name #ty_generics {
|
||||
&**self
|
||||
}
|
||||
}
|
||||
|
||||
impl #impl_generics #crate_::export::BorrowMut<#ref_name #ty_generics> for #name #ty_generics {
|
||||
#[inline]
|
||||
fn borrow_mut(&mut self) -> &mut #ref_name #ty_generics {
|
||||
&mut **self
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn build_as_ref_impls(crate_: &Path, input: &ForeignType) -> TokenStream {
|
||||
let name = &input.name;
|
||||
let ref_name = ref_name(input);
|
||||
let (impl_generics, ty_generics, _) = input.generics.split_for_impl();
|
||||
|
||||
quote! {
|
||||
impl #impl_generics #crate_::export::AsRef<#ref_name #ty_generics> for #name #ty_generics {
|
||||
#[inline]
|
||||
fn as_ref(&self) -> &#ref_name #ty_generics {
|
||||
&**self
|
||||
}
|
||||
}
|
||||
|
||||
impl #impl_generics #crate_::export::AsMut<#ref_name #ty_generics> for #name #ty_generics {
|
||||
#[inline]
|
||||
fn as_mut(&mut self) -> &mut #ref_name #ty_generics {
|
||||
&mut **self
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn build_clone_impl(crate_: &Path, input: &ForeignType) -> TokenStream {
|
||||
let clone = match &input.clone {
|
||||
Some(clone) => clone,
|
||||
None => return quote!(),
|
||||
};
|
||||
let name = &input.name;
|
||||
let (impl_generics, ty_generics, _) = input.generics.split_for_impl();
|
||||
|
||||
quote! {
|
||||
impl #impl_generics #crate_::export::Clone for #name #ty_generics {
|
||||
#[inline]
|
||||
fn clone(&self) -> #name #ty_generics {
|
||||
unsafe {
|
||||
let ptr = (#clone)(#crate_::ForeignType::as_ptr(self));
|
||||
#crate_::ForeignType::from_ptr(ptr)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
fn build_to_owned_impl(crate_: &Path, input: &ForeignType) -> TokenStream {
|
||||
let clone = match &input.clone {
|
||||
Some(clone) => clone,
|
||||
None => return quote!(),
|
||||
};
|
||||
let name = &input.name;
|
||||
let ref_name = ref_name(input);
|
||||
let (impl_generics, ty_generics, _) = input.generics.split_for_impl();
|
||||
|
||||
quote! {
|
||||
impl #impl_generics #crate_::export::ToOwned for #ref_name #ty_generics {
|
||||
type Owned = #name #ty_generics;
|
||||
|
||||
#[inline]
|
||||
fn to_owned(&self) -> #name #ty_generics {
|
||||
unsafe {
|
||||
let ptr = (#clone)(#crate_::ForeignTypeRef::as_ptr(self));
|
||||
#crate_::ForeignType::from_ptr(ptr)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
fn build_to_owned_impl(_: &Path, _: &ForeignType) -> TokenStream {
|
||||
quote!()
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
extern crate proc_macro;
|
||||
|
||||
use proc_macro::TokenStream;
|
||||
use syn::parse_macro_input;
|
||||
|
||||
use crate::parse::Input;
|
||||
|
||||
mod build;
|
||||
mod parse;
|
||||
|
||||
#[proc_macro]
|
||||
pub fn foreign_type_impl(input: TokenStream) -> TokenStream {
|
||||
let input = parse_macro_input!(input as Input);
|
||||
build::build(input).into()
|
||||
}
|
|
@ -1,140 +0,0 @@
|
|||
use syn::parse::{self, Parse, ParseStream};
|
||||
use syn::punctuated::Punctuated;
|
||||
use syn::token;
|
||||
use syn::{braced, Attribute, Expr, Generics, Ident, Path, Token, Type, Visibility};
|
||||
|
||||
mod kw {
|
||||
syn::custom_keyword!(Sync);
|
||||
syn::custom_keyword!(Send);
|
||||
syn::custom_keyword!(PhantomData);
|
||||
syn::custom_keyword!(CType);
|
||||
syn::custom_keyword!(drop);
|
||||
syn::custom_keyword!(clone);
|
||||
}
|
||||
|
||||
pub struct Input {
|
||||
pub crate_: Path,
|
||||
pub types: Vec<ForeignType>,
|
||||
}
|
||||
|
||||
impl Parse for Input {
|
||||
fn parse(input: ParseStream) -> parse::Result<Input> {
|
||||
let crate_ = input.parse()?;
|
||||
let mut types = vec![];
|
||||
while !input.is_empty() {
|
||||
types.push(input.parse()?);
|
||||
}
|
||||
|
||||
Ok(Input { crate_, types })
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ForeignType {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub visibility: Visibility,
|
||||
pub name: Ident,
|
||||
pub generics: Generics,
|
||||
pub oibits: Punctuated<Ident, Token![+]>,
|
||||
pub phantom_data: Option<Type>,
|
||||
pub ctype: Type,
|
||||
pub drop: Expr,
|
||||
pub clone: Option<Expr>,
|
||||
}
|
||||
|
||||
impl Parse for ForeignType {
|
||||
fn parse(input: ParseStream) -> parse::Result<ForeignType> {
|
||||
let attrs = input.call(Attribute::parse_outer)?;
|
||||
let visibility = input.parse()?;
|
||||
input.parse::<Token![unsafe]>()?;
|
||||
input.parse::<Token![type]>()?;
|
||||
let name = input.parse()?;
|
||||
let generics = input.parse()?;
|
||||
let oibits = input.call(parse_oibits)?;
|
||||
let inner;
|
||||
braced!(inner in input);
|
||||
let ctype = inner.call(parse_type::<kw::CType>)?;
|
||||
let phantom_data = inner.call(parse_phantom_data)?;
|
||||
let drop = inner.call(parse_fn::<kw::drop>)?;
|
||||
let clone = inner.call(parse_clone)?;
|
||||
|
||||
Ok(ForeignType {
|
||||
attrs,
|
||||
visibility,
|
||||
name,
|
||||
generics,
|
||||
oibits,
|
||||
ctype,
|
||||
phantom_data,
|
||||
drop,
|
||||
clone,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_oibit(input: ParseStream) -> parse::Result<Ident> {
|
||||
let lookahead = input.lookahead1();
|
||||
if lookahead.peek(kw::Sync) || lookahead.peek(kw::Send) {
|
||||
input.parse()
|
||||
} else {
|
||||
Err(lookahead.error())
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_oibits(input: ParseStream) -> parse::Result<Punctuated<Ident, Token![+]>> {
|
||||
let mut out = Punctuated::new();
|
||||
|
||||
if input.parse::<Option<Token![:]>>()?.is_some() {
|
||||
loop {
|
||||
out.push_value(input.call(parse_oibit)?);
|
||||
if input.peek(token::Brace) {
|
||||
break;
|
||||
}
|
||||
out.push_punct(input.parse()?);
|
||||
if input.peek(token::Brace) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(out)
|
||||
}
|
||||
|
||||
fn parse_type<T>(input: ParseStream) -> parse::Result<Type>
|
||||
where
|
||||
T: Parse,
|
||||
{
|
||||
input.parse::<Token![type]>()?;
|
||||
input.parse::<T>()?;
|
||||
input.parse::<Token![=]>()?;
|
||||
let type_ = input.parse()?;
|
||||
input.parse::<Token![;]>()?;
|
||||
Ok(type_)
|
||||
}
|
||||
|
||||
fn parse_phantom_data(input: ParseStream) -> parse::Result<Option<Type>> {
|
||||
if input.peek(Token![type]) && input.peek2(kw::PhantomData) {
|
||||
input.call(parse_type::<kw::PhantomData>).map(Some)
|
||||
} else {
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_fn<T>(input: ParseStream) -> parse::Result<Expr>
|
||||
where
|
||||
T: Parse,
|
||||
{
|
||||
input.parse::<Token![fn]>()?;
|
||||
input.parse::<T>()?;
|
||||
input.parse::<Token![=]>()?;
|
||||
let path = input.parse()?;
|
||||
input.parse::<Token![;]>()?;
|
||||
Ok(path)
|
||||
}
|
||||
|
||||
fn parse_clone(input: ParseStream) -> parse::Result<Option<Expr>> {
|
||||
if input.peek(Token![fn]) && input.peek2(kw::clone) {
|
||||
input.call(parse_fn::<kw::clone>).map(Some)
|
||||
} else {
|
||||
Ok(None)
|
||||
}
|
||||
}
|
|
@ -1 +1 @@
|
|||
{"files":{"Cargo.toml":"096ac915be03aa1eb99b12ad4c5552a50bd550de4d1fb9a52e0799319f98f994","LICENSE-APACHE":"c6596eb7be8581c18be736c846fb9173b69eccf6ef94c5135893ec56bd92ba08","LICENSE-MIT":"333ea3aaa3cadb819f4acd9f9153f9feee060a995ca8710f32bc5bd9a4b91734","src/lib.rs":"60aa483e41abdbdc3b5057e3ff75abd63d0e92263d93a50d8fd739910a0b19e8"},"package":"aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b"}
|
||||
{"files":{"Cargo.toml":"6b91ae600fe7b521537096b2269ab7bfd606f8a1fcd97749634dd03ba18daf53","LICENSE-APACHE":"c6596eb7be8581c18be736c846fb9173b69eccf6ef94c5135893ec56bd92ba08","LICENSE-MIT":"333ea3aaa3cadb819f4acd9f9153f9feee060a995ca8710f32bc5bd9a4b91734","src/lib.rs":"77aed289fd36258c273f033e766e572ee05330249083c017d045f0a75662f5df"},"package":"00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"}
|
|
@ -3,16 +3,16 @@
|
|||
# When uploading crates to the registry Cargo will automatically
|
||||
# "normalize" Cargo.toml files for maximal compatibility
|
||||
# with all versions of Cargo and also rewrite `path` dependencies
|
||||
# to registry (e.g., crates.io) dependencies.
|
||||
# to registry (e.g. crates.io) dependencies
|
||||
#
|
||||
# If you are reading this file be aware that the original Cargo.toml
|
||||
# will likely look very different (and much more reasonable).
|
||||
# See Cargo.toml.orig for the original contents.
|
||||
# If you believe there's an error in this file please file an
|
||||
# issue against the rust-lang/cargo repository. If you're
|
||||
# editing this file be aware that the upstream Cargo.toml
|
||||
# will likely look very different (and much more reasonable)
|
||||
|
||||
[package]
|
||||
edition = "2018"
|
||||
name = "foreign-types-shared"
|
||||
version = "0.3.1"
|
||||
version = "0.1.1"
|
||||
authors = ["Steven Fackler <sfackler@gmail.com>"]
|
||||
description = "An internal crate used by foreign-types"
|
||||
license = "MIT/Apache-2.0"
|
||||
|
|
|
@ -2,29 +2,17 @@
|
|||
|
||||
#![no_std]
|
||||
#![warn(missing_docs)]
|
||||
#![doc(html_root_url = "https://docs.rs/foreign-types-shared/0.3")]
|
||||
#![doc(html_root_url="https://docs.rs/foreign-types-shared/0.1")]
|
||||
|
||||
use core::cell::UnsafeCell;
|
||||
use core::marker::PhantomData;
|
||||
use core::mem;
|
||||
|
||||
/// An opaque type used to define `ForeignTypeRef` types.
|
||||
///
|
||||
/// A type implementing `ForeignTypeRef` should simply be a newtype wrapper around this type.
|
||||
pub struct Opaque(PhantomData<UnsafeCell<*mut ()>>);
|
||||
pub struct Opaque(UnsafeCell<()>);
|
||||
|
||||
/// A type implemented by wrappers over foreign types.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// Implementations of `ForeignType` must guarantee the following:
|
||||
/// - `Self::from_ptr(x).as_ptr() == x`
|
||||
/// - `Self::from_ptr(x).into_ptr(x) == x`
|
||||
/// - `Self::from_ptr(x).deref().as_ptr(x) == x`
|
||||
/// - `Self::from_ptr(x).deref_mut().as_ptr(x) == x`
|
||||
/// - `Self::from_ptr(x).as_ref().as_ptr(x) == x`
|
||||
/// - `Self::from_ptr(x).as_mut().as_ptr(x) == x`
|
||||
pub unsafe trait ForeignType: Sized {
|
||||
pub trait ForeignType: Sized {
|
||||
/// The raw C type.
|
||||
type CType;
|
||||
|
||||
|
@ -32,55 +20,26 @@ pub unsafe trait ForeignType: Sized {
|
|||
type Ref: ForeignTypeRef<CType = Self::CType>;
|
||||
|
||||
/// Constructs an instance of this type from its raw type.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// `ptr` must be a valid, owned instance of the native type.
|
||||
unsafe fn from_ptr(ptr: *mut Self::CType) -> Self;
|
||||
|
||||
/// Returns a raw pointer to the wrapped value.
|
||||
fn as_ptr(&self) -> *mut Self::CType;
|
||||
|
||||
/// Consumes the wrapper and returns the raw pointer.
|
||||
#[inline]
|
||||
fn into_ptr(self) -> *mut Self::CType {
|
||||
let ptr = self.as_ptr();
|
||||
mem::forget(self);
|
||||
ptr
|
||||
}
|
||||
}
|
||||
|
||||
/// A trait implemented by types which reference borrowed foreign types.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// Implementations of `ForeignTypeRef` must guarantee the following:
|
||||
///
|
||||
/// - `Self::from_ptr(x).as_ptr() == x`
|
||||
/// - `Self::from_mut_ptr(x).as_ptr() == x`
|
||||
pub unsafe trait ForeignTypeRef: Sized {
|
||||
pub trait ForeignTypeRef: Sized {
|
||||
/// The raw C type.
|
||||
type CType;
|
||||
|
||||
/// Constructs a shared instance of this type from its raw type.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// `ptr` must be a valid, immutable, instance of the type for the `'a` lifetime.
|
||||
#[inline]
|
||||
unsafe fn from_ptr<'a>(ptr: *mut Self::CType) -> &'a Self {
|
||||
debug_assert!(!ptr.is_null());
|
||||
&*(ptr as *mut _)
|
||||
}
|
||||
|
||||
/// Constructs a mutable reference of this type from its raw type.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// `ptr` must be a valid, unique, instance of the type for the `'a` lifetime.
|
||||
#[inline]
|
||||
unsafe fn from_ptr_mut<'a>(ptr: *mut Self::CType) -> &'a mut Self {
|
||||
debug_assert!(!ptr.is_null());
|
||||
&mut *(ptr as *mut _)
|
||||
}
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"files":{"Cargo.toml":"2e1b7838114ee31147555eb858dd837f1f8ac80d53f00c62b2c81c5a0121224d","LICENSE-APACHE":"c6596eb7be8581c18be736c846fb9173b69eccf6ef94c5135893ec56bd92ba08","LICENSE-MIT":"333ea3aaa3cadb819f4acd9f9153f9feee060a995ca8710f32bc5bd9a4b91734","README.md":"6f3f1429f2724a481df811842f318d0d3b83160ada953fd869d4b685f7fd72e4","src/lib.rs":"a0039cfb11b235119b81ba8d31987c19d8fd6e1d23abbde57e67747fdd8f0ad0","tests/test.rs":"7913e5e040b75e5b63bf813d25a0491cb8e9b51857a039cf3b56d7f10fc787d3"},"package":"d737d9aa519fb7b749cbc3b962edcf310a8dd1f4b67c91c4f83975dbdd17d965"}
|
||||
{"files":{"Cargo.toml":"1a667c28f60115423b68fea369255c2dcb129b8dce10f30e0e1da73d05f9adab","LICENSE-APACHE":"c6596eb7be8581c18be736c846fb9173b69eccf6ef94c5135893ec56bd92ba08","LICENSE-MIT":"333ea3aaa3cadb819f4acd9f9153f9feee060a995ca8710f32bc5bd9a4b91734","README.md":"6f3f1429f2724a481df811842f318d0d3b83160ada953fd869d4b685f7fd72e4","src/lib.rs":"4f0a33bf8ec94a57d1b71e50f1af8ca410985e447f69fdc9c680545b03ea4566"},"package":"f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"}
|
|
@ -3,7 +3,7 @@
|
|||
# When uploading crates to the registry Cargo will automatically
|
||||
# "normalize" Cargo.toml files for maximal compatibility
|
||||
# with all versions of Cargo and also rewrite `path` dependencies
|
||||
# to registry (e.g., crates.io) dependencies
|
||||
# to registry (e.g. crates.io) dependencies
|
||||
#
|
||||
# If you believe there's an error in this file please file an
|
||||
# issue against the rust-lang/cargo repository. If you're
|
||||
|
@ -11,20 +11,12 @@
|
|||
# will likely look very different (and much more reasonable)
|
||||
|
||||
[package]
|
||||
edition = "2018"
|
||||
name = "foreign-types"
|
||||
version = "0.5.0"
|
||||
version = "0.3.2"
|
||||
authors = ["Steven Fackler <sfackler@gmail.com>"]
|
||||
description = "A framework for Rust wrappers over C APIs"
|
||||
readme = "README.md"
|
||||
license = "MIT/Apache-2.0"
|
||||
repository = "https://github.com/sfackler/foreign-types"
|
||||
[dependencies.foreign-types-macros]
|
||||
version = "0.2"
|
||||
|
||||
[dependencies.foreign-types-shared]
|
||||
version = "0.3"
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = ["foreign-types-macros/std"]
|
||||
version = "0.1"
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
//! ```
|
||||
//! use foreign_types::{ForeignType, ForeignTypeRef, Opaque};
|
||||
//! use std::ops::{Deref, DerefMut};
|
||||
//! use std::ptr::NonNull;
|
||||
//!
|
||||
//! mod foo_sys {
|
||||
//! pub enum FOO {}
|
||||
|
@ -31,7 +30,7 @@
|
|||
//! // from raw C pointers.
|
||||
//! pub struct FooRef(Opaque);
|
||||
//!
|
||||
//! unsafe impl ForeignTypeRef for FooRef {
|
||||
//! impl ForeignTypeRef for FooRef {
|
||||
//! type CType = foo_sys::FOO;
|
||||
//! }
|
||||
//!
|
||||
|
@ -39,36 +38,24 @@
|
|||
//! //
|
||||
//! // It dereferences to `FooRef`, so methods that do not require ownership
|
||||
//! // should be defined there.
|
||||
//! pub struct Foo(NonNull<foo_sys::FOO>);
|
||||
//!
|
||||
//! unsafe impl Sync for FooRef {}
|
||||
//! unsafe impl Send for FooRef {}
|
||||
//!
|
||||
//! unsafe impl Sync for Foo {}
|
||||
//! unsafe impl Send for Foo {}
|
||||
//! pub struct Foo(*mut foo_sys::FOO);
|
||||
//!
|
||||
//! impl Drop for Foo {
|
||||
//! fn drop(&mut self) {
|
||||
//! unsafe { foo_sys::FOO_free(self.as_ptr()) }
|
||||
//! unsafe { foo_sys::FOO_free(self.0) }
|
||||
//! }
|
||||
//! }
|
||||
//!
|
||||
//! unsafe impl ForeignType for Foo {
|
||||
//! impl ForeignType for Foo {
|
||||
//! type CType = foo_sys::FOO;
|
||||
//! type Ref = FooRef;
|
||||
//!
|
||||
//! unsafe fn from_ptr(ptr: *mut foo_sys::FOO) -> Foo {
|
||||
//! Foo(NonNull::new_unchecked(ptr))
|
||||
//! Foo(ptr)
|
||||
//! }
|
||||
//!
|
||||
//! fn as_ptr(&self) -> *mut foo_sys::FOO {
|
||||
//! self.0.as_ptr()
|
||||
//! }
|
||||
//!
|
||||
//! fn into_ptr(self) -> *mut foo_sys::FOO {
|
||||
//! let inner = self.as_ptr();
|
||||
//! ::core::mem::forget(self);
|
||||
//! inner
|
||||
//! self.0
|
||||
//! }
|
||||
//! }
|
||||
//!
|
||||
|
@ -76,60 +63,50 @@
|
|||
//! type Target = FooRef;
|
||||
//!
|
||||
//! fn deref(&self) -> &FooRef {
|
||||
//! unsafe { FooRef::from_ptr(self.as_ptr()) }
|
||||
//! unsafe { FooRef::from_ptr(self.0) }
|
||||
//! }
|
||||
//! }
|
||||
//!
|
||||
//! impl DerefMut for Foo {
|
||||
//! fn deref_mut(&mut self) -> &mut FooRef {
|
||||
//! unsafe { FooRef::from_ptr_mut(self.as_ptr()) }
|
||||
//! unsafe { FooRef::from_ptr_mut(self.0) }
|
||||
//! }
|
||||
//! }
|
||||
//!
|
||||
//! // add in Borrow, BorrowMut, AsRef, AsRefMut, Clone, ToOwned...
|
||||
//! ```
|
||||
//!
|
||||
//! The `foreign_type!` macro can generate this boilerplate for you:
|
||||
//!
|
||||
//! ```
|
||||
//! use foreign_types::foreign_type;
|
||||
//! #[macro_use]
|
||||
//! extern crate foreign_types;
|
||||
//!
|
||||
//! mod foo_sys {
|
||||
//! pub enum FOO {}
|
||||
//!
|
||||
//! extern {
|
||||
//! pub fn FOO_free(foo: *mut FOO);
|
||||
//! pub fn FOO_duplicate(foo: *mut FOO) -> *mut FOO; // optional
|
||||
//! pub fn FOO_duplicate(foo: *mut FOO) -> *mut FOO; // Optional
|
||||
//! }
|
||||
//! }
|
||||
//!
|
||||
//! foreign_type! {
|
||||
//! type CType = foo_sys::FOO;
|
||||
//! fn drop = foo_sys::FOO_free;
|
||||
//! fn clone = foo_sys::FOO_duplicate; // Optional
|
||||
//! /// A Foo.
|
||||
//! pub unsafe type Foo
|
||||
//! : Sync + Send // optional
|
||||
//! {
|
||||
//! type CType = foo_sys::FOO;
|
||||
//! fn drop = foo_sys::FOO_free;
|
||||
//! fn clone = foo_sys::FOO_duplicate; // optional
|
||||
//! }
|
||||
//!
|
||||
//! /// A Foo with generic parameters.
|
||||
//! pub unsafe type GenericFoo<T> {
|
||||
//! type CType = foo_sys::FOO;
|
||||
//! // This type is added as a `PhantomData` field to handle variance
|
||||
//! // of the parameters. However, it has no impact on trait impls:
|
||||
//! // `GenericFoo<T>` is always `Clone`, even if `T` is not.
|
||||
//! type PhantomData = T;
|
||||
//! fn drop = foo_sys::FOO_free;
|
||||
//! fn clone = foo_sys::FOO_duplicate;
|
||||
//! }
|
||||
//! pub struct Foo;
|
||||
//! /// A borrowed Foo.
|
||||
//! pub struct FooRef;
|
||||
//! }
|
||||
//!
|
||||
//! # fn main() {}
|
||||
//! ```
|
||||
//!
|
||||
//! If `fn clone` is specified, then it must take `CType` as an argument and return a copy of it as `CType`.
|
||||
//! It will be used to implement `Clone`, and if the `std` Cargo feature is enabled, `ToOwned`.
|
||||
//! It will be used to implement `ToOwned` and `Clone`.
|
||||
//!
|
||||
//! `#[derive(…)] is permitted before the lines with `pub struct`.
|
||||
//! `#[doc(hidden)]` before the `type CType` line will hide the `foreign_type!` implementations from documentation.
|
||||
//!
|
||||
//! Say we then have a separate type in our C API that contains a `FOO`:
|
||||
//!
|
||||
|
@ -151,7 +128,10 @@
|
|||
//! modify the `FOO`, so we'll define a pair of accessor methods, one immutable and one mutable:
|
||||
//!
|
||||
//! ```
|
||||
//! use foreign_types::{ForeignTypeRef, foreign_type};
|
||||
//! #[macro_use]
|
||||
//! extern crate foreign_types;
|
||||
//!
|
||||
//! use foreign_types::ForeignTypeRef;
|
||||
//!
|
||||
//! mod foo_sys {
|
||||
//! pub enum FOO {}
|
||||
|
@ -165,17 +145,22 @@
|
|||
//! }
|
||||
//!
|
||||
//! foreign_type! {
|
||||
//! /// A Foo.
|
||||
//! pub unsafe type Foo: Sync + Send {
|
||||
//! #[doc(hidden)]
|
||||
//! type CType = foo_sys::FOO;
|
||||
//! fn drop = foo_sys::FOO_free;
|
||||
//! /// A Foo.
|
||||
//! pub struct Foo;
|
||||
//! /// A borrowed Foo.
|
||||
//! pub struct FooRef;
|
||||
//! }
|
||||
//!
|
||||
//! /// A Bar.
|
||||
//! pub unsafe type Bar: Sync + Send {
|
||||
//! foreign_type! {
|
||||
//! type CType = foo_sys::BAR;
|
||||
//! fn drop = foo_sys::BAR_free;
|
||||
//! }
|
||||
//! /// A Foo.
|
||||
//! pub struct Bar;
|
||||
//! /// A borrowed Bar.
|
||||
//! pub struct BarRef;
|
||||
//! }
|
||||
//!
|
||||
//! impl BarRef {
|
||||
|
@ -192,59 +177,130 @@
|
|||
//! ```
|
||||
#![no_std]
|
||||
#![warn(missing_docs)]
|
||||
#![doc(html_root_url = "https://docs.rs/foreign-types/0.5")]
|
||||
#![doc(html_root_url="https://docs.rs/foreign-types/0.3")]
|
||||
extern crate foreign_types_shared;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
extern crate std;
|
||||
|
||||
#[doc(hidden)]
|
||||
pub use foreign_types_macros::foreign_type_impl;
|
||||
#[doc(inline)]
|
||||
pub use foreign_types_shared::{ForeignType, ForeignTypeRef, Opaque};
|
||||
|
||||
#[doc(hidden)]
|
||||
pub mod export {
|
||||
pub use core::borrow::{Borrow, BorrowMut};
|
||||
pub use core::clone::Clone;
|
||||
pub use core::convert::{AsMut, AsRef};
|
||||
pub use core::marker::{PhantomData, Send, Sync};
|
||||
pub use core::ops::{Deref, DerefMut, Drop};
|
||||
pub use core::ptr::NonNull;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
pub use std::borrow::ToOwned;
|
||||
}
|
||||
pub use foreign_types_shared::*;
|
||||
|
||||
/// A macro to easily define wrappers for foreign types.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use foreign_types::foreign_type;
|
||||
/// #[macro_use]
|
||||
/// extern crate foreign_types;
|
||||
///
|
||||
/// # mod openssl_sys { pub type SSL = (); pub unsafe fn SSL_free(_: *mut SSL) {} pub unsafe fn SSL_dup(x: *mut SSL) -> *mut SSL {x} }
|
||||
/// # mod foo_sys { pub type THING = (); pub unsafe fn THING_free(_: *mut THING) {} }
|
||||
/// foreign_type! {
|
||||
/// /// Documentation for the owned type.
|
||||
/// pub unsafe type Ssl: Sync + Send {
|
||||
/// type CType = openssl_sys::SSL;
|
||||
/// fn drop = openssl_sys::SSL_free;
|
||||
/// fn clone = openssl_sys::SSL_dup;
|
||||
/// }
|
||||
///
|
||||
/// /// This type immutably borrows other data and has a limited lifetime!
|
||||
/// pub unsafe type Thing<'a>: Send {
|
||||
/// type CType = foo_sys::THING;
|
||||
/// type PhantomData = &'a ();
|
||||
/// fn drop = foo_sys::THING_free;
|
||||
/// }
|
||||
/// /// Documentation for the owned type.
|
||||
/// pub struct Ssl;
|
||||
/// /// Documentation for the borrowed type.
|
||||
/// pub struct SslRef;
|
||||
/// }
|
||||
///
|
||||
/// # fn main() {}
|
||||
/// ```
|
||||
#[macro_export(local_inner_macros)]
|
||||
#[macro_export]
|
||||
macro_rules! foreign_type {
|
||||
($($t:tt)*) => {
|
||||
$crate::foreign_type_impl!($crate $($t)*);
|
||||
};
|
||||
(
|
||||
$(#[$impl_attr:meta])*
|
||||
type CType = $ctype:ty;
|
||||
fn drop = $drop:expr;
|
||||
$(fn clone = $clone:expr;)*
|
||||
$(#[$owned_attr:meta])*
|
||||
pub struct $owned:ident;
|
||||
$(#[$borrowed_attr:meta])*
|
||||
pub struct $borrowed:ident;
|
||||
) => {
|
||||
$(#[$owned_attr])*
|
||||
pub struct $owned(*mut $ctype);
|
||||
|
||||
$(#[$impl_attr])*
|
||||
impl $crate::ForeignType for $owned {
|
||||
type CType = $ctype;
|
||||
type Ref = $borrowed;
|
||||
|
||||
#[inline]
|
||||
unsafe fn from_ptr(ptr: *mut $ctype) -> $owned {
|
||||
$owned(ptr)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn as_ptr(&self) -> *mut $ctype {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for $owned {
|
||||
#[inline]
|
||||
fn drop(&mut self) {
|
||||
unsafe { $drop(self.0) }
|
||||
}
|
||||
}
|
||||
|
||||
$(
|
||||
impl Clone for $owned {
|
||||
#[inline]
|
||||
fn clone(&self) -> $owned {
|
||||
unsafe {
|
||||
let handle: *mut $ctype = $clone(self.0);
|
||||
$crate::ForeignType::from_ptr(handle)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ::std::borrow::ToOwned for $borrowed {
|
||||
type Owned = $owned;
|
||||
#[inline]
|
||||
fn to_owned(&self) -> $owned {
|
||||
unsafe {
|
||||
let handle: *mut $ctype = $clone($crate::ForeignTypeRef::as_ptr(self));
|
||||
$crate::ForeignType::from_ptr(handle)
|
||||
}
|
||||
}
|
||||
}
|
||||
)*
|
||||
|
||||
impl ::std::ops::Deref for $owned {
|
||||
type Target = $borrowed;
|
||||
|
||||
#[inline]
|
||||
fn deref(&self) -> &$borrowed {
|
||||
unsafe { $crate::ForeignTypeRef::from_ptr(self.0) }
|
||||
}
|
||||
}
|
||||
|
||||
impl ::std::ops::DerefMut for $owned {
|
||||
#[inline]
|
||||
fn deref_mut(&mut self) -> &mut $borrowed {
|
||||
unsafe { $crate::ForeignTypeRef::from_ptr_mut(self.0) }
|
||||
}
|
||||
}
|
||||
|
||||
impl ::std::borrow::Borrow<$borrowed> for $owned {
|
||||
#[inline]
|
||||
fn borrow(&self) -> &$borrowed {
|
||||
&**self
|
||||
}
|
||||
}
|
||||
|
||||
impl ::std::convert::AsRef<$borrowed> for $owned {
|
||||
#[inline]
|
||||
fn as_ref(&self) -> &$borrowed {
|
||||
&**self
|
||||
}
|
||||
}
|
||||
|
||||
$(#[$borrowed_attr])*
|
||||
pub struct $borrowed($crate::Opaque);
|
||||
|
||||
$(#[$impl_attr])*
|
||||
impl $crate::ForeignTypeRef for $borrowed {
|
||||
type CType = $ctype;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
use foreign_types::foreign_type;
|
||||
|
||||
mod foo_sys {
|
||||
pub enum FOO {}
|
||||
|
||||
pub unsafe extern "C" fn foo_drop(_: *mut FOO) {}
|
||||
pub unsafe extern "C" fn foo_clone(ptr: *mut FOO) -> *mut FOO { ptr }
|
||||
}
|
||||
|
||||
foreign_type! {
|
||||
pub unsafe type Foo<'a, T>: Sync + Send {
|
||||
type CType = foo_sys::FOO;
|
||||
type PhantomData = &'a T;
|
||||
fn drop = foo_sys::foo_drop;
|
||||
fn clone = foo_sys::foo_clone;
|
||||
}
|
||||
|
||||
pub unsafe type Foo2 {
|
||||
type CType = foo_sys::FOO;
|
||||
fn drop = foo_sys::foo_drop;
|
||||
}
|
||||
}
|
|
@ -1 +1 @@
|
|||
{"files":{"Cargo.toml":"ce92a2d32d4b2e50d617595e689b6bca736b7792280480c4057eaebef15bf325","README.md":"5a96b135d18e172f090bd6147830ab3a1b5cefac5f02be28f06cf88eea61b64f","src/device.rs":"8173609d5fb700f8b82d6335729c592ff62c306b12894a9bab9da45a47810e4a","src/lib.rs":"0f77c21a5770b54affa146e5f4c15abcb83599de551226d336ee48ec5185f866","src/types.rs":"aa861f891a63c232441c5a9fe5fed61cac2d62780108c01ebe6cb64a8547b4e2"},"package":"98ff03b468aa837d70984d55f5d3f846f6ec31fe34bbb97c4f85219caeee1ca4"}
|
||||
{"files":{"Cargo.toml":"5ec80402fb950b3e70b291c64a49275dd951221b71ee74f8be5a16a74d42d296","src/device.rs":"1f44d08d50fc59d55bd3f92308e4965bde9134e7f5daa03594e122f7cdb1dfa2","src/lib.rs":"0f77c21a5770b54affa146e5f4c15abcb83599de551226d336ee48ec5185f866","src/types.rs":"8c6acec203faa11856076193835f6d9a1924469682e1fdf11a0325936a1255ee"},"package":"54804d0d6bc9d7f26db4eaec1ad10def69b599315f487d32c334a80d1efe67a5"}
|
|
@ -3,36 +3,24 @@
|
|||
# When uploading crates to the registry Cargo will automatically
|
||||
# "normalize" Cargo.toml files for maximal compatibility
|
||||
# with all versions of Cargo and also rewrite `path` dependencies
|
||||
# to registry (e.g., crates.io) dependencies.
|
||||
# to registry (e.g., crates.io) dependencies
|
||||
#
|
||||
# If you are reading this file be aware that the original Cargo.toml
|
||||
# will likely look very different (and much more reasonable).
|
||||
# See Cargo.toml.orig for the original contents.
|
||||
# If you believe there's an error in this file please file an
|
||||
# issue against the rust-lang/cargo repository. If you're
|
||||
# editing this file be aware that the upstream Cargo.toml
|
||||
# will likely look very different (and much more reasonable)
|
||||
|
||||
[package]
|
||||
edition = "2018"
|
||||
name = "gpu-alloc-types"
|
||||
version = "0.3.0"
|
||||
version = "0.2.0"
|
||||
authors = ["Zakarum <zakarumych@ya.ru>"]
|
||||
description = "Core types of gpu-alloc crate"
|
||||
homepage = "https://github.com/zakarumych/gpu-alloc"
|
||||
documentation = "https://docs.rs/gpu-alloc-types"
|
||||
readme = "README.md"
|
||||
keywords = [
|
||||
"gpu",
|
||||
"vulkan",
|
||||
"allocation",
|
||||
"no-std",
|
||||
]
|
||||
categories = [
|
||||
"graphics",
|
||||
"memory-management",
|
||||
"no-std",
|
||||
"game-development",
|
||||
]
|
||||
documentation = "https://docs.rs/gpu-alloc-types/0.2.0"
|
||||
keywords = ["gpu", "vulkan", "allocation", "no-std"]
|
||||
license = "MIT OR Apache-2.0"
|
||||
repository = "https://github.com/zakarumych/gpu-alloc"
|
||||
|
||||
[dependencies.bitflags]
|
||||
version = "2.0"
|
||||
version = "1.2"
|
||||
default-features = false
|
||||
|
|
|
@ -1,51 +0,0 @@
|
|||
# gpu-alloc
|
||||
|
||||
[![crates](https://img.shields.io/crates/v/gpu-alloc.svg?style=for-the-badge&label=gpu-alloc)](https://crates.io/crates/gpu-alloc)
|
||||
[![docs](https://img.shields.io/badge/docs.rs-gpu--alloc-66c2a5?style=for-the-badge&labelColor=555555&logoColor=white)](https://docs.rs/gpu-alloc)
|
||||
[![actions](https://img.shields.io/github/workflow/status/zakarumych/gpu-alloc/Rust/main?style=for-the-badge)](https://github.com/zakarumych/gpu-alloc/actions?query=workflow%3ARust)
|
||||
[![MIT/Apache](https://img.shields.io/badge/license-MIT%2FApache-blue.svg?style=for-the-badge)](COPYING)
|
||||
![loc](https://img.shields.io/tokei/lines/github/zakarumych/gpu-alloc?style=for-the-badge)
|
||||
|
||||
|
||||
Implementation agnostic memory allocator for Vulkan like APIs.
|
||||
|
||||
This crate is intended to be used as part of safe API implementations.\
|
||||
Use with caution. There are unsafe functions all over the place.
|
||||
|
||||
## Usage
|
||||
|
||||
Start with fetching `DeviceProperties` from `gpu-alloc-<backend>` crate for the backend of choice.\
|
||||
Then create `GpuAllocator` instance and use it for all device memory allocations.\
|
||||
`GpuAllocator` will take care for all necessary bookkeeping like memory object count limit,
|
||||
heap budget and memory mapping.
|
||||
|
||||
#### Backends implementations
|
||||
|
||||
Backend supporting crates should not depend on this crate.\
|
||||
Instead they should depend on `gpu-alloc-types` which is much more stable,
|
||||
allowing to upgrade `gpu-alloc` version without `gpu-alloc-<backend>` upgrade.
|
||||
|
||||
|
||||
Supported Rust Versions
|
||||
|
||||
The minimum supported version is 1.40.
|
||||
The current version is not guaranteed to build on Rust versions earlier than the minimum supported version.
|
||||
|
||||
`gpu-alloc-erupt` crate requires version 1.48 or higher due to dependency on `erupt` crate.
|
||||
|
||||
## License
|
||||
|
||||
Licensed under either of
|
||||
|
||||
* Apache License, Version 2.0, ([license/APACHE](license/APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
|
||||
* MIT license ([license/MIT](license/MIT) or http://opensource.org/licenses/MIT)
|
||||
|
||||
at your option.
|
||||
|
||||
## Contributions
|
||||
|
||||
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
|
||||
|
||||
## Donate
|
||||
|
||||
[![Become a patron](https://c5.patreon.com/external/logo/become_a_patron_button.png)](https://www.patreon.com/zakarum)
|
|
@ -67,7 +67,6 @@ pub struct DeviceProperties<'a> {
|
|||
bitflags::bitflags! {
|
||||
/// Allocation flags
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
|
||||
pub struct AllocationFlags : u8 {
|
||||
/// Specifies that the memory can be used for buffers created
|
||||
/// with flag that allows fetching device address.
|
||||
|
@ -85,7 +84,7 @@ pub trait MemoryDevice<M> {
|
|||
/// # Safety
|
||||
///
|
||||
/// `memory_type` must be valid index for memory type associated with this device.
|
||||
/// Retrieving this information is implementation specific.
|
||||
/// Retreiving this information is implementation specific.
|
||||
///
|
||||
/// `flags` must be supported by the device.
|
||||
unsafe fn allocate_memory(
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
bitflags::bitflags! {
|
||||
/// Memory properties type.
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
|
||||
pub struct MemoryPropertyFlags: u8 {
|
||||
/// This flag is set for device-local memory types.
|
||||
/// Device-local memory is situated "close" to the GPU cores
|
||||
|
@ -43,7 +42,7 @@ pub struct MemoryType {
|
|||
/// Heap index of the memory type.
|
||||
pub heap: u32,
|
||||
|
||||
/// Property flags of the memory type.
|
||||
/// Propety flags of the memory type.
|
||||
pub props: MemoryPropertyFlags,
|
||||
}
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"files":{"Cargo.toml":"3647062a9589eedcc361f51f1e1f0852ae6be3c028d0dc8f8d3c0c944bbca61e","README.md":"5a96b135d18e172f090bd6147830ab3a1b5cefac5f02be28f06cf88eea61b64f","src/allocator.rs":"28f20bbfc3866b4eb94a025027925268178921393f5ab8eb5febad1acf94dce8","src/block.rs":"3553343eb171e7ef8b771a1582489cbbbe22b3a1aca4d54b9ff0174fd30bf0da","src/buddy.rs":"253df5f689b643cf97cfd27be6512ea84b84d3c2097a35f3f2d73f537ab353b3","src/config.rs":"1851264db7576f92f3b455e4667339e1c48b7f1b88f8fae7be95c6a9badde455","src/error.rs":"50e30bccc4ba3b23d99298a65155eec45f7d91b66773e828460907ebdcb8ee41","src/freelist.rs":"92c9241d899f3e92a70b0eb5af0b557a3a76aa14c4a6d23876c3ed7857b5f15b","src/heap.rs":"347c25a8560d39d1abb807fb5c34a6a51d4786c0be24a92293f9c8217bace340","src/lib.rs":"07077fb465fb471b39db99bb0311082133d1c2044c2e192d20f7bbb9e743dd0b","src/slab.rs":"6a2b818087850bd5615b085d912490dbd46bbca0df28daa86932505b3983c64a","src/usage.rs":"99009f2ff532904de3ef66520336cd25bd1b795afcb0158385e78a5908f8308f","src/util.rs":"ce3fd7a278eb4d4bd030d4db5495313f56dc91b0765c394f88d126f11c2b4e75"},"package":"fbcd2dba93594b227a1f57ee09b8b9da8892c34d55aa332e034a228d0fe6a171"}
|
||||
{"files":{"Cargo.toml":"d444caa50cc5b4e0ee201da5347df73c6e77d3eedaae9e69d007c24dd0bb7bfa","src/allocator.rs":"c06b84e062859e1dcd21fa5cd71c8faafcca325b53dcc7b2fee3df945163e820","src/block.rs":"6efc369712e3d880a0d16ab1ef18062a88fefae9bf0a4e626de301cbb1b962ee","src/buddy.rs":"f8eacc183f2ee66faba05dec6f33659afa797e765326c96be4a8bafa651c0e47","src/config.rs":"49bb14c27713c6b1c0c91c094b0f00be22bd26efa660ff979fb1ee1193e9d70e","src/error.rs":"11337a66fc32f3423a1355ffd597d2c7ea28c2b7ce07d707fd5905c330edba08","src/freelist.rs":"3fbbcb96e307e0e021b38df6fe04d129e5d954fcd5a0144e388371442ef20916","src/heap.rs":"03f7c623a0389263073ab48797a191ca06c5611006df7b79c9dc8615c130f495","src/lib.rs":"78800455337d231af24814d84f4e5eb61c5181b12daec06fdcee2d2a75ccb221","src/slab.rs":"2df136b7e0a85eec8a198c7f807678d3a2043c46233e7ec63cd2de72fe562477","src/usage.rs":"0e4788c437718807cdd0b88301228cc27a6b8398313a91e1b70c5f2ab04dcbfb","src/util.rs":"31a496ee3407eb6b0dea255e30e154d805a0d08d777be9c06bdf56d1135bf950"},"package":"7fc59e5f710e310e76e6707f86c561dd646f69a8876da9131703b2f717de818d"}
|
|
@ -12,33 +12,22 @@
|
|||
[package]
|
||||
edition = "2018"
|
||||
name = "gpu-alloc"
|
||||
version = "0.6.0"
|
||||
version = "0.5.3"
|
||||
authors = ["Zakarum <zakarumych@ya.ru>"]
|
||||
description = "Implementation agnostic memory allocator for Vulkan like APIs"
|
||||
homepage = "https://github.com/zakarumych/gpu-alloc"
|
||||
documentation = "https://docs.rs/gpu-alloc-types"
|
||||
readme = "README.md"
|
||||
keywords = [
|
||||
"gpu",
|
||||
"vulkan",
|
||||
"allocation",
|
||||
"no-std",
|
||||
]
|
||||
categories = [
|
||||
"graphics",
|
||||
"memory-management",
|
||||
"no-std",
|
||||
"game-development",
|
||||
]
|
||||
readme = "../README.md"
|
||||
keywords = ["gpu", "vulkan", "allocation", "no-std"]
|
||||
categories = ["graphics", "memory-management", "no-std", "game-development"]
|
||||
license = "MIT OR Apache-2.0"
|
||||
repository = "https://github.com/zakarumych/gpu-alloc"
|
||||
|
||||
[dependencies.bitflags]
|
||||
version = "2.0"
|
||||
version = "1.2"
|
||||
default-features = false
|
||||
|
||||
[dependencies.gpu-alloc-types]
|
||||
version = "=0.3.0"
|
||||
version = "0.2"
|
||||
|
||||
[dependencies.serde]
|
||||
version = "1.0"
|
||||
|
@ -54,8 +43,4 @@ default-features = false
|
|||
|
||||
[features]
|
||||
default = ["std"]
|
||||
serde = [
|
||||
"dep:serde",
|
||||
"bitflags/serde",
|
||||
]
|
||||
std = []
|
||||
|
|
|
@ -1,51 +0,0 @@
|
|||
# gpu-alloc
|
||||
|
||||
[![crates](https://img.shields.io/crates/v/gpu-alloc.svg?style=for-the-badge&label=gpu-alloc)](https://crates.io/crates/gpu-alloc)
|
||||
[![docs](https://img.shields.io/badge/docs.rs-gpu--alloc-66c2a5?style=for-the-badge&labelColor=555555&logoColor=white)](https://docs.rs/gpu-alloc)
|
||||
[![actions](https://img.shields.io/github/workflow/status/zakarumych/gpu-alloc/Rust/main?style=for-the-badge)](https://github.com/zakarumych/gpu-alloc/actions?query=workflow%3ARust)
|
||||
[![MIT/Apache](https://img.shields.io/badge/license-MIT%2FApache-blue.svg?style=for-the-badge)](COPYING)
|
||||
![loc](https://img.shields.io/tokei/lines/github/zakarumych/gpu-alloc?style=for-the-badge)
|
||||
|
||||
|
||||
Implementation agnostic memory allocator for Vulkan like APIs.
|
||||
|
||||
This crate is intended to be used as part of safe API implementations.\
|
||||
Use with caution. There are unsafe functions all over the place.
|
||||
|
||||
## Usage
|
||||
|
||||
Start with fetching `DeviceProperties` from `gpu-alloc-<backend>` crate for the backend of choice.\
|
||||
Then create `GpuAllocator` instance and use it for all device memory allocations.\
|
||||
`GpuAllocator` will take care for all necessary bookkeeping like memory object count limit,
|
||||
heap budget and memory mapping.
|
||||
|
||||
#### Backends implementations
|
||||
|
||||
Backend supporting crates should not depend on this crate.\
|
||||
Instead they should depend on `gpu-alloc-types` which is much more stable,
|
||||
allowing to upgrade `gpu-alloc` version without `gpu-alloc-<backend>` upgrade.
|
||||
|
||||
|
||||
Supported Rust Versions
|
||||
|
||||
The minimum supported version is 1.40.
|
||||
The current version is not guaranteed to build on Rust versions earlier than the minimum supported version.
|
||||
|
||||
`gpu-alloc-erupt` crate requires version 1.48 or higher due to dependency on `erupt` crate.
|
||||
|
||||
## License
|
||||
|
||||
Licensed under either of
|
||||
|
||||
* Apache License, Version 2.0, ([license/APACHE](license/APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
|
||||
* MIT license ([license/MIT](license/MIT) or http://opensource.org/licenses/MIT)
|
||||
|
||||
at your option.
|
||||
|
||||
## Contributions
|
||||
|
||||
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
|
||||
|
||||
## Donate
|
||||
|
||||
[![Become a patron](https://c5.patreon.com/external/logo/become_a_patron_button.png)](https://www.patreon.com/zakarum)
|
|
@ -202,11 +202,6 @@ where
|
|||
let heap = memory_type.heap;
|
||||
let heap = &mut self.memory_heaps[heap as usize];
|
||||
|
||||
if request.size > heap.size() {
|
||||
// Impossible to use memory type from this heap.
|
||||
continue;
|
||||
}
|
||||
|
||||
let atom_mask = if host_visible_non_coherent(memory_type.props) {
|
||||
self.non_coherent_atom_mask
|
||||
} else {
|
||||
|
@ -402,78 +397,6 @@ where
|
|||
Err(AllocationError::OutOfDeviceMemory)
|
||||
}
|
||||
|
||||
/// Creates a memory block from an existing memory allocation, transferring ownership to the allocator.
|
||||
///
|
||||
/// This function allows the [`GpuAllocator`] to manage memory allocated outside of the typical
|
||||
/// [`GpuAllocator::alloc`] family of functions.
|
||||
///
|
||||
/// # Usage
|
||||
///
|
||||
/// If you need to import external memory, such as a Win32 `HANDLE` or a Linux `dmabuf`, import the device
|
||||
/// memory using the graphics api and platform dependent functions. Once that is done, call this function
|
||||
/// to make the [`GpuAllocator`] take ownership of the imported memory.
|
||||
///
|
||||
/// When calling this function, you **must** ensure there are [enough remaining allocations](GpuAllocator::remaining_allocations).
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// - The `memory` must be allocated with the same device that was provided to create this [`GpuAllocator`]
|
||||
/// instance.
|
||||
/// - The `memory` must be valid.
|
||||
/// - The `props`, `offset` and `size` must match the properties, offset and size of the memory allocation.
|
||||
/// - The memory must have been allocated with the specified `memory_type`.
|
||||
/// - There must be enough remaining allocations.
|
||||
/// - The memory allocation must not come from an existing memory block created by this allocator.
|
||||
/// - The underlying memory object must be deallocated using the returned [`MemoryBlock`] with
|
||||
/// [`GpuAllocator::dealloc`].
|
||||
pub unsafe fn import_memory(
|
||||
&mut self,
|
||||
memory: M,
|
||||
memory_type: u32,
|
||||
props: MemoryPropertyFlags,
|
||||
offset: u64,
|
||||
size: u64,
|
||||
) -> MemoryBlock<M> {
|
||||
// Get the heap which the imported memory is from.
|
||||
let heap = self
|
||||
.memory_types
|
||||
.get(memory_type as usize)
|
||||
.expect("Invalid memory type specified when importing memory")
|
||||
.heap;
|
||||
let heap = &mut self.memory_heaps[heap as usize];
|
||||
|
||||
#[cfg(feature = "tracing")]
|
||||
tracing::debug!(
|
||||
"Importing memory object {:?} `{}@{:?}`",
|
||||
memory,
|
||||
size,
|
||||
memory_type
|
||||
);
|
||||
|
||||
assert_ne!(
|
||||
self.allocations_remains, 0,
|
||||
"Out of allocations when importing a memory block. Ensure you check GpuAllocator::remaining_allocations before import."
|
||||
);
|
||||
self.allocations_remains -= 1;
|
||||
|
||||
let atom_mask = if host_visible_non_coherent(props) {
|
||||
self.non_coherent_atom_mask
|
||||
} else {
|
||||
0
|
||||
};
|
||||
|
||||
heap.alloc(size);
|
||||
|
||||
MemoryBlock::new(
|
||||
memory_type,
|
||||
props,
|
||||
offset,
|
||||
size,
|
||||
atom_mask,
|
||||
MemoryBlockFlavor::Dedicated { memory },
|
||||
)
|
||||
}
|
||||
|
||||
/// Deallocates memory block previously allocated from this `GpuAllocator` instance.
|
||||
///
|
||||
/// # Safety
|
||||
|
@ -546,30 +469,6 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns the maximum allocation size supported.
|
||||
pub fn max_allocation_size(&self) -> u64 {
|
||||
self.max_memory_allocation_size
|
||||
}
|
||||
|
||||
/// Returns the number of remaining available allocations.
|
||||
///
|
||||
/// This may be useful if you need know if the allocator can allocate a number of allocations ahead of
|
||||
/// time. This function is also useful for ensuring you do not allocate too much memory outside allocator
|
||||
/// (such as external memory).
|
||||
pub fn remaining_allocations(&self) -> u32 {
|
||||
self.allocations_remains
|
||||
}
|
||||
|
||||
/// Sets the number of remaining available allocations.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// The caller is responsible for ensuring the number of remaining allocations does not exceed how many
|
||||
/// remaining allocations there actually are on the memory device.
|
||||
pub unsafe fn set_remaining_allocations(&mut self, remaining: u32) {
|
||||
self.allocations_remains = remaining;
|
||||
}
|
||||
|
||||
/// Deallocates leftover memory objects.
|
||||
/// Should be used before dropping.
|
||||
///
|
||||
|
|
|
@ -86,8 +86,8 @@ impl<M> MemoryBlock<M> {
|
|||
pub fn memory(&self) -> &M {
|
||||
match &self.flavor {
|
||||
MemoryBlockFlavor::Dedicated { memory } => memory,
|
||||
MemoryBlockFlavor::Buddy { memory, .. } => memory,
|
||||
MemoryBlockFlavor::FreeList { memory, .. } => memory,
|
||||
MemoryBlockFlavor::Buddy { memory, .. } => &**memory,
|
||||
MemoryBlockFlavor::FreeList { memory, .. } => &**memory,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -318,8 +318,6 @@ where
|
|||
.and_then(|size| size.checked_next_power_of_two())
|
||||
.ok_or(AllocationError::OutOfDeviceMemory)?;
|
||||
|
||||
let size = size.max(self.minimal_size);
|
||||
|
||||
let size_index = size.trailing_zeros() - self.minimal_size.trailing_zeros();
|
||||
let size_index =
|
||||
usize::try_from(size_index).map_err(|_| AllocationError::OutOfDeviceMemory)?;
|
||||
|
|
|
@ -7,7 +7,6 @@ bitflags::bitflags! {
|
|||
/// Memory usage type.
|
||||
/// Bits set define intended usage for requested memory.
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
|
||||
pub struct UsageFlags: u8 {
|
||||
/// Hints for allocator to find memory with faster device access.
|
||||
/// If no flags is specified than `FAST_DEVICE_ACCESS` is implied.
|
||||
|
@ -111,7 +110,7 @@ fn one_usage(usage: UsageFlags, memory_types: &[MemoryType]) -> MemoryForOneUsag
|
|||
}
|
||||
|
||||
types[..types_count as usize]
|
||||
.sort_unstable_by_key(|&index| reverse_priority(usage, memory_types[index as usize].props));
|
||||
.sort_unstable_by_key(|&index| priority(usage, memory_types[index as usize].props));
|
||||
|
||||
let mask = types[..types_count as usize]
|
||||
.iter()
|
||||
|
@ -138,9 +137,9 @@ fn compatible(usage: UsageFlags, flags: MemoryPropertyFlags) -> bool {
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns reversed priority of memory with specified flags for specified usage.
|
||||
/// Returns priority of memory with specified flags for specified usage.
|
||||
/// Lesser value returned = more prioritized.
|
||||
fn reverse_priority(usage: UsageFlags, flags: MemoryPropertyFlags) -> u32 {
|
||||
fn priority(usage: UsageFlags, flags: MemoryPropertyFlags) -> u32 {
|
||||
type Flags = MemoryPropertyFlags;
|
||||
|
||||
// Highly prefer device local memory when `FAST_DEVICE_ACCESS` usage is specified
|
||||
|
@ -154,23 +153,15 @@ fn reverse_priority(usage: UsageFlags, flags: MemoryPropertyFlags) -> u32 {
|
|||
.intersects(UsageFlags::HOST_ACCESS | UsageFlags::UPLOAD | UsageFlags::DOWNLOAD)
|
||||
);
|
||||
|
||||
// Prefer non-host-visible memory when host access is not required.
|
||||
let host_visible: bool = flags.contains(Flags::HOST_VISIBLE)
|
||||
^ usage.intersects(UsageFlags::HOST_ACCESS | UsageFlags::UPLOAD | UsageFlags::DOWNLOAD);
|
||||
|
||||
// Prefer cached memory for downloads.
|
||||
// Or non-cached if downloads are not expected.
|
||||
let host_cached: bool =
|
||||
flags.contains(Flags::HOST_CACHED) ^ usage.contains(UsageFlags::DOWNLOAD);
|
||||
let cached: bool = flags.contains(Flags::HOST_CACHED) ^ usage.contains(UsageFlags::DOWNLOAD);
|
||||
|
||||
// Prefer coherent for both uploads and downloads.
|
||||
// Prefer non-coherent if neither flags is set.
|
||||
let host_coherent: bool = flags.contains(Flags::HOST_COHERENT)
|
||||
let coherent: bool = flags.contains(Flags::HOST_COHERENT)
|
||||
^ (usage.intersects(UsageFlags::UPLOAD | UsageFlags::DOWNLOAD));
|
||||
|
||||
// Each boolean is false if flags are preferred.
|
||||
device_local as u32 * 8
|
||||
+ host_visible as u32 * 4
|
||||
+ host_cached as u32 * 2
|
||||
+ host_coherent as u32
|
||||
device_local as u32 * 4 + cached as u32 * 2 + coherent as u32
|
||||
}
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -10,9 +10,9 @@
|
|||
# See Cargo.toml.orig for the original contents.
|
||||
|
||||
[package]
|
||||
edition = "2021"
|
||||
edition = "2018"
|
||||
name = "metal"
|
||||
version = "0.25.0"
|
||||
version = "0.24.0"
|
||||
authors = ["GFX Developers"]
|
||||
exclude = [
|
||||
"guide/**/*",
|
||||
|
@ -45,9 +45,6 @@ name = "headless-render"
|
|||
[[example]]
|
||||
name = "library"
|
||||
|
||||
[[example]]
|
||||
name = "raytracing"
|
||||
|
||||
[[example]]
|
||||
name = "reflection"
|
||||
|
||||
|
@ -104,7 +101,7 @@ version = "0.2"
|
|||
optional = true
|
||||
|
||||
[dependencies.foreign-types]
|
||||
version = "0.5"
|
||||
version = "0.3.2"
|
||||
|
||||
[dependencies.log]
|
||||
version = "0.4"
|
||||
|
@ -113,29 +110,20 @@ version = "0.4"
|
|||
version = "0.2.4"
|
||||
features = ["objc_exception"]
|
||||
|
||||
[dependencies.paste]
|
||||
version = "1"
|
||||
|
||||
[dev-dependencies.cocoa]
|
||||
version = "0.24.0"
|
||||
|
||||
[dev-dependencies.cty]
|
||||
version = "0.2.1"
|
||||
|
||||
[dev-dependencies.glam]
|
||||
version = "0.22"
|
||||
|
||||
[dev-dependencies.png]
|
||||
version = "0.17"
|
||||
|
||||
[dev-dependencies.rand]
|
||||
version = "0.8"
|
||||
version = "0.16"
|
||||
|
||||
[dev-dependencies.sema]
|
||||
version = "0.1.4"
|
||||
|
||||
[dev-dependencies.winit]
|
||||
version = "0.27"
|
||||
version = "0.24"
|
||||
|
||||
[features]
|
||||
default = []
|
||||
|
|
|
@ -10,7 +10,3 @@ window:
|
|||
circle:
|
||||
xcrun -sdk macosx metal -c examples/circle/shaders.metal -o examples/circle/shaders.air
|
||||
xcrun -sdk macosx metallib examples/circle/shaders.air -o examples/circle/shaders.metallib
|
||||
|
||||
raytracing:
|
||||
xcrun -sdk macosx metal -c -g examples/raytracing/shaders.metal -o examples/raytracing/shaders.air
|
||||
xcrun -sdk macosx metallib examples/raytracing/shaders.air -o examples/raytracing/shaders.metallib
|
||||
|
|
|
@ -2,18 +2,7 @@
|
|||
[![Actions Status](https://github.com/gfx-rs/metal-rs/workflows/ci/badge.svg)](https://github.com/gfx-rs/metal-rs/actions)
|
||||
[![Crates.io](https://img.shields.io/crates/v/metal.svg?label=metal)](https://crates.io/crates/metal)
|
||||
|
||||
<p align="center">
|
||||
<img width="150" height="150" src="./assets/metal.svg">
|
||||
</p>
|
||||
|
||||
<p align="center">Unsafe Rust bindings for the Metal 3D Graphics API.</p>
|
||||
|
||||
## Documentation
|
||||
|
||||
Note that [docs.rs](docs.rs) will fail to build the (albeit limited) documentation for this crate!
|
||||
They build in a Linux container, but of course this will only compile on MacOS.
|
||||
|
||||
Please build the documentation yourself with `cargo docs`.
|
||||
Unsafe Rust bindings for the Metal 3D Graphics API.
|
||||
|
||||
## Examples
|
||||
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="720px" height="720px" viewBox="0 0 720 720" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<defs>
|
||||
<linearGradient x1="50%" y1="0%" x2="50%" y2="100%" id="limeGradient">
|
||||
<stop stop-color="#0EFFDD" offset="0%"></stop>
|
||||
<stop stop-color="#24FF74" offset="100%"></stop>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<g>
|
||||
<g>
|
||||
<path d="M576,720 L144,720 C64.5,720 0,655.5 0,576 L0,144 C0,64.5 64.5,0 144,0 L576,0 C655.5,0 720,64.5 720,144 L720,576 C720,655.5 655.5,720 576,720 Z" id="app-backplate" fill="url(#limeGradient)"></path>
|
||||
<polygon id="Path" fill="#000000" points="141 132 334 368 334 195 651 545 569 545 398 364 396 545 205 309 205 545 141 545"></polygon>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
До Ширина: | Высота: | Размер: 848 B |
|
@ -34,30 +34,19 @@ pub struct AAPLVertex {
|
|||
fn main() {
|
||||
// Create a window for viewing the content
|
||||
let event_loop = EventLoop::new();
|
||||
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".to_string())
|
||||
.build(&event_loop)
|
||||
.build(&events_loop)
|
||||
.unwrap();
|
||||
|
||||
// Set up the GPU device found in the system
|
||||
let device = Device::system_default().expect("no device found");
|
||||
println!("Your device is: {}", device.name(),);
|
||||
|
||||
// Scaffold required to sample the GPU and CPU timestamps
|
||||
let mut cpu_start = 0;
|
||||
let mut gpu_start = 0;
|
||||
device.sample_timestamps(&mut cpu_start, &mut gpu_start);
|
||||
let counter_sample_buffer = create_counter_sample_buffer(&device);
|
||||
let destination_buffer = device.new_buffer(
|
||||
(std::mem::size_of::<u64>() * 4 as usize) as u64,
|
||||
MTLResourceOptions::StorageModeShared,
|
||||
);
|
||||
let counter_sampling_point = MTLCounterSamplingPoint::AtStageBoundary;
|
||||
assert!(device.supports_counter_sampling(counter_sampling_point));
|
||||
|
||||
let binary_archive_path = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"))
|
||||
.join("examples/circle/binary_archive.metallib");
|
||||
|
||||
|
@ -152,14 +141,7 @@ fn main() {
|
|||
|
||||
// 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,
|
||||
);
|
||||
prepare_render_pass_descriptor(&render_pass_descriptor, drawable.texture());
|
||||
|
||||
// Create a render command encoder.
|
||||
let encoder =
|
||||
|
@ -171,23 +153,11 @@ fn main() {
|
|||
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);
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
|
@ -241,20 +211,7 @@ fn create_vertex_points_for_circle() -> Vec<AAPLVertex> {
|
|||
v
|
||||
}
|
||||
|
||||
fn handle_render_pass_sample_buffer_attachment(
|
||||
descriptor: &RenderPassDescriptorRef,
|
||||
counter_sample_buffer: &CounterSampleBufferRef,
|
||||
) {
|
||||
let sample_buffer_attachment_descriptor =
|
||||
descriptor.sample_buffer_attachments().object_at(0).unwrap();
|
||||
sample_buffer_attachment_descriptor.set_sample_buffer(&counter_sample_buffer);
|
||||
sample_buffer_attachment_descriptor.set_start_of_vertex_sample_index(0 as NSUInteger);
|
||||
sample_buffer_attachment_descriptor.set_end_of_vertex_sample_index(1 as NSUInteger);
|
||||
sample_buffer_attachment_descriptor.set_start_of_fragment_sample_index(2 as NSUInteger);
|
||||
sample_buffer_attachment_descriptor.set_end_of_fragment_sample_index(3 as NSUInteger);
|
||||
}
|
||||
|
||||
fn handle_render_pass_color_attachment(descriptor: &RenderPassDescriptorRef, texture: &TextureRef) {
|
||||
fn prepare_render_pass_descriptor(descriptor: &RenderPassDescriptorRef, texture: &TextureRef) {
|
||||
let color_attachment = descriptor.color_attachments().object_at(0).unwrap();
|
||||
|
||||
color_attachment.set_texture(Some(texture));
|
||||
|
@ -292,86 +249,3 @@ fn prepare_pipeline_state(
|
|||
.new_render_pipeline_state(&pipeline_state_descriptor)
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
fn resolve_samples_into_buffer(
|
||||
command_buffer: &CommandBufferRef,
|
||||
counter_sample_buffer: &CounterSampleBufferRef,
|
||||
destination_buffer: &BufferRef,
|
||||
) {
|
||||
let blit_encoder = command_buffer.new_blit_command_encoder();
|
||||
blit_encoder.resolve_counters(
|
||||
&counter_sample_buffer,
|
||||
crate::NSRange::new(0_u64, 4),
|
||||
&destination_buffer,
|
||||
0_u64,
|
||||
);
|
||||
blit_encoder.end_encoding();
|
||||
}
|
||||
|
||||
fn handle_timestamps(
|
||||
resolved_sample_buffer: &BufferRef,
|
||||
cpu_start: u64,
|
||||
cpu_end: u64,
|
||||
gpu_start: u64,
|
||||
gpu_end: u64,
|
||||
) {
|
||||
let samples = unsafe {
|
||||
std::slice::from_raw_parts(resolved_sample_buffer.contents() as *const u64, 4 as usize)
|
||||
};
|
||||
let vertex_pass_start = samples[0];
|
||||
let vertex_pass_end = samples[1];
|
||||
let fragment_pass_start = samples[2];
|
||||
let fragment_pass_end = samples[3];
|
||||
|
||||
let cpu_time_span = cpu_end - cpu_start;
|
||||
let gpu_time_span = gpu_end - gpu_start;
|
||||
|
||||
let vertex_micros = microseconds_between_begin(
|
||||
vertex_pass_start,
|
||||
vertex_pass_end,
|
||||
gpu_time_span,
|
||||
cpu_time_span,
|
||||
);
|
||||
let fragment_micros = microseconds_between_begin(
|
||||
fragment_pass_start,
|
||||
fragment_pass_end,
|
||||
gpu_time_span,
|
||||
cpu_time_span,
|
||||
);
|
||||
|
||||
println!("Vertex pass duration: {:.2} µs", vertex_micros);
|
||||
println!("Fragment pass duration: {:.2} µs\n", fragment_micros);
|
||||
}
|
||||
|
||||
fn create_counter_sample_buffer(device: &Device) -> CounterSampleBuffer {
|
||||
let counter_sample_buffer_desc = metal::CounterSampleBufferDescriptor::new();
|
||||
counter_sample_buffer_desc.set_storage_mode(metal::MTLStorageMode::Shared);
|
||||
counter_sample_buffer_desc.set_sample_count(4_u64);
|
||||
counter_sample_buffer_desc.set_counter_set(&fetch_timestamp_counter_set(device));
|
||||
|
||||
device
|
||||
.new_counter_sample_buffer_with_descriptor(&counter_sample_buffer_desc)
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
fn fetch_timestamp_counter_set(device: &Device) -> metal::CounterSet {
|
||||
let counter_sets = device.counter_sets();
|
||||
let mut timestamp_counter = None;
|
||||
for cs in counter_sets.iter() {
|
||||
if cs.name() == "timestamp" {
|
||||
timestamp_counter = Some(cs);
|
||||
break;
|
||||
}
|
||||
}
|
||||
timestamp_counter
|
||||
.expect("No timestamp counter found")
|
||||
.clone()
|
||||
}
|
||||
|
||||
/// <https://developer.apple.com/documentation/metal/gpu_counters_and_counter_sample_buffers/converting_gpu_timestamps_into_cpu_time>
|
||||
fn microseconds_between_begin(begin: u64, end: u64, gpu_time_span: u64, cpu_time_span: u64) -> f64 {
|
||||
let time_span = (end as f64) - (begin as f64);
|
||||
let nanoseconds = time_span / (gpu_time_span as f64) * (cpu_time_span as f64);
|
||||
let microseconds = nanoseconds / 1000.0;
|
||||
return microseconds;
|
||||
}
|
||||
|
|
|
@ -1,41 +1,66 @@
|
|||
// Copyright 2017 GFX developers
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
|
||||
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
|
||||
// http://opensource.org/licenses/MIT>, at your option. This file may not be
|
||||
// copied, modified, or distributed except according to those terms.
|
||||
|
||||
use metal::*;
|
||||
use objc::rc::autoreleasepool;
|
||||
use std::path::PathBuf;
|
||||
|
||||
const NUM_SAMPLES: u64 = 2;
|
||||
const NUM_ELEMENTS: u64 = 64 * 64;
|
||||
use std::mem;
|
||||
|
||||
fn main() {
|
||||
autoreleasepool(|| {
|
||||
let device = Device::system_default().expect("No device found");
|
||||
let mut cpu_start = 0;
|
||||
let mut gpu_start = 0;
|
||||
device.sample_timestamps(&mut cpu_start, &mut gpu_start);
|
||||
let device = Device::system_default().expect("no device found");
|
||||
let command_queue = device.new_command_queue();
|
||||
|
||||
let counter_sample_buffer = create_counter_sample_buffer(&device);
|
||||
let destination_buffer = device.new_buffer(
|
||||
(std::mem::size_of::<u64>() * NUM_SAMPLES as usize) as u64,
|
||||
MTLResourceOptions::StorageModeShared,
|
||||
let data = [
|
||||
1u32, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
|
||||
24, 25, 26, 27, 28, 29, 30,
|
||||
];
|
||||
|
||||
let buffer = device.new_buffer_with_data(
|
||||
unsafe { mem::transmute(data.as_ptr()) },
|
||||
(data.len() * mem::size_of::<u32>()) as u64,
|
||||
MTLResourceOptions::CPUCacheModeDefaultCache,
|
||||
);
|
||||
|
||||
let counter_sampling_point = MTLCounterSamplingPoint::AtStageBoundary;
|
||||
assert!(device.supports_counter_sampling(counter_sampling_point));
|
||||
let sum = {
|
||||
let data = [0u32];
|
||||
device.new_buffer_with_data(
|
||||
unsafe { mem::transmute(data.as_ptr()) },
|
||||
(data.len() * mem::size_of::<u32>()) as u64,
|
||||
MTLResourceOptions::CPUCacheModeDefaultCache,
|
||||
)
|
||||
};
|
||||
|
||||
let command_queue = device.new_command_queue();
|
||||
let command_buffer = command_queue.new_command_buffer();
|
||||
|
||||
let compute_pass_descriptor = ComputePassDescriptor::new();
|
||||
handle_compute_pass_sample_buffer_attachment(
|
||||
&compute_pass_descriptor,
|
||||
&counter_sample_buffer,
|
||||
);
|
||||
let encoder =
|
||||
command_buffer.compute_command_encoder_with_descriptor(&compute_pass_descriptor);
|
||||
command_buffer.set_label("label");
|
||||
let block = block::ConcreteBlock::new(move |buffer: &metal::CommandBufferRef| {
|
||||
println!("{}", buffer.label());
|
||||
})
|
||||
.copy();
|
||||
|
||||
command_buffer.add_completed_handler(&block);
|
||||
|
||||
let encoder = command_buffer.new_compute_command_encoder();
|
||||
let library_path = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"))
|
||||
.join("examples/compute/shaders.metallib");
|
||||
|
||||
let library = device.new_library_with_file(library_path).unwrap();
|
||||
let kernel = library.get_function("sum", None).unwrap();
|
||||
|
||||
let pipeline_state_descriptor = ComputePipelineDescriptor::new();
|
||||
pipeline_state_descriptor.set_compute_function(Some(&kernel));
|
||||
|
||||
let pipeline_state = device
|
||||
.new_compute_pipeline_state_with_function(
|
||||
pipeline_state_descriptor.compute_function().unwrap(),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let pipeline_state = create_pipeline_state(&device);
|
||||
encoder.set_compute_pipeline_state(&pipeline_state);
|
||||
|
||||
let (buffer, sum) = create_input_and_output_buffers(&device);
|
||||
encoder.set_buffer(0, Some(&buffer), 0);
|
||||
encoder.set_buffer(1, Some(&sum), 0);
|
||||
|
||||
|
@ -48,141 +73,19 @@ fn main() {
|
|||
};
|
||||
|
||||
let thread_group_size = MTLSize {
|
||||
width: (NUM_ELEMENTS + width) / width,
|
||||
width: (data.len() as u64 + width) / width,
|
||||
height: 1,
|
||||
depth: 1,
|
||||
};
|
||||
|
||||
encoder.dispatch_thread_groups(thread_group_count, thread_group_size);
|
||||
encoder.end_encoding();
|
||||
|
||||
resolve_samples_into_buffer(&command_buffer, &counter_sample_buffer, &destination_buffer);
|
||||
|
||||
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);
|
||||
|
||||
let ptr = sum.contents() as *mut u32;
|
||||
println!("Compute shader sum: {}", unsafe { *ptr });
|
||||
|
||||
unsafe {
|
||||
assert_eq!(NUM_ELEMENTS as u32, *ptr);
|
||||
assert_eq!(465, *ptr);
|
||||
}
|
||||
|
||||
handle_timestamps(&destination_buffer, cpu_start, cpu_end, gpu_start, gpu_end);
|
||||
});
|
||||
}
|
||||
|
||||
fn create_pipeline_state(device: &Device) -> ComputePipelineState {
|
||||
let library_path =
|
||||
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("examples/compute/shaders.metallib");
|
||||
let library = device.new_library_with_file(library_path).unwrap();
|
||||
let kernel = library.get_function("sum", None).unwrap();
|
||||
|
||||
let pipeline_state_descriptor = ComputePipelineDescriptor::new();
|
||||
pipeline_state_descriptor.set_compute_function(Some(&kernel));
|
||||
|
||||
device
|
||||
.new_compute_pipeline_state_with_function(
|
||||
pipeline_state_descriptor.compute_function().unwrap(),
|
||||
)
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
fn handle_compute_pass_sample_buffer_attachment(
|
||||
compute_pass_descriptor: &ComputePassDescriptorRef,
|
||||
counter_sample_buffer: &CounterSampleBufferRef,
|
||||
) {
|
||||
let sample_buffer_attachment_descriptor = compute_pass_descriptor
|
||||
.sample_buffer_attachments()
|
||||
.object_at(0)
|
||||
.unwrap();
|
||||
|
||||
sample_buffer_attachment_descriptor.set_sample_buffer(&counter_sample_buffer);
|
||||
sample_buffer_attachment_descriptor.set_start_of_encoder_sample_index(0);
|
||||
sample_buffer_attachment_descriptor.set_end_of_encoder_sample_index(1);
|
||||
}
|
||||
|
||||
fn resolve_samples_into_buffer(
|
||||
command_buffer: &CommandBufferRef,
|
||||
counter_sample_buffer: &CounterSampleBufferRef,
|
||||
destination_buffer: &BufferRef,
|
||||
) {
|
||||
let blit_encoder = command_buffer.new_blit_command_encoder();
|
||||
blit_encoder.resolve_counters(
|
||||
&counter_sample_buffer,
|
||||
crate::NSRange::new(0_u64, NUM_SAMPLES),
|
||||
&destination_buffer,
|
||||
0_u64,
|
||||
);
|
||||
blit_encoder.end_encoding();
|
||||
}
|
||||
|
||||
fn handle_timestamps(
|
||||
resolved_sample_buffer: &BufferRef,
|
||||
cpu_start: u64,
|
||||
cpu_end: u64,
|
||||
gpu_start: u64,
|
||||
gpu_end: u64,
|
||||
) {
|
||||
let samples = unsafe {
|
||||
std::slice::from_raw_parts(
|
||||
resolved_sample_buffer.contents() as *const u64,
|
||||
NUM_SAMPLES as usize,
|
||||
)
|
||||
};
|
||||
let pass_start = samples[0];
|
||||
let pass_end = samples[1];
|
||||
|
||||
let cpu_time_span = cpu_end - cpu_start;
|
||||
let gpu_time_span = gpu_end - gpu_start;
|
||||
|
||||
let micros = microseconds_between_begin(pass_start, pass_end, gpu_time_span, cpu_time_span);
|
||||
println!("Compute pass duration: {} µs", micros);
|
||||
}
|
||||
|
||||
fn create_counter_sample_buffer(device: &Device) -> CounterSampleBuffer {
|
||||
let counter_sample_buffer_desc = metal::CounterSampleBufferDescriptor::new();
|
||||
counter_sample_buffer_desc.set_storage_mode(metal::MTLStorageMode::Shared);
|
||||
counter_sample_buffer_desc.set_sample_count(NUM_SAMPLES);
|
||||
let counter_sets = device.counter_sets();
|
||||
|
||||
let timestamp_counter = counter_sets.iter().find(|cs| cs.name() == "timestamp");
|
||||
|
||||
counter_sample_buffer_desc
|
||||
.set_counter_set(×tamp_counter.expect("No timestamp counter found"));
|
||||
|
||||
device
|
||||
.new_counter_sample_buffer_with_descriptor(&counter_sample_buffer_desc)
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
fn create_input_and_output_buffers(device: &Device) -> (metal::Buffer, metal::Buffer) {
|
||||
let data = [1u32; 64 * 64];
|
||||
|
||||
let buffer = device.new_buffer_with_data(
|
||||
unsafe { std::mem::transmute(data.as_ptr()) },
|
||||
(data.len() * std::mem::size_of::<u32>()) as u64,
|
||||
MTLResourceOptions::CPUCacheModeDefaultCache,
|
||||
);
|
||||
|
||||
let sum = {
|
||||
let data = [0u32];
|
||||
device.new_buffer_with_data(
|
||||
unsafe { std::mem::transmute(data.as_ptr()) },
|
||||
(data.len() * std::mem::size_of::<u32>()) as u64,
|
||||
MTLResourceOptions::CPUCacheModeDefaultCache,
|
||||
)
|
||||
};
|
||||
(buffer, sum)
|
||||
}
|
||||
|
||||
/// <https://developer.apple.com/documentation/metal/gpu_counters_and_counter_sample_buffers/converting_gpu_timestamps_into_cpu_time>
|
||||
fn microseconds_between_begin(begin: u64, end: u64, gpu_time_span: u64, cpu_time_span: u64) -> f64 {
|
||||
let time_span = (end as f64) - (begin as f64);
|
||||
let nanoseconds = time_span / (gpu_time_span as f64) * (cpu_time_span as f64);
|
||||
let microseconds = nanoseconds / 1000.0;
|
||||
return microseconds;
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ fn save_image(texture: &TextureRef) {
|
|||
let ref mut w = BufWriter::new(file);
|
||||
|
||||
let mut encoder = png::Encoder::new(w, VIEW_WIDTH as u32, VIEW_HEIGHT as u32);
|
||||
encoder.set_color(ColorType::Rgba);
|
||||
encoder.set_color(ColorType::RGBA);
|
||||
encoder.set_depth(png::BitDepth::Eight);
|
||||
let mut writer = encoder.write_header().unwrap();
|
||||
|
||||
|
|
|
@ -1,118 +0,0 @@
|
|||
extern crate objc;
|
||||
|
||||
use cocoa::{appkit::NSView, base::id as cocoa_id};
|
||||
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,
|
||||
};
|
||||
|
||||
fn prepare_render_pass_descriptor(descriptor: &RenderPassDescriptorRef, texture: &TextureRef) {
|
||||
let color_attachment = descriptor.color_attachments().object_at(0).unwrap();
|
||||
|
||||
color_attachment.set_texture(Some(texture));
|
||||
color_attachment.set_load_action(MTLLoadAction::Clear);
|
||||
color_attachment.set_clear_color(MTLClearColor::new(0.2, 0.2, 0.25, 1.0));
|
||||
color_attachment.set_store_action(MTLStoreAction::Store);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
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(&events_loop)
|
||||
.unwrap();
|
||||
|
||||
let device = Device::system_default().expect("no device found");
|
||||
|
||||
let layer = MetalLayer::new();
|
||||
layer.set_device(&device);
|
||||
layer.set_pixel_format(MTLPixelFormat::BGRA8Unorm);
|
||||
layer.set_presents_with_transaction(false);
|
||||
|
||||
unsafe {
|
||||
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));
|
||||
|
||||
let library_path = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"))
|
||||
.join("examples/mesh-shader/shaders.metallib");
|
||||
let library = device.new_library_with_file(library_path).unwrap();
|
||||
|
||||
let mesh = library.get_function("mesh_function", None).unwrap();
|
||||
let frag = library.get_function("fragment_function", None).unwrap();
|
||||
|
||||
let pipeline_state_desc = MeshRenderPipelineDescriptor::new();
|
||||
pipeline_state_desc
|
||||
.color_attachments()
|
||||
.object_at(0)
|
||||
.unwrap()
|
||||
.set_pixel_format(MTLPixelFormat::BGRA8Unorm);
|
||||
pipeline_state_desc.set_mesh_function(Some(&mesh));
|
||||
pipeline_state_desc.set_fragment_function(Some(&frag));
|
||||
|
||||
let pipeline_state = device
|
||||
.new_mesh_render_pipeline_state(&pipeline_state_desc)
|
||||
.unwrap();
|
||||
|
||||
let command_queue = device.new_command_queue();
|
||||
|
||||
events_loop.run(move |event, _, control_flow| {
|
||||
autoreleasepool(|| {
|
||||
*control_flow = ControlFlow::Poll;
|
||||
|
||||
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();
|
||||
}
|
||||
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();
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче