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

Fix voxel GI issues #76437

Merged
merged 2 commits into from
Apr 27, 2023
Merged

Conversation

RandomShaper
Copy link
Member

@RandomShaper RandomShaper commented Apr 25, 2023

UPDATE: To avoid multiple 'update' notices throughout, just know that the full text has been revised after enhancing the fixes.


Changes kept in two commits because, even if related, they address different issues:

*:

drivers\vulkan\vulkan_context.cpp:267 - VALIDATION - Message Id Number: 188609398 | Message Id Name: VUID-vkCmdDispatch-magFilter-04553
Validation Error: [ VUID-vkCmdDispatch-magFilter-04553 ] Object 0: handle = 0x8f7057000000562c, name = RID:505478996034037, type = VK_OBJECT_TYPE_DESCRIPTOR_SET; Object 1: handle = 0xa182620000000079, name = RID:163208757251, type = VK_OBJECT_TYPE_SAMPLER; Object 2: handle = 0xf325e500000055e3, name = RenderBuffer forward_clustered/voxel_gi View, type = VK_OBJECT_TYPE_IMAGE_VIEW; | MessageID = 0xb3df376 | Descriptor set VkDescriptorSet 0x8f7057000000562c[RID:505478996034037] encountered the following validation error at vkCmdDispatch time: Sampler (VkSampler 0xa182620000000079[RID:163208757251]) is set to use VK_FILTER_LINEAR with compareEnable is set to VK_FALSE, but image view's (VkImageView 0xf325e500000055e3[RenderBuffer forward_clustered/voxel_gi View]) format (VK_FORMAT_R8G8_UINT) does not contain VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT in its format features. The Vulkan spec states: If a VkSampler created with magFilter or minFilter equal to VK_FILTER_LINEAR and compareEnable equal to VK_FALSE is used to sample a VkImageView as a result of this command, then the image view's format features must contain VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT (https://vulkan.lunarg.com/doc/view/1.3.216.0/windows/1.3-extensions/vkspec.html#VUID-vkCmdDispatch-magFilter-04553)
	Objects - 3
		Object[0] - VK_OBJECT_TYPE_DESCRIPTOR_SET, Handle -8110887271382624724, Name "RID:505478996034037"
		Object[1] - VK_OBJECT_TYPE_SAMPLER, Handle -6808771934491246471, Name "RID:163208757251"
		Object[2] - VK_OBJECT_TYPE_IMAGE_VIEW, Handle -926082360191986205, Name "RenderBuffer forward_clustered/voxel_gi View"

@@ -3493,6 +3493,9 @@ void GI::init(SkyRD *p_sky) {
if (RendererSceneRenderRD::get_singleton()->is_vrs_supported()) {
defines += "\n#define USE_VRS\n";
}
if (!RD::get_singleton()->sampler_is_format_supported_for_filter(RD::DATA_FORMAT_R8G8_UINT, RD::SAMPLER_FILTER_LINEAR)) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Specifying the format here feels too hard-coded to my taste, but I couldn't find a way of querying the format of the actual texture. This is not the end of the world, but has a risk of getting out of sync with the code that creates the texture.

@Calinou
Copy link
Member

Calinou commented Apr 25, 2023

Fixes a validation error about an R8G8 texture being sampled linearly when the drivers reports no support for that. Besides the validation error, without the appropriate fallback to nearest, when looking at the scene from certain angles, the volumetric fog starts flooding the whole viewport with white in a few frames and there's no way back other than resizing the viewport.

Does this fix #76243? I thought it was due to compiler optimization levels but that may have been a fluke.

@RandomShaper
Copy link
Member Author

Does this fix #76243? I thought it was due to compiler optimization levels but that may have been a fluke.

Oh, that's exactly what one of the commits addresses! Not completely sure if its the same root cause or it's instead a different bug that looks like the same. I'm being optimistic and choosing to believe it's the same, and so updating the PR description.

@RandomShaper
Copy link
Member Author

Hmm... I've been able to reproduce the fog glitch once. I'll investigate a bit more before concluding this PR doesn't fix it.

@RandomShaper
Copy link
Member Author

I think I've found the glitched fog issue! Will finish updating the PR tomorrow. Tagging as Needs work.

@RandomShaper RandomShaper requested review from a team as code owners April 26, 2023 08:19
@RandomShaper RandomShaper removed the request for review from a team April 26, 2023 08:23
@RandomShaper RandomShaper removed request for a team April 26, 2023 08:23
@RandomShaper
Copy link
Member Author

OK. I finally think this is good for reviewing. And fixes the flood-of-white-or-black fog issue! I've overhauled the PR description.

@@ -3695,14 +3698,16 @@ void GI::setup_voxel_gi_instances(RenderDataRD *p_render_data, Ref<RenderSceneBu
if (p_render_buffers->has_custom_data(RB_SCOPE_FOG)) {
Copy link
Member Author

@RandomShaper RandomShaper Apr 26, 2023

Choose a reason for hiding this comment

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

I think this block of checks would belong better to just before using the uniform sets. They will be invalid by that time because of deletion of dependencies, so doing the check there is to me more correct. The idea would be being reactive to what actually happened instead of being proactive in guessing what may have happened. That, of course, without detriment of being proactive as an optimization in cases where that can save some checks (a bit like this PR does by assuming the whole group of sets is either valid or invalid).

In any case, this is a suggestion to the rendering maintainers. I didn't want to attempt something like that in this PR, which would broaden its scope needlessly.

Copy link
Member

Choose a reason for hiding this comment

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

That makes sense. There isn't much of a reason to be caching this so early

@RandomShaper
Copy link
Member Author

For the records, I've still seen the floody fog glitch once even with this changes, in the D3D12 renderer. But I believe this PR fixes it like 99% since without it I've been able to reproduce the issue consistently if I force voxel_instances_changed = true always.

Copy link
Member

@clayjohn clayjohn left a comment

Choose a reason for hiding this comment

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

This looks good as a minimalistic approach to fixing the issues. Indeed clearing those uniform sets should be moved out of the gi_setup code as it creates a weird dependency between the two classes.

doc/classes/RenderingDevice.xml Outdated Show resolved Hide resolved
@akien-mga akien-mga merged commit 359b494 into godotengine:master Apr 27, 2023
@akien-mga
Copy link
Member

Thanks!

@akien-mga
Copy link
Member

Cherry-picked for 4.0.3.

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