Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions command/src/buffer/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ where
self.raw,
rendy_core::hal::buffer::IndexBufferView {
buffer: buffer,
offset,
range: rendy_core::hal::buffer::SubRange { offset, size: None },
index_type,
},
)
Expand Down Expand Up @@ -137,7 +137,12 @@ where
rendy_core::hal::command::CommandBuffer::bind_vertex_buffers(
self.raw,
first_binding,
buffers,
buffers.into_iter().map(|(buffer, offset)| {
(
buffer,
rendy_core::hal::buffer::SubRange { offset, size: None },
)
}),
)
}

Expand Down
4 changes: 3 additions & 1 deletion command/src/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ where
{
let level = L::default();

let buffers = unsafe { self.raw.allocate_vec(count, level.raw_level()) };
let mut buffers: Vec<_> = Vec::new();

unsafe { self.raw.allocate(count, level.raw_level(), &mut buffers) };

buffers
.into_iter()
Expand Down
12 changes: 6 additions & 6 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ vulkan = ["gfx-backend-vulkan"]
no-slow-safety-checks = []

[dependencies]
gfx-hal = { git = "https://github.com/gfx-rs/gfx", rev = "3641183231f16877d4ea2fbdb2ff208ce736d6c4" }
gfx-backend-empty = { git = "https://github.com/gfx-rs/gfx", rev = "3641183231f16877d4ea2fbdb2ff208ce736d6c4", optional = true }
gfx-backend-gl = { git = "https://github.com/gfx-rs/gfx", rev = "3641183231f16877d4ea2fbdb2ff208ce736d6c4", features = ["glutin"], optional = true }
gfx-hal = { git = "https://github.com/gfx-rs/gfx", rev = "6d10d21788fffa6a7ca17888c8d3a4b6265442e7" }
gfx-backend-empty = { git = "https://github.com/gfx-rs/gfx", rev = "6d10d21788fffa6a7ca17888c8d3a4b6265442e7", optional = true }
gfx-backend-gl = { git = "https://github.com/gfx-rs/gfx", rev = "6d10d21788fffa6a7ca17888c8d3a4b6265442e7", features = ["glutin"], default_features = false, optional = true }
lazy_static = "1.0"
log = "0.4"
parking_lot = "0.9"
Expand All @@ -37,10 +37,10 @@ thread_profiler = "0.3"
raw-window-handle = "0.3"

[target.'cfg(all(target_os = "windows", not(target_arch = "wasm32")))'.dependencies]
gfx-backend-dx12 = { git = "https://github.com/gfx-rs/gfx", rev = "3641183231f16877d4ea2fbdb2ff208ce736d6c4", optional = true }
gfx-backend-dx12 = { git = "https://github.com/gfx-rs/gfx", rev = "6d10d21788fffa6a7ca17888c8d3a4b6265442e7", optional = true }

[target.'cfg(any(all(not(target_arch = "wasm32"), target_os = "macos"), all(target_arch = "aarch64", target_os = "ios")))'.dependencies]
gfx-backend-metal = { git = "https://github.com/gfx-rs/gfx", rev = "3641183231f16877d4ea2fbdb2ff208ce736d6c4", optional = true }
gfx-backend-metal = { git = "https://github.com/gfx-rs/gfx", rev = "6d10d21788fffa6a7ca17888c8d3a4b6265442e7", optional = true }

[target.'cfg(all(any(target_os = "windows", all(unix, not(any(target_os = "macos", target_os = "ios")))), not(target_arch = "wasm32")))'.dependencies]
gfx-backend-vulkan = { git = "https://github.com/gfx-rs/gfx", rev = "3641183231f16877d4ea2fbdb2ff208ce736d6c4", features = ["x11"], optional = true }
gfx-backend-vulkan = { git = "https://github.com/gfx-rs/gfx", rev = "6d10d21788fffa6a7ca17888c8d3a4b6265442e7", features = ["x11"], optional = true }
2 changes: 1 addition & 1 deletion descriptor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ categories = ["rendering"]
description = "Rendy's descriptor allocator"

[dependencies]
gfx-hal = { git = "https://github.com/gfx-rs/gfx", rev = "3641183231f16877d4ea2fbdb2ff208ce736d6c4" }
gfx-hal = { git = "https://github.com/gfx-rs/gfx", rev = "6d10d21788fffa6a7ca17888c8d3a4b6265442e7" }
log = "0.4"
relevant = { version = "0.4", features = ["log"] }
smallvec = "1.0"
19 changes: 12 additions & 7 deletions descriptor/src/allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,9 @@ unsafe fn allocate_from_pool<B: Backend>(
allocation: &mut SmallVec<[B::DescriptorSet; 1]>,
) -> Result<(), OutOfMemory> {
let sets_were = allocation.len();
raw.allocate_sets(std::iter::repeat(layout).take(count as usize), allocation)
raw.allocate(std::iter::repeat(layout).take(count as usize), allocation)
.map_err(|err| match err {
AllocationError::Host => OutOfMemory::Host,
AllocationError::Device => OutOfMemory::Device,
AllocationError::OutOfMemory(oom) => oom,
err => {
// We check pool for free descriptors and sets before calling this function,
// so it can't be exhausted.
Expand Down Expand Up @@ -182,7 +181,7 @@ where

while count > 0 {
let size = self.new_pool_size(count);
let pool_ranges = layout_ranges * size;
let pool_ranges = layout_ranges.clone() * size;
log::trace!(
"Create new pool with {} sets and {:?} descriptors",
size,
Expand Down Expand Up @@ -301,9 +300,15 @@ where

let bucket = self
.buckets
.entry(layout_ranges)
.entry(layout_ranges.clone())
.or_insert_with(|| DescriptorBucket::new());
match bucket.allocate(device, layout, layout_ranges, count, &mut self.allocation) {
match bucket.allocate(
device,
layout,
layout_ranges.clone(),
count,
&mut self.allocation,
) {
Ok(()) => {
extend.extend(
Iterator::zip(
Expand All @@ -312,7 +317,7 @@ where
)
.map(|(pool, set)| DescriptorSet {
raw: set,
ranges: layout_ranges,
ranges: layout_ranges.clone(),
pool,
}),
);
Expand Down
4 changes: 2 additions & 2 deletions descriptor/src/ranges.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const DESCRIPTOR_TYPES: [DescriptorType; DESCRIPTOR_TYPES_COUNT] = [
},
},
DescriptorType::Image {
ty: ImageDescriptorType::Storage,
ty: ImageDescriptorType::Storage { read_only: false },
},
DescriptorType::Buffer {
ty: BufferDescriptorType::Storage { read_only: false },
Expand Down Expand Up @@ -70,7 +70,7 @@ fn descriptor_type_index(ty: &DescriptorType) -> usize {
},
} => 2,
DescriptorType::Image {
ty: ImageDescriptorType::Storage,
ty: ImageDescriptorType::Storage { read_only: _ },
} => 3,
DescriptorType::Buffer {
ty: BufferDescriptorType::Storage { read_only: _ },
Expand Down
12 changes: 9 additions & 3 deletions graph/src/node/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ pub enum NodeBuildError {
/// Mismatched or unsupported queue family.
QueueFamily(FamilyId),
/// Failed to create an imate view.
View(rendy_core::hal::image::ViewError),
View(rendy_core::hal::image::ViewCreationError),
/// Failed to create a pipeline.
Pipeline(rendy_core::hal::pso::CreationError),
/// Failed to create a swap chain.
Expand Down Expand Up @@ -523,7 +523,10 @@ pub fn gfx_acquire_barriers<'a, 'b, B: Backend>(
.get_buffer(buffer.id)
.expect("Buffer does not exist")
.raw(),
range: Some(buffer.range.start)..Some(buffer.range.end),
range: rendy_core::hal::buffer::SubRange {
offset: buffer.range.start,
size: Some(buffer.range.start - buffer.range.end),
},
}
})
})
Expand Down Expand Up @@ -574,7 +577,10 @@ pub fn gfx_release_barriers<'a, B: Backend>(
.get_buffer(buffer.id)
.expect("Buffer does not exist")
.raw(),
range: Some(buffer.range.start)..Some(buffer.range.end),
range: rendy_core::hal::buffer::SubRange {
offset: buffer.range.start,
size: Some(buffer.range.end - buffer.range.start),
},
}
})
})
Expand Down
14 changes: 9 additions & 5 deletions graph/src/node/render/pass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,10 @@ where

/// Add sub-pass to the render-pass.
pub fn add_subpass(&mut self, subpass: SubpassBuilder<B, T>) -> &mut Self {
// Since GFX only allows us to pass a u8 for the subpass index, we need
// to make sure that the subpass count never exceeds 255.
assert!(self.subpasses.len() < 255);

self.subpasses.push(subpass);
self
}
Expand Down Expand Up @@ -858,7 +862,7 @@ where
framebuffer_width,
framebuffer_height,
rendy_core::hal::pass::Subpass {
index,
index: index as u8,
main_pass: &render_pass,
},
buffers,
Expand Down Expand Up @@ -1168,7 +1172,7 @@ where
queue.id(),
index,
rendy_core::hal::pass::Subpass {
index: subpass_index,
index: subpass_index as u8,
main_pass: &render_pass,
},
aux,
Expand Down Expand Up @@ -1219,7 +1223,7 @@ where
pass_encoder.reborrow(),
index,
rendy_core::hal::pass::Subpass {
index: subpass_index,
index: subpass_index as u8,
main_pass: &render_pass,
},
aux,
Expand Down Expand Up @@ -1350,7 +1354,7 @@ where
queue.id(),
index,
rendy_core::hal::pass::Subpass {
index: subpass_index,
index: subpass_index as u8,
main_pass: &render_pass,
},
aux,
Expand Down Expand Up @@ -1392,7 +1396,7 @@ where
pass_encoder.reborrow(),
index,
rendy_core::hal::pass::Subpass {
index: subpass_index,
index: subpass_index as u8,
main_pass: &render_pass,
},
aux,
Expand Down
2 changes: 1 addition & 1 deletion init/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ rendy-command = { version = "0.5.1", path = "../command" }
rendy-factory = { version = "0.5.1", path = "../factory" }
rendy-core = { version = "0.5.1", path = "../core" }
rendy-wsi = { version = "0.5.1", path = "../wsi" }
winit = { version = "0.20.0-alpha4", optional = true, features = ["web-sys"] }
winit = { version = "0.21.0", optional = true, features = ["web-sys"] }
log = "0.4"
smallvec = "1.0"
2 changes: 1 addition & 1 deletion memory/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ description = "Rendy's memory manager"
serde-1 = ["serde", "gfx-hal/serde"]

[dependencies]
gfx-hal = { git = "https://github.com/gfx-rs/gfx", rev = "3641183231f16877d4ea2fbdb2ff208ce736d6c4" }
gfx-hal = { git = "https://github.com/gfx-rs/gfx", rev = "6d10d21788fffa6a7ca17888c8d3a4b6265442e7" }
log = "0.4"
hibitset = {version = "0.6", default-features = false}
relevant = { version = "0.4", features = ["log"] }
Expand Down
8 changes: 7 additions & 1 deletion memory/src/allocator/dedicated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,13 @@ where
))
} else {
self.unmap(device);
let ptr = device.map_memory(self.memory.raw(), mapping_range.clone())?;
let ptr = device.map_memory(
self.memory.raw(),
gfx_hal::memory::Segment {
offset: mapping_range.start,
size: Some(mapping_range.end - mapping_range.start),
},
)?;
let ptr = NonNull::new(ptr).expect("Memory mapping shouldn't return nullptr");
let mapping =
MappedRange::from_raw(&self.memory, ptr, mapping_range, requested_range);
Expand Down
8 changes: 7 additions & 1 deletion memory/src/allocator/dynamic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,13 @@ where
.contains(gfx_hal::memory::Properties::CPU_VISIBLE)
{
log::trace!("Map new memory object");
match device.map_memory(&raw, 0..chunk_size) {
match device.map_memory(
&raw,
gfx_hal::memory::Segment {
offset: 0,
size: Some(chunk_size),
},
) {
Ok(mapping) => Some(NonNull::new_unchecked(mapping)),
Err(gfx_hal::device::MapError::OutOfMemory(error)) => {
device.free_memory(raw);
Expand Down
8 changes: 7 additions & 1 deletion memory/src/allocator/linear.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,13 @@ where
let (memory, ptr) = unsafe {
let raw = device.allocate_memory(self.memory_type, self.linear_size)?;

let ptr = match device.map_memory(&raw, 0..self.linear_size) {
let ptr = match device.map_memory(
&raw,
gfx_hal::memory::Segment {
offset: 0,
size: Some(self.linear_size),
},
) {
Ok(ptr) => NonNull::new_unchecked(ptr),
Err(gfx_hal::device::MapError::OutOfMemory(error)) => {
device.free_memory(raw);
Expand Down
16 changes: 14 additions & 2 deletions memory/src/mapping/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,13 @@ where
self.mapping_range.clone(),
aligned_sub_range.clone()
));
device.invalidate_mapped_memory_ranges(Some((self.memory.raw(), aligned_sub_range)))?;
device.invalidate_mapped_memory_ranges(Some((
self.memory.raw(),
gfx_hal::memory::Segment {
offset: aligned_sub_range.start,
size: Some(aligned_sub_range.end - aligned_sub_range.start),
},
)))?;
}

let slice = mapped_slice::<T>(ptr, size);
Expand Down Expand Up @@ -231,7 +237,13 @@ where
));
Some(move || {
device
.flush_mapped_memory_ranges(Some((memory.raw(), aligned_sub_range)))
.flush_mapped_memory_ranges(Some((
memory.raw(),
gfx_hal::memory::Segment {
offset: aligned_sub_range.start,
size: Some(aligned_sub_range.end - aligned_sub_range.start),
},
)))
.expect("Should flush successfully");
})
} else {
Expand Down
13 changes: 8 additions & 5 deletions rendy/examples/meshes/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use {
graph::{render::*, GraphBuilder, GraphContext, NodeBuffer, NodeImage},
hal::{self, adapter::PhysicalDevice as _, device::Device as _},
init::winit::{
dpi::Size as DpiSize,
event::{Event, WindowEvent},
event_loop::{ControlFlow, EventLoop},
window::WindowBuilder,
Expand Down Expand Up @@ -230,8 +231,10 @@ where
array_offset: 0,
descriptors: Some(hal::pso::Descriptor::Buffer(
buffer.raw(),
Some(uniform_offset(index, align))
..Some(uniform_offset(index, align) + UNIFORM_SIZE),
hal::buffer::SubRange {
offset: uniform_offset(index, align),
size: Some(UNIFORM_SIZE),
},
)),
}));
sets.push(set);
Expand Down Expand Up @@ -369,7 +372,7 @@ fn main() {

let event_loop = EventLoop::new();
let window = WindowBuilder::new()
.with_inner_size((960, 640).into())
.with_inner_size(DpiSize::Logical((960, 640).into()))
.with_title("Rendy example");

let config: Config = Default::default();
Expand All @@ -379,7 +382,7 @@ fn main() {

let mut graph_builder = GraphBuilder::<_, Scene<_>>::new();

let size = window.inner_size().to_physical(window.hidpi_factor());
let size = window.inner_size();
let window_kind = hal::image::Kind::D2(size.width as u32, size.height as u32, 1, 1);
let aspect = size.width / size.height;

Expand Down Expand Up @@ -500,7 +503,7 @@ fn main() {
WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit,
_ => {}
},
Event::EventsCleared => {
Event::MainEventsCleared => {
factory.maintain(&mut families);
if let Some(ref mut graph) = graph {
graph.run(&mut factory, &mut families, &scene);
Expand Down
Loading