Skip to content

Commit

Permalink
Revert "Fixes amethyst#58 + minor fixes"
Browse files Browse the repository at this point in the history
This reverts commit 1a23b74.
  • Loading branch information
jaynus committed Sep 30, 2019
1 parent 90ea766 commit 50aa6b1
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 32 deletions.
39 changes: 12 additions & 27 deletions factory/src/factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,24 +398,16 @@ where
&self,
buffer: &mut Buffer<B>,
offset: u64,
content: &T,
) -> Result<(), MapError>
where
T: ?Sized + 'static,
{
let content_size = std::mem::size_of_val(content);

content: &[T],
) -> Result<(), MapError> {
let content = std::slice::from_raw_parts(
{
let content_ptr: *const T = content;
content_ptr as *const u8
},
content_size,
content.as_ptr() as *const u8,
content.len() * std::mem::size_of::<T>(),
);

let mut mapped = buffer.map(&self.device, offset..offset + content_size as u64)?;
let mut mapped = buffer.map(&self.device, offset..offset + content.len() as u64)?;
mapped
.write(&self.device, 0..content_size as u64)?
.write(&self.device, 0..content.len() as u64)?
.write(content);
Ok(())
}
Expand Down Expand Up @@ -445,17 +437,13 @@ where
&self,
buffer: &Buffer<B>,
offset: u64,
content: &T,
content: &[T],
last: Option<BufferState>,
next: BufferState,
) -> Result<(), UploadError>
where
T: ?Sized + 'static,
{
) -> Result<(), UploadError> {
assert!(buffer.info().usage.contains(buffer::Usage::TRANSFER_DST));

let content_size = std::mem::size_of_val(content) as u64;

let content_size = content.len() as u64 * std::mem::size_of::<T>() as u64;
let mut staging = self
.create_buffer(
BufferInfo {
Expand Down Expand Up @@ -556,20 +544,17 @@ where
image_layers: SubresourceLayers,
image_offset: image::Offset,
image_extent: Extent,
content: &T,
content: &[T],
last: impl Into<ImageStateOrLayout>,
next: ImageState,
) -> Result<(), UploadError>
where
T: ?Sized + 'static,
{
) -> Result<(), UploadError> {
assert!(image.info().usage.contains(image::Usage::TRANSFER_DST));
assert_eq!(image.format().surface_desc().aspects, image_layers.aspects);
assert!(image_layers.layers.start <= image_layers.layers.end);
assert!(image_layers.layers.end <= image.kind().num_layers());
assert!(image_layers.level <= image.info().levels);

let content_size = std::mem::size_of_val(content) as u64;
let content_size = content.len() as u64 * std::mem::size_of::<T>() as u64;
let format_desc = image.format().surface_desc();
let texels_count = (image_extent.width / format_desc.dim.0 as u32) as u64
* (image_extent.height / format_desc.dim.1 as u32) as u64
Expand Down
2 changes: 1 addition & 1 deletion mesh/src/mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ impl<'a> MeshBuilder<'a> {
factory.upload_buffer(
&mut buffer,
0,
&**indices,
&indices,
None,
BufferState::new(queue)
.with_access(gfx_hal::buffer::Access::INDEX_BUFFER_READ)
Expand Down
6 changes: 3 additions & 3 deletions rendy/examples/quads/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ where
.upload_buffer(
posvelbuff,
0,
&POSVEL_DATA[..],
&POSVEL_DATA,
None,
BufferState {
queue: QueueId {
Expand Down Expand Up @@ -582,7 +582,7 @@ fn run(
WindowEvent::Resized(_dims) => {
let started = std::time::Instant::now();
graph.take().unwrap().dispose(&mut factory, &());
log::trace!("Graph disposed in: {:?}", started.elapsed());
println!("Graph disposed in: {:?}", started.elapsed());
graph = Some(build_graph(&mut factory, &mut families, &window));
}
_ => {}
Expand Down Expand Up @@ -691,7 +691,7 @@ fn build_graph(

let started = std::time::Instant::now();
let graph = graph_builder.build(factory, families, &()).unwrap();
log::trace!("Graph built in: {:?}", started.elapsed());
println!("Graph built in: {:?}", started.elapsed());
graph
}

Expand Down
2 changes: 1 addition & 1 deletion rendy/examples/source_shaders/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ fn run(
#[cfg(any(feature = "dx12", feature = "metal", feature = "vulkan"))]
fn main() {
env_logger::Builder::from_default_env()
.filter_module("source_shaders", log::LevelFilter::Trace)
.filter_module("triangle", log::LevelFilter::Trace)
.init();

let config: Config = Default::default();
Expand Down

0 comments on commit 50aa6b1

Please sign in to comment.