mistodon / gfx-hal-tutorials Goto Github PK
View Code? Open in Web Editor NEWA series of small gfx-hal tutorials.
A series of small gfx-hal tutorials.
Hi, thanks for doing these tutorials! :)
I'm starting to run through these tutorials, and I got to the point in Part 1 where we create graphics resources:
let (instance, surface, adapter) = {
let instance = backend::Instance::create(APP_NAME, 1)
.expect("Backend not supported");
let surface = unsafe {
instance
.create_surface(&window)
.expect("Failed to create surface for window")
};
let adapter = instance.enumerate_adapters().remove(0);
(instance, surface, adapter)
};
I got the following error:
thread 'main' panicked at 'Failed to create surface for window:
UnsupportedWindowHandle', src/main.rs:50:13
(which corresponds to the instance.create_surface().expect()
line).
I took a look at the Vulkan backend code, and realized that the match
branches in create_surface
are all guarded by #[cfg(all(feature = "FOO", ...))]
I saw my system was trying to use the Xlib
window handle, so I threw in features = ["x11"]
to my Vulkan backend dependencies in Cargo.toml
:
[target.'cfg(all(unix, not(target_os = "macos")))'.dependencies.backend]
package = "gfx-backend-vulkan"
features = ["x11"]
version = "=0.5.1"
And it started working again. However, this is probably not the way to solve it for all Vulkan users :) I'm not sure what the correct way to solve this is, so I'm leaving this issue here instead.
Hi,
The package for the shader compilation says it's deprecated, I got tutorial 1 working using shaderc instead. Would you be interested in a pull request to update?
I ran the code on Linux Ubuntu 18.10. I have rustc 1.30.1 and rustup 1.14.0(1e51b07cc 2018-10-04) installed. everything is just as it is in the tutorial but still I get this error message:
Updating git repository `https://github.com/gfx-rs/gfx`
Updating crates.io index
Compiling cc v1.0.25
Compiling semver-parser v0.7.0
Compiling proc-macro2 v0.4.24
Compiling bitflags v1.0.4
Compiling libc v0.2.44
Compiling unicode-xid v0.1.0
Compiling gcc v0.3.55
Compiling lazy_static v1.2.0
Compiling core-foundation-sys v0.6.2
Compiling downcast-rs v1.0.3
Compiling void v1.0.2
Compiling rand_core v0.3.0
Compiling pkg-config v0.3.14
Compiling failure_derive v0.1.3
Compiling nix v0.11.0
Compiling foreign-types-shared v0.1.1
Compiling stable_deref_trait v1.1.1
Compiling scopeguard v0.3.3
Compiling cfg-if v0.1.6
Compiling remove_dir_all v0.5.1
Compiling rustc-demangle v0.1.9
Compiling block v0.1.6
Compiling byteorder v1.2.7
Compiling percent-encoding v1.0.1
Compiling gfx-backend-metal v0.1.0 (https://github.com/gfx-rs/gfx?rev=d428a5d5#d428a5d5)
Compiling xml-rs v0.7.0
Compiling semver v0.9.0
Compiling libloading v0.5.0
Compiling backtrace-sys v0.1.24
Compiling spirv_cross v0.10.1
Compiling unreachable v1.0.0
Compiling rand_isaac v0.1.1
Compiling rand_hc v0.1.0
Compiling rand_xorshift v0.1.0
Compiling rand_core v0.2.2
Compiling objc_exception v0.1.1
Compiling foreign-types v0.3.2
Compiling owning_ref v0.4.0
Compiling log v0.4.6
Compiling x11-dl v2.18.3
Compiling fxhash v0.2.1
error: failed to run custom build command for gfx-backend-metal v0.1.0 (https://github.com/gfx-rs/gfx?rev=d428a5d5#d428a5d5)
process didn't exit successfully: /home/wolfman13/Game Dev/Rust/Tutorials/gfx-triangle/target/debug/build/gfx-backend-metal-88c05fb0bf7b314f/build-script-build
(exit code: 101)
--- stdout
cargo:rerun-if-changed=/home/wolfman13/.cargo/git/checkouts/gfx-e86e7f3ebdbc4218/d428a5d/src/backend/metal/shaders
cargo:rerun-if-changed=/home/wolfman13/.cargo/git/checkouts/gfx-e86e7f3ebdbc4218/d428a5d/src/backend/metal/shaders/fill.metal
--- stderr
thread 'main' panicked at 'failed to execute metal compiler: Os { code: 2, kind: NotFound, message: "No such file or directory" }', libcore/result.rs:1009:5
note: Run with RUST_BACKTRACE=1
for a backtrace.
warning: build failed, waiting for other jobs to finish...
error: build failed
Can anyone please help :(
Hi, I am trying to learn with your tutorial, but I can't compile it.
failed to run custom build command for
glsl-to-spirv v0.1.7
I think this dependency got replaced with shaderc.
Could you please look at this error, and if it isn't a lot of work change the dependency?
Hi,
I recently updated to Rust 1.43 while typing in your code(slow but that is the way to learn) and compiling to perform checks. I started getting the following link errors on Windows 10 and do not know how to proceed at this point.
libspirv_cross-540902a585abd075.rlib(wrapper.o) : error LNK2001: unresolved external symbol __CxxFrameHandler4
libspirv_cross-540902a585abd075.rlib(spirv_msl.o) : error LNK2001: unresolved external symbol __CxxFrameHandler4
F:\users\fdemi\rust\Graphics\gfx-hal\gfx_hal_try1\target\debug\deps\gfx_hal_tutorials.exe : fatal error LNK1120: 1 unresolved externals
I know that _CXX** are windows symbols.
I am learning Rust while taking your tutorials. I do notice the rlib's have a bit of a different format.
Not sure how to proceed. Maybe see how to rollback Rust to an earlier version?
Pretty much what it says, I run part01-resizing
with a Vulkan backend, and on resize I get the following:
thread 'main' panicked at 'Present failed: ()', libcore/result.rs:945:5
stack backtrace:
0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
1: std::sys_common::backtrace::print
at libstd/sys_common/backtrace.rs:71
at libstd/sys_common/backtrace.rs:59
2: std::panicking::default_hook::{{closure}}
at libstd/panicking.rs:211
3: std::panicking::default_hook
at libstd/panicking.rs:227
4: std::panicking::rust_panic_with_hook
at libstd/panicking.rs:511
5: std::panicking::continue_panic_fmt
at libstd/panicking.rs:426
6: rust_begin_unwind
at libstd/panicking.rs:337
7: core::panicking::panic_fmt
at libcore/panicking.rs:92
8: core::result::unwrap_failed
at /checkout/src/libcore/macros.rs:26
9: <core::result::Result<T, E>>::expect
at /checkout/src/libcore/result.rs:809
10: part01_resizing::main
at src/bin/part01-resizing.rs:313
11: std::rt::lang_start::{{closure}}
at /checkout/src/libstd/rt.rs:74
12: std::panicking::try::do_call
at libstd/rt.rs:59
at libstd/panicking.rs:310
13: __rust_maybe_catch_panic
at libpanic_unwind/lib.rs:105
14: std::rt::lang_start_internal
at libstd/panicking.rs:289
at libstd/panic.rs:392
at libstd/rt.rs:58
15: std::rt::lang_start
at /checkout/src/libstd/rt.rs:74
16: main
17: __libc_start_main
18: _start
This line appears to be swapchain.present(&mut queue_group.queues[0], frame_index, &[]).expect("Present failed");
. Haven't fiddled around with it further yet.
Hello,
I have encountered the following issue in part-2 of the tutorial:
A black window appears when I'm trying to run the program. There are no errors on the console, neither during compilation, nor during runtime.
Environment:
Linux OS with X11
Hardware:
OpenGL vendor string: Intel
OpenGL renderer string: Mesa Intel(R) HD Graphics 5500 (BDW GT2)
OpenGL core profile version string: 4.6 (Core Profile) Mesa 20.2.3
OpenGL core profile shading language version string: 4.60
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 4.6 (Compatibility Profile) Mesa 20.2.3
OpenGL shading language version string: 4.60
OpenGL context flags: (none)
OpenGL profile mask: compatibility profile
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 3.2 Mesa 20.2.3
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20
OpenGL ES profile extensions:
OpenGL vendor string: NVIDIA Corporation
OpenGL renderer string: GeForce 920M/PCIe/SSE2
OpenGL core profile version string: 4.6.0 NVIDIA 418.113
OpenGL core profile shading language version string: 4.60 NVIDIA
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 4.6.0 NVIDIA 418.113
OpenGL shading language version string: 4.60 NVIDIA
OpenGL context flags: (none)
OpenGL profile mask: (none)
OpenGL extensions:
As I have no access to a Vulkan-capable hardware, I switched to the gl
backend. Also, I have added the x11 feature to the Cargo.toml file as follows:
[target.'cfg(all(unix, not(target_os = "macos")))'.dependencies.backend]
package = "gfx-backend-gl"
version = "=0.6.1"
features = ["x11"]
With both rendering devices mentioned above, I get a black window, no triangles are shown. The part-1 of the tutorial worked correctly.
I have also tried to upgrade all dependencies in Cargo.toml to the currently available most up-to-date versions. This didn't fix the issue, while part-1 of the tutorial still worked.
Note: after upgrading winit, let dpi = event_loop.primary_monitor().scale_factor();
has to be changed to something like let dpi = event_loop.primary_monitor().unwrap().scale_factor();
, as the event_loop.primary_monitor()
method now returns an Option
.
Now, as I get no errors at all, I have absolutely no clue where to even start with debugging the code.
hello,
i followed the first part of the tutorials and the triangle example works on Linux (using the vulkan backend) but on Windows (dx12), the window opens up as blank, does not respond, then it closes and I get the aforementioned exit code. there are no logs, or anything in the console that could potentially give me a clue on what is happening.
i know that my PC does support dx12. the GPU is a GeForce 635M with the default drivers you get from the nvidia utility for this GPU.
sorry if the info i'm giving is lacking, but that's about it :|
i appreciate any help.
As far as I can see there's no license file and no license entry in the Cargo.toml file.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.