Skip to content

use mipmapping when gpu-scaling textures#1330

Open
barbeque-squared wants to merge 1 commit into
masterfrom
mipmap
Open

use mipmapping when gpu-scaling textures#1330
barbeque-squared wants to merge 1 commit into
masterfrom
mipmap

Conversation

@barbeque-squared

Copy link
Copy Markdown
Member

I knew there was something missing from #1165. I knew the cover images on my local builds weren't that blocky, but pardon me not finding that particular needle in an almost-6000 line diff haystack on the first try. note that these are pretty bad examples as these covers are actually quite large, it looks much better on 1080p (especially the text is much sharper then)

GL_LINEAR (old code)
screenshot0071

GL_LINEAR_MIPMAP_LINEAR (this PR)
screenshot0072

NB: #1213 appears to also also do something to UTexture in a similar regard, but it's more advanced and I don't exactly know what some of the things in there are doing. The best link I can give you is dgruss@66dd909#diff-43d61e4155c65a983e9091e0c5297c03e075a69b6946addbe9bf608222b23061 also screenshotted below, because I don't trust github to keep that working in case of a force-push:
2026-05-29-134840_843x768_scrot

I'm open to integrating the relevant bits into this PR. I don't know if I can blindly call glGenerateMipmaps but I've been running with this for probably over 3 years now.

@dgruss

dgruss commented May 30, 2026

Copy link
Copy Markdown
Contributor

I refactored #1213 so that the changes there are more clearly separated into commits. 1213 is the more complete implementation of the same fix:

  • 1330 only calls glGenerateMipmap, while 1213 also supports glGenerateMipmapEXT. That matters for older GL setups where the extension entry point may be available even if the core function is not.

  • 1330 only changes LoadTexture; 1213 applies the same sampling setup to CreateTexture as well. That keeps file-loaded textures and created/generated textures using the same filtering rules instead of fixing only one texture path.

  • 1330 hardcodes the texture parameters inline; 1213 factors this into ApplyTextureSampling. That avoids having the same GL state setup duplicated and drifting between texture creation paths later.

  • 1213 contains a ton of upscaled textures, because that's where I started from

  • 1213 also contains the small theme/layout fixes needed by the upscaled assets, for example explicit select arrow dimensions and preserving avatar viewport geometry when replacing textures. Without those, some textures render at unintended sizes or change layout behavior because the new source images have different dimensions. The theme was simply not explicit enough so far but implicitly just using the texture's image width and height.

I also adjusted 1213 so it no longer selects GL_LINEAR_MIPMAP_LINEAR if neither glGenerateMipmap nor glGenerateMipmapEXT is available. In that fallback case it keeps GL_LINEAR, so we do not request mipmap sampling without generated mipmaps.

I can split out the upsampling commit out of 1213 or you merge the corresponding mipmap commits here.

@barbeque-squared

Copy link
Copy Markdown
Member Author

1330 only changes LoadTexture; 1213 applies the same sampling setup to CreateTexture as well. That keeps file-loaded textures and created/generated textures using the same filtering rules instead of fixing only one texture path.

Because of course there's two texture paths. And glTexParameteri is also strewn all throughout the code. I'm also not sure if we actually want mipmapping on the second path (CreateTexture) since that appears to be used by (at least) the webcam and I don't know if that comes with performance considerations. Obviously for avatars it would make more sense, but that's probably a result of avatar.db.

I'll probably just park this until at least the worst of the mess has been addressed first, or perhaps we just do the whole OpenGL issue first.

@dgruss

dgruss commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

I removed the upscaled textures from #1213 and excluded the webcam. It's now about 100 loc.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants