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 upAdding more caching to GL backend. #1221
Conversation
icefoxen
referenced this pull request
Apr 5, 2017
Closed
Attempts at making the GL backend cache more state #1220
kvark
reviewed
Apr 5, 2017
| } | ||
|
|
||
| fn bind_constant_buffer(&mut self, buf: &mut Vec<Command>, constant_buffer: c::pso::ConstantBufferParam<Resources>) { | ||
| if let Some(cb) = self.constant_buffer { |
This comment has been minimized.
This comment has been minimized.
kvark
Apr 5, 2017
Member
nit: could be simplified to if self.constant_buffer == Some(constant_buffer)
if it complains about the type being moved and such, you can compare by reference if self.constant_buffer.as_ref() == Some(&constant_buffer)
| Command::SetScissor(None), | ||
| Command::SetDepthState(None), | ||
| Command::SetStencilState(None, (0, 0), s::CullFace::Nothing), | ||
| Command::SetBlendState(0, COLOR_DEFAULT), | ||
| Command::SetBlendState(1, COLOR_DEFAULT), | ||
| Command::SetBlendState(2, COLOR_DEFAULT), | ||
| Command::SetBlendState(3, COLOR_DEFAULT), | ||
| Command::SetBlendColor([0f32; 4]), | ||
| Command::SetBlendColor([0f32; 4]) |
This comment has been minimized.
This comment has been minimized.
| } | ||
|
|
||
| fn bind_resource_view(&mut self, buf: &mut Vec<Command>, resource_view: c::pso::ResourceViewParam<Resources>) { | ||
| if let Some(rv) = self.resource_view { |
This comment has been minimized.
This comment has been minimized.
| } | ||
|
|
||
| fn bind_framebuffer(&mut self, buf: &mut Vec<Command>, access: Access, fb: FrameBuffer) { | ||
|
|
This comment has been minimized.
This comment has been minimized.
| // That's actually bad because it makes it impossible | ||
| // to completely remove all redundant calls if the | ||
| // stencil is enabled; | ||
| // we'll be re-enabling it over and over. |
This comment has been minimized.
This comment has been minimized.
| (_, None) => (), | ||
| if self.cache.current_vbs == Some(vbs) { | ||
| return | ||
| } else { |
This comment has been minimized.
This comment has been minimized.
| dst_offset_bytes as gl::types::GLintptr, | ||
| size_bytes as gl::types::GLsizeiptr)); | ||
| self.cache.push(&mut self.buf, | ||
| Command::CopyBuffer(src, |
This comment has been minimized.
This comment has been minimized.
| error!("GL: unable to update the contents of a Surface({})", s), | ||
| NewTexture::Texture(t) => { | ||
| self.cache.push(&mut self.buf, | ||
| Command::UpdateTexture(t, kind, face, ptr, img)) |
This comment has been minimized.
This comment has been minimized.
| count: c::VertexCount, | ||
| instances: Option<command::InstanceParams>) { | ||
| self.cache.push(&mut self.buf, | ||
| Command::Draw(self.cache.primitive, start, count, instances)); |
This comment has been minimized.
This comment has been minimized.
| gl_index, RawOffset(offset as *const gl::types::GLvoid), count, base, instances)); | ||
| self.cache | ||
| .push(&mut self.buf, | ||
| Command::DrawIndexed(self.cache.primitive, |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
What is the policy on rustfmt? You don't appear to be using it as far as I can tell, so a lot of the indentation stuff is just emacs's auto-formatting. If there's some specific formatting guide or such I should follow that'd make life easier; I tried to follow the existing style, but only partially succeeded. ;-) |
This comment has been minimized.
This comment has been minimized.
|
@icefoxen I haven't looked into |
This comment has been minimized.
This comment has been minimized.
|
All right. I was more looking for ways to vigorously not reformat everything, since I usually code with rustfmt running automatically every time I save a file and it makes a terrible mess of projects that don't use it. |
This comment has been minimized.
This comment has been minimized.
|
Okay, I think I've fixed all the formatting bugs and simplified where indicated. The only thing I haven't done is gotten rid of I think that ideally every command should be added to the buffer via a method on |
This comment has been minimized.
This comment has been minimized.
|
@icefoxen thanks for updating it!!!
Don't worry about the caller. There is only one, so it doesn't make much sense to try to shove more logic into the Does this sound reasonable? |
This comment has been minimized.
This comment has been minimized.
|
Fair enough! It's hard sometimes, you look at stuff and say "hey, a layer of abstraction could go here!" and why not put one in? This will probably take me a few days to get around to doing, but I'll refactor it so the functions just return an option. |
This comment has been minimized.
This comment has been minimized.
|
Refactor complete; it IS nicer, thank you for the suggestion. |
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.
homu
added a commit
that referenced
this pull request
Apr 19, 2017
This comment has been minimized.
This comment has been minimized.
|
|
kvark
approved these changes
Apr 19, 2017
| @@ -208,7 +208,7 @@ impl Descriptor { | |||
| } | |||
|
|
|||
| /// A complete set of vertex buffers to be used for vertex import in PSO. | |||
| #[derive(Copy, Clone, Debug)] | |||
| #[derive(Copy, Clone, Debug, PartialEq)] | |||
This comment has been minimized.
This comment has been minimized.
kvark
Apr 19, 2017
Member
are these core changes required for your PR?
We need to bump the version numbers and (if core is changed) change the dependency of core to the new version.
This comment has been minimized.
This comment has been minimized.
icefoxen
Apr 19, 2017
Author
Contributor
I'm afraid so because it needs to be able to compare the existing VertexBufferSet against the one it has cached. It can probably be worked around by just storing the contents of the VertexBufferSet, but that seems a little redundant.
This comment has been minimized.
This comment has been minimized.
kvark
Apr 19, 2017
Member
Ok, I see. Please bump both version numbers then and make sure the new core is requested
| } | ||
|
|
||
| fn bind_program(&mut self, program: Program) -> Option<Command> { | ||
| if program == self.program { |
This comment has been minimized.
This comment has been minimized.
kvark
Apr 19, 2017
Member
nit: I think a simple if/else for the case of small branches should be preferred over return
This comment has been minimized.
This comment has been minimized.
|
Ok, we can bump the versions ourselves and do the refactor, if needed. |
This comment has been minimized.
This comment has been minimized.
|
@icefoxen your code has sailed in https://crates.io/crates/gfx_device_gl/0.13.1 |
icefoxen commentedApr 5, 2017
Like #1220 except based on the right starting point. Sorry.