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

[no sq] Texture/rendering fixes and improvements #15398

Merged
merged 5 commits into from
Nov 16, 2024
Merged

Conversation

sfan5
Copy link
Collaborator

@sfan5 sfan5 commented Nov 8, 2024

followup to #15396

context for commit 2 is here:

Another great trick at the cost of some performance is to use a higher precision depth buffer. Most depth buffers have a precision of 24 bits, but most GPUs nowadays support 32 bit depth buffers, increasing the precision by a significant amount. So at the cost of some performance you'll get much more precision with depth testing, reducing z-fighting.

To do

This PR is Ready for Review.

How to test

first commit:

  • apply
diff --git a/src/irrlicht_changes/CGUITTFont.h b/src/irrlicht_changes/CGUITTFont.h
--- a/src/irrlicht_changes/CGUITTFont.h
+++ b/src/irrlicht_changes/CGUITTFont.h
@@ -143,7 +143,7 @@ namespace gui
 				bool flgmip = driver->getTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS);
 				driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false);
 				bool flgcpy = driver->getTextureCreationFlag(video::ETCF_ALLOW_MEMORY_COPY);
-				driver->setTextureCreationFlag(video::ETCF_ALLOW_MEMORY_COPY, true);
+				driver->setTextureCreationFlag(video::ETCF_ALLOW_MEMORY_COPY, false);
 
 				// Set the texture color format.
 				switch (pixel_mode)
@@ -176,6 +176,8 @@ namespace gui
 			{
 				if (!dirty) return;
 
+				fprintf(stderr, "updating glyph texture\n");
+
 				void* ptr = texture->lock();
 				video::ECOLOR_FORMAT format = texture->getColorFormat();
 				core::dimension2du size = texture->getOriginalSize();
  • ensure that "updating glyph texture" shows up and that the font rendering works fine

other commits:
check that everything still works, in particular:

  • sun/moon tonemapping
  • minimap
  • dynamic shadows

@sfan5 sfan5 added Performance Bugfix 🐛 PRs that fix a bug @ Client rendering Waiting (on dependency) Waiting on another PR or external circumstances (not for rebases/changes requested) and removed Waiting (on dependency) Waiting on another PR or external circumstances (not for rebases/changes requested) labels Nov 8, 2024
Copy link
Member

@grorp grorp left a comment

Choose a reason for hiding this comment

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

For the texture downloading code, tested with Sharpnet texture pack (because it has a sun_tonemap.png)

video_driver = ogles2

  • works on "master" (ETCF_ALLOW_MEMORY_COPY true)

  • broken on "master" with ETCF_ALLOW_MEMORY_COPY false

    nicebroken.mp4

    (perhaps epilepsy warning or something)

  • works on this PR (also ETCF_ALLOW_MEMORY_COPY false)

works 👍

depth_format = video::ECF_D32;
auto depth_format = video::ECF_D16;
if (driver->queryTextureFormat(video::ECF_D24))
depth_format = video::ECF_D24;
Copy link
Member

Choose a reason for hiding this comment

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

For preferring a 24-bit depth buffer over a 32-bit buffer:

  • Do you have data how much it improves performance / have you observed a performance improvement?

  • Looking through the issue tracker, it seems there have been some issues with z-fighting in the past. Have you tested this to make sure there are no new problems?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have done no testing beyond checking that world rendering generally works. No performance data either.
This is all just going off "24-bit seems to be the default in GL so that should be enough for us".

If x2048 was still here we could ask him why he preferred a 32-bit depth buffer but 🤷

Looking through the issue tracker, it seems there have been some issues with z-fighting in the past

links please

Copy link
Member

@grorp grorp Nov 11, 2024

Choose a reason for hiding this comment

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

OK, looking into this further, the non-post-processing version of the pipeline has always used a 24-bit depth buffer, so this should be fine.

I don't see a noteworthy performance improvement on my phone, but I do see a noteworthy performance improvement when removing the ECF_A16B16G16R16F branch so it uses ECF_A8R8G8B8 instead. The data I collected is not of very high quality though.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

thx for testing

I do see a noteworthy performance improvement when removing the ECF_A16B16G16R16F branch so it uses ECF_A8R8G8B8 instead

OpenGL has a 10-bit color format and I have wondered before if we should maybe try using it, in case it's faster than 16-bit.
Not exactly sure what the higher precision is for anyway. It might be so bloom, tonemapping and light effects can work correctly? (see: HDR in video)

@sfan5 sfan5 added the Action / change needed Code still needs changes (PR) / more information requested (Issues) label Nov 11, 2024
@sfan5 sfan5 removed the Action / change needed Code still needs changes (PR) / more information requested (Issues) label Nov 12, 2024
@sfan5 sfan5 added the Rebase needed The PR needs to be rebased by its author label Nov 15, 2024
@sfan5 sfan5 removed the Rebase needed The PR needs to be rebased by its author label Nov 15, 2024
@sfan5 sfan5 merged commit 8d2e770 into luanti-org:master Nov 16, 2024
16 checks passed
@sfan5 sfan5 deleted the gfx2 branch November 16, 2024 15:54
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.

2 participants