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

Use default samplers in base uniform set when rendering to reflection probes #84317

Merged
merged 1 commit into from
Nov 8, 2023

Conversation

clayjohn
Copy link
Member

@clayjohn clayjohn commented Nov 1, 2023

Fixes: #83962

The RenderBuffers used by ReflectionProbes doesn't create and maintain its own set of samplers. So basically what was happening was the Viewport RenderBuffers were invalidating the base_uniform_set (so it would get recreated with the new samplers). But then the ReflectionProbes would get rendered, and they don't have valid samplers, so they would give invalid samplers and the base_uniform_set would be null. Then rendering would fail for a frame. The Viewport would then get rendered and update the base_uniform_set to be valid. Then, in subsequent frames, the ReflectionProbes would just use the updated base_uniform_set.

This PR works, but I think it will bring us back to the state where the sampler gets ignored when changed (due to how the caching works). I need to do a bit more testing before this is ready.

@clayjohn
Copy link
Member Author

clayjohn commented Nov 1, 2023

It seems that we are going to need to implement a base_uniform_set cache. Right now the first Viewport to set a base_uniform set wins and its settings are used for everything else.

@clayjohn
Copy link
Member Author

clayjohn commented Nov 7, 2023

This iteration fixes #83962 and an unreported bug whereby the wrong bias is used.

However, there is still an existing unreported bug (#84083) that will require more invasive changes. Right now we maintain a render_base_uniform_set which should only hold data that doesn't change between draw calls. However, since we made the samplers change per viewport/render type, that assumption no longer holds true. render_base_uniform_set can change depending on the type of rendering going on (shadows, probes, scene draw) and per viewport.

This PR splits render_base_uniform_set into two, one for viewports (where bias is not default) and one for everything else (where bias is always default). This fixes the most obvious bug, but it will stop working if multiple viewports are used in a scene and the Viewports do not all have the same bias setting.

A perfect solution would be one where we either store the samplers in another location (one that is updated more frequently), or we store the render_base_uniform_set on a per-viewport basis with a default implementation for non-viewport rendering. That, however, would be a much more invasive change than this, so it might be best to hold that off for 4.3

@clayjohn clayjohn marked this pull request as ready for review November 7, 2023 15:25
@clayjohn clayjohn requested review from a team as code owners November 7, 2023 15:25
@Calinou
Copy link
Member

Calinou commented Nov 7, 2023

This iteration fixes #83962 and an unreported bug whereby the wrong bias is used.

Judging by your description, this may also fix #65690 🙂 I'll give it a try.
Edit: I tested the MRP linked in that issue, and this PR doesn't appear to fix that issue.

This fixes the most obvious bug, but it will stop working if multiple viewports are used in a scene and the Viewports do not all have the same bias setting.

I assume this is connected to #84083.

Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally, it works as expected.

@clayjohn
Copy link
Member Author

clayjohn commented Nov 7, 2023

This iteration fixes #83962 and an unreported bug whereby the wrong bias is used.

Judging by your description, this may also fix #65690 🙂 I'll give it a try. Edit: This PR doesn't appear to fix that issue.

That's a different issue, ya.

This fixes the most obvious bug, but it will stop working if multiple viewports are used in a scene and the Viewports do not all have the same bias setting.

I assume this is connected to #84083.

That's right. I hadn't seen #84083 before. It is exactly what I was describing

@akien-mga akien-mga merged commit 7efe2e3 into godotengine:master Nov 8, 2023
15 checks passed
@akien-mga
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Vulkan: reflection probe rendering breaks when window gets resized or is maximized
3 participants