Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write Rendy backend for Turbine-Scene3D #89

Merged
merged 8 commits into from
Aug 22, 2019

Conversation

aaruel
Copy link
Contributor

@aaruel aaruel commented Aug 15, 2019

This is a follow up to issue #70. My goal for this implementation was to leave as much of the original API the same as possible, which I've achieved for the most part aside from some quirks.

In terms of dependencies, there are more crates introduced in this PR than I wanted (serde_json and spirv-reflect). The reason for that is, Rendy's exposure of SPIR-V reflection is minimal, leading to having to perform the reflection manually. I will probably open an issue on their repo addressing this. (amethyst/rendy#188)

Since Rendy/gfx-hal uses Winit, I used Piston's winit_window package but modified to be updated and work nicely with the WindowSettings builder. I will submit a PR on that repo so the dependency is an actual crate. (PistonDevelopers/winit_window#12)

Quirks:

  • Scene manages the window by passing in WindowSettings
  • The UBOS_PER_FRAME_SIZE constant determines how many draw calls (like DrawTriangles) there can be between frames. It's 4 for debugging but can be increased to something much larger.
  • There's a certain structure the shaders must follow because of SPIR-V. Just keep in mind:
    • Attributes layout locations are exact
    • UBO at set 0 binding 0 contains all the uniforms (which should be matched if needed in both vert and frag stages)
    • Sampler2d is always at set 1 binding 0
    • Inputs and outputs should have explicit locations
  • Toggling SRGB and Blending are disabled for now.
  • Drawing with multiple shaders is not tested but theoretically working.

Examples can be run at scene3d root as such cargo run --example colored_cube --features vulkan

@aaruel aaruel changed the title Write gfx-hal backend for Turbine-Scene3D Write Rendy backend for Turbine-Scene3D Aug 15, 2019
@bvssvni
Copy link
Member

bvssvni commented Aug 15, 2019

winit_window 0.12.0 is now published.

@aaruel
Copy link
Contributor Author

aaruel commented Aug 15, 2019

Thanks, updated cargo.toml

@aaruel
Copy link
Contributor Author

aaruel commented Aug 16, 2019

serde_json is now removed, I missed that there actually was a Rendy method exposing the compiled SPIR-V data.

@bvssvni
Copy link
Member

bvssvni commented Aug 19, 2019

I've been trying to install Vulkan on Ubuntu to test this PR, but without success so far (got problems with NVidia graphics drivers).

@aaruel
Copy link
Contributor Author

aaruel commented Aug 19, 2019

Possibly related, but a lot of people using Rendy reported having trouble with Vulkan validation layers on multiple SDK versions. I was on 1.1.108.0 and the validation layers crashed completely. I updated to 1.1.114.0 and was able to run it, but also got an error about VK_IMAGE_LAYOUT_UNDEFINED, which is pretty commonly reported on the Discord (however it doesn't affect anything as far as I can tell). If you run the examples with --release it should run without the validation layers and avoid the problems altogether.

@bvssvni
Copy link
Member

bvssvni commented Aug 22, 2019

I got problems installing graphics drivers. Adding --release does not work. However, I can build it just fine.

I think this is a fine starting point.

Merging.

@bvssvni bvssvni merged commit 1b2b120 into PistonDevelopers:master Aug 22, 2019
@bvssvni
Copy link
Member

bvssvni commented Aug 22, 2019

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants