Skip to content

Commit

Permalink
Merge #1476
Browse files Browse the repository at this point in the history
1476: [ll] Frames and encoders for render r=kvark a=Bastacyclop

Working on #1466.
This is an untested draft, I hope there are not too many mistakes.
The interesting stuff is in [core/pool](https://github.com/gfx-rs/gfx/compare/ll...Bastacyclop:ll?expand=1#diff-a8c8cf11be50bbdb6bab730b503bfe00), [render/device](https://github.com/gfx-rs/gfx/compare/ll...Bastacyclop:ll?expand=1#diff-a505eeca0919c44fc9d868f9a1cbdfe3) and more importantly [render/encoder](https://github.com/gfx-rs/gfx/compare/ll...Bastacyclop:ll?expand=1#diff-e76accb5ddad96024c8ebca0ad05ee68) and [render/lib](https://github.com/gfx-rs/gfx/compare/ll...Bastacyclop:ll?expand=1#diff-be2c920c08146924af4d1983d6894d63).
My next step will be to test it in a copy of the quad example.

You can acquire `encoder::Scope`s from which you can get actual `Encoder`s. An `encoder::Scope` is basically a more convenient command buffer pool. So there are two reasons to use multiple scopes: to use multiple encoders at the same time (multithreading mostly) and to release all the acquired encoders independently (different encoding scopes). Maybe scope is not a good name and I should name it simply pool instead.
  • Loading branch information
bors[bot] committed Sep 10, 2017
2 parents a1805e8 + 6a692e1 commit c4b2af6
Show file tree
Hide file tree
Showing 25 changed files with 1,471 additions and 336 deletions.
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ members = [
"src/backend/vulkan",
"src/core",
#"src/macros",
#"src/render",
"src/render",
#"src/support",
#"src/window/dxgi",
#"src/window/glfw",
#"src/window/glutin",
#"src/window/metal",
#"src/window/sdl",
#"examples",
"examples/core/quad"
"examples/core/quad",
"examples/render/quad_render",
]
6 changes: 3 additions & 3 deletions examples/core/quad/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ fn main() {
let mut queue = graphics_queues.remove(0);
let swap_config = SwapchainConfig::new()
.with_color::<ColorFormat>();
let mut swap_chain = surface.build_swapchain(swap_config, &queue);
let (mut swap_chain, backbuffers) = surface.build_swapchain(swap_config, &queue);

// Setup renderpass and pipeline
// dx12 runtime shader compilation
Expand Down Expand Up @@ -220,7 +220,7 @@ fn main() {
let set1 = sampler_pool.allocate_sets(&[&set1_layout]);

// Framebuffer and render target creation
let frame_rtvs = swap_chain.get_backbuffers().iter().map(|bb| {
let frame_rtvs = backbuffers.iter().map(|bb| {
device.view_image_as_render_target(&bb.color, ColorFormat::get_format(), (0..1, 0..1)).unwrap()
}).collect::<Vec<_>>();

Expand Down Expand Up @@ -401,7 +401,7 @@ fn main() {
let submit = {
let mut cmd_buffer = graphics_pool.acquire_command_buffer();

let rtv = &swap_chain.get_backbuffers()[frame.id()].color;
let rtv = &backbuffers[frame.id()].color;
if do_barriers {
let rtv_target_barrier = m::Barrier::Image {
states: (i::Access::empty(), i::ImageLayout::Undefined) ..
Expand Down
53 changes: 53 additions & 0 deletions examples/render/quad_render/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
[package]
name = "quad_render"
version = "0.1.0"
publish = false
workspace = "../../.."

[features]
default = ["vulkan"]
#metal = ["gfx_device_metal", "gfx_window_metal"]
gl = ["glutin", "gfx_backend_gl"]
#dx11 = ["gfx_device_dx11", "gfx_window_dxgi"]
#dx12 = ["gfx_device_dx12", "gfx_window_dxgi"]
vulkan = ["gfx_backend_vulkan"]
unstable = []

[[bin]]
name = "quad_render"
path = "main.rs"

[dependencies]
env_logger = "0.4"
glutin = { version = "0.9", optional = true }
image = "0.15"
log = "0.3"
winit = "0.7"
gfx_core = { path = "../../../src/core", version = "0.10" }
gfx = { path = "../../../src/render", version = "0.17" }

[dependencies.gfx_backend_gl]
path = "../../../src/backend/gl"
version = "0.1"
optional = true

[dependencies.gfx_backend_vulkan]
path = "../../../src/backend/vulkan"
version = "0.1"
optional = true

#[dependencies.gfx_device_metal]
#path = "../../../src/backend/metal"
#version = "0.3"
#optional = true

#[dependencies.gfx_window_metal]
#path = "../../../src/window/metal"
#version = "0.4"
#optional = true

#[target.'cfg(windows)'.dependencies]
#gfx_device_dx11 = { path = "../../../src/backend/dx11", version = "0.6", optional = true }
#gfx_device_dx12 = { path = "../../../src/backend/dx12", version = "0.1", optional = true }
#gfx_window_dxgi = { path = "../../../src/window/dxgi", version = "0.9", optional = true }

Loading

0 comments on commit c4b2af6

Please sign in to comment.