Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign up[WIP] Implement texture staging #1202
Conversation
kvark
added
the
status: working
label
Mar 4, 2017
Bastacyclop
reviewed
Mar 4, 2017
| fn on_resize(&mut self, window_targets: gfx_app::WindowTargets<R>) { | ||
| fn on_resize_ext<F: gfx::Factory<R>>(&mut self, | ||
| factory: &mut F, | ||
| window_targets: gfx_app::WindowTargets<R>) { |
This comment has been minimized.
This comment has been minimized.
Bastacyclop
Mar 4, 2017
Author
Member
That's hacky but it's currently hard to get a hold on the factory with gfx_app
Bastacyclop
reviewed
Mar 4, 2017
| @@ -189,7 +188,7 @@ pub fn create_main_targets_raw(dim: texture::Dimensions, color_format: format::S | |||
| levels: 1, | |||
| kind: texture::Kind::D2(dim.0, dim.1, dim.3), | |||
| format: color_format, | |||
| bind: RENDER_TARGET, | |||
| bind: memory::RENDER_TARGET | memory::TRANSFER_SRC, | |||
This comment has been minimized.
This comment has been minimized.
kvark
approved these changes
Mar 7, 2017
|
Looks great, minus a few nits. |
| @@ -59,8 +62,20 @@ impl Vertex { | |||
| } | |||
|
|
|||
| //---------------------------------------- | |||
|
|
|||
| type DataType = <<ColorFormat as Formatted>::Surface as SurfaceTyped>::DataType; | |||
This comment has been minimized.
This comment has been minimized.
kvark
Mar 7, 2017
Member
while it is technically correct, it's still an overkill for the examples. I think using [u8; 4] is fine
| self.download.raw(), | ||
| 0 | ||
| ).unwrap(); | ||
| println!("screenshot taken"); |
This comment has been minimized.
This comment has been minimized.
| let reader = factory.read_mapping(&self.download).unwrap(); | ||
| let mut data = Vec::with_capacity(w as usize * h as usize * 4); | ||
| for l in reader.chunks(w as usize).rev() { | ||
| for &v in l { |
This comment has been minimized.
This comment has been minimized.
| data.push(v[2]); | ||
| } | ||
| } | ||
| let path = "screen.png"; |
This comment has been minimized.
This comment has been minimized.
|
|
||
| // In this example the transform is static except for window resizes. | ||
| let proj = cgmath::perspective(cgmath::deg(45.0f32), window_targets.aspect_ratio, 1.0, 10.0); | ||
| self.bundle.data.transform = (proj * default_view().mat).into(); | ||
| } | ||
|
|
||
| fn on(&mut self, event: winit::Event) { | ||
| use winit::Event::*; |
This comment has been minimized.
This comment has been minimized.
kvark
Mar 7, 2017
Member
nit: lets not do * and instead just do use winit::{Event, ElementState, VirtualKeyCode as Key};
| @@ -100,6 +100,16 @@ pub enum Command { | |||
| CopyBuffer(Buffer, Buffer, | |||
| gl::types::GLintptr, gl::types::GLintptr, | |||
| gl::types::GLsizeiptr), | |||
| CopyBufferToTexture(Buffer, gl::types::GLintptr, | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@kvark So you want to keep the cube example screenshot thing ? I did it for testing but I didn't think we would keep it (with the screenshot being saved upon resize :s). |
This comment has been minimized.
This comment has been minimized.
|
@Bastacyclop to be honest, I think another example (like the |
Bastacyclop
added some commits
Mar 3, 2017
Bastacyclop
force-pushed the
Bastacyclop:textage
branch
from
75db505
to
e77a4e5
Mar 8, 2017
This comment has been minimized.
This comment has been minimized.
|
@kvark I think it's ready to be merged, we only tested framebuffer download. |
This comment has been minimized.
This comment has been minimized.
|
Thanks @Bastacyclop ! |
Bastacyclop commentedMar 4, 2017
Implements texture staging by providing
copy_buffer_to_textureandcopy_texture_to_buffermethods.Would close #1181
@kvark: @Androcas and me will move on to the D3D11 implementation if you like the OpenGL one, I'm not sure if we want to add another example for staging or modify an existing one?