Learning_gfx_hal tutorial and problems with finding gfx_backend_dx12

Hi,
I am working through the learning_gfx_tutorial and trying to use more current crates since the original cargo.toml does not allow complete compilation.

With the newer versions of gfx_backend_dx12 I have in a library file(hal_state.rs)
pub mod Halstate

use gfx_hal:: long list
use log etc

use gfx_backend_dx12 as back;

The problem is that the compilation process finds gfx_hal and log well enough but fails with gfx_backend_dx12 with can't find crate gfx_backend_dx12

I used the original Cargo.toml from the original git project(listed below) with a few updates to versions but no luck . Any ideas??? Is the problem that not enough information has been created in my project dependencies for the compilation process to make the connection? I suspect this but really don't know


Cargo.toml

[package]

name = "learning_gfx_hal"

version = "0.1.0"

authors = ["FrankieD frank.deming@gmail.com"]

edition = "2018"

See more keys and their definitions at The Manifest Format - The Cargo Book

[features]

default =

metal = ["gfx-backend-metal"]

dx12 = ["gfx-backend-dx12"]

vulkan = ["gfx-backend-vulkan"]

[dependencies]

winit = "0.22.2"

log = "0.4.8"

simple_logger = "1.6.0"

gfx-hal = "0.4.0"

arrayvec = "0.5.1"

[dependencies.gfx-backend-vulkan]

version = "0.4.0"

optional = true

[target.'cfg(target_os = "macos")'.dependencies.gfx-backend-metal]

version = "0.4.0"

optional = true

[target.'cfg(target_os = "windows")'.dependencies.gfx-backend-dx12]

version = "0.4.0"

optional = true.
Thanks,
Frank

Hi Adding to my question I ran "cargo metadata" on my project and examined the json file. I did not find any mention of gfx_backend_dx12

Frank

My above statement is incorrect
Frank

Try running with

cargo run --features dx12

gfx-backend-dx12 is configured as an optional dependency, so it won't compile by default. The following two lines

default = []
dx12 = ["gfx-backend-dx12"]

state that by default no features are enabled, and that for your workspace a feature named dx12 will enable the feature gfx-backend-dx12. The config is set up this way to make it easy to compile for multiple backends. If that's not needed though and you always want to use dx12 then you can change default to

default = ["gfx-backend-dx12"]

Hi , thanks for hint. I had been doing that with the features.

I think my problem is in part that I have put some of the major types from learning_gfx_hal into the lib directory as pub mod modules. I have not sorted out the Cargo.html for the lib directory correctly. I have tried some examples that I have in documentation and some other sites but I not quite getting it yet.

I trying to create individual pub modules for hal_state and winit_state if you are familiar with the learning_gfx_hal tutorials.

As a simplified example I have in lib/winit_state.rs

pub mod winit_state
{
use winit::{ dpi:PhyscialSize, error:OsError

etc.

the lib/Cargo.toml has winit listed as a dependency

[package]
name = "fd_gfx_hal"
version = "0.1.0"
authors = ["FrankieD frank.deming@gmail.com"]
edition = "2018"

See more keys and their definitions at The Manifest Format - The Cargo Book

[dependencies]
winit = "0.22.2"

[[bin]]
name = "lib_gfx"
path = "."

Compiling winit_state.rs gives me a compiler error of "maybe a missing crate" about winit. I tried extern crate winit; but that errors as the crate is not found. In the top Cargo.toml winit is listed as a dependency.

I guess I just don't understand all the scoping rules in play at this point.

By the way i have backed off of dealing with gfx_backend_dx12 until I understand this problem.
Thanks,
Frank

One other item to add. In the top-level project Cargo.toml I have

[workspace]
members =[
"lib" ]

with examples to add on eventually.

I have gotten the problem fixed except for the problem with gfx_backend_dx12. I put in the appropriate lib targets in the project Cargo.toml and the one in the lib.

Is gfx_backend_dx12 broken right now? The documentation page on crates.io certainly is.

Frank

I figured out my problem. I am learning rust(from Programming Rust, Blandy) while entering code from online tutorials such as learning_gfx_hal. Somehow I got a
//#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq)]
before a
pub struct HalState {
etc.

I got an error that was not obviously tied to the #[derive statement. As I learning more from the book I suddenly saw it. A chapter on utility traits ringed the bell.

I like Rust's goals but it is not easy after a number of years of not programming.

Frank

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.