Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to default PartialEq implementation for RenderResourceBinding #877

Merged
merged 2 commits into from
Nov 21, 2020

Conversation

mvlabat
Copy link
Contributor

@mvlabat mvlabat commented Nov 16, 2020

This should fix #858.

I'm a noob in rendering, but I assumed that changing the dynamic index of a binding should invalidate it. It works (in my example I can see materials changed), though I'm not sure about the performance implications of this. I guess excluding dynamic index from PartialEq implementation was done on purpose. Probably there's a better way to solve the issue.

@cart
Copy link
Member

cart commented Nov 17, 2020

Yeah I'm pretty sure this solves #858, but I'm also worried about performance. We don't want to "rebind" the dynamic uniform buffer when there is a different uniform index / create a new bind group for each buffer/index combo.

@memoryruins memoryruins added the A-Rendering Drawing game state to the screen label Nov 17, 2020
@mvlabat
Copy link
Contributor Author

mvlabat commented Nov 17, 2020

@cart, yeah, understood. I'm trying to come up with a better fix, but my knowledge is really limiting me here. Could you give me a hint what code should I take a look at?

@cart
Copy link
Member

cart commented Nov 18, 2020

Alrighty I've given this some thought and I think I found the "right" solution. Its basically:

  1. Move to the default "derive" impls, just like you already did in this pr (which I just verified does solve Changing a material handle doesn't affect how an entity is rendered #858)
  2. Add a new function to BindGroupBuilder called "hash_binding(&mut self, binding: &RenderResourceBinding)" and copy the "old" hash implementation there.

That way the normal impl behaves as expected and we move the "special case" logic to the place that needs it.

@cart
Copy link
Member

cart commented Nov 18, 2020

@cart
Copy link
Member

cart commented Nov 18, 2020

I guess specifically we would replace this line with our new "hash_binding" function:

@mvlabat
Copy link
Contributor Author

mvlabat commented Nov 18, 2020

Alright, this should work. I also removed the default Hash implementation for RenderResourceBinding, since it doesn't seem to be used anywhere else.

@cart cart merged commit d11be43 into bevyengine:master Nov 21, 2020
@mvlabat mvlabat deleted the fix-material-handles branch August 24, 2021 21:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Changing a material handle doesn't affect how an entity is rendered
3 participants