Skip to content

Commit

Permalink
Ray tracing support (#11)
Browse files Browse the repository at this point in the history
* Don't recreate extensions
* Remove unessecery deps/clean-up
* Mostly working ray tracing 🎉
  • Loading branch information
attackgoat authored May 20, 2022
1 parent ea1291b commit 6b7a485
Show file tree
Hide file tree
Showing 37 changed files with 2,786 additions and 1,447 deletions.
Binary file added .github/img/ray_trace.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.3.0] - UNRELEASED
## [0.3.0] - 2022-05-20

### Added

- Ray tracing support
- Subpass API, additional examples

### Removed

- Pak file functionality moved to `pak` [crate](https://crates.io/crates/pak)

## [0.2.1] - UNRELEASED
## [0.2.1] - _Unreleased_

### Added

Expand Down
5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@ description = "An easy-to-use Vulkan rendering engine in the spirit of QBasic."
archery = "0.4"
ash = "0.37"
ash-window = "0.10"
bitflags = "1.3"
derive_builder = "0.11"
gpu-allocator = { git = "https://github.com/Traverse-Research/gpu-allocator.git", branch = "ash-0.37" } # https://github.com/Traverse-Research/gpu-allocator/pull/104
gpu-allocator = "0.18"
log = "0.4"
ordered-float = "3.0"
parking_lot = "0.12"
paste = "1.0"
puffin = "0.13"
raw-window-handle = "0.4"
spirq = "0.5"
vk-sync = { version = "0.4.0", package = "vk-sync-fork" } # // SEE: https://github.com/gwihlidal/vk-sync-rs/pull/4 -> https://github.com/expenses/vk-sync-rs
Expand All @@ -45,4 +43,5 @@ pretty_env_logger = "0.4"
rand = "0.8"
screen-13-fx = { path = "contrib/screen-13-fx" }
screen-13-imgui = { path = "contrib/screen-13-imgui" }
tobj = "3.2"

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ itself is not tied to swapchain access and may be used to execute general comman

Features of the render graph:

- Compute, Graphic, and Ray-trace (WIP) pipelines
- Automatic Vulkan management (Render passes, subpasses, descriptors, pools, _etc._)
- Compute, graphic, and ray-trace pipelines
- Automatic Vulkan management (render passes, subpasses, descriptors, pools, _etc._)
- Automatic render pass scheduling, re-ordering, merging, with resource aliasing
- Interoperable with exsting Vulkan code

Expand Down
2 changes: 1 addition & 1 deletion contrib/screen-13-fx/src/bitmap_font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ where
0.0,
));

let vertex_buf_len = text.chars().count() as u64 * 120;
let vertex_buf_len = 120 * text.chars().count() as vk::DeviceSize;
let mut vertex_buf = self
.cache
.lease(BufferInfo {
Expand Down
6 changes: 5 additions & 1 deletion contrib/screen-13-fx/src/image_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ use {
screen_13::prelude_all::*,
};

fn align_up_u32(val: u32, atom: u32) -> u32 {
(val + atom - 1) & !(atom - 1)
}

/// Describes the channels and pixel stride of an image format
#[derive(Clone, Copy, Debug)]
pub enum ImageFormat {
Expand Down Expand Up @@ -162,7 +166,7 @@ where
//trace!("{bitmap_width}x{bitmap_height} Stride={bitmap_stride}");

let pixel_buf_stride = align_up_u32(stride as u32, 12);
let pixel_buf_len = (pixel_buf_stride * height) as u64;
let pixel_buf_len = (pixel_buf_stride * height) as vk::DeviceSize;

//trace!("pixel_buf_len={pixel_buf_len} pixel_buf_stride={pixel_buf_stride}");

Expand Down
1 change: 1 addition & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ Example | Instructions | Preview
[imgui.rs](imgui.rs) | <pre>cargo run --example imgui</pre> | <image alt="Preview" src="../.github/img/imgui.png" height=149 width=176>
[font_bmp.rs](font_bmp.rs) | <pre>cargo run --example font_bmp</pre> | <image alt="Preview" src="../.github/img/font_bmp.png" height=149 width=176>
[multipass.rs](multipass.rs) | <pre>cargo run --example multipass</pre> | <image alt="Preview" src="../.github/img/multipass.png" height=149 width=176>
[ray_trace.rs](ray_trace.rs) | <pre>cargo run --example ray_trace</pre> | <image alt="Preview" src="../.github/img/ray_trace.png" height=149 width=176>
[transitions.rs](transitions.rs) | <pre>cargo run --example transitions</pre> | <image alt="Preview" src="../.github/img/transitions.png" height=149 width=176>
[shader-toy/](shader-toy/src/main.rs) | <pre>cargo run --manifest-path examples/shader-toy/Cargo.toml</pre> | <image alt="Preview" src="../.github/img/shader-toy.png" height=105 width=176>
6 changes: 3 additions & 3 deletions examples/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ let driver = Driver::new(&my_winit_window, DriverConfig {
desired_swapchain_image_count: 3,
presentation: true, // require operating system window swapchain support
ray_tracing: true, // require KHR ray tracing support
sync_display: true, // v-sync
sync_display: true, // v-synceE
});
let driver = driver.expect("Oh no I don't support debug/presentation/ray_tracing if set!");
let device: Shared<Device> = driver.device;
Expand Down Expand Up @@ -419,8 +419,8 @@ functions:
Where:

- `node` is any type of buffer or image node
- `view_info` is an `ImageViewInfo { .. }` for images or `Range<u64>` for buffers
- `subresource` is an `ImageSubresource { .. }` for images or `Range<u64>` for buffers
- `view_info` is an `ImageViewInfo { .. }` for images or `Range<vk::DeviceSize>` for buffers
- `subresource` is an `ImageSubresource { .. }` for images or `Range<vk::DeviceSize>` for buffers
- `descriptor` is a GLSL or HLSL shader binding point, as described below

These functions work like the `access`, `read`, and `write` functions on `PassRef`/`PipelinePassRef`
Expand Down
4 changes: 2 additions & 2 deletions examples/multipass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ fn main() -> Result<(), DisplayError> {
// (Note the event_loop height and width may change, and are provided in the frame context,
// but we're not using that in this demo so the image won't resize with the window!
let image_info = image_info_2d(event_loop.width(), event_loop.height());
let index_buf_info = index_buffer_info(indices.len() as u64);
let vertex_buf_info = vertex_buffer_info(vertices.len() as u64);
let index_buf_info = index_buffer_info(indices.len() as vk::DeviceSize);
let vertex_buf_info = vertex_buffer_info(vertices.len() as vk::DeviceSize);

// Some colors for readability
let red = [0xffu8, 0x00, 0x00, 0xff];
Expand Down
Loading

0 comments on commit 6b7a485

Please sign in to comment.