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

Skip 2D rendering if stereo enabled and fix couple of MSAA issues #83649

Merged
merged 1 commit into from
Oct 25, 2023

Conversation

BastiaanOlij
Copy link
Contributor

@BastiaanOlij BastiaanOlij commented Oct 19, 2023

Small fix in the viewport logic, when we enable stereoscopic rendering we can't render 2D elements as these lack depth information.

The assumption up till now was that users simply wouldn't add 2D elements to the scene but this has lead to a couple of issues:

  • 2D elements could be part of a mixed environment where a UI was presented to the user on screen but not in HMD
  • even without 2D elements part of the 2D pipeline still ran and could result in empty render passes.

This fix ensures that 2D is disabled when stereoscopic rendering is applied to a viewport.

Note, it isn't enough to check use_xr, for phone AR (ARKit/ARCore) 2D elements can be used.

edit In testing this fix I ran into issues with MSAA2D which had to be dealt with, that threw me down a rabbit hole that ended up fixing a number of MSAA related issues.

second edit turned out when introducing FSR2 we lost some the logic that turns scaling off when scaling is set to 1.0 and introduce overhead both when FSR1 was set or when running on the mobile renderer.
Added a change that re-instates the old logic, but leaves the option to set scaling to 1.0 with FSR2.

Dumb little test project to test the MSAA settings, run with both Mobile and Forward+ to test:
Test MSAA.zip

@BastiaanOlij BastiaanOlij added enhancement topic:xr topic:2d cherrypick:4.1 Considered for cherry-picking into a future 4.1.x release labels Oct 19, 2023
@BastiaanOlij BastiaanOlij added this to the 4.3 milestone Oct 19, 2023
@BastiaanOlij BastiaanOlij self-assigned this Oct 19, 2023
@BastiaanOlij BastiaanOlij requested a review from a team as a code owner October 19, 2023 23:56
@BastiaanOlij
Copy link
Contributor Author

BastiaanOlij commented Oct 19, 2023

Note didn't want to classify this as a bug but might be worth putting in 4.2 or at least 4.2.1 (and 4.1.3 if we decide to build that).

With the fixes this now introduces, I suggest we merge this as a bugfix.

@BastiaanOlij BastiaanOlij force-pushed the no_2d_stereo branch 2 times, most recently from eb4cdcb to e4cdcc6 Compare October 20, 2023 00:55
@BastiaanOlij BastiaanOlij changed the title Skip 2D rendering if stereo enabled Skip 2D rendering if stereo enabled and fix couple of MSAA issues Oct 20, 2023
bool scaling_3d_is_fsr = (scaling_3d_mode == RS::VIEWPORT_SCALING_3D_MODE_FSR) || (scaling_3d_mode == RS::VIEWPORT_SCALING_3D_MODE_FSR2);
bool use_taa = p_viewport->use_taa;

if (scaling_3d_is_fsr && (scaling_3d_scale > 1.0)) {
if (scaling_3d_is_fsr && (scaling_3d_scale >= (1.0 + EPSILON))) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Requested by @DarioSamo to change this. Not sure if this should be > or >=

@BastiaanOlij BastiaanOlij modified the milestones: 4.3, 4.2 Oct 20, 2023
@fire
Copy link
Member

fire commented Oct 21, 2023

Does this preserve the 2d controls on a 3d plane usecase for vr?

@BastiaanOlij
Copy link
Contributor Author

BastiaanOlij commented Oct 21, 2023

Does this preserve the 2d controls on a 3d plane usecase for vr?

No, this purely stops 2D rendering on the viewport that has use_xr set to true and which have stereoscopic rendering, which never worked consistently to begin with due to 2D content not being aware of multiview.

Rendering 2D content to other viewports which are then displayed on 3D quadmeshes etc. works as before.

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.

Looks mostly fine to me. There were a few changes that I am unsure about as the reason for the change is not obvious. So I left a few comments asking for clarification

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.

Looks fine to me. I am a little wary about the extra copy when using MSAA, but since FSR can only be used on desktop anyway, it isn't a huge deal for now. At some point we will want to return and see if we can't eliminate that copy though.

@BastiaanOlij
Copy link
Contributor Author

Looks fine to me. I am a little wary about the extra copy when using MSAA, but since FSR can only be used on desktop anyway, it isn't a huge deal for now. At some point we will want to return and see if we can't eliminate that copy though.

Agreed, it's a bit of an unlikely scenario but I'm sure there is a way to have FSR output into an MSAA buffer.

@akien-mga akien-mga merged commit 4cc8f0f into godotengine:master Oct 25, 2023
@akien-mga
Copy link
Member

Thanks!

@YuriSizov
Copy link
Contributor

Looks like this change led to some regressions and potentially uncovered other issues. I'd avoid cherry-picking it based on this, especially given that it's not clear how critical the fixes are for 4.1 and if we may find more issues in future. I'll remove the label, but if the rendering team still wants this, keep in mind that we also need to pick #84267.

@YuriSizov YuriSizov removed the cherrypick:4.1 Considered for cherry-picking into a future 4.1.x release label Jan 23, 2024
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.

5 participants