Upgrade assets_manager to 0.8.0 and image to 0.24

This removes a significant number of duplicated dependencies
This commit is contained in:
Benoît du Garreau 2022-05-28 23:17:28 +02:00
parent d56e0de392
commit 8488c7b25e
21 changed files with 86 additions and 312 deletions

243
Cargo.lock generated
View File

@ -214,17 +214,17 @@ dependencies = [
[[package]]
name = "assets_manager"
version = "0.7.2"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9bec562a7c25c1aa60d4394cb96c914aa9236ae53dddf5e89ea8aac8a20d98c0"
checksum = "c53a8477ada5edbd6ba3b0698aabaa76b352454aedc8c8dca0c6328fc8313b7e"
dependencies = [
"ab_glyph",
"ahash 0.7.6",
"bincode",
"crossbeam-channel",
"log",
"notify 4.0.17",
"parking_lot 0.11.2",
"notify",
"parking_lot 0.12.0",
"ron 0.7.0",
"serde",
"serde_json",
@ -320,16 +320,16 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]]
name = "backtrace"
version = "0.3.64"
version = "0.3.65"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e121dee8023ce33ab248d9ce1493df03c3b38a659b240096fcbd7048ff9c31f"
checksum = "11a17d453482a265fd5f8479f2a3f405566e6ca627837aaddb85af8b1ab8ef61"
dependencies = [
"addr2line",
"cc",
"cfg-if 1.0.0",
"libc",
"miniz_oxide 0.4.4",
"object 0.27.1",
"miniz_oxide",
"object",
"rustc-demangle",
]
@ -1461,16 +1461,6 @@ dependencies = [
"syn 1.0.90",
]
[[package]]
name = "deflate"
version = "0.8.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73770f8e1fe7d64df17ca66ad28994a0a623ea497fa69486e14984e715c5d174"
dependencies = [
"adler32",
"byteorder",
]
[[package]]
name = "deflate"
version = "1.0.0"
@ -1870,14 +1860,12 @@ checksum = "279fb028e20b3c4c320317955b77c5e0c9701f05a1d309905d6fc702cdc5053e"
[[package]]
name = "flate2"
version = "1.0.22"
version = "1.0.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e6988e897c1c9c485f43b47a529cef42fde0547f9d8d41a7062518f1d8fc53f"
checksum = "f82b0f4c27ad9f8bfd1f3208d882da2b09c301bc1c828fd3a00d0216d2fbbff6"
dependencies = [
"cfg-if 1.0.0",
"crc32fast",
"libc",
"miniz_oxide 0.4.4",
"miniz_oxide",
]
[[package]]
@ -1920,25 +1908,6 @@ dependencies = [
"percent-encoding",
]
[[package]]
name = "fsevent"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ab7d1bd1bd33cc98b0889831b72da23c0aa4df9cec7e0702f46ecea04b35db6"
dependencies = [
"bitflags",
"fsevent-sys 2.0.1",
]
[[package]]
name = "fsevent-sys"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f41b048a94555da0f42f1d632e2e19510084fb8e303b0daa2816e733fb3644a0"
dependencies = [
"libc",
]
[[package]]
name = "fsevent-sys"
version = "4.1.0"
@ -1948,22 +1917,6 @@ dependencies = [
"libc",
]
[[package]]
name = "fuchsia-zircon"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82"
dependencies = [
"bitflags",
"fuchsia-zircon-sys",
]
[[package]]
name = "fuchsia-zircon-sys"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7"
[[package]]
name = "funty"
version = "1.2.0"
@ -2764,16 +2717,16 @@ dependencies = [
[[package]]
name = "image"
version = "0.23.14"
version = "0.24.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24ffcb7e7244a9bf19d35bf2883b9c080c4ced3c07a9895572178cdb8f13f6a1"
checksum = "28edd9d7bc256be2502e325ac0628bde30b7001b9b52e0abe31a1a9dc2701212"
dependencies = [
"bytemuck",
"byteorder",
"color_quant",
"jpeg-decoder",
"num-iter",
"num-rational 0.3.2",
"num-rational 0.4.0",
"num-traits",
"png",
]
@ -2799,17 +2752,6 @@ dependencies = [
"lazy_static",
]
[[package]]
name = "inotify"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4816c66d2c8ae673df83366c18341538f234a26d65a9ecea5c348b453ac1d02f"
dependencies = [
"bitflags",
"inotify-sys",
"libc",
]
[[package]]
name = "inotify"
version = "0.9.6"
@ -2861,15 +2803,6 @@ version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9448015e586b611e5d322f6703812bbca2f1e709d5773ecd38ddb4e3bb649504"
[[package]]
name = "iovec"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e"
dependencies = [
"libc",
]
[[package]]
name = "itertools"
version = "0.10.3"
@ -2922,9 +2855,9 @@ dependencies = [
[[package]]
name = "jpeg-decoder"
version = "0.1.22"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "229d53d58899083193af11e15917b5640cd40b29ff475a1fe4ef725deb02d0f2"
checksum = "9478aa10f73e7528198d75109c8be5cd7d15fb530238040148d5f9a22d4c5b3b"
[[package]]
name = "js-sys"
@ -3363,40 +3296,11 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
[[package]]
name = "miniz_oxide"
version = "0.3.7"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "791daaae1ed6889560f8c4359194f56648355540573244a5448a83ba1ecc7435"
dependencies = [
"adler32",
]
[[package]]
name = "miniz_oxide"
version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b"
checksum = "d2b29bd4bc3f33391105ebee3589c19197c4271e3e5a9ec9bfe8127eeff8f082"
dependencies = [
"adler",
"autocfg",
]
[[package]]
name = "mio"
version = "0.6.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4afd66f5b91bf2a3bc13fad0e21caedac168ca4c707504e75585648ae80e4cc4"
dependencies = [
"cfg-if 0.1.10",
"fuchsia-zircon",
"fuchsia-zircon-sys",
"iovec",
"kernel32-sys",
"libc",
"log",
"miow 0.2.2",
"net2",
"slab",
"winapi 0.2.8",
]
[[package]]
@ -3407,7 +3311,7 @@ checksum = "8067b404fe97c70829f082dec8bcf4f71225d7eaea1d8645349cb76fa06205cc"
dependencies = [
"libc",
"log",
"miow 0.3.7",
"miow",
"ntapi",
"winapi 0.3.9",
]
@ -3420,24 +3324,12 @@ checksum = "52da4364ffb0e4fe33a9841a98a3f3014fb964045ce4f7a45a398243c8d6b0c9"
dependencies = [
"libc",
"log",
"miow 0.3.7",
"miow",
"ntapi",
"wasi 0.11.0+wasi-snapshot-preview1",
"winapi 0.3.9",
]
[[package]]
name = "mio-extras"
version = "2.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "52403fe290012ce777c4626790c8951324a2b9e3316b3143779c72b029742f19"
dependencies = [
"lazycell",
"log",
"mio 0.6.23",
"slab",
]
[[package]]
name = "mio-misc"
version = "1.2.2"
@ -3450,18 +3342,6 @@ dependencies = [
"mio 0.7.14",
]
[[package]]
name = "miow"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ebd808424166322d4a38da87083bfddd3ac4c131334ed55856112eb06d46944d"
dependencies = [
"kernel32-sys",
"net2",
"winapi 0.2.8",
"ws2_32-sys",
]
[[package]]
name = "miow"
version = "0.3.7"
@ -3632,17 +3512,6 @@ dependencies = [
"jni-sys",
]
[[package]]
name = "net2"
version = "0.2.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "391630d12b68002ae1e25e8f974306474966550ad82dac6886fb8910c19568ae"
dependencies = [
"cfg-if 0.1.10",
"libc",
"winapi 0.3.9",
]
[[package]]
name = "nibble_vec"
version = "0.1.0"
@ -3744,33 +3613,15 @@ dependencies = [
[[package]]
name = "notify"
version = "4.0.17"
version = "5.0.0-pre.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae03c8c853dba7bfd23e571ff0cff7bc9dceb40a4cd684cd1681824183f45257"
dependencies = [
"bitflags",
"filetime",
"fsevent",
"fsevent-sys 2.0.1",
"inotify 0.7.1",
"libc",
"mio 0.6.23",
"mio-extras",
"walkdir 2.3.2",
"winapi 0.3.9",
]
[[package]]
name = "notify"
version = "5.0.0-pre.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d13c22db70a63592e098fb51735bab36646821e6389a0ba171f3549facdf0b74"
checksum = "553f9844ad0b0824605c20fb55a661679782680410abfb1a8144c2e7e437e7a7"
dependencies = [
"bitflags",
"crossbeam-channel",
"filetime",
"fsevent-sys 4.1.0",
"inotify 0.9.6",
"fsevent-sys",
"inotify",
"kqueue",
"libc",
"mio 0.8.2",
@ -3900,17 +3751,6 @@ dependencies = [
"num-traits",
]
[[package]]
name = "num-rational"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12ac428b1cb17fce6f731001d307d351ec70a6d202fc2e60f7d4c5e42d8f4f07"
dependencies = [
"autocfg",
"num-integer",
"num-traits",
]
[[package]]
name = "num-rational"
version = "0.4.0"
@ -4012,15 +3852,6 @@ dependencies = [
"objc",
]
[[package]]
name = "object"
version = "0.27.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "67ac1d3f9a1d3616fd9a60c8d74296f22406a238b6a72f5cc1e6f314df4ffbf9"
dependencies = [
"memchr",
]
[[package]]
name = "object"
version = "0.28.3"
@ -4404,14 +4235,14 @@ dependencies = [
[[package]]
name = "png"
version = "0.16.8"
version = "0.17.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c3287920cb847dee3de33d301c463fba14dda99db24214ddf93f83d3021f4c6"
checksum = "dc38c0ad57efb786dd57b9864e5b18bae478c00c824dc55a38bbc9da95dde3ba"
dependencies = [
"bitflags",
"crc32fast",
"deflate 0.8.6",
"miniz_oxide 0.3.7",
"deflate",
"miniz_oxide",
]
[[package]]
@ -6933,7 +6764,7 @@ version = "0.1.0"
dependencies = [
"find_folder",
"libloading 0.7.3",
"notify 5.0.0-pre.14",
"notify",
"tracing",
]
@ -6980,7 +6811,7 @@ dependencies = [
"clap 3.1.8",
"criterion",
"csv",
"deflate 1.0.0",
"deflate",
"enum-iterator",
"fallible-iterator",
"flate2",
@ -7261,7 +7092,7 @@ dependencies = [
"leb128",
"libloading 0.7.3",
"loupe",
"object 0.28.3",
"object",
"rkyv",
"serde",
"tempfile",
@ -7300,7 +7131,7 @@ version = "2.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24ce18ac2877050e59580d27ee1a88f3192d7a31e77fbba0852abc7888d6e0b5"
dependencies = [
"object 0.28.3",
"object",
"thiserror",
"wasmer-compiler",
"wasmer-types",
@ -7855,16 +7686,6 @@ dependencies = [
"winapi 0.3.9",
]
[[package]]
name = "ws2_32-sys"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e"
dependencies = [
"winapi 0.2.8",
"winapi-build",
]
[[package]]
name = "wyz"
version = "0.4.0"

View File

@ -24,7 +24,7 @@ network = { package = "veloren-network", path = "../network", features = ["compr
byteorder = "1.3.2"
tokio = { version = "1.14", default-features = false, features = ["rt-multi-thread"] }
quinn = "0.8"
image = { version = "0.23.12", default-features = false, features = ["png"] }
image = { version = "0.24", default-features = false, features = ["png"] }
num = "0.4"
tracing = { version = "0.1", default-features = false }
rayon = "1.5"

View File

@ -7,11 +7,11 @@ version = "0.10.0"
[dependencies]
lazy_static = "1.4.0"
assets_manager = {version = "0.7", features = ["bincode", "ron", "json"]}
assets_manager = {version = "0.8.1", features = ["bincode", "ron", "json"]}
ron = { version = "0.7", default-features = false }
dot_vox = "4.0"
wavefront = "0.2" # TODO: Use vertex-colors branch when we have models that have them
image = { version = "0.23.12", default-features = false, features = ["png"] }
image = { version = "0.24", default-features = false, features = ["png"] }
tracing = "0.1"
# asset tweak

View File

@ -12,7 +12,7 @@ pub use assets_manager::{
self, BincodeLoader, BytesLoader, JsonLoader, LoadFrom, Loader, RonLoader, StringLoader,
},
source::{self, Source},
Asset, AssetCache, BoxedError, Compound, Error, SharedString,
AnyCache, Asset, AssetCache, BoxedError, Compound, Error, SharedString,
};
mod fs;
@ -28,7 +28,7 @@ pub fn start_hot_reloading() { ASSETS.enhance_hot_reloading(); }
pub type AssetHandle<T> = assets_manager::Handle<'static, T>;
pub type AssetGuard<T> = assets_manager::AssetGuard<'static, T>;
pub type AssetDirHandle<T> = assets_manager::DirHandle<'static, T, fs::FileSystem>;
pub type AssetDirHandle<T> = assets_manager::DirHandle<'static, T>;
pub type ReloadWatcher = assets_manager::ReloadWatcher<'static>;
/// The Asset trait, which is implemented by all structures that have their data
@ -122,7 +122,7 @@ pub fn load_dir<T: DirLoadable>(
/// 1) If can't load directory (filesystem errors)
/// 2) If file can't be loaded (parsing problem)
#[track_caller]
pub fn read_expect_dir<T: DirLoadable>(
pub fn read_expect_dir<T: DirLoadable + Compound>(
specifier: &str,
recursive: bool,
) -> impl Iterator<Item = AssetGuard<T>> {

View File

@ -15,7 +15,7 @@ common = {package = "veloren-common", path = "../../common"}
bincode = "1.3.3"
flate2 = "1.0.20"
image = { version = "0.23.12", default-features = false, features = ["png", "jpeg"] }
image = { version = "0.24", default-features = false, features = ["png", "jpeg"] }
num-traits = "0.2"
sum_type = "0.2.0"
vek = { version = "0.15.8", features = ["serde"] }

View File

@ -4,7 +4,7 @@ use common::{
volumes::vol_grid_2d::VolGrid2d,
};
use hashbrown::HashMap;
use image::{ImageBuffer, ImageDecoder, Pixel};
use image::{ImageBuffer, ImageDecoder, ImageEncoder, Pixel};
use num_traits::cast::FromPrimitive;
use serde::{Deserialize, Serialize};
use std::{
@ -237,7 +237,7 @@ impl<const N: u32> VoxelImageEncoding for QuadPngEncoding<N> {
CompressionType::Rle,
FilterType::Up,
);
png.encode(&*x.as_raw(), x.width(), x.height(), image::ColorType::L8)
png.write_image(&*x.as_raw(), x.width(), x.height(), image::ColorType::L8)
.ok()?;
indices[i] = buf.len();
Some(())
@ -252,7 +252,7 @@ impl<const N: u32> VoxelImageEncoding for QuadPngEncoding<N> {
CompressionType::Rle,
FilterType::Sub,
);
png.encode(
png.write_image(
&*ws.3.as_raw(),
ws.3.width(),
ws.3.height(),
@ -513,7 +513,7 @@ impl<const AVERAGE_PALETTE: bool> VoxelImageEncoding for TriPngEncoding<AVERAGE_
CompressionType::Rle,
FilterType::Up,
);
png.encode(&*x.as_raw(), x.width(), x.height(), image::ColorType::L8)
png.write_image(&*x.as_raw(), x.width(), x.height(), image::ColorType::L8)
.ok()?;
indices[i] = buf.len();
Some(())

View File

@ -206,10 +206,7 @@ pub mod figuredata {
}
impl assets::Compound for ShipSpec {
fn load<S: assets::source::Source + ?Sized>(
cache: &assets::AssetCache<S>,
_: &str,
) -> Result<Self, assets::BoxedError> {
fn load(cache: assets::AnyCache, _: &str) -> Result<Self, assets::BoxedError> {
let manifest: AssetHandle<Ron<ShipCentralSpec>> =
AssetExt::load("common.manifests.ship_manifest")?;
let mut colliders = HashMap::new();

View File

@ -656,10 +656,7 @@ impl PartialEq for Item {
}
impl assets::Compound for ItemDef {
fn load<S: assets::source::Source + ?Sized>(
cache: &assets::AssetCache<S>,
specifier: &str,
) -> Result<Self, BoxedError> {
fn load(cache: assets::AnyCache, specifier: &str) -> Result<Self, BoxedError> {
if specifier.starts_with("veloren.core.") {
return Err(format!(
"Attempted to load an asset from a specifier reserved for core veloren functions. \

View File

@ -373,10 +373,7 @@ impl Asset for AbilityMap<String> {
}
impl assets::Compound for AbilityMap {
fn load<S: assets::source::Source + ?Sized>(
cache: &assets::AssetCache<S>,
specifier: &str,
) -> Result<Self, assets::BoxedError> {
fn load(cache: assets::AnyCache, specifier: &str) -> Result<Self, assets::BoxedError> {
let manifest = cache.load::<AbilityMap<String>>(specifier)?.read();
Ok(AbilityMap(

View File

@ -299,10 +299,7 @@ impl EqualitySet {
}
impl assets::Compound for EqualitySet {
fn load<S: assets::source::Source + ?Sized>(
cache: &assets::AssetCache<S>,
id: &str,
) -> Result<Self, assets::BoxedError> {
fn load(cache: assets::AnyCache, id: &str) -> Result<Self, assets::BoxedError> {
#[derive(Debug, Deserialize)]
enum EqualitySpec {
LootTable(String),

View File

@ -420,10 +420,7 @@ impl assets::Asset for ItemList {
}
impl assets::Compound for RecipeBook {
fn load<S: assets::source::Source + ?Sized>(
cache: &assets::AssetCache<S>,
specifier: &str,
) -> Result<Self, assets::BoxedError> {
fn load(cache: assets::AnyCache, specifier: &str) -> Result<Self, assets::BoxedError> {
#[inline]
fn load_item_def(spec: &(String, u32)) -> Result<(Arc<ItemDef>, u32), assets::Error> {
let def = Arc::<ItemDef>::load_cloned(&spec.0)?;
@ -748,10 +745,7 @@ enum RawComponentOutput {
}
impl assets::Compound for ComponentRecipeBook {
fn load<S: assets::source::Source + ?Sized>(
cache: &assets::AssetCache<S>,
specifier: &str,
) -> Result<Self, assets::BoxedError> {
fn load(cache: assets::AnyCache, specifier: &str) -> Result<Self, assets::BoxedError> {
#[inline]
fn create_recipe_key(raw_recipe: &RawComponentRecipe) -> ComponentKey {
match &raw_recipe.output {

View File

@ -68,10 +68,7 @@ impl std::ops::Deref for StructuresGroup {
}
impl assets::Compound for StructuresGroup {
fn load<S: assets::source::Source + ?Sized>(
cache: &assets::AssetCache<S>,
specifier: &str,
) -> Result<Self, BoxedError> {
fn load(cache: assets::AnyCache, specifier: &str) -> Result<Self, BoxedError> {
let specs = cache.load::<StructuresGroupSpec>(specifier)?.read();
Ok(StructuresGroup(
@ -139,10 +136,7 @@ impl ReadVol for Structure {
}
impl assets::Compound for BaseStructure {
fn load<S: assets::source::Source + ?Sized>(
cache: &assets::AssetCache<S>,
specifier: &str,
) -> Result<Self, BoxedError> {
fn load(cache: assets::AnyCache, specifier: &str) -> Result<Self, BoxedError> {
let dot_vox_data = cache.load::<DotVoxAsset>(specifier)?.read();
let dot_vox_data = &dot_vox_data.0;

View File

@ -90,7 +90,7 @@ gilrs = {version = "0.8.0", features = ["serde-serialize"]}
server = { package = "veloren-server", path = "../server", optional = true, default-features = false, features = ["worldgen"] }
# Utility
assets_manager = {version = "0.7", features = ["ab_glyph"]}
assets_manager = {version = "0.8", features = ["ab_glyph"]}
backtrace = "0.3.40"
bincode = "1.3.1"
chrono = { version = "0.4.19", features = ["serde"] }
@ -105,7 +105,7 @@ dot_vox = "4.0"
enum-iterator = "0.7"
guillotiere = "0.6"
hashbrown = {version = "0.11", features = ["rayon", "serde", "nightly"]}
image = {version = "0.23.12", default-features = false, features = ["ico", "png"]}
image = {version = "0.24", default-features = false, features = ["ico", "png"]}
lazy_static = "1.4.0"
native-dialog = { version = "0.6.3", optional = true }
num = "0.4"

View File

@ -102,8 +102,8 @@ impl Language {
}
impl common_assets::Compound for Language {
fn load<S: common_assets::source::Source + ?Sized>(
cache: &common_assets::AssetCache<S>,
fn load(
cache: common_assets::AnyCache,
asset_key: &str,
) -> Result<Self, common_assets::BoxedError> {
let manifest = cache
@ -282,15 +282,6 @@ impl LocalizationHandle {
struct FindManifests;
impl common_assets::Compound for FindManifests {
fn load<S: common_assets::Source + ?Sized>(
_: &common_assets::AssetCache<S>,
_: &str,
) -> Result<Self, common_assets::BoxedError> {
Ok(Self)
}
}
impl common_assets::DirLoadable for FindManifests {
fn select_ids<S: common_assets::Source + ?Sized>(
source: &S,
@ -315,8 +306,8 @@ impl common_assets::DirLoadable for FindManifests {
struct LocalizationList(Vec<LanguageMetadata>);
impl common_assets::Compound for LocalizationList {
fn load<S: common_assets::Source + ?Sized>(
cache: &common_assets::AssetCache<S>,
fn load(
cache: common_assets::AnyCache,
specifier: &str,
) -> Result<Self, common_assets::BoxedError> {
// List language directories

View File

@ -446,10 +446,7 @@ impl assets::Asset for SoundtrackCollection<RawSoundtrackItem> {
}
impl assets::Compound for SoundtrackCollection<SoundtrackItem> {
fn load<S: assets::source::Source + ?Sized>(
_: &assets::AssetCache<S>,
id: &str,
) -> Result<Self, assets::BoxedError> {
fn load(_: assets::AnyCache, id: &str) -> Result<Self, assets::BoxedError> {
let inner = || -> Result<_, assets::Error> {
let manifest: AssetHandle<SoundtrackCollection<RawSoundtrackItem>> =
AssetExt::load(id)?;

View File

@ -10,7 +10,8 @@
once_cell,
trait_alias,
option_get_or_insert_default,
map_try_insert
map_try_insert,
slice_as_chunks
)]
#![recursion_limit = "2048"]

View File

@ -147,7 +147,7 @@ impl TakeScreenshot {
let buffer_map_future = buffer_slice.map_async(wgpu::MapMode::Read);
// Wait on buffer mapping
let pixel_bytes = match singlethread_rt.block_on(buffer_map_future) {
let mut pixel_bytes = match singlethread_rt.block_on(buffer_map_future) {
// Buffer is mapped and we can read it
Ok(()) => {
// Copy to a Vec
@ -174,38 +174,30 @@ impl TakeScreenshot {
// Construct image
let image = match self.tex_format {
wgpu::TextureFormat::Bgra8UnormSrgb => {
let image = image::ImageBuffer::<image::Bgra<u8>, Vec<u8>>::from_vec(
self.width,
self.height,
pixel_bytes,
)
.expect(
"Failed to create ImageBuffer! Buffer was not large enough. This should not \
occur",
);
let image = image::DynamicImage::ImageBgra8(image);
Ok(image)
},
wgpu::TextureFormat::Rgba8UnormSrgb => {
let image = image::ImageBuffer::<image::Rgba<u8>, Vec<u8>>::from_vec(
self.width,
self.height,
pixel_bytes,
)
.expect(
"Failed to create ImageBuffer! Buffer was not large enough. This should not \
occur",
);
let image = image::DynamicImage::ImageRgba8(image);
Ok(image)
let (pixels, rest) = pixel_bytes.as_chunks_mut();
assert!(rest.is_empty());
for [b, _g, r, _a] in pixels {
std::mem::swap(b, r);
}
Ok(pixel_bytes)
},
wgpu::TextureFormat::Rgba8UnormSrgb => Ok(pixel_bytes),
format => Err(format!(
"Unhandled format for screenshot texture: {:?}",
format,
)),
};
}
.and_then(|pixel_bytes| {
let image = image::ImageBuffer::<image::Rgba<u8>, Vec<u8>>::from_vec(
self.width,
self.height,
pixel_bytes,
)
.expect(
"Failed to create ImageBuffer! Buffer was not large enough. This should not occur",
);
Ok(image::DynamicImage::ImageRgba8(image))
});
// Call supplied handler
(self.screenshot_fn)(image);

View File

@ -24,10 +24,7 @@ pub struct Shaders {
impl assets::Compound for Shaders {
// TODO: Taking the specifier argument as a base for shaders specifiers
// would allow to use several shaders groups easily
fn load<S: assets::source::Source + ?Sized>(
_: &assets::AssetCache<S>,
_: &str,
) -> Result<Shaders, assets::BoxedError> {
fn load(_: assets::AnyCache, _: &str) -> Result<Shaders, assets::BoxedError> {
let shaders = [
"include.constants",
"include.globals",

View File

@ -1,6 +1,6 @@
use super::RenderError;
use core::num::NonZeroU32;
use image::{DynamicImage, GenericImageView};
use image::DynamicImage;
use wgpu::Extent3d;
/// Represents an image that has been uploaded to the GPU.
@ -21,17 +21,16 @@ impl Texture {
filter_method: Option<wgpu::FilterMode>,
address_mode: Option<wgpu::AddressMode>,
) -> Result<Self, RenderError> {
let format = match &image {
let format = match image {
DynamicImage::ImageLuma8(_) => wgpu::TextureFormat::R8Unorm,
DynamicImage::ImageLumaA8(_) => panic!("ImageLuma8 unsupported"),
DynamicImage::ImageRgb8(_) => panic!("ImageRgb8 unsupported"),
DynamicImage::ImageRgba8(_) => wgpu::TextureFormat::Rgba8UnormSrgb,
DynamicImage::ImageBgr8(_) => panic!("ImageBgr8 unsupported"),
DynamicImage::ImageBgra8(_) => panic!("ImageBgra8 unsupported"),
DynamicImage::ImageLuma16(_) => panic!("ImageLuma16 unsupported"),
DynamicImage::ImageLumaA16(_) => panic!("ImageLumaA16 unsupported"),
DynamicImage::ImageRgb16(_) => panic!("ImageRgb16 unsupported"),
DynamicImage::ImageRgba16(_) => panic!("ImageRgba16 unsupported"),
_ => panic!("unsupported format"),
};
// TODO: Actually handle images that aren't in rgba format properly.

View File

@ -125,7 +125,7 @@ macro_rules! make_vox_spec {
}
impl assets::Compound for $Spec {
fn load<S: assets::source::Source + ?Sized>(_: &assets::AssetCache<S>, _: &str) -> Result<Self, assets::BoxedError> {
fn load(_: assets::AnyCache, _: &str) -> Result<Self, assets::BoxedError> {
Ok($Spec {
$( $field: AssetExt::load($asset_path)?, )*
})

View File

@ -19,7 +19,7 @@ bincode = "1.3.1"
bitvec = "0.22"
enum-iterator = "0.7"
fxhash = "0.2.1"
image = { version = "0.23.12", default-features = false, features = ["png"] }
image = { version = "0.24", default-features = false, features = ["png"] }
itertools = "0.10"
vek = { version = "0.15.8", features = ["serde"] }
noise = { version = "0.7", default-features = false }