Bug 1624174 - Update wgpu to get the coordinate spaces right r=jgilbert

The updated wgpu has the coordinate space fixes.
Depends on

  - https://phabricator.services.mozilla.com/D70421
  - https://phabricator.services.mozilla.com/D70432
  - https://phabricator.services.mozilla.com/D70646

Differential Revision: https://phabricator.services.mozilla.com/D70140

--HG--
rename : third_party/rust/rendy-descriptor/Cargo.toml => third_party/rust/gfx-descriptor/Cargo.toml
rename : third_party/rust/rendy-memory/Cargo.toml => third_party/rust/gfx-memory/Cargo.toml
rename : third_party/rust/rendy-memory/src/allocator/dynamic.rs => third_party/rust/gfx-memory/src/allocator/general.rs
rename : third_party/rust/rendy-memory/src/heaps/heap.rs => third_party/rust/gfx-memory/src/heaps/heap.rs
rename : third_party/rust/rendy-memory/src/utilization.rs => third_party/rust/gfx-memory/src/stats.rs
extra : moz-landing-system : lando
This commit is contained in:
Dzmitry Malyshau 2020-04-13 13:42:15 +00:00
Родитель 9f7b0a7d3f
Коммит e8a60d2eab
299 изменённых файлов: 61867 добавлений и 43810 удалений

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

@ -28,15 +28,10 @@ replace-with = "vendored-sources"
rev = "60952724c192a54f8d46c0f481f4bd8967c9bb6a"
[source."https://github.com/kvark/spirv_cross"]
branch = "wgpu"
branch = "wgpu2"
git = "https://github.com/kvark/spirv_cross"
replace-with = "vendored-sources"
[source."https://github.com/kvark/peek-poke"]
git = "https://github.com/kvark/peek-poke"
replace-with = "vendored-sources"
rev = "969bd7fe2be1a83f87916dc8b388c63cfd457075"
[source."https://github.com/jfkthame/mapped_hyph.git"]
git = "https://github.com/jfkthame/mapped_hyph.git"
replace-with = "vendored-sources"

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

@ -54,11 +54,11 @@ checksum = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8"
[[package]]
name = "ash"
version = "0.29.0"
version = "0.30.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "003d1fb2eb12eb06d4a03dbe02eea67a9fac910fa97932ab9e3a75b96a1ea5e5"
checksum = "69daec0742947f33a85931fa3cb0ce5f07929159dcbd1f0cbb5b2912e2978509"
dependencies = [
"shared_library",
"libloading",
]
[[package]]
@ -201,7 +201,7 @@ dependencies = [
"cranelift-wasm",
"env_logger",
"log",
"smallvec 1.2.0",
"smallvec",
]
[[package]]
@ -595,12 +595,6 @@ dependencies = [
"objc",
]
[[package]]
name = "colorful"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0bca1619ff57dd7a56b58a8e25ef4199f123e78e503fe1653410350a1b98ae65"
[[package]]
name = "comedy"
version = "0.1.0"
@ -728,7 +722,7 @@ dependencies = [
"cranelift-codegen-shared",
"cranelift-entity 0.62.0",
"log",
"smallvec 1.2.0",
"smallvec",
"target-lexicon 0.10.0",
"thiserror",
]
@ -764,7 +758,7 @@ source = "git+https://github.com/bytecodealliance/wasmtime?rev=6a68130d5b0296379
dependencies = [
"cranelift-codegen",
"log",
"smallvec 1.2.0",
"smallvec",
"target-lexicon 0.10.0",
]
@ -857,7 +851,7 @@ dependencies = [
"phf",
"proc-macro2",
"quote",
"smallvec 1.2.0",
"smallvec",
"syn",
]
@ -1232,7 +1226,7 @@ name = "fallible"
version = "0.0.1"
dependencies = [
"hashglobe",
"smallvec 1.2.0",
"smallvec",
]
[[package]]
@ -1310,7 +1304,7 @@ dependencies = [
"intl-memoizer",
"intl_pluralrules",
"rental",
"smallvec 1.2.0",
"smallvec",
"unic-langid",
]
@ -1496,7 +1490,7 @@ dependencies = [
"parking_lot",
"selectors",
"servo_arc",
"smallvec 1.2.0",
"smallvec",
"style",
"style_traits",
"to_shmem",
@ -1525,9 +1519,9 @@ dependencies = [
[[package]]
name = "gfx-auxil"
version = "0.1.0"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "572eee952a9a23c99cfe3e4fd95d277784058a89ac3c77ff6fa3d80a4e321919"
checksum = "3b46e6f0031330a0be08d17820f2dcaaa91cb36710a97a9500cb4f1c36e785c8"
dependencies = [
"fxhash",
"gfx-hal",
@ -1536,9 +1530,9 @@ dependencies = [
[[package]]
name = "gfx-backend-dx11"
version = "0.4.6"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7527cfcd7d1eec6b99f81891293bdd2a41d044ace009717264e5f3b10ce5b86"
checksum = "b148219292624126f78245e50a9720d95ea149a415ce8ce73ab7014205301b88"
dependencies = [
"bitflags",
"gfx-auxil",
@ -1548,7 +1542,7 @@ dependencies = [
"parking_lot",
"range-alloc",
"raw-window-handle",
"smallvec 0.6.10",
"smallvec",
"spirv_cross",
"winapi 0.3.7",
"wio",
@ -1556,9 +1550,9 @@ dependencies = [
[[package]]
name = "gfx-backend-dx12"
version = "0.4.1"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6e913cc800fb12eaba2c420091a02aca9aafbefd672600dfc5b52654343d341"
checksum = "a0e526746379e974501551b08958947e67a81b5ea8cdc717a000cdd72577da05"
dependencies = [
"bitflags",
"d3d12",
@ -1567,16 +1561,16 @@ dependencies = [
"log",
"range-alloc",
"raw-window-handle",
"smallvec 0.6.10",
"smallvec",
"spirv_cross",
"winapi 0.3.7",
]
[[package]]
name = "gfx-backend-empty"
version = "0.4.0"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d383e6bc48867cb37d298a20139fd1eec298f8f6d594690cd1c50ef25470cc7"
checksum = "b67bd2d7bc022b257ddbdabc5fa3b10c29c292372c3409f2b6a6e3f4e11cdb85"
dependencies = [
"gfx-hal",
"raw-window-handle",
@ -1584,9 +1578,9 @@ dependencies = [
[[package]]
name = "gfx-backend-metal"
version = "0.4.5"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05b6130b9a72129ebb5c91d3d75a142a7fa54dcc112603231582e3fdc0b84247"
checksum = "cfe128c29675b5afc8acdda1dfe096d6abd5e3528059ab0b98bda8215d8beed9"
dependencies = [
"arrayvec",
"bitflags",
@ -1604,16 +1598,16 @@ dependencies = [
"parking_lot",
"range-alloc",
"raw-window-handle",
"smallvec 0.6.10",
"smallvec",
"spirv_cross",
"storage-map",
]
[[package]]
name = "gfx-backend-vulkan"
version = "0.4.3"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1b8d901941d1734d307dacd8e5f00c89ee8fb8e78b4dab3edd91248150b26b4"
checksum = "ebd1dee09bd8d8f1ba52c5ba22d1f70c7ffa990c5eb245eb3ef2d0206f631673"
dependencies = [
"arrayvec",
"ash",
@ -1624,20 +1618,43 @@ dependencies = [
"log",
"objc",
"raw-window-handle",
"smallvec 0.6.10",
"smallvec",
"winapi 0.3.7",
"x11",
]
[[package]]
name = "gfx-hal"
version = "0.4.1"
name = "gfx-descriptor"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7c88981665c780447bb08eb099e1ded330754a7246719bab927ee4a949c0ba7f"
checksum = "1bf35f5d66d1bc56e63e68d7528441453f25992bd954b84309d23c659df2c5da"
dependencies = [
"fxhash",
"gfx-hal",
"log",
]
[[package]]
name = "gfx-hal"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc96180204064c9493e0fe4a9efeb721e0ac59fe8e1906d0c659142a93114fb1"
dependencies = [
"bitflags",
"raw-window-handle",
"smallvec 0.6.10",
]
[[package]]
name = "gfx-memory"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2eed6cda674d9cd4d92229102dbd544292124533d236904f987e9afab456137"
dependencies = [
"fxhash",
"gfx-hal",
"hibitset",
"log",
"slab",
]
[[package]]
@ -2236,9 +2253,9 @@ dependencies = [
[[package]]
name = "libloading"
version = "0.5.0"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c3ad660d7cb8c5822cd83d10897b0f1f1526792737a179e73896152f85b88c2"
checksum = "f2b111a074963af1d37a139918ac6d49ad1d0d5e47f72fd55388619691a7d753"
dependencies = [
"cc",
"winapi 0.3.7",
@ -2446,7 +2463,7 @@ dependencies = [
"selectors",
"servo_arc",
"smallbitvec",
"smallvec 1.2.0",
"smallvec",
"thin-slice",
"void",
]
@ -2826,7 +2843,7 @@ dependencies = [
"neqo-qpack",
"neqo-transport",
"num-traits",
"smallvec 1.2.0",
"smallvec",
]
[[package]]
@ -2851,7 +2868,7 @@ dependencies = [
"log",
"neqo-common",
"neqo-crypto",
"smallvec 1.2.0",
"smallvec",
]
[[package]]
@ -3129,18 +3146,10 @@ dependencies = [
"cloudabi",
"libc",
"redox_syscall",
"smallvec 1.2.0",
"smallvec",
"winapi 0.3.7",
]
[[package]]
name = "peek-poke"
version = "0.2.0"
source = "git+https://github.com/kvark/peek-poke?rev=969bd7fe2be1a83f87916dc8b388c63cfd457075#969bd7fe2be1a83f87916dc8b388c63cfd457075"
dependencies = [
"peek-poke-derive 0.2.0",
]
[[package]]
name = "peek-poke"
version = "0.2.0"
@ -3150,13 +3159,12 @@ dependencies = [
]
[[package]]
name = "peek-poke-derive"
name = "peek-poke"
version = "0.2.0"
source = "git+https://github.com/kvark/peek-poke?rev=969bd7fe2be1a83f87916dc8b388c63cfd457075#969bd7fe2be1a83f87916dc8b388c63cfd457075"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d93fd6a575ebf1ac2668d08443c97a22872cfb463fd8b7ddd141e9f6be59af2f"
dependencies = [
"proc-macro2",
"quote",
"syn",
"peek-poke-derive 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -3170,6 +3178,19 @@ dependencies = [
"unicode-xid",
]
[[package]]
name = "peek-poke-derive"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6fb44a25c5bba983be0fc8592dfaf3e6d0935ce8be0c6b15b2a39507af34a926"
dependencies = [
"proc-macro2",
"quote",
"syn",
"synstructure",
"unicode-xid",
]
[[package]]
name = "peeking_take_while"
version = "0.1.2"
@ -3533,16 +3554,6 @@ version = "0.6.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "11a7e20d1cce64ef2fed88b66d347f88bd9babb82845b2b858f3edbf59a4f716"
[[package]]
name = "relevant"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbc232e13d37f4547f5b9b42a5efc380cabe5dbc1807f8b893580640b2ab0308"
dependencies = [
"cfg-if",
"log",
]
[[package]]
name = "remote"
version = "0.1.0"
@ -3565,33 +3576,6 @@ dependencies = [
"winapi 0.3.7",
]
[[package]]
name = "rendy-descriptor"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f475bcc0505946e998590f1f0545c52ef4b559174a1b353a7ce6638def8b621e"
dependencies = [
"gfx-hal",
"log",
"relevant",
"smallvec 0.6.10",
]
[[package]]
name = "rendy-memory"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08f99de535d9e48d9cfab780b521702cc0d7183d354872d223967b75abae1199"
dependencies = [
"colorful",
"gfx-hal",
"hibitset",
"log",
"relevant",
"slab",
"smallvec 0.6.10",
]
[[package]]
name = "rental"
version = "0.5.5"
@ -3833,7 +3817,7 @@ dependencies = [
"phf_codegen",
"precomputed-hash",
"servo_arc",
"smallvec 1.2.0",
"smallvec",
"thin-slice",
"to_shmem",
"to_shmem_derive",
@ -3961,16 +3945,6 @@ dependencies = [
"opaque-debug",
]
[[package]]
name = "shared_library"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a9e7e0f2bfae24d8a5b5a66c5b257a83c7412304311512a0c054cd5e619da11"
dependencies = [
"lazy_static",
"libc",
]
[[package]]
name = "shift_or_euc"
version = "0.1.0"
@ -4021,15 +3995,9 @@ checksum = "1764fe2b30ee783bfe3b9b37b2649d8d590b3148bb12e0079715d4d5c673562e"
[[package]]
name = "smallvec"
version = "0.6.10"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab606a9c5e214920bb66c458cd7be8ef094f813f20fe77a54cc7dbfff220d4b7"
[[package]]
name = "smallvec"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c2fb2ec9bcd216a5b0d0ccf31ab17b5ed1d627960edff65bbe95d3ce221cefc"
checksum = "05720e22615919e4734f6a99ceae50d00226c3c5aca406e102ebc33298214e0a"
dependencies = [
"serde",
]
@ -4059,15 +4027,15 @@ dependencies = [
[[package]]
name = "spirv-cross-internal"
version = "0.1.0"
source = "git+https://github.com/kvark/spirv_cross?branch=wgpu#9cb4de489bf80b2b23efffe5a79afb7db6247ba4"
source = "git+https://github.com/kvark/spirv_cross?branch=wgpu2#f0c322e8a17d4957fbb5b7cd3b56d520ad72fbf2"
dependencies = [
"cc",
]
[[package]]
name = "spirv_cross"
version = "0.16.0"
source = "git+https://github.com/kvark/spirv_cross?branch=wgpu#9cb4de489bf80b2b23efffe5a79afb7db6247ba4"
version = "0.18.0"
source = "git+https://github.com/kvark/spirv_cross?branch=wgpu2#f0c322e8a17d4957fbb5b7cd3b56d520ad72fbf2"
dependencies = [
"spirv-cross-internal",
]
@ -4169,7 +4137,7 @@ dependencies = [
"serde",
"servo_arc",
"smallbitvec",
"smallvec 1.2.0",
"smallvec",
"static_prefs",
"style_derive",
"style_traits",
@ -4230,7 +4198,7 @@ dependencies = [
"num-traits",
"selectors",
"size_of_test",
"smallvec 1.2.0",
"smallvec",
"style",
"style_traits",
"to_shmem",
@ -4438,7 +4406,7 @@ dependencies = [
"cssparser",
"servo_arc",
"smallbitvec",
"smallvec 1.2.0",
"smallvec",
"thin-slice",
]
@ -4968,7 +4936,7 @@ dependencies = [
"ron",
"serde",
"serde_json",
"smallvec 1.2.0",
"smallvec",
"svg_fmt",
"time",
"tracy-rs",
@ -5064,14 +5032,14 @@ dependencies = [
"gfx-backend-empty",
"gfx-backend-metal",
"gfx-backend-vulkan",
"gfx-descriptor",
"gfx-hal",
"gfx-memory",
"log",
"parking_lot",
"peek-poke 0.2.0 (git+https://github.com/kvark/peek-poke?rev=969bd7fe2be1a83f87916dc8b388c63cfd457075)",
"rendy-descriptor",
"rendy-memory",
"peek-poke 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde",
"smallvec 1.2.0",
"smallvec",
"vec_map",
"wgpu-types",
]
@ -5091,7 +5059,7 @@ name = "wgpu-types"
version = "0.1.0"
dependencies = [
"bitflags",
"peek-poke 0.2.0 (git+https://github.com/kvark/peek-poke?rev=969bd7fe2be1a83f87916dc8b388c63cfd457075)",
"peek-poke 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde",
]

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

@ -69,7 +69,7 @@ libudev-sys = { path = "dom/webauthn/libudev-sys" }
packed_simd = { git = "https://github.com/hsivonen/packed_simd", rev="3541e3818fdc7c2a24f87e3459151a4ce955a67a" }
rlbox_lucet_sandbox = { git = "https://github.com/PLSysSec/rlbox_lucet_sandbox/", rev="d510da5999a744c563b0acd18056069d1698273f" }
nix = { git = "https://github.com/shravanrn/nix/", branch = "r0.13.1", rev="4af6c367603869a30fddb5ffb0aba2b9477ba92e" }
spirv_cross = { git = "https://github.com/kvark/spirv_cross", branch = "wgpu", rev = "9cb4de489bf80b2b23efffe5a79afb7db6247ba4" }
spirv_cross = { git = "https://github.com/kvark/spirv_cross", branch = "wgpu2", rev = "9cb4de489bf80b2b23efffe5a79afb7db6247ba4" }
# failure's backtrace feature might break our builds, see bug 1608157.
failure = { git = "https://github.com/badboy/failure", rev = "64af847bc5fdcb6d2438bec8a6030812a80519a5" }
failure_derive = { git = "https://github.com/badboy/failure", rev = "64af847bc5fdcb6d2438bec8a6030812a80519a5" }

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

@ -86,7 +86,7 @@ ffi::WGPURawPass BeginRenderPass(RawId aEncoderId,
cd.store_op = ConvertStoreOp(ca.mStoreOp);
if (ca.mResolveTarget.WasPassed()) {
cd.resolve_target = &ca.mResolveTarget.Value().mId;
cd.resolve_target = ca.mResolveTarget.Value().mId;
}
if (ca.mLoadValue.IsGPULoadOp()) {
cd.load_op = ConvertLoadOp(ca.mLoadValue.GetAsGPULoadOp());

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

@ -14,6 +14,7 @@ using SerialPipelineLayoutDescriptor from "mozilla/webgpu/WebGPUTypes.h";
using SerialBindGroupDescriptor from "mozilla/webgpu/WebGPUTypes.h";
using SerialComputePipelineDescriptor from "mozilla/webgpu/WebGPUTypes.h";
using SerialRenderPipelineDescriptor from "mozilla/webgpu/WebGPUTypes.h";
using SerialTextureDescriptor from "mozilla/webgpu/WebGPUTypes.h";
using dom::GPURequestAdapterOptions from "mozilla/dom/WebGPUBinding.h";
using dom::GPUDeviceDescriptor from "mozilla/dom/WebGPUBinding.h";
using dom::GPUBufferDescriptor from "mozilla/dom/WebGPUBinding.h";
@ -21,7 +22,6 @@ using dom::GPUSamplerDescriptor from "mozilla/dom/WebGPUBinding.h";
using dom::GPUCommandEncoderDescriptor from "mozilla/dom/WebGPUBinding.h";
using dom::GPUCommandBufferDescriptor from "mozilla/dom/WebGPUBinding.h";
using dom::GPUPipelineLayoutDescriptor from "mozilla/dom/WebGPUBinding.h";
using webgpu::ffi::WGPUTextureDescriptor from "mozilla/webgpu/ffi/wgpu.h";
using webgpu::ffi::WGPUTextureViewDescriptor from "mozilla/webgpu/ffi/wgpu.h";
include "mozilla/webgpu/WebGPUSerialize.h";
@ -48,7 +48,7 @@ parent:
async DeviceUnmapBuffer(RawId selfId, RawId bufferId, Shmem shmem);
async BufferMapRead(RawId selfId, Shmem shmem) returns (Shmem sm);
async BufferDestroy(RawId selfId);
async DeviceCreateTexture(RawId selfId, WGPUTextureDescriptor desc, RawId newId);
async DeviceCreateTexture(RawId selfId, SerialTextureDescriptor desc, RawId newId);
async TextureCreateView(RawId selfId, WGPUTextureViewDescriptor desc, RawId newId);
async TextureDestroy(RawId selfId);
async TextureViewDestroy(RawId selfId);

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

@ -99,26 +99,26 @@ UniquePtr<ffi::WGPUTextureViewDescriptor> WebGPUChild::GetDefaultViewDescriptor(
RawId WebGPUChild::DeviceCreateTexture(RawId aSelfId,
const dom::GPUTextureDescriptor& aDesc) {
ffi::WGPUTextureDescriptor desc = {};
SerialTextureDescriptor desc = {};
if (aDesc.mSize.IsUnsignedLongSequence()) {
const auto& seq = aDesc.mSize.GetAsUnsignedLongSequence();
desc.size.width = seq.Length() > 0 ? seq[0] : 1;
desc.size.height = seq.Length() > 1 ? seq[1] : 1;
desc.size.depth = seq.Length() > 2 ? seq[2] : 1;
desc.mSize.width = seq.Length() > 0 ? seq[0] : 1;
desc.mSize.height = seq.Length() > 1 ? seq[1] : 1;
desc.mSize.depth = seq.Length() > 2 ? seq[2] : 1;
} else if (aDesc.mSize.IsGPUExtent3DDict()) {
const auto& dict = aDesc.mSize.GetAsGPUExtent3DDict();
desc.size.width = dict.mWidth;
desc.size.height = dict.mHeight;
desc.size.depth = dict.mDepth;
desc.mSize.width = dict.mWidth;
desc.mSize.height = dict.mHeight;
desc.mSize.depth = dict.mDepth;
} else {
MOZ_CRASH("Unexpected union");
}
desc.array_layer_count = aDesc.mArrayLayerCount;
desc.mip_level_count = aDesc.mMipLevelCount;
desc.sample_count = aDesc.mSampleCount;
desc.dimension = ffi::WGPUTextureDimension(aDesc.mDimension);
desc.format = ffi::WGPUTextureFormat(aDesc.mFormat);
desc.usage = aDesc.mUsage;
desc.mArrayLayerCount = aDesc.mArrayLayerCount;
desc.mMipLevelCount = aDesc.mMipLevelCount;
desc.mSampleCount = aDesc.mSampleCount;
desc.mDimension = ffi::WGPUTextureDimension(aDesc.mDimension);
desc.mFormat = ffi::WGPUTextureFormat(aDesc.mFormat);
desc.mUsage = aDesc.mUsage;
RawId id = ffi::wgpu_client_make_texture_id(mClient, aSelfId);
if (!SendDeviceCreateTexture(aSelfId, desc, id)) {

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

@ -251,8 +251,16 @@ ipc::IPCResult WebGPUParent::RecvBufferDestroy(RawId aSelfId) {
}
ipc::IPCResult WebGPUParent::RecvDeviceCreateTexture(
RawId aSelfId, const ffi::WGPUTextureDescriptor& aDesc, RawId aNewId) {
ffi::wgpu_server_device_create_texture(mContext, aSelfId, &aDesc, aNewId);
RawId aSelfId, const SerialTextureDescriptor& aDesc, RawId aNewId) {
ffi::WGPUTextureDescriptor desc = {};
desc.size = aDesc.mSize;
desc.array_layer_count = aDesc.mArrayLayerCount;
desc.mip_level_count = aDesc.mMipLevelCount;
desc.sample_count = aDesc.mSampleCount;
desc.dimension = aDesc.mDimension;
desc.format = aDesc.mFormat;
desc.usage = aDesc.mUsage;
ffi::wgpu_server_device_create_texture(mContext, aSelfId, &desc, aNewId);
return IPC_OK();
}
@ -286,7 +294,7 @@ ipc::IPCResult WebGPUParent::RecvDeviceCreateSampler(
ffi::WGPUCompareFunction compare;
if (aDesc.mCompare.WasPassed()) {
compare = ffi::WGPUCompareFunction(aDesc.mCompare.Value());
desc.compare = &compare;
desc.compare = compare;
}
ffi::wgpu_server_device_create_sampler(mContext, aSelfId, &desc, aNewId);
@ -605,6 +613,7 @@ ipc::IPCResult WebGPUParent::RecvSwapChainPresent(
data->mBuffersLock.Lock();
if (!data->mAvailableBufferIds.empty()) {
bufferId = data->mAvailableBufferIds.back();
wgpu_server_buffer_unmap(mContext, bufferId);
data->mAvailableBufferIds.pop_back();
} else if (!data->mUnassignedBufferIds.empty()) {
bufferId = data->mUnassignedBufferIds.back();
@ -612,10 +621,9 @@ ipc::IPCResult WebGPUParent::RecvSwapChainPresent(
ffi::WGPUBufferUsage usage =
WGPUBufferUsage_COPY_DST | WGPUBufferUsage_MAP_READ;
const ffi::WGPUBufferDescriptor desc = {
bufferSize,
usage,
};
ffi::WGPUBufferDescriptor desc = {};
desc.size = bufferSize;
desc.usage = usage;
ffi::wgpu_server_device_create_buffer(mContext, data->mDeviceId, &desc,
bufferId);
} else {

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

@ -38,8 +38,9 @@ class WebGPUParent final : public PWebGPUParent {
ipc::IPCResult RecvBufferMapRead(RawId aSelfId, Shmem&& shmem,
BufferMapReadResolver&& resolver);
ipc::IPCResult RecvBufferDestroy(RawId aSelfId);
ipc::IPCResult RecvDeviceCreateTexture(
RawId aSelfId, const ffi::WGPUTextureDescriptor& aDesc, RawId aNewId);
ipc::IPCResult RecvDeviceCreateTexture(RawId aSelfId,
const SerialTextureDescriptor& aDesc,
RawId aNewId);
ipc::IPCResult RecvTextureCreateView(
RawId aSelfId, const ffi::WGPUTextureViewDescriptor& aDesc, RawId aNewId);
ipc::IPCResult RecvTextureDestroy(RawId aSelfId);

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

@ -64,9 +64,6 @@ DEFINE_IPC_SERIALIZER_WITH_FIELDS(mozilla::dom::GPUSamplerDescriptor,
mLodMinClamp, mLodMaxClamp, mCompare);
DEFINE_IPC_SERIALIZER_WITH_FIELDS(mozilla::webgpu::ffi::WGPUExtent3d, width,
height, depth);
DEFINE_IPC_SERIALIZER_WITH_FIELDS(mozilla::webgpu::ffi::WGPUTextureDescriptor,
size, array_layer_count, mip_level_count,
sample_count, dimension, format, usage);
DEFINE_IPC_SERIALIZER_WITH_FIELDS(
mozilla::webgpu::ffi::WGPUTextureViewDescriptor, format, dimension, aspect,
base_mip_level, level_count, base_array_layer, array_layer_count);
@ -117,6 +114,10 @@ DEFINE_IPC_SERIALIZER_WITH_FIELDS(
mFragmentStage, mPrimitiveTopology, mRasterizationState, mColorStates,
mDepthStencilState, mVertexState, mSampleCount, mSampleMask,
mAlphaToCoverageEnabled);
DEFINE_IPC_SERIALIZER_WITH_FIELDS(mozilla::webgpu::SerialTextureDescriptor,
mLabel, mSize, mArrayLayerCount,
mMipLevelCount, mSampleCount, mDimension,
mFormat, mUsage);
#undef DEFINE_IPC_SERIALIZER_FFI_ENUM
#undef DEFINE_IPC_SERIALIZER_DOM_ENUM

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

@ -80,6 +80,17 @@ struct SerialRenderPipelineDescriptor {
bool mAlphaToCoverageEnabled;
};
struct SerialTextureDescriptor {
nsString mLabel;
struct ffi::WGPUExtent3d mSize;
uint32_t mArrayLayerCount;
uint32_t mMipLevelCount;
uint32_t mSampleCount;
enum ffi::WGPUTextureDimension mDimension;
enum ffi::WGPUTextureFormat mFormat;
ffi::WGPUTextureUsage mUsage;
};
} // namespace webgpu
} // namespace mozilla

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

@ -7,10 +7,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "ash"
version = "0.29.0"
version = "0.30.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"shared_library 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -91,11 +91,6 @@ dependencies = [
"objc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "colorful"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "copyless"
version = "0.1.4"
@ -129,17 +124,6 @@ name = "core-foundation-sys"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "core-graphics"
version = "0.17.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"core-foundation 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
"foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "core-graphics"
version = "0.19.0"
@ -184,62 +168,62 @@ dependencies = [
[[package]]
name = "gfx-auxil"
version = "0.1.0"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx-hal 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"spirv_cross 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx-hal 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"spirv_cross 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "gfx-backend-dx11"
version = "0.4.6"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx-auxil 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx-hal 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx-auxil 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx-hal 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)",
"range-alloc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"raw-window-handle 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)",
"spirv_cross 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"spirv_cross 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"wio 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "gfx-backend-dx12"
version = "0.4.1"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"d3d12 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx-auxil 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx-hal 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx-auxil 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx-hal 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"range-alloc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"raw-window-handle 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)",
"spirv_cross 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"spirv_cross 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "gfx-backend-empty"
version = "0.4.0"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"gfx-hal 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx-hal 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"raw-window-handle 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "gfx-backend-metal"
version = "0.4.5"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"arrayvec 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
@ -249,8 +233,8 @@ dependencies = [
"copyless 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
"core-graphics 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)",
"foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx-auxil 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx-hal 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx-auxil 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx-hal 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"metal 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -258,38 +242,59 @@ dependencies = [
"parking_lot 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)",
"range-alloc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"raw-window-handle 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)",
"spirv_cross 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"spirv_cross 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)",
"storage-map 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "gfx-backend-vulkan"
version = "0.4.0"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"arrayvec 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"ash 0.29.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ash 0.30.0 (registry+https://github.com/rust-lang/crates.io-index)",
"byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"core-graphics 0.17.3 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx-hal 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"core-graphics 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx-hal 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"objc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
"raw-window-handle 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"x11 2.18.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "gfx-descriptor"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx-hal 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "gfx-hal"
version = "0.4.1"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"raw-window-handle 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "gfx-memory"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx-hal 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"hibitset 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -364,11 +369,6 @@ dependencies = [
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "maybe-uninit"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "metal"
version = "0.18.0"
@ -445,19 +445,21 @@ dependencies = [
[[package]]
name = "peek-poke"
version = "0.2.0"
source = "git+https://github.com/kvark/peek-poke?rev=969bd7fe2be1a83f87916dc8b388c63cfd457075#969bd7fe2be1a83f87916dc8b388c63cfd457075"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"peek-poke-derive 0.2.0 (git+https://github.com/kvark/peek-poke?rev=969bd7fe2be1a83f87916dc8b388c63cfd457075)",
"peek-poke-derive 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "peek-poke-derive"
version = "0.2.0"
source = "git+https://github.com/kvark/peek-poke?rev=969bd7fe2be1a83f87916dc8b388c63cfd457075#969bd7fe2be1a83f87916dc8b388c63cfd457075"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)",
"synstructure 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -499,40 +501,6 @@ name = "redox_syscall"
version = "0.1.56"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "relevant"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rendy-descriptor"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"gfx-hal 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"relevant 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rendy-memory"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"colorful 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx-hal 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"hibitset 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"relevant 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "scopeguard"
version = "1.0.0"
@ -556,28 +524,11 @@ dependencies = [
"syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "shared_library"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "slab"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "smallvec"
version = "0.6.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "smallvec"
version = "1.0.0"
@ -585,7 +536,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "spirv_cross"
version = "0.16.0"
version = "0.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cc 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)",
@ -611,6 +562,17 @@ dependencies = [
"unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "synstructure"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "typenum"
version = "1.11.2"
@ -698,17 +660,17 @@ dependencies = [
"bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"copyless 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
"fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx-backend-dx11 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx-backend-dx12 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx-backend-empty 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx-backend-metal 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx-backend-vulkan 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx-hal 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx-backend-dx11 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx-backend-dx12 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx-backend-empty 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx-backend-metal 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx-backend-vulkan 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx-descriptor 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx-hal 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx-memory 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)",
"peek-poke 0.2.0 (git+https://github.com/kvark/peek-poke?rev=969bd7fe2be1a83f87916dc8b388c63cfd457075)",
"rendy-descriptor 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rendy-memory 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
"peek-poke 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
@ -744,7 +706,7 @@ name = "wgpu-types"
version = "0.1.0"
dependencies = [
"bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"peek-poke 0.2.0 (git+https://github.com/kvark/peek-poke?rev=969bd7fe2be1a83f87916dc8b388c63cfd457075)",
"peek-poke 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -786,7 +748,7 @@ dependencies = [
[metadata]
"checksum arrayvec 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8"
"checksum ash 0.29.0 (registry+https://github.com/rust-lang/crates.io-index)" = "003d1fb2eb12eb06d4a03dbe02eea67a9fac910fa97932ab9e3a75b96a1ea5e5"
"checksum ash 0.30.0 (registry+https://github.com/rust-lang/crates.io-index)" = "69daec0742947f33a85931fa3cb0ce5f07929159dcbd1f0cbb5b2912e2978509"
"checksum atom 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3c86699c3f02778ec07158376991c8f783dd1f2f95c579ffaf0738dc984b2fe2"
"checksum autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d"
"checksum battery 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)" = "36a698e449024a5d18994a815998bf5e2e4bc1883e35a7d7ba95b6b69ee45907"
@ -798,25 +760,25 @@ dependencies = [
"checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
"checksum cocoa 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0a4736c86d51bd878b474400d9ec888156f4037015f5d09794fab9f26eab1ad4"
"checksum colorful 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0bca1619ff57dd7a56b58a8e25ef4199f123e78e503fe1653410350a1b98ae65"
"checksum copyless 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6ff9c56c9fb2a49c05ef0e431485a22400af20d33226dc0764d891d09e724127"
"checksum core-foundation 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "25b9e03f145fd4f2bf705e07b900cd41fc636598fe5dc452fd0db1441c3f496d"
"checksum core-foundation 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "57d24c7a13c43e870e37c1556b74555437870a04514f7685f5b354e090567171"
"checksum core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e7ca8a5221364ef15ce201e8ed2f609fc312682a8f4e0e3d4aa5879764e0fa3b"
"checksum core-foundation-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b3a71ab494c0b5b860bdc8407ae08978052417070c2ced38573a9157ad75b8ac"
"checksum core-graphics 0.17.3 (registry+https://github.com/rust-lang/crates.io-index)" = "56790968ab1c8a1202a102e6de05fc6e1ec87da99e4e93e9a7d13efbfc1e95a9"
"checksum core-graphics 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)" = "59e78b2e0aaf43f08e7ae0d6bc96895ef72ff0921c7d4ff4762201b2dba376dd"
"checksum d3d12 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc7ed48e89905e5e146bcc1951cc3facb9e44aea9adf5dc01078cda1bd24b662"
"checksum foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"
"checksum foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
"checksum fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c"
"checksum gfx-auxil 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "572eee952a9a23c99cfe3e4fd95d277784058a89ac3c77ff6fa3d80a4e321919"
"checksum gfx-backend-dx11 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "d7527cfcd7d1eec6b99f81891293bdd2a41d044ace009717264e5f3b10ce5b86"
"checksum gfx-backend-dx12 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b6e913cc800fb12eaba2c420091a02aca9aafbefd672600dfc5b52654343d341"
"checksum gfx-backend-empty 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3d383e6bc48867cb37d298a20139fd1eec298f8f6d594690cd1c50ef25470cc7"
"checksum gfx-backend-metal 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "05b6130b9a72129ebb5c91d3d75a142a7fa54dcc112603231582e3fdc0b84247"
"checksum gfx-backend-vulkan 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "62538fedd66a78968a162e8e1a29d085ffbc97f8782634684b2f7da7aea59207"
"checksum gfx-hal 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7c88981665c780447bb08eb099e1ded330754a7246719bab927ee4a949c0ba7f"
"checksum gfx-auxil 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3b46e6f0031330a0be08d17820f2dcaaa91cb36710a97a9500cb4f1c36e785c8"
"checksum gfx-backend-dx11 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b148219292624126f78245e50a9720d95ea149a415ce8ce73ab7014205301b88"
"checksum gfx-backend-dx12 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a0e526746379e974501551b08958947e67a81b5ea8cdc717a000cdd72577da05"
"checksum gfx-backend-empty 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b67bd2d7bc022b257ddbdabc5fa3b10c29c292372c3409f2b6a6e3f4e11cdb85"
"checksum gfx-backend-metal 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cfe128c29675b5afc8acdda1dfe096d6abd5e3528059ab0b98bda8215d8beed9"
"checksum gfx-backend-vulkan 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ebd1dee09bd8d8f1ba52c5ba22d1f70c7ffa990c5eb245eb3ef2d0206f631673"
"checksum gfx-descriptor 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1bf35f5d66d1bc56e63e68d7528441453f25992bd954b84309d23c659df2c5da"
"checksum gfx-hal 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc96180204064c9493e0fe4a9efeb721e0ac59fe8e1906d0c659142a93114fb1"
"checksum gfx-memory 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c2eed6cda674d9cd4d92229102dbd544292124533d236904f987e9afab456137"
"checksum hibitset 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "47e7292fd9f7fe89fa35c98048f2d0a69b79ed243604234d18f6f8a1aa6f408d"
"checksum js-sys 0.3.32 (registry+https://github.com/rust-lang/crates.io-index)" = "1c840fdb2167497b0bd0db43d6dfe61e91637fa72f9d061f8bd17ddc44ba6414"
"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
@ -827,7 +789,6 @@ dependencies = [
"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7"
"checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1"
"checksum malloc_buf 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb"
"checksum maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00"
"checksum metal 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e198a0ee42bdbe9ef2c09d0b9426f3b2b47d90d93a4a9b0395c4cea605e92dc0"
"checksum nix 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3b2e0b4f3320ed72aaedb9a5ac838690a8047c7b275da22711fddff4f8a14229"
"checksum num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "c62be47e61d1842b9170f0fdeec8eba98e60e90e5446449a0545e5152acd7096"
@ -835,27 +796,23 @@ dependencies = [
"checksum objc_exception 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ad970fb455818ad6cba4c122ad012fae53ae8b4795f86378bce65e4f6bab2ca4"
"checksum parking_lot 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e"
"checksum parking_lot_core 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0e136c1904604defe99ce5fd71a28d473fa60a12255d511aa78a9ddf11237aeb"
"checksum peek-poke 0.2.0 (git+https://github.com/kvark/peek-poke?rev=969bd7fe2be1a83f87916dc8b388c63cfd457075)" = "<none>"
"checksum peek-poke-derive 0.2.0 (git+https://github.com/kvark/peek-poke?rev=969bd7fe2be1a83f87916dc8b388c63cfd457075)" = "<none>"
"checksum peek-poke 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d93fd6a575ebf1ac2668d08443c97a22872cfb463fd8b7ddd141e9f6be59af2f"
"checksum peek-poke-derive 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6fb44a25c5bba983be0fc8592dfaf3e6d0935ce8be0c6b15b2a39507af34a926"
"checksum pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)" = "05da548ad6865900e60eaba7f589cc0783590a92e940c26953ff81ddbab2d677"
"checksum proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9c9e470a8dc4aeae2dee2f335e8f533e2d4b347e1434e5671afc49b054592f27"
"checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe"
"checksum range-alloc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "dd5927936723a9e8b715d37d7e4b390455087c4bdf25b9f702309460577b14f9"
"checksum raw-window-handle 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0a441a7a6c80ad6473bd4b74ec1c9a4c951794285bf941c2126f607c72e48211"
"checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84"
"checksum relevant 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bbc232e13d37f4547f5b9b42a5efc380cabe5dbc1807f8b893580640b2ab0308"
"checksum rendy-descriptor 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f475bcc0505946e998590f1f0545c52ef4b559174a1b353a7ce6638def8b621e"
"checksum rendy-memory 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ed492161a819feae7f27f418bb16035276ac20649c60d756699152cb5c1960ec"
"checksum scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d"
"checksum serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)" = "1217f97ab8e8904b57dd22eb61cde455fa7446a9c1cf43966066da047c1f3702"
"checksum serde_derive 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)" = "a8c6faef9a2e64b0064f48570289b4bf8823b7581f1d6157c1b52152306651d0"
"checksum shared_library 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "5a9e7e0f2bfae24d8a5b5a66c5b257a83c7412304311512a0c054cd5e619da11"
"checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8"
"checksum smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "f7b0758c52e15a8b5e3691eae6cc559f08eee9406e548a4477ba4e67770a82b6"
"checksum smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4ecf3b85f68e8abaa7555aa5abdb1153079387e60b718283d732f03897fcfc86"
"checksum spirv_cross 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fbbe441b3ac8ec0ae6a4f05234239bd372a241ce15793eef694e8b24afc267bb"
"checksum spirv_cross 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)" = "946216f8793f7199e3ea5b995ee8dc20a0ace1fcf46293a0ef4c17e1d046dbde"
"checksum storage-map 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fd0a4829a5c591dc24a944a736d6b1e4053e51339a79fd5d4702c4c999a9c45e"
"checksum syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)" = "dff0acdb207ae2fe6d5976617f887eb1e35a2ba52c13c7234c790960cdad9238"
"checksum synstructure 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545"
"checksum typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6d2783fe2d6b8c1101136184eb41be8b1ad379e4657050b8aaff0c79ee7575f9"
"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
"checksum uom 0.26.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4cec796ec5f7ac557631709079168286056205c51c60aac33f51764bdc7b8dc4"

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

@ -9,7 +9,7 @@ This is an active GitHub mirror of the WebGPU implementation in Rust, which now
[![Crates.io](https://img.shields.io/crates/v/wgpu-core.svg?label=wgpu-core)](https://crates.io/crates/wgpu-core)
[![Crates.io](https://img.shields.io/crates/v/wgpu-native.svg?label=wgpu-native)](https://crates.io/crates/wgpu-native)
This is an experimental [WebGPU](https://www.w3.org/community/gpu/) implementation, exposing both Rust and C interfaces as a native static library. It's written in Rust and is based on [gfx-hal](https://github.com/gfx-rs/gfx) and a few [Rendy](https://github.com/amethyst/rendy) bits. See the upstream [WebGPU specification](https://gpuweb.github.io/gpuweb/) (work in progress).
This is an experimental [WebGPU](https://www.w3.org/community/gpu/) implementation, exposing both Rust and C interfaces as a native static library. It's written in Rust and is based on [gfx-hal](https://github.com/gfx-rs/gfx) with help of [gfx-extras](https://github.com/gfx-rs/gfx-extras). See the upstream [WebGPU specification](https://gpuweb.github.io/gpuweb/) (work in progress).
The implementation consists of the following parts:
@ -35,6 +35,8 @@ The implementation consists of the following parts:
Vulkan | :heavy_check_mark: | :heavy_check_mark: | |
Metal | | | :heavy_check_mark: |
OpenGL | :construction: | :construction: | :construction: |
:heavy_check_mark: = Primary support — :white_check_mark: = Secondary support — :construction: = Unsupported, but support in progress
## Usage

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

@ -69,6 +69,7 @@ int main(
WGPUBufferId buffer = wgpu_device_create_buffer_mapped(device,
&(WGPUBufferDescriptor){
.label = "buffer",
.size = size,
.usage = WGPUBufferUsage_STORAGE | WGPUBufferUsage_MAP_READ},
&staging_memory);
@ -80,6 +81,7 @@ int main(
WGPUBindGroupLayoutId bind_group_layout =
wgpu_device_create_bind_group_layout(device,
&(WGPUBindGroupLayoutDescriptor){
.label = "bind group layout",
.entries = &(WGPUBindGroupLayoutEntry){
.binding = 0,
.visibility = WGPUShaderStage_COMPUTE,
@ -94,7 +96,9 @@ int main(
.offset = 0}}};
WGPUBindGroupId bind_group = wgpu_device_create_bind_group(device,
&(WGPUBindGroupDescriptor){.layout = bind_group_layout,
&(WGPUBindGroupDescriptor){
.label = "bind group",
.layout = bind_group_layout,
.entries = &(WGPUBindGroupEntry){
.binding = 0,
.resource = resource},
@ -124,7 +128,7 @@ int main(
WGPUCommandEncoderId encoder = wgpu_device_create_command_encoder(
device, &(WGPUCommandEncoderDescriptor){
.todo = 0
.label = "command encoder",
});
WGPUComputePassId command_pass =

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

@ -43,10 +43,58 @@ void request_adapter_callback(WGPUAdapterId received, void *userdata) {
}
int main() {
if (!glfwInit()) {
printf("Cannot initialize glfw");
return 1;
}
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
GLFWwindow *window =
glfwCreateWindow(640, 480, "wgpu with glfw", NULL, NULL);
if (!window) {
printf("Cannot create window");
return 1;
}
WGPUSurfaceId surface;
#if WGPU_TARGET == WGPU_TARGET_MACOS
{
id metal_layer = NULL;
NSWindow *ns_window = glfwGetCocoaWindow(window);
[ns_window.contentView setWantsLayer:YES];
metal_layer = [CAMetalLayer layer];
[ns_window.contentView setLayer:metal_layer];
surface = wgpu_create_surface_from_metal_layer(metal_layer);
}
#elif WGPU_TARGET == WGPU_TARGET_LINUX_X11
{
Display *x11_display = glfwGetX11Display();
Window x11_window = glfwGetX11Window(window);
surface = wgpu_create_surface_from_xlib((const void **)x11_display, x11_window);
}
#elif WGPU_TARGET == WGPU_TARGET_LINUX_WAYLAND
{
struct wl_display *wayland_display = glfwGetWaylandDisplay();
struct wl_surface *wayland_surface = glfwGetWaylandWindow(window);
surface = wgpu_create_surface_from_wayland(wayland_surface, wayland_display);
}
#elif WGPU_TARGET == WGPU_TARGET_WINDOWS
{
HWND hwnd = glfwGetWin32Window(window);
HINSTANCE hinstance = GetModuleHandle(NULL);
surface = wgpu_create_surface_from_windows_hwnd(hinstance, hwnd);
}
#else
#error "Unsupported WGPU_TARGET"
#endif
WGPUAdapterId adapter = { 0 };
wgpu_request_adapter_async(
&(WGPURequestAdapterOptions){
.power_preference = WGPUPowerPreference_LowPower,
.compatible_surface = surface,
},
2 | 4 | 8,
request_adapter_callback,
@ -79,12 +127,14 @@ int main() {
WGPUBindGroupLayoutId bind_group_layout =
wgpu_device_create_bind_group_layout(device,
&(WGPUBindGroupLayoutDescriptor){
.label = "bind group layout",
.entries = NULL,
.entries_length = 0,
});
WGPUBindGroupId bind_group =
wgpu_device_create_bind_group(device,
&(WGPUBindGroupDescriptor){
.label = "bind group",
.layout = bind_group_layout,
.entries = NULL,
.entries_length = 0,
@ -151,53 +201,6 @@ int main() {
.sample_count = 1,
});
if (!glfwInit()) {
printf("Cannot initialize glfw");
return 1;
}
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
GLFWwindow *window =
glfwCreateWindow(640, 480, "wgpu with glfw", NULL, NULL);
if (!window) {
printf("Cannot create window");
return 1;
}
WGPUSurfaceId surface;
#if WGPU_TARGET == WGPU_TARGET_MACOS
{
id metal_layer = NULL;
NSWindow *ns_window = glfwGetCocoaWindow(window);
[ns_window.contentView setWantsLayer:YES];
metal_layer = [CAMetalLayer layer];
[ns_window.contentView setLayer:metal_layer];
surface = wgpu_create_surface_from_metal_layer(metal_layer);
}
#elif WGPU_TARGET == WGPU_TARGET_LINUX_X11
{
Display *x11_display = glfwGetX11Display();
Window x11_window = glfwGetX11Window(window);
surface = wgpu_create_surface_from_xlib((const void **)x11_display, x11_window);
}
#elif WGPU_TARGET == WGPU_TARGET_LINUX_WAYLAND
{
struct wl_display *wayland_display = glfwGetWaylandDisplay();
struct wl_surface *wayland_surface = glfwGetWaylandWindow(window);
surface = wgpu_create_surface_from_wayland(wayland_surface, wayland_display);
}
#elif WGPU_TARGET == WGPU_TARGET_WINDOWS
{
HWND hwnd = glfwGetWin32Window(window);
HINSTANCE hinstance = GetModuleHandle(NULL);
surface = wgpu_create_surface_from_windows_hwnd(hinstance, hwnd);
}
#else
#error "Unsupported WGPU_TARGET"
#endif
int prev_width = 0;
int prev_height = 0;
glfwGetWindowSize(window, &prev_width, &prev_height);
@ -237,7 +240,7 @@ int main() {
}
WGPUCommandEncoderId cmd_encoder = wgpu_device_create_command_encoder(
device, &(WGPUCommandEncoderDescriptor){.todo = 0});
device, &(WGPUCommandEncoderDescriptor){.label = "command encoder"});
WGPURenderPassColorAttachmentDescriptor
color_attachments[ATTACHMENTS_LENGTH] = {

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

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

@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* Generated with cbindgen:0.13.1 */
/* Generated with cbindgen:0.14.0 */
/* DO NOT MODIFY THIS MANUALLY! This file was generated using cbindgen.
* To generate this file:
@ -11,7 +11,10 @@
* 2. Run `rustup run nightly cbindgen toolkit/library/rust/ --lockfile Cargo.lock --crate wgpu-remote -o dom/webgpu/ffi/wgpu_ffi_generated.h`
*/
#define WGPU_LOCAL
typedef unsigned long long WGPUNonZeroU64;
typedef unsigned long long WGPUOption_AdapterId;
typedef unsigned long long WGPUOption_SurfaceId;
typedef unsigned long long WGPUOption_TextureViewId;
#include <stdarg.h>
@ -19,6 +22,11 @@
#include <stdint.h>
#include <stdlib.h>
/**
* Bound uniform/storage buffer offsets must be aligned to this number.
*/
#define WGPUBIND_BUFFER_ALIGNMENT 256
#define WGPUDEFAULT_BIND_GROUPS 4
#define WGPUDESIRED_NUM_FRAMES 3
@ -80,14 +88,15 @@ typedef enum {
} WGPUBufferMapAsyncStatus;
typedef enum {
WGPUCompareFunction_Never = 0,
WGPUCompareFunction_Less = 1,
WGPUCompareFunction_Equal = 2,
WGPUCompareFunction_LessEqual = 3,
WGPUCompareFunction_Greater = 4,
WGPUCompareFunction_NotEqual = 5,
WGPUCompareFunction_GreaterEqual = 6,
WGPUCompareFunction_Always = 7,
WGPUCompareFunction_Undefined = 0,
WGPUCompareFunction_Never = 1,
WGPUCompareFunction_Less = 2,
WGPUCompareFunction_Equal = 3,
WGPUCompareFunction_LessEqual = 4,
WGPUCompareFunction_Greater = 5,
WGPUCompareFunction_NotEqual = 6,
WGPUCompareFunction_GreaterEqual = 7,
WGPUCompareFunction_Always = 8,
} WGPUCompareFunction;
typedef enum {
@ -275,11 +284,11 @@ typedef enum {
WGPUVertexFormat_Int4 = 48,
} WGPUVertexFormat;
typedef uint64_t WGPUId_Adapter_Dummy;
typedef WGPUNonZeroU64 WGPUId_Adapter_Dummy;
typedef WGPUId_Adapter_Dummy WGPUAdapterId;
typedef uint64_t WGPUId_Device_Dummy;
typedef WGPUNonZeroU64 WGPUId_Device_Dummy;
typedef WGPUId_Device_Dummy WGPUDeviceId;
@ -296,11 +305,11 @@ typedef struct {
WGPULimits limits;
} WGPUDeviceDescriptor;
typedef uint64_t WGPUId_BindGroup_Dummy;
typedef WGPUNonZeroU64 WGPUId_BindGroup_Dummy;
typedef WGPUId_BindGroup_Dummy WGPUBindGroupId;
typedef uint64_t WGPUId_Buffer_Dummy;
typedef WGPUNonZeroU64 WGPUId_Buffer_Dummy;
typedef WGPUId_Buffer_Dummy WGPUBufferId;
@ -310,7 +319,7 @@ typedef void (*WGPUBufferMapReadCallback)(WGPUBufferMapAsyncStatus status, const
typedef void (*WGPUBufferMapWriteCallback)(WGPUBufferMapAsyncStatus status, uint8_t *data, uint8_t *userdata);
typedef uint64_t WGPUId_CommandBuffer_Dummy;
typedef WGPUNonZeroU64 WGPUId_CommandBuffer_Dummy;
typedef WGPUId_CommandBuffer_Dummy WGPUCommandBufferId;
@ -327,12 +336,10 @@ typedef struct {
uint32_t todo;
} WGPUComputePassDescriptor;
typedef uint64_t WGPUId_TextureView_Dummy;
typedef WGPUNonZeroU64 WGPUId_TextureView_Dummy;
typedef WGPUId_TextureView_Dummy WGPUTextureViewId;
typedef const WGPUTextureViewId *WGPUOptionRef_TextureViewId;
typedef struct {
double r;
double g;
@ -348,13 +355,13 @@ typedef struct {
typedef struct {
WGPUTextureViewId attachment;
WGPUOptionRef_TextureViewId resolve_target;
WGPUOption_TextureViewId resolve_target;
WGPULoadOp load_op;
WGPUStoreOp store_op;
WGPUColor clear_color;
} WGPURenderPassColorAttachmentDescriptorBase_TextureViewId__OptionRef_TextureViewId;
} WGPURenderPassColorAttachmentDescriptorBase_TextureViewId;
typedef WGPURenderPassColorAttachmentDescriptorBase_TextureViewId__OptionRef_TextureViewId WGPURenderPassColorAttachmentDescriptor;
typedef WGPURenderPassColorAttachmentDescriptorBase_TextureViewId WGPURenderPassColorAttachmentDescriptor;
typedef struct {
WGPUTextureViewId attachment;
@ -381,7 +388,7 @@ typedef struct {
uint32_t rows_per_image;
} WGPUBufferCopyView;
typedef uint64_t WGPUId_Texture_Dummy;
typedef WGPUNonZeroU64 WGPUId_Texture_Dummy;
typedef WGPUId_Texture_Dummy WGPUTextureId;
@ -415,15 +422,15 @@ typedef const char *WGPURawString;
typedef uint32_t WGPUDynamicOffset;
typedef uint64_t WGPUId_ComputePipeline_Dummy;
typedef WGPUNonZeroU64 WGPUId_ComputePipeline_Dummy;
typedef WGPUId_ComputePipeline_Dummy WGPUComputePipelineId;
typedef uint64_t WGPUId_Surface;
typedef WGPUNonZeroU64 WGPUId_Surface;
typedef WGPUId_Surface WGPUSurfaceId;
typedef uint64_t WGPUId_BindGroupLayout_Dummy;
typedef WGPUNonZeroU64 WGPUId_BindGroupLayout_Dummy;
typedef WGPUId_BindGroupLayout_Dummy WGPUBindGroupLayoutId;
@ -433,7 +440,7 @@ typedef struct {
WGPUBufferAddress size;
} WGPUBufferBinding;
typedef uint64_t WGPUId_Sampler_Dummy;
typedef WGPUNonZeroU64 WGPUId_Sampler_Dummy;
typedef WGPUId_Sampler_Dummy WGPUSamplerId;
@ -470,6 +477,7 @@ typedef struct {
} WGPUBindGroupEntry;
typedef struct {
const char *label;
WGPUBindGroupLayoutId layout;
const WGPUBindGroupEntry *entries;
uintptr_t entries_length;
@ -493,6 +501,7 @@ typedef struct {
} WGPUBindGroupLayoutEntry;
typedef struct {
const char *label;
const WGPUBindGroupLayoutEntry *entries;
uintptr_t entries_length;
} WGPUBindGroupLayoutDescriptor;
@ -511,19 +520,20 @@ typedef uint32_t WGPUBufferUsage;
#define WGPUBufferUsage_NONE 0
typedef struct {
const char *label;
WGPUBufferAddress size;
WGPUBufferUsage usage;
} WGPUBufferDescriptor;
typedef struct {
uint32_t todo;
const char *label;
} WGPUCommandEncoderDescriptor;
typedef uint64_t WGPUId_PipelineLayout_Dummy;
typedef WGPUNonZeroU64 WGPUId_PipelineLayout_Dummy;
typedef WGPUId_PipelineLayout_Dummy WGPUPipelineLayoutId;
typedef uint64_t WGPUId_ShaderModule_Dummy;
typedef WGPUNonZeroU64 WGPUId_ShaderModule_Dummy;
typedef WGPUId_ShaderModule_Dummy WGPUShaderModuleId;
@ -542,7 +552,7 @@ typedef struct {
uintptr_t bind_group_layouts_length;
} WGPUPipelineLayoutDescriptor;
typedef uint64_t WGPUId_RenderPipeline_Dummy;
typedef WGPUNonZeroU64 WGPUId_RenderPipeline_Dummy;
typedef WGPUId_RenderPipeline_Dummy WGPURenderPipelineId;
@ -637,7 +647,7 @@ typedef struct {
WGPUFilterMode mipmap_filter;
float lod_min_clamp;
float lod_max_clamp;
const WGPUCompareFunction *compare;
WGPUCompareFunction compare;
} WGPUSamplerDescriptor;
typedef struct {
@ -649,7 +659,7 @@ typedef struct {
WGPUU32Array code;
} WGPUShaderModuleDescriptor;
typedef uint64_t WGPUId_SwapChain_Dummy;
typedef WGPUNonZeroU64 WGPUId_SwapChain_Dummy;
typedef WGPUId_SwapChain_Dummy WGPUSwapChainId;
@ -671,6 +681,7 @@ typedef struct {
} WGPUSwapChainDescriptor;
typedef struct {
const char *label;
WGPUExtent3d size;
uint32_t array_layer_count;
uint32_t mip_level_count;
@ -684,20 +695,21 @@ typedef WGPUDeviceId WGPUQueueId;
typedef WGPURawPass *WGPURenderPassId;
typedef uint64_t WGPUId_RenderBundle_Dummy;
typedef WGPUNonZeroU64 WGPUId_RenderBundle_Dummy;
typedef WGPUId_RenderBundle_Dummy WGPURenderBundleId;
typedef struct {
WGPUPowerPreference power_preference;
WGPUOption_SurfaceId compatible_surface;
} WGPURequestAdapterOptions;
typedef uint32_t WGPUBackendBit;
typedef void (*WGPURequestAdapterCallback)(WGPUAdapterId id, void *userdata);
typedef void (*WGPURequestAdapterCallback)(WGPUOption_AdapterId id, void *userdata);
typedef struct {
WGPUTextureViewId view_id;
WGPUOption_TextureViewId view_id;
} WGPUSwapChainOutput;
typedef struct {

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

@ -6,7 +6,7 @@ authors = [
"Joshua Groves <josh@joshgroves.com>",
]
edition = "2018"
description = "WebGPU core logic on gfx-hal/rendy"
description = "WebGPU core logic on gfx-hal"
homepage = "https://github.com/gfx-rs/wgpu"
repository = "https://github.com/gfx-rs/wgpu"
keywords = ["graphics"]
@ -27,13 +27,13 @@ bitflags = "1.0"
copyless = "0.1"
fxhash = "0.2"
log = "0.4"
hal = { package = "gfx-hal", version = "0.4" }
gfx-backend-empty = { version = "0.4" }
hal = { package = "gfx-hal", version = "0.5" }
gfx-backend-empty = "0.5"
gfx-descriptor = "0.1"
gfx-memory = "0.1"
parking_lot = "0.10"
peek-poke = { git = "https://github.com/kvark/peek-poke", rev = "969bd7fe2be1a83f87916dc8b388c63cfd457075" }
rendy-memory = "0.5"
rendy-descriptor = "0.5"
smallvec = "1.0"
peek-poke = "0.2"
smallvec = "1"
vec_map = "0.8"
[dependencies.serde_crate]
@ -49,16 +49,16 @@ version = "0.1"
features = ["peek-poke"]
[target.'cfg(any(target_os = "ios", target_os = "macos"))'.dependencies]
gfx-backend-metal = { version = "0.4" }
gfx-backend-vulkan = { version = "0.4", optional = true }
gfx-backend-metal = { version = "0.5" }
gfx-backend-vulkan = { version = "0.5", optional = true }
[target.'cfg(all(unix, not(target_os = "ios"), not(target_os = "macos")))'.dependencies]
gfx-backend-vulkan = { version = "0.4", features = ["x11"] }
gfx-backend-vulkan = { version = "0.5", features = ["x11"] }
[target.'cfg(windows)'.dependencies]
gfx-backend-dx12 = { version = "0.4.1" }
gfx-backend-dx11 = { version = "0.4" }
gfx-backend-vulkan = { version = "0.4" }
gfx-backend-dx12 = { version = "0.5" }
gfx-backend-dx11 = { version = "0.5" }
gfx-backend-vulkan = { version = "0.5" }
[target.'cfg(any(target_os = "linux", target_os = "macos", target_os = "windows", target_os = "dragonfly", target_os = "freebsd"))'.dependencies]
battery = { version = "0.7", optional = true }

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

@ -11,9 +11,9 @@ use crate::{
Stored,
};
use wgt::BufferAddress;
use wgt::{BufferAddress, TextureComponentType};
use arrayvec::ArrayVec;
use rendy_descriptor::{DescriptorRanges, DescriptorSet};
use gfx_descriptor::{DescriptorCounts, DescriptorSet};
#[cfg(feature = "serde")]
use serde_crate::{Deserialize, Serialize};
@ -33,15 +33,6 @@ pub enum BindingType {
WriteonlyStorageTexture = 7,
}
#[repr(C)]
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(crate="serde_crate"))]
pub enum TextureComponentType {
Float,
Sint,
Uint,
}
#[repr(C)]
#[derive(Clone, Debug, Hash, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(crate="serde_crate"))]
@ -59,6 +50,7 @@ pub struct BindGroupLayoutEntry {
#[repr(C)]
#[derive(Debug)]
pub struct BindGroupLayoutDescriptor {
pub label: *const std::os::raw::c_char,
pub entries: *const BindGroupLayoutEntry,
pub entries_length: usize,
}
@ -68,7 +60,7 @@ pub struct BindGroupLayout<B: hal::Backend> {
pub(crate) raw: B::DescriptorSetLayout,
pub(crate) device_id: Stored<DeviceId>,
pub(crate) entries: FastHashMap<u32, BindGroupLayoutEntry>,
pub(crate) desc_ranges: DescriptorRanges,
pub(crate) desc_counts: DescriptorCounts,
pub(crate) dynamic_count: usize,
}
@ -115,6 +107,7 @@ pub struct BindGroupEntry {
#[repr(C)]
#[derive(Debug)]
pub struct BindGroupDescriptor {
pub label: *const std::os::raw::c_char,
pub layout: BindGroupLayoutId,
pub entries: *const BindGroupEntry,
pub entries_length: usize,

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

@ -55,10 +55,8 @@ impl<B: hal::Backend> CommandPool<B> {
fn allocate(&mut self) -> B::CommandBuffer {
if self.available.is_empty() {
let extra = unsafe { self.raw.allocate_vec(20, hal::command::Level::Primary) };
self.available.extend(extra);
unsafe { self.raw.allocate(20, hal::command::Level::Primary, &mut self.available) };
}
self.available.pop().unwrap()
}
}
@ -133,8 +131,7 @@ impl<B: hal::Backend> CommandAllocator<B> {
let pool = inner.pools.get_mut(&cmd_buf.recorded_thread_id).unwrap();
if pool.available.is_empty() {
let extra = unsafe { pool.raw.allocate_vec(20, hal::command::Level::Primary) };
pool.available.extend(extra);
unsafe { pool.raw.allocate(20, hal::command::Level::Primary, &mut pool.available) };
}
pool.available.pop().unwrap()

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

@ -8,19 +8,24 @@ use crate::{
CommandBuffer,
PhantomSlice,
},
device::{all_buffer_stages, BIND_BUFFER_ALIGNMENT},
device::all_buffer_stages,
hub::{GfxBackend, Global, GlobalIdentityHandlerFactory, Token},
id,
};
use wgt::{BufferAddress, BufferUsage, DynamicOffset};
use wgt::{BufferAddress, BufferUsage, DynamicOffset, BIND_BUFFER_ALIGNMENT};
use hal::command::CommandBuffer as _;
use peek_poke::{Peek, PeekCopy, Poke};
use peek_poke::{Peek, PeekPoke, Poke};
use std::iter;
#[derive(Debug, PartialEq)]
enum PipelineState {
Required,
Set,
}
#[derive(Clone, Copy, Debug, PeekCopy, Poke)]
#[derive(Clone, Copy, Debug, PeekPoke)]
enum ComputeCommand {
SetBindGroup {
index: u8,
@ -37,6 +42,12 @@ enum ComputeCommand {
End,
}
impl Default for ComputeCommand {
fn default() -> Self {
ComputeCommand::End
}
}
impl super::RawPass {
pub unsafe fn new_compute(parent: id::CommandEncoderId) -> Self {
Self::from_vec(Vec::<ComputeCommand>::with_capacity(1), parent)
@ -76,6 +87,8 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
let (buffer_guard, mut token) = hub.buffers.read(&mut token);
let (texture_guard, _) = hub.textures.read(&mut token);
let mut pipeline_state = PipelineState::Required;
let mut peeker = raw_data.as_ptr();
let raw_data_end = unsafe {
raw_data.as_ptr().add(raw_data.len())
@ -83,7 +96,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
let mut command = ComputeCommand::Dispatch([0; 3]); // dummy
loop {
assert!(unsafe { peeker.add(ComputeCommand::max_size()) } <= raw_data_end);
peeker = unsafe { command.peek_from(peeker) };
peeker = unsafe { ComputeCommand::peek_from(peeker, &mut command) };
match command {
ComputeCommand::SetBindGroup { index, num_dynamic_offsets, bind_group_id, phantom_offsets } => {
let (new_peeker, offsets) = unsafe {
@ -136,13 +149,17 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
offsets
.iter()
.chain(follow_ups.flat_map(|(_, offsets)| offsets))
.map(|&off| off as hal::command::DescriptorSetOffset),
.cloned(),
);
}
}
}
ComputeCommand::SetPipeline(pipeline_id) => {
let pipeline = &pipeline_guard[pipeline_id];
pipeline_state = PipelineState::Set;
let pipeline = cmb.trackers
.compute_pipes
.use_extend(&*pipeline_guard, pipeline_id, (), ())
.unwrap();
unsafe {
raw.bind_compute_pipeline(&pipeline.raw);
@ -170,7 +187,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
&pipeline_layout.raw,
index,
iter::once(desc_set),
offsets.iter().map(|offset| *offset as u32),
offsets.iter().cloned(),
);
}
}
@ -183,11 +200,13 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
}
}
ComputeCommand::Dispatch(groups) => {
assert_eq!(pipeline_state, PipelineState::Set, "Dispatch error: Pipeline is missing");
unsafe {
raw.dispatch(groups);
}
}
ComputeCommand::DispatchIndirect { buffer_id, offset } => {
assert_eq!(pipeline_state, PipelineState::Set, "Dispatch error: Pipeline is missing");
let (src_buffer, src_pending) = cmb.trackers.buffers.use_replace(
&*buffer_guard,
buffer_id,
@ -243,7 +262,7 @@ use wgt::{BufferAddress, DynamicOffset};
index: index.try_into().unwrap(),
num_dynamic_offsets: offset_length.try_into().unwrap(),
bind_group_id,
phantom_offsets: PhantomSlice::new(),
phantom_offsets: PhantomSlice::default(),
});
pass.encode_slice(
slice::from_raw_parts(offsets, offset_length),

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

@ -28,6 +28,8 @@ use crate::{
Stored,
};
use peek_poke::PeekPoke;
use std::{
marker::PhantomData,
mem,
@ -35,17 +37,18 @@ use std::{
slice,
thread::ThreadId,
};
use wgt::RenderPassColorAttachmentDescriptorBase;
#[derive(Clone, Copy, Debug, peek_poke::PeekCopy, peek_poke::Poke)]
#[derive(Clone, Copy, Debug, PeekPoke)]
struct PhantomSlice<T>(PhantomData<T>);
impl<T> PhantomSlice<T> {
fn new() -> Self {
impl<T> Default for PhantomSlice<T> {
fn default() -> Self {
PhantomSlice(PhantomData)
}
}
impl<T> PhantomSlice<T> {
unsafe fn decode_unaligned<'a>(
self, pointer: *const u8, count: usize, bound: *const u8
) -> (*const u8, &'a [T]) {
@ -183,6 +186,8 @@ impl<B: GfxBackend> CommandBuffer<B> {
base.views.merge_extend(&head.views).unwrap();
base.bind_groups.merge_extend(&head.bind_groups).unwrap();
base.samplers.merge_extend(&head.samplers).unwrap();
base.compute_pipes.merge_extend(&head.compute_pipes).unwrap();
base.render_pipes.merge_extend(&head.render_pipes).unwrap();
let stages = all_buffer_stages() | all_image_stages();
unsafe {
@ -196,26 +201,52 @@ impl<B: GfxBackend> CommandBuffer<B> {
}
#[repr(C)]
#[derive(Clone, Debug, Default)]
pub struct CommandBufferDescriptor {
pub todo: u32,
#[derive(PeekPoke)]
struct PassComponent<T> {
load_op: wgt::LoadOp,
store_op: wgt::StoreOp,
clear_value: T,
}
pub type RawRenderPassColorAttachmentDescriptor =
RenderPassColorAttachmentDescriptorBase<id::TextureViewId, id::TextureViewId>;
// required for PeekPoke
impl<T: Default> Default for PassComponent<T> {
fn default() -> Self {
PassComponent {
load_op: wgt::LoadOp::Clear,
store_op: wgt::StoreOp::Clear,
clear_value: T::default(),
}
}
}
#[repr(C)]
#[derive(peek_poke::PeekCopy, peek_poke::Poke)]
pub struct RawRenderTargets {
pub colors: [RawRenderPassColorAttachmentDescriptor; MAX_COLOR_TARGETS],
pub depth_stencil: RenderPassDepthStencilAttachmentDescriptor,
#[derive(Default, PeekPoke)]
struct RawRenderPassColorAttachmentDescriptor {
attachment: u64,
resolve_target: u64,
component: PassComponent<wgt::Color>,
}
#[repr(C)]
#[derive(Default, PeekPoke)]
struct RawRenderPassDepthStencilAttachmentDescriptor {
attachment: u64,
depth: PassComponent<f32>,
stencil: PassComponent<u32>,
}
#[repr(C)]
#[derive(Default, PeekPoke)]
struct RawRenderTargets {
colors: [RawRenderPassColorAttachmentDescriptor; MAX_COLOR_TARGETS],
depth_stencil: RawRenderPassDepthStencilAttachmentDescriptor,
}
impl<G: GlobalIdentityHandlerFactory> Global<G> {
pub fn command_encoder_finish<B: GfxBackend>(
&self,
encoder_id: id::CommandEncoderId,
_desc: &CommandBufferDescriptor,
_desc: &wgt::CommandBufferDescriptor,
) -> id::CommandBufferId {
let hub = B::hub(self);
let mut token = Token::root();

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

@ -5,8 +5,10 @@
use crate::{
command::{
bind::{Binder, LayoutChange},
PassComponent,
PhantomSlice,
RawRenderPassColorAttachmentDescriptor,
RawRenderPassDepthStencilAttachmentDescriptor,
RawRenderTargets,
},
conv,
@ -14,7 +16,6 @@ use crate::{
FramebufferKey,
RenderPassContext,
RenderPassKey,
BIND_BUFFER_ALIGNMENT,
MAX_VERTEX_BUFFERS,
MAX_COLOR_TARGETS,
},
@ -37,10 +38,11 @@ use wgt::{
RenderPassColorAttachmentDescriptorBase,
RenderPassDepthStencilAttachmentDescriptorBase,
TextureUsage,
BIND_BUFFER_ALIGNMENT
};
use arrayvec::ArrayVec;
use hal::command::CommandBuffer as _;
use peek_poke::{Peek, PeekCopy, Poke};
use peek_poke::{Peek, PeekPoke, Poke};
use std::{
borrow::Borrow,
@ -52,23 +54,20 @@ use std::{
slice,
};
//Note: this could look better if `cbindgen` wasn't confused by &T used in place of
// a generic parameter, it's not able to manage
pub type OptionRef<'a, T> = Option<&'a T>;
pub type RenderPassColorAttachmentDescriptor<'a> =
RenderPassColorAttachmentDescriptorBase<id::TextureViewId, OptionRef<'a, id::TextureViewId>>;
pub type RenderPassColorAttachmentDescriptor =
RenderPassColorAttachmentDescriptorBase<id::TextureViewId>;
pub type RenderPassDepthStencilAttachmentDescriptor =
RenderPassDepthStencilAttachmentDescriptorBase<id::TextureViewId>;
#[repr(C)]
#[derive(Debug)]
pub struct RenderPassDescriptor<'a> {
pub color_attachments: *const RenderPassColorAttachmentDescriptor<'a>,
pub color_attachments: *const RenderPassColorAttachmentDescriptor,
pub color_attachments_length: usize,
pub depth_stencil_attachment: Option<&'a RenderPassDepthStencilAttachmentDescriptor>,
}
#[derive(Clone, Copy, Debug, PeekCopy, Poke)]
#[derive(Clone, Copy, Debug, Default, PeekPoke)]
pub struct Rect<T> {
pub x: T,
pub y: T,
@ -76,7 +75,7 @@ pub struct Rect<T> {
pub h: T,
}
#[derive(Clone, Copy, Debug, PeekCopy, Poke)]
#[derive(Clone, Copy, Debug, PeekPoke)]
enum RenderCommand {
SetBindGroup {
index: u8,
@ -129,26 +128,46 @@ enum RenderCommand {
End,
}
// required for PeekPoke
impl Default for RenderCommand {
fn default() -> Self {
RenderCommand::End
}
}
impl super::RawPass {
pub unsafe fn new_render(parent_id: id::CommandEncoderId, desc: &RenderPassDescriptor) -> Self {
let mut pass = Self::from_vec(Vec::<RenderCommand>::with_capacity(1), parent_id);
let mut targets = RawRenderTargets {
depth_stencil: desc.depth_stencil_attachment
.cloned()
.unwrap_or_else(|| mem::zeroed()),
colors: mem::zeroed(),
};
let mut targets: RawRenderTargets = mem::zeroed();
if let Some(ds) = desc.depth_stencil_attachment {
targets.depth_stencil = RawRenderPassDepthStencilAttachmentDescriptor {
attachment: ds.attachment.into_raw(),
depth: PassComponent {
load_op: ds.depth_load_op,
store_op: ds.depth_store_op,
clear_value: ds.clear_depth,
},
stencil: PassComponent {
load_op: ds.stencil_load_op,
store_op: ds.stencil_store_op,
clear_value: ds.clear_stencil,
},
};
}
for (color, at) in targets.colors
.iter_mut()
.zip(slice::from_raw_parts(desc.color_attachments, desc.color_attachments_length))
{
*color = RawRenderPassColorAttachmentDescriptor {
attachment: at.attachment,
resolve_target: at.resolve_target.map_or(id::TextureViewId::ERROR, |rt| *rt),
load_op: at.load_op,
store_op: at.store_op,
clear_color: at.clear_color,
attachment: at.attachment.into_raw(),
resolve_target: at.resolve_target.map_or(0, |id| id.into_raw()),
component: PassComponent {
load_op: at.load_op,
store_op: at.store_op,
clear_value: at.clear_color,
},
};
}
@ -182,6 +201,7 @@ impl OptionalState {
enum DrawError {
MissingBlendColor,
MissingStencilReference,
MissingPipeline,
IncompatibleBindGroup {
index: u32,
//expected: BindGroupLayoutId,
@ -255,6 +275,7 @@ struct State {
binder: Binder,
blend_color: OptionalState,
stencil_reference: OptionalState,
pipeline: OptionalState,
index: IndexState,
vertex: VertexState,
}
@ -266,9 +287,12 @@ impl State {
if bind_mask != 0 {
//let (expected, provided) = self.binder.entries[index as usize].info();
return Err(DrawError::IncompatibleBindGroup {
index: bind_mask.trailing_zeros() as u32,
index: bind_mask.trailing_zeros(),
});
}
if self.pipeline == OptionalState::Required {
return Err(DrawError::MissingPipeline);
}
if self.blend_color == OptionalState::Required {
return Err(DrawError::MissingBlendColor);
}
@ -317,29 +341,36 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
let mut targets: RawRenderTargets = unsafe { mem::zeroed() };
assert!(unsafe { peeker.add(RawRenderTargets::max_size()) <= raw_data_end });
peeker = unsafe { targets.peek_from(peeker) };
peeker = unsafe { RawRenderTargets::peek_from(peeker, &mut targets) };
let color_attachments = targets.colors
.iter()
.take_while(|at| at.attachment != id::TextureViewId::ERROR)
.take_while(|at| at.attachment != 0)
.map(|at| {
RenderPassColorAttachmentDescriptor {
attachment: at.attachment,
resolve_target: if at.resolve_target == id::TextureViewId::ERROR {
None
} else {
Some(&at.resolve_target)
},
load_op: at.load_op,
store_op: at.store_op,
clear_color: at.clear_color,
attachment: id::TextureViewId::from_raw(at.attachment).unwrap(),
resolve_target: id::TextureViewId::from_raw(at.resolve_target),
load_op: at.component.load_op,
store_op: at.component.store_op,
clear_color: at.component.clear_value,
}
})
.collect::<arrayvec::ArrayVec<[_; MAX_COLOR_TARGETS]>>();
let depth_stencil_attachment = if targets.depth_stencil.attachment == id::TextureViewId::ERROR {
.collect::<ArrayVec<[_; MAX_COLOR_TARGETS]>>();
let depth_stencil_attachment_body;
let depth_stencil_attachment = if targets.depth_stencil.attachment == 0 {
None
} else {
Some(&targets.depth_stencil)
let at = &targets.depth_stencil;
depth_stencil_attachment_body = RenderPassDepthStencilAttachmentDescriptor {
attachment: id::TextureViewId::from_raw(at.attachment).unwrap(),
depth_load_op: at.depth.load_op,
depth_store_op: at.depth.store_op,
clear_depth: at.depth.clear_value,
stencil_load_op: at.stencil.load_op,
stencil_store_op: at.stencil.store_op,
clear_stencil: at.stencil.clear_value,
};
Some(&depth_stencil_attachment_body)
};
let (context, sample_count) = {
@ -485,7 +516,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
});
}
for &resolve_target in color_attachments
for resolve_target in color_attachments
.iter()
.flat_map(|at| at.resolve_target)
{
@ -602,7 +633,8 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
} else {
let sample_count_check =
view_guard[color_attachments[i].attachment].samples;
assert!(sample_count_check > 1, "RenderPassColorAttachmentDescriptor with a resolve_target must have an attachment with sample_count > 1");
assert!(sample_count_check > 1,
"RenderPassColorAttachmentDescriptor with a resolve_target must have an attachment with sample_count > 1");
resolve_ids.push((
attachment_index,
hal::image::Layout::ColorAttachmentOptimal,
@ -641,7 +673,6 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
resolves: color_attachments
.iter()
.filter_map(|at| at.resolve_target)
.cloned()
.collect(),
depth_stencil: depth_stencil_attachment.map(|at| at.attachment),
};
@ -773,7 +804,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
resolves: color_attachments
.iter()
.filter_map(|at| at.resolve_target)
.map(|resolve| view_guard[*resolve].format)
.map(|resolve| view_guard[resolve].format)
.collect(),
depth_stencil: depth_stencil_attachment.map(|at| view_guard[at.attachment].format),
};
@ -784,6 +815,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
binder: Binder::new(cmb.features.max_bind_groups),
blend_color: OptionalState::Unused,
stencil_reference: OptionalState::Unused,
pipeline: OptionalState::Required,
index: IndexState {
bound_buffer_view: None,
format: IndexFormat::Uint16,
@ -804,7 +836,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
};
loop {
assert!(unsafe { peeker.add(RenderCommand::max_size()) } <= raw_data_end);
peeker = unsafe { command.peek_from(peeker) };
peeker = unsafe { RenderCommand::peek_from(peeker, &mut command) };
match command {
RenderCommand::SetBindGroup { index, num_dynamic_offsets, bind_group_id, phantom_offsets } => {
let (new_peeker, offsets) = unsafe {
@ -845,13 +877,17 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
offsets
.iter()
.chain(follow_ups.flat_map(|(_, offsets)| offsets))
.map(|&off| off as hal::command::DescriptorSetOffset),
.cloned()
);
}
};
}
RenderCommand::SetPipeline(pipeline_id) => {
let pipeline = &pipeline_guard[pipeline_id];
state.pipeline = OptionalState::Set;
let pipeline = trackers
.render_pipes
.use_extend(&*pipeline_guard, pipeline_id, (), ())
.unwrap();
assert!(
context.compatible(&pipeline.pass_context),
@ -894,7 +930,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
&pipeline_layout.raw,
index,
iter::once(desc_set),
offsets.iter().map(|offset| *offset as u32),
offsets.iter().cloned(),
);
}
}
@ -919,7 +955,10 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
let view = hal::buffer::IndexBufferView {
buffer: &buffer.raw,
offset: range.start,
range: hal::buffer::SubRange {
offset: range.start,
size: Some(range.end - range.start),
},
index_type: conv::map_index_format(state.index.format),
};
@ -957,7 +996,10 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
let view = hal::buffer::IndexBufferView {
buffer: &buffer.raw,
offset,
range: hal::buffer::SubRange {
offset,
size: Some(end - offset),
},
index_type: conv::map_index_format(state.index.format),
};
@ -977,8 +1019,12 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
buffer.size - offset
};
let range = hal::buffer::SubRange {
offset,
size: if size != 0 { Some(size) } else { None },
};
unsafe {
raw.bind_vertex_buffers(slot, iter::once((&buffer.raw, offset)));
raw.bind_vertex_buffers(slot, iter::once((&buffer.raw, range)));
}
state.vertex.update_limits();
}
@ -1151,7 +1197,7 @@ pub mod render_ffi {
index: index.try_into().unwrap(),
num_dynamic_offsets: offset_length.try_into().unwrap(),
bind_group_id,
phantom_offsets: PhantomSlice::new(),
phantom_offsets: PhantomSlice::default(),
});
pass.encode_slice(
slice::from_raw_parts(offsets, offset_length),

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

@ -7,11 +7,9 @@ use crate::{
device::{all_buffer_stages, all_image_stages},
hub::{GfxBackend, Global, GlobalIdentityHandlerFactory, Token},
id::{BufferId, CommandEncoderId, TextureId},
Extent3d,
Origin3d,
};
use wgt::{BufferAddress, BufferUsage, TextureUsage};
use wgt::{BufferAddress, BufferUsage, Extent3d, Origin3d, TextureUsage};
use hal::command::CommandBuffer as _;
use std::iter;

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

@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use crate::{binding_model, resource, Extent3d, Features, Origin3d};
use crate::{binding_model, Features};
use wgt::{
BlendDescriptor,
BlendFactor,
@ -12,13 +12,15 @@ use wgt::{
CompareFunction,
CullMode,
DepthStencilStateDescriptor,
Extent3d,
FrontFace,
IndexFormat,
Origin3d,
PrimitiveTopology,
RasterizationStateDescriptor,
StencilOperation,
StencilStateFaceDescriptor,
TextureFormat,
RasterizationStateDescriptor,
VertexFormat,
};
@ -99,28 +101,61 @@ pub fn map_binding_type(
binding: &binding_model::BindGroupLayoutEntry,
) -> hal::pso::DescriptorType {
use crate::binding_model::BindingType as Bt;
use hal::pso::DescriptorType as H;
use hal::pso;
match binding.ty {
Bt::UniformBuffer => {
if binding.has_dynamic_offset {
H::UniformBufferDynamic
} else {
H::UniformBuffer
pso::DescriptorType::Buffer {
ty: pso::BufferDescriptorType::Uniform,
format: pso::BufferDescriptorFormat::Structured {
dynamic_offset: binding.has_dynamic_offset,
},
}
}
Bt::StorageBuffer => {
pso::DescriptorType::Buffer {
ty: pso::BufferDescriptorType::Storage {
read_only: false,
},
format: pso::BufferDescriptorFormat::Structured {
dynamic_offset: binding.has_dynamic_offset,
},
}
}
Bt::StorageBuffer |
Bt::ReadonlyStorageBuffer => {
if binding.has_dynamic_offset {
H::StorageBufferDynamic
} else {
H::StorageBuffer
pso::DescriptorType::Buffer {
ty: pso::BufferDescriptorType::Storage {
read_only: true,
},
format: pso::BufferDescriptorFormat::Structured {
dynamic_offset: binding.has_dynamic_offset,
},
}
}
Bt::Sampler |
Bt::ComparisonSampler => H::Sampler,
Bt::SampledTexture => H::SampledImage,
Bt::ReadonlyStorageTexture |
Bt::WriteonlyStorageTexture => H::StorageImage,
Bt::ComparisonSampler => {
pso::DescriptorType::Sampler
}
Bt::SampledTexture => {
pso::DescriptorType::Image {
ty: pso::ImageDescriptorType::Sampled {
with_sampler: false,
},
}
}
Bt::ReadonlyStorageTexture => {
pso::DescriptorType::Image {
ty: pso::ImageDescriptorType::Storage {
read_only: true,
},
}
}
Bt::WriteonlyStorageTexture => {
pso::DescriptorType::Image {
ty: pso::ImageDescriptorType::Storage {
read_only: false,
},
}
}
}
}
@ -262,7 +297,7 @@ pub fn map_depth_stencil_state_descriptor(
|| desc.depth_compare != CompareFunction::Always
{
Some(hal::pso::DepthTest {
fun: map_compare_function(desc.depth_compare),
fun: map_compare_function(desc.depth_compare).expect("DepthStencilStateDescriptor has undefined compare function"),
write: desc.depth_write_enabled,
})
} else {
@ -297,25 +332,26 @@ fn map_stencil_face(
stencil_state_face_desc: &StencilStateFaceDescriptor,
) -> hal::pso::StencilFace {
hal::pso::StencilFace {
fun: map_compare_function(stencil_state_face_desc.compare),
fun: map_compare_function(stencil_state_face_desc.compare).expect("StencilStateFaceDescriptor has undefined compare function"),
op_fail: map_stencil_operation(stencil_state_face_desc.fail_op),
op_depth_fail: map_stencil_operation(stencil_state_face_desc.depth_fail_op),
op_pass: map_stencil_operation(stencil_state_face_desc.pass_op),
}
}
pub fn map_compare_function(compare_function: CompareFunction) -> hal::pso::Comparison {
pub fn map_compare_function(compare_function: CompareFunction) -> Option<hal::pso::Comparison> {
use wgt::CompareFunction as Cf;
use hal::pso::Comparison as H;
match compare_function {
Cf::Never => H::Never,
Cf::Less => H::Less,
Cf::Equal => H::Equal,
Cf::LessEqual => H::LessEqual,
Cf::Greater => H::Greater,
Cf::NotEqual => H::NotEqual,
Cf::GreaterEqual => H::GreaterEqual,
Cf::Always => H::Always,
Cf::Undefined => None,
Cf::Never => Some(H::Never),
Cf::Less => Some(H::Less),
Cf::Equal => Some(H::Equal),
Cf::LessEqual => Some(H::LessEqual),
Cf::Greater => Some(H::Greater),
Cf::NotEqual => Some(H::NotEqual),
Cf::GreaterEqual => Some(H::GreaterEqual),
Cf::Always => Some(H::Always),
}
}
@ -450,7 +486,7 @@ fn checked_u32_as_u16(value: u32) -> u16 {
}
pub fn map_texture_dimension_size(
dimension: resource::TextureDimension,
dimension: wgt::TextureDimension,
Extent3d {
width,
height,
@ -459,7 +495,7 @@ pub fn map_texture_dimension_size(
array_size: u32,
sample_size: u32,
) -> hal::image::Kind {
use crate::resource::TextureDimension::*;
use wgt::TextureDimension::*;
use hal::image::Kind as H;
match dimension {
D1 => {
@ -624,15 +660,15 @@ pub fn map_color_u32(color: &Color) -> [u32; 4] {
]
}
pub fn map_filter(filter: resource::FilterMode) -> hal::image::Filter {
pub fn map_filter(filter: wgt::FilterMode) -> hal::image::Filter {
match filter {
resource::FilterMode::Nearest => hal::image::Filter::Nearest,
resource::FilterMode::Linear => hal::image::Filter::Linear,
wgt::FilterMode::Nearest => hal::image::Filter::Nearest,
wgt::FilterMode::Linear => hal::image::Filter::Linear,
}
}
pub fn map_wrap(address: resource::AddressMode) -> hal::image::WrapMode {
use crate::resource::AddressMode as Am;
pub fn map_wrap(address: wgt::AddressMode) -> hal::image::WrapMode {
use wgt::AddressMode as Am;
use hal::image::WrapMode as W;
match address {
Am::ClampToEdge => W::Clamp,
@ -644,23 +680,24 @@ pub fn map_wrap(address: resource::AddressMode) -> hal::image::WrapMode {
pub fn map_rasterization_state_descriptor(
desc: &RasterizationStateDescriptor,
) -> hal::pso::Rasterizer {
hal::pso::Rasterizer {
use hal::pso;
pso::Rasterizer {
depth_clamping: false,
polygon_mode: hal::pso::PolygonMode::Fill,
polygon_mode: pso::PolygonMode::Fill,
cull_face: match desc.cull_mode {
CullMode::None => hal::pso::Face::empty(),
CullMode::Front => hal::pso::Face::FRONT,
CullMode::Back => hal::pso::Face::BACK,
CullMode::None => pso::Face::empty(),
CullMode::Front => pso::Face::FRONT,
CullMode::Back => pso::Face::BACK,
},
front_face: match desc.front_face {
FrontFace::Ccw => hal::pso::FrontFace::CounterClockwise,
FrontFace::Cw => hal::pso::FrontFace::Clockwise,
FrontFace::Ccw => pso::FrontFace::CounterClockwise,
FrontFace::Cw => pso::FrontFace::Clockwise,
},
depth_bias: if desc.depth_bias != 0
|| desc.depth_bias_slope_scale != 0.0
|| desc.depth_bias_clamp != 0.0
{
Some(hal::pso::State::Static(hal::pso::DepthBias {
Some(pso::State::Static(pso::DepthBias {
const_factor: desc.depth_bias as f32,
slope_factor: desc.depth_bias_slope_scale,
clamp: desc.depth_bias_clamp,
@ -669,6 +706,7 @@ pub fn map_rasterization_state_descriptor(
None
},
conservative: false,
line_width: pso::State::Static(1.0),
}
}

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

@ -16,8 +16,8 @@ use crate::{
use copyless::VecHelper as _;
use hal::device::Device as _;
use parking_lot::Mutex;
use rendy_descriptor::{DescriptorAllocator, DescriptorSet};
use rendy_memory::{Heaps, MemoryBlock};
use gfx_descriptor::{DescriptorAllocator, DescriptorSet};
use gfx_memory::{Heaps, MemoryBlock};
use std::{
sync::atomic::Ordering,
@ -34,6 +34,8 @@ pub struct SuspectedResources {
pub(crate) texture_views: Vec<id::TextureViewId>,
pub(crate) samplers: Vec<id::SamplerId>,
pub(crate) bind_groups: Vec<id::BindGroupId>,
pub(crate) compute_pipelines: Vec<id::ComputePipelineId>,
pub(crate) render_pipelines: Vec<id::RenderPipelineId>,
}
impl SuspectedResources {
@ -43,6 +45,8 @@ impl SuspectedResources {
self.texture_views.clear();
self.samplers.clear();
self.bind_groups.clear();
self.compute_pipelines.clear();
self.render_pipelines.clear();
}
pub fn extend(&mut self, other: &Self) {
@ -51,6 +55,8 @@ impl SuspectedResources {
self.texture_views.extend_from_slice(&other.texture_views);
self.samplers.extend_from_slice(&other.samplers);
self.bind_groups.extend_from_slice(&other.bind_groups);
self.compute_pipelines.extend_from_slice(&other.compute_pipelines);
self.render_pipelines.extend_from_slice(&other.render_pipelines);
}
}
@ -65,6 +71,8 @@ struct NonReferencedResources<B: hal::Backend> {
samplers: Vec<B::Sampler>,
framebuffers: Vec<B::Framebuffer>,
desc_sets: Vec<DescriptorSet<B>>,
compute_pipes: Vec<B::ComputePipeline>,
graphics_pipes: Vec<B::GraphicsPipeline>,
}
impl<B: hal::Backend> NonReferencedResources<B> {
@ -76,6 +84,8 @@ impl<B: hal::Backend> NonReferencedResources<B> {
samplers: Vec::new(),
framebuffers: Vec::new(),
desc_sets: Vec::new(),
compute_pipes: Vec::new(),
graphics_pipes: Vec::new(),
}
}
@ -86,6 +96,8 @@ impl<B: hal::Backend> NonReferencedResources<B> {
self.samplers.extend(other.samplers);
self.framebuffers.extend(other.framebuffers);
self.desc_sets.extend(other.desc_sets);
self.compute_pipes.extend(other.compute_pipes);
self.graphics_pipes.extend(other.graphics_pipes);
}
unsafe fn clean(
@ -97,6 +109,7 @@ impl<B: hal::Backend> NonReferencedResources<B> {
if !self.buffers.is_empty() {
let mut heaps = heaps_mutex.lock();
for (raw, memory) in self.buffers.drain(..) {
log::trace!("Buffer {:?} is destroyed with memory {:?}", raw, memory);
device.destroy_buffer(raw);
heaps.free(device, memory);
}
@ -124,6 +137,13 @@ impl<B: hal::Backend> NonReferencedResources<B> {
.lock()
.free(self.desc_sets.drain(..));
}
for raw in self.compute_pipes.drain(..) {
device.destroy_compute_pipeline(raw);
}
for raw in self.graphics_pipes.drain(..) {
device.destroy_graphics_pipeline(raw);
}
}
}
@ -218,10 +238,14 @@ impl<B: hal::Backend> LifetimeTracker<B> {
}
/// Returns the last submission index that is done.
fn check_last_done(
pub fn triage_submissions(
&mut self,
device: &B::Device,
force_wait: bool,
) -> SubmissionIndex {
if force_wait {
self.wait_idle(device);
}
//TODO: enable when `is_sorted_by_key` is stable
//debug_assert!(self.active.is_sorted_by_key(|a| a.index));
let done_count = self
@ -250,22 +274,19 @@ impl<B: hal::Backend> LifetimeTracker<B> {
pub fn cleanup(
&mut self,
device: &B::Device,
force_wait: bool,
heaps_mutex: &Mutex<Heaps<B>>,
descriptor_allocator_mutex: &Mutex<DescriptorAllocator<B>>,
) -> SubmissionIndex {
if force_wait {
self.wait_idle(device);
}
let last_done = self.check_last_done(device);
) {
unsafe {
self.free_resources.clean(
device,
heaps_mutex,
descriptor_allocator_mutex,
);
descriptor_allocator_mutex
.lock()
.cleanup(device);
}
last_done
}
}
@ -376,6 +397,7 @@ impl<B: GfxBackend> LifetimeTracker<B> {
if trackers.buffers.remove_abandoned(id) {
hub.buffers.free_id(id);
let res = guard.remove(id).unwrap();
log::debug!("Buffer {:?} is detached", id);
let submit_index = res.life_guard.submission_index.load(Ordering::Acquire);
self.active
@ -386,6 +408,44 @@ impl<B: GfxBackend> LifetimeTracker<B> {
}
}
}
if !self.suspected_resources.compute_pipelines.is_empty() {
let mut trackers = trackers.lock();
let (mut guard, _) = hub.compute_pipelines.write(token);
for id in self.suspected_resources.compute_pipelines.drain(..) {
if trackers.compute_pipes.remove_abandoned(id) {
hub.compute_pipelines.free_id(id);
let res = guard.remove(id).unwrap();
let submit_index = res.life_guard.submission_index.load(Ordering::Acquire);
self.active
.iter_mut()
.find(|a| a.index == submit_index)
.map_or(&mut self.free_resources, |a| &mut a.last_resources)
.compute_pipes.push(res.raw);
}
}
}
if !self.suspected_resources.render_pipelines.is_empty() {
let mut trackers = trackers.lock();
let (mut guard, _) = hub.render_pipelines.write(token);
for id in self.suspected_resources.render_pipelines.drain(..) {
if trackers.render_pipes.remove_abandoned(id) {
hub.render_pipelines.free_id(id);
let res = guard.remove(id).unwrap();
let submit_index = res.life_guard.submission_index.load(Ordering::Acquire);
self.active
.iter_mut()
.find(|a| a.index == submit_index)
.map_or(&mut self.free_resources, |a| &mut a.last_resources)
.graphics_pipes.push(res.raw);
}
}
}
}
pub(crate) fn triage_mapped<G: GlobalIdentityHandlerFactory>(
@ -485,27 +545,41 @@ impl<B: GfxBackend> LifetimeTracker<B> {
&mut self,
global: &Global<G>,
raw: &B::Device,
trackers: &Mutex<TrackerSet>,
token: &mut Token<super::Device<B>>,
) -> Vec<super::BufferMapPendingCallback> {
if self.ready_to_map.is_empty() {
return Vec::new();
}
let hub = B::hub(global);
let (mut buffer_guard, _) = B::hub(global).buffers.write(token);
self.ready_to_map
.drain(..)
.map(|buffer_id| {
let buffer = &mut buffer_guard[buffer_id];
let mapping = buffer.pending_mapping.take().unwrap();
let mut pending_callbacks: Vec<super::BufferMapPendingCallback> = Vec::with_capacity(self.ready_to_map.len());
let mut trackers = trackers.lock();
for buffer_id in self.ready_to_map.drain(..) {
let buffer = &mut buffer_guard[buffer_id];
if buffer.life_guard.ref_count.is_none() && trackers.buffers.remove_abandoned(buffer_id) {
buffer.map_state = resource::BufferMapState::Idle;
log::debug!("Mapping request is dropped because the buffer is destroyed.");
hub.buffers.free_id(buffer_id);
let buffer = buffer_guard.remove(buffer_id).unwrap();
self.free_resources.buffers.push((buffer.raw, buffer.memory));
} else {
let mapping = match std::mem::replace(&mut buffer.map_state, resource::BufferMapState::Active) {
resource::BufferMapState::Waiting(pending_mapping) => pending_mapping,
_ => panic!("No pending mapping."),
};
log::debug!("Buffer {:?} map state -> Active", buffer_id);
let result = match mapping.op {
resource::BufferMapOperation::Read(..) => {
super::map_buffer(raw, buffer, mapping.range, super::HostMap::Read)
resource::BufferMapOperation::Read { .. } => {
super::map_buffer(raw, buffer, mapping.sub_range, super::HostMap::Read)
}
resource::BufferMapOperation::Write(..) => {
super::map_buffer(raw, buffer, mapping.range, super::HostMap::Write)
resource::BufferMapOperation::Write { .. } => {
super::map_buffer(raw, buffer, mapping.sub_range, super::HostMap::Write)
}
};
(mapping.op, result)
})
.collect()
pending_callbacks.push((mapping.op, result));
}
}
pending_callbacks
}
}

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

@ -18,9 +18,11 @@ use crate::{
Stored,
};
use wgt::{BufferAddress, InputStepMode, TextureFormat};
use wgt::{BufferAddress, InputStepMode, TextureDimension, TextureFormat, BIND_BUFFER_ALIGNMENT};
use arrayvec::ArrayVec;
use copyless::VecHelper as _;
use gfx_descriptor::DescriptorAllocator;
use gfx_memory::{Block, Heaps};
use hal::{
self,
command::CommandBuffer as _,
@ -29,8 +31,6 @@ use hal::{
window::{PresentationSurface as _, Surface as _},
};
use parking_lot::{Mutex, MutexGuard};
use rendy_descriptor::{DescriptorAllocator, DescriptorRanges};
use rendy_memory::{Block, Heaps};
use smallvec::SmallVec;
use std::{
@ -38,7 +38,6 @@ use std::{
ffi,
iter,
marker::PhantomData,
ops,
ptr,
slice,
sync::atomic::Ordering,
@ -50,9 +49,6 @@ pub const MAX_COLOR_TARGETS: usize = 4;
pub const MAX_MIP_LEVELS: usize = 16;
pub const MAX_VERTEX_BUFFERS: usize = 8;
/// Bound uniform/storage buffer offsets must be aligned to this number.
pub const BIND_BUFFER_ALIGNMENT: hal::buffer::Offset = 256;
pub fn all_buffer_stages() -> hal::pso::PipelineStage {
use hal::pso::PipelineStage as Ps;
Ps::DRAW_INDIRECT
@ -120,33 +116,41 @@ pub type BufferMapWriteCallback =
fn map_buffer<B: hal::Backend>(
raw: &B::Device,
buffer: &mut resource::Buffer<B>,
buffer_range: ops::Range<BufferAddress>,
sub_range: hal::buffer::SubRange,
kind: HostMap,
) -> BufferMapResult {
let is_coherent = buffer
.memory
.properties()
.contains(hal::memory::Properties::COHERENT);
let (ptr, mapped_range) = {
let mapped = buffer.memory.map(raw, buffer_range)?;
(mapped.ptr(), mapped.range())
let (ptr, sync_range) = {
let segment = hal::memory::Segment {
offset: sub_range.offset,
size: sub_range.size,
};
let mapped = buffer.memory.map(raw, segment)?;
let sync_range = if mapped.is_coherent() {
None
} else {
Some(mapped.range())
};
(mapped.ptr(), sync_range)
};
if !is_coherent {
if let Some(range) = sync_range {
let segment = hal::memory::Segment {
offset: range.start,
size: Some(range.end - range.start),
};
match kind {
HostMap::Read => unsafe {
raw.invalidate_mapped_memory_ranges(iter::once((
buffer.memory.memory(),
mapped_range,
segment,
)))
.unwrap();
},
HostMap::Write => {
buffer.mapped_write_ranges.push(mapped_range);
buffer.mapped_write_segments.push(segment);
}
}
}
Ok(ptr.as_ptr())
}
@ -154,21 +158,27 @@ fn unmap_buffer<B: hal::Backend>(
raw: &B::Device,
buffer: &mut resource::Buffer<B>,
) {
if !buffer.mapped_write_ranges.is_empty() {
match buffer.map_state {
resource::BufferMapState::Idle => {
log::error!("Buffer already unmapped");
return;
},
_ => buffer.map_state = resource::BufferMapState::Idle,
}
if !buffer.mapped_write_segments.is_empty() {
unsafe {
raw
.flush_mapped_memory_ranges(
buffer
.mapped_write_ranges
.mapped_write_segments
.iter()
.map(|r| (buffer.memory.memory(), r.clone())),
)
.unwrap()
};
buffer.mapped_write_ranges.clear();
buffer.mapped_write_segments.clear();
}
buffer.memory.unmap(raw);
}
//Note: this logic is specifically moved out of `handle_mapping()` in order to
@ -183,11 +193,11 @@ fn fire_map_callbacks<I: IntoIterator<Item = BufferMapPendingCallback>>(callback
}
};
match operation {
resource::BufferMapOperation::Read(on_read) => {
on_read(status, ptr)
resource::BufferMapOperation::Read { callback, userdata } => unsafe {
callback(status, ptr, userdata)
}
resource::BufferMapOperation::Write(on_write) => {
on_write(status, ptr)
resource::BufferMapOperation::Write { callback, userdata } => unsafe {
callback(status, ptr, userdata)
}
}
}
@ -218,6 +228,7 @@ impl<B: GfxBackend> Device<B> {
adapter_id: id::AdapterId,
queue_group: hal::queue::QueueGroup<B>,
mem_props: hal::adapter::MemoryProperties,
non_coherent_atom_size: u64,
supports_texture_d24_s8: bool,
max_bind_groups: u32,
) -> Self {
@ -225,26 +236,19 @@ impl<B: GfxBackend> Device<B> {
let life_guard = LifeGuard::new();
life_guard.submission_index.fetch_add(1, Ordering::Relaxed);
let heaps = {
let types = mem_props.memory_types.iter().map(|mt| {
use rendy_memory::{DynamicConfig, HeapsConfig, LinearConfig};
let config = HeapsConfig {
linear: if mt.properties.contains(hal::memory::Properties::CPU_VISIBLE) {
Some(LinearConfig {
linear_size: 0x10_00_00,
})
} else {
None
},
dynamic: Some(DynamicConfig {
block_size_granularity: 0x1_00,
max_chunk_size: 0x1_00_00_00,
min_device_allocation: 0x1_00_00,
}),
};
(mt.properties, mt.heap_index as u32, config)
});
unsafe { Heaps::new(types, mem_props.memory_heaps.iter().cloned()) }
let heaps = unsafe {
Heaps::new(
&mem_props,
gfx_memory::GeneralConfig {
block_size_granularity: 0x100,
max_chunk_size: 0x100_0000,
min_device_allocation: 0x1_0000,
},
gfx_memory::LinearConfig {
linear_size: 0x10_0000,
},
non_coherent_atom_size,
)
};
Device {
@ -284,18 +288,13 @@ impl<B: GfxBackend> Device<B> {
life_tracker.triage_suspected(global, &self.trackers, token);
life_tracker.triage_mapped(global, token);
life_tracker.triage_framebuffers(global, &mut *self.framebuffers.lock(), token);
let _last_done = life_tracker.triage_submissions(&self.raw, force_wait);
let callbacks = life_tracker.handle_mapping(global, &self.raw, &self.trackers, token);
life_tracker.cleanup(
&self.raw,
force_wait,
&self.mem_allocator,
&self.desc_allocator,
);
let callbacks = life_tracker.handle_mapping(global, &self.raw, token);
unsafe {
self.desc_allocator.lock().cleanup(&self.raw);
}
callbacks
}
@ -304,25 +303,31 @@ impl<B: GfxBackend> Device<B> {
self_id: id::DeviceId,
desc: &wgt::BufferDescriptor,
) -> resource::Buffer<B> {
use gfx_memory::{Kind, MemoryUsage};
debug_assert_eq!(self_id.backend(), B::VARIANT);
let (usage, _memory_properties) = conv::map_buffer_usage(desc.usage);
let rendy_usage = {
use rendy_memory::MemoryUsageValue as Muv;
let (kind, mem_usage) = {
use wgt::BufferUsage as Bu;
if !desc.usage.intersects(Bu::MAP_READ | Bu::MAP_WRITE) {
Muv::Data
(Kind::General, MemoryUsage::Private)
} else if (Bu::MAP_WRITE | Bu::COPY_SRC).contains(desc.usage) {
Muv::Upload
(Kind::Linear, MemoryUsage::Staging { read_back: false })
} else if (Bu::MAP_READ | Bu::COPY_DST).contains(desc.usage) {
Muv::Download
(Kind::Linear, MemoryUsage::Staging { read_back: true })
} else {
Muv::Dynamic
(Kind::General, MemoryUsage::Dynamic { sparse_updates: false })
}
};
let mut buffer = unsafe { self.raw.create_buffer(desc.size, usage).unwrap() };
if !desc.label.is_null() {
unsafe {
let label = ffi::CStr::from_ptr(desc.label).to_string_lossy();
self.raw.set_buffer_name(&mut buffer, &label)
};
}
let requirements = unsafe { self.raw.get_buffer_requirements(&buffer) };
let memory = self
.mem_allocator
@ -330,7 +335,8 @@ impl<B: GfxBackend> Device<B> {
.allocate(
&self.raw,
requirements.type_mask as u32,
rendy_usage,
mem_usage,
kind,
requirements.size,
requirements.alignment,
)
@ -338,7 +344,11 @@ impl<B: GfxBackend> Device<B> {
unsafe {
self.raw
.bind_buffer_memory(memory.memory(), memory.range().start, &mut buffer)
.bind_buffer_memory(
memory.memory(),
memory.segment().offset,
&mut buffer,
)
.unwrap()
};
@ -352,8 +362,8 @@ impl<B: GfxBackend> Device<B> {
memory,
size: desc.size,
full_range: (),
mapped_write_ranges: Vec::new(),
pending_mapping: None,
mapped_write_segments: Vec::new(),
map_state: resource::BufferMapState::Idle,
life_guard: LifeGuard::new(),
}
}
@ -361,7 +371,7 @@ impl<B: GfxBackend> Device<B> {
fn create_texture(
&self,
self_id: id::DeviceId,
desc: &resource::TextureDescriptor,
desc: &wgt::TextureDescriptor,
) -> resource::Texture<B> {
debug_assert_eq!(self_id.backend(), B::VARIANT);
@ -390,23 +400,27 @@ impl<B: GfxBackend> Device<B> {
// 2D textures with array layer counts that are multiples of 6 could be cubemaps
// Following gpuweb/gpuweb#68 always add the hint in that case
if desc.dimension == resource::TextureDimension::D2 && desc.array_layer_count % 6 == 0 {
if desc.dimension == TextureDimension::D2 && desc.array_layer_count % 6 == 0 {
view_capabilities |= hal::image::ViewCapabilities::KIND_CUBE;
};
// TODO: 2D arrays, cubemap arrays
let mut image = unsafe {
self.raw.create_image(
let mut image = self.raw.create_image(
kind,
desc.mip_level_count as hal::image::Level,
format,
hal::image::Tiling::Optimal,
usage,
view_capabilities,
)
}
.unwrap();
).unwrap();
if !desc.label.is_null() {
let label = ffi::CStr::from_ptr(desc.label).to_string_lossy();
self.raw.set_image_name(&mut image, &label);
}
image
};
let requirements = unsafe { self.raw.get_image_requirements(&image) };
let memory = self
@ -415,7 +429,8 @@ impl<B: GfxBackend> Device<B> {
.allocate(
&self.raw,
requirements.type_mask as u32,
rendy_memory::Data,
gfx_memory::MemoryUsage::Private,
gfx_memory::Kind::General,
requirements.size,
requirements.alignment,
)
@ -423,7 +438,11 @@ impl<B: GfxBackend> Device<B> {
unsafe {
self.raw
.bind_image_memory(memory.memory(), memory.range().start, &mut image)
.bind_image_memory(
memory.memory(),
memory.segment().offset,
&mut image,
)
.unwrap()
};
@ -469,18 +488,18 @@ impl<B: hal::Backend> Device<B> {
}
pub(crate) fn dispose(self) {
self.life_tracker.lock().triage_submissions(&self.raw, true);
self.life_tracker.lock().cleanup(
&self.raw,
true,
&self.mem_allocator,
&self.desc_allocator,
);
self.com_allocator.destroy(&self.raw);
let desc_alloc = self.desc_allocator.into_inner();
let mem_alloc = self.mem_allocator.into_inner();
let mut desc_alloc = self.desc_allocator.into_inner();
let mut mem_alloc = self.mem_allocator.into_inner();
unsafe {
desc_alloc.dispose(&self.raw);
mem_alloc.dispose(&self.raw);
desc_alloc.clear(&self.raw);
mem_alloc.clear(&self.raw);
for (_, rp) in self.render_passes.lock().drain() {
self.raw.destroy_render_pass(rp);
}
@ -510,6 +529,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
let ref_count = buffer.life_guard.add_ref();
let id = hub.buffers.register_identity(id_in, buffer, &mut token);
log::info!("Created buffer {:?} with {:?}", id, desc);
device
.trackers
.lock()
@ -539,8 +559,16 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
let mut buffer = device.create_buffer(device_id, &desc);
let ref_count = buffer.life_guard.add_ref();
let pointer = match map_buffer(&device.raw, &mut buffer, 0 .. desc.size, HostMap::Write) {
Ok(ptr) => ptr,
let pointer = match map_buffer(
&device.raw,
&mut buffer,
hal::buffer::SubRange::WHOLE,
HostMap::Write,
) {
Ok(ptr) => {
buffer.map_state = resource::BufferMapState::Active;
ptr
},
Err(e) => {
log::error!("failed to create buffer in a mapped state: {:?}", e);
ptr::null_mut()
@ -548,6 +576,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
};
let id = hub.buffers.register_identity(id_in, buffer, &mut token);
log::info!("Created mapped buffer {:?} with {:?}", id, desc);
device.trackers
.lock()
.buffers.init(
@ -580,7 +609,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
match map_buffer(
&device.raw,
&mut buffer,
offset .. offset + data.len() as BufferAddress,
hal::buffer::SubRange { offset, size: Some(data.len() as BufferAddress) },
HostMap::Write,
) {
Ok(ptr) => unsafe {
@ -615,7 +644,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
match map_buffer(
&device.raw,
&mut buffer,
offset .. offset + data.len() as BufferAddress,
hal::buffer::SubRange { offset, size: Some(data.len() as BufferAddress) },
HostMap::Read,
) {
Ok(ptr) => unsafe {
@ -634,6 +663,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
let hub = B::hub(self);
let mut token = Token::root();
log::info!("Buffer {:?} is dropped", buffer_id);
let device_id = {
let (mut buffer_guard, _) = hub.buffers.write(&mut token);
let buffer = &mut buffer_guard[buffer_id];
@ -650,7 +680,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
pub fn device_create_texture<B: GfxBackend>(
&self,
device_id: id::DeviceId,
desc: &resource::TextureDescriptor,
desc: &wgt::TextureDescriptor,
id_in: Input<G, id::TextureId>,
) -> id::TextureId {
let hub = B::hub(self);
@ -694,7 +724,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
pub fn texture_create_view<B: GfxBackend>(
&self,
texture_id: id::TextureId,
desc: Option<&resource::TextureViewDescriptor>,
desc: Option<&wgt::TextureViewDescriptor>,
id_in: Input<G, id::TextureViewId>,
) -> id::TextureViewId {
let hub = B::hub(self);
@ -803,7 +833,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
pub fn device_create_sampler<B: GfxBackend>(
&self,
device_id: id::DeviceId,
desc: &resource::SamplerDescriptor,
desc: &wgt::SamplerDescriptor,
id_in: Input<G, id::SamplerId>,
) -> id::SamplerId {
let hub = B::hub(self);
@ -822,10 +852,10 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
),
lod_bias: hal::image::Lod(0.0),
lod_range: hal::image::Lod(desc.lod_min_clamp) .. hal::image::Lod(desc.lod_max_clamp),
comparison: desc.compare.cloned().map(conv::map_compare_function),
comparison: conv::map_compare_function(desc.compare),
border: hal::image::PackedColor(0),
normalized: true,
anisotropic: hal::image::Anisotropic::Off, //TODO
anisotropy_clamp: None, //TODO
};
let sampler = resource::Sampler {
@ -906,10 +936,15 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
let (device_guard, mut token) = hub.devices.read(&mut token);
let device = &device_guard[device_id];
let raw = unsafe {
device
let mut raw_layout = device
.raw
.create_descriptor_set_layout(&raw_bindings, &[])
.unwrap()
.unwrap();
if !desc.label.is_null() {
let label = ffi::CStr::from_ptr(desc.label).to_string_lossy();
device.raw.set_descriptor_set_layout_name(&mut raw_layout, &label);
}
raw_layout
};
let layout = binding_model::BindGroupLayout {
@ -919,7 +954,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
ref_count: device.life_guard.add_ref(),
},
entries: entry_map,
desc_ranges: DescriptorRanges::from_bindings(&raw_bindings),
desc_counts: raw_bindings.iter().cloned().collect(),
dynamic_count: entries.iter().filter(|b| b.has_dynamic_offset).count(),
};
@ -1005,7 +1040,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
let (bind_group_layout_guard, mut token) = hub.bind_group_layouts.read(&mut token);
let bind_group_layout = &bind_group_layout_guard[desc.layout];
let entries =
unsafe { slice::from_raw_parts(desc.entries, desc.entries_length as usize) };
unsafe { slice::from_raw_parts(desc.entries, desc.entries_length) };
assert_eq!(entries.len(), bind_group_layout.entries.len());
let desc_set = unsafe {
@ -1016,7 +1051,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
.allocate(
&device.raw,
&bind_group_layout.raw,
bind_group_layout.desc_ranges,
&bind_group_layout.desc_counts,
1,
&mut desc_sets,
)
@ -1024,6 +1059,14 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
desc_sets.pop().unwrap()
};
if !desc.label.is_null() {
//TODO: https://github.com/gfx-rs/gfx-extras/pull/5
//unsafe {
// let label = ffi::CStr::from_ptr(desc.label).to_string_lossy();
// device.raw.set_descriptor_set_name(desc_set.raw_mut(), &label);
//}
}
// fill out the descriptors
let mut used = TrackerSet::new(B::VARIANT);
{
@ -1058,7 +1101,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
}
};
assert_eq!(
bb.offset as hal::buffer::Offset % alignment,
bb.offset % alignment,
0,
"Misaligned buffer offset {}",
bb.offset
@ -1073,21 +1116,20 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
usage
);
let end = if bb.size == 0 {
None
} else {
let end = bb.offset + bb.size;
assert!(
end <= buffer.size,
"Bound buffer range {:?} does not fit in buffer size {}",
bb.offset .. end,
buffer.size
);
Some(end)
let sub_range = hal::buffer::SubRange {
offset: bb.offset,
size: if bb.size == 0 { None } else {
let end = bb.offset + bb.size;
assert!(
end <= buffer.size,
"Bound buffer range {:?} does not fit in buffer size {}",
bb.offset .. end,
buffer.size
);
Some(bb.size)
},
};
let range = Some(bb.offset) .. end;
hal::pso::Descriptor::Buffer(&buffer.raw, range)
hal::pso::Descriptor::Buffer(&buffer.raw, sub_range)
}
binding_model::BindingResource::Sampler(id) => {
match decl.ty {
@ -1245,7 +1287,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
pub fn device_create_command_encoder<B: GfxBackend>(
&self,
device_id: id::DeviceId,
_desc: &wgt::CommandEncoderDescriptor,
desc: &wgt::CommandEncoderDescriptor,
id_in: Input<G, id::CommandEncoderId>,
) -> id::CommandEncoderId {
let hub = B::hub(self);
@ -1263,17 +1305,22 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
.lock_life(&mut token)
.lowest_active_submission();
let mut comb = device
let mut command_buffer = device
.com_allocator
.allocate(dev_stored, &device.raw, device.features, lowest_active_index);
unsafe {
comb.raw.last_mut().unwrap().begin_primary(
let raw_command_buffer = command_buffer.raw.last_mut().unwrap();
if !desc.label.is_null() {
let label = ffi::CStr::from_ptr(desc.label).to_string_lossy();
device.raw.set_command_buffer_name(raw_command_buffer, &label);
}
raw_command_buffer.begin_primary(
hal::command::CommandBufferFlags::ONE_TIME_SUBMIT,
);
}
hub.command_buffers
.register_identity(id_in, comb, &mut token)
.register_identity(id_in, command_buffer, &mut token)
}
pub fn command_encoder_destroy<B: GfxBackend>(
@ -1294,6 +1341,8 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
// that it references for destruction in the next GC pass.
{
let (bind_group_guard, mut token) = hub.bind_groups.read(&mut token);
let (compute_pipe_guard, mut token) = hub.compute_pipelines.read(&mut token);
let (render_pipe_guard, mut token) = hub.render_pipelines.read(&mut token);
let (buffer_guard, mut token) = hub.buffers.read(&mut token);
let (texture_guard, mut token) = hub.textures.read(&mut token);
let (texture_view_guard, mut token) = hub.texture_views.read(&mut token);
@ -1324,6 +1373,16 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
device.temp_suspected.samplers.push(id);
}
}
for id in comb.trackers.compute_pipes.used() {
if compute_pipe_guard[id].life_guard.ref_count.is_none() {
device.temp_suspected.compute_pipelines.push(id);
}
}
for id in comb.trackers.render_pipes.used() {
if render_pipe_guard[id].life_guard.ref_count.is_none() {
device.temp_suspected.render_pipelines.push(id);
}
}
}
device
@ -1359,7 +1418,9 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
let (mut swap_chain_guard, mut token) = hub.swap_chains.write(&mut token);
let (mut command_buffer_guard, mut token) = hub.command_buffers.write(&mut token);
let (bind_group_guard, mut token) = hub.bind_groups.read(&mut token);
let (buffer_guard, mut token) = hub.buffers.read(&mut token);
let (compute_pipe_guard, mut token) = hub.compute_pipelines.read(&mut token);
let (render_pipe_guard, mut token) = hub.render_pipelines.read(&mut token);
let (mut buffer_guard, mut token) = hub.buffers.write(&mut token);
let (texture_guard, mut token) = hub.textures.read(&mut token);
let (texture_view_guard, mut token) = hub.texture_views.read(&mut token);
let (sampler_guard, _) = hub.samplers.read(&mut token);
@ -1392,8 +1453,13 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
// update submission IDs
for id in comb.trackers.buffers.used() {
assert!(buffer_guard[id].pending_mapping.is_none());
if let resource::BufferMapState::Waiting(_) = buffer_guard[id].map_state {
panic!("Buffer has a pending mapping.");
}
if !buffer_guard[id].life_guard.use_at(submit_index) {
if let resource::BufferMapState::Active = buffer_guard[id].map_state {
unmap_buffer(&device.raw, &mut buffer_guard[id]);
}
device.temp_suspected.buffers.push(id);
}
}
@ -1417,6 +1483,16 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
device.temp_suspected.samplers.push(id);
}
}
for id in comb.trackers.compute_pipes.used() {
if !compute_pipe_guard[id].life_guard.use_at(submit_index) {
device.temp_suspected.compute_pipelines.push(id);
}
}
for id in comb.trackers.render_pipes.used() {
if !render_pipe_guard[id].life_guard.use_at(submit_index) {
device.temp_suspected.render_pipelines.push(id);
}
}
// execute resource transitions
let mut transit = device.com_allocator.extend(comb);
@ -1747,6 +1823,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
index_format: desc.vertex_state.index_format,
vertex_strides,
sample_count: sc,
life_guard: LifeGuard::new(),
};
hub.render_pipelines
@ -1756,9 +1833,18 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
pub fn render_pipeline_destroy<B: GfxBackend>(&self, render_pipeline_id: id::RenderPipelineId) {
let hub = B::hub(self);
let mut token = Token::root();
let (_, mut token) = hub.devices.read(&mut token);
//TODO: track usage by GPU
hub.render_pipelines.unregister(render_pipeline_id, &mut token);
let (device_guard, mut token) = hub.devices.read(&mut token);
let device_id = {
let (mut pipeline_guard, _) = hub.render_pipelines.write(&mut token);
let pipeline = &mut pipeline_guard[render_pipeline_id];
pipeline.life_guard.ref_count.take();
pipeline.device_id.value
};
device_guard[device_id]
.lock_life(&mut token)
.suspected_resources.render_pipelines.push(render_pipeline_id);
}
pub fn device_create_compute_pipeline<B: GfxBackend>(
@ -1814,6 +1900,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
value: device_id,
ref_count: device.life_guard.add_ref(),
},
life_guard: LifeGuard::new(),
};
hub.compute_pipelines
.register_identity(id_in, pipeline, &mut token)
@ -1822,9 +1909,19 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
pub fn compute_pipeline_destroy<B: GfxBackend>(&self, compute_pipeline_id: id::ComputePipelineId) {
let hub = B::hub(self);
let mut token = Token::root();
let (_, mut token) = hub.devices.read(&mut token);
//TODO: track usage by GPU
hub.compute_pipelines.unregister(compute_pipeline_id, &mut token);
let (device_guard, mut token) = hub.devices.read(&mut token);
let device_id = {
let (mut pipeline_guard, _) = hub.compute_pipelines.write(&mut token);
let pipeline = &mut pipeline_guard[compute_pipeline_id];
pipeline.life_guard.ref_count.take();
pipeline.device_id.value
};
device_guard[device_id]
.lock_life(&mut token)
.suspected_resources.compute_pipelines.push(compute_pipeline_id);
}
pub fn device_create_swap_chain<B: GfxBackend>(
@ -1997,16 +2094,23 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
assert!(buffer.usage.contains(wgt::BufferUsage::MAP_WRITE));
}
if buffer.pending_mapping.is_some() {
operation.call_error();
return;
}
buffer.map_state = match buffer.map_state {
resource::BufferMapState::Active => panic!("Buffer already mapped"),
resource::BufferMapState::Waiting(_) => {
operation.call_error();
return;
}
resource::BufferMapState::Idle => resource::BufferMapState::Waiting(resource::BufferPendingMapping {
sub_range: hal::buffer::SubRange {
offset: range.start,
size: Some(range.end - range.start),
},
op: operation,
parent_ref_count: buffer.life_guard.add_ref(),
}),
};
log::debug!("Buffer {:?} map state -> Waiting", buffer_id);
buffer.pending_mapping = Some(resource::BufferPendingMapping {
range,
op: operation,
parent_ref_count: buffer.life_guard.add_ref(),
});
(buffer.device_id.value, buffer.life_guard.add_ref())
};
@ -2031,6 +2135,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
let (mut buffer_guard, _) = hub.buffers.write(&mut token);
let buffer = &mut buffer_guard[buffer_id];
log::debug!("Buffer {:?} map state -> Idle", buffer_id);
unmap_buffer(
&device_guard[buffer.device_id.value].raw,
buffer,

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

@ -39,7 +39,7 @@ use vec_map::VecMap;
#[cfg(debug_assertions)]
use std::cell::Cell;
use std::{fmt::Debug, marker::PhantomData, ops};
use std::{fmt::Debug, iter, marker::PhantomData, ops};
/// A simple structure to manage identities of objects.
@ -184,6 +184,7 @@ impl<B: hal::Backend> Access<ComputePipeline<B>> for Device<B> {}
impl<B: hal::Backend> Access<ComputePipeline<B>> for BindGroup<B> {}
impl<B: hal::Backend> Access<RenderPipeline<B>> for Device<B> {}
impl<B: hal::Backend> Access<RenderPipeline<B>> for BindGroup<B> {}
impl<B: hal::Backend> Access<RenderPipeline<B>> for ComputePipeline<B> {}
impl<B: hal::Backend> Access<ShaderModule<B>> for Device<B> {}
impl<B: hal::Backend> Access<ShaderModule<B>> for PipelineLayout<B> {}
impl<B: hal::Backend> Access<Buffer<B>> for Root {}
@ -270,7 +271,7 @@ impl<I: TypedId + Debug> IdentityHandler<I> for Mutex<IdentityManager> {
pub trait IdentityHandlerFactory<I> {
type Filter: IdentityHandler<I>;
fn spawn(&self) -> Self::Filter;
fn spawn(&self, min_index: Index) -> Self::Filter;
}
#[derive(Debug)]
@ -278,8 +279,11 @@ pub struct IdentityManagerFactory;
impl<I: TypedId + Debug> IdentityHandlerFactory<I> for IdentityManagerFactory {
type Filter = Mutex<IdentityManager>;
fn spawn(&self) -> Self::Filter {
Mutex::new(IdentityManager::default())
fn spawn(&self, min_index: Index) -> Self::Filter {
let mut man = IdentityManager::default();
man.free.extend(0 .. min_index);
man.epochs.extend(iter::repeat(1).take(min_index as usize));
Mutex::new(man)
}
}
@ -316,7 +320,7 @@ pub struct Registry<T, I: TypedId, F: IdentityHandlerFactory<I>> {
impl<T, I: TypedId, F: IdentityHandlerFactory<I>> Registry<T, I, F> {
fn new(backend: Backend, factory: &F) -> Self {
Registry {
identity: factory.spawn(),
identity: factory.spawn(0),
data: RwLock::new(Storage {
map: VecMap::new(),
_phantom: PhantomData,
@ -324,6 +328,17 @@ impl<T, I: TypedId, F: IdentityHandlerFactory<I>> Registry<T, I, F> {
backend,
}
}
fn without_backend(factory: &F) -> Self {
Registry {
identity: factory.spawn(1),
data: RwLock::new(Storage {
map: VecMap::new(),
_phantom: PhantomData,
}),
backend: Backend::Empty,
}
}
}
impl<T, I: TypedId + Copy, F: IdentityHandlerFactory<I>> Registry<T, I, F> {
@ -544,7 +559,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
pub fn new(name: &str, factory: G) -> Self {
Global {
instance: Instance::new(name, 1),
surfaces: Registry::new(Backend::Empty, &factory),
surfaces: Registry::without_backend(&factory),
hubs: Hubs::new(&factory),
}
}

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

@ -6,7 +6,7 @@ use crate::{Epoch, Index};
#[cfg(feature = "serde")]
use serde_crate::{Deserialize, Serialize};
use wgt::Backend;
use std::{fmt, marker::PhantomData, mem};
use std::{fmt, marker::PhantomData, mem, num::NonZeroU64};
const BACKEND_BITS: usize = 3;
const EPOCH_MASK: u32 = (1 << (32 - BACKEND_BITS)) - 1;
@ -14,13 +14,18 @@ type Dummy = crate::backend::Empty;
#[repr(transparent)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(crate="serde_crate"))]
pub struct Id<T>(u64, PhantomData<T>);
pub struct Id<T>(NonZeroU64, PhantomData<T>);
// required for PeekPoke
impl<T> Default for Id<T> {
fn default() -> Self {
Id(unsafe { NonZeroU64::new_unchecked(!0) }, PhantomData)
}
}
impl<T> Id<T> {
pub const ERROR: Self = Self(0, PhantomData);
pub fn backend(self) -> Backend {
match self.0 >> (64 - BACKEND_BITS) as u8 {
match self.0.get() >> (64 - BACKEND_BITS) as u8 {
0 => Backend::Empty,
1 => Backend::Vulkan,
2 => Backend::Metal,
@ -30,6 +35,14 @@ impl<T> Id<T> {
_ => unreachable!(),
}
}
pub(crate) fn into_raw(self) -> u64 {
self.0.get()
}
pub(crate) fn from_raw(value: u64) -> Option<Self> {
NonZeroU64::new(value).map(|nz| Id(nz, PhantomData))
}
}
impl<T> Copy for Id<T> {}
@ -58,18 +71,23 @@ impl<T> PartialEq for Id<T> {
}
}
impl<T> Eq for Id<T> {}
unsafe impl<T> peek_poke::Poke for Id<T> {
fn max_size() -> usize {
mem::size_of::<u64>()
}
unsafe fn poke_into(&self, data: *mut u8) -> *mut u8 {
self.0.poke_into(data)
self.0.get().poke_into(data)
}
}
impl<T> peek_poke::Peek for Id<T> {
unsafe fn peek_from(&mut self, data: *const u8) -> *const u8 {
self.0.peek_from(data)
unsafe fn peek_from(mut data: *const u8, this: *mut Self) -> *const u8 {
let mut v = 0u64;
data = u64::peek_from(data, &mut v);
(*this).0 = NonZeroU64::new(v).unwrap();
data
}
}
@ -82,13 +100,13 @@ impl<T> TypedId for Id<T> {
fn zip(index: Index, epoch: Epoch, backend: Backend) -> Self {
assert_eq!(0, epoch >> (32 - BACKEND_BITS));
let v = index as u64 | ((epoch as u64) << 32) | ((backend as u64) << (64 - BACKEND_BITS));
Id(v, PhantomData)
Id(NonZeroU64::new(v).unwrap(), PhantomData)
}
fn unzip(self) -> (Index, Epoch, Backend) {
(
self.0 as u32,
(self.0 >> 32) as u32 & EPOCH_MASK,
self.0.get() as u32,
(self.0.get() >> 32) as u32 & EPOCH_MASK,
self.backend(),
)
}
@ -145,7 +163,7 @@ fn test_id_backend() {
Backend::Dx11,
Backend::Gl,
] {
let id: Id<()> = Id::zip(0, 0, b);
let id: Id<()> = Id::zip(1, 0, b);
assert_eq!(id.backend(), b);
}
}

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

@ -4,25 +4,47 @@
use crate::{
backend,
device::{Device, BIND_BUFFER_ALIGNMENT},
device::Device,
hub::{GfxBackend, Global, GlobalIdentityHandlerFactory, Input, Token},
id::{AdapterId, DeviceId},
id::{AdapterId, DeviceId, SurfaceId},
power,
};
use wgt::{Backend, BackendBit, DeviceDescriptor, PowerPreference, RequestAdapterOptions};
use wgt::{Backend, BackendBit, DeviceDescriptor, PowerPreference, BIND_BUFFER_ALIGNMENT};
#[cfg(feature = "serde")]
use serde_crate::{Deserialize, Serialize};
use hal::{
self,
adapter::{AdapterInfo as HalAdapterInfo, DeviceType as HalDeviceType, PhysicalDevice as _},
adapter::{
AdapterInfo as HalAdapterInfo,
DeviceType as HalDeviceType,
PhysicalDevice as _,
},
queue::QueueFamily as _,
window::Surface as _,
Instance as _,
};
#[repr(C)]
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(crate="serde_crate"))]
pub struct RequestAdapterOptions {
pub power_preference: PowerPreference,
pub compatible_surface: Option<SurfaceId>,
}
impl Default for RequestAdapterOptions {
fn default() -> Self {
RequestAdapterOptions {
power_preference: PowerPreference::Default,
compatible_surface: None,
}
}
}
#[derive(Debug)]
pub struct Instance {
#[cfg(any(
@ -261,6 +283,9 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
inputs: AdapterInputs<Input<G, AdapterId>>,
) -> Option<AdapterId> {
let instance = &self.instance;
let mut token = Token::root();
let (surface_guard, mut token) = self.surfaces.read(&mut token);
let compatible_surface = desc.compatible_surface.map(|id| &surface_guard[id]);
let mut device_types = Vec::new();
let id_vulkan = inputs.find(Backend::Vulkan);
@ -274,7 +299,15 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
))]
let mut adapters_vk = match instance.vulkan {
Some(ref inst) if id_vulkan.is_some() => {
let adapters = inst.enumerate_adapters();
let mut adapters = inst.enumerate_adapters();
if let Some(&Surface { vulkan: Some(ref surface), .. }) = compatible_surface {
adapters.retain(|a|
a.queue_families
.iter()
.find(|qf| qf.queue_type().supports_graphics())
.map_or(false, |qf| surface.supports_queue_family(qf))
);
}
device_types.extend(adapters.iter().map(|ad| ad.info.device_type.clone()));
adapters
}
@ -282,7 +315,15 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
};
#[cfg(any(target_os = "ios", target_os = "macos"))]
let mut adapters_mtl = if id_metal.is_some() {
let adapters = instance.metal.enumerate_adapters();
let mut adapters = instance.metal.enumerate_adapters();
if let Some(surface) = compatible_surface {
adapters.retain(|a|
a.queue_families
.iter()
.find(|qf| qf.queue_type().supports_graphics())
.map_or(false, |qf| surface.metal.supports_queue_family(qf))
);
}
device_types.extend(adapters.iter().map(|ad| ad.info.device_type.clone()));
adapters
} else {
@ -291,7 +332,15 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
#[cfg(windows)]
let mut adapters_dx12 = match instance.dx12 {
Some(ref inst) if id_dx12.is_some() => {
let adapters = inst.enumerate_adapters();
let mut adapters = inst.enumerate_adapters();
if let Some(&Surface { dx12: Some(ref surface), .. }) = compatible_surface {
adapters.retain(|a|
a.queue_families
.iter()
.find(|qf| qf.queue_type().supports_graphics())
.map_or(false, |qf| surface.supports_queue_family(qf))
);
}
device_types.extend(adapters.iter().map(|ad| ad.info.device_type.clone()));
adapters
}
@ -299,7 +348,15 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
};
#[cfg(windows)]
let mut adapters_dx11 = if id_dx11.is_some() {
let adapters = instance.dx11.enumerate_adapters();
let mut adapters = instance.dx11.enumerate_adapters();
if let Some(surface) = compatible_surface {
adapters.retain(|a|
a.queue_families
.iter()
.find(|qf| qf.queue_type().supports_graphics())
.map_or(false, |qf| surface.dx11.supports_queue_family(qf))
);
}
device_types.extend(adapters.iter().map(|ad| ad.info.device_type.clone()));
adapters
} else {
@ -345,7 +402,6 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
PowerPreference::HighPerformance => discrete.or(other).or(integrated).or(virt),
};
let mut token = Token::root();
let mut selected = preferred_gpu.unwrap_or(0);
#[cfg(any(
not(any(target_os = "ios", target_os = "macos")),
@ -446,7 +502,12 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
let adapter = &adapter_guard[adapter_id].raw;
let wishful_features =
hal::Features::VERTEX_STORES_AND_ATOMICS |
hal::Features::FRAGMENT_STORES_AND_ATOMICS;
hal::Features::FRAGMENT_STORES_AND_ATOMICS |
hal::Features::NDC_Y_UP;
let enabled_features = adapter.physical_device.features() & wishful_features;
if enabled_features != wishful_features {
log::warn!("Missing features: {:?}", wishful_features - enabled_features);
}
let family = adapter
.queue_families
@ -456,10 +517,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
let mut gpu = unsafe {
adapter
.physical_device
.open(
&[(family, &[1.0])],
adapter.physical_device.features() & wishful_features,
)
.open(&[(family, &[1.0])], enabled_features)
.unwrap()
};
@ -496,6 +554,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
adapter_id,
gpu.queue_groups.swap_remove(0),
mem_props,
limits.non_coherent_atom_size as u64,
supports_texture_d24_s8,
desc.limits.max_bind_groups,
)

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

@ -2,6 +2,13 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#![warn(
trivial_casts,
trivial_numeric_casts,
unused_extern_crates,
unused_qualifications
)]
pub mod backend {
#[cfg(windows)]
pub use gfx_backend_dx11::Backend as Dx11;
@ -108,36 +115,6 @@ struct Stored<T> {
ref_count: RefCount,
}
#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct Origin3d {
pub x: u32,
pub y: u32,
pub z: u32,
}
impl Origin3d {
pub const ZERO: Self = Origin3d {
x: 0,
y: 0,
z: 0,
};
}
impl Default for Origin3d {
fn default() -> Self {
Origin3d::ZERO
}
}
#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct Extent3d {
pub width: u32,
pub height: u32,
pub depth: u32,
}
#[repr(C)]
#[derive(Debug)]
pub struct U32Array {

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

@ -5,11 +5,14 @@
use crate::{
device::RenderPassContext,
id::{DeviceId, PipelineLayoutId, ShaderModuleId},
LifeGuard,
RawString,
RefCount,
Stored,
U32Array
};
use wgt::{BufferAddress, ColorStateDescriptor, DepthStencilStateDescriptor, IndexFormat, InputStepMode, PrimitiveTopology, RasterizationStateDescriptor, VertexAttributeDescriptor};
use std::borrow::Borrow;
#[repr(C)]
#[derive(Debug)]
@ -59,6 +62,13 @@ pub struct ComputePipeline<B: hal::Backend> {
pub(crate) raw: B::ComputePipeline,
pub(crate) layout_id: PipelineLayoutId,
pub(crate) device_id: Stored<DeviceId>,
pub(crate) life_guard: LifeGuard,
}
impl<B: hal::Backend> Borrow<RefCount> for ComputePipeline<B> {
fn borrow(&self) -> &RefCount {
self.life_guard.ref_count.as_ref().unwrap()
}
}
#[repr(C)]
@ -96,4 +106,11 @@ pub struct RenderPipeline<B: hal::Backend> {
pub(crate) index_format: IndexFormat,
pub(crate) sample_count: u8,
pub(crate) vertex_strides: Vec<(BufferAddress, InputStepMode)>,
pub(crate) life_guard: LifeGuard,
}
impl<B: hal::Backend> Borrow<RefCount> for RenderPipeline<B> {
fn borrow(&self) -> &RefCount {
self.life_guard.ref_count.as_ref().unwrap()
}
}

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

@ -5,15 +5,18 @@
use crate::{
id::{DeviceId, SwapChainId, TextureId},
track::DUMMY_SELECTOR,
Extent3d,
LifeGuard,
RefCount,
Stored,
};
use wgt::{BufferAddress, BufferUsage, CompareFunction, TextureFormat, TextureUsage};
use hal;
use rendy_memory::MemoryBlock;
use wgt::{
BufferAddress,
BufferUsage,
TextureFormat,
TextureUsage,
};
use gfx_memory::MemoryBlock;
use std::{borrow::Borrow, fmt};
@ -26,9 +29,25 @@ pub enum BufferMapAsyncStatus {
ContextLost,
}
#[derive(Debug)]
pub enum BufferMapState {
/// Waiting for GPU to be done before mapping
Waiting(BufferPendingMapping),
/// Mapped
Active,
/// Not mapped
Idle,
}
pub enum BufferMapOperation {
Read(Box<dyn FnOnce(BufferMapAsyncStatus, *const u8)>),
Write(Box<dyn FnOnce(BufferMapAsyncStatus, *mut u8)>),
Read {
callback: crate::device::BufferMapReadCallback,
userdata: *mut u8,
},
Write {
callback: crate::device::BufferMapWriteCallback,
userdata: *mut u8,
}
}
//TODO: clarify if/why this is needed here
@ -38,8 +57,8 @@ unsafe impl Sync for BufferMapOperation {}
impl fmt::Debug for BufferMapOperation {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
let op = match *self {
BufferMapOperation::Read(_) => "read",
BufferMapOperation::Write(_) => "write",
BufferMapOperation::Read { .. } => "read",
BufferMapOperation::Write { .. } => "write",
};
write!(fmt, "BufferMapOperation <{}>", op)
}
@ -48,13 +67,13 @@ impl fmt::Debug for BufferMapOperation {
impl BufferMapOperation {
pub(crate) fn call_error(self) {
match self {
BufferMapOperation::Read(callback) => {
BufferMapOperation::Read { callback, userdata } => {
log::error!("wgpu_buffer_map_read_async failed: buffer mapping is pending");
callback(BufferMapAsyncStatus::Error, std::ptr::null());
unsafe { callback(BufferMapAsyncStatus::Error, std::ptr::null(), userdata); }
}
BufferMapOperation::Write(callback) => {
BufferMapOperation::Write { callback, userdata } => {
log::error!("wgpu_buffer_map_write_async failed: buffer mapping is pending");
callback(BufferMapAsyncStatus::Error, std::ptr::null_mut());
unsafe { callback(BufferMapAsyncStatus::Error, std::ptr::null_mut(), userdata); }
}
}
}
@ -62,7 +81,7 @@ impl BufferMapOperation {
#[derive(Debug)]
pub struct BufferPendingMapping {
pub range: std::ops::Range<BufferAddress>,
pub sub_range: hal::buffer::SubRange,
pub op: BufferMapOperation,
// hold the parent alive while the mapping is active
pub parent_ref_count: RefCount,
@ -76,9 +95,9 @@ pub struct Buffer<B: hal::Backend> {
pub(crate) memory: MemoryBlock<B>,
pub(crate) size: BufferAddress,
pub(crate) full_range: (),
pub(crate) mapped_write_ranges: Vec<std::ops::Range<BufferAddress>>,
pub(crate) pending_mapping: Option<BufferPendingMapping>,
pub(crate) mapped_write_segments: Vec<hal::memory::Segment>,
pub(crate) life_guard: LifeGuard,
pub(crate) map_state: BufferMapState,
}
impl<B: hal::Backend> Borrow<RefCount> for Buffer<B> {
@ -93,26 +112,6 @@ impl<B: hal::Backend> Borrow<()> for Buffer<B> {
}
}
#[repr(C)]
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
pub enum TextureDimension {
D1,
D2,
D3,
}
#[repr(C)]
#[derive(Debug)]
pub struct TextureDescriptor {
pub size: Extent3d,
pub array_layer_count: u32,
pub mip_level_count: u32,
pub sample_count: u32,
pub dimension: TextureDimension,
pub format: TextureFormat,
pub usage: TextureUsage,
}
#[derive(Debug)]
pub struct Texture<B: hal::Backend> {
pub(crate) raw: B::Image,
@ -137,32 +136,6 @@ impl<B: hal::Backend> Borrow<hal::image::SubresourceRange> for Texture<B> {
}
}
#[repr(C)]
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
pub enum TextureAspect {
All,
StencilOnly,
DepthOnly,
}
impl Default for TextureAspect {
fn default() -> Self {
TextureAspect::All
}
}
#[repr(C)]
#[derive(Debug)]
pub struct TextureViewDescriptor {
pub format: TextureFormat,
pub dimension: wgt::TextureViewDimension,
pub aspect: TextureAspect,
pub base_mip_level: u32,
pub level_count: u32,
pub base_array_layer: u32,
pub array_layer_count: u32,
}
#[derive(Debug)]
pub(crate) enum TextureViewInner<B: hal::Backend> {
Native {
@ -198,47 +171,6 @@ impl<B: hal::Backend> Borrow<()> for TextureView<B> {
}
}
#[repr(C)]
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
pub enum AddressMode {
ClampToEdge = 0,
Repeat = 1,
MirrorRepeat = 2,
}
impl Default for AddressMode {
fn default() -> Self {
AddressMode::ClampToEdge
}
}
#[repr(C)]
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
pub enum FilterMode {
Nearest = 0,
Linear = 1,
}
impl Default for FilterMode {
fn default() -> Self {
FilterMode::Nearest
}
}
#[repr(C)]
#[derive(Debug)]
pub struct SamplerDescriptor<'a> {
pub address_mode_u: AddressMode,
pub address_mode_v: AddressMode,
pub address_mode_w: AddressMode,
pub mag_filter: FilterMode,
pub min_filter: FilterMode,
pub mipmap_filter: FilterMode,
pub lod_min_clamp: f32,
pub lod_max_clamp: f32,
pub compare: Option<&'a CompareFunction>,
}
#[derive(Debug)]
pub struct Sampler<B: hal::Backend> {
pub(crate) raw: B::Sampler,

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

@ -85,7 +85,7 @@ pub(crate) fn swap_chain_descriptor_to_hal(
#[repr(C)]
#[derive(Debug)]
pub struct SwapChainOutput {
pub view_id: TextureViewId,
pub view_id: Option<TextureViewId>,
}
#[derive(Debug)]
@ -150,7 +150,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
life_guard: LifeGuard::new(),
};
let ref_count = view.life_guard.add_ref();
let view_id = hub
let id = hub
.texture_views
.register_identity(view_id_in, view, &mut token);
@ -159,11 +159,11 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
"Swap chain image is already acquired"
);
sc.acquired_view_id = Some(Stored {
value: view_id,
value: id,
ref_count,
});
Ok(SwapChainOutput { view_id })
Ok(SwapChainOutput { view_id: Some(id) })
}
pub fn swap_chain_present<B: GfxBackend>(&self, swap_chain_id: SwapChainId) {

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

@ -122,7 +122,7 @@ mod test {
first: Some(BufferUsage::INDEX),
last: BufferUsage::STORAGE,
};
let id = TypedId::zip(0, 0, wgt::Backend::Empty);
let id = TypedId::zip(1, 0, wgt::Backend::Empty);
assert!(bs.change(id, (), BufferUsage::VERTEX, None).is_err());
bs.change(id, (), BufferUsage::VERTEX, Some(&mut Vec::new()))
.unwrap();

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

@ -9,7 +9,7 @@ mod texture;
use crate::{
conv,
hub::Storage,
id::{BindGroupId, SamplerId, TextureViewId, TypedId},
id::{self, TypedId},
resource,
Epoch,
FastHashMap,
@ -138,7 +138,7 @@ impl PendingTransition<BufferState> {
hal::memory::Barrier::Buffer {
states: conv::map_buffer_state(self.usage.start) .. conv::map_buffer_state(self.usage.end),
target: &buf.raw,
range: None .. None,
range: hal::buffer::SubRange::WHOLE,
families: None,
}
}
@ -464,9 +464,11 @@ pub const DUMMY_SELECTOR: () = ();
pub struct TrackerSet {
pub buffers: ResourceTracker<BufferState>,
pub textures: ResourceTracker<TextureState>,
pub views: ResourceTracker<PhantomData<TextureViewId>>,
pub bind_groups: ResourceTracker<PhantomData<BindGroupId>>,
pub samplers: ResourceTracker<PhantomData<SamplerId>>,
pub views: ResourceTracker<PhantomData<id::TextureViewId>>,
pub bind_groups: ResourceTracker<PhantomData<id::BindGroupId>>,
pub samplers: ResourceTracker<PhantomData<id::SamplerId>>,
pub compute_pipes: ResourceTracker<PhantomData<id::ComputePipelineId>>,
pub render_pipes: ResourceTracker<PhantomData<id::RenderPipelineId>>,
}
impl TrackerSet {
@ -478,6 +480,8 @@ impl TrackerSet {
views: ResourceTracker::new(backend),
bind_groups: ResourceTracker::new(backend),
samplers: ResourceTracker::new(backend),
compute_pipes: ResourceTracker::new(backend),
render_pipes: ResourceTracker::new(backend),
}
}
@ -488,6 +492,8 @@ impl TrackerSet {
self.views.clear();
self.bind_groups.clear();
self.samplers.clear();
self.compute_pipes.clear();
self.render_pipes.clear();
}
/// Try to optimize the tracking representation.
@ -497,6 +503,8 @@ impl TrackerSet {
self.views.optimize();
self.bind_groups.optimize();
self.samplers.optimize();
self.compute_pipes.optimize();
self.render_pipes.optimize();
}
/// Merge all the trackers of another instance by extending
@ -507,6 +515,8 @@ impl TrackerSet {
self.views.merge_extend(&other.views).unwrap();
self.bind_groups.merge_extend(&other.bind_groups).unwrap();
self.samplers.merge_extend(&other.samplers).unwrap();
self.compute_pipes.merge_extend(&other.compute_pipes).unwrap();
self.render_pipes.merge_extend(&other.render_pipes).unwrap();
}
pub fn backend(&self) -> wgt::Backend {

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

@ -8,7 +8,10 @@ autogen_warning = """/* DO NOT MODIFY THIS MANUALLY! This file was generated usi
* 2. Run `rustup run nightly cbindgen toolkit/library/rust/ --lockfile Cargo.lock --crate wgpu-remote -o dom/webgpu/ffi/wgpu_ffi_generated.h`
*/
#define WGPU_LOCAL
typedef unsigned long long WGPUNonZeroU64;
typedef unsigned long long WGPUOption_AdapterId;
typedef unsigned long long WGPUOption_SurfaceId;
typedef unsigned long long WGPUOption_TextureViewId;
"""
include_version = true
braces = "SameLine"
@ -18,8 +21,7 @@ language = "C"
[export]
prefix = "WGPU"
#TODO: figure out why cbindgen even tries to export a private type...
exclude = ["BufferMapResult"]
exclude = ["Option_AdapterId", "Option_SurfaceId", "Option_TextureViewId"]
[parse]
parse_deps = true

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

@ -15,7 +15,7 @@ use core::{gfx_select, id};
#[no_mangle]
pub extern "C" fn wgpu_command_encoder_finish(
encoder_id: id::CommandEncoderId,
desc: Option<&core::command::CommandBufferDescriptor>,
desc: Option<&wgt::CommandBufferDescriptor>,
) -> id::CommandBufferId {
let desc = &desc.cloned().unwrap_or_default();
gfx_select!(encoder_id => GLOBAL.command_encoder_finish(encoder_id, desc))
@ -43,7 +43,7 @@ pub extern "C" fn wgpu_command_encoder_copy_buffer_to_texture(
command_encoder_id: id::CommandEncoderId,
source: &core::command::BufferCopyView,
destination: &core::command::TextureCopyView,
copy_size: core::Extent3d,
copy_size: wgt::Extent3d,
) {
gfx_select!(command_encoder_id => GLOBAL.command_encoder_copy_buffer_to_texture(
command_encoder_id,
@ -57,7 +57,7 @@ pub extern "C" fn wgpu_command_encoder_copy_texture_to_buffer(
command_encoder_id: id::CommandEncoderId,
source: &core::command::TextureCopyView,
destination: &core::command::BufferCopyView,
copy_size: core::Extent3d,
copy_size: wgt::Extent3d,
) {
gfx_select!(command_encoder_id => GLOBAL.command_encoder_copy_texture_to_buffer(
command_encoder_id,
@ -71,7 +71,7 @@ pub extern "C" fn wgpu_command_encoder_copy_texture_to_texture(
command_encoder_id: id::CommandEncoderId,
source: &core::command::TextureCopyView,
destination: &core::command::TextureCopyView,
copy_size: core::Extent3d,
copy_size: wgt::Extent3d,
) {
gfx_select!(command_encoder_id => GLOBAL.command_encoder_copy_texture_to_texture(
command_encoder_id,

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

@ -4,7 +4,7 @@
use crate::GLOBAL;
use wgt::{BackendBit, DeviceDescriptor, Limits, RequestAdapterOptions};
use wgt::{BackendBit, DeviceDescriptor, Limits};
use core::{gfx_select, hub::Token, id};
use std::{marker::PhantomData, slice};
@ -13,7 +13,7 @@ use std::{marker::PhantomData, slice};
use objc::{msg_send, runtime::Object, sel, sel_impl};
pub type RequestAdapterCallback =
unsafe extern "C" fn(id: id::AdapterId, userdata: *mut std::ffi::c_void);
unsafe extern "C" fn(id: Option<id::AdapterId>, userdata: *mut std::ffi::c_void);
pub fn wgpu_create_surface(raw_handle: raw_window_handle::RawWindowHandle) -> id::SurfaceId {
use raw_window_handle::RawWindowHandle as Rwh;
@ -153,7 +153,7 @@ pub fn wgpu_enumerate_adapters(mask: BackendBit) -> Vec<id::AdapterId> {
/// This function is unsafe as it calls an unsafe extern callback.
#[no_mangle]
pub unsafe extern "C" fn wgpu_request_adapter_async(
desc: Option<&RequestAdapterOptions>,
desc: Option<&core::instance::RequestAdapterOptions>,
mask: BackendBit,
callback: RequestAdapterCallback,
userdata: *mut std::ffi::c_void,
@ -162,10 +162,7 @@ pub unsafe extern "C" fn wgpu_request_adapter_async(
&desc.cloned().unwrap_or_default(),
core::instance::AdapterInputs::Mask(mask, || PhantomData),
);
callback(
id.unwrap_or(id::AdapterId::ERROR),
userdata,
);
callback(id, userdata);
}
#[no_mangle]
@ -225,7 +222,7 @@ pub extern "C" fn wgpu_buffer_destroy(buffer_id: id::BufferId) {
#[no_mangle]
pub extern "C" fn wgpu_device_create_texture(
device_id: id::DeviceId,
desc: &core::resource::TextureDescriptor,
desc: &wgt::TextureDescriptor,
) -> id::TextureId {
gfx_select!(device_id => GLOBAL.device_create_texture(device_id, desc, PhantomData))
}
@ -238,7 +235,7 @@ pub extern "C" fn wgpu_texture_destroy(texture_id: id::TextureId) {
#[no_mangle]
pub extern "C" fn wgpu_texture_create_view(
texture_id: id::TextureId,
desc: Option<&core::resource::TextureViewDescriptor>,
desc: Option<&wgt::TextureViewDescriptor>,
) -> id::TextureViewId {
gfx_select!(texture_id => GLOBAL.texture_create_view(texture_id, desc, PhantomData))
}
@ -251,7 +248,7 @@ pub extern "C" fn wgpu_texture_view_destroy(texture_view_id: id::TextureViewId)
#[no_mangle]
pub extern "C" fn wgpu_device_create_sampler(
device_id: id::DeviceId,
desc: &core::resource::SamplerDescriptor,
desc: &wgt::SamplerDescriptor,
) -> id::SamplerId {
gfx_select!(device_id => GLOBAL.device_create_sampler(device_id, desc, PhantomData))
}
@ -380,11 +377,11 @@ pub extern "C" fn wgpu_buffer_map_read_async(
callback: core::device::BufferMapReadCallback,
userdata: *mut u8,
) {
let operation = core::resource::BufferMapOperation::Read(
Box::new(move |status, data| unsafe {
callback(status, data, userdata)
}),
);
let operation = core::resource::BufferMapOperation::Read {
callback,
userdata,
};
gfx_select!(buffer_id => GLOBAL.buffer_map_async(buffer_id, wgt::BufferUsage::MAP_READ, start .. start + size, operation))
}
@ -396,11 +393,11 @@ pub extern "C" fn wgpu_buffer_map_write_async(
callback: core::device::BufferMapWriteCallback,
userdata: *mut u8,
) {
let operation = core::resource::BufferMapOperation::Write(
Box::new(move |status, data| unsafe {
callback(status, data, userdata)
}),
);
let operation = core::resource::BufferMapOperation::Write {
callback,
userdata,
};
gfx_select!(buffer_id => GLOBAL.buffer_map_async(buffer_id, wgt::BufferUsage::MAP_WRITE, start .. start + size, operation))
}
@ -415,7 +412,7 @@ pub extern "C" fn wgpu_swap_chain_get_next_texture(
) -> core::swap_chain::SwapChainOutput {
gfx_select!(swap_chain_id => GLOBAL.swap_chain_get_next_texture(swap_chain_id, PhantomData))
.unwrap_or(core::swap_chain::SwapChainOutput {
view_id: id::TextureViewId::ERROR,
view_id: None,
})
}

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

@ -8,7 +8,10 @@ autogen_warning = """/* DO NOT MODIFY THIS MANUALLY! This file was generated usi
* 2. Run `rustup run nightly cbindgen toolkit/library/rust/ --lockfile Cargo.lock --crate wgpu-remote -o dom/webgpu/ffi/wgpu_ffi_generated.h`
*/
typedef void WGPUEmpty;
typedef uint64_t WGPUNonZeroU64;
typedef uint64_t WGPUOption_AdapterId;
typedef uint64_t WGPUOption_SurfaceId;
typedef uint64_t WGPUOption_TextureViewId;
"""
include_version = true
braces = "SameLine"
@ -19,7 +22,7 @@ style = "tag"
[export]
prefix = "WGPU"
exclude = ["BufferMapResult"]
exclude = ["Option_AdapterId", "Option_SurfaceId", "Option_TextureViewId"]
[parse]
parse_deps = true

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

@ -49,7 +49,7 @@ pub struct IdentityRecyclerFactory {
impl core::hub::IdentityHandlerFactory<id::AdapterId> for IdentityRecyclerFactory {
type Filter = IdentityRecycler<id::AdapterId>;
fn spawn(&self) -> Self::Filter {
fn spawn(&self, _min_index: u32) -> Self::Filter {
IdentityRecycler {
fun: self.free_adapter,
param: self.param,
@ -59,7 +59,7 @@ impl core::hub::IdentityHandlerFactory<id::AdapterId> for IdentityRecyclerFactor
}
impl core::hub::IdentityHandlerFactory<id::DeviceId> for IdentityRecyclerFactory {
type Filter = IdentityRecycler<id::DeviceId>;
fn spawn(&self) -> Self::Filter {
fn spawn(&self, _min_index: u32) -> Self::Filter {
IdentityRecycler {
fun: self.free_device,
param: self.param,
@ -69,7 +69,7 @@ impl core::hub::IdentityHandlerFactory<id::DeviceId> for IdentityRecyclerFactory
}
impl core::hub::IdentityHandlerFactory<id::SwapChainId> for IdentityRecyclerFactory {
type Filter = IdentityRecycler<id::SwapChainId>;
fn spawn(&self) -> Self::Filter {
fn spawn(&self, _min_index: u32) -> Self::Filter {
IdentityRecycler {
fun: self.free_swap_chain,
param: self.param,
@ -79,7 +79,7 @@ impl core::hub::IdentityHandlerFactory<id::SwapChainId> for IdentityRecyclerFact
}
impl core::hub::IdentityHandlerFactory<id::PipelineLayoutId> for IdentityRecyclerFactory {
type Filter = IdentityRecycler<id::PipelineLayoutId>;
fn spawn(&self) -> Self::Filter {
fn spawn(&self, _min_index: u32) -> Self::Filter {
IdentityRecycler {
fun: self.free_pipeline_layout,
param: self.param,
@ -89,7 +89,7 @@ impl core::hub::IdentityHandlerFactory<id::PipelineLayoutId> for IdentityRecycle
}
impl core::hub::IdentityHandlerFactory<id::ShaderModuleId> for IdentityRecyclerFactory {
type Filter = IdentityRecycler<id::ShaderModuleId>;
fn spawn(&self) -> Self::Filter {
fn spawn(&self, _min_index: u32) -> Self::Filter {
IdentityRecycler {
fun: self.free_shader_module,
param: self.param,
@ -99,7 +99,7 @@ impl core::hub::IdentityHandlerFactory<id::ShaderModuleId> for IdentityRecyclerF
}
impl core::hub::IdentityHandlerFactory<id::BindGroupLayoutId> for IdentityRecyclerFactory {
type Filter = IdentityRecycler<id::BindGroupLayoutId>;
fn spawn(&self) -> Self::Filter {
fn spawn(&self, _min_index: u32) -> Self::Filter {
IdentityRecycler {
fun: self.free_bind_group_layout,
param: self.param,
@ -109,7 +109,7 @@ impl core::hub::IdentityHandlerFactory<id::BindGroupLayoutId> for IdentityRecycl
}
impl core::hub::IdentityHandlerFactory<id::BindGroupId> for IdentityRecyclerFactory {
type Filter = IdentityRecycler<id::BindGroupId>;
fn spawn(&self) -> Self::Filter {
fn spawn(&self, _min_index: u32) -> Self::Filter {
IdentityRecycler {
fun: self.free_bind_group,
param: self.param,
@ -119,7 +119,7 @@ impl core::hub::IdentityHandlerFactory<id::BindGroupId> for IdentityRecyclerFact
}
impl core::hub::IdentityHandlerFactory<id::CommandBufferId> for IdentityRecyclerFactory {
type Filter = IdentityRecycler<id::CommandBufferId>;
fn spawn(&self) -> Self::Filter {
fn spawn(&self, _min_index: u32) -> Self::Filter {
IdentityRecycler {
fun: self.free_command_buffer,
param: self.param,
@ -129,7 +129,7 @@ impl core::hub::IdentityHandlerFactory<id::CommandBufferId> for IdentityRecycler
}
impl core::hub::IdentityHandlerFactory<id::RenderPipelineId> for IdentityRecyclerFactory {
type Filter = IdentityRecycler<id::RenderPipelineId>;
fn spawn(&self) -> Self::Filter {
fn spawn(&self, _min_index: u32) -> Self::Filter {
IdentityRecycler {
fun: self.free_render_pipeline,
param: self.param,
@ -139,7 +139,7 @@ impl core::hub::IdentityHandlerFactory<id::RenderPipelineId> for IdentityRecycle
}
impl core::hub::IdentityHandlerFactory<id::ComputePipelineId> for IdentityRecyclerFactory {
type Filter = IdentityRecycler<id::ComputePipelineId>;
fn spawn(&self) -> Self::Filter {
fn spawn(&self, _min_index: u32) -> Self::Filter {
IdentityRecycler {
fun: self.free_compute_pipeline,
param: self.param,
@ -149,7 +149,7 @@ impl core::hub::IdentityHandlerFactory<id::ComputePipelineId> for IdentityRecycl
}
impl core::hub::IdentityHandlerFactory<id::BufferId> for IdentityRecyclerFactory {
type Filter = IdentityRecycler<id::BufferId>;
fn spawn(&self) -> Self::Filter {
fn spawn(&self, _min_index: u32) -> Self::Filter {
IdentityRecycler {
fun: self.free_buffer,
param: self.param,
@ -159,7 +159,7 @@ impl core::hub::IdentityHandlerFactory<id::BufferId> for IdentityRecyclerFactory
}
impl core::hub::IdentityHandlerFactory<id::TextureId> for IdentityRecyclerFactory {
type Filter = IdentityRecycler<id::TextureId>;
fn spawn(&self) -> Self::Filter {
fn spawn(&self, _min_index: u32) -> Self::Filter {
IdentityRecycler {
fun: self.free_texture,
param: self.param,
@ -169,7 +169,7 @@ impl core::hub::IdentityHandlerFactory<id::TextureId> for IdentityRecyclerFactor
}
impl core::hub::IdentityHandlerFactory<id::TextureViewId> for IdentityRecyclerFactory {
type Filter = IdentityRecycler<id::TextureViewId>;
fn spawn(&self) -> Self::Filter {
fn spawn(&self, _min_index: u32) -> Self::Filter {
IdentityRecycler {
fun: self.free_texture_view,
param: self.param,
@ -179,7 +179,7 @@ impl core::hub::IdentityHandlerFactory<id::TextureViewId> for IdentityRecyclerFa
}
impl core::hub::IdentityHandlerFactory<id::SamplerId> for IdentityRecyclerFactory {
type Filter = IdentityRecycler<id::SamplerId>;
fn spawn(&self) -> Self::Filter {
fn spawn(&self, _min_index: u32) -> Self::Filter {
IdentityRecycler {
fun: self.free_sampler,
param: self.param,
@ -189,7 +189,7 @@ impl core::hub::IdentityHandlerFactory<id::SamplerId> for IdentityRecyclerFactor
}
impl core::hub::IdentityHandlerFactory<id::SurfaceId> for IdentityRecyclerFactory {
type Filter = IdentityRecycler<id::SurfaceId>;
fn spawn(&self) -> Self::Filter {
fn spawn(&self, _min_index: u32) -> Self::Filter {
IdentityRecycler {
fun: self.free_surface,
param: self.param,

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

@ -46,7 +46,7 @@ pub extern "C" fn wgpu_server_poll_all_devices(global: &Global, force_wait: bool
#[no_mangle]
pub unsafe extern "C" fn wgpu_server_instance_request_adapter(
global: &Global,
desc: &wgt::RequestAdapterOptions,
desc: &core::instance::RequestAdapterOptions,
ids: *const id::AdapterId,
id_length: usize,
) -> i8 {
@ -123,11 +123,11 @@ pub extern "C" fn wgpu_server_buffer_map_read(
callback: core::device::BufferMapReadCallback,
userdata: *mut u8,
) {
let operation = core::resource::BufferMapOperation::Read(
Box::new(move |status, data| unsafe {
callback(status, data, userdata)
}),
);
let operation = core::resource::BufferMapOperation::Read {
callback,
userdata,
};
gfx_select!(buffer_id => global.buffer_map_async(
buffer_id,
wgt::BufferUsage::MAP_READ,
@ -136,6 +136,14 @@ pub extern "C" fn wgpu_server_buffer_map_read(
));
}
#[no_mangle]
pub extern "C" fn wgpu_server_buffer_unmap(
global: &Global,
buffer_id: id::BufferId,
) {
gfx_select!(buffer_id => global.buffer_unmap(buffer_id));
}
#[no_mangle]
pub extern "C" fn wgpu_server_buffer_destroy(global: &Global, self_id: id::BufferId) {
gfx_select!(self_id => global.buffer_destroy(self_id));
@ -155,7 +163,7 @@ pub extern "C" fn wgpu_server_device_create_encoder(
pub extern "C" fn wgpu_server_encoder_finish(
global: &Global,
self_id: id::CommandEncoderId,
desc: &core::command::CommandBufferDescriptor,
desc: &wgt::CommandBufferDescriptor,
) {
gfx_select!(self_id => global.command_encoder_finish(self_id, desc));
}
@ -199,7 +207,7 @@ pub unsafe extern "C" fn wgpu_server_encoder_copy_texture_to_buffer(
self_id: id::CommandEncoderId,
source: &core::command::TextureCopyView,
destination: &core::command::BufferCopyView,
size: core::Extent3d,
size: wgt::Extent3d,
) {
gfx_select!(self_id => global.command_encoder_copy_texture_to_buffer(self_id, source, destination, size));
}
@ -210,11 +218,22 @@ pub unsafe extern "C" fn wgpu_server_encoder_copy_buffer_to_texture(
self_id: id::CommandEncoderId,
source: &core::command::BufferCopyView,
destination: &core::command::TextureCopyView,
size: core::Extent3d,
size: wgt::Extent3d,
) {
gfx_select!(self_id => global.command_encoder_copy_buffer_to_texture(self_id, source, destination, size));
}
#[no_mangle]
pub unsafe extern "C" fn wgpu_server_encoder_copy_texture_to_texture(
global: &Global,
self_id: id::CommandEncoderId,
source: &core::command::TextureCopyView,
destination: &core::command::TextureCopyView,
size: wgt::Extent3d,
) {
gfx_select!(self_id => global.command_encoder_copy_texture_to_texture(self_id, source, destination, size));
}
/// # Safety
///
/// This function is unsafe as there is no guarantee that the given pointers are
@ -374,7 +393,7 @@ pub extern "C" fn wgpu_server_render_pipeline_destroy(
pub extern "C" fn wgpu_server_device_create_texture(
global: &Global,
self_id: id::DeviceId,
desc: &core::resource::TextureDescriptor,
desc: &wgt::TextureDescriptor,
new_id: id::TextureId,
) {
gfx_select!(self_id => global.device_create_texture(self_id, desc, new_id));
@ -384,7 +403,7 @@ pub extern "C" fn wgpu_server_device_create_texture(
pub extern "C" fn wgpu_server_texture_create_view(
global: &Global,
self_id: id::TextureId,
desc: Option<&core::resource::TextureViewDescriptor>,
desc: Option<&wgt::TextureViewDescriptor>,
new_id: id::TextureViewId,
) {
gfx_select!(self_id => global.texture_create_view(self_id, desc, new_id));
@ -410,7 +429,7 @@ pub extern "C" fn wgpu_server_texture_view_destroy(
pub extern "C" fn wgpu_server_device_create_sampler(
global: &Global,
self_id: id::DeviceId,
desc: &core::resource::SamplerDescriptor,
desc: &wgt::SamplerDescriptor,
new_id: id::SamplerId,
) {
gfx_select!(self_id => global.device_create_sampler(self_id, desc, new_id));

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

@ -17,4 +17,4 @@ license = "MPL-2.0"
[dependencies]
bitflags = "1.0"
serde = { version = "1.0", features = ["serde_derive"], optional = true }
peek-poke = { git = "https://github.com/kvark/peek-poke", rev = "969bd7fe2be1a83f87916dc8b388c63cfd457075", optional = true }
peek-poke = { version = "0.2", optional = true }

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

@ -2,14 +2,14 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use std::{io, slice};
use std::{io, slice, ptr};
#[cfg(feature = "serde")]
use serde::{Serialize, Deserialize};
#[cfg(feature = "peek-poke")]
use peek_poke::{PeekCopy, Poke};
use peek_poke::{PeekPoke};
#[repr(u8)]
#[derive(Clone, Copy, Debug, PartialEq)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum Backend {
Empty = 0,
@ -22,7 +22,7 @@ pub enum Backend {
}
#[repr(C)]
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum PowerPreference {
Default = 0,
@ -30,21 +30,6 @@ pub enum PowerPreference {
HighPerformance = 2,
}
#[repr(C)]
#[derive(Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct RequestAdapterOptions {
pub power_preference: PowerPreference,
}
impl Default for RequestAdapterOptions {
fn default() -> Self {
RequestAdapterOptions {
power_preference: PowerPreference::Default,
}
}
}
bitflags::bitflags! {
#[repr(transparent)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
@ -72,14 +57,14 @@ impl From<Backend> for BackendBit {
}
#[repr(C)]
#[derive(Clone, Debug, Default)]
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Extensions {
pub anisotropic_filtering: bool,
}
#[repr(C)]
#[derive(Clone, Debug)]
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Limits {
pub max_bind_groups: u32,
@ -170,6 +155,7 @@ pub type BufferAddress = u64;
#[repr(C)]
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum BlendFactor {
Zero = 0,
One = 1,
@ -188,6 +174,7 @@ pub enum BlendFactor {
#[repr(C)]
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum BlendOperation {
Add = 0,
Subtract = 1,
@ -203,7 +190,8 @@ impl Default for BlendOperation {
}
#[repr(C)]
#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct BlendDescriptor {
pub src_factor: BlendFactor,
pub dst_factor: BlendFactor,
@ -235,7 +223,8 @@ impl Default for BlendDescriptor {
}
#[repr(C)]
#[derive(Clone, Debug)]
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct ColorStateDescriptor {
pub format: TextureFormat,
pub alpha_blend: BlendDescriptor,
@ -245,6 +234,7 @@ pub struct ColorStateDescriptor {
#[repr(C)]
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum PrimitiveTopology {
PointList = 0,
LineList = 1,
@ -255,6 +245,7 @@ pub enum PrimitiveTopology {
#[repr(C)]
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum FrontFace {
Ccw = 0,
Cw = 1,
@ -268,6 +259,7 @@ impl Default for FrontFace {
#[repr(C)]
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum CullMode {
None = 0,
Front = 1,
@ -281,7 +273,8 @@ impl Default for CullMode {
}
#[repr(C)]
#[derive(Clone, Debug, Default)]
#[derive(Clone, Debug, Default, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct RasterizationStateDescriptor {
pub front_face: FrontFace,
pub cull_mode: CullMode,
@ -349,6 +342,7 @@ pub enum TextureFormat {
bitflags::bitflags! {
#[repr(transparent)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct ColorWrite: u32 {
const RED = 1;
const GREEN = 2;
@ -366,7 +360,8 @@ impl Default for ColorWrite {
}
#[repr(C)]
#[derive(Clone, Debug)]
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct DepthStencilStateDescriptor {
pub format: TextureFormat,
pub depth_write_enabled: bool,
@ -385,6 +380,7 @@ impl DepthStencilStateDescriptor {
#[repr(C)]
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum IndexFormat {
Uint16 = 0,
Uint32 = 1,
@ -392,6 +388,7 @@ pub enum IndexFormat {
#[repr(C)]
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum StencilOperation {
Keep = 0,
Zero = 1,
@ -410,7 +407,8 @@ impl Default for StencilOperation {
}
#[repr(C)]
#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct StencilStateFaceDescriptor {
pub compare: CompareFunction,
pub fail_op: StencilOperation,
@ -435,15 +433,17 @@ impl Default for StencilStateFaceDescriptor {
#[repr(C)]
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum CompareFunction {
Never = 0,
Less = 1,
Equal = 2,
LessEqual = 3,
Greater = 4,
NotEqual = 5,
GreaterEqual = 6,
Always = 7,
Undefined = 0,
Never = 1,
Less = 2,
Equal = 3,
LessEqual = 4,
Greater = 5,
NotEqual = 6,
GreaterEqual = 7,
Always = 8,
}
impl CompareFunction {
@ -459,13 +459,15 @@ pub type ShaderLocation = u32;
#[repr(C)]
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum InputStepMode {
Vertex = 0,
Instance = 1,
}
#[repr(C)]
#[derive(Clone, Debug)]
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct VertexAttributeDescriptor {
pub offset: BufferAddress,
pub format: VertexFormat,
@ -474,6 +476,7 @@ pub struct VertexAttributeDescriptor {
#[repr(C)]
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum VertexFormat {
Uchar2 = 1,
Uchar4 = 3,
@ -536,25 +539,35 @@ bitflags::bitflags! {
}
#[repr(C)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Clone, Debug)]
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct BufferDescriptor {
pub label: *const std::os::raw::c_char,
pub size: BufferAddress,
pub usage: BufferUsage,
}
#[repr(C)]
#[derive(Clone, Debug, Default)]
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct CommandEncoderDescriptor {
// MSVC doesn't allow zero-sized structs
// We can remove this when we actually have a field
pub todo: u32,
// pub todo: u32,
pub label: *const std::os::raw::c_char,
}
impl Default for CommandEncoderDescriptor {
fn default() -> CommandEncoderDescriptor {
CommandEncoderDescriptor {
label: ptr::null(),
}
}
}
pub type DynamicOffset = u32;
#[repr(C)]
#[derive(Copy, Clone, Debug)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum PresentMode {
/// The presentation engine does **not** wait for a vertical blanking period and
/// the request is presented immediately. This is a low-latency presentation mode,
@ -574,6 +587,7 @@ pub enum PresentMode {
bitflags::bitflags! {
#[repr(transparent)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct TextureUsage: u32 {
const COPY_SRC = 1;
const COPY_DST = 2;
@ -594,7 +608,8 @@ bitflags::bitflags! {
}
#[repr(C)]
#[derive(Clone, Debug)]
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct SwapChainDescriptor {
pub usage: TextureUsage,
pub format: TextureFormat,
@ -605,7 +620,8 @@ pub struct SwapChainDescriptor {
#[repr(C)]
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
#[cfg_attr(feature = "peek-poke", derive(PeekCopy, Poke))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "peek-poke", derive(PeekPoke))]
pub enum LoadOp {
Clear = 0,
Load = 1,
@ -613,18 +629,20 @@ pub enum LoadOp {
#[repr(C)]
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
#[cfg_attr(feature = "peek-poke", derive(PeekCopy, Poke))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "peek-poke", derive(PeekPoke))]
pub enum StoreOp {
Clear = 0,
Store = 1,
}
#[repr(C)]
#[derive(Debug)]
#[cfg_attr(feature = "peek-poke", derive(PeekCopy, Poke))]
pub struct RenderPassColorAttachmentDescriptorBase<T, R> {
#[derive(Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "peek-poke", derive(PeekPoke))]
pub struct RenderPassColorAttachmentDescriptorBase<T> {
pub attachment: T,
pub resolve_target: R,
pub resolve_target: Option<T>,
pub load_op: LoadOp,
pub store_op: StoreOp,
pub clear_color: Color,
@ -632,7 +650,8 @@ pub struct RenderPassColorAttachmentDescriptorBase<T, R> {
#[repr(C)]
#[derive(Clone, Debug)]
#[cfg_attr(feature = "peek-poke", derive(PeekCopy, Poke))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "peek-poke", derive(PeekPoke))]
pub struct RenderPassDepthStencilAttachmentDescriptorBase<T> {
pub attachment: T,
pub depth_load_op: LoadOp,
@ -644,8 +663,9 @@ pub struct RenderPassDepthStencilAttachmentDescriptorBase<T> {
}
#[repr(C)]
#[derive(Clone, Copy, Debug)]
#[cfg_attr(feature = "peek-poke", derive(PeekCopy, Poke))]
#[derive(Clone, Copy, Debug, Default, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "peek-poke", derive(PeekPoke))]
pub struct Color {
pub r: f64,
pub g: f64,
@ -691,3 +711,148 @@ impl Color {
a: 1.0,
};
}
#[repr(C)]
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum TextureDimension {
D1,
D2,
D3,
}
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Origin3d {
pub x: u32,
pub y: u32,
pub z: u32,
}
impl Origin3d {
pub const ZERO: Self = Origin3d {
x: 0,
y: 0,
z: 0,
};
}
impl Default for Origin3d {
fn default() -> Self {
Origin3d::ZERO
}
}
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Extent3d {
pub width: u32,
pub height: u32,
pub depth: u32,
}
#[repr(C)]
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct TextureDescriptor {
pub label: *const std::os::raw::c_char,
pub size: Extent3d,
pub array_layer_count: u32,
pub mip_level_count: u32,
pub sample_count: u32,
pub dimension: TextureDimension,
pub format: TextureFormat,
pub usage: TextureUsage,
}
#[repr(C)]
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum TextureAspect {
All,
StencilOnly,
DepthOnly,
}
impl Default for TextureAspect {
fn default() -> Self {
TextureAspect::All
}
}
#[repr(C)]
#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct TextureViewDescriptor {
pub format: TextureFormat,
pub dimension: TextureViewDimension,
pub aspect: TextureAspect,
pub base_mip_level: u32,
pub level_count: u32,
pub base_array_layer: u32,
pub array_layer_count: u32,
}
#[repr(C)]
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum AddressMode {
ClampToEdge = 0,
Repeat = 1,
MirrorRepeat = 2,
}
impl Default for AddressMode {
fn default() -> Self {
AddressMode::ClampToEdge
}
}
#[repr(C)]
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum FilterMode {
Nearest = 0,
Linear = 1,
}
impl Default for FilterMode {
fn default() -> Self {
FilterMode::Nearest
}
}
#[repr(C)]
#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct SamplerDescriptor {
pub address_mode_u: AddressMode,
pub address_mode_v: AddressMode,
pub address_mode_w: AddressMode,
pub mag_filter: FilterMode,
pub min_filter: FilterMode,
pub mipmap_filter: FilterMode,
pub lod_min_clamp: f32,
pub lod_max_clamp: f32,
pub compare: CompareFunction,
}
#[repr(C)]
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct CommandBufferDescriptor {
pub todo: u32,
}
#[repr(C)]
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum TextureComponentType {
Float,
Sint,
Uint,
}
/// Bound uniform/storage buffer offsets must be aligned to this number.
pub const BIND_BUFFER_ALIGNMENT: u64 = 256;

2
third_party/rust/ash/.cargo-checksum.json поставляемый
Просмотреть файл

@ -1 +1 @@
{"files":{"Cargo.toml":"c1c67981635d76cb25b8e2d93bbf5ed521f2a436c8a3eb5c11673a1d6373cbbb","output":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","src/allocator.rs":"8defd2b41207b2049c2fdae62564148c969d92d5a724487bbc189e748b27fd5c","src/device.rs":"7349761540893b33a41eff1e922f846db494b8b9e6bf0dcfd48ce0bec00e5870","src/entry.rs":"2491a6f350f1c04bcb39e4f585d8549e2cf4bbd3e8a792145a6b0218f52b6e9b","src/extensions/experimental/amd.rs":"70652e2216811f0fcf2f0e748d0cf5c52c6eabfd613e3bd6da28cb1100cfd620","src/extensions/experimental/mod.rs":"41a5366e1c8bd0e1fa47e9cf6fddc8111ed0a6946813be4eefca81da969d1ee9","src/extensions/ext/debug_marker.rs":"2221980d611c8e9bdc9ca5186bf363ccbda22e6b5ea52572f3b7ed4ec5a752a3","src/extensions/ext/debug_report.rs":"affff85cefb68313a6d91489fba4c58e4adffca00d571e24a6818e72f94f4983","src/extensions/ext/debug_utils.rs":"8592be4c7dfbf13d4d224d79d16e4fc6ab746d1fa761178a781dc03caa63a53a","src/extensions/ext/mod.rs":"ccd7b9471c4bb356fc2fa309d58a847f9aff393b77fc08752123e19c801cbc65","src/extensions/khr/android_surface.rs":"5f9ff04add0661637258b32eea95c1eefcf86ab8686088e28a7369ab77df9456","src/extensions/khr/display_swapchain.rs":"cfd551cc2bb29d8e998938880de49d0142c1af6561360282820f6e32c1f9bc42","src/extensions/khr/mod.rs":"12a32c91a4b13972660dc997b59b38383b8059e6ff457d594731e828db6f2e1d","src/extensions/khr/surface.rs":"2e5a08e6a3f8903f40e643476eb48b0626054de606dfeed1e1e6ee3b8098c743","src/extensions/khr/swapchain.rs":"4dd73298a5d3e55c83d649a81aaf42384625ef53b7f13b24ad326a08627cf794","src/extensions/khr/wayland_surface.rs":"63233a95aa5f4c693f7322b6cf70789a9ac304a90bc3157a0855ce71872cf6e9","src/extensions/khr/win32_surface.rs":"4e27aaf236eba179eb0d2ad3a29a54ace21d7c4b5210ac36bc328e3d57cc8616","src/extensions/khr/xcb_surface.rs":"328e57312e261f55f13ed78a7c3bd8dcaab7d94d481910a6483b962d0f4da40d","src/extensions/khr/xlib_surface.rs":"44ee06032f0d3fe7f330c6542cbe81636523123355f8c10844abf7893bcb2503","src/extensions/mod.rs":"4a394c468a0fc824671b36c1390f6c34173d073ed0918a528a84f48667756d65","src/extensions/mvk/ios_surface.rs":"3c58810506841142a781df7ab76fe95a2eac5d7dc95ae6345ae93220d2647b7b","src/extensions/mvk/macos_surface.rs":"fcf3a34c164f0251293a50222f944e74fff4eeb797ad8521678031e69a26956c","src/extensions/mvk/mod.rs":"d03ac1a0144d1aca9ed1d0ce0c14b099f1fedb03b8108028b780a34f64de604c","src/extensions/nv/mesh_shader.rs":"c0450955eb36344b7e49acc58a021d04926dd918685b9fc6a655cd29a39afc72","src/extensions/nv/mod.rs":"175512de8528c3a90000cf9509c683761e9536dcb448877b7c7772b695aad258","src/extensions/nv/ray_tracing.rs":"a241936debf78f219de647b8392dc18c0542a82393eace4d25aaa49afef36b82","src/instance.rs":"fab133b311506eb38d8a3faa7f3e60a9e13b84760e08ad830e616262a6b46228","src/lib.rs":"801481c0cd8415f7f90ba1022128b440cc951cbd572a82f30cc1a142d34af405","src/prelude.rs":"ed6ee8e74131c232af2e3a780abe13f0c65acba1e6de61e3d1eec7f7aec7467a","src/util.rs":"bb50e11bc75058fb474bda5e34aa8978cb585ce3532ae2921c93692a13a25187","src/version.rs":"6f2d52ac2edd6f54c899763825954ac8b4c944aa9168d00885cf3955b5e4e454","src/vk.rs":"f946223870190a0060cf7b3c5baacae9ef1e4bcd12bc2d860344dc5c1567cf3d","tests/constant_size_arrays.rs":"6577f5c8d9810f9aea1d47862243e4d41a297d43e744be04fdb34d08021bac48","tests/display.rs":"13f341053efcfc104e6dae48c19e6092ffc2acf6ff3cbc4ed37dd1a03875cb17"},"package":"003d1fb2eb12eb06d4a03dbe02eea67a9fac910fa97932ab9e3a75b96a1ea5e5"}
{"files":{"Cargo.toml":"8672467a4061ab042e1680a880e7dc96bff020880af1309f40ec5b3a92d98758","src/allocator.rs":"8defd2b41207b2049c2fdae62564148c969d92d5a724487bbc189e748b27fd5c","src/device.rs":"012bb9dbd4c557ac0309b8f39d911c2d28800c5258931e6c4166a56366b8f769","src/entry.rs":"e6cb5bd68abd37442fea9faa6a307210398c8f9798c19691d99ea8355d21aa2d","src/extensions/experimental/amd.rs":"39bef9d347d3abda78599a2363944612b3b52ea4ed90dcc36afc57162f5bdc87","src/extensions/experimental/mod.rs":"41a5366e1c8bd0e1fa47e9cf6fddc8111ed0a6946813be4eefca81da969d1ee9","src/extensions/ext/debug_marker.rs":"ddb7629fa10180fbe9e8ef55ce82bec08210a102baf7c66208697a1d6c2240d3","src/extensions/ext/debug_report.rs":"8d97690f144940beee44e198a81eae60c9aba2b549ac0c4cfedd1f81a8927cad","src/extensions/ext/debug_utils.rs":"a1064627573a2d552deecd210a8b93672f6b71f22ba7ba2ff08865e58a9fa354","src/extensions/ext/mod.rs":"ccd7b9471c4bb356fc2fa309d58a847f9aff393b77fc08752123e19c801cbc65","src/extensions/khr/android_surface.rs":"24f741651204c91d2f02c2fcb70bc30982c811434b32451590ffeb012931ebfc","src/extensions/khr/display.rs":"0358c47b5d22f8abc04141c121d1c810bd5714445532c67634d396cfdff71d2c","src/extensions/khr/display_swapchain.rs":"e18ca144054d99980c256a665e6a55dfbb33caf7c6d2d3261a6dcf02a88b16c1","src/extensions/khr/external_memory_fd.rs":"19d77c876693762c36a9bc3c5ba920515590fc7485c45f0acc10b9e6160b6536","src/extensions/khr/mod.rs":"b9416eb2158938c2887b06a3e157350da74853e0737c965091833edba55e21f2","src/extensions/khr/push_descriptor.rs":"b4976428308eb1399e565954ba487c2715d9bf46388c95ddd2155c9e9cb37af5","src/extensions/khr/ray_tracing.rs":"6f4f7c59c3812b87b66b87c5a15168f2d930fd55740f65ea157846d59eba1afd","src/extensions/khr/surface.rs":"09dd9b3489ad696ab931ed91d03e56d804e43444d99fe101a607aa3f7f330759","src/extensions/khr/swapchain.rs":"8dcd3561fd562013b8f3c3020497d149ff275bdb4725916380419ebb6d6c9903","src/extensions/khr/timeline_semaphore.rs":"28b9b68902ac0867d875261cfe6548539cb4446e57c7d7a9093ad3b0b93fc18e","src/extensions/khr/wayland_surface.rs":"67d73dfaae92c824c82e8c52e409388e25d5e9eed9a0546e12b3fe4bb9c0a7a3","src/extensions/khr/win32_surface.rs":"15f7c58b536fb4a278022c8e8b723d1c520ac4cd416e205794a6ca091a08b33d","src/extensions/khr/xcb_surface.rs":"3967715468823765c239023b4e3cec895a3b039d13c8e4126655bbf2d4a441cd","src/extensions/khr/xlib_surface.rs":"f057d3314aeb4646d10075fd71e6d4244ff98baf2cd0f29787fdf0aab76c530a","src/extensions/mod.rs":"4a394c468a0fc824671b36c1390f6c34173d073ed0918a528a84f48667756d65","src/extensions/mvk/ios_surface.rs":"2734555f36a2faf43bdf955caadd186484a50370b2a359b59f46e212a6cae953","src/extensions/mvk/macos_surface.rs":"a0aaa9027ecc0a005c8db5a8ff282866b0578bbf47da5d1d2483e2aabf606d89","src/extensions/mvk/mod.rs":"d03ac1a0144d1aca9ed1d0ce0c14b099f1fedb03b8108028b780a34f64de604c","src/extensions/nv/mesh_shader.rs":"d2d675a60047e2312fe72287a69c07ae4761a8980f8b9987efcd96b2fc3913c5","src/extensions/nv/mod.rs":"175512de8528c3a90000cf9509c683761e9536dcb448877b7c7772b695aad258","src/extensions/nv/ray_tracing.rs":"40112de7c6e27d4e763ac36488f6b01a5c313bca5e4f8d63a00e5c6fcb0320f4","src/instance.rs":"8dfb706126608f91c788e8d9984ac94f1894fbf52eaa784242234bff42672265","src/lib.rs":"e53d93789398bd2ea17d6ab056bc18d66373d7b87dcb912441426bcd70f05beb","src/prelude.rs":"68b66cab3ca52ef50943eca68c4482f919342f51e21fb52a66e9b0625d5ff79e","src/util.rs":"4f966bb489398813ae062d906ccb8348e8d6a77fdc48c0f8a0ad7871780f264e","src/version.rs":"2d46dc6a5cc2358f70e1561bf17fffeccf11649e67011b816b9e114d8ecebffb","src/vk.rs":"12a419254a1879d4c0fef855de973eb1f1a3e97fcf1a61587704cb6af139c37c","tests/constant_size_arrays.rs":"aff59222e42a0920ac1045f8eb34b1ff815fa0b19cd10c63194632e2ff0d362e","tests/display.rs":"d294396bb5b2210432724cccc0a56e105bab8743e180d4ad7cc675a200c09539"},"package":"69daec0742947f33a85931fa3cb0ce5f07929159dcbd1f0cbb5b2912e2978509"}

7
third_party/rust/ash/Cargo.toml поставляемый
Просмотреть файл

@ -11,8 +11,9 @@
# will likely look very different (and much more reasonable)
[package]
edition = "2018"
name = "ash"
version = "0.29.0"
version = "0.30.0"
authors = ["maik klein <maikklein@googlemail.com>"]
description = "Vulkan bindings for Rust"
documentation = "https://docs.rs/ash"
@ -22,8 +23,8 @@ license = "MIT"
repository = "https://github.com/MaikKlein/ash"
[package.metadata.release]
no-dev-version = true
[dependencies.shared_library]
version = "0.1.9"
[dependencies.libloading]
version = "0.5.2"
[features]
default = []

0
third_party/rust/ash/output поставляемый
Просмотреть файл

527
third_party/rust/ash/src/device.rs поставляемый

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

105
third_party/rust/ash/src/entry.rs поставляемый
Просмотреть файл

@ -1,34 +1,34 @@
use instance::Instance;
use prelude::*;
use shared_library::dynamic_library::DynamicLibrary;
use crate::instance::Instance;
use crate::prelude::*;
use crate::vk;
use crate::RawPtr;
use libloading::Library;
use std::error::Error;
use std::fmt;
use std::io;
use std::mem;
use std::os::raw::c_char;
use std::os::raw::c_void;
use std::path::Path;
use std::ptr;
use std::sync::Arc;
use vk;
use RawPtr;
#[cfg(windows)]
const LIB_PATH: &'static str = "vulkan-1.dll";
const LIB_PATH: &str = "vulkan-1.dll";
#[cfg(all(
unix,
not(any(target_os = "macos", target_os = "ios", target_os = "android"))
))]
const LIB_PATH: &'static str = "libvulkan.so.1";
const LIB_PATH: &str = "libvulkan.so.1";
#[cfg(target_os = "android")]
const LIB_PATH: &'static str = "libvulkan.so";
const LIB_PATH: &str = "libvulkan.so";
#[cfg(any(target_os = "macos", target_os = "ios"))]
const LIB_PATH: &'static str = "libvulkan.dylib";
const LIB_PATH: &str = "libvulkan.dylib";
/// Function loader
pub type Entry = EntryCustom<Arc<DynamicLibrary>>;
pub type Entry = EntryCustom<Arc<Library>>;
/// Function loader
#[derive(Clone)]
@ -36,12 +36,13 @@ pub struct EntryCustom<L> {
static_fn: vk::StaticFn,
entry_fn_1_0: vk::EntryFnV1_0,
entry_fn_1_1: vk::EntryFnV1_1,
entry_fn_1_2: vk::EntryFnV1_2,
lib: L,
}
#[derive(Debug)]
pub enum LoadingError {
LibraryLoadError(String),
LibraryLoadError(io::Error),
}
impl fmt::Display for LoadingError {
@ -54,7 +55,7 @@ impl fmt::Display for LoadingError {
impl Error for LoadingError {}
#[derive(Debug)]
#[derive(Clone, Debug)]
pub enum InstanceError {
LoadError(Vec<&'static str>),
VkError(vk::Result),
@ -76,14 +77,19 @@ pub trait EntryV1_0 {
type Instance;
fn fp_v1_0(&self) -> &vk::EntryFnV1_0;
fn static_fn(&self) -> &vk::StaticFn;
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreateInstance.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateInstance.html>"]
///
/// # Safety
/// In order for the created `Instance` to be valid for the duration of its
/// usage, the `Entry` this was called on must be dropped later than the
/// resulting `Instance`.
unsafe fn create_instance(
&self,
create_info: &vk::InstanceCreateInfo,
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> Result<Self::Instance, InstanceError>;
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkEnumerateInstanceLayerProperties.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkEnumerateInstanceLayerProperties.html>"]
fn enumerate_instance_layer_properties(&self) -> VkResult<Vec<vk::LayerProperties>> {
unsafe {
let mut num = 0;
@ -102,7 +108,7 @@ pub trait EntryV1_0 {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkEnumerateInstanceExtensionProperties.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkEnumerateInstanceExtensionProperties.html>"]
fn enumerate_instance_extension_properties(&self) -> VkResult<Vec<vk::ExtensionProperties>> {
unsafe {
let mut num = 0;
@ -125,25 +131,30 @@ pub trait EntryV1_0 {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetInstanceProcAddr.html>"]
fn get_instance_proc_addr(
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetInstanceProcAddr.html>"]
unsafe fn get_instance_proc_addr(
&self,
instance: vk::Instance,
p_name: *const c_char,
) -> vk::PFN_vkVoidFunction {
unsafe { self.static_fn().get_instance_proc_addr(instance, p_name) }
self.static_fn().get_instance_proc_addr(instance, p_name)
}
}
impl<L> EntryV1_0 for EntryCustom<L> {
type Instance = Instance;
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreateInstance.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateInstance.html>"]
///
/// # Safety
/// In order for the created `Instance` to be valid for the duration of its
/// usage, the `Entry` this was called on must be dropped later than the
/// resulting `Instance`.
unsafe fn create_instance(
&self,
create_info: &vk::InstanceCreateInfo,
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> Result<Self::Instance, InstanceError> {
let mut instance: vk::Instance = mem::uninitialized();
let mut instance: vk::Instance = mem::zeroed();
let err_code = self.fp_v1_0().create_instance(
create_info,
allocation_callbacks.as_raw_ptr(),
@ -166,7 +177,8 @@ impl<L> EntryV1_0 for EntryCustom<L> {
pub trait EntryV1_1: EntryV1_0 {
fn fp_v1_1(&self) -> &vk::EntryFnV1_1;
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkEnumerateInstanceVersion.html>"]
#[deprecated = "This function is unavailable and therefore panics on Vulkan 1.0, please use `try_enumerate_instance_version` instead"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkEnumerateInstanceVersion.html>"]
fn enumerate_instance_version(&self) -> VkResult<u32> {
unsafe {
let mut api_version = 0;
@ -179,15 +191,30 @@ pub trait EntryV1_1: EntryV1_0 {
}
}
impl EntryCustom<Arc<DynamicLibrary>> {
impl<L> EntryV1_1 for EntryCustom<L> {
fn fp_v1_1(&self) -> &vk::EntryFnV1_1 {
&self.entry_fn_1_1
}
}
#[allow(non_camel_case_types)]
pub trait EntryV1_2: EntryV1_1 {
fn fp_v1_2(&self) -> &vk::EntryFnV1_2;
}
impl<L> EntryV1_2 for EntryCustom<L> {
fn fp_v1_2(&self) -> &vk::EntryFnV1_2 {
&self.entry_fn_1_2
}
}
impl EntryCustom<Arc<Library>> {
/// ```rust,no_run
/// # #[macro_use]
/// # extern crate ash;
/// use ash::{vk, Entry, version::EntryV1_0};
/// # fn main() -> Result<(), Box<std::error::Error>> {
/// let entry = Entry::new()?;
/// let app_info = vk::ApplicationInfo {
/// api_version: vk_make_version!(1, 0, 0),
/// api_version: vk::make_version(1, 0, 0),
/// ..Default::default()
/// };
/// let create_info = vk::InstanceCreateInfo {
@ -200,13 +227,14 @@ impl EntryCustom<Arc<DynamicLibrary>> {
pub fn new() -> Result<Entry, LoadingError> {
Self::new_custom(
|| {
DynamicLibrary::open(Some(&Path::new(LIB_PATH)))
.map_err(|err| LoadingError::LibraryLoadError(err.clone()))
.map(|dl| Arc::new(dl))
Library::new(&LIB_PATH)
.map_err(LoadingError::LibraryLoadError)
.map(Arc::new)
},
|vk_lib, name| unsafe {
vk_lib
.symbol(&*name.to_string_lossy())
.get(name.to_bytes_with_nul())
.map(|symbol| *symbol)
.unwrap_or(ptr::null_mut())
},
)
@ -230,27 +258,30 @@ impl<L> EntryCustom<L> {
mem::transmute(static_fn.get_instance_proc_addr(vk::Instance::null(), name.as_ptr()))
});
let entry_fn_1_2 = vk::EntryFnV1_2::load(|name| unsafe {
mem::transmute(static_fn.get_instance_proc_addr(vk::Instance::null(), name.as_ptr()))
});
Ok(EntryCustom {
static_fn,
entry_fn_1_0,
entry_fn_1_1,
entry_fn_1_2,
lib,
})
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkEnumerateInstanceVersion.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkEnumerateInstanceVersion.html>"]
/// ```rust,no_run
/// # #[macro_use]
/// # extern crate ash;
/// # use ash::Entry;
/// # use ash::{Entry, vk};
/// # fn main() -> Result<(), Box<std::error::Error>> {
/// let entry = Entry::new()?;
/// match entry.try_enumerate_instance_version()? {
/// // Vulkan 1.1+
/// Some(version) => {
/// let major = vk_version_major!(version);
/// let minor = vk_version_minor!(version);
/// let patch = vk_version_patch!(version);
/// let major = vk::version_major(version);
/// let minor = vk::version_minor(version);
/// let patch = vk::version_patch(version);
/// },
/// // Vulkan 1.0
/// None => {},

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

@ -1,3 +1,5 @@
#![allow(clippy::unreadable_literal)]
/*
***********************************************************************************************************************
*
@ -23,9 +25,9 @@
*
**********************************************************************************************************************/
use crate::vk::*;
use std::fmt;
use std::os::raw::*;
use vk::*;
// Extension: `VK_AMD_gpa_interface`

22
third_party/rust/ash/src/extensions/ext/debug_marker.rs поставляемый Normal file → Executable file
Просмотреть файл

@ -1,9 +1,9 @@
#![allow(dead_code)]
use prelude::*;
use crate::prelude::*;
use crate::version::{DeviceV1_0, InstanceV1_0};
use crate::vk;
use std::ffi::CStr;
use std::mem;
use version::{DeviceV1_0, InstanceV1_0};
use vk;
#[derive(Clone)]
pub struct DebugMarker {
@ -15,16 +15,14 @@ impl DebugMarker {
let debug_marker_fn = vk::ExtDebugMarkerFn::load(|name| unsafe {
mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr()))
});
DebugMarker {
debug_marker_fn: debug_marker_fn,
}
DebugMarker { debug_marker_fn }
}
pub fn name() -> &'static CStr {
vk::ExtDebugMarkerFn::name()
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkDebugMarkerSetObjectNameEXT.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkDebugMarkerSetObjectNameEXT.html>"]
pub unsafe fn debug_marker_set_object_name(
&self,
device: vk::Device,
@ -39,7 +37,7 @@ impl DebugMarker {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdDebugMarkerBeginEXT.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdDebugMarkerBeginEXT.html>"]
pub unsafe fn cmd_debug_marker_begin(
&self,
command_buffer: vk::CommandBuffer,
@ -49,13 +47,13 @@ impl DebugMarker {
.cmd_debug_marker_begin_ext(command_buffer, marker_info);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdDebugMarkerEndEXT.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdDebugMarkerEndEXT.html>"]
pub unsafe fn cmd_debug_marker_end(&self, command_buffer: vk::CommandBuffer) {
self.debug_marker_fn
.cmd_debug_marker_end_ext(command_buffer);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdDebugMarkerInsertEXT.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdDebugMarkerInsertEXT.html>"]
pub unsafe fn cmd_debug_marker_insert(
&self,
command_buffer: vk::CommandBuffer,
@ -64,4 +62,8 @@ impl DebugMarker {
self.debug_marker_fn
.cmd_debug_marker_insert_ext(command_buffer, marker_info);
}
pub fn fp(&self) -> &vk::ExtDebugMarkerFn {
&self.debug_marker_fn
}
}

22
third_party/rust/ash/src/extensions/ext/debug_report.rs поставляемый Normal file → Executable file
Просмотреть файл

@ -1,10 +1,10 @@
#![allow(dead_code)]
use prelude::*;
use crate::prelude::*;
use crate::version::{EntryV1_0, InstanceV1_0};
use crate::vk;
use crate::RawPtr;
use std::ffi::CStr;
use std::mem;
use version::{EntryV1_0, InstanceV1_0};
use vk;
use RawPtr;
#[derive(Clone)]
pub struct DebugReport {
@ -27,7 +27,7 @@ impl DebugReport {
vk::ExtDebugReportFn::name()
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkDestroyDebugReportCallbackEXT.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkDestroyDebugReportCallbackEXT.html>"]
pub unsafe fn destroy_debug_report_callback(
&self,
debug: vk::DebugReportCallbackEXT,
@ -40,13 +40,13 @@ impl DebugReport {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreateDebugReportCallbackEXT.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateDebugReportCallbackEXT.html>"]
pub unsafe fn create_debug_report_callback(
&self,
create_info: &vk::DebugReportCallbackCreateInfoEXT,
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::DebugReportCallbackEXT> {
let mut debug_cb = mem::uninitialized();
let mut debug_cb = mem::zeroed();
let err_code = self.debug_report_fn.create_debug_report_callback_ext(
self.handle,
create_info,
@ -58,4 +58,12 @@ impl DebugReport {
_ => Err(err_code),
}
}
pub fn fp(&self) -> &vk::ExtDebugReportFn {
&self.debug_report_fn
}
pub fn instance(&self) -> vk::Instance {
self.handle
}
}

38
third_party/rust/ash/src/extensions/ext/debug_utils.rs поставляемый Normal file → Executable file
Просмотреть файл

@ -1,9 +1,9 @@
#![allow(dead_code)]
use prelude::*;
use crate::prelude::*;
use crate::version::{EntryV1_0, InstanceV1_0};
use crate::{vk, RawPtr};
use std::ffi::CStr;
use std::mem;
use version::{EntryV1_0, InstanceV1_0};
use {vk, RawPtr};
#[derive(Clone)]
pub struct DebugUtils {
@ -26,7 +26,7 @@ impl DebugUtils {
vk::ExtDebugUtilsFn::name()
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkSetDebugUtilsObjectNameEXT.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkSetDebugUtilsObjectNameEXT.html>"]
pub unsafe fn debug_utils_set_object_name(
&self,
device: vk::Device,
@ -41,7 +41,7 @@ impl DebugUtils {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkSetDebugUtilsObjectTagEXT.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkSetDebugUtilsObjectTagEXT.html>"]
pub unsafe fn debug_utils_set_object_tag(
&self,
device: vk::Device,
@ -56,7 +56,7 @@ impl DebugUtils {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdBeginDebugUtilsLabelEXT.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdBeginDebugUtilsLabelEXT.html>"]
pub unsafe fn cmd_begin_debug_utils_label(
&self,
command_buffer: vk::CommandBuffer,
@ -66,13 +66,13 @@ impl DebugUtils {
.cmd_begin_debug_utils_label_ext(command_buffer, label);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdEndDebugUtilsLabelEXT.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdEndDebugUtilsLabelEXT.html>"]
pub unsafe fn cmd_end_debug_utils_label(&self, command_buffer: vk::CommandBuffer) {
self.debug_utils_fn
.cmd_end_debug_utils_label_ext(command_buffer);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdInsertDebugUtilsLabelEXT.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdInsertDebugUtilsLabelEXT.html>"]
pub unsafe fn cmd_insert_debug_utils_label(
&self,
command_buffer: vk::CommandBuffer,
@ -82,7 +82,7 @@ impl DebugUtils {
.cmd_insert_debug_utils_label_ext(command_buffer, label);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkQueueBeginDebugUtilsLabelEXT.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkQueueBeginDebugUtilsLabelEXT.html>"]
pub unsafe fn queue_begin_debug_utils_label(
&self,
queue: vk::Queue,
@ -92,12 +92,12 @@ impl DebugUtils {
.queue_begin_debug_utils_label_ext(queue, label);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkQueueEndDebugUtilsLabelEXT.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkQueueEndDebugUtilsLabelEXT.html>"]
pub unsafe fn queue_end_debug_utils_label(&self, queue: vk::Queue) {
self.debug_utils_fn.queue_end_debug_utils_label_ext(queue);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkQueueInsertDebugUtilsLabelEXT.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkQueueInsertDebugUtilsLabelEXT.html>"]
pub unsafe fn queue_insert_debug_utils_label(
&self,
queue: vk::Queue,
@ -107,13 +107,13 @@ impl DebugUtils {
.queue_insert_debug_utils_label_ext(queue, label);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreateDebugUtilsMessengerEXT.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateDebugUtilsMessengerEXT.html>"]
pub unsafe fn create_debug_utils_messenger(
&self,
create_info: &vk::DebugUtilsMessengerCreateInfoEXT,
allocator: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::DebugUtilsMessengerEXT> {
let mut messenger = mem::uninitialized();
let mut messenger = mem::zeroed();
let err_code = self.debug_utils_fn.create_debug_utils_messenger_ext(
self.handle,
create_info,
@ -126,7 +126,7 @@ impl DebugUtils {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkDestroyDebugUtilsMessengerEXT.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkDestroyDebugUtilsMessengerEXT.html>"]
pub unsafe fn destroy_debug_utils_messenger(
&self,
messenger: vk::DebugUtilsMessengerEXT,
@ -139,7 +139,7 @@ impl DebugUtils {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkSubmitDebugUtilsMessageEXT.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkSubmitDebugUtilsMessageEXT.html>"]
pub unsafe fn submit_debug_utils_message(
&self,
instance: vk::Instance,
@ -154,4 +154,12 @@ impl DebugUtils {
callback_data,
);
}
pub fn fp(&self) -> &vk::ExtDebugUtilsFn {
&self.debug_utils_fn
}
pub fn instance(&self) -> vk::Instance {
self.handle
}
}

20
third_party/rust/ash/src/extensions/khr/android_surface.rs поставляемый Normal file → Executable file
Просмотреть файл

@ -1,10 +1,10 @@
#![allow(dead_code)]
use prelude::*;
use crate::prelude::*;
use crate::version::{EntryV1_0, InstanceV1_0};
use crate::vk;
use crate::RawPtr;
use std::ffi::CStr;
use std::mem;
use version::{EntryV1_0, InstanceV1_0};
use vk;
use RawPtr;
#[derive(Clone)]
pub struct AndroidSurface {
@ -27,13 +27,13 @@ impl AndroidSurface {
vk::KhrAndroidSurfaceFn::name()
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreateAndroidSurfaceKHR.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateAndroidSurfaceKHR.html>"]
pub unsafe fn create_android_surface(
&self,
create_info: &vk::AndroidSurfaceCreateInfoKHR,
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::SurfaceKHR> {
let mut surface = mem::uninitialized();
let mut surface = mem::zeroed();
let err_code = self.android_surface_fn.create_android_surface_khr(
self.handle,
create_info,
@ -45,4 +45,12 @@ impl AndroidSurface {
_ => Err(err_code),
}
}
pub fn fp(&self) -> &vk::KhrAndroidSurfaceFn {
&self.android_surface_fn
}
pub fn instance(&self) -> vk::Instance {
self.handle
}
}

203
third_party/rust/ash/src/extensions/khr/display.rs поставляемый Executable file
Просмотреть файл

@ -0,0 +1,203 @@
use crate::prelude::*;
use crate::version::{EntryV1_0, InstanceV1_0};
use crate::vk;
use crate::RawPtr;
use std::ffi::CStr;
use std::mem;
use std::ptr;
#[derive(Clone)]
pub struct Display {
handle: vk::Instance,
display_fn: vk::KhrDisplayFn,
}
impl Display {
pub fn new<E: EntryV1_0, I: InstanceV1_0>(entry: &E, instance: &I) -> Display {
let display_fn = vk::KhrDisplayFn::load(|name| unsafe {
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))
});
Display {
handle: instance.handle(),
display_fn,
}
}
pub fn name() -> &'static CStr {
vk::KhrDisplayFn::name()
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceDisplayPropertiesKHR.html>"]
pub unsafe fn get_physical_device_display_properties(
&self,
physical_device: vk::PhysicalDevice,
) -> VkResult<Vec<vk::DisplayPropertiesKHR>> {
let mut count = 0;
self.display_fn.get_physical_device_display_properties_khr(
physical_device,
&mut count,
ptr::null_mut(),
);
let mut v = Vec::with_capacity(count as usize);
let err_code = self.display_fn.get_physical_device_display_properties_khr(
physical_device,
&mut count,
v.as_mut_ptr(),
);
v.set_len(count as usize);
match err_code {
vk::Result::SUCCESS => Ok(v),
_ => Err(err_code),
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceDisplayPlanePropertiesKHR.html>"]
pub unsafe fn get_physical_device_display_plane_properties(
&self,
physical_device: vk::PhysicalDevice,
) -> VkResult<Vec<vk::DisplayPlanePropertiesKHR>> {
let mut count = 0;
self.display_fn
.get_physical_device_display_plane_properties_khr(
physical_device,
&mut count,
ptr::null_mut(),
);
let mut v = Vec::with_capacity(count as usize);
let err_code = self
.display_fn
.get_physical_device_display_plane_properties_khr(
physical_device,
&mut count,
v.as_mut_ptr(),
);
v.set_len(count as usize);
match err_code {
vk::Result::SUCCESS => Ok(v),
_ => Err(err_code),
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetDisplayPlaneSupportedDisplaysKHR.html>"]
pub unsafe fn get_display_plane_supported_displays(
&self,
physical_device: vk::PhysicalDevice,
plane_index: u32,
) -> VkResult<Vec<vk::DisplayKHR>> {
let mut count = 0;
self.display_fn.get_display_plane_supported_displays_khr(
physical_device,
plane_index,
&mut count,
ptr::null_mut(),
);
let mut v = Vec::with_capacity(count as usize);
let err_code = self.display_fn.get_display_plane_supported_displays_khr(
physical_device,
plane_index,
&mut count,
v.as_mut_ptr(),
);
v.set_len(count as usize);
match err_code {
vk::Result::SUCCESS => Ok(v),
_ => Err(err_code),
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetDisplayModePropertiesKHR.html>"]
pub unsafe fn get_display_mode_properties(
&self,
physical_device: vk::PhysicalDevice,
display: vk::DisplayKHR,
) -> VkResult<Vec<vk::DisplayModePropertiesKHR>> {
let mut count = 0;
self.display_fn.get_display_mode_properties_khr(
physical_device,
display,
&mut count,
ptr::null_mut(),
);
let mut v = Vec::with_capacity(count as usize);
let err_code = self.display_fn.get_display_mode_properties_khr(
physical_device,
display,
&mut count,
v.as_mut_ptr(),
);
v.set_len(count as usize);
match err_code {
vk::Result::SUCCESS => Ok(v),
_ => Err(err_code),
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateDisplayModeKHR.html>"]
pub unsafe fn create_display_mode(
&self,
physical_device: vk::PhysicalDevice,
display: vk::DisplayKHR,
create_info: &vk::DisplayModeCreateInfoKHR,
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::DisplayModeKHR> {
let mut display_mode = mem::MaybeUninit::zeroed();
let err_code = self.display_fn.create_display_mode_khr(
physical_device,
display,
create_info,
allocation_callbacks.as_raw_ptr(),
display_mode.as_mut_ptr(),
);
match err_code {
vk::Result::SUCCESS => Ok(display_mode.assume_init()),
_ => Err(err_code),
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetDisplayPlaneCapabilitiesKHR.html>"]
pub unsafe fn get_display_plane_capabilities(
&self,
physical_device: vk::PhysicalDevice,
mode: vk::DisplayModeKHR,
plane_index: u32,
) -> VkResult<vk::DisplayPlaneCapabilitiesKHR> {
let mut display_plane_capabilities = mem::MaybeUninit::zeroed();
let err_code = self.display_fn.get_display_plane_capabilities_khr(
physical_device,
mode,
plane_index,
display_plane_capabilities.as_mut_ptr(),
);
match err_code {
vk::Result::SUCCESS => Ok(display_plane_capabilities.assume_init()),
_ => Err(err_code),
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateDisplayPlaneSurfaceKHR.html>"]
pub unsafe fn create_display_plane_surface(
&self,
create_info: &vk::DisplaySurfaceCreateInfoKHR,
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::SurfaceKHR> {
let mut surface = mem::MaybeUninit::zeroed();
let err_code = self.display_fn.create_display_plane_surface_khr(
self.handle,
create_info,
allocation_callbacks.as_raw_ptr(),
surface.as_mut_ptr(),
);
match err_code {
vk::Result::SUCCESS => Ok(surface.assume_init()),
_ => Err(err_code),
}
}
pub fn fp(&self) -> &vk::KhrDisplayFn {
&self.display_fn
}
pub fn instance(&self) -> vk::Instance {
self.handle
}
}

20
third_party/rust/ash/src/extensions/khr/display_swapchain.rs поставляемый Normal file → Executable file
Просмотреть файл

@ -1,10 +1,10 @@
#![allow(dead_code)]
use prelude::*;
use crate::prelude::*;
use crate::version::{DeviceV1_0, InstanceV1_0};
use crate::vk;
use crate::RawPtr;
use std::ffi::CStr;
use std::mem;
use version::{DeviceV1_0, InstanceV1_0};
use vk;
use RawPtr;
#[derive(Clone)]
pub struct DisplaySwapchain {
@ -19,7 +19,7 @@ impl DisplaySwapchain {
});
DisplaySwapchain {
handle: device.handle(),
swapchain_fn: swapchain_fn,
swapchain_fn,
}
}
@ -27,7 +27,7 @@ impl DisplaySwapchain {
vk::KhrDisplaySwapchainFn::name()
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreateSharedSwapchainsKHR.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateSharedSwapchainsKHR.html>"]
pub unsafe fn create_shared_swapchains(
&self,
create_infos: &[vk::SwapchainCreateInfoKHR],
@ -47,4 +47,12 @@ impl DisplaySwapchain {
_ => Err(err_code),
}
}
pub fn fp(&self) -> &vk::KhrDisplaySwapchainFn {
&self.swapchain_fn
}
pub fn device(&self) -> vk::Device {
self.handle
}
}

66
third_party/rust/ash/src/extensions/khr/external_memory_fd.rs поставляемый Normal file
Просмотреть файл

@ -0,0 +1,66 @@
use crate::prelude::*;
use crate::version::{DeviceV1_0, InstanceV1_0};
use crate::vk;
use std::ffi::CStr;
use std::mem;
#[derive(Clone)]
pub struct ExternalMemoryFd {
handle: vk::Device,
external_memory_fd_fn: vk::KhrExternalMemoryFdFn,
}
impl ExternalMemoryFd {
pub fn new<I: InstanceV1_0, D: DeviceV1_0>(instance: &I, device: &D) -> Self {
let external_memory_fd_fn = vk::KhrExternalMemoryFdFn::load(|name| unsafe {
mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr()))
});
Self {
handle: device.handle(),
external_memory_fd_fn,
}
}
pub fn name() -> &'static CStr {
vk::KhrExternalMemoryFdFn::name()
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetMemoryFdKHR.html>"]
pub unsafe fn get_memory_fd(&self, create_info: &vk::MemoryGetFdInfoKHR) -> VkResult<i32> {
let mut fd = -1;
let err_code =
self.external_memory_fd_fn
.get_memory_fd_khr(self.handle, create_info, &mut fd);
match err_code {
vk::Result::SUCCESS => Ok(fd),
_ => Err(err_code),
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetMemoryFdPropertiesKHR.html>"]
pub unsafe fn get_memory_fd_properties_khr(
&self,
handle_type: vk::ExternalMemoryHandleTypeFlags,
fd: i32,
) -> VkResult<vk::MemoryFdPropertiesKHR> {
let mut memory_fd_properties = mem::zeroed();
let err_code = self.external_memory_fd_fn.get_memory_fd_properties_khr(
self.handle,
handle_type,
fd,
&mut memory_fd_properties,
);
match err_code {
vk::Result::SUCCESS => Ok(memory_fd_properties),
_ => Err(err_code),
}
}
pub fn fp(&self) -> &vk::KhrExternalMemoryFdFn {
&self.external_memory_fd_fn
}
pub fn device(&self) -> vk::Device {
self.handle
}
}

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

@ -1,16 +1,26 @@
pub use self::android_surface::AndroidSurface;
pub use self::display::Display;
pub use self::display_swapchain::DisplaySwapchain;
pub use self::external_memory_fd::ExternalMemoryFd;
pub use self::push_descriptor::PushDescriptor;
pub use self::ray_tracing::RayTracing;
pub use self::surface::Surface;
pub use self::swapchain::Swapchain;
pub use self::timeline_semaphore::TimelineSemaphore;
pub use self::wayland_surface::WaylandSurface;
pub use self::win32_surface::Win32Surface;
pub use self::xcb_surface::XcbSurface;
pub use self::xlib_surface::XlibSurface;
mod android_surface;
mod display;
mod display_swapchain;
mod external_memory_fd;
mod push_descriptor;
mod ray_tracing;
mod surface;
mod swapchain;
mod timeline_semaphore;
mod wayland_surface;
mod win32_surface;
mod xcb_surface;

75
third_party/rust/ash/src/extensions/khr/push_descriptor.rs поставляемый Normal file
Просмотреть файл

@ -0,0 +1,75 @@
#![allow(dead_code)]
use crate::version::{DeviceV1_0, InstanceV1_0};
use crate::vk;
use std::ffi::c_void;
use std::ffi::CStr;
use std::mem;
#[derive(Clone)]
pub struct PushDescriptor {
handle: vk::Instance,
push_descriptors_fn: vk::KhrPushDescriptorFn,
}
impl PushDescriptor {
pub fn new<I: InstanceV1_0, D: DeviceV1_0>(instance: &I, device: &D) -> PushDescriptor {
let push_descriptors_fn = vk::KhrPushDescriptorFn::load(|name| unsafe {
mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr()))
});
PushDescriptor {
handle: instance.handle(),
push_descriptors_fn,
}
}
pub fn name() -> &'static CStr {
vk::KhrPushDescriptorFn::name()
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdPushDescriptorSetKHR.html>"]
pub unsafe fn cmd_push_descriptor_set(
&self,
command_buffer: vk::CommandBuffer,
pipeline_bind_point: vk::PipelineBindPoint,
layout: vk::PipelineLayout,
set: u32,
descriptor_writes: &[vk::WriteDescriptorSet],
) {
self.push_descriptors_fn.cmd_push_descriptor_set_khr(
command_buffer,
pipeline_bind_point,
layout,
set,
descriptor_writes.len() as u32,
descriptor_writes.as_ptr(),
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdPushDescriptorSetWithTemplateKHR.html>"]
pub unsafe fn cmd_push_descriptor_set_with_template(
&self,
command_buffer: vk::CommandBuffer,
descriptor_update_template: vk::DescriptorUpdateTemplate,
layout: vk::PipelineLayout,
set: u32,
p_data: *const c_void,
) {
self.push_descriptors_fn
.cmd_push_descriptor_set_with_template_khr(
command_buffer,
descriptor_update_template,
layout,
set,
p_data,
);
}
pub fn fp(&self) -> &vk::KhrPushDescriptorFn {
&self.push_descriptors_fn
}
pub fn instance(&self) -> vk::Instance {
self.handle
}
}

369
third_party/rust/ash/src/extensions/khr/ray_tracing.rs поставляемый Normal file
Просмотреть файл

@ -0,0 +1,369 @@
#![allow(dead_code)]
use crate::prelude::*;
use crate::version::{DeviceV1_0, InstanceV1_0, InstanceV1_1};
use crate::vk;
use crate::RawPtr;
use std::ffi::CStr;
use std::mem;
#[derive(Clone)]
pub struct RayTracing {
handle: vk::Device,
ray_tracing_fn: vk::KhrRayTracingFn,
}
impl RayTracing {
pub fn new<I: InstanceV1_0, D: DeviceV1_0>(instance: &I, device: &D) -> RayTracing {
let ray_tracing_fn = vk::KhrRayTracingFn::load(|name| unsafe {
mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr()))
});
RayTracing {
handle: device.handle(),
ray_tracing_fn,
}
}
pub unsafe fn get_properties<I: InstanceV1_1>(
instance: &I,
pdevice: vk::PhysicalDevice,
) -> vk::PhysicalDeviceRayTracingPropertiesKHR {
let mut props_rt = vk::PhysicalDeviceRayTracingPropertiesKHR::default();
{
let mut props = vk::PhysicalDeviceProperties2::builder().push_next(&mut props_rt);
instance.get_physical_device_properties2(pdevice, &mut props);
}
props_rt
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateAccelerationStructureKHR.html>"]
pub unsafe fn create_acceleration_structure(
&self,
create_info: &vk::AccelerationStructureCreateInfoKHR,
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::AccelerationStructureKHR> {
let mut accel_struct = mem::zeroed();
let err_code = self.ray_tracing_fn.create_acceleration_structure_khr(
self.handle,
create_info,
allocation_callbacks.as_raw_ptr(),
&mut accel_struct,
);
match err_code {
vk::Result::SUCCESS => Ok(accel_struct),
_ => Err(err_code),
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkDestroyAccelerationStructureKHR.html>"]
pub unsafe fn destroy_acceleration_structure(
&self,
accel_struct: vk::AccelerationStructureKHR,
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) {
self.ray_tracing_fn.destroy_acceleration_structure_khr(
self.handle,
accel_struct,
allocation_callbacks.as_raw_ptr(),
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetAccelerationStructureMemoryRequirementsKHR.html>"]
pub unsafe fn get_acceleration_structure_memory_requirements(
&self,
info: &vk::AccelerationStructureMemoryRequirementsInfoKHR,
) -> vk::MemoryRequirements2KHR {
let mut requirements = mem::zeroed();
self.ray_tracing_fn
.get_acceleration_structure_memory_requirements_khr(
self.handle,
info,
&mut requirements,
);
requirements
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkBindAccelerationStructureMemoryKHR.html>"]
pub unsafe fn bind_acceleration_structure_memory(
&self,
bind_info: &[vk::BindAccelerationStructureMemoryInfoKHR],
) -> VkResult<()> {
let err_code = self.ray_tracing_fn.bind_acceleration_structure_memory_khr(
self.handle,
bind_info.len() as u32,
bind_info.as_ptr(),
);
match err_code {
vk::Result::SUCCESS => Ok(()),
_ => Err(err_code),
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdBuildAccelerationStructureKHR.html>"]
pub unsafe fn cmd_build_acceleration_structure(
&self,
command_buffer: vk::CommandBuffer,
infos: &[vk::AccelerationStructureBuildGeometryInfoKHR],
offset_infos: &[&[vk::AccelerationStructureBuildOffsetInfoKHR]],
) {
let offset_info_ptr = offset_infos
.iter()
.map(|slice| slice.as_ptr())
.collect::<Vec<*const vk::AccelerationStructureBuildOffsetInfoKHR>>();
self.ray_tracing_fn.cmd_build_acceleration_structure_khr(
command_buffer,
infos.len() as u32,
infos.as_ptr(),
offset_info_ptr.as_ptr(),
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdCopyAccelerationStructureKHR.html>"]
pub unsafe fn cmd_copy_acceleration_structure(
&self,
command_buffer: vk::CommandBuffer,
info: &vk::CopyAccelerationStructureInfoKHR,
) {
self.ray_tracing_fn
.cmd_copy_acceleration_structure_khr(command_buffer, info);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdTraceRaysKHR.html>"]
pub unsafe fn cmd_trace_rays(
&self,
command_buffer: vk::CommandBuffer,
raygen_shader_binding_tables: &[vk::StridedBufferRegionKHR],
miss_shader_binding_tables: &[vk::StridedBufferRegionKHR],
hit_shader_binding_tables: &[vk::StridedBufferRegionKHR],
callable_shader_binding_tables: &[vk::StridedBufferRegionKHR],
width: u32,
height: u32,
depth: u32,
) {
self.ray_tracing_fn.cmd_trace_rays_khr(
command_buffer,
raygen_shader_binding_tables.as_ptr(),
miss_shader_binding_tables.as_ptr(),
hit_shader_binding_tables.as_ptr(),
callable_shader_binding_tables.as_ptr(),
width,
height,
depth,
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateRayTracingPipelinesKHR.html>"]
pub unsafe fn create_ray_tracing_pipelines(
&self,
pipeline_cache: vk::PipelineCache,
create_info: &[vk::RayTracingPipelineCreateInfoKHR],
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<Vec<vk::Pipeline>> {
let mut pipelines = vec![mem::zeroed(); create_info.len()];
let err_code = self.ray_tracing_fn.create_ray_tracing_pipelines_khr(
self.handle,
pipeline_cache,
create_info.len() as u32,
create_info.as_ptr(),
allocation_callbacks.as_raw_ptr(),
pipelines.as_mut_ptr(),
);
match err_code {
vk::Result::SUCCESS => Ok(pipelines),
_ => Err(err_code),
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetRayTracingShaderGroupHandlesKHR.html>"]
pub unsafe fn get_ray_tracing_shader_group_handles(
&self,
pipeline: vk::Pipeline,
first_group: u32,
group_count: u32,
data: &mut [u8],
) -> VkResult<()> {
let err_code = self
.ray_tracing_fn
.get_ray_tracing_shader_group_handles_khr(
self.handle,
pipeline,
first_group,
group_count,
data.len(),
data.as_mut_ptr() as *mut std::ffi::c_void,
);
match err_code {
vk::Result::SUCCESS => Ok(()),
_ => Err(err_code),
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetAccelerationStructureHandleKHR.html>"]
pub unsafe fn get_acceleration_structure_device_address(
&self,
info: &vk::AccelerationStructureDeviceAddressInfoKHR,
) -> vk::DeviceAddress {
self.ray_tracing_fn
.get_acceleration_structure_device_address_khr(self.handle, info)
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdWriteAccelerationStructuresPropertiesKHR.html>"]
pub unsafe fn cmd_write_acceleration_structures_properties(
&self,
command_buffer: vk::CommandBuffer,
structures: &[vk::AccelerationStructureKHR],
query_type: vk::QueryType,
query_pool: vk::QueryPool,
first_query: u32,
) {
self.ray_tracing_fn
.cmd_write_acceleration_structures_properties_khr(
command_buffer,
structures.len() as u32,
structures.as_ptr(),
query_type,
query_pool,
first_query,
);
}
pub unsafe fn cmd_build_acceleration_structure_indirect(
&self,
command_buffer: vk::CommandBuffer,
info: &vk::AccelerationStructureBuildGeometryInfoKHR,
indirect_buffer: vk::Buffer,
indirect_offset: vk::DeviceSize,
indirect_stride: u32,
) {
self.ray_tracing_fn
.cmd_build_acceleration_structure_indirect_khr(
command_buffer,
info,
indirect_buffer,
indirect_offset,
indirect_stride,
);
}
pub unsafe fn copy_acceleration_structure_to_memory(
&self,
device: vk::Device,
info: &vk::CopyAccelerationStructureToMemoryInfoKHR,
) -> VkResult<()> {
let err_code = self
.ray_tracing_fn
.copy_acceleration_structure_to_memory_khr(device, info);
match err_code {
vk::Result::SUCCESS => Ok(()),
_ => Err(err_code),
}
}
pub unsafe fn copy_memory_to_acceleration_structure(
&self,
device: vk::Device,
info: &vk::CopyMemoryToAccelerationStructureInfoKHR,
) -> VkResult<()> {
let err_code = self
.ray_tracing_fn
.copy_memory_to_acceleration_structure_khr(device, info);
match err_code {
vk::Result::SUCCESS => Ok(()),
_ => Err(err_code),
}
}
pub unsafe fn cmd_copy_acceleration_structure_to_memory(
&self,
command_buffer: vk::CommandBuffer,
info: &vk::CopyAccelerationStructureToMemoryInfoKHR,
) {
self.ray_tracing_fn
.cmd_copy_acceleration_structure_to_memory_khr(command_buffer, info);
}
pub unsafe fn cmd_copy_memory_to_acceleration_structure(
&self,
command_buffer: vk::CommandBuffer,
info: &vk::CopyMemoryToAccelerationStructureInfoKHR,
) {
self.ray_tracing_fn
.cmd_copy_memory_to_acceleration_structure_khr(command_buffer, info);
}
pub unsafe fn get_ray_tracing_capture_replay_shader_group_handles(
&self,
device: vk::Device,
pipeline: vk::Pipeline,
first_group: u32,
group_count: u32,
data_size: usize,
) -> VkResult<Vec<u8>> {
let mut data: Vec<u8> = Vec::with_capacity(data_size);
let err_code = self
.ray_tracing_fn
.get_ray_tracing_capture_replay_shader_group_handles_khr(
device,
pipeline,
first_group,
group_count,
data_size,
data.as_mut_ptr() as *mut _,
);
match err_code {
vk::Result::SUCCESS => Ok(data),
_ => Err(err_code),
}
}
pub unsafe fn cmd_trace_rays_indirect(
&self,
command_buffer: vk::CommandBuffer,
raygen_shader_binding_table: &[vk::StridedBufferRegionKHR],
miss_shader_binding_table: &[vk::StridedBufferRegionKHR],
hit_shader_binding_table: &[vk::StridedBufferRegionKHR],
callable_shader_binding_table: &[vk::StridedBufferRegionKHR],
buffer: vk::Buffer,
offset: vk::DeviceSize,
) {
self.ray_tracing_fn.cmd_trace_rays_indirect_khr(
command_buffer,
raygen_shader_binding_table.as_ptr(),
miss_shader_binding_table.as_ptr(),
hit_shader_binding_table.as_ptr(),
callable_shader_binding_table.as_ptr(),
buffer,
offset,
);
}
pub unsafe fn get_device_acceleration_structure_compatibility(
&self,
device: vk::Device,
version: &vk::AccelerationStructureVersionKHR,
) -> VkResult<()> {
let err_code = self
.ray_tracing_fn
.get_device_acceleration_structure_compatibility_khr(device, version);
match err_code {
vk::Result::SUCCESS => Ok(()),
_ => Err(err_code),
}
}
pub fn name() -> &'static CStr {
vk::KhrRayTracingFn::name()
}
pub fn fp(&self) -> &vk::KhrRayTracingFn {
&self.ray_tracing_fn
}
pub fn device(&self) -> vk::Device {
self.handle
}
}

42
third_party/rust/ash/src/extensions/khr/surface.rs поставляемый Normal file → Executable file
Просмотреть файл

@ -1,11 +1,11 @@
#![allow(dead_code)]
use prelude::*;
use crate::prelude::*;
use crate::version::{EntryV1_0, InstanceV1_0};
use crate::vk;
use crate::RawPtr;
use std::ffi::CStr;
use std::mem;
use std::ptr;
use version::{EntryV1_0, InstanceV1_0};
use vk;
use RawPtr;
#[derive(Clone)]
pub struct Surface {
@ -20,7 +20,7 @@ impl Surface {
});
Surface {
handle: instance.handle(),
surface_fn: surface_fn,
surface_fn,
}
}
@ -28,24 +28,28 @@ impl Surface {
vk::KhrSurfaceFn::name()
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetPhysicalDeviceSurfaceSupportKHR.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceSurfaceSupportKHR.html>"]
pub unsafe fn get_physical_device_surface_support(
&self,
physical_device: vk::PhysicalDevice,
queue_index: u32,
surface: vk::SurfaceKHR,
) -> bool {
let mut b = mem::uninitialized();
self.surface_fn.get_physical_device_surface_support_khr(
) -> VkResult<bool> {
let mut b = mem::zeroed();
let err_code = self.surface_fn.get_physical_device_surface_support_khr(
physical_device,
queue_index,
surface,
&mut b,
);
b > 0
match err_code {
vk::Result::SUCCESS => Ok(b > 0),
_ => Err(err_code),
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetPhysicalDeviceSurfacePresentModesKHR.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceSurfacePresentModesKHR.html>"]
pub unsafe fn get_physical_device_surface_present_modes(
&self,
physical_device: vk::PhysicalDevice,
@ -75,13 +79,13 @@ impl Surface {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetPhysicalDeviceSurfaceCapabilitiesKHR.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceSurfaceCapabilitiesKHR.html>"]
pub unsafe fn get_physical_device_surface_capabilities(
&self,
physical_device: vk::PhysicalDevice,
surface: vk::SurfaceKHR,
) -> VkResult<vk::SurfaceCapabilitiesKHR> {
let mut surface_capabilities = mem::uninitialized();
let mut surface_capabilities = mem::zeroed();
let err_code = self
.surface_fn
.get_physical_device_surface_capabilities_khr(
@ -95,7 +99,7 @@ impl Surface {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetPhysicalDeviceSurfaceFormatsKHR.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceSurfaceFormatsKHR.html>"]
pub unsafe fn get_physical_device_surface_formats(
&self,
physical_device: vk::PhysicalDevice,
@ -122,7 +126,7 @@ impl Surface {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkDestroySurfaceKHR.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkDestroySurfaceKHR.html>"]
pub unsafe fn destroy_surface(
&self,
surface: vk::SurfaceKHR,
@ -134,4 +138,12 @@ impl Surface {
allocation_callbacks.as_raw_ptr(),
);
}
pub fn fp(&self) -> &vk::KhrSurfaceFn {
&self.surface_fn
}
pub fn instance(&self) -> vk::Instance {
self.handle
}
}

32
third_party/rust/ash/src/extensions/khr/swapchain.rs поставляемый Normal file → Executable file
Просмотреть файл

@ -1,11 +1,11 @@
#![allow(dead_code)]
use prelude::*;
use crate::prelude::*;
use crate::version::{DeviceV1_0, InstanceV1_0};
use crate::vk;
use crate::RawPtr;
use std::ffi::CStr;
use std::mem;
use std::ptr;
use version::{DeviceV1_0, InstanceV1_0};
use vk;
use RawPtr;
#[derive(Clone)]
pub struct Swapchain {
@ -20,7 +20,7 @@ impl Swapchain {
});
Swapchain {
handle: device.handle(),
swapchain_fn: swapchain_fn,
swapchain_fn,
}
}
@ -28,7 +28,7 @@ impl Swapchain {
vk::KhrSwapchainFn::name()
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkDestroySwapchainKHR.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkDestroySwapchainKHR.html>"]
pub unsafe fn destroy_swapchain(
&self,
swapchain: vk::SwapchainKHR,
@ -42,7 +42,7 @@ impl Swapchain {
}
/// On success, returns the next image's index and whether the swapchain is suboptimal for the surface.
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkAcquireNextImageKHR.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkAcquireNextImageKHR.html>"]
pub unsafe fn acquire_next_image(
&self,
swapchain: vk::SwapchainKHR,
@ -50,7 +50,7 @@ impl Swapchain {
semaphore: vk::Semaphore,
fence: vk::Fence,
) -> VkResult<(u32, bool)> {
let mut index = mem::uninitialized();
let mut index = mem::zeroed();
let err_code = self.swapchain_fn.acquire_next_image_khr(
self.handle,
swapchain,
@ -66,13 +66,13 @@ impl Swapchain {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreateSwapchainKHR.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateSwapchainKHR.html>"]
pub unsafe fn create_swapchain(
&self,
create_info: &vk::SwapchainCreateInfoKHR,
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::SwapchainKHR> {
let mut swapchain = mem::uninitialized();
let mut swapchain = mem::zeroed();
let err_code = self.swapchain_fn.create_swapchain_khr(
self.handle,
create_info,
@ -86,7 +86,7 @@ impl Swapchain {
}
/// On success, returns whether the swapchain is suboptimal for the surface.
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkQueuePresentKHR.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkQueuePresentKHR.html>"]
pub unsafe fn queue_present(
&self,
queue: vk::Queue,
@ -100,7 +100,7 @@ impl Swapchain {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetSwapchainImagesKHR.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetSwapchainImagesKHR.html>"]
pub unsafe fn get_swapchain_images(
&self,
swapchain: vk::SwapchainKHR,
@ -126,4 +126,12 @@ impl Swapchain {
_ => Err(err_code),
}
}
pub fn fp(&self) -> &vk::KhrSwapchainFn {
&self.swapchain_fn
}
pub fn device(&self) -> vk::Device {
self.handle
}
}

87
third_party/rust/ash/src/extensions/khr/timeline_semaphore.rs поставляемый Normal file
Просмотреть файл

@ -0,0 +1,87 @@
#![allow(dead_code)]
use crate::prelude::*;
use crate::version::{EntryV1_0, InstanceV1_0};
use crate::vk;
use std::ffi::CStr;
use std::mem;
#[derive(Clone)]
pub struct TimelineSemaphore {
handle: vk::Instance,
timeline_semaphore_fn: vk::KhrTimelineSemaphoreFn,
}
impl TimelineSemaphore {
pub fn new<E: EntryV1_0, I: InstanceV1_0>(entry: &E, instance: &I) -> TimelineSemaphore {
let timeline_semaphore_fn = vk::KhrTimelineSemaphoreFn::load(|name| unsafe {
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))
});
TimelineSemaphore {
handle: instance.handle(),
timeline_semaphore_fn,
}
}
pub fn name() -> &'static CStr {
vk::KhrTimelineSemaphoreFn::name()
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#vkGetSemaphoreCounterValueKHR>"]
pub unsafe fn get_semaphore_counter_value(
&self,
device: vk::Device,
semaphore: vk::Semaphore,
) -> VkResult<u64> {
let mut value = 0;
let err_code = self
.timeline_semaphore_fn
.get_semaphore_counter_value_khr(device, semaphore, &mut value);
match err_code {
vk::Result::SUCCESS => Ok(value),
_ => Err(err_code),
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#vkWaitSemaphoresKHR>"]
pub unsafe fn wait_semaphores(
&self,
device: vk::Device,
wait_info: &vk::SemaphoreWaitInfo,
timeout: u64,
) -> VkResult<()> {
let err_code = self
.timeline_semaphore_fn
.wait_semaphores_khr(device, wait_info, timeout);
match err_code {
vk::Result::SUCCESS => Ok(()),
_ => Err(err_code),
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#vkSignalSemaphoreKHR>"]
pub unsafe fn signal_semaphore(
&self,
device: vk::Device,
signal_info: &vk::SemaphoreSignalInfo,
) -> VkResult<()> {
let err_code = self
.timeline_semaphore_fn
.signal_semaphore_khr(device, signal_info);
match err_code {
vk::Result::SUCCESS => Ok(()),
_ => Err(err_code),
}
}
pub fn fp(&self) -> &vk::KhrTimelineSemaphoreFn {
&self.timeline_semaphore_fn
}
pub fn instance(&self) -> vk::Instance {
self.handle
}
}

38
third_party/rust/ash/src/extensions/khr/wayland_surface.rs поставляемый Normal file → Executable file
Просмотреть файл

@ -1,10 +1,10 @@
#![allow(dead_code)]
use prelude::*;
use crate::prelude::*;
use crate::version::{EntryV1_0, InstanceV1_0};
use crate::vk;
use crate::RawPtr;
use std::ffi::CStr;
use std::mem;
use version::{EntryV1_0, InstanceV1_0};
use vk;
use RawPtr;
#[derive(Clone)]
pub struct WaylandSurface {
@ -27,13 +27,13 @@ impl WaylandSurface {
vk::KhrWaylandSurfaceFn::name()
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreateWaylandSurfaceKHR.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateWaylandSurfaceKHR.html>"]
pub unsafe fn create_wayland_surface(
&self,
create_info: &vk::WaylandSurfaceCreateInfoKHR,
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::SurfaceKHR> {
let mut surface = mem::uninitialized();
let mut surface = mem::zeroed();
let err_code = self.wayland_surface_fn.create_wayland_surface_khr(
self.handle,
create_info,
@ -45,4 +45,30 @@ impl WaylandSurface {
_ => Err(err_code),
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceWaylandPresentationSupportKHR.html"]
pub unsafe fn get_physical_device_wayland_presentation_support(
&self,
physical_device: vk::PhysicalDevice,
queue_family_index: u32,
wl_display: &mut vk::wl_display,
) -> bool {
let b = self
.wayland_surface_fn
.get_physical_device_wayland_presentation_support_khr(
physical_device,
queue_family_index,
wl_display,
);
b > 0
}
pub fn fp(&self) -> &vk::KhrWaylandSurfaceFn {
&self.wayland_surface_fn
}
pub fn instance(&self) -> vk::Instance {
self.handle
}
}

36
third_party/rust/ash/src/extensions/khr/win32_surface.rs поставляемый Normal file → Executable file
Просмотреть файл

@ -1,10 +1,10 @@
#![allow(dead_code)]
use prelude::*;
use crate::prelude::*;
use crate::version::{EntryV1_0, InstanceV1_0};
use crate::vk;
use crate::RawPtr;
use std::ffi::CStr;
use std::mem;
use version::{EntryV1_0, InstanceV1_0};
use vk;
use RawPtr;
#[derive(Clone)]
pub struct Win32Surface {
@ -27,13 +27,13 @@ impl Win32Surface {
vk::KhrWin32SurfaceFn::name()
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreateWin32SurfaceKHR.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateWin32SurfaceKHR.html>"]
pub unsafe fn create_win32_surface(
&self,
create_info: &vk::Win32SurfaceCreateInfoKHR,
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::SurfaceKHR> {
let mut surface = mem::uninitialized();
let mut surface = mem::zeroed();
let err_code = self.win32_surface_fn.create_win32_surface_khr(
self.handle,
create_info,
@ -45,4 +45,28 @@ impl Win32Surface {
_ => Err(err_code),
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceWin32PresentationSupportKHR.html"]
pub unsafe fn get_physical_device_win32_presentation_support(
&self,
physical_device: vk::PhysicalDevice,
queue_family_index: u32,
) -> bool {
let b = self
.win32_surface_fn
.get_physical_device_win32_presentation_support_khr(
physical_device,
queue_family_index,
);
b > 0
}
pub fn fp(&self) -> &vk::KhrWin32SurfaceFn {
&self.win32_surface_fn
}
pub fn instance(&self) -> vk::Instance {
self.handle
}
}

40
third_party/rust/ash/src/extensions/khr/xcb_surface.rs поставляемый Normal file → Executable file
Просмотреть файл

@ -1,10 +1,10 @@
#![allow(dead_code)]
use prelude::*;
use crate::prelude::*;
use crate::version::{EntryV1_0, InstanceV1_0};
use crate::vk;
use crate::RawPtr;
use std::ffi::CStr;
use std::mem;
use version::{EntryV1_0, InstanceV1_0};
use vk;
use RawPtr;
#[derive(Clone)]
pub struct XcbSurface {
@ -27,13 +27,13 @@ impl XcbSurface {
vk::KhrXcbSurfaceFn::name()
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreateXcbSurfaceKHR.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateXcbSurfaceKHR.html>"]
pub unsafe fn create_xcb_surface(
&self,
create_info: &vk::XcbSurfaceCreateInfoKHR,
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::SurfaceKHR> {
let mut surface = mem::uninitialized();
let mut surface = mem::zeroed();
let err_code = self.xcb_surface_fn.create_xcb_surface_khr(
self.handle,
create_info,
@ -45,4 +45,32 @@ impl XcbSurface {
_ => Err(err_code),
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceXcbPresentationSupportKHR.html"]
pub unsafe fn get_physical_device_xcb_presentation_support(
&self,
physical_device: vk::PhysicalDevice,
queue_family_index: u32,
connection: &mut vk::xcb_connection_t,
visual_id: vk::xcb_visualid_t,
) -> bool {
let b = self
.xcb_surface_fn
.get_physical_device_xcb_presentation_support_khr(
physical_device,
queue_family_index,
connection,
visual_id,
);
b > 0
}
pub fn fp(&self) -> &vk::KhrXcbSurfaceFn {
&self.xcb_surface_fn
}
pub fn instance(&self) -> vk::Instance {
self.handle
}
}

40
third_party/rust/ash/src/extensions/khr/xlib_surface.rs поставляемый Normal file → Executable file
Просмотреть файл

@ -1,10 +1,10 @@
#![allow(dead_code)]
use prelude::*;
use crate::prelude::*;
use crate::version::{EntryV1_0, InstanceV1_0};
use crate::vk;
use crate::RawPtr;
use std::ffi::CStr;
use std::mem;
use version::{EntryV1_0, InstanceV1_0};
use vk;
use RawPtr;
#[derive(Clone)]
pub struct XlibSurface {
@ -27,13 +27,13 @@ impl XlibSurface {
vk::KhrXlibSurfaceFn::name()
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreateXlibSurfaceKHR.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateXlibSurfaceKHR.html>"]
pub unsafe fn create_xlib_surface(
&self,
create_info: &vk::XlibSurfaceCreateInfoKHR,
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::SurfaceKHR> {
let mut surface = mem::uninitialized();
let mut surface = mem::zeroed();
let err_code = self.xlib_surface_fn.create_xlib_surface_khr(
self.handle,
create_info,
@ -45,4 +45,32 @@ impl XlibSurface {
_ => Err(err_code),
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceXlibPresentationSupportKHR.html"]
pub unsafe fn get_physical_device_xlib_presentation_support(
&self,
physical_device: vk::PhysicalDevice,
queue_family_index: u32,
display: &mut vk::Display,
visual_id: vk::VisualID,
) -> bool {
let b = self
.xlib_surface_fn
.get_physical_device_xlib_presentation_support_khr(
physical_device,
queue_family_index,
display,
visual_id,
);
b > 0
}
pub fn fp(&self) -> &vk::KhrXlibSurfaceFn {
&self.xlib_surface_fn
}
pub fn instance(&self) -> vk::Instance {
self.handle
}
}

20
third_party/rust/ash/src/extensions/mvk/ios_surface.rs поставляемый Normal file → Executable file
Просмотреть файл

@ -1,10 +1,10 @@
#![allow(dead_code)]
use prelude::*;
use crate::prelude::*;
use crate::version::{EntryV1_0, InstanceV1_0};
use crate::vk;
use crate::RawPtr;
use std::ffi::CStr;
use std::mem;
use version::{EntryV1_0, InstanceV1_0};
use vk;
use RawPtr;
#[derive(Clone)]
pub struct IOSSurface {
@ -27,13 +27,13 @@ impl IOSSurface {
vk::MvkIosSurfaceFn::name()
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreateIOSSurfaceMVK.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateIOSSurfaceMVK.html>"]
pub unsafe fn create_ios_surface_mvk(
&self,
create_info: &vk::IOSSurfaceCreateInfoMVK,
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::SurfaceKHR> {
let mut surface = mem::uninitialized();
let mut surface = mem::zeroed();
let err_code = self.ios_surface_fn.create_ios_surface_mvk(
self.handle,
create_info,
@ -45,4 +45,12 @@ impl IOSSurface {
_ => Err(err_code),
}
}
pub fn fp(&self) -> &vk::MvkIosSurfaceFn {
&self.ios_surface_fn
}
pub fn instance(&self) -> vk::Instance {
self.handle
}
}

20
third_party/rust/ash/src/extensions/mvk/macos_surface.rs поставляемый Normal file → Executable file
Просмотреть файл

@ -1,10 +1,10 @@
#![allow(dead_code)]
use prelude::*;
use crate::prelude::*;
use crate::version::{EntryV1_0, InstanceV1_0};
use crate::vk;
use crate::RawPtr;
use std::ffi::CStr;
use std::mem;
use version::{EntryV1_0, InstanceV1_0};
use vk;
use RawPtr;
#[derive(Clone)]
pub struct MacOSSurface {
@ -27,13 +27,13 @@ impl MacOSSurface {
vk::MvkMacosSurfaceFn::name()
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreateMacOSSurfaceMVK.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateMacOSSurfaceMVK.html>"]
pub unsafe fn create_mac_os_surface_mvk(
&self,
create_info: &vk::MacOSSurfaceCreateInfoMVK,
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::SurfaceKHR> {
let mut surface = mem::uninitialized();
let mut surface = mem::zeroed();
let err_code = self.macos_surface_fn.create_mac_os_surface_mvk(
self.handle,
create_info,
@ -45,4 +45,12 @@ impl MacOSSurface {
_ => Err(err_code),
}
}
pub fn fp(&self) -> &vk::MvkMacosSurfaceFn {
&self.macos_surface_fn
}
pub fn instance(&self) -> vk::Instance {
self.handle
}
}

14
third_party/rust/ash/src/extensions/nv/mesh_shader.rs поставляемый Normal file → Executable file
Просмотреть файл

@ -1,8 +1,8 @@
#![allow(dead_code)]
use crate::version::{DeviceV1_0, InstanceV1_0};
use crate::vk;
use std::ffi::CStr;
use std::mem;
use version::{DeviceV1_0, InstanceV1_0};
use vk;
#[derive(Clone)]
pub struct MeshShader {
@ -16,7 +16,7 @@ impl MeshShader {
});
MeshShader { mesh_shader_fn }
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdDrawMeshTasksNV.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdDrawMeshTasksNV.html>"]
pub unsafe fn cmd_draw_mesh_tasks(
&self,
command_buffer: vk::CommandBuffer,
@ -26,7 +26,7 @@ impl MeshShader {
self.mesh_shader_fn
.cmd_draw_mesh_tasks_nv(command_buffer, task_count, first_task);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdDrawMeshTasksIndirectNV.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdDrawMeshTasksIndirectNV.html>"]
pub unsafe fn cmd_draw_mesh_tasks_indirect(
&self,
command_buffer: vk::CommandBuffer,
@ -43,7 +43,7 @@ impl MeshShader {
stride,
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdDrawMeshTasksIndirectCountNV.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdDrawMeshTasksIndirectCountNV.html>"]
pub unsafe fn cmd_draw_mesh_tasks_indirect_count(
&self,
command_buffer: vk::CommandBuffer,
@ -67,4 +67,8 @@ impl MeshShader {
pub fn name() -> &'static CStr {
vk::NvMeshShaderFn::name()
}
pub fn fp(&self) -> &vk::NvMeshShaderFn {
&self.mesh_shader_fn
}
}

46
third_party/rust/ash/src/extensions/nv/ray_tracing.rs поставляемый Normal file → Executable file
Просмотреть файл

@ -1,10 +1,10 @@
#![allow(dead_code)]
use prelude::*;
use crate::prelude::*;
use crate::version::{DeviceV1_0, InstanceV1_0, InstanceV1_1};
use crate::vk;
use crate::RawPtr;
use std::ffi::CStr;
use std::mem;
use version::{DeviceV1_0, InstanceV1_0, InstanceV1_1};
use vk;
use RawPtr;
#[derive(Clone)]
pub struct RayTracing {
@ -35,13 +35,13 @@ impl RayTracing {
props_rt
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreateAccelerationStructureNV.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateAccelerationStructureNV.html>"]
pub unsafe fn create_acceleration_structure(
&self,
create_info: &vk::AccelerationStructureCreateInfoNV,
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::AccelerationStructureNV> {
let mut accel_struct = mem::uninitialized();
let mut accel_struct = mem::zeroed();
let err_code = self.ray_tracing_fn.create_acceleration_structure_nv(
self.handle,
create_info,
@ -54,7 +54,7 @@ impl RayTracing {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkDestroyAccelerationStructureNV.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkDestroyAccelerationStructureNV.html>"]
pub unsafe fn destroy_acceleration_structure(
&self,
accel_struct: vk::AccelerationStructureNV,
@ -67,12 +67,12 @@ impl RayTracing {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetAccelerationStructureMemoryRequirementsNV.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetAccelerationStructureMemoryRequirementsNV.html>"]
pub unsafe fn get_acceleration_structure_memory_requirements(
&self,
info: &vk::AccelerationStructureMemoryRequirementsInfoNV,
) -> vk::MemoryRequirements2KHR {
let mut requirements = mem::uninitialized();
let mut requirements = mem::zeroed();
self.ray_tracing_fn
.get_acceleration_structure_memory_requirements_nv(
self.handle,
@ -82,7 +82,7 @@ impl RayTracing {
requirements
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkBindAccelerationStructureMemoryNV.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkBindAccelerationStructureMemoryNV.html>"]
pub unsafe fn bind_acceleration_structure_memory(
&self,
bind_info: &[vk::BindAccelerationStructureMemoryInfoNV],
@ -98,7 +98,7 @@ impl RayTracing {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdBuildAccelerationStructureNV.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdBuildAccelerationStructureNV.html>"]
pub unsafe fn cmd_build_acceleration_structure(
&self,
command_buffer: vk::CommandBuffer,
@ -124,7 +124,7 @@ impl RayTracing {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdCopyAccelerationStructureNV.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdCopyAccelerationStructureNV.html>"]
pub unsafe fn cmd_copy_acceleration_structure(
&self,
command_buffer: vk::CommandBuffer,
@ -136,7 +136,7 @@ impl RayTracing {
.cmd_copy_acceleration_structure_nv(command_buffer, dst, src, mode);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdTraceRaysNV.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdTraceRaysNV.html>"]
pub unsafe fn cmd_trace_rays(
&self,
command_buffer: vk::CommandBuffer,
@ -174,14 +174,14 @@ impl RayTracing {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreateRayTracingPipelinesNV.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateRayTracingPipelinesNV.html>"]
pub unsafe fn create_ray_tracing_pipelines(
&self,
pipeline_cache: vk::PipelineCache,
create_info: &[vk::RayTracingPipelineCreateInfoNV],
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<Vec<vk::Pipeline>> {
let mut pipelines = vec![mem::uninitialized(); create_info.len()];
let mut pipelines = vec![mem::zeroed(); create_info.len()];
let err_code = self.ray_tracing_fn.create_ray_tracing_pipelines_nv(
self.handle,
pipeline_cache,
@ -196,7 +196,7 @@ impl RayTracing {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetRayTracingShaderGroupHandlesNV.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetRayTracingShaderGroupHandlesNV.html>"]
pub unsafe fn get_ray_tracing_shader_group_handles(
&self,
pipeline: vk::Pipeline,
@ -218,7 +218,7 @@ impl RayTracing {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetAccelerationStructureHandleNV.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetAccelerationStructureHandleNV.html>"]
pub unsafe fn get_acceleration_structure_handle(
&self,
accel_struct: vk::AccelerationStructureNV,
@ -237,7 +237,7 @@ impl RayTracing {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdWriteAccelerationStructuresPropertiesNV.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdWriteAccelerationStructuresPropertiesNV.html>"]
pub unsafe fn cmd_write_acceleration_structures_properties(
&self,
command_buffer: vk::CommandBuffer,
@ -257,7 +257,7 @@ impl RayTracing {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCompileDeferredNV.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCompileDeferredNV.html>"]
pub unsafe fn compile_deferred(&self, pipeline: vk::Pipeline, shader: u32) -> VkResult<()> {
let err_code = self
.ray_tracing_fn
@ -271,4 +271,12 @@ impl RayTracing {
pub fn name() -> &'static CStr {
vk::NvRayTracingFn::name()
}
pub fn fp(&self) -> &vk::NvRayTracingFn {
&self.ray_tracing_fn
}
pub fn device(&self) -> vk::Device {
self.handle
}
}

106
third_party/rust/ash/src/instance.rs поставляемый
Просмотреть файл

@ -1,18 +1,19 @@
#![allow(dead_code)]
use device::Device;
use prelude::*;
use crate::device::Device;
use crate::prelude::*;
use crate::vk;
use crate::RawPtr;
use std::mem;
use std::os::raw::c_char;
use std::ptr;
use vk;
use RawPtr;
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/VkInstance.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkInstance.html>"]
#[derive(Clone)]
pub struct Instance {
handle: vk::Instance,
instance_fn_1_0: vk::InstanceFnV1_0,
instance_fn_1_1: vk::InstanceFnV1_1,
instance_fn_1_2: vk::InstanceFnV1_2,
}
impl Instance {
pub unsafe fn load(static_fn: &vk::StaticFn, instance: vk::Instance) -> Self {
@ -22,25 +23,34 @@ impl Instance {
let instance_fn_1_1 = vk::InstanceFnV1_1::load(|name| {
mem::transmute(static_fn.get_instance_proc_addr(instance, name.as_ptr()))
});
let instance_fn_1_2 = vk::InstanceFnV1_2::load(|name| {
mem::transmute(static_fn.get_instance_proc_addr(instance, name.as_ptr()))
});
Instance {
handle: instance,
instance_fn_1_0,
instance_fn_1_1,
instance_fn_1_2,
}
}
}
impl InstanceV1_0 for Instance {
type Device = Device;
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreateDevice.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateDevice.html>"]
///
/// # Safety
/// 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`.
unsafe fn create_device(
&self,
physical_device: vk::PhysicalDevice,
create_info: &vk::DeviceCreateInfo,
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> Result<Self::Device, vk::Result> {
let mut device: vk::Device = mem::uninitialized();
let mut device: vk::Device = mem::zeroed();
let err_code = self.fp_v1_0().create_device(
physical_device,
create_info,
@ -67,12 +77,23 @@ impl InstanceV1_1 for Instance {
}
}
impl InstanceV1_2 for Instance {
fn fp_v1_2(&self) -> &vk::InstanceFnV1_2 {
&self.instance_fn_1_2
}
}
#[allow(non_camel_case_types)]
pub trait InstanceV1_2: InstanceV1_1 {
fn fp_v1_2(&self) -> &vk::InstanceFnV1_2;
}
#[allow(non_camel_case_types)]
pub trait InstanceV1_1: InstanceV1_0 {
fn fp_v1_1(&self) -> &vk::InstanceFnV1_1;
unsafe fn enumerate_physical_device_groups_len(&self) -> usize {
let mut group_count = mem::uninitialized();
let mut group_count = mem::zeroed();
self.fp_v1_1().enumerate_physical_device_groups(
self.handle(),
&mut group_count,
@ -81,7 +102,7 @@ pub trait InstanceV1_1: InstanceV1_0 {
group_count as usize
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkEnumeratePhysicalDeviceGroups.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkEnumeratePhysicalDeviceGroups.html>"]
fn enumerate_physical_device_groups(
&self,
out: &mut [vk::PhysicalDeviceGroupProperties],
@ -101,7 +122,17 @@ pub trait InstanceV1_1: InstanceV1_0 {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetPhysicalDeviceProperties2.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceFeatures2.html>"]
unsafe fn get_physical_device_features2(
&self,
physical_device: vk::PhysicalDevice,
features: &mut vk::PhysicalDeviceFeatures2,
) {
self.fp_v1_1()
.get_physical_device_features2(physical_device, features);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceProperties2.html>"]
unsafe fn get_physical_device_properties2(
&self,
physical_device: vk::PhysicalDevice,
@ -111,7 +142,7 @@ pub trait InstanceV1_1: InstanceV1_0 {
.get_physical_device_properties2(physical_device, prop);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetPhysicalDeviceFormatProperties2.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceFormatProperties2.html>"]
unsafe fn get_physical_device_format_properties2(
&self,
physical_device: vk::PhysicalDevice,
@ -122,7 +153,7 @@ pub trait InstanceV1_1: InstanceV1_0 {
.get_physical_device_format_properties2(physical_device, format, out);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetPhysicalDeviceImageFormatProperties2.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceImageFormatProperties2.html>"]
unsafe fn get_physical_device_image_format_properties2(
&self,
physical_device: vk::PhysicalDevice,
@ -154,7 +185,7 @@ pub trait InstanceV1_1: InstanceV1_0 {
queue_count as usize
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetPhysicalDeviceQueueFamilyProperties2.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceQueueFamilyProperties2.html>"]
unsafe fn get_physical_device_queue_family_properties2(
&self,
physical_device: vk::PhysicalDevice,
@ -168,7 +199,7 @@ pub trait InstanceV1_1: InstanceV1_0 {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetPhysicalDeviceMemoryProperties2.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceMemoryProperties2.html>"]
unsafe fn get_physical_device_memory_properties2(
&self,
physical_device: vk::PhysicalDevice,
@ -194,7 +225,7 @@ pub trait InstanceV1_1: InstanceV1_0 {
format_count as usize
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetPhysicalDeviceSparseImageFormatProperties2.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceSparseImageFormatProperties2.html>"]
unsafe fn get_physical_device_sparse_image_format_properties2(
&self,
physical_device: vk::PhysicalDevice,
@ -211,7 +242,7 @@ pub trait InstanceV1_1: InstanceV1_0 {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetPhysicalDeviceExternalBufferProperties.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceExternalBufferProperties.html>"]
unsafe fn get_physical_device_external_buffer_properties(
&self,
physical_device: vk::PhysicalDevice,
@ -226,7 +257,7 @@ pub trait InstanceV1_1: InstanceV1_0 {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetPhysicalDeviceExternalFenceProperties.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceExternalFenceProperties.html>"]
unsafe fn get_physical_device_external_fence_properties(
&self,
physical_device: vk::PhysicalDevice,
@ -241,7 +272,7 @@ pub trait InstanceV1_1: InstanceV1_0 {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetPhysicalDeviceExternalSemaphoreProperties.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceExternalSemaphoreProperties.html>"]
unsafe fn get_physical_device_external_semaphore_properties(
&self,
physical_device: vk::PhysicalDevice,
@ -262,7 +293,12 @@ pub trait InstanceV1_0 {
type Device;
fn handle(&self) -> vk::Instance;
fn fp_v1_0(&self) -> &vk::InstanceFnV1_0;
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreateDevice.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateDevice.html>"]
///
/// # Safety
/// 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`.
unsafe fn create_device(
&self,
physical_device: vk::PhysicalDevice,
@ -270,7 +306,7 @@ pub trait InstanceV1_0 {
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> Result<Self::Device, vk::Result>;
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetDeviceProcAddr.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetDeviceProcAddr.html>"]
unsafe fn get_device_proc_addr(
&self,
device: vk::Device,
@ -279,19 +315,19 @@ pub trait InstanceV1_0 {
self.fp_v1_0().get_device_proc_addr(device, p_name)
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkDestroyInstance.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkDestroyInstance.html>"]
unsafe fn destroy_instance(&self, allocation_callbacks: Option<&vk::AllocationCallbacks>) {
self.fp_v1_0()
.destroy_instance(self.handle(), allocation_callbacks.as_raw_ptr());
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetPhysicalDeviceFormatProperties.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceFormatProperties.html>"]
unsafe fn get_physical_device_format_properties(
&self,
physical_device: vk::PhysicalDevice,
format: vk::Format,
) -> vk::FormatProperties {
let mut format_prop = mem::uninitialized();
let mut format_prop = mem::zeroed();
self.fp_v1_0().get_physical_device_format_properties(
physical_device,
format,
@ -300,7 +336,7 @@ pub trait InstanceV1_0 {
format_prop
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetPhysicalDeviceImageFormatProperties.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceImageFormatProperties.html>"]
unsafe fn get_physical_device_image_format_properties(
&self,
physical_device: vk::PhysicalDevice,
@ -310,7 +346,7 @@ pub trait InstanceV1_0 {
usage: vk::ImageUsageFlags,
flags: vk::ImageCreateFlags,
) -> VkResult<vk::ImageFormatProperties> {
let mut image_format_prop = mem::uninitialized();
let mut image_format_prop = mem::zeroed();
let err_code = self.fp_v1_0().get_physical_device_image_format_properties(
physical_device,
format,
@ -327,29 +363,29 @@ pub trait InstanceV1_0 {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetPhysicalDeviceMemoryProperties.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceMemoryProperties.html>"]
unsafe fn get_physical_device_memory_properties(
&self,
physical_device: vk::PhysicalDevice,
) -> vk::PhysicalDeviceMemoryProperties {
let mut memory_prop = mem::uninitialized();
let mut memory_prop = mem::zeroed();
self.fp_v1_0()
.get_physical_device_memory_properties(physical_device, &mut memory_prop);
memory_prop
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetPhysicalDeviceProperties.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceProperties.html>"]
unsafe fn get_physical_device_properties(
&self,
physical_device: vk::PhysicalDevice,
) -> vk::PhysicalDeviceProperties {
let mut prop = mem::uninitialized();
let mut prop = mem::zeroed();
self.fp_v1_0()
.get_physical_device_properties(physical_device, &mut prop);
prop
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetPhysicalDeviceQueueFamilyProperties.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceQueueFamilyProperties.html>"]
unsafe fn get_physical_device_queue_family_properties(
&self,
physical_device: vk::PhysicalDevice,
@ -370,20 +406,20 @@ pub trait InstanceV1_0 {
queue_families_vec
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetPhysicalDeviceFeatures.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceFeatures.html>"]
unsafe fn get_physical_device_features(
&self,
physical_device: vk::PhysicalDevice,
) -> vk::PhysicalDeviceFeatures {
let mut prop = mem::uninitialized();
let mut prop = mem::zeroed();
self.fp_v1_0()
.get_physical_device_features(physical_device, &mut prop);
prop
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkEnumeratePhysicalDevices.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkEnumeratePhysicalDevices.html>"]
unsafe fn enumerate_physical_devices(&self) -> VkResult<Vec<vk::PhysicalDevice>> {
let mut num = mem::uninitialized();
let mut num = mem::zeroed();
self.fp_v1_0()
.enumerate_physical_devices(self.handle(), &mut num, ptr::null_mut());
let mut physical_devices = Vec::<vk::PhysicalDevice>::with_capacity(num as usize);
@ -399,7 +435,7 @@ pub trait InstanceV1_0 {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkEnumerateDeviceExtensionProperties.html>"]
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkEnumerateDeviceExtensionProperties.html>"]
unsafe fn enumerate_device_extension_properties(
&self,
device: vk::PhysicalDevice,

19
third_party/rust/ash/src/lib.rs поставляемый
Просмотреть файл

@ -1,17 +1,16 @@
#![allow(clippy::too_many_arguments, clippy::missing_safety_doc)]
//! # Vulkan API
//!
//! <https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/index.html>
//! <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/index.html>
//!
//! ## Examples
//!
//! ```rust,no_run
//! # #[macro_use]
//! # extern crate ash;
//! use ash::{vk, Entry, version::EntryV1_0};
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let entry = Entry::new()?;
//! let app_info = vk::ApplicationInfo {
//! api_version: vk_make_version!(1, 0, 0),
//! api_version: vk::make_version(1, 0, 0),
//! ..Default::default()
//! };
//! let create_info = vk::InstanceCreateInfo {
@ -23,11 +22,9 @@
//! ```
//!
extern crate shared_library;
pub use device::Device;
pub use entry::{Entry, EntryCustom, InstanceError, LoadingError};
pub use instance::Instance;
pub use crate::device::Device;
pub use crate::entry::{Entry, EntryCustom, InstanceError, LoadingError};
pub use crate::instance::Instance;
mod device;
mod entry;
@ -47,8 +44,8 @@ pub trait RawPtr<T> {
impl<'r, T> RawPtr<T> for Option<&'r T> {
fn as_raw_ptr(&self) -> *const T {
match self {
&Some(inner) => inner as *const T,
match *self {
Some(inner) => inner as *const T,
_ => ::std::ptr::null(),
}

2
third_party/rust/ash/src/prelude.rs поставляемый
Просмотреть файл

@ -1,2 +1,2 @@
use vk;
use crate::vk;
pub type VkResult<T> = Result<T, vk::Result>;

8
third_party/rust/ash/src/util.rs поставляемый
Просмотреть файл

@ -1,9 +1,9 @@
use crate::vk;
use std::iter::Iterator;
use std::marker::PhantomData;
use std::mem::size_of;
use std::os::raw::c_void;
use std::{io, slice};
use vk;
/// `Align` handles dynamic alignment. The is useful for dynamic uniform buffers where
/// the alignment might be different. For example a 4x4 f32 matrix has a size of 64 bytes
@ -122,13 +122,13 @@ pub fn read_spv<R: io::Read + io::Seek>(x: &mut R) -> io::Result<Vec<u32>> {
))?;
result.set_len(words);
}
const MAGIC_NUMBER: u32 = 0x07230203;
if result.len() > 0 && result[0] == MAGIC_NUMBER.swap_bytes() {
const MAGIC_NUMBER: u32 = 0x0723_0203;
if !result.is_empty() && result[0] == MAGIC_NUMBER.swap_bytes() {
for word in &mut result {
*word = word.swap_bytes();
}
}
if result.len() == 0 || result[0] != MAGIC_NUMBER {
if result.is_empty() || result[0] != MAGIC_NUMBER {
return Err(io::Error::new(
io::ErrorKind::InvalidData,
"input missing SPIR-V magic number",

6
third_party/rust/ash/src/version.rs поставляемый
Просмотреть файл

@ -1,3 +1,3 @@
pub use device::{DeviceV1_0, DeviceV1_1};
pub use entry::{EntryV1_0, EntryV1_1};
pub use instance::{InstanceV1_0, InstanceV1_1};
pub use crate::device::{DeviceV1_0, DeviceV1_1, DeviceV1_2};
pub use crate::entry::{EntryV1_0, EntryV1_1, EntryV1_2};
pub use crate::instance::{InstanceV1_0, InstanceV1_1, InstanceV1_2};

29374
third_party/rust/ash/src/vk.rs поставляемый

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

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

@ -1,4 +1,4 @@
extern crate ash;
use ash;
use ash::vk::{PhysicalDeviceProperties, PipelineColorBlendStateCreateInfo};
@ -27,15 +27,10 @@ fn assert_struct_field_is_array() {
#[allow(dead_code)]
fn assert_ffi_array_param_is_pointer() {
use ash::version::DeviceV1_0;
unsafe {
// don't run it, just make sure it compiles
if false {
let device: ash::Device = std::mem::uninitialized();
let cmd_buffer = std::mem::uninitialized();
// don't run it, just make sure it compiles
unsafe fn dummy(device: &ash::Device, cmd_buffer: ash::vk::CommandBuffer) {
let blend_constants: [f32; 4] = [0.0, 0.0, 0.0, 0.0];
let blend_constants: [f32; 4] = [0.0, 0.0, 0.0, 0.0];
device.cmd_set_blend_constants(cmd_buffer, &blend_constants);
}
device.cmd_set_blend_constants(cmd_buffer, &blend_constants);
}
}

1
third_party/rust/ash/tests/display.rs поставляемый
Просмотреть файл

@ -1,4 +1,3 @@
extern crate ash;
use ash::vk;
#[test]

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

@ -1 +0,0 @@
{"files":{"Cargo.toml":"4b57cc26ea5fe95d54cd5ddaa036a435b1f996cd283283efd6675f1f4b77fed1","CodeOfConduct.md":"9a97bc250bc21e1b3fe7d7217296a33b7379e082e293f206afb6bcc93f2d3cce","README.md":"0059d0114dc6283f54eacf7cc285e0b7f3fe5db35107f5841844c8949c67000e","license":"48da2f39e100d4085767e94966b43f4fa95ff6a0698fba57ed460914e35f94a0","rustfmt.toml":"2e13002b5bbc7c434e8b6e669bd5e9417c58607bacf2f3c8711e9fc1745dd302","src/core/color_string.rs":"e860320fdce6d9590eceee040eda4e769a100e9f3a3ef24c3620bd523482fff8","src/core/colors.rs":"d22bf7c763994259ba02320ec64d6349a4f596cbf68c2161c09130f2fad16219","src/core/hsl.rs":"7308dd6b02b74b1e13eb61d4f960d52a50c9e01621404fe7468bedcf29596de5","src/core/mod.rs":"331493703e3c09b36cbf7a51d7c2b6b2455f34b7558fac172a847470b1e31fd9","src/core/rgb.rs":"c5dda4eb726a1d137658b22aa5d69958c4c710a595dff6a966395003918c1e95","src/core/style.rs":"315def912b8df5f4d6efa3b92adf5c5d21caaa8b3688dab79348140909551d9c","src/core/symbols.rs":"4925401f864d7c9b40bebf9f1a565c5650e7475dcc05a4d43240c32fd7ea38da","src/lib.rs":"f423d55cd70f7b4d4a31172f0ac3b74123ef7ed925f6be33913a8222da092279","tests/test_all_color.rs":"83d8ff40812200682360e59c9ac8ced14af65adb558699958e280e05d359933d","tests/test_animation.rs":"1b6db4c29c7b2727337c9096b53108475bf12cea0ffda9e26aa86bd7956885e2","tests/test_basic.rs":"8884ac1fb3b6749d94429ce57336a43a1a84f6c2c8c9c7ea9cdf224e2bc230df","tests/test_extra.rs":"c46c7f4fd45851565359fa20d9fce3216a19e000b66d08b1af8dc8f1e0b2282c","tests/test_gradient.rs":"bedd7a0afedbca9f606acfa3ae3bc718fab03b5f69fced8c9fbf0d499ad9d991","tests/test_hsl.rs":"668a7db4f84b555210f47cac4183141703aae679d3343bcbdb6fa75c1b3057b2"},"package":"0bca1619ff57dd7a56b58a8e25ef4199f123e78e503fe1653410350a1b98ae65"}

26
third_party/rust/colorful/Cargo.toml поставляемый
Просмотреть файл

@ -1,26 +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 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 = "colorful"
version = "0.2.1"
authors = ["da2018 <da2018t@gmail.com>"]
exclude = ["images/*", "examples"]
description = "Make your terminal output colorful"
homepage = "https://github.com/rocketsman/colorful"
readme = "README.md"
keywords = ["cli", "colors", "terminal"]
categories = ["cli", "colors", "terminal"]
license = "MIT"
repository = "https://github.com/rocketsman/colorful"
[dependencies]

74
third_party/rust/colorful/CodeOfConduct.md поставляемый
Просмотреть файл

@ -1,74 +0,0 @@
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of
experience, nationality, personal appearance, race, religion, or sexual identity
and orientation.
## Our Standards
Examples of behaviour that contributes to creating a positive environment
include:
- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members
Examples of unacceptable behaviour by participants include:
- The use of sexualised language or imagery and unwelcome sexual
attention or advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others private information, such as a physical or electronic
address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a
professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behaviour and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behaviour.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviours that they deem inappropriate,
threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may
be further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behaviour may be
reported by contacting the project team at tituswormer@gmail.com. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an
incident. Further details of specific enforcement policies may be posted
separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the projects leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 1.4, available at <https://www.contributor-covenant.org/version/1/4>.
[homepage]: https://www.contributor-covenant.org

196
third_party/rust/colorful/README.md поставляемый
Просмотреть файл

@ -1,196 +0,0 @@
<h1 align="center">
<a>Colorful</a>
<br>
<br>
</h1>
[![Build Status](https://travis-ci.org/rocketsman/colorful.svg?branch=master)](https://travis-ci.org/rocketsman/colorful) [![Coverage Status](https://coveralls.io/repos/github/rocketsman/colorful/badge.svg?branch=master)](https://coveralls.io/github/rocketsman/colorful?branch=master) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/37a45510f41445eea0168f0f07e8f7cb)](https://app.codacy.com/app/rocketsman/colorful_2?utm_source=github.com&utm_medium=referral&utm_content=rocketsman/colorful&utm_campaign=Badge_Grade_Dashboard)
## Usage
### Basic Usage
```Rust
extern crate colorful;
use colorful::Color;
use colorful::Colorful;
//use colorful::HSL;
//use colorful::RGB;
fn main() {
let s = "Hello world";
println!("{}", s.color(Color::Blue).bg_color(Color::Yellow).bold());
// println!("{}", s.color(HSL::new(1.0, 1.0, 0.5)).bold());
// println!("{}", s.color(RGB::new(255, 0, 0)).bold());
println!("{}", s.blue().bg_yellow());
}
```
### Gradient
```Rust
extern crate colorful;
use colorful::Color;
use colorful::Colorful;
fn main() {
println!("{}", "This code is editable and runnable!".gradient(Color::Red));
println!("{}", "¡Este código es editable y ejecutable!".gradient(Color::Green));
println!("{}", "Ce code est modifiable et exécutable !".gradient(Color::Yellow));
println!("{}", "Questo codice è modificabile ed eseguibile!".gradient(Color::Blue));
println!("{}", "このコードは編集して実行出来ます!".gradient(Color::Magenta));
println!("{}", "여기에서 코드를 수정하고 실행할 수 있습니다!".gradient(Color::Cyan));
println!("{}", "Ten kod można edytować oraz uruchomić!".gradient(Color::LightGray));
println!("{}", "Este código é editável e executável!".gradient(Color::DarkGray));
println!("{}", "Этот код можно отредактировать и запустить!".gradient(Color::LightRed));
println!("{}", "Bạn có thể edit và run code trực tiếp!".gradient(Color::LightGreen));
println!("{}", "这段代码是可以编辑并且能够运行的!".gradient(Color::LightYellow));
println!("{}", "Dieser Code kann bearbeitet und ausgeführt werden!".gradient(Color::LightBlue));
println!("{}", "Den här koden kan redigeras och köras!".gradient(Color::LightMagenta));
println!("{}", "Tento kód můžete upravit a spustit".gradient(Color::LightCyan));
println!("{}", "این کد قابلیت ویرایش و اجرا دارد!".gradient(Color::White));
println!("{}", "โค้ดนี้สามารถแก้ไขได้และรันได้".gradient(Color::Grey0));
}
```
<div align="center">
<img src="images/1.png" width="600px"</img>
</div>
### Gradient with style
```Rust
extern crate colorful;
use colorful::Colorful;
fn main() {
println!("{}", "言葉にできず 凍えたままで 人前ではやさしく生きていた しわよせで こんなふうに雑に 雨の夜にきみを 抱きしめてた".gradient_with_color(HSL::new(0.0, 1.0, 0.5), HSL::new(0.833, 1.0, 0.5)).underlined());
}
```
<div align="center">
<img src="images/2.png" width="700px"</img>
</div>
### Bar chart
```Rust
extern crate colorful;
use colorful::Colorful;
use colorful::HSL;
fn main() {
let s = "█";
println!("{}\n", "Most Loved, Dreaded, and Wanted Languages".red());
let values = vec![78.9, 75.1, 68.0, 67.0, 65.6, 65.1, 61.9, 60.4];
let languages = vec!["Rust", "Kotlin", "Python", "TypeScript", "Go", "Swift", "JavaScript", "C#"];
let c = languages.iter().max_by_key(|x| x.len()).unwrap();
for (i, value) in values.iter().enumerate() {
let h = (*value as f32 * 15.0 % 360.0) / 360.0;
let length = (value - 30.0) as usize;
println!("{:<width$} | {} {}%\n", languages.get(i).unwrap(), s.repeat(length).gradient(HSL::new(h, 1.0, 0.5)), value, width = c.len());
}
}
```
Output
<div align="center">
<img src="images/3.png" width="500px"</img>
</div>
### Animation
#### Rainbow
```Rust
extern crate colorful;
use colorful::Colorful;
fn main() {
let text = format!("{:^50}\n{}\r\n{}", "岳飞 小重山", "昨夜寒蛩不住鸣 惊回千里梦 已三更 起身独自绕阶行 人悄悄 帘外月胧明",
"白首为功名 旧山松竹老 阻归程 欲将心事付瑶琴 知音少 弦断有谁听");
text.rainbow();
}
```
Output
<div align="center">
<img src="images/11.gif"</img>
</div>
#### Neon
```Rust
extern crate colorful;
use colorful::Colorful;
fn main() {
let text = format!("{:^28}\n{}", "WARNING", "BIG BROTHER IS WATCHING YOU!!!");
text.neon(RGB::new(226, 14, 14), RGB::new(158, 158, 158));
// or you can use text.warn();
}
```
Output
<div align="center">
<img src="images/22.gif"</img>
</div>
## Terminals compatibility
<table style="font-size: 60%; padding: 1px;">
<thead>
<tr>
<th rowspan=2>Terminal</th>
<th colspan=6 align=center>Formatting</th>
<th colspan=4 align=center>Color</th>
</tr>
<tr>
<!-- Formatting ---------><th>Bold</th><th>Dim</th><th>Underlined</th><th>Blink</th><th>Invert</th><th>Hidden</th>
<!--Color -------><th>8</th><th>16</th><th>88</th><th>256</th>
</tr>
<tbody>
<tr align=center><td>aTerm </td><td> <img src="images/yes.png" alt=""/> </td><td><img src="images/no.png" alt=""/></td><td> <img src="images/yes.png" alt=""/> </td><td><img src="images/no.png" alt=""/></td><td> <img src="images/yes.png" alt=""/> </td><td><img src="images/no.png" alt=""/></td><td> <img src="images/yes.png" alt=""/> </td><td> ~ </td><td><img src="images/no.png" alt=""/></td><td><img src="images/no.png" alt=""/></td></tr>
<tr align=center><td>Eterm </td><td> ~ </td><td><img src="images/no.png" alt=""/></td><td> <img src="images/yes.png" alt=""/> </td><td><img src="images/no.png" alt=""/></td><td> <img src="images/yes.png" alt=""/> </td><td><img src="images/no.png" alt=""/></td><td> <img src="images/yes.png" alt=""/> </td><td> ~ </td><td><img src="images/no.png" alt=""/></td><td> <img src="images/yes.png" alt=""/></td></tr>
<tr align=center><td>GNOME Terminal </td><td> <img src="images/yes.png" alt=""/> </td><td> <img src="images/yes.png" alt=""/> </td><td> <img src="images/yes.png" alt=""/> </td><td> <img src="images/yes.png" alt=""/> </td><td> <img src="images/yes.png" alt=""/> </td><td> <img src="images/yes.png" alt=""/> </td><td> <img src="images/yes.png" alt=""/> </td><td> <img src="images/yes.png" alt=""/> </td><td><img src="images/no.png" alt=""/></td><td> <img src="images/yes.png" alt=""/></td></tr>
<tr align=center><td>Guake </td><td> <img src="images/yes.png" alt=""/> </td><td> <img src="images/yes.png" alt=""/> </td><td> <img src="images/yes.png" alt=""/> </td><td> <img src="images/yes.png" alt=""/> </td><td> <img src="images/yes.png" alt=""/> </td><td> <img src="images/yes.png" alt=""/> </td><td> <img src="images/yes.png" alt=""/> </td><td> <img src="images/yes.png" alt=""/> </td><td><img src="images/no.png" alt=""/></td><td> <img src="images/yes.png" alt=""/></td></tr>
<tr align=center><td>Konsole </td><td> <img src="images/yes.png" alt=""/> </td><td><img src="images/no.png" alt=""/></td><td> <img src="images/yes.png" alt=""/> </td><td> <img src="images/yes.png" alt=""/> </td><td> <img src="images/yes.png" alt=""/> </td><td><img src="images/no.png" alt=""/></td><td> <img src="images/yes.png" alt=""/> </td><td> <img src="images/yes.png" alt=""/> </td><td><img src="images/no.png" alt=""/></td><td> <img src="images/yes.png" alt=""/></td></tr>
<tr align=center><td>Nautilus Terminal </td><td> <img src="images/yes.png" alt=""/> </td><td> <img src="images/yes.png" alt=""/> </td><td> <img src="images/yes.png" alt=""/> </td><td> <img src="images/yes.png" alt=""/> </td><td> <img src="images/yes.png" alt=""/> </td><td> <img src="images/yes.png" alt=""/> </td><td> <img src="images/yes.png" alt=""/> </td><td> <img src="images/yes.png" alt=""/> </td><td><img src="images/no.png" alt=""/></td><td> <img src="images/yes.png" alt=""/></td></tr>
<tr align=center><td>rxvt </td><td> <img src="images/yes.png" alt=""/> </td><td><img src="images/no.png" alt=""/></td><td> <img src="images/yes.png" alt=""/> </td><td> ~ </td><td> <img src="images/yes.png" alt=""/> </td><td><img src="images/no.png" alt=""/></td><td> <img src="images/yes.png" alt=""/> </td><td> <img src="images/yes.png" alt=""/> </td><td> <img src="images/yes.png" alt=""/> </td><td><img src="images/no.png" alt=""/></td></tr>
<tr align=center><td>Terminator </td><td> <img src="images/yes.png" alt=""/> </td><td> <img src="images/yes.png" alt=""/> </td><td> <img src="images/yes.png" alt=""/> </td><td><img src="images/no.png" alt=""/></td><td> <img src="images/yes.png" alt=""/> </td><td> <img src="images/yes.png" alt=""/> </td><td> <img src="images/yes.png" alt=""/> </td><td> <img src="images/yes.png" alt=""/> </td><td><img src="images/no.png" alt=""/></td><td> <img src="images/yes.png" alt=""/></td></tr>
<tr align=center><td>Tilda </td><td> <img src="images/yes.png" alt=""/> </td><td><img src="images/no.png" alt=""/></td><td> <img src="images/yes.png" alt=""/> </td><td> <img src="images/yes.png" alt=""/> </td><td> <img src="images/yes.png" alt=""/> </td><td><img src="images/no.png" alt=""/></td><td> <img src="images/yes.png" alt=""/> </td><td> <img src="images/yes.png" alt=""/> </td><td><img src="images/no.png" alt=""/></td><td><img src="images/no.png" alt=""/></td></tr>
<tr align=center><td>XFCE4 Terminal </td><td> <img src="images/yes.png" alt=""/> </td><td> <img src="images/yes.png" alt=""/> </td><td> <img src="images/yes.png" alt=""/> </td><td> <img src="images/yes.png" alt=""/> </td><td> <img src="images/yes.png" alt=""/> </td><td> <img src="images/yes.png" alt=""/> </td><td> <img src="images/yes.png" alt=""/> </td><td> <img src="images/yes.png" alt=""/> </td><td><img src="images/no.png" alt=""/></td><td> <img src="images/yes.png" alt=""/></td></tr>
<tr align=center><td>XTerm </td><td> <img src="images/yes.png" alt=""/> </td><td><img src="images/no.png" alt=""/></td><td> <img src="images/yes.png" alt=""/> </td><td> <img src="images/yes.png" alt=""/> </td><td> <img src="images/yes.png" alt=""/> </td><td> <img src="images/yes.png" alt=""/> </td><td> <img src="images/yes.png" alt=""/> </td><td> <img src="images/yes.png" alt=""/> </td><td><img src="images/no.png" alt=""/></td><td> <img src="images/yes.png" alt=""/> </td></tr>
<tr align=center><td>xvt </td><td> <img src="images/yes.png" alt=""/> </td><td><img src="images/no.png" alt=""/></td><td> <img src="images/yes.png" alt=""/> </td><td><img src="images/no.png" alt=""/></td><td> <img src="images/yes.png" alt=""/> </td><td><img src="images/no.png" alt=""/></td><td><img src="images/no.png" alt=""/></td><td><img src="images/no.png" alt=""/></td><td><img src="images/no.png" alt=""/></td><td><img src="images/no.png" alt=""/></td></tr>
<tr align=center><td>Linux TTY </td><td> <img src="images/yes.png" alt=""/> </td><td><img src="images/no.png" alt=""/></td><td><img src="images/no.png" alt=""/></td><td><img src="images/no.png" alt=""/></td><td> <img src="images/yes.png" alt=""/> </td><td><img src="images/no.png" alt=""/></td><td> <img src="images/yes.png" alt=""/> </td><td> ~ </td><td><img src="images/no.png" alt=""/></td><td><img src="images/no.png" alt=""/></td></tr>
<tr align=center><td>VTE Terminal </td><td> <img src="images/yes.png" alt=""/> </td><td> <img src="images/yes.png" alt=""/> </td><td> <img src="images/yes.png" alt=""/> </td><td> <img src="images/yes.png" alt=""/> </td><td> <img src="images/yes.png" alt=""/> </td><td> <img src="images/yes.png" alt=""/> </td><td> <img src="images/yes.png" alt=""/> </td><td> <img src="images/yes.png" alt=""/> </td><td><img src="images/no.png" alt=""/></td><td> <img src="images/yes.png" alt=""/></td></tr>
</tbody>
</thead>
</table>
~: Supported in a special way by the terminal.
## Todo
- [x] Basic 16 color
- [ ] Extra 240 color
- [x] HSL support
- [x] RGB support
- [x] Gradient mode
- [x] Rainbow mode
- [x] Animation mode
- [ ] Document
- [x] Terminals compatibility
## License
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fda2018%2Fcolorful.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fda2018%2Fcolorful?ref=badge_large)

9
third_party/rust/colorful/license поставляемый
Просмотреть файл

@ -1,9 +0,0 @@
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
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.

5
third_party/rust/colorful/rustfmt.toml поставляемый
Просмотреть файл

@ -1,5 +0,0 @@
max_width = 89
reorder_imports = true
#wrap_comments = true
fn_args_density = "Compressed"
#use_small_heuristics = false

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

@ -1,134 +0,0 @@
use std::fmt::Display;
use std::fmt::Formatter;
use std::fmt::Result as FmtResult;
use core::ColorInterface;
use core::colors::Colorado;
use core::colors::ColorMode;
use core::StrMarker;
use core::symbols::Symbol;
use Style;
// Support multiple style
#[derive(Clone)]
pub struct CString {
text: String,
fg_color: Option<Colorado>,
bg_color: Option<Colorado>,
styles: Option<Vec<Style>>,
}
impl StrMarker for CString {
fn to_str(&self) -> String {
self.text.to_owned()
}
fn get_fg_color(&self) -> Option<Colorado> {
self.fg_color.clone()
}
fn get_bg_color(&self) -> Option<Colorado> {
self.bg_color.clone()
}
fn get_style(&self) -> Option<Vec<Style>> {
self.styles.clone()
}
}
impl CString {
pub fn new<S: StrMarker>(cs: S) -> CString {
CString {
text: cs.to_str(),
fg_color: cs.get_fg_color(),
bg_color: cs.get_bg_color(),
styles: cs.get_style(),
}
}
pub fn create_by_text<S: StrMarker>(cs: S, t: String) -> CString {
CString { text: t, ..CString::new(cs) }
}
pub fn create_by_fg<S: StrMarker, C: ColorInterface>(cs: S, color: C) -> CString {
CString { fg_color: Some(Colorado::new(color)), ..CString::new(cs) }
}
pub fn create_by_bg<S: StrMarker, C: ColorInterface>(cs: S, color: C) -> CString {
CString { bg_color: Some(Colorado::new(color)), ..CString::new(cs) }
}
pub fn create_by_style<S: StrMarker>(cs: S, style: Style) -> CString {
CString {
text: cs.to_str(),
styles: match cs.get_style() {
Some(mut v) => {
v.push(style);
Some(v)
}
_ => { Some(vec![style]) }
},
fg_color: cs.get_fg_color(),
bg_color: cs.get_bg_color(),
}
}
}
impl Display for CString {
fn fmt(&self, f: &mut Formatter) -> FmtResult {
let mut is_colored = false;
if self.bg_color.is_none() && self.fg_color.is_none() && self.styles.is_none() {
write!(f, "{}", self.text)?;
Ok(())
} else {
match &self.fg_color {
Some(v) => {
is_colored = true;
match v.get_mode() {
ColorMode::SIMPLE => {
f.write_str(Symbol::Simple256Foreground.to_str())?;
}
ColorMode::RGB => {
f.write_str(Symbol::RgbForeground.to_str())?;
}
_ => {}
}
write!(f, "{}", v.get_color())?;
}
_ => {}
}
match &self.bg_color {
Some(v) => {
if is_colored {
f.write_str(Symbol::Mode.to_str())?;
} else {
is_colored = true;
}
match v.get_mode() {
ColorMode::SIMPLE => {
f.write_str(Symbol::Simple256Background.to_str())?;
}
ColorMode::RGB => {
f.write_str(Symbol::RgbBackground.to_str())?;
}
_ => {}
}
write!(f, "{}", v.get_color())?;
}
_ => {}
}
match &self.styles {
Some(v) => {
if !is_colored { // pure style without color
write!(f, "{}{}", Symbol::Esc, Symbol::LeftBrackets)?;
} else {
f.write_str(Symbol::Semicolon.to_str())?;
}
let t: Vec<String> = v.into_iter().map(|x| x.to_string()).collect();
f.write_str(&t.join(";")[..])?;
}
_ => {}
}
f.write_str(Symbol::Mode.to_str())?;
write!(f, "{}", self.text)?;
f.write_str(Symbol::Reset.to_str())?;
Ok(())
}
}
}

847
third_party/rust/colorful/src/core/colors.rs поставляемый
Просмотреть файл

@ -1,847 +0,0 @@
use std::slice::Iter;
use core::ColorInterface;
use HSL;
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub enum Color {
Black,
Red,
Green,
Yellow,
Blue,
Magenta,
Cyan,
LightGray,
DarkGray,
LightRed,
LightGreen,
LightYellow,
LightBlue,
LightMagenta,
LightCyan,
White,
Grey0,
NavyBlue,
DarkBlue,
Blue3a,
Blue3b,
Blue1,
DarkGreen,
DeepSkyBlue4a,
DeepSkyBlue4b,
DeepSkyBlue4c,
DodgerBlue3,
DodgerBlue2,
Green4,
SpringGreen4,
Turquoise4,
DeepSkyBlue3a,
DeepSkyBlue3b,
DodgerBlue1,
Green3a,
SpringGreen3a,
DarkCyan,
LightSeaGreen,
DeepSkyBlue2,
DeepSkyBlue1,
Green3b,
SpringGreen3b,
SpringGreen2a,
Cyan3,
DarkTurquoise,
Turquoise2,
Green1,
SpringGreen2b,
SpringGreen1,
MediumSpringGreen,
Cyan2,
Cyan1,
DarkRed1,
DeepPink4a,
Purple4a,
Purple4b,
Purple3,
BlueViolet,
Orange4a,
Grey37,
MediumPurple4,
SlateBlue3a,
SlateBlue3b,
RoyalBlue1,
Chartreuse4,
DarkSeaGreen4a,
PaleTurquoise4,
SteelBlue,
SteelBlue3,
CornflowerBlue,
Chartreuse3a,
DarkSeaGreen4b,
CadetBlue2,
CadetBlue1,
SkyBlue3,
SteelBlue1a,
Chartreuse3b,
PaleGreen3a,
SeaGreen3,
Aquamarine3,
MediumTurquoise,
SteelBlue1b,
Chartreuse2a,
SeaGreen2,
SeaGreen1a,
SeaGreen1b,
Aquamarine1a,
DarkSlateGray2,
DarkRed2,
DeepPink4b,
DarkMagenta1,
DarkMagenta2,
DarkViolet1a,
Purple1a,
Orange4b,
LightPink4,
Plum4,
MediumPurple3a,
MediumPurple3b,
SlateBlue1,
Yellow4a,
Wheat4,
Grey53,
LightSlateGrey,
MediumPurple,
LightSlateBlue,
Yellow4b,
DarkOliveGreen3a,
DarkGreenSea,
LightSkyBlue3a,
LightSkyBlue3b,
SkyBlue2,
Chartreuse2b,
DarkOliveGreen3b,
PaleGreen3b,
DarkSeaGreen3a,
DarkSlateGray3,
SkyBlue1,
Chartreuse1,
LightGreen2,
LightGreen3,
PaleGreen1a,
Aquamarine1b,
DarkSlateGray1,
Red3a,
DeepPink4c,
MediumVioletRed,
Magenta3a,
DarkViolet1b,
Purple1b,
DarkOrange3a,
IndianRed1a,
HotPink3a,
MediumOrchid3,
MediumOrchid,
MediumPurple2a,
DarkGoldenrod,
LightSalmon3a,
RosyBrown,
Grey63,
MediumPurple2b,
MediumPurple1,
Gold3a,
DarkKhaki,
NavajoWhite3,
Grey69,
LightSteelBlue3,
LightSteelBlue,
Yellow3a,
DarkOliveGreen3,
DarkSeaGreen3b,
DarkSeaGreen2,
LightCyan3,
LightSkyBlue1,
GreenYellow,
DarkOliveGreen2,
PaleGreen1b,
DarkSeaGreen5b,
DarkSeaGreen5a,
PaleTurquoise1,
Red3b,
DeepPink3a,
DeepPink3b,
Magenta3b,
Magenta3c,
Magenta2a,
DarkOrange3b,
IndianRed1b,
HotPink3b,
HotPink2,
Orchid,
MediumOrchid1a,
Orange3,
LightSalmon3b,
LightPink3,
Pink3,
Plum3,
Violet,
Gold3b,
LightGoldenrod3,
Tan,
MistyRose3,
Thistle3,
Plum2,
Yellow3b,
Khaki3,
LightGoldenrod2a,
LightYellow3,
Grey84,
LightSteelBlue1,
Yellow2,
DarkOliveGreen1a,
DarkOliveGreen1b,
DarkSeaGreen1,
Honeydew2,
LightCyan1,
Red1,
DeepPink2,
DeepPink1a,
DeepPink1b,
Magenta2b,
Magenta1,
OrangeRed1,
IndianRed1c,
IndianRed1d,
HotPink1a,
HotPink1b,
MediumOrchid1b,
DarkOrange,
Salmon1,
LightCoral,
PaleVioletRed1,
Orchid2,
Orchid1,
Orange1,
SandyBrown,
LightSalmon1,
LightPink1,
Pink1,
Plum1,
Gold1,
LightGoldenrod2b,
LightGoldenrod2c,
NavajoWhite1,
MistyRose1,
Thistle1,
Yellow1,
LightGoldenrod1,
Khaki1,
Wheat1,
CornSilk1,
Grey100,
Grey3,
Grey7,
Grey11,
Grey15,
Grey19,
Grey23,
Grey27,
Grey30,
Grey35,
Grey39,
Grey42,
Grey46,
Grey50,
Grey54,
Grey58,
Grey62,
Grey66,
Grey70,
Grey74,
Grey78,
Grey82,
Grey85,
Grey89,
Grey93,
}
impl ColorInterface for Color {
fn to_color_str(&self) -> String {
format!("{}",
match self {
Color::Black => "0",
Color::Red => "1",
Color::Green => "2",
Color::Yellow => "3",
Color::Blue => "4",
Color::Magenta => "5",
Color::Cyan => "6",
Color::LightGray => "7",
Color::DarkGray => "8",
Color::LightRed => "9",
Color::LightGreen => "10",
Color::LightYellow => "11",
Color::LightBlue => "12",
Color::LightMagenta => "13",
Color::LightCyan => "14",
Color::White => "15",
Color::Grey0 => "16",
Color::NavyBlue => "17",
Color::DarkBlue => "18",
Color::Blue3a => "19",
Color::Blue3b => "20",
Color::Blue1 => "21",
Color::DarkGreen => "22",
Color::DeepSkyBlue4a => "23",
Color::DeepSkyBlue4b => "24",
Color::DeepSkyBlue4c => "25",
Color::DodgerBlue3 => "26",
Color::DodgerBlue2 => "27",
Color::Green4 => "28",
Color::SpringGreen4 => "29",
Color::Turquoise4 => "30",
Color::DeepSkyBlue3a => "31",
Color::DeepSkyBlue3b => "32",
Color::DodgerBlue1 => "33",
Color::Green3a => "34",
Color::SpringGreen3a => "35",
Color::DarkCyan => "36",
Color::LightSeaGreen => "37",
Color::DeepSkyBlue2 => "38",
Color::DeepSkyBlue1 => "39",
Color::Green3b => "40",
Color::SpringGreen3b => "41",
Color::SpringGreen2a => "42",
Color::Cyan3 => "43",
Color::DarkTurquoise => "44",
Color::Turquoise2 => "45",
Color::Green1 => "46",
Color::SpringGreen2b => "47",
Color::SpringGreen1 => "48",
Color::MediumSpringGreen => "49",
Color::Cyan2 => "50",
Color::Cyan1 => "51",
Color::DarkRed1 => "52",
Color::DeepPink4a => "53",
Color::Purple4a => "54",
Color::Purple4b => "55",
Color::Purple3 => "56",
Color::BlueViolet => "57",
Color::Orange4a => "58",
Color::Grey37 => "59",
Color::MediumPurple4 => "60",
Color::SlateBlue3a => "61",
Color::SlateBlue3b => "62",
Color::RoyalBlue1 => "63",
Color::Chartreuse4 => "64",
Color::DarkSeaGreen4a => "65",
Color::PaleTurquoise4 => "66",
Color::SteelBlue => "67",
Color::SteelBlue3 => "68",
Color::CornflowerBlue => "69",
Color::Chartreuse3a => "70",
Color::DarkSeaGreen4b => "71",
Color::CadetBlue2 => "72",
Color::CadetBlue1 => "73",
Color::SkyBlue3 => "74",
Color::SteelBlue1a => "75",
Color::Chartreuse3b => "76",
Color::PaleGreen3a => "77",
Color::SeaGreen3 => "78",
Color::Aquamarine3 => "79",
Color::MediumTurquoise => "80",
Color::SteelBlue1b => "81",
Color::Chartreuse2a => "82",
Color::SeaGreen2 => "83",
Color::SeaGreen1a => "84",
Color::SeaGreen1b => "85",
Color::Aquamarine1a => "86",
Color::DarkSlateGray2 => "87",
Color::DarkRed2 => "88",
Color::DeepPink4b => "89",
Color::DarkMagenta1 => "90",
Color::DarkMagenta2 => "91",
Color::DarkViolet1a => "92",
Color::Purple1a => "93",
Color::Orange4b => "94",
Color::LightPink4 => "95",
Color::Plum4 => "96",
Color::MediumPurple3a => "97",
Color::MediumPurple3b => "98",
Color::SlateBlue1 => "99",
Color::Yellow4a => "100",
Color::Wheat4 => "101",
Color::Grey53 => "102",
Color::LightSlateGrey => "103",
Color::MediumPurple => "104",
Color::LightSlateBlue => "105",
Color::Yellow4b => "106",
Color::DarkOliveGreen3a => "107",
Color::DarkGreenSea => "108",
Color::LightSkyBlue3a => "109",
Color::LightSkyBlue3b => "110",
Color::SkyBlue2 => "111",
Color::Chartreuse2b => "112",
Color::DarkOliveGreen3b => "113",
Color::PaleGreen3b => "114",
Color::DarkSeaGreen3a => "115",
Color::DarkSlateGray3 => "116",
Color::SkyBlue1 => "117",
Color::Chartreuse1 => "118",
Color::LightGreen2 => "119",
Color::LightGreen3 => "120",
Color::PaleGreen1a => "121",
Color::Aquamarine1b => "122",
Color::DarkSlateGray1 => "123",
Color::Red3a => "124",
Color::DeepPink4c => "125",
Color::MediumVioletRed => "126",
Color::Magenta3a => "127",
Color::DarkViolet1b => "128",
Color::Purple1b => "129",
Color::DarkOrange3a => "130",
Color::IndianRed1a => "131",
Color::HotPink3a => "132",
Color::MediumOrchid3 => "133",
Color::MediumOrchid => "134",
Color::MediumPurple2a => "135",
Color::DarkGoldenrod => "136",
Color::LightSalmon3a => "137",
Color::RosyBrown => "138",
Color::Grey63 => "139",
Color::MediumPurple2b => "140",
Color::MediumPurple1 => "141",
Color::Gold3a => "142",
Color::DarkKhaki => "143",
Color::NavajoWhite3 => "144",
Color::Grey69 => "145",
Color::LightSteelBlue3 => "146",
Color::LightSteelBlue => "147",
Color::Yellow3a => "148",
Color::DarkOliveGreen3 => "149",
Color::DarkSeaGreen3b => "150",
Color::DarkSeaGreen2 => "151",
Color::LightCyan3 => "152",
Color::LightSkyBlue1 => "153",
Color::GreenYellow => "154",
Color::DarkOliveGreen2 => "155",
Color::PaleGreen1b => "156",
Color::DarkSeaGreen5b => "157",
Color::DarkSeaGreen5a => "158",
Color::PaleTurquoise1 => "159",
Color::Red3b => "160",
Color::DeepPink3a => "161",
Color::DeepPink3b => "162",
Color::Magenta3b => "163",
Color::Magenta3c => "164",
Color::Magenta2a => "165",
Color::DarkOrange3b => "166",
Color::IndianRed1b => "167",
Color::HotPink3b => "168",
Color::HotPink2 => "169",
Color::Orchid => "170",
Color::MediumOrchid1a => "171",
Color::Orange3 => "172",
Color::LightSalmon3b => "173",
Color::LightPink3 => "174",
Color::Pink3 => "175",
Color::Plum3 => "176",
Color::Violet => "177",
Color::Gold3b => "178",
Color::LightGoldenrod3 => "179",
Color::Tan => "180",
Color::MistyRose3 => "181",
Color::Thistle3 => "182",
Color::Plum2 => "183",
Color::Yellow3b => "184",
Color::Khaki3 => "185",
Color::LightGoldenrod2a => "186",
Color::LightYellow3 => "187",
Color::Grey84 => "188",
Color::LightSteelBlue1 => "189",
Color::Yellow2 => "190",
Color::DarkOliveGreen1a => "191",
Color::DarkOliveGreen1b => "192",
Color::DarkSeaGreen1 => "193",
Color::Honeydew2 => "194",
Color::LightCyan1 => "195",
Color::Red1 => "196",
Color::DeepPink2 => "197",
Color::DeepPink1a => "198",
Color::DeepPink1b => "199",
Color::Magenta2b => "200",
Color::Magenta1 => "201",
Color::OrangeRed1 => "202",
Color::IndianRed1c => "203",
Color::IndianRed1d => "204",
Color::HotPink1a => "205",
Color::HotPink1b => "206",
Color::MediumOrchid1b => "207",
Color::DarkOrange => "208",
Color::Salmon1 => "209",
Color::LightCoral => "210",
Color::PaleVioletRed1 => "211",
Color::Orchid2 => "212",
Color::Orchid1 => "213",
Color::Orange1 => "214",
Color::SandyBrown => "215",
Color::LightSalmon1 => "216",
Color::LightPink1 => "217",
Color::Pink1 => "218",
Color::Plum1 => "219",
Color::Gold1 => "220",
Color::LightGoldenrod2b => "221",
Color::LightGoldenrod2c => "222",
Color::NavajoWhite1 => "223",
Color::MistyRose1 => "224",
Color::Thistle1 => "225",
Color::Yellow1 => "226",
Color::LightGoldenrod1 => "227",
Color::Khaki1 => "228",
Color::Wheat1 => "229",
Color::CornSilk1 => "230",
Color::Grey100 => "231",
Color::Grey3 => "232",
Color::Grey7 => "233",
Color::Grey11 => "234",
Color::Grey15 => "235",
Color::Grey19 => "236",
Color::Grey23 => "237",
Color::Grey27 => "238",
Color::Grey30 => "239",
Color::Grey35 => "240",
Color::Grey39 => "241",
Color::Grey42 => "242",
Color::Grey46 => "243",
Color::Grey50 => "244",
Color::Grey54 => "245",
Color::Grey58 => "246",
Color::Grey62 => "247",
Color::Grey66 => "248",
Color::Grey70 => "249",
Color::Grey74 => "250",
Color::Grey78 => "251",
Color::Grey82 => "252",
Color::Grey85 => "253",
Color::Grey89 => "254",
Color::Grey93 => "255",
}
)
}
fn to_hsl(&self) -> HSL {
match self {
Color::Black => HSL::new(0.0, 0.0, 0.0),
Color::Red => HSL::new(0.0, 1.0, 0.25),
Color::Green => HSL::new(0.3333333333333333, 1.0, 0.25),
Color::Yellow => HSL::new(0.16666666666666666, 1.0, 0.25),
Color::Blue => HSL::new(0.6666666666666666, 1.0, 0.25),
Color::Magenta => HSL::new(0.8333333333333334, 1.0, 0.25),
Color::Cyan => HSL::new(0.5, 1.0, 0.25),
Color::LightGray => HSL::new(0.0, 0.0, 0.75),
Color::DarkGray => HSL::new(0.0, 0.0, 0.5),
Color::LightRed => HSL::new(0.0, 1.0, 0.5),
Color::LightGreen => HSL::new(0.3333333333333333, 1.0, 0.5),
Color::LightYellow => HSL::new(0.16666666666666666, 1.0, 0.5),
Color::LightBlue => HSL::new(0.6666666666666666, 1.0, 0.5),
Color::LightMagenta => HSL::new(0.8333333333333334, 1.0, 0.5),
Color::LightCyan => HSL::new(0.5, 1.0, 0.5),
Color::White => HSL::new(0.0, 0.0, 1.0),
Color::Grey0 => HSL::new(0.0, 0.0, 0.0),
Color::NavyBlue => HSL::new(0.6666666666666666, 1.0, 0.18),
Color::DarkBlue => HSL::new(0.6666666666666666, 1.0, 0.26),
Color::Blue3a => HSL::new(0.6666666666666666, 1.0, 0.34),
Color::Blue3b => HSL::new(0.6666666666666666, 1.0, 0.42),
Color::Blue1 => HSL::new(0.6666666666666666, 1.0, 0.5),
Color::DarkGreen => HSL::new(0.3333333333333333, 1.0, 0.18),
Color::DeepSkyBlue4a => HSL::new(0.5, 1.0, 0.18),
Color::DeepSkyBlue4b => HSL::new(0.5493827160493834, 1.0, 0.26),
Color::DeepSkyBlue4c => HSL::new(0.5761904761904749, 1.0, 0.34),
Color::DodgerBlue3 => HSL::new(0.5930232558139528, 1.0, 0.42),
Color::DodgerBlue2 => HSL::new(0.6045751633986917, 1.0, 0.5),
Color::Green4 => HSL::new(0.3333333333333333, 1.0, 0.26),
Color::SpringGreen4 => HSL::new(0.4506172839506167, 1.0, 0.26),
Color::Turquoise4 => HSL::new(0.5, 1.0, 0.26),
Color::DeepSkyBlue3a => HSL::new(0.538095238095239, 1.0, 0.34),
Color::DeepSkyBlue3b => HSL::new(0.5620155038759694, 1.0, 0.42),
Color::DodgerBlue1 => HSL::new(0.5784313725490194, 1.0, 0.5),
Color::Green3a => HSL::new(0.3333333333333333, 1.0, 0.34),
Color::SpringGreen3a => HSL::new(0.423809523809525, 1.0, 0.34),
Color::DarkCyan => HSL::new(0.4619047619047611, 1.0, 0.34),
Color::LightSeaGreen => HSL::new(0.5, 1.0, 0.34),
Color::DeepSkyBlue2 => HSL::new(0.5310077519379833, 1.0, 0.42),
Color::DeepSkyBlue1 => HSL::new(0.5522875816993472, 1.0, 0.5),
Color::Green3b => HSL::new(0.3333333333333333, 1.0, 0.42),
Color::SpringGreen3b => HSL::new(0.40697674418604723, 1.0, 0.42),
Color::SpringGreen2a => HSL::new(0.43798449612403056, 1.0, 0.42),
Color::Cyan3 => HSL::new(0.4689922480620166, 1.0, 0.42),
Color::DarkTurquoise => HSL::new(0.5, 1.0, 0.42),
Color::Turquoise2 => HSL::new(0.5261437908496722, 1.0, 0.5),
Color::Green1 => HSL::new(0.3333333333333333, 1.0, 0.5),
Color::SpringGreen2b => HSL::new(0.39542483660130834, 1.0, 0.5),
Color::SpringGreen1 => HSL::new(0.4215686274509806, 1.0, 0.5),
Color::MediumSpringGreen => HSL::new(0.4477124183006528, 1.0, 0.5),
Color::Cyan2 => HSL::new(0.4738562091503278, 1.0, 0.5),
Color::Cyan1 => HSL::new(0.5, 1.0, 0.5),
Color::DarkRed1 => HSL::new(0.0, 1.0, 0.18),
Color::DeepPink4a => HSL::new(0.8333333333333334, 1.0, 0.18),
Color::Purple4a => HSL::new(0.78395061728395, 1.0, 0.26),
Color::Purple4b => HSL::new(0.7571428571428583, 1.0, 0.34),
Color::Purple3 => HSL::new(0.7403100775193806, 1.0, 0.42),
Color::BlueViolet => HSL::new(0.7287581699346417, 1.0, 0.5),
Color::Orange4a => HSL::new(0.16666666666666666, 1.0, 0.18),
Color::Grey37 => HSL::new(0.0, 0.0, 0.37),
Color::MediumPurple4 => HSL::new(0.6666666666666666, 0.17, 0.45),
Color::SlateBlue3a => HSL::new(0.6666666666666666, 0.33, 0.52),
Color::SlateBlue3b => HSL::new(0.6666666666666666, 0.6, 0.6),
Color::RoyalBlue1 => HSL::new(0.6666666666666666, 1.0, 0.68),
Color::Chartreuse4 => HSL::new(0.21604938271604945, 1.0, 0.26),
Color::DarkSeaGreen4a => HSL::new(0.3333333333333333, 0.17, 0.45),
Color::PaleTurquoise4 => HSL::new(0.5, 0.17, 0.45),
Color::SteelBlue => HSL::new(0.5833333333333334, 0.33, 0.52),
Color::SteelBlue3 => HSL::new(0.6111111111111112, 0.6, 0.6),
Color::CornflowerBlue => HSL::new(0.625, 1.0, 0.68),
Color::Chartreuse3a => HSL::new(0.24285714285714277, 1.0, 0.34),
Color::DarkSeaGreen4b => HSL::new(0.3333333333333333, 0.33, 0.52),
Color::CadetBlue2 => HSL::new(0.4166666666666667, 0.33, 0.52),
Color::CadetBlue1 => HSL::new(0.5, 0.33, 0.52),
Color::SkyBlue3 => HSL::new(0.5555555555555556, 0.6, 0.6),
Color::SteelBlue1a => HSL::new(0.5833333333333334, 1.0, 0.68),
Color::Chartreuse3b => HSL::new(0.2596899224806203, 1.0, 0.42),
Color::PaleGreen3a => HSL::new(0.3333333333333333, 0.6, 0.6),
Color::SeaGreen3 => HSL::new(0.3888888888888889, 0.6, 0.6),
Color::Aquamarine3 => HSL::new(0.4444444444444444, 0.6, 0.6),
Color::MediumTurquoise => HSL::new(0.5, 0.6, 0.6),
Color::SteelBlue1b => HSL::new(0.5416666666666666, 1.0, 0.68),
Color::Chartreuse2a => HSL::new(0.27124183006535946, 1.0, 0.5),
Color::SeaGreen2 => HSL::new(0.3333333333333333, 1.0, 0.68),
Color::SeaGreen1a => HSL::new(0.375, 1.0, 0.68),
Color::SeaGreen1b => HSL::new(0.4166666666666667, 1.0, 0.68),
Color::Aquamarine1a => HSL::new(0.4583333333333333, 1.0, 0.68),
Color::DarkSlateGray2 => HSL::new(0.5, 1.0, 0.68),
Color::DarkRed2 => HSL::new(0.0, 1.0, 0.26),
Color::DeepPink4b => HSL::new(0.8827160493827166, 1.0, 0.26),
Color::DarkMagenta1 => HSL::new(0.8333333333333334, 1.0, 0.26),
Color::DarkMagenta2 => HSL::new(0.7952380952380944, 1.0, 0.34),
Color::DarkViolet1a => HSL::new(0.7713178294573639, 1.0, 0.42),
Color::Purple1a => HSL::new(0.7549019607843138, 1.0, 0.5),
Color::Orange4b => HSL::new(0.11728395061728389, 1.0, 0.26),
Color::LightPink4 => HSL::new(0.0, 0.17, 0.45),
Color::Plum4 => HSL::new(0.8333333333333334, 0.17, 0.45),
Color::MediumPurple3a => HSL::new(0.75, 0.33, 0.52),
Color::MediumPurple3b => HSL::new(0.7222222222222222, 0.6, 0.6),
Color::SlateBlue1 => HSL::new(0.7083333333333334, 1.0, 0.68),
Color::Yellow4a => HSL::new(0.16666666666666666, 1.0, 0.26),
Color::Wheat4 => HSL::new(0.16666666666666666, 0.17, 0.45),
Color::Grey53 => HSL::new(0.0, 0.0, 0.52),
Color::LightSlateGrey => HSL::new(0.6666666666666666, 0.2, 0.6),
Color::MediumPurple => HSL::new(0.6666666666666666, 0.5, 0.68),
Color::LightSlateBlue => HSL::new(0.6666666666666666, 1.0, 0.76),
Color::Yellow4b => HSL::new(0.2047619047619047, 1.0, 0.34),
Color::DarkOliveGreen3a => HSL::new(0.25, 0.33, 0.52),
Color::DarkGreenSea => HSL::new(0.3333333333333333, 0.2, 0.6),
Color::LightSkyBlue3a => HSL::new(0.5, 0.2, 0.6),
Color::LightSkyBlue3b => HSL::new(0.5833333333333334, 0.5, 0.68),
Color::SkyBlue2 => HSL::new(0.6111111111111112, 1.0, 0.76),
Color::Chartreuse2b => HSL::new(0.22868217054263557, 1.0, 0.42),
Color::DarkOliveGreen3b => HSL::new(0.2777777777777778, 0.6, 0.6),
Color::PaleGreen3b => HSL::new(0.3333333333333333, 0.5, 0.68),
Color::DarkSeaGreen3a => HSL::new(0.4166666666666667, 0.5, 0.68),
Color::DarkSlateGray3 => HSL::new(0.5, 0.5, 0.68),
Color::SkyBlue1 => HSL::new(0.5555555555555556, 1.0, 0.76),
Color::Chartreuse1 => HSL::new(0.2450980392156864, 1.0, 0.5),
Color::LightGreen2 => HSL::new(0.2916666666666667, 1.0, 0.68),
Color::LightGreen3 => HSL::new(0.3333333333333333, 1.0, 0.76),
Color::PaleGreen1a => HSL::new(0.3888888888888889, 1.0, 0.76),
Color::Aquamarine1b => HSL::new(0.4444444444444444, 1.0, 0.76),
Color::DarkSlateGray1 => HSL::new(0.5, 1.0, 0.76),
Color::Red3a => HSL::new(0.0, 1.0, 0.34),
Color::DeepPink4c => HSL::new(0.9095238095238083, 1.0, 0.34),
Color::MediumVioletRed => HSL::new(0.8714285714285722, 1.0, 0.34),
Color::Magenta3a => HSL::new(0.8333333333333334, 1.0, 0.34),
Color::DarkViolet1b => HSL::new(0.80232558139535, 1.0, 0.42),
Color::Purple1b => HSL::new(0.7810457516339862, 1.0, 0.5),
Color::DarkOrange3a => HSL::new(0.09047619047619054, 1.0, 0.34),
Color::IndianRed1a => HSL::new(0.0, 0.33, 0.52),
Color::HotPink3a => HSL::new(0.9166666666666666, 0.33, 0.52),
Color::MediumOrchid3 => HSL::new(0.8333333333333334, 0.33, 0.52),
Color::MediumOrchid => HSL::new(0.7777777777777778, 0.6, 0.6),
Color::MediumPurple2a => HSL::new(0.75, 1.0, 0.68),
Color::DarkGoldenrod => HSL::new(0.12857142857142861, 1.0, 0.34),
Color::LightSalmon3a => HSL::new(0.08333333333333333, 0.33, 0.52),
Color::RosyBrown => HSL::new(0.0, 0.2, 0.6),
Color::Grey63 => HSL::new(0.8333333333333334, 0.2, 0.6),
Color::MediumPurple2b => HSL::new(0.75, 0.5, 0.68),
Color::MediumPurple1 => HSL::new(0.7222222222222222, 1.0, 0.76),
Color::Gold3a => HSL::new(0.16666666666666666, 1.0, 0.34),
Color::DarkKhaki => HSL::new(0.16666666666666666, 0.33, 0.52),
Color::NavajoWhite3 => HSL::new(0.16666666666666666, 0.2, 0.6),
Color::Grey69 => HSL::new(0.0, 0.0, 0.68),
Color::LightSteelBlue3 => HSL::new(0.6666666666666666, 0.33, 0.76),
Color::LightSteelBlue => HSL::new(0.6666666666666666, 1.0, 0.84),
Color::Yellow3a => HSL::new(0.1976744186046511, 1.0, 0.42),
Color::DarkOliveGreen3 => HSL::new(0.2222222222222222, 0.6, 0.6),
Color::DarkSeaGreen3b => HSL::new(0.25, 0.5, 0.68),
Color::DarkSeaGreen2 => HSL::new(0.3333333333333333, 0.33, 0.76),
Color::LightCyan3 => HSL::new(0.5, 0.33, 0.76),
Color::LightSkyBlue1 => HSL::new(0.5833333333333334, 1.0, 0.84),
Color::GreenYellow => HSL::new(0.21895424836601304, 1.0, 0.5),
Color::DarkOliveGreen2 => HSL::new(0.25, 1.0, 0.68),
Color::PaleGreen1b => HSL::new(0.2777777777777778, 1.0, 0.76),
Color::DarkSeaGreen5b => HSL::new(0.3333333333333333, 1.0, 0.84),
Color::DarkSeaGreen5a => HSL::new(0.4166666666666667, 1.0, 0.84),
Color::PaleTurquoise1 => HSL::new(0.5, 1.0, 0.84),
Color::Red3b => HSL::new(0.0, 1.0, 0.42),
Color::DeepPink3a => HSL::new(0.926356589147286, 1.0, 0.42),
Color::DeepPink3b => HSL::new(0.8953488372093028, 1.0, 0.42),
Color::Magenta3b => HSL::new(0.8643410852713166, 1.0, 0.42),
Color::Magenta3c => HSL::new(0.8333333333333334, 1.0, 0.42),
Color::Magenta2a => HSL::new(0.8071895424836611, 1.0, 0.5),
Color::DarkOrange3b => HSL::new(0.07364341085271306, 1.0, 0.42),
Color::IndianRed1b => HSL::new(0.0, 0.6, 0.6),
Color::HotPink3b => HSL::new(0.9444444444444444, 0.6, 0.6),
Color::HotPink2 => HSL::new(0.8888888888888888, 0.6, 0.6),
Color::Orchid => HSL::new(0.8333333333333334, 0.6, 0.6),
Color::MediumOrchid1a => HSL::new(0.7916666666666666, 1.0, 0.68),
Color::Orange3 => HSL::new(0.10465116279069778, 1.0, 0.42),
Color::LightSalmon3b => HSL::new(0.05555555555555555, 0.6, 0.6),
Color::LightPink3 => HSL::new(0.0, 0.5, 0.68),
Color::Pink3 => HSL::new(0.9166666666666666, 0.5, 0.68),
Color::Plum3 => HSL::new(0.8333333333333334, 0.5, 0.68),
Color::Violet => HSL::new(0.7777777777777778, 1.0, 0.76),
Color::Gold3b => HSL::new(0.13565891472868222, 1.0, 0.42),
Color::LightGoldenrod3 => HSL::new(0.1111111111111111, 0.6, 0.6),
Color::Tan => HSL::new(0.08333333333333333, 0.5, 0.68),
Color::MistyRose3 => HSL::new(0.0, 0.33, 0.76),
Color::Thistle3 => HSL::new(0.8333333333333334, 0.33, 0.76),
Color::Plum2 => HSL::new(0.75, 1.0, 0.84),
Color::Yellow3b => HSL::new(0.16666666666666666, 1.0, 0.42),
Color::Khaki3 => HSL::new(0.16666666666666666, 0.6, 0.6),
Color::LightGoldenrod2a => HSL::new(0.16666666666666666, 0.5, 0.68),
Color::LightYellow3 => HSL::new(0.16666666666666666, 0.33, 0.76),
Color::Grey84 => HSL::new(0.0, 0.0, 0.84),
Color::LightSteelBlue1 => HSL::new(0.6666666666666666, 1.0, 0.92),
Color::Yellow2 => HSL::new(0.19281045751633974, 1.0, 0.5),
Color::DarkOliveGreen1a => HSL::new(0.20833333333333334, 1.0, 0.68),
Color::DarkOliveGreen1b => HSL::new(0.2222222222222222, 1.0, 0.76),
Color::DarkSeaGreen1 => HSL::new(0.25, 1.0, 0.84),
Color::Honeydew2 => HSL::new(0.3333333333333333, 1.0, 0.92),
Color::LightCyan1 => HSL::new(0.5, 1.0, 0.92),
Color::Red1 => HSL::new(0.0, 1.0, 0.5),
Color::DeepPink2 => HSL::new(0.937908496732025, 1.0, 0.5),
Color::DeepPink1a => HSL::new(0.9117647058823528, 1.0, 0.5),
Color::DeepPink1b => HSL::new(0.8856209150326805, 1.0, 0.5),
Color::Magenta2b => HSL::new(0.8594771241830055, 1.0, 0.5),
Color::Magenta1 => HSL::new(0.8333333333333334, 1.0, 0.5),
Color::OrangeRed1 => HSL::new(0.06209150326797389, 1.0, 0.5),
Color::IndianRed1c => HSL::new(0.0, 1.0, 0.68),
Color::IndianRed1d => HSL::new(0.9583333333333334, 1.0, 0.68),
Color::HotPink1a => HSL::new(0.9166666666666666, 1.0, 0.68),
Color::HotPink1b => HSL::new(0.875, 1.0, 0.68),
Color::MediumOrchid1b => HSL::new(0.8333333333333334, 1.0, 0.68),
Color::DarkOrange => HSL::new(0.08823529411764694, 1.0, 0.5),
Color::Salmon1 => HSL::new(0.041666666666666664, 1.0, 0.68),
Color::LightCoral => HSL::new(0.0, 1.0, 0.76),
Color::PaleVioletRed1 => HSL::new(0.9444444444444444, 1.0, 0.76),
Color::Orchid2 => HSL::new(0.8888888888888888, 1.0, 0.76),
Color::Orchid1 => HSL::new(0.8333333333333334, 1.0, 0.76),
Color::Orange1 => HSL::new(0.11437908496732027, 1.0, 0.5),
Color::SandyBrown => HSL::new(0.08333333333333333, 1.0, 0.68),
Color::LightSalmon1 => HSL::new(0.05555555555555555, 1.0, 0.76),
Color::LightPink1 => HSL::new(0.0, 1.0, 0.84),
Color::Pink1 => HSL::new(0.9166666666666666, 1.0, 0.84),
Color::Plum1 => HSL::new(0.8333333333333334, 1.0, 0.84),
Color::Gold1 => HSL::new(0.14052287581699335, 1.0, 0.5),
Color::LightGoldenrod2b => HSL::new(0.125, 1.0, 0.68),
Color::LightGoldenrod2c => HSL::new(0.1111111111111111, 1.0, 0.76),
Color::NavajoWhite1 => HSL::new(0.08333333333333333, 1.0, 0.84),
Color::MistyRose1 => HSL::new(0.0, 1.0, 0.92),
Color::Thistle1 => HSL::new(0.8333333333333334, 1.0, 0.92),
Color::Yellow1 => HSL::new(0.16666666666666666, 1.0, 0.5),
Color::LightGoldenrod1 => HSL::new(0.16666666666666666, 1.0, 0.68),
Color::Khaki1 => HSL::new(0.16666666666666666, 1.0, 0.76),
Color::Wheat1 => HSL::new(0.16666666666666666, 1.0, 0.84),
Color::CornSilk1 => HSL::new(0.16666666666666666, 1.0, 0.92),
Color::Grey100 => HSL::new(0.0, 0.0, 1.0),
Color::Grey3 => HSL::new(0.0, 0.0, 0.03),
Color::Grey7 => HSL::new(0.0, 0.0, 0.07),
Color::Grey11 => HSL::new(0.0, 0.0, 0.1),
Color::Grey15 => HSL::new(0.0, 0.0, 0.14),
Color::Grey19 => HSL::new(0.0, 0.0, 0.18),
Color::Grey23 => HSL::new(0.0, 0.0, 0.22),
Color::Grey27 => HSL::new(0.0, 0.0, 0.26),
Color::Grey30 => HSL::new(0.0, 0.0, 0.3),
Color::Grey35 => HSL::new(0.0, 0.0, 0.34),
Color::Grey39 => HSL::new(0.0, 0.0, 0.37),
Color::Grey42 => HSL::new(0.0, 0.0, 0.4),
Color::Grey46 => HSL::new(0.0, 0.0, 0.46),
Color::Grey50 => HSL::new(0.0, 0.0, 0.5),
Color::Grey54 => HSL::new(0.0, 0.0, 0.54),
Color::Grey58 => HSL::new(0.0, 0.0, 0.58),
Color::Grey62 => HSL::new(0.0, 0.0, 0.61),
Color::Grey66 => HSL::new(0.0, 0.0, 0.65),
Color::Grey70 => HSL::new(0.0, 0.0, 0.69),
Color::Grey74 => HSL::new(0.0, 0.0, 0.73),
Color::Grey78 => HSL::new(0.0, 0.0, 0.77),
Color::Grey82 => HSL::new(0.0, 0.0, 0.81),
Color::Grey85 => HSL::new(0.0, 0.0, 0.85),
Color::Grey89 => HSL::new(0.0, 0.0, 0.89),
Color::Grey93 => HSL::new(0.0, 0.0, 0.93),
}
}
}
impl Color {
pub fn iterator() -> Iter<'static, Color> {
use Color::*;
static ITEMS: [Color; 256] = [Black, Red, Green, Yellow, Blue, Magenta, Cyan, LightGray, DarkGray, LightRed, LightGreen, LightYellow, LightBlue, LightMagenta, LightCyan, White, Grey0, NavyBlue, DarkBlue, Blue3a, Blue3b, Blue1, DarkGreen, DeepSkyBlue4a, DeepSkyBlue4b, DeepSkyBlue4c, DodgerBlue3, DodgerBlue2, Green4, SpringGreen4, Turquoise4, DeepSkyBlue3a, DeepSkyBlue3b, DodgerBlue1, Green3a, SpringGreen3a, DarkCyan, LightSeaGreen, DeepSkyBlue2, DeepSkyBlue1, Green3b, SpringGreen3b, SpringGreen2a, Cyan3, DarkTurquoise, Turquoise2, Green1, SpringGreen2b, SpringGreen1, MediumSpringGreen, Cyan2, Cyan1, DarkRed1, DeepPink4a, Purple4a, Purple4b, Purple3, BlueViolet, Orange4a, Grey37, MediumPurple4, SlateBlue3a, SlateBlue3b, RoyalBlue1, Chartreuse4, DarkSeaGreen4a, PaleTurquoise4, SteelBlue, SteelBlue3, CornflowerBlue, Chartreuse3a, DarkSeaGreen4b, CadetBlue2, CadetBlue1, SkyBlue3, SteelBlue1a, Chartreuse3b, PaleGreen3a, SeaGreen3, Aquamarine3, MediumTurquoise, SteelBlue1b, Chartreuse2a, SeaGreen2, SeaGreen1a, SeaGreen1b, Aquamarine1a, DarkSlateGray2, DarkRed2, DeepPink4b, DarkMagenta1, DarkMagenta2, DarkViolet1a, Purple1a, Orange4b, LightPink4, Plum4, MediumPurple3a, MediumPurple3b, SlateBlue1, Yellow4a, Wheat4, Grey53, LightSlateGrey, MediumPurple, LightSlateBlue, Yellow4b, DarkOliveGreen3a, DarkGreenSea, LightSkyBlue3a, LightSkyBlue3b, SkyBlue2, Chartreuse2b, DarkOliveGreen3b, PaleGreen3b, DarkSeaGreen3a, DarkSlateGray3, SkyBlue1, Chartreuse1, LightGreen2, LightGreen3, PaleGreen1a, Aquamarine1b, DarkSlateGray1, Red3a, DeepPink4c, MediumVioletRed, Magenta3a, DarkViolet1b, Purple1b, DarkOrange3a, IndianRed1a, HotPink3a, MediumOrchid3, MediumOrchid, MediumPurple2a, DarkGoldenrod, LightSalmon3a, RosyBrown, Grey63, MediumPurple2b, MediumPurple1, Gold3a, DarkKhaki, NavajoWhite3, Grey69, LightSteelBlue3, LightSteelBlue, Yellow3a, DarkOliveGreen3, DarkSeaGreen3b, DarkSeaGreen2, LightCyan3, LightSkyBlue1, GreenYellow, DarkOliveGreen2, PaleGreen1b, DarkSeaGreen5b, DarkSeaGreen5a, PaleTurquoise1, Red3b, DeepPink3a, DeepPink3b, Magenta3b, Magenta3c, Magenta2a, DarkOrange3b, IndianRed1b, HotPink3b, HotPink2, Orchid, MediumOrchid1a, Orange3, LightSalmon3b, LightPink3, Pink3, Plum3, Violet, Gold3b, LightGoldenrod3, Tan, MistyRose3, Thistle3, Plum2, Yellow3b, Khaki3, LightGoldenrod2a, LightYellow3, Grey84, LightSteelBlue1, Yellow2, DarkOliveGreen1a, DarkOliveGreen1b, DarkSeaGreen1, Honeydew2, LightCyan1, Red1, DeepPink2, DeepPink1a, DeepPink1b, Magenta2b, Magenta1, OrangeRed1, IndianRed1c, IndianRed1d, HotPink1a, HotPink1b, MediumOrchid1b, DarkOrange, Salmon1, LightCoral, PaleVioletRed1, Orchid2, Orchid1, Orange1, SandyBrown, LightSalmon1, LightPink1, Pink1, Plum1, Gold1, LightGoldenrod2b, LightGoldenrod2c, NavajoWhite1, MistyRose1, Thistle1, Yellow1, LightGoldenrod1, Khaki1, Wheat1, CornSilk1, Grey100, Grey3, Grey7, Grey11, Grey15, Grey19, Grey23, Grey27, Grey30, Grey35, Grey39, Grey42, Grey46, Grey50, Grey54, Grey58, Grey62, Grey66, Grey70, Grey74, Grey78, Grey82, Grey85, Grey89, Grey93];
ITEMS.iter()
}
}
#[derive(Copy, Clone)]
pub enum ColorMode {
SIMPLE,
RGB,
HSL,
}
#[derive(Clone)]
pub struct Colorado {
mode: ColorMode,
color: String,
}
impl Default for Colorado {
fn default() -> Colorado {
Colorado {
mode: ColorMode::SIMPLE,
color: String::default(),
}
}
}
impl Colorado {
pub fn new<C: ColorInterface>(color: C) -> Colorado {
let c = format!("{}", color.to_color_str());
Colorado {
color: c.clone(),
mode: if c.contains(";") {
ColorMode::RGB
} else {
ColorMode::SIMPLE
},
}
}
pub fn get_color(&self) -> String { self.color.clone() }
pub fn get_mode(&self) -> ColorMode { self.mode }
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_rgb_iterator() {
for _ in Color::iterator() {}
}
}

105
third_party/rust/colorful/src/core/hsl.rs поставляемый
Просмотреть файл

@ -1,105 +0,0 @@
use core::ColorInterface;
use core::rgb::RGB;
#[derive(Debug, Copy, Clone, PartialEq)]
pub struct HSL {
// range 0 ≤ H < 1.0, 0 ≤ S ≤ 1.0 and 0 ≤ L ≤ 1.0:
pub h: f32,
s: f32,
l: f32,
}
impl HSL {
pub fn new(h: f32, s: f32, l: f32) -> HSL {
HSL { h: _round(h), s: _round(s), l: _round(l) }
}
pub fn hsl_to_rgb(&self) -> RGB {
let red: f32;
let green: f32;
let blue: f32;
let var_1: f32;
let var_2: f32;
if self.s == 0.0 {
let tmp = self.l * 255.0;
red = tmp;
green = tmp;
blue = tmp;
} else {
if self.l < 0.5 {
var_2 = self.l * (1.0 + self.s);
} else {
var_2 = (self.l + self.s) - (self.s * self.l);
}
var_1 = 2.0 * self.l - var_2;
red = 255.0 * hue_2_rgb(var_1, var_2, &mut (self.h + (1.0 / 3.0)));
green = 255.0 * hue_2_rgb(var_1, var_2, &mut self.h.clone());
blue = 255.0 * hue_2_rgb(var_1, var_2, &mut (self.h - (1.0 / 3.0)));
}
RGB::new(red.round() as u8, green.round() as u8, blue.round() as u8)
}
}
impl ColorInterface for HSL {
fn to_color_str(&self) -> String {
self.hsl_to_rgb().to_color_str()
}
fn to_hsl(&self) -> HSL { *self }
}
fn hue_2_rgb(v1: f32, v2: f32, vh: &mut f32) -> f32 {
if *vh < 0.0 {
*vh += 1.0;
}
if *vh > 1.0 {
*vh -= 1.0;
}
if 6.0 * *vh < 1.0 {
return v1 + (v2 - v1) * 6.0 * *vh;
}
if 2.0 * *vh < 1.0 {
return v2;
}
if 3.0 * *vh < 2.0 {
return v1 + (v2 - v1) * (2.0 / 3.0 - *vh) * 6.0;
}
v1
}
fn _round(value: f32) -> f32 {
if value < 0.0 {
0.0
} else if value >= 1.0 {
1.0
} else {
value
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_hsl_2_rgb_1() {
let hsl = HSL::new(0.7, 0.50, 0.60);
let rgb = RGB::new(122, 102, 204);
assert_eq!(rgb, hsl.hsl_to_rgb());
}
#[test]
fn test_hsl_2_rgb_2() {
let hsl = HSL::new(0.7, 0.0, 0.60);
let rgb = RGB::new(153, 153, 153);
assert_eq!(rgb, hsl.hsl_to_rgb());
}
#[test]
fn test_hsl_2_rgb_3() {
let hsl = HSL::new(0.7, 0.50, 0.30);
let rgb = RGB::new(54, 38, 115);
assert_eq!(rgb, hsl.hsl_to_rgb());
}
}

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

@ -1,36 +0,0 @@
use core::colors::Colorado;
use core::style::Style;
use HSL;
pub mod colors;
pub mod symbols;
pub mod style;
pub mod color_string;
pub mod rgb;
pub mod hsl;
pub trait StrMarker {
fn to_str(&self) -> String;
fn get_fg_color(&self) -> Option<Colorado> { None }
fn get_bg_color(&self) -> Option<Colorado> { None }
fn get_style(&self) -> Option<Vec<Style>> { None }
}
impl<'a> StrMarker for &'a str {
fn to_str(&self) -> String {
String::from(*self)
}
}
impl StrMarker for String {
fn to_str(&self) -> String {
self.clone()
}
}
/// `ColorInterface` is for basic trait for `Colorful`, `RGB`, `HSL` and `Color` implement this trait.
pub trait ColorInterface: Clone {
fn to_color_str(&self) -> String;
fn to_hsl(&self) -> HSL;
}

90
third_party/rust/colorful/src/core/rgb.rs поставляемый
Просмотреть файл

@ -1,90 +0,0 @@
use core::ColorInterface;
use HSL;
#[derive(Debug, Copy, Clone, PartialEq)]
pub struct RGB {
// range 0 -255
r: u8,
g: u8,
b: u8,
}
impl RGB {
pub fn new(r: u8, g: u8, b: u8) -> RGB {
RGB { r, g, b }
}
pub fn unpack(&self) -> (u8, u8, u8) {
(self.r, self.g, self.b)
}
pub fn rgb_to_hsl(&self) -> HSL {
let (r, g, b) = self.unpack();
let r = r as f32 / 255.0;
let g = g as f32 / 255.0;
let b = b as f32 / 255.0;
let max = r.max(g).max(b);
let min = r.min(g).min(b);
let mut h: f32 = 0.0;
let mut s: f32 = 0.0;
let l = (max + min) / 2.0;
if max != min {
let d = max - min;
s = if l > 0.5 { d / (2.0 - max - min) } else { d / (max + min) };
if max == r {
h = (g - b) / d + (if g < b { 6.0 } else { 0.0 });
} else if max == g {
h = (b - r) / d + 2.0;
} else {
h = (r - g) / d + 4.0;
}
h /= 6.0;
}
return HSL::new(h, s, l);
}
}
impl ColorInterface for RGB {
fn to_color_str(&self) -> String {
format!("{};{};{}", self.r, self.g, self.b)
}
fn to_hsl(&self) -> HSL { self.rgb_to_hsl() }
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_rgb_2_hsl_1() {
let hsl = HSL::new(0.69934636, 0.49999997, 0.60);
let rgb = RGB::new(122, 102, 204);
assert_eq!(hsl, rgb.rgb_to_hsl());
}
#[test]
fn test_rgb_2_hsl_2() {
let hsl = HSL::new(0.0, 0.0, 0.60);
let rgb = RGB::new(153, 153, 153);
assert_eq!(hsl, rgb.rgb_to_hsl());
}
#[test]
fn test_rgb_2_hsl_3() {
let hsl = HSL::new(0.7012987, 0.50326794, 0.30);
let rgb = RGB::new(54, 38, 115);
assert_eq!(hsl, rgb.rgb_to_hsl());
}
#[test]
fn test_rgb_2_hsl_4() {
let hsl = HSL::new(0.08333334, 1.0, 0.6862745);
let rgb = RGB::new(255, 175, 95);
assert_eq!(hsl, rgb.rgb_to_hsl());
}
}

24
third_party/rust/colorful/src/core/style.rs поставляемый
Просмотреть файл

@ -1,24 +0,0 @@
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub enum Style {
Bold,
Dim,
Underlined,
Blink,
// invert the foreground and background colors
Reverse,
// useful for passwords
Hidden,
}
impl Style {
pub fn to_string(&self) -> String {
match self {
Style::Bold => String::from("1"),
Style::Dim => String::from("2"),
Style::Underlined => String::from("4"),
Style::Blink => String::from("5"),
Style::Reverse => String::from("7"),
Style::Hidden => String::from("8"),
}
}
}

55
third_party/rust/colorful/src/core/symbols.rs поставляемый
Просмотреть файл

@ -1,55 +0,0 @@
use std::fmt::Display;
use std::fmt::Formatter;
use std::fmt::Result as FmtResult;
pub enum Symbol {
Mode,
Semicolon,
LeftBrackets,
Esc,
Reset,
Simple256Foreground,
Simple256Background,
RgbForeground,
RgbBackground,
ResetStyle,
ResetForeground,
ResetBackground,
ClearScreenFromCursorToEnd,
ClearScreenUpToCursor,
ClearEntireScreen,
ClearLineFromCursorToEnd,
ClearLineUpToCursor,
ClearEntireLine
}
impl Symbol {
pub fn to_str<'a>(&self) -> &'a str {
match self {
Symbol::Mode => "m",
Symbol::Semicolon => ";",
Symbol::LeftBrackets => "[",
Symbol::Esc => "\x1B",
Symbol::Reset => "\x1B[0m",
Symbol::Simple256Foreground => "\x1B[38;5;",
Symbol::Simple256Background => "\x1B[48;5;",
Symbol::RgbForeground => "\x1B[38;2;",
Symbol::RgbBackground => "\x1B[48;2;",
Symbol::ResetStyle => "\x1B[20m",
Symbol::ResetForeground => "\x1B[39m",
Symbol::ResetBackground => "\x1B[49m",
Symbol::ClearScreenFromCursorToEnd => "\x1B[0J",
Symbol::ClearScreenUpToCursor => "\x1B[1J",
Symbol::ClearEntireScreen => "\x1B[2J",
Symbol::ClearLineFromCursorToEnd => "\x1B[0K",
Symbol::ClearLineUpToCursor => "\x1B[1K",
Symbol::ClearEntireLine => "\x1B[2K",
}
}
}
impl Display for Symbol {
fn fmt(&self, f: &mut Formatter) -> FmtResult {
write!(f, "{}", self.to_str())
}
}

316
third_party/rust/colorful/src/lib.rs поставляемый
Просмотреть файл

@ -1,316 +0,0 @@
//! Colored your terminal.
//! You can use this package to make your string colorful in terminal.
//! Platform support:
//! - Linux
//! - macOS
//! <img src="https://github.com/rocketsman/colorful/blob/master/images/1.png?raw=true" width="60%">
/// It is recommended to use `Color` enum item to set foreground color not literal string.
/// Literal string makes program uncontrollable, you can use `Color` `RGB::new(1,1,1)` or `HSL::new(0.5,0.5,0.5)`
/// to create color and pass the variable to method.
/// # Examples
/// ```
/// extern crate colorful;
///
/// use colorful::Colorful;
/// use colorful::Color;
///
/// fn main(){
/// let s = "Hello world";
/// println!("{}",s.color(Color::Red).bg_color(Color::Yellow).bold().to_string());
/// }
/// ```
use std::{thread, time};
use core::color_string::CString;
use core::ColorInterface;
pub use core::colors::Color;
pub use core::hsl::HSL;
pub use core::rgb::RGB;
use core::StrMarker;
pub use core::style::Style;
pub mod core;
/// Support `&str` and `String`, you can use `"text".red()` and `s.red()` for s:String
pub trait Colorful {
/// Set foreground color. Support Color enum and HSL, RGB mode.
/// ```Rust
/// extern crate colorful;
///
/// use colorful::Colorful;
/// use colorful::Color;
///
/// fn main() {
/// let a = "Hello world";
/// println!("{}", a.color(Color::Red));
/// println!("{}", a.blue());
/// let b = String::from("Hello world");
/// println!("{}", b.blue());
/// }
/// ```
fn color<C: ColorInterface>(self, color: C) -> CString;
fn black(self) -> CString;
fn red(self) -> CString;
fn green(self) -> CString;
fn yellow(self) -> CString;
fn blue(self) -> CString;
fn magenta(self) -> CString;
fn cyan(self) -> CString;
fn light_gray(self) -> CString;
fn dark_gray(self) -> CString;
fn light_red(self) -> CString;
fn light_green(self) -> CString;
fn light_yellow(self) -> CString;
fn light_blue(self) -> CString;
fn light_magenta(self) -> CString;
fn light_cyan(self) -> CString;
fn white(self) -> CString;
/// Set background color. Support Color enum and HSL, RGB mode.
/// ```Rust
/// extern crate colorful;
///
/// use colorful::Colorful;
/// use colorful::Color;
///
/// fn main() {
/// let a = "Hello world";
/// println!("{}", a.bg_color(Color::Red));
/// }
/// ```
fn bg_color<C: ColorInterface>(self, color: C) -> CString;
fn bg_black(self) -> CString;
fn bg_red(self) -> CString;
fn bg_green(self) -> CString;
fn bg_yellow(self) -> CString;
fn bg_blue(self) -> CString;
fn bg_magenta(self) -> CString;
fn bg_cyan(self) -> CString;
fn bg_light_gray(self) -> CString;
fn bg_dark_gray(self) -> CString;
fn bg_light_red(self) -> CString;
fn bg_light_green(self) -> CString;
fn bg_light_yellow(self) -> CString;
fn bg_light_blue(self) -> CString;
fn bg_light_magenta(self) -> CString;
fn bg_light_cyan(self) -> CString;
fn bg_white(self) -> CString;
/// Support RGB color and HSL mode
/// ```Rust
/// extern crate colorful;
///
/// use colorful::Colorful;
///
/// fn main() {
/// let a = "Hello world";
/// println!("{}", a.rgb(100, 100, 100).bg_rgb(100, 100, 100);
/// println!("{}", a.hsl(0.5, 0.5, 0.5)).bg_hsl(0.5, 0.5, 0.5));
/// }
/// ```
fn rgb(self, r: u8, g: u8, b: u8) -> CString;
fn bg_rgb(self, r: u8, g: u8, b: u8) -> CString;
fn hsl(self, h: f32, s: f32, l: f32) -> CString;
fn bg_hsl(self, h: f32, s: f32, l: f32) -> CString;
/// Terminal effect
/// See [ANSI escape code](https://en.wikipedia.org/wiki/ANSI_escape_code)
/// For terminals compatibility, check [Terminals compatibility](https://github.com/rocketsman/colorful#terminals-compatibility)
fn style(self, style: Style) -> CString;
/// Turn bold mode on.
fn bold(self) -> CString;
/// Turn blinking mode on. Blink doesn't work in many terminal emulators ,and it will still work on the console.
fn blink(self) -> CString;
/// Turn low intensity mode on.
fn dim(self) -> CString;
/// Turn underline mode on.
fn underlined(self) -> CString;
/// Turn reverse mode on (invert the foreground and background colors).
fn reverse(self) -> CString;
/// Turn invisible text mode on (useful for passwords).
fn hidden(self) -> CString;
/// Apply gradient color to sentences, support multiple lines.
/// You can use `use colorful::Color;` or `use colorful::HSL;` or `use colorful::RGB;`
/// to import colors and create gradient string.
/// ```Rust
/// extern crate colorful;
///
/// use colorful::Color;
/// use colorful::Colorful;
///
/// fn main() {
/// println!("{}", "This code is editable and runnable!".gradient(Color::Red));
/// println!("{}", "¡Este código es editable y ejecutable!".gradient(Color::Green));
/// println!("{}", "Ce code est modifiable et exécutable !".gradient(Color::Yellow));
/// println!("{}", "Questo codice è modificabile ed eseguibile!".gradient(Color::Blue));
/// println!("{}", "このコードは編集して実行出来ます!".gradient(Color::Magenta));
/// println!("{}", "여기에서 코드를 수정하고 실행할 수 있습니다!".gradient(Color::Cyan));
/// println!("{}", "Ten kod można edytować oraz uruchomić!".gradient(Color::LightGray));
/// println!("{}", "Este código é editável e executável!".gradient(Color::DarkGray));
/// println!("{}", "Этот код можно отредактировать и запустить!".gradient(Color::LightRed));
/// println!("{}", "Bạn có thể edit và run code trực tiếp!".gradient(Color::LightGreen));
/// println!("{}", "这段代码是可以编辑并且能够运行的!".gradient(Color::LightYellow));
/// println!("{}", "Dieser Code kann bearbeitet und ausgeführt werden!".gradient(Color::LightBlue));
/// println!("{}", "Den här koden kan redigeras och köras!".gradient(Color::LightMagenta));
/// println!("{}", "Tento kód můžete upravit a spustit".gradient(Color::LightCyan));
/// println!("{}", "این کد قابلیت ویرایش و اجرا دارد!".gradient(Color::White));
/// println!("{}", "โค้ดนี้สามารถแก้ไขได้และรันได้".gradient(Color::Grey0));
/// }
/// ```
/// <img src="https://github.com/rocketsman/colorful/blob/master/images/1.png?raw=true" width="60%">
fn gradient_with_step<C: ColorInterface>(self, color: C, step: f32) -> CString;
fn gradient_with_color<C: ColorInterface>(self, start: C, stop: C) -> CString;
fn gradient<C: ColorInterface>(self, color: C) -> CString;
fn rainbow_with_speed(self, speed: i32);
/// Rainbow mode, support multiple lines
/// <img src="https://github.com/rocketsman/colorful/blob/master/images/11.gif?raw=true" width="60%">
fn rainbow(self);
fn neon_with_speed<C: ColorInterface>(self, low: C, high: C, speed: i32);
/// Neon mode
fn neon<C: ColorInterface>(self, low: C, high: C);
/// Show some warning words.
/// <img src="https://github.com/rocketsman/colorful/blob/master/images/22.gif?raw=true" width="60%">
fn warn(self);
}
impl<T> Colorful for T where T: StrMarker {
fn color<C: ColorInterface>(self, color: C) -> CString { CString::create_by_fg(self, color) }
fn black(self) -> CString { self.color(Color::Black) }
fn red(self) -> CString { self.color(Color::Red) }
fn green(self) -> CString { self.color(Color::Green) }
fn yellow(self) -> CString { self.color(Color::Yellow) }
fn blue(self) -> CString { self.color(Color::Blue) }
fn magenta(self) -> CString { self.color(Color::Magenta) }
fn cyan(self) -> CString { self.color(Color::Cyan) }
fn light_gray(self) -> CString { self.color(Color::LightGray) }
fn dark_gray(self) -> CString { self.color(Color::DarkGray) }
fn light_red(self) -> CString { self.color(Color::LightRed) }
fn light_green(self) -> CString { self.color(Color::LightGreen) }
fn light_yellow(self) -> CString { self.color(Color::LightYellow) }
fn light_blue(self) -> CString { self.color(Color::LightBlue) }
fn light_magenta(self) -> CString { self.color(Color::LightMagenta) }
fn light_cyan(self) -> CString { self.color(Color::LightCyan) }
fn white(self) -> CString { self.color(Color::White) }
fn bg_color<C: ColorInterface>(self, color: C) -> CString { CString::create_by_bg(self, color) }
fn bg_black(self) -> CString { self.bg_color(Color::Black) }
fn bg_red(self) -> CString { self.bg_color(Color::Red) }
fn bg_green(self) -> CString { self.bg_color(Color::Green) }
fn bg_yellow(self) -> CString { self.bg_color(Color::Yellow) }
fn bg_blue(self) -> CString { self.bg_color(Color::Blue) }
fn bg_magenta(self) -> CString { self.bg_color(Color::Magenta) }
fn bg_cyan(self) -> CString { self.bg_color(Color::Cyan) }
fn bg_light_gray(self) -> CString { self.bg_color(Color::LightGray) }
fn bg_dark_gray(self) -> CString { self.bg_color(Color::DarkGray) }
fn bg_light_red(self) -> CString { self.bg_color(Color::LightRed) }
fn bg_light_green(self) -> CString { self.bg_color(Color::LightGreen) }
fn bg_light_yellow(self) -> CString { self.bg_color(Color::LightYellow) }
fn bg_light_blue(self) -> CString { self.bg_color(Color::LightBlue) }
fn bg_light_magenta(self) -> CString { self.bg_color(Color::LightMagenta) }
fn bg_light_cyan(self) -> CString { self.bg_color(Color::LightCyan) }
fn bg_white(self) -> CString { self.bg_color(Color::White) }
fn rgb(self, r: u8, g: u8, b: u8) -> CString { CString::create_by_fg(self, RGB::new(r, g, b)) }
fn bg_rgb(self, r: u8, g: u8, b: u8) -> CString { CString::create_by_bg(self, RGB::new(r, g, b)) }
fn hsl(self, h: f32, s: f32, l: f32) -> CString { CString::create_by_fg(self, HSL::new(h, s, l)) }
fn bg_hsl(self, h: f32, s: f32, l: f32) -> CString { CString::create_by_bg(self, HSL::new(h, s, l)) }
fn style(self, style: Style) -> CString { CString::create_by_style(self, style) }
fn bold(self) -> CString { self.style(Style::Bold) }
fn blink(self) -> CString { self.style(Style::Blink) }
fn dim(self) -> CString { self.style(Style::Dim) }
fn underlined(self) -> CString { self.style(Style::Underlined) }
fn reverse(self) -> CString { self.style(Style::Reverse) }
fn hidden(self) -> CString { self.style(Style::Hidden) }
fn gradient_with_step<C: ColorInterface>(self, color: C, step: f32) -> CString {
let mut t = vec![];
let mut start = color.to_hsl().h;
let s = self.to_str();
let c = s.chars();
let length = c.clone().count() - 1;
for (index, i) in c.enumerate() {
let b = i.to_string();
let tmp = b.hsl(start, 1.0, 0.5).to_string();
t.push(format!("{}", &tmp[..tmp.len() - if index != length { 4 } else { 0 }]));
start = (start + step) % 1.0;
}
CString::create_by_text(self, t.join(""))
}
fn gradient_with_color<C: ColorInterface>(self, start: C, stop: C) -> CString {
let mut t = vec![];
let c = self.to_str();
let s = c.chars();
let length = s.clone().count() - 1;
let mut start = start.to_hsl().h;
let stop = stop.to_hsl().h;
let step = (stop - start) / length as f32;
for (index, i) in s.enumerate() {
let b = i.to_string();
let tmp = b.hsl(start, 1.0, 0.5).to_string();
t.push(format!("{}", &tmp[..tmp.len() - if index != length { 4 } else { 0 }]));
start = (start + step) % 1.0;
}
CString::create_by_text(self, t.join(""))
}
fn gradient<C: ColorInterface>(self, color: C) -> CString {
let text = self.to_str();
let lines: Vec<_> = text.lines().collect();
let mut tmp = vec![];
for sub_str in lines.iter() {
tmp.push(sub_str.gradient_with_step(color.clone(), 1.5 / 360.0).to_string());
}
CString::new(tmp.join("\n"))
}
fn rainbow_with_speed(self, speed: i32) {
let respite: u64 = match speed {
3 => { 10 }
2 => { 5 }
1 => { 2 }
_ => { 0 }
};
let text = self.to_str();
let lines: Vec<_> = text.lines().collect();
for i in 0..360 {
let mut tmp = vec![];
for sub_str in lines.iter() {
tmp.push(sub_str.gradient_with_step(HSL::new(i as f32 / 360.0, 1.0, 0.5), 0.02).to_string());
}
println!("{}\x1B[{}F\x1B[G\x1B[2K", tmp.join("\n"), lines.len());
let ten_millis = time::Duration::from_millis(respite);
thread::sleep(ten_millis);
}
}
fn rainbow(self) {
self.rainbow_with_speed(3);
}
fn neon_with_speed<C: ColorInterface>(self, high: C, low: C, speed: i32) {
let respite: u64 = match speed {
3 => { 500 }
2 => { 200 }
1 => { 100 }
_ => { 0 }
};
let text = self.to_str();
let lines: Vec<_> = text.lines().collect();
let mut coin = true;
let positive = format!("{}\x1B[{}F\x1B[2K", text.clone().color(high), lines.len());
let negative = format!("{}\x1B[{}F\x1B[2K", text.clone().color(low), lines.len());
for _ in 0..360 {
if coin { println!("{}", positive) } else { println!("{}", negative) };
let ten_millis = time::Duration::from_millis(respite);
thread::sleep(ten_millis);
coin = !coin;
}
}
fn neon<C: ColorInterface>(self, high: C, low: C) {
self.neon_with_speed(high, low, 3);
}
fn warn(self) {
self.neon_with_speed(RGB::new(226, 14, 14), RGB::new(158, 158, 158), 3);
}
}
pub trait ExtraColorInterface {
fn grey0(self) -> CString;
}
impl<T> ExtraColorInterface for T where T: Colorful {
fn grey0(self) -> CString { self.color(Color::Grey0) }
}

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

@ -1,280 +0,0 @@
extern crate colorful;
extern crate core;
use colorful::Colorful;
use colorful::Color;
use colorful::core::ColorInterface;
use colorful::HSL;
#[test]
fn test_color() {
let s = "Hello world";
for (i, color) in Color::iterator().enumerate() {
assert_eq!(format!("\x1B[38;5;{}mHello world\x1B[0m", i.to_owned()), s.color(*color).to_string());
}
}
#[test]
fn test_color_to_hsl() {
let l = vec![
HSL::new(0.0, 0.0, 0.0),
HSL::new(0.0, 1.0, 0.25),
HSL::new(0.3333333333333333, 1.0, 0.25),
HSL::new(0.16666666666666666, 1.0, 0.25),
HSL::new(0.6666666666666666, 1.0, 0.25),
HSL::new(0.8333333333333334, 1.0, 0.25),
HSL::new(0.5, 1.0, 0.25),
HSL::new(0.0, 0.0, 0.75),
HSL::new(0.0, 0.0, 0.5),
HSL::new(0.0, 1.0, 0.5),
HSL::new(0.3333333333333333, 1.0, 0.5),
HSL::new(0.16666666666666666, 1.0, 0.5),
HSL::new(0.6666666666666666, 1.0, 0.5),
HSL::new(0.8333333333333334, 1.0, 0.5),
HSL::new(0.5, 1.0, 0.5),
HSL::new(0.0, 0.0, 1.0),
HSL::new(0.0, 0.0, 0.0),
HSL::new(0.6666666666666666, 1.0, 0.18),
HSL::new(0.6666666666666666, 1.0, 0.26),
HSL::new(0.6666666666666666, 1.0, 0.34),
HSL::new(0.6666666666666666, 1.0, 0.42),
HSL::new(0.6666666666666666, 1.0, 0.5),
HSL::new(0.3333333333333333, 1.0, 0.18),
HSL::new(0.5, 1.0, 0.18),
HSL::new(0.5493827160493834, 1.0, 0.26),
HSL::new(0.5761904761904749, 1.0, 0.34),
HSL::new(0.5930232558139528, 1.0, 0.42),
HSL::new(0.6045751633986917, 1.0, 0.5),
HSL::new(0.3333333333333333, 1.0, 0.26),
HSL::new(0.4506172839506167, 1.0, 0.26),
HSL::new(0.5, 1.0, 0.26),
HSL::new(0.538095238095239, 1.0, 0.34),
HSL::new(0.5620155038759694, 1.0, 0.42),
HSL::new(0.5784313725490194, 1.0, 0.5),
HSL::new(0.3333333333333333, 1.0, 0.34),
HSL::new(0.423809523809525, 1.0, 0.34),
HSL::new(0.4619047619047611, 1.0, 0.34),
HSL::new(0.5, 1.0, 0.34),
HSL::new(0.5310077519379833, 1.0, 0.42),
HSL::new(0.5522875816993472, 1.0, 0.5),
HSL::new(0.3333333333333333, 1.0, 0.42),
HSL::new(0.40697674418604723, 1.0, 0.42),
HSL::new(0.43798449612403056, 1.0, 0.42),
HSL::new(0.4689922480620166, 1.0, 0.42),
HSL::new(0.5, 1.0, 0.42),
HSL::new(0.5261437908496722, 1.0, 0.5),
HSL::new(0.3333333333333333, 1.0, 0.5),
HSL::new(0.39542483660130834, 1.0, 0.5),
HSL::new(0.4215686274509806, 1.0, 0.5),
HSL::new(0.4477124183006528, 1.0, 0.5),
HSL::new(0.4738562091503278, 1.0, 0.5),
HSL::new(0.5, 1.0, 0.5),
HSL::new(0.0, 1.0, 0.18),
HSL::new(0.8333333333333334, 1.0, 0.18),
HSL::new(0.78395061728395, 1.0, 0.26),
HSL::new(0.7571428571428583, 1.0, 0.34),
HSL::new(0.7403100775193806, 1.0, 0.42),
HSL::new(0.7287581699346417, 1.0, 0.5),
HSL::new(0.16666666666666666, 1.0, 0.18),
HSL::new(0.0, 0.0, 0.37),
HSL::new(0.6666666666666666, 0.17, 0.45),
HSL::new(0.6666666666666666, 0.33, 0.52),
HSL::new(0.6666666666666666, 0.6, 0.6),
HSL::new(0.6666666666666666, 1.0, 0.68),
HSL::new(0.21604938271604945, 1.0, 0.26),
HSL::new(0.3333333333333333, 0.17, 0.45),
HSL::new(0.5, 0.17, 0.45),
HSL::new(0.5833333333333334, 0.33, 0.52),
HSL::new(0.6111111111111112, 0.6, 0.6),
HSL::new(0.625, 1.0, 0.68),
HSL::new(0.24285714285714277, 1.0, 0.34),
HSL::new(0.3333333333333333, 0.33, 0.52),
HSL::new(0.4166666666666667, 0.33, 0.52),
HSL::new(0.5, 0.33, 0.52),
HSL::new(0.5555555555555556, 0.6, 0.6),
HSL::new(0.5833333333333334, 1.0, 0.68),
HSL::new(0.2596899224806203, 1.0, 0.42),
HSL::new(0.3333333333333333, 0.6, 0.6),
HSL::new(0.3888888888888889, 0.6, 0.6),
HSL::new(0.4444444444444444, 0.6, 0.6),
HSL::new(0.5, 0.6, 0.6),
HSL::new(0.5416666666666666, 1.0, 0.68),
HSL::new(0.27124183006535946, 1.0, 0.5),
HSL::new(0.3333333333333333, 1.0, 0.68),
HSL::new(0.375, 1.0, 0.68),
HSL::new(0.4166666666666667, 1.0, 0.68),
HSL::new(0.4583333333333333, 1.0, 0.68),
HSL::new(0.5, 1.0, 0.68),
HSL::new(0.0, 1.0, 0.26),
HSL::new(0.8827160493827166, 1.0, 0.26),
HSL::new(0.8333333333333334, 1.0, 0.26),
HSL::new(0.7952380952380944, 1.0, 0.34),
HSL::new(0.7713178294573639, 1.0, 0.42),
HSL::new(0.7549019607843138, 1.0, 0.5),
HSL::new(0.11728395061728389, 1.0, 0.26),
HSL::new(0.0, 0.17, 0.45),
HSL::new(0.8333333333333334, 0.17, 0.45),
HSL::new(0.75, 0.33, 0.52),
HSL::new(0.7222222222222222, 0.6, 0.6),
HSL::new(0.7083333333333334, 1.0, 0.68),
HSL::new(0.16666666666666666, 1.0, 0.26),
HSL::new(0.16666666666666666, 0.17, 0.45),
HSL::new(0.0, 0.0, 0.52),
HSL::new(0.6666666666666666, 0.2, 0.6),
HSL::new(0.6666666666666666, 0.5, 0.68),
HSL::new(0.6666666666666666, 1.0, 0.76),
HSL::new(0.2047619047619047, 1.0, 0.34),
HSL::new(0.25, 0.33, 0.52),
HSL::new(0.3333333333333333, 0.2, 0.6),
HSL::new(0.5, 0.2, 0.6),
HSL::new(0.5833333333333334, 0.5, 0.68),
HSL::new(0.6111111111111112, 1.0, 0.76),
HSL::new(0.22868217054263557, 1.0, 0.42),
HSL::new(0.2777777777777778, 0.6, 0.6),
HSL::new(0.3333333333333333, 0.5, 0.68),
HSL::new(0.4166666666666667, 0.5, 0.68),
HSL::new(0.5, 0.5, 0.68),
HSL::new(0.5555555555555556, 1.0, 0.76),
HSL::new(0.2450980392156864, 1.0, 0.5),
HSL::new(0.2916666666666667, 1.0, 0.68),
HSL::new(0.3333333333333333, 1.0, 0.76),
HSL::new(0.3888888888888889, 1.0, 0.76),
HSL::new(0.4444444444444444, 1.0, 0.76),
HSL::new(0.5, 1.0, 0.76),
HSL::new(0.0, 1.0, 0.34),
HSL::new(0.9095238095238083, 1.0, 0.34),
HSL::new(0.8714285714285722, 1.0, 0.34),
HSL::new(0.8333333333333334, 1.0, 0.34),
HSL::new(0.80232558139535, 1.0, 0.42),
HSL::new(0.7810457516339862, 1.0, 0.5),
HSL::new(0.09047619047619054, 1.0, 0.34),
HSL::new(0.0, 0.33, 0.52),
HSL::new(0.9166666666666666, 0.33, 0.52),
HSL::new(0.8333333333333334, 0.33, 0.52),
HSL::new(0.7777777777777778, 0.6, 0.6),
HSL::new(0.75, 1.0, 0.68),
HSL::new(0.12857142857142861, 1.0, 0.34),
HSL::new(0.08333333333333333, 0.33, 0.52),
HSL::new(0.0, 0.2, 0.6),
HSL::new(0.8333333333333334, 0.2, 0.6),
HSL::new(0.75, 0.5, 0.68),
HSL::new(0.7222222222222222, 1.0, 0.76),
HSL::new(0.16666666666666666, 1.0, 0.34),
HSL::new(0.16666666666666666, 0.33, 0.52),
HSL::new(0.16666666666666666, 0.2, 0.6),
HSL::new(0.0, 0.0, 0.68),
HSL::new(0.6666666666666666, 0.33, 0.76),
HSL::new(0.6666666666666666, 1.0, 0.84),
HSL::new(0.1976744186046511, 1.0, 0.42),
HSL::new(0.2222222222222222, 0.6, 0.6),
HSL::new(0.25, 0.5, 0.68),
HSL::new(0.3333333333333333, 0.33, 0.76),
HSL::new(0.5, 0.33, 0.76),
HSL::new(0.5833333333333334, 1.0, 0.84),
HSL::new(0.21895424836601304, 1.0, 0.5),
HSL::new(0.25, 1.0, 0.68),
HSL::new(0.2777777777777778, 1.0, 0.76),
HSL::new(0.3333333333333333, 1.0, 0.84),
HSL::new(0.4166666666666667, 1.0, 0.84),
HSL::new(0.5, 1.0, 0.84),
HSL::new(0.0, 1.0, 0.42),
HSL::new(0.926356589147286, 1.0, 0.42),
HSL::new(0.8953488372093028, 1.0, 0.42),
HSL::new(0.8643410852713166, 1.0, 0.42),
HSL::new(0.8333333333333334, 1.0, 0.42),
HSL::new(0.8071895424836611, 1.0, 0.5),
HSL::new(0.07364341085271306, 1.0, 0.42),
HSL::new(0.0, 0.6, 0.6),
HSL::new(0.9444444444444444, 0.6, 0.6),
HSL::new(0.8888888888888888, 0.6, 0.6),
HSL::new(0.8333333333333334, 0.6, 0.6),
HSL::new(0.7916666666666666, 1.0, 0.68),
HSL::new(0.10465116279069778, 1.0, 0.42),
HSL::new(0.05555555555555555, 0.6, 0.6),
HSL::new(0.0, 0.5, 0.68),
HSL::new(0.9166666666666666, 0.5, 0.68),
HSL::new(0.8333333333333334, 0.5, 0.68),
HSL::new(0.7777777777777778, 1.0, 0.76),
HSL::new(0.13565891472868222, 1.0, 0.42),
HSL::new(0.1111111111111111, 0.6, 0.6),
HSL::new(0.08333333333333333, 0.5, 0.68),
HSL::new(0.0, 0.33, 0.76),
HSL::new(0.8333333333333334, 0.33, 0.76),
HSL::new(0.75, 1.0, 0.84),
HSL::new(0.16666666666666666, 1.0, 0.42),
HSL::new(0.16666666666666666, 0.6, 0.6),
HSL::new(0.16666666666666666, 0.5, 0.68),
HSL::new(0.16666666666666666, 0.33, 0.76),
HSL::new(0.0, 0.0, 0.84),
HSL::new(0.6666666666666666, 1.0, 0.92),
HSL::new(0.19281045751633974, 1.0, 0.5),
HSL::new(0.20833333333333334, 1.0, 0.68),
HSL::new(0.2222222222222222, 1.0, 0.76),
HSL::new(0.25, 1.0, 0.84),
HSL::new(0.3333333333333333, 1.0, 0.92),
HSL::new(0.5, 1.0, 0.92),
HSL::new(0.0, 1.0, 0.5),
HSL::new(0.937908496732025, 1.0, 0.5),
HSL::new(0.9117647058823528, 1.0, 0.5),
HSL::new(0.8856209150326805, 1.0, 0.5),
HSL::new(0.8594771241830055, 1.0, 0.5),
HSL::new(0.8333333333333334, 1.0, 0.5),
HSL::new(0.06209150326797389, 1.0, 0.5),
HSL::new(0.0, 1.0, 0.68),
HSL::new(0.9583333333333334, 1.0, 0.68),
HSL::new(0.9166666666666666, 1.0, 0.68),
HSL::new(0.875, 1.0, 0.68),
HSL::new(0.8333333333333334, 1.0, 0.68),
HSL::new(0.08823529411764694, 1.0, 0.5),
HSL::new(0.041666666666666664, 1.0, 0.68),
HSL::new(0.0, 1.0, 0.76),
HSL::new(0.9444444444444444, 1.0, 0.76),
HSL::new(0.8888888888888888, 1.0, 0.76),
HSL::new(0.8333333333333334, 1.0, 0.76),
HSL::new(0.11437908496732027, 1.0, 0.5),
HSL::new(0.08333333333333333, 1.0, 0.68),
HSL::new(0.05555555555555555, 1.0, 0.76),
HSL::new(0.0, 1.0, 0.84),
HSL::new(0.9166666666666666, 1.0, 0.84),
HSL::new(0.8333333333333334, 1.0, 0.84),
HSL::new(0.14052287581699335, 1.0, 0.5),
HSL::new(0.125, 1.0, 0.68),
HSL::new(0.1111111111111111, 1.0, 0.76),
HSL::new(0.08333333333333333, 1.0, 0.84),
HSL::new(0.0, 1.0, 0.92),
HSL::new(0.8333333333333334, 1.0, 0.92),
HSL::new(0.16666666666666666, 1.0, 0.5),
HSL::new(0.16666666666666666, 1.0, 0.68),
HSL::new(0.16666666666666666, 1.0, 0.76),
HSL::new(0.16666666666666666, 1.0, 0.84),
HSL::new(0.16666666666666666, 1.0, 0.92),
HSL::new(0.0, 0.0, 1.0),
HSL::new(0.0, 0.0, 0.03),
HSL::new(0.0, 0.0, 0.07),
HSL::new(0.0, 0.0, 0.1),
HSL::new(0.0, 0.0, 0.14),
HSL::new(0.0, 0.0, 0.18),
HSL::new(0.0, 0.0, 0.22),
HSL::new(0.0, 0.0, 0.26),
HSL::new(0.0, 0.0, 0.3),
HSL::new(0.0, 0.0, 0.34),
HSL::new(0.0, 0.0, 0.37),
HSL::new(0.0, 0.0, 0.4),
HSL::new(0.0, 0.0, 0.46),
HSL::new(0.0, 0.0, 0.5),
HSL::new(0.0, 0.0, 0.54),
HSL::new(0.0, 0.0, 0.58),
HSL::new(0.0, 0.0, 0.61),
HSL::new(0.0, 0.0, 0.65),
HSL::new(0.0, 0.0, 0.69),
HSL::new(0.0, 0.0, 0.73),
HSL::new(0.0, 0.0, 0.77),
HSL::new(0.0, 0.0, 0.81),
HSL::new(0.0, 0.0, 0.85),
HSL::new(0.0, 0.0, 0.89),
HSL::new(0.0, 0.0, 0.93), ];
for (i, color) in Color::iterator().enumerate() {
assert_eq!(color.to_hsl(), l[i]);
}
}

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

@ -1,31 +0,0 @@
extern crate colorful;
use colorful::Color;
use colorful::Colorful;
use colorful::HSL;
use colorful::RGB;
#[test]
fn test_rainbow() {
let s = "Hello world";
s.rainbow_with_speed(0);
}
#[test]
fn test_neon_1() {
let s = "Hello world";
s.neon_with_speed(Color::Grey0, Color::Grey0, 0);
}
#[test]
fn test_neon_2() {
let s = "Hello world";
s.neon_with_speed(HSL::new(1.0, 1.0, 0.4), HSL::new(0.5, 1.0, 0.4), 0);
}
#[test]
fn test_neon_3() {
let s = "Hello world";
s.neon_with_speed(RGB::new(122, 122, 122), RGB::new(222, 222, 222), 0);
}

53
third_party/rust/colorful/tests/test_basic.rs поставляемый
Просмотреть файл

@ -1,53 +0,0 @@
extern crate colorful;
extern crate core;
use colorful::Colorful;
use colorful::Color;
use colorful::Style;
#[test]
fn test_1() {
assert_eq!("\u{1b}", "\x1B");
}
#[test]
fn test_color() {
let s = "Hello world";
assert_eq!("\x1B[38;5;1mHello world\x1B[0m".to_owned(), s.color(Color::Red).to_string());
assert_eq!("\x1B[38;5;220mHello world\x1B[0m".to_owned(), s.color(Color::Red).color(Color::Gold1).to_string());
}
#[test]
fn test_bg_color() {
let s = "Hello world";
assert_eq!("\x1B[38;5;1m\x1B[48;5;16mHello world\x1B[0m".to_owned(), s.color(Color::Red).bg_color(Color::Grey0).to_string());
assert_eq!("\x1B[38;5;1m\x1B[48;5;6mHello world\x1B[0m".to_owned(), s.color(Color::Red).bg_cyan().to_string());
assert_eq!("\x1B[38;5;220m\x1B[48;5;6mHello world\x1B[0m".to_owned(), s.color(Color::Red).color(Color::Gold1).bg_color(Color::Cyan).to_string());
}
#[test]
fn test_style() {
let s = "Hello world";
assert_eq!("\x1B[1mHello world\x1B[0m".to_owned(), s.style(Style::Bold).to_string());
assert_eq!("\x1B[1;5mHello world\x1B[0m".to_owned(), s.style(Style::Bold).style(Style::Blink).to_string());
}
#[test]
fn test_interface() {
let s = "Hello world";
assert_eq!("\x1B[1mHello world\x1B[0m".to_owned(), s.bold().to_string());
assert_eq!("\x1B[1;5mHello world\x1B[0m".to_owned(), s.bold().blink().to_string());
assert_eq!("\x1B[38;5;1mHello world\x1B[0m".to_owned(), s.red().to_string());
assert_eq!("\x1B[38;5;2mHello world\x1B[0m".to_owned(), s.red().green().to_string());
}
#[test]
fn test_mix() {
let s = "Hello world";
assert_eq!("\x1B[38;5;1;5mHello world\x1B[0m".to_owned(), s.color(Color::Red).blink().to_string());
assert_eq!("\x1B[38;5;220;1mHello world\x1B[0m".to_owned(), s.bold().color(Color::Gold1).to_string());
assert_eq!("\x1B[38;5;2;5;1mHello world\x1B[0m".to_owned(), s.color(Color::Green).blink().bold().to_string());
assert_eq!("\x1B[38;5;220;1;5mHello world\x1B[0m".to_owned(), s.bold().blink().color(Color::Gold1).to_string());
}

10
third_party/rust/colorful/tests/test_extra.rs поставляемый
Просмотреть файл

@ -1,10 +0,0 @@
extern crate colorful;
extern crate core;
#[test]
fn test_extra_color() {
use colorful::ExtraColorInterface;
let s = "Hello world";
assert_eq!("\x1B[38;5;16mHello world\x1B[0m".to_owned(), s.grey0().to_string());
}

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

@ -1,16 +0,0 @@
extern crate colorful;
use colorful::Color;
use colorful::Colorful;
#[test]
fn test_gradient_color() {
let s = "Hello world";
assert_eq!("\u{1b}[38;2;255;0;0mH\u{1b}[38;2;255;6;0me\u{1b}[38;2;255;13;0ml\u{1b}[38;2;255;19;0ml\u{1b}[38;2;255;26;0mo\u{1b}[38;2;255;32;0m \u{1b}[38;2;255;38;0mw\u{1b}[38;2;255;45;0mo\u{1b}[38;2;255;51;0mr\u{1b}[38;2;255;57;0ml\u{1b}[38;2;255;64;0md\u{1b}[0m".to_owned(), s.gradient(Color::Red).to_string());
}
#[test]
fn test_gradient_multiple_lines() {
let s = "a\nb";
assert_eq!("\u{1b}[38;2;255;0;0ma\u{1b}[0m\n\u{1b}[38;2;255;0;0mb\u{1b}[0m".to_owned(), s.gradient(Color::Red).to_string());
}

10
third_party/rust/colorful/tests/test_hsl.rs поставляемый
Просмотреть файл

@ -1,10 +0,0 @@
extern crate colorful;
extern crate core;
use colorful::Colorful;
#[test]
fn test_hsl_color() {
let s = "Hello world";
assert_eq!("\x1B[38;2;19;205;94mHello world\x1B[0m", s.hsl(0.4, 0.83, 0.44).to_string());
}

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

@ -1 +1 @@
{"files":{"Cargo.toml":"f06acc2f73f07e900bfdb0539ecac85b0481993babe8c5fdf7e079c54179c5a4","src/lib.rs":"3a200e513417044eaa986ac61810d9087193369afa1aeb4469a7306fd64249ec"},"package":"572eee952a9a23c99cfe3e4fd95d277784058a89ac3c77ff6fa3d80a4e321919"}
{"files":{"Cargo.toml":"d9bacdc7fb6c94a0f98f766118b320b037be66cf28896b1edd348f900006ff49","src/lib.rs":"090ca4b005fe34762215078e30b7bca58f47fd6c43267a29d032ebe806428df9"},"package":"3b46e6f0031330a0be08d17820f2dcaaa91cb36710a97a9500cb4f1c36e785c8"}

7
third_party/rust/gfx-auxil/Cargo.toml поставляемый
Просмотреть файл

@ -13,7 +13,7 @@
[package]
edition = "2018"
name = "gfx-auxil"
version = "0.1.0"
version = "0.3.0"
authors = ["The Gfx-rs Developers"]
description = "Implementation details shared between gfx-rs backends"
homepage = "https://github.com/gfx-rs/gfx"
@ -28,8 +28,9 @@ name = "gfx_auxil"
version = "0.2.1"
[dependencies.hal]
version = "0.4"
version = "0.5"
package = "gfx-hal"
[dependencies.spirv_cross]
version = "0.16"
version = "0.18"
optional = true

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше