From 8e62c189f345ef3e6752fa4debe8eefa61042400 Mon Sep 17 00:00:00 2001 From: Felix Kaaman Date: Fri, 22 Jun 2018 15:00:34 +0300 Subject: [PATCH] Add dx11 --- Cargo.lock | 26 ++++++++++++++++++++++---- libportability-gfx/Cargo.toml | 5 +++++ libportability-gfx/src/impls.rs | 8 ++++++++ libportability-gfx/src/lib.rs | 2 ++ libportability-icd/Cargo.toml | 1 + libportability/Cargo.toml | 1 + 6 files changed, 39 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 189fb18..a683eaa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -257,10 +257,26 @@ name = "gcc" version = "0.3.54" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "gfx-backend-dx11" +version = "0.1.0" +source = "git+https://github.com/gfx-rs/gfx#842b9313d9391dc99dc215bc2dd01f9e4daffcda" +dependencies = [ + "bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "derivative 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gfx-hal 0.1.0 (git+https://github.com/gfx-rs/gfx)", + "log 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "spirv_cross 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "winit 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", + "wio 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "gfx-backend-dx12" version = "0.1.0" -source = "git+https://github.com/gfx-rs/gfx#39aff0d7cf5e756fafdc310731d426c7883f9414" +source = "git+https://github.com/gfx-rs/gfx#842b9313d9391dc99dc215bc2dd01f9e4daffcda" dependencies = [ "bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "derivative 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -276,7 +292,7 @@ dependencies = [ [[package]] name = "gfx-backend-metal" version = "0.1.0" -source = "git+https://github.com/gfx-rs/gfx#39aff0d7cf5e756fafdc310731d426c7883f9414" +source = "git+https://github.com/gfx-rs/gfx#842b9313d9391dc99dc215bc2dd01f9e4daffcda" dependencies = [ "bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "block 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -299,7 +315,7 @@ dependencies = [ [[package]] name = "gfx-backend-vulkan" version = "0.1.0" -source = "git+https://github.com/gfx-rs/gfx#39aff0d7cf5e756fafdc310731d426c7883f9414" +source = "git+https://github.com/gfx-rs/gfx#842b9313d9391dc99dc215bc2dd01f9e4daffcda" dependencies = [ "ash 0.24.3 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -317,7 +333,7 @@ dependencies = [ [[package]] name = "gfx-hal" version = "0.1.0" -source = "git+https://github.com/gfx-rs/gfx#39aff0d7cf5e756fafdc310731d426c7883f9414" +source = "git+https://github.com/gfx-rs/gfx#842b9313d9391dc99dc215bc2dd01f9e4daffcda" dependencies = [ "bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -557,6 +573,7 @@ name = "portability-gfx" version = "0.1.0" dependencies = [ "env_logger 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", + "gfx-backend-dx11 0.1.0 (git+https://github.com/gfx-rs/gfx)", "gfx-backend-dx12 0.1.0 (git+https://github.com/gfx-rs/gfx)", "gfx-backend-metal 0.1.0 (git+https://github.com/gfx-rs/gfx)", "gfx-backend-vulkan 0.1.0 (git+https://github.com/gfx-rs/gfx)", @@ -978,6 +995,7 @@ dependencies = [ "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" "checksum fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" "checksum gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)" = "5e33ec290da0d127825013597dbdfc28bee4964690c7ce1166cbc2a7bd08b1bb" +"checksum gfx-backend-dx11 0.1.0 (git+https://github.com/gfx-rs/gfx)" = "" "checksum gfx-backend-dx12 0.1.0 (git+https://github.com/gfx-rs/gfx)" = "" "checksum gfx-backend-metal 0.1.0 (git+https://github.com/gfx-rs/gfx)" = "" "checksum gfx-backend-vulkan 0.1.0 (git+https://github.com/gfx-rs/gfx)" = "" diff --git a/libportability-gfx/Cargo.toml b/libportability-gfx/Cargo.toml index 17bbe79..d39790c 100644 --- a/libportability-gfx/Cargo.toml +++ b/libportability-gfx/Cargo.toml @@ -41,6 +41,11 @@ git = "https://github.com/gfx-rs/gfx" #path = "../../gfx/src/backend/dx12" optional = true +[target.'cfg(windows)'.dependencies.gfx-backend-dx11] +git = "https://github.com/gfx-rs/gfx" +#path = "../../gfx/src/backend/dx11" +optional = true + [target.'cfg(target_os = "macos")'.dependencies.gfx-backend-metal] git = "https://github.com/gfx-rs/gfx" #path = "../../gfx/src/backend/metal" diff --git a/libportability-gfx/src/impls.rs b/libportability-gfx/src/impls.rs index 43d0e13..5b21a10 100644 --- a/libportability-gfx/src/impls.rs +++ b/libportability-gfx/src/impls.rs @@ -4107,6 +4107,14 @@ pub extern "C" fn gfxCreateWin32SurfaceKHR( VkResult::VK_SUCCESS } } + #[cfg(feature = "gfx-backend-dx11")] + { + unsafe { + assert_eq!(info.flags, 0); + *pSurface = Handle::new(instance.backend.create_surface_from_hwnd(info.hwnd)); + VkResult::VK_SUCCESS + } + } #[cfg(not(target_os = "windows"))] { let _ = (instance, info, pSurface); diff --git a/libportability-gfx/src/lib.rs b/libportability-gfx/src/lib.rs index 3ef0941..39ff064 100644 --- a/libportability-gfx/src/lib.rs +++ b/libportability-gfx/src/lib.rs @@ -7,6 +7,8 @@ extern crate gfx_hal as hal; #[cfg(feature = "gfx-backend-dx12")] extern crate gfx_backend_dx12 as back; +#[cfg(feature = "gfx-backend-dx11")] +extern crate gfx_backend_dx11 as back; #[cfg(feature = "gfx-backend-metal")] extern crate gfx_backend_metal as back; #[cfg(feature = "gfx-backend-vulkan")] diff --git a/libportability-icd/Cargo.toml b/libportability-icd/Cargo.toml index 038844f..0891a52 100644 --- a/libportability-icd/Cargo.toml +++ b/libportability-icd/Cargo.toml @@ -14,6 +14,7 @@ crate-type = ["cdylib"] [features] default = [] dx12 = ["portability-gfx/gfx-backend-dx12"] +dx11 = ["portability-gfx/gfx-backend-dx11"] metal = ["portability-gfx/gfx-backend-metal"] vulkan = ["portability-gfx/gfx-backend-vulkan"] diff --git a/libportability/Cargo.toml b/libportability/Cargo.toml index 0e3ba3b..863bea4 100644 --- a/libportability/Cargo.toml +++ b/libportability/Cargo.toml @@ -15,6 +15,7 @@ crate-type = ["cdylib"] default = [] debug = ["portability-gfx/env_logger", "portability-gfx/nightly"] dx12 = ["portability-gfx/gfx-backend-dx12"] +dx11 = ["portability-gfx/gfx-backend-dx11"] metal = ["portability-gfx/gfx-backend-metal"] vulkan = ["portability-gfx/gfx-backend-vulkan"]