Upgraded to gfx_hal 0.6.0

+ added swapchain recreation mechanism
+ sorted minor issues
! some framebuffer error present
! may crash during swapchain recreation
This commit is contained in:
Steins7 2020-09-06 20:10:58 +02:00
parent 6579566ccd
commit 5f9cc86689
8 changed files with 420 additions and 422 deletions

242
Cargo.lock generated
View File

@ -37,9 +37,9 @@ checksum = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8"
[[package]]
name = "ash"
version = "0.30.0"
version = "0.31.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "69daec0742947f33a85931fa3cb0ce5f07929159dcbd1f0cbb5b2912e2978509"
checksum = "c69a8137596e84c22d57f3da1b5de1d4230b1742a710091c85f4d7ce50f00f38"
dependencies = [
"libloading",
]
@ -52,14 +52,14 @@ checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
dependencies = [
"hermit-abi",
"libc",
"winapi 0.3.8",
"winapi 0.3.9",
]
[[package]]
name = "autocfg"
version = "1.0.0"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d"
checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
[[package]]
name = "bitflags"
@ -92,9 +92,9 @@ dependencies = [
[[package]]
name = "cc"
version = "1.0.50"
version = "1.0.59"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95e28fa049fda1c330bcf9d723be7663a899c4679724b34c81e9f5a326aab8cd"
checksum = "66120af515773fb005778dc07c261bd201ec8ce50bd6e7144c927753fe013381"
[[package]]
name = "cfg-if"
@ -104,9 +104,9 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
[[package]]
name = "chrono"
version = "0.4.11"
version = "0.4.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "80094f509cf8b5ae86a4966a39b3ff66cd7e2a3e594accec3743ff3fabeab5b2"
checksum = "942f72db697d8767c22d46a598e01f2d3b475501ea43d0db4f16d90259182d0b"
dependencies = [
"num-integer",
"num-traits",
@ -124,13 +124,13 @@ dependencies = [
[[package]]
name = "cocoa"
version = "0.20.1"
version = "0.20.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f7b6f3f7f4f0b3ec5c5039aaa9e8c3cef97a7a480a400fd62944841314f293d"
checksum = "0c49e86fc36d5704151f5996b7b3795385f50ce09e3be0f47a0cfde869681cf8"
dependencies = [
"bitflags",
"block",
"core-foundation",
"core-foundation 0.7.0",
"core-graphics",
"foreign-types",
"libc",
@ -145,7 +145,7 @@ checksum = "f4ffc801dacf156c5854b9df4f425a626539c3a6ef7893cc0c5084a23f0b6c59"
dependencies = [
"atty",
"lazy_static",
"winapi 0.3.8",
"winapi 0.3.9",
]
[[package]]
@ -154,7 +154,17 @@ version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57d24c7a13c43e870e37c1556b74555437870a04514f7685f5b354e090567171"
dependencies = [
"core-foundation-sys",
"core-foundation-sys 0.7.0",
"libc",
]
[[package]]
name = "core-foundation"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b5ed8e7e76c45974e15e41bfa8d5b0483cd90191639e01d8f5f1e606299d3fb"
dependencies = [
"core-foundation-sys 0.8.0",
"libc",
]
@ -165,13 +175,31 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b3a71ab494c0b5b860bdc8407ae08978052417070c2ced38573a9157ad75b8ac"
[[package]]
name = "core-graphics"
version = "0.19.0"
name = "core-foundation-sys"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "59e78b2e0aaf43f08e7ae0d6bc96895ef72ff0921c7d4ff4762201b2dba376dd"
checksum = "9a21fa21941700a3cd8fcb4091f361a6a712fac632f85d9f487cc892045d55c6"
[[package]]
name = "core-graphics"
version = "0.19.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b3889374e6ea6ab25dba90bb5d96202f61108058361f6dc72e8b03e6f8bbe923"
dependencies = [
"bitflags",
"core-foundation",
"core-foundation 0.7.0",
"foreign-types",
"libc",
]
[[package]]
name = "core-graphics-types"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e92f5d519093a4178296707dbaa3880eae85a5ef5386675f361a1cf25376e93c"
dependencies = [
"bitflags",
"core-foundation 0.9.0",
"foreign-types",
"libc",
]
@ -183,7 +211,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34ecad23610ad9757664d644e369246edde1803fcb43ed72876565098a5d3828"
dependencies = [
"cfg-if",
"core-foundation-sys",
"core-foundation-sys 0.7.0",
"core-graphics",
"libc",
"objc",
@ -195,7 +223,7 @@ version = "2.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb582b60359da160a9477ee80f15c8d784c477e69c217ef2cdd4169c24ea380f"
dependencies = [
"proc-macro2 1.0.18",
"proc-macro2 1.0.20",
"quote 1.0.7",
"syn",
]
@ -208,18 +236,18 @@ checksum = "bd0c93bb4b0c6d9b77f4435b0ae98c24d17f1c45b2ff844c6151a07256ca923b"
[[package]]
name = "dlib"
version = "0.4.1"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77e51249a9d823a4cb79e3eca6dcd756153e8ed0157b6c04775d04bf1b13b76a"
checksum = "b11f15d1e3268f140f68d390637d5e76d849782d971ae7063e0da69fe9709a76"
dependencies = [
"libloading",
]
[[package]]
name = "downcast-rs"
version = "1.1.1"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "52ba6eb47c2131e784a38b726eb54c1e1484904f013e576a25354d0124161af6"
checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650"
[[package]]
name = "fern"
@ -264,29 +292,30 @@ checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7"
[[package]]
name = "gfx-backend-vulkan"
version = "0.5.2"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ebd1dee09bd8d8f1ba52c5ba22d1f70c7ffa990c5eb245eb3ef2d0206f631673"
checksum = "a84bda4200a82e1912d575801e2bb76ae19c6256359afbc0adfbbaec02fcadc6"
dependencies = [
"arrayvec",
"ash",
"byteorder",
"core-graphics",
"core-graphics-types",
"gfx-hal",
"inplace_it",
"lazy_static",
"log",
"objc",
"raw-window-handle",
"smallvec",
"winapi 0.3.8",
"winapi 0.3.9",
"x11",
]
[[package]]
name = "gfx-hal"
version = "0.5.3"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a18534b23d4c262916231511309bc1f307c74cda8dcb68b93a10ca213a22814b"
checksum = "18d0754f5b7a43915fd7466883b2d1bb0800d7cc4609178d0b27bf143b9e5123"
dependencies = [
"bitflags",
"raw-window-handle",
@ -294,18 +323,24 @@ dependencies = [
[[package]]
name = "hermit-abi"
version = "0.1.14"
version = "0.1.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9586eedd4ce6b3c498bc3b4dd92fc9f11166aa908a914071953768066c67909"
checksum = "3deed196b6e7f9e44a2ae8d94225d80302d81208b1bb673fd21fe634645c85a9"
dependencies = [
"libc",
]
[[package]]
name = "instant"
version = "0.1.2"
name = "inplace_it"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c346c299e3fe8ef94dc10c2c0253d858a69aac1245157a3bf4125915d528caf"
checksum = "dd01a2a73f2f399df96b22dc88ea687ef4d76226284e7531ae3c7ee1dc5cb534"
[[package]]
name = "instant"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b141fdc7836c525d4d594027d318c84161ca17aaf8113ab1f81ab93ae897485"
[[package]]
name = "iovec"
@ -354,24 +389,24 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "lazycell"
version = "1.2.1"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f"
checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
[[package]]
name = "libc"
version = "0.2.68"
version = "0.2.76"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dea0c0405123bba743ee3f91f49b1c7cfb684eef0da0a50110f758ccf24cdff0"
checksum = "755456fae044e6fa1ebbbd1b3e902ae19e73097ed4ed87bb79934a867c007bc3"
[[package]]
name = "libloading"
version = "0.5.2"
version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2b111a074963af1d37a139918ac6d49ad1d0d5e47f72fd55388619691a7d753"
checksum = "2443d8f0478b16759158b2f66d525991a05491138bc05814ef52a250148ef4f9"
dependencies = [
"cc",
"winapi 0.3.8",
"cfg-if",
"winapi 0.3.9",
]
[[package]]
@ -385,18 +420,18 @@ dependencies = [
[[package]]
name = "lock_api"
version = "0.3.3"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "79b2de95ecb4691949fea4716ca53cdbcfccb2c612e19644a8bad05edcf9f47b"
checksum = "c4da24a77a3d8a6d4862d95f72e6fdb9c09a643ecdb402d754004a557f2bec75"
dependencies = [
"scopeguard",
]
[[package]]
name = "log"
version = "0.4.8"
version = "0.4.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7"
checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b"
dependencies = [
"cfg-if",
]
@ -423,14 +458,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6585fd95e7bb50d6cc31e20d4cf9afb4e2ba16c5846fc76793f11218da9c475b"
dependencies = [
"libc",
"winapi 0.3.8",
"winapi 0.3.9",
]
[[package]]
name = "mio"
version = "0.6.21"
version = "0.6.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "302dec22bcf6bae6dfb69c647187f4b4d0fb6f535521f7bc022430ce8e12008f"
checksum = "fce347092656428bc8eaf6201042cb551b8d67855af7374542a92a0fbfcac430"
dependencies = [
"cfg-if",
"fuchsia-zircon",
@ -502,13 +537,13 @@ checksum = "2b2820aca934aba5ed91c79acc72b6a44048ceacc5d36c035ed4e051f12d887d"
[[package]]
name = "net2"
version = "0.2.33"
version = "0.2.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88"
checksum = "2ba7c918ac76704fb42afcbbb43891e72731f3dcca3bef2a19786297baf14af7"
dependencies = [
"cfg-if",
"libc",
"winapi 0.3.8",
"winapi 0.3.9",
]
[[package]]
@ -526,9 +561,9 @@ dependencies = [
[[package]]
name = "num-integer"
version = "0.1.42"
version = "0.1.43"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f6ea62e9d81a77cd3ee9a2a5b9b609447857f3d358704331e4ef39eb247fcba"
checksum = "8d59457e662d541ba17869cf51cf177c0b5f0cbf476c66bdc90bf1edac4f875b"
dependencies = [
"autocfg",
"num-traits",
@ -560,7 +595,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ffa5a33ddddfee04c0283a7653987d634e880347e96b5b2ed64de07efb59db9d"
dependencies = [
"proc-macro-crate",
"proc-macro2 1.0.18",
"proc-macro2 1.0.20",
"quote 1.0.7",
"syn",
]
@ -576,18 +611,18 @@ dependencies = [
[[package]]
name = "ordered-float"
version = "1.0.2"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "18869315e81473c951eb56ad5558bbc56978562d3ecfb87abb7a1e944cea4518"
checksum = "3741934be594d77de1c8461ebcbbe866f585ea616a9753aa78f2bdc69f0e4579"
dependencies = [
"num-traits",
]
[[package]]
name = "parking_lot"
version = "0.10.0"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "92e98c49ab0b7ce5b222f2cc9193fc4efe11c6d0bd4f648e374684a6857b1cfc"
checksum = "d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e"
dependencies = [
"lock_api",
"parking_lot_core",
@ -595,16 +630,16 @@ dependencies = [
[[package]]
name = "parking_lot_core"
version = "0.7.0"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7582838484df45743c8434fbff785e8edf260c28748353d44bc0da32e0ceabf1"
checksum = "d58c7c768d4ba344e3e8d72518ac13e259d7c7ade24167003b8488e10b6740a3"
dependencies = [
"cfg-if",
"cloudabi",
"libc",
"redox_syscall",
"smallvec",
"winapi 0.3.8",
"winapi 0.3.9",
]
[[package]]
@ -615,15 +650,15 @@ checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e"
[[package]]
name = "pkg-config"
version = "0.3.17"
version = "0.3.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05da548ad6865900e60eaba7f589cc0783590a92e940c26953ff81ddbab2d677"
checksum = "d36492546b6af1463394d46f0c834346f31548646f6ba10849802c9c9a27ac33"
[[package]]
name = "proc-macro-crate"
version = "0.1.4"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e10d4b51f154c8a7fb96fd6dad097cb74b863943ec010ac94b9fd1be8861fe1e"
checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785"
dependencies = [
"toml",
]
@ -639,11 +674,11 @@ dependencies = [
[[package]]
name = "proc-macro2"
version = "1.0.18"
version = "1.0.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "beae6331a816b1f65d04c45b078fd8e6c93e8071771f41b8163255bbd8d7c8fa"
checksum = "175c513d55719db99da20232b06cda8bab6b83ec2d04e3283edf0213c37c1a29"
dependencies = [
"unicode-xid 0.2.0",
"unicode-xid 0.2.1",
]
[[package]]
@ -661,7 +696,7 @@ version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37"
dependencies = [
"proc-macro2 1.0.18",
"proc-macro2 1.0.20",
]
[[package]]
@ -675,9 +710,9 @@ dependencies = [
[[package]]
name = "redox_syscall"
version = "0.1.56"
version = "0.1.57"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84"
checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce"
[[package]]
name = "rusttype"
@ -685,17 +720,16 @@ version = "0.7.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "310942406a39981bed7e12b09182a221a29e0990f3e7e0c971f131922ed135d5"
dependencies = [
"rusttype 0.8.2",
"rusttype 0.8.3",
]
[[package]]
name = "rusttype"
version = "0.8.2"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "14a911032fb5791ccbeec9f28fdcb9bf0983b81f227bafdfd227c658d0731c8a"
checksum = "9f61411055101f7b60ecf1041d87fb74205fb20b0c7a723f07ef39174cf6b4c0"
dependencies = [
"approx",
"arrayvec",
"ordered-float",
"stb_truetype",
]
@ -717,9 +751,9 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]]
name = "serde"
version = "1.0.112"
version = "1.0.115"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "736aac72d1eafe8e5962d1d1c3d99b0df526015ba40915cb3c49d042e92ec243"
checksum = "e54c9a88f2da7238af84b5101443f0c0d0a3bbdc455e34a5c9497b1903ed55d5"
[[package]]
name = "slab"
@ -729,9 +763,9 @@ checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8"
[[package]]
name = "smallvec"
version = "1.2.0"
version = "1.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c2fb2ec9bcd216a5b0d0ccf31ab17b5ed1d627960edff65bbe95d3ce221cefc"
checksum = "fbee7696b84bbf3d89a1c2eccff0850e3047ed46bfcd2e92c29a2d074d57e252"
[[package]]
name = "smithay-client-toolkit"
@ -760,24 +794,24 @@ dependencies = [
[[package]]
name = "syn"
version = "1.0.31"
version = "1.0.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5304cfdf27365b7585c25d4af91b35016ed21ef88f17ced89c7093b43dba8b6"
checksum = "963f7d3cc59b59b9325165add223142bbf1df27655d07789f109896d353d8350"
dependencies = [
"proc-macro2 1.0.18",
"proc-macro2 1.0.20",
"quote 1.0.7",
"unicode-xid 0.2.0",
"unicode-xid 0.2.1",
]
[[package]]
name = "time"
version = "0.1.42"
version = "0.1.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f"
checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255"
dependencies = [
"libc",
"redox_syscall",
"winapi 0.3.8",
"wasi",
"winapi 0.3.9",
]
[[package]]
@ -797,9 +831,9 @@ checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
[[package]]
name = "unicode-xid"
version = "0.2.0"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
[[package]]
name = "void"
@ -814,10 +848,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "777182bc735b6424e1a57516d35ed72cb8019d85c8c9bf536dccb3445c1a2f7d"
dependencies = [
"same-file",
"winapi 0.3.8",
"winapi 0.3.9",
"winapi-util",
]
[[package]]
name = "wasi"
version = "0.10.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f"
[[package]]
name = "wayland-client"
version = "0.23.6"
@ -886,9 +926,9 @@ checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
[[package]]
name = "winapi"
version = "0.3.8"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6"
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
dependencies = [
"winapi-i686-pc-windows-gnu",
"winapi-x86_64-pc-windows-gnu",
@ -908,11 +948,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-util"
version = "0.1.4"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa515c5163a99cc82bab70fd3bfdd36d827be85de63737b40fcef2ce084a436e"
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
dependencies = [
"winapi 0.3.8",
"winapi 0.3.9",
]
[[package]]
@ -929,7 +969,7 @@ checksum = "1e4ccbf7ddb6627828eace16cacde80fc6bf4dbb3469f88487262a02cf8e7862"
dependencies = [
"bitflags",
"cocoa",
"core-foundation",
"core-foundation 0.7.0",
"core-graphics",
"core-video-sys",
"dispatch",
@ -948,7 +988,7 @@ dependencies = [
"raw-window-handle",
"smithay-client-toolkit",
"wayland-client",
"winapi 0.3.8",
"winapi 0.3.9",
"x11-dl",
]
@ -992,6 +1032,6 @@ checksum = "d089681aa106a86fade1b0128fb5daf07d5867a509ab036d99988dec80429a57"
[[package]]
name = "xml-rs"
version = "0.8.2"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2bb76e5c421bbbeb8924c60c030331b345555024d56261dae8f3e786ed817c23"
checksum = "b07db065a5cf61a7e4ba64f29e67db906fb1787316516c4e6e5ff0fea1efcd8a"

View File

@ -7,16 +7,16 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
log = "0.4.8"
chrono = "0.4.11"
fern = { version = "0.6.0", features = ["colored"] }
gfx-hal = "0.5.3"
winit = "0.22.0"
raw-window-handle = "0.3.3"
num-traits = "0.2.12"
log = "^0.4.8"
chrono = "^0.4.11"
fern = { version = "^0.6.0", features = ["colored"] }
gfx-hal = "^0.6.0"
winit = "^0.22.0"
raw-window-handle = "^0.3.3"
num-traits = "^0.2.12"
[dependencies.gfx-backend-vulkan]
version = "0.5"
version = "^0.6.1"
features = ["x11"]
[lib]

View File

@ -1 +1 @@
<mxfile host="Electron" modified="2020-09-04T11:01:21.930Z" agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/12.5.3 Chrome/83.0.4103.122 Electron/9.2.1 Safari/537.36" etag="YgdyJS5-mkG3ly8C_Hns" version="12.5.3" type="device"><diagram id="nEmVVCywiwsQaQufvWWo" name="Page-1">7Vxtc+I4Ev41VM1dFRR+I/hjAmFmb5Pd7JC7yewXSrEFaMa2vLYIYX79SrbkNwnHBDuzufJUisHtVkvubrUedcsMjJn//DEC4fYWu9Ab6GP3eWDMB7quWxcX9D9GOaSUqTZOCZsIuSlJywlL9ANyomDbIRfGJUaCsUdQWCY6OAigQ0o0EEV4X2ZbY6/cawg2UCIsHeDJ1C/IJVtO1SZ2fuMTRJst73qq8wf2gWDmTxJvgYv3BZJxPTBmEcYk/eY/z6DHlCf0krZbHLmbDSyCAWnS4D+//hpc/u/rt/nKeYDfdeKut5shl/IEvB1/4I/hjo+XHIQS4j3yPRDQq6s1DsiS39HoNfDQJqDfHToKGFHCE4wIovq75DcIDinV2SLPvQEHvGNjjQlwvourqy2O0A8qFnhcJr0dEe4K+qTEsWQtKXlMqRGMKc+d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BgAdJYL4Dnod1zwsAb15Y4EP16y92RzT0xoC8RUxVu4gsPxQBwjJyVyFq0OAL5YIBEYq1ggqXtvsb36yFmeYaorARvFy7PvJSksnL2NpPDEFEu7yN3z8taZWWGrLFSrwL7u0sFib1kuB2jvuQjQpr0vLMuumOY8e4sl4K3sa9h9pP8Jkb62Zv5PCfXql6DYucxVnByceb+lX+H2bcSA6UQ3Wo0BWZVoUhFbKQN0GPUVL/wU9oC90UdTS5Rkz7TyRcnGF29m4Xd/pOn/J+6LNM8/Je6rs78hr/m836AvfL6doG+Xo7PZSjSobB7e7NSPqUj3vv+A36bBbc2urPLt7OzET4aU3ahViy9uHmxn8vBl+GN7HYx/+xHbt5riB7DSd3Aqpu7LekWznlDWyzJ2oqJjylm9rIJX+t2hFpL+SosrdvJJDpkPiOV8kaFLKWYxtux+n+4lDebVOaU+pV8YZkd+0f8eVXfGVaTylcbtas7LUE4Uffo4306cnzaI84bK5HYLxRulzVW13X4+106Pc4K10rhdzWfVu6xXSaNq5VcUuFW/WqZa5tn8OUUGf2M7KQ6n8tQV6n1ygiCXfFRsJswPmRo+gfgz2KfnDz6BgPlY/4pdN04tkMVLTm21cNjodhs9DB2IgsPtUgP3/7X3zzeKvcg9M+nbbjtZtipOV6Q876PYOUrLxfG1YaKVi0O2YUiaNhWK1k9fGuhl/ovK6R4x/11q4/pv</diagram></mxfile>
<mxfile host="Electron" modified="2020-09-06T15:26:10.830Z" agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/12.5.3 Chrome/83.0.4103.122 Electron/9.2.1 Safari/537.36" etag="FFuBQ54XZzMJyE2_3O9m" version="12.5.3" type="device"><diagram id="nEmVVCywiwsQaQufvWWo" name="Page-1">7Vxtc5u4Fv41num9M/EYMI75mNhx27vpNm0623S/eBSQbbWAWJDjuL9+9cqrICSG7uYOnYxrDkcv6Bw9enSO8MhaBI9vYxDtPmAP+iNz4j2OrOXINM25adP/mOQoJI49E4JtjDw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uWfZtoJ7N4HLe2g/qIwxao5t9RRhM3RZ0iDB0ZF675ZzuK8BgTTTWzQUYsi1nhvDtAgNKv7jPH+ChY/+pbky1/tPbySCrmtgWIWl2nGHgAt1wAWdW5AKtT6wbs76ogFXNePNzM2nUT076LAw4TP2mqZ/Oo85zD0qvexeopksHZtCZeW2znXl7YwbVTZ4+9fAVhewVqtw7JJr4ddPJcbVatOMVSr9t/sCLwaE2AJ81XtvnlyQU0nZdH4L4lNbFLT5RTuoIiREIt/5Jvfgi63hJRwbw7xYdWhOA3mIB1rxi1VeWkLBHzekIzh8v2OuqmSdy2QqxoZIlPKXh+iBJkCuEUsVoIoBPJjAUx8onMJpeH+wuf3GSZ0z1mYCt5h3W1xIUVs7eRVB4NlVLu4rdy/TTiVFhu1ipUaJ9/YWD1d6ymA4wXnMSoEt7n9u2UzLNafZWS8Cvsq/lDEj/DyB9Y0773wL11XeE+LnJ7M3L15v6VW7fBQbMZ6bVKQakWaJZqdpSGqBH1Ne80ZLbAw5GH89tlZI90crnBRuf/zILv/ojR/8/uK/CPP8W3NdHfyOZ83m9oK98vhvQd4roPO0EDUqbh1926meqCfe+fsDv0uCO4ZRW+W52duqXO4pu1KnFV9d3jju7+3r2c3cVTn7/mTgfDM3vUIl3UkqmHtJ6ebM+I62XRuxURkfzIpShewNu1kHQX2txzU5evPIvOsRivsgyKyFm1bf0/hDuJS3m1SmpPq1fWNOe/GL4Waj+jKsJ5WuN29ecr1I5lfQZcL4bnJ+3wHlL+3MUHSRvtDbX5XaH+dw4PU4Ba61x+5rPujdCL3mhcuZXJbh1P+ilW+bZ/HlOHfINZp4cFvXpM9QHfoIgq7m22rSyIGLD8A4kn8FBnD94B0LmY8MrcP04tWIWTzm1/fzDRvQy+71dsXXJfrXYuvob</diagram></mxfile>

View File

@ -59,7 +59,7 @@ pub fn run() -> Result<(), &'static str> {
let mut windows = vec![
WinitWindow::new("IV", Rect {w: 1280, h: 720})?,
WinitWindow::new("IV 2", Rect {w: 720, h: 480})?,
// WinitWindow::new("IV 2", Rect {w: 720, h: 480})?,
];
let mut renderer: Renderer<vk_back::Backend> = Renderer::new(&mut windows)?;
@ -67,18 +67,14 @@ pub fn run() -> Result<(), &'static str> {
let color = [0.5, 0.0, 0.0, 1.0];
for window in &mut windows {
let _ = renderer.draw_clear_frame(window, color);
}
loop {
for window in &mut windows {
match renderer.draw_frame(window) {
match renderer.draw_clear_frame(window, color) {
Err(err) => println!("{}", err),
_ => (),
}
}
}
}}}
// Ok(())
}
// let (input_tx, input_rx) = mpsc::channel();

View File

@ -3,6 +3,7 @@ use log::{debug, error, info, trace, warn};
use std::{
mem::ManuallyDrop,
iter,
};
mod gpu;
@ -31,7 +32,10 @@ where
B: gfx_hal::Backend,
{
fn drop(&mut self) {
use gfx_hal::device::Device;
use gfx_hal::{
Instance,
device::Device,
};
debug!("Waiting for device to idle...");
let _ = self.gpu
@ -39,13 +43,14 @@ where
.wait_idle();
info!("Dropping Renderer...");
for mut swap_system in self.swap_systems.drain(..) {
swap_system.drop(&mut self.gpu, &self.instance);
}
// for mut pipeline in self.pipelines.drain(..) {
//
// }
//
unsafe {
for mut swap_system in self.swap_systems.drain(..) {
self.instance.destroy_surface(swap_system.drop(&mut self.gpu));
}
ManuallyDrop::drop(&mut self.gpu);
ManuallyDrop::drop(&mut self.instance);
}
@ -86,42 +91,88 @@ where
})
}
pub fn draw_frame<T, O>(&mut self, output: &mut O)
-> Result<(), &'static str>
where
T: raw_window_handle::HasRawWindowHandle,
O: Output<T>
{
use gfx_hal::window::AcquireError;
let swap_index = output.get_id();
let (frame, image_id) = match self.swap_systems[swap_index].acquire_frame() {
Ok((frame, image_id)) => (frame, image_id),
Err(err) => match err {
AcquireError::NotReady => {
return Err("Frame acquisition failed because all Frames are in use");
},
_ => Err("Could not acquire Frame from SwapSystem")?,
}};
let _ = frame.sync_gpu(&self.gpu)?;
let queue = &mut self.gpu.queue_mut();
frame.submit(queue);
let _ = self.swap_systems[swap_index].present_frame(frame, image_id, queue)?;
Ok(())
}
pub fn draw_clear_frame<T, O>(&mut self, output: &mut O, color: [f32; 4])
-> Result<(), &'static str>
where
T: raw_window_handle::HasRawWindowHandle,
O: Output<T>
{
self.swap_systems[output.get_id()].configure_render_pass(color)?;
self.draw_frame(output)
use gfx_hal::{
window::AcquireError,
device::Device,
queue::Submission,
};
let swap_system = &mut self.swap_systems[output.get_id()];
let mut frame = match swap_system.acquire_frame(&self.gpu) {
Ok(frame) => frame,
Err(err) => match err {
AcquireError::NotReady => {
return Err("Frame acquisition failed because all Frames are in use");
},
AcquireError::OutOfDate => {
swap_system.recreate(&mut self.gpu)?;
debug!("SwapSystem : {:#?}", swap_system);
return Ok(());
},
_ => Err("Could not acquire Frame from SwapSystem")?,
}};
trace!("Waiting for Frame...");
unsafe {
let _ = self.gpu.device()
.wait_for_fence(&frame.fences[0], !0)
.map_err(|_| "Failed to wait for Fence")?;
let _ = self.gpu.device()
.reset_fence(&frame.fences[0])
.map_err(|_| "Failed to reset fence")?;
}
trace!("Recording CommandBuffer...");
unsafe {
use gfx_hal::command::{
CommandBufferFlags,
SubpassContents,
ClearValue,
ClearColor,
CommandBuffer,
};
frame.command_buffer.begin_primary(CommandBufferFlags::ONE_TIME_SUBMIT);
let clear_value = ClearValue {color: ClearColor{float32: color}};
frame.command_buffer.begin_render_pass(
&swap_system.render_pass,
&frame.framebuffer.as_ref().unwrap(),
swap_system.render_area,
iter::once(clear_value),
SubpassContents::Inline,
);
frame.command_buffer.end_render_pass();
frame.command_buffer.finish();
}
trace!("Submiting to queue...");
let submission = Submission {
command_buffers: iter::once(&*frame.command_buffer),
wait_semaphores: None,
signal_semaphores: iter::once(&frame.signal_semaphores[0]),
};
unsafe {
use gfx_hal::queue::CommandQueue;
self.gpu.queue_mut().submit(submission, Some(&frame.fences[0]));
}
let result = swap_system.present_frame(frame, &mut self.gpu);
if result.is_err() {
swap_system.recreate(&mut self.gpu).unwrap();
}
Ok(())
}
}

View File

@ -162,7 +162,7 @@ where
trace!("Creating CommandPool...");
device
.create_command_pool(queue_group.family,
CommandPoolCreateFlags::empty())
CommandPoolCreateFlags::RESET_INDIVIDUAL)
.map_err(|_| "Could not create CommandPool")?
};

View File

@ -4,11 +4,11 @@ use log::{debug, error, info, trace, warn};
use std::{
mem::ManuallyDrop,
ptr::read,
collections::HashMap,
collections::VecDeque,
};
use gfx_hal::{
window::{Extent2D, AcquireError},
window::{Extent2D, AcquireError, PresentationSurface, SurfaceCapabilities, SwapchainConfig},
pso::Rect as GfxRect,
format::Format,
};
@ -24,11 +24,9 @@ pub struct SwapSystem<B: gfx_hal::Backend> {
surface: ManuallyDrop<B::Surface>,
format: Format,
extent: Extent2D,
render_area: GfxRect, //TODO may not be needed (duplicate of extent)
swapchain: ManuallyDrop<B::Swapchain>,
spare_semaphore: ManuallyDrop<B::Semaphore>,
render_pass: ManuallyDrop<B::RenderPass>,
frames: HashMap<usize, Frame<B>>,
pub render_area: GfxRect, //TODO may not be needed (duplicate of extent)
pub render_pass: ManuallyDrop<B::RenderPass>,
frames: VecDeque<Frame<B>>,
frame_nb: usize,
}
@ -36,36 +34,26 @@ impl<B> SwapSystem<B>
where
B: gfx_hal::Backend,
{
pub fn drop(&mut self, gpu: &mut Gpu<B>, instance: &B::Instance) {
use gfx_hal::{
device::Device,
Instance,
};
pub fn drop(&mut self, gpu: &mut Gpu<B>) -> B::Surface {
use gfx_hal::device::Device;
debug!("Dropping SwapSystem...");
for (_, mut frame) in self.frames.drain() {
for mut frame in self.frames.drain(..) {
frame.drop(gpu);
}
unsafe {
gpu.device().destroy_render_pass(
ManuallyDrop::into_inner(read(&mut self.render_pass)));
gpu.device().destroy_semaphore(
ManuallyDrop::into_inner(read(&mut self.spare_semaphore)));
gpu.device().destroy_swapchain(
ManuallyDrop::into_inner(read(&mut self.swapchain)));
//render_area extent and format can be dropped automatically
instance.destroy_surface(
ManuallyDrop::into_inner(read(&mut self.surface)));
}
self.surface.unconfigure_swapchain(gpu.device());
trace!("SwapSystem dropped !");
ManuallyDrop::take(&mut self.surface)
}
}
pub fn new(gpu: &mut Gpu<B>, mut surface: B::Surface)
-> Result<SwapSystem<B>, &'static str>
{
use gfx_hal::{
window::SwapchainConfig,
};
debug!("Creating SwapSystem...");
trace!("Obtaining surface capabilities...");
@ -99,8 +87,170 @@ where
let render_area = GfxRect{x: 0, y: 0, w: extent.width as i16, h: extent.height as i16};
trace!("Generating Swapchain configuration...");
let (swapchain_config, frame_nb) = {
let (swapchain_config, frame_nb) =
generate_swapchain_config(capabilities, &format, &extent)?;
debug!("Swapchain configuration : {:#?}", swapchain_config);
trace!("Configuring Swapchain...");
let _ = unsafe {
surface
.configure_swapchain(gpu.device(), swapchain_config)
.map_err(|_| "Failed to create swapchain and backbuffer")?
};
trace!("Creating RenderPass...");
let render_pass = {
use gfx_hal::{
pass::{Attachment, AttachmentOps, AttachmentLoadOp, AttachmentStoreOp, SubpassDesc},
image::Layout,
device::Device,
};
let color_attachment = Attachment {
format : Some(format),
samples : 1,
ops : AttachmentOps {
load : AttachmentLoadOp::Clear,
store : AttachmentStoreOp::Store,
},
stencil_ops : AttachmentOps::DONT_CARE,
layouts : (Layout::Undefined..Layout::Present),
};
let subpass = SubpassDesc {
colors : &[(0, Layout::ColorAttachmentOptimal)],
depth_stencil : None,
inputs : &[],
resolves : &[],
preserves : &[],
};
unsafe {
gpu.device().create_render_pass(&[color_attachment], &[subpass], &[])
.map_err(|_| "Could not create render pass")?
}
};
warn!("Generating hard-coded number of frames !");
let mut frames = VecDeque::with_capacity(frame_nb);
for _ in 0..frame_nb {
let frame = Frame::new(gpu)
.map_err(|_| "Could not create frame")?;
frames.push_back(frame);
};
let frame_nb = frames.len();
trace!("Created SwapSystem !");
Ok( SwapSystem {
surface: ManuallyDrop::new(surface),
format,
extent,
render_area,
render_pass: ManuallyDrop::new(render_pass),
frames,
frame_nb,
})
}
pub fn recreate(&mut self, gpu: &mut Gpu<B>) -> Result<(), &'static str> {
trace!("Obtaining surface capabilities...");
let capabilities = {
use gfx_hal::window::Surface;
self.surface.capabilities(&gpu.adapter().physical_device)
};
debug!("Surface capabitlities : {:#?}", capabilities);
trace!("Getting surface's render area size...");
self.extent = capabilities.current_extent
.unwrap_or(*capabilities.extents.end())
.clone();
self.render_area =
GfxRect{x: 0, y: 0, w: self.extent.width as i16, h: self.extent.height as i16};
trace!("Generating Swapchain configuration...");
let (swapchain_config, _frame_nb) = //TODO check frame nb change
generate_swapchain_config(capabilities, &self.format, &self.extent)?;
debug!("Swapchain configuration : {:#?}", swapchain_config);
trace!("Configuring Swapchain...");
let _ = unsafe {
self.surface
.configure_swapchain(gpu.device(), swapchain_config)
.map_err(|_| "Failed to create swapchain and backbuffer")?
};
Ok(())
}
pub fn acquire_frame(&mut self, gpu: &Gpu<B>) -> Result<Frame<B>, AcquireError> {
trace!("Acquiring Frame...");
let image = unsafe {
match self.surface.acquire_image(core::u64::MAX) {
Ok((image, suboptimal)) => {
match suboptimal {
Some(_) => return Err(AcquireError::OutOfDate),
None => image,
}},
Err(err) => return Err(err),
}};
let mut frame = self.frames.pop_back().unwrap();
trace!("Creating Framebuffer...");
let framebuffer = unsafe {
use gfx_hal::device::Device;
use std::borrow::Borrow;
gpu.device()
.create_framebuffer(&self.render_pass,
vec![image.borrow()],
self.extent.clone().to_extent())
.unwrap() //TODO improve that
};
frame.link_swapchain_image(image, framebuffer);
Ok(frame)
}
pub fn present_frame(&mut self, mut frame: Frame<B>, gpu: &mut Gpu<B>)
-> Result<(), &'static str> {
use gfx_hal::{
queue::CommandQueue,
device::Device,
};
let (image, framebuffer) = frame
.unlink_swapchain_image()
.unwrap(); //TODO improve that
trace!("Presenting Frame...");
let _ = unsafe {
gpu.queue_mut()
.present(&mut self.surface, image, Some(&frame.signal_semaphores[0]))
.map_err(|_| "Failed to present into the swapchain")?;
};
self.frames.push_front(frame);
trace!("Destroying Framebuffer...");
unsafe {
gpu.device().destroy_framebuffer(framebuffer);
}
Ok(())
}
}
fn generate_swapchain_config(capabilities: SurfaceCapabilities,
format: &Format,
extent: &Extent2D)
-> Result<(SwapchainConfig, usize), &'static str> {
trace!("Generating Swapchain configuration...");
let present_mode = {
use gfx_hal::window::PresentMode;
@ -147,7 +297,7 @@ where
Err("The Surface isn't capable of supporting color!")?
}};
(
Ok ((
SwapchainConfig {
present_mode,
composite_alpha_mode,
@ -158,143 +308,6 @@ where
image_usage,
},
image_count as usize
)
};
// //TODO improve swapchain configuration
// let swapchain_config = SwapchainConfig::from_caps(&capabilities, format, extent);
// let swapchain_config = swapchain_config.with_image_count(3);
debug!("Swapchain configuration : {:#?}", swapchain_config);
trace!("Creating Swapchain...");
let (swapchain, backbuffer) = unsafe {
use gfx_hal::device::Device;
gpu.device()
.create_swapchain(&mut surface, swapchain_config, None)
.map_err(|_| "Failed to create swapchain and backbuffer")?
};
trace!("Creating spare Semaphore...");
let spare_semaphore = {
use gfx_hal::device::Device;
gpu.device()
.create_semaphore()
.map_err(|_| "Could not create sempahore")?
};
trace!("Creating RenderPass...");
let render_pass = {
use gfx_hal::{
pass::{Attachment, AttachmentOps, AttachmentLoadOp, AttachmentStoreOp, SubpassDesc},
image::Layout,
device::Device,
};
let color_attachment = Attachment {
format : Some(format),
samples : 1,
ops : AttachmentOps {
load : AttachmentLoadOp::Clear,
store : AttachmentStoreOp::Store,
},
stencil_ops : AttachmentOps::DONT_CARE,
layouts : (Layout::Undefined..Layout::Present),
};
let subpass = SubpassDesc {
colors : &[(0, Layout::ColorAttachmentOptimal)],
depth_stencil : None,
inputs : &[],
resolves : &[],
preserves : &[],
};
unsafe {
gpu.device().create_render_pass(&[color_attachment], &[subpass], &[])
.map_err(|_| "Could not create render pass")?
}
};
warn!("Generating hard-coded number of frames !");
let mut frames = HashMap::with_capacity(frame_nb);
for i in 0..frame_nb {
let frame = Frame::new(gpu, &backbuffer[i], &format, &render_pass, &extent)
.map_err(|_| "Could not create frame")?;
frames.insert(i, frame);
};
let frame_nb = frames.len();
trace!("Created SwapSystem !");
Ok( SwapSystem {
surface: ManuallyDrop::new(surface),
format,
extent,
render_area,
swapchain: ManuallyDrop::new(swapchain),
spare_semaphore: ManuallyDrop::new(spare_semaphore),
render_pass: ManuallyDrop::new(render_pass),
frames,
frame_nb,
})
}
pub fn configure_render_pass(&mut self, color: [f32; 4]) -> Result<(), &'static str> {
if self.frames.len() != self.frame_nb {
return Err("Tried to configure RenderPass with frames acquired");
}
debug!("Configuring Color RenderPass...");
for (_, frame) in &mut self.frames {
frame.record_command_buffer(&self.render_pass, self.render_area.clone(), color);
}
Ok(())
}
pub fn acquire_frame(&mut self) -> Result<(Frame<B>, u32), AcquireError> {
use gfx_hal::window::Swapchain;
trace!("Acquiring Frame...");
let image_id = unsafe {
match self.swapchain.acquire_image(core::u64::MAX, Some(&self.spare_semaphore), None) {
Ok((image_id, suboptimal)) => {
match suboptimal {
Some(_) => return Err(AcquireError::OutOfDate),
None => image_id,
}},
Err(err) => return Err(err),
}};
//TODO give back image to swaphain
//debug!("image id : {}", image_id);
let mut frame = match self.frames.remove(&(image_id as usize)) {
Some(frame) => frame,
None => return Err(AcquireError::NotReady),
};
frame.swap_semaphore(&mut self.spare_semaphore);
Ok((frame, image_id))
}
pub fn present_frame(&mut self, frame: Frame<B>, image_id: u32, queue: &mut B::CommandQueue)
-> Result<(), &'static str> {
use gfx_hal::window::Swapchain;
trace!("Presenting Frame...");
let _result = unsafe {
self.swapchain
.present(queue, image_id, Some(frame.get_present_semaphore()))
.map_err(|_| "Failed to present into the swapchain")?;
};
self.frames.insert(image_id as usize, frame);
Ok(())
}
))
}

View File

@ -7,24 +7,19 @@ use std::{
iter,
};
use gfx_hal::{
window::Extent2D,
format::Format,
queue::Submission,
pso::Rect as GfxRect,
};
use gfx_hal::window::{PresentationSurface};
use super::super::gpu::Gpu;
//--Frame implementation----------------------------------------------------------------------------
#[derive(Debug)]
pub struct Frame<B: gfx_hal::Backend> {
wait_semaphores: Vec<B::Semaphore>,
signal_semaphores: Vec<B::Semaphore>,
fences: Vec<B::Fence>,
image_view: ManuallyDrop<B::ImageView>,
framebuffer: ManuallyDrop<B::Framebuffer>,
command_buffer: ManuallyDrop<B::CommandBuffer>,
pub wait_semaphores: Vec<B::Semaphore>,
pub signal_semaphores: Vec<B::Semaphore>,
pub fences: Vec<B::Fence>,
pub command_buffer: ManuallyDrop<B::CommandBuffer>,
image_view: Option<<B::Surface as PresentationSurface<B>>::SwapchainImage>,
pub framebuffer: Option<B::Framebuffer>,
}
impl<B> Frame<B>
@ -39,12 +34,11 @@ where
trace!("Dropping Frame...");
unsafe {
if self.image_view.is_some() {
warn!("Dropping non-presented frame !");
}
gpu.command_pool_mut().free(
iter::once(ManuallyDrop::into_inner(read(&mut self.command_buffer))));
gpu.device().destroy_framebuffer(
ManuallyDrop::into_inner(read(&mut self.framebuffer)));
gpu.device().destroy_image_view(
ManuallyDrop::into_inner(read(&mut self.image_view)));
for fence in self.fences.drain(..) {
gpu.device().destroy_fence(fence);
}
@ -58,12 +52,7 @@ where
}
}
pub fn new(gpu: &mut Gpu<B>,
image: &B::Image,
format: &Format,
render_pass: &B::RenderPass,
extent: &Extent2D)
-> Result<Frame<B>, &'static str>
pub fn new(gpu: &mut Gpu<B>) -> Result<Frame<B>, &'static str>
{
debug!("Creating Frame...");
@ -87,40 +76,6 @@ where
(wait_semaphores, signal_semaphores, fences)
};
trace!("Creating ImageView...");
let image_view = unsafe {
use gfx_hal::{
image::{ViewKind, SubresourceRange},
format::{Swizzle, Aspects},
device::Device,
};
gpu.device()
.create_image_view(
image,
ViewKind::D2,
format.clone(),
Swizzle::NO,
SubresourceRange {
aspects : Aspects::COLOR,
levels : 0..1,
layers : 0..1,
},
)
.map_err(|_| "Could not create ImageView")?
};
trace!("Creating Framebuffer...");
let framebuffer = unsafe {
use gfx_hal::device::Device;
gpu.device()
.create_framebuffer(render_pass,
vec![&image_view],
extent.clone().to_extent())
.map_err(|_| "Could not create FrameBuffer")?
};
trace!("Allocating CommandBuffer...");
let command_buffer = unsafe {
use gfx_hal::{
@ -136,86 +91,29 @@ where
wait_semaphores,
signal_semaphores,
fences,
image_view: ManuallyDrop::new(image_view),
framebuffer: ManuallyDrop::new(framebuffer),
command_buffer: ManuallyDrop::new(command_buffer),
image_view: None,
framebuffer: None,
})
}
pub fn sync_gpu(&self, gpu: &Gpu<B>) -> Result<(), &'static str>{
use gfx_hal::device::Device;
pub fn link_swapchain_image(&mut self,
image: <B::Surface as PresentationSurface<B>>::SwapchainImage,
framebuffer: B::Framebuffer) {
trace!("Waiting for Frame...");
unsafe {
let _ = gpu.device()
.wait_for_fence(&self.fences[0], !0)
.map_err(|_| "Failed to wait for Fence")?;
let _ = gpu.device()
.reset_fence(&self.fences[0])
.map_err(|_| "Failed to reset fence")?;
self.image_view = Some(image);
self.framebuffer = Some(framebuffer);
}
Ok(())
pub fn unlink_swapchain_image(&mut self)
-> Result<(<B::Surface as PresentationSurface<B>>::SwapchainImage,
B::Framebuffer), &'static str> {
match (self.image_view.take(), self.framebuffer.take()) {
(Some(image_view), Some(framebuffer)) => Some((image_view, framebuffer)),
_ => None,
}
pub fn record_command_buffer(&mut self,
render_pass: &B::RenderPass,
render_area: GfxRect,
color: [f32; 4]) {
trace!("Recording CommandBuffer...");
unsafe {
use gfx_hal::command::{
CommandBufferFlags,
SubpassContents,
ClearValue,
ClearColor,
CommandBuffer,
};
self.command_buffer.begin_primary(CommandBufferFlags::EMPTY);
let clear_value = ClearValue {color: ClearColor{float32: color}};
self.command_buffer.begin_render_pass(
render_pass,
&self.framebuffer,
render_area,
iter::once(clear_value),
SubpassContents::Inline,
);
self.command_buffer.end_render_pass();
self.command_buffer.finish();
}
}
pub fn submit(&self, queue: &mut B::CommandQueue) {
use gfx_hal::pso::PipelineStage;
trace!("Submiting to queue...");
let submission = Submission {
command_buffers: iter::once(&*self.command_buffer),
wait_semaphores: iter::once((&self.wait_semaphores[0],
PipelineStage::COLOR_ATTACHMENT_OUTPUT)),
signal_semaphores: iter::once(&self.signal_semaphores[0]),
};
unsafe {
use gfx_hal::queue::CommandQueue;
queue.submit(submission, Some(&self.fences[0]));
}
}
pub fn swap_semaphore(&mut self, semaphore: &mut B::Semaphore) {
std::mem::swap(&mut self.wait_semaphores[0], semaphore);
}
pub fn get_present_semaphore(&self) -> &B::Semaphore {
&self.signal_semaphores[0]
.ok_or("Can not unlink non-linked Frame !")
}
}