[Fixed] Vulkan forces mipmapping on resized console fonts

Bugs that have been investigated and resolved somehow.

Moderator: GZDoom Developers

Vulkan forces mipmapping on resized console fonts

Postby Rachael » Fri Apr 12, 2019 2:47 pm


(Click to enlarge the image)

The screenshot is of the console font when using Normal3x scaling in the game. The work-around is to disable scaling for fonts, but then this affects the menu, as well, in nearly unpredictable ways.
User avatar
Rachael
Webmaster
 
Joined: 13 Jan 2004
Discord: Rachael#3767
Twitch ID: madamerachelle
Github ID: madame-rachelle

Re: Disable applying texture resize to console font

Postby Graf Zahl » Fri Apr 12, 2019 3:01 pm

What did you do to make it look that bad? For me the font looks really nice with upscaling on
User avatar
Graf Zahl
Lead GZDoom Developer
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Disable applying texture resize to console font

Postby Rachael » Fri Apr 12, 2019 3:32 pm

It seems like this might only happen with Vulkan. The sizes, at least for my setup, that causes issues is 3x, 5x, and 6x.
User avatar
Rachael
Webmaster
 
Joined: 13 Jan 2004
Discord: Rachael#3767
Twitch ID: madamerachelle
Github ID: madame-rachelle

Re: Disable applying texture resize to console font

Postby Graf Zahl » Fri Apr 12, 2019 4:11 pm

It may be because Vulkan unconditionally creates mipmaps and this font doesn't like that. The problem here seems to be that these sizes are not powers of two so that it renders some trilinearly filtered version of the character. For fonts, mipmapping should be disabled, especially for these factors.
User avatar
Graf Zahl
Lead GZDoom Developer
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Disable applying texture resize to console font

Postby _mental_ » Sat May 18, 2019 7:17 am

Here is my attempt to fix it.

However, I'm not quite sure that the given condition should be applied to VulkanSampler objects.
Clamp mode can be passed to VkHardwareTexture as well.
_mental_
 
 
 
Joined: 07 Aug 2011

Re: Disable applying texture resize to console font

Postby dpJudas » Sat May 18, 2019 10:12 am

Hopefully Graf knows the answer to this one. What does the OpenGL backend do here?
dpJudas
 
 
 
Joined: 28 May 2016

Re: Disable applying texture resize to console font

Postby _mental_ » Sat May 18, 2019 10:29 am

OpenGL backend passes clamp mode to hardware texture, and decision about mipmap generation is made there. I thought Vulkan is different in this regard.
_mental_
 
 
 
Joined: 07 Aug 2011

Re: Disable applying texture resize to console font

Postby dpJudas » Sat May 18, 2019 10:58 am

There's two possible ways mipmapping can be disabled (for both backends).

Either the texture can be generated with no mipmaps to begin with. In this case the current vulkan samplers will suffice because their mipmap sampling rules say they clamp to the available mipmap levels. This is different from OpenGL where the sampling rules say if mipmap sampling is enabled and it doesn't have mipmaps then it must behave like sampling from a white texture.

Or the texture is generated with mipmaps always and it is the selected sampler that chooses not to use it. In this case the vulkan backend will have to create a descriptor set with a sampler with no mipmapping. My general understanding of the hwrenderer level isn't strong enough to say if the mipmap rule applies to a full set of clamp modes. If it does, then your PR is correct. If not, then logic for picking a different sampler needs to be handled in VkHardwareTexture::GetDescriptorSet.

If the texture shouldn't have mipmaps to begin with, then that decision is handled in VkHardwareTexture::CreateTexture. The third parameter to imgbuilder.setSize and the call to mImage.GenerateMipmaps needs to be made conditional in that case.
dpJudas
 
 
 
Joined: 28 May 2016

Re: Disable applying texture resize to console font

Postby Graf Zahl » Sat May 18, 2019 11:09 am

TBH, I think the 3x, 5x and 6x scaling modes should be disabled because they tend to generate very shitty lower mipmap levels, i.e. they first do an upscale of the texture and then a downscale with a different factor. That will inevitably create bad looking textures where small detail is involved.
User avatar
Graf Zahl
Lead GZDoom Developer
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Disable applying texture resize to console font

Postby _mental_ » Sat May 18, 2019 11:13 am

I was using 3x and 5x with old xBRZ for a while. Textures were pretty good to me, so I disagree with you here.
_mental_
 
 
 
Joined: 07 Aug 2011

Re: Disable applying texture resize to console font

Postby Graf Zahl » Sat May 18, 2019 11:31 am

Read my last 5 words. With normal textures it won't be so obvious but it kills the fonts.
User avatar
Graf Zahl
Lead GZDoom Developer
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Disable applying texture resize to console font

Postby Rachael » Sat May 18, 2019 1:02 pm

Honestly I believe that's a bit overkill and perhaps too constricting for the end-user for a simple problem like this. It's like using a hammer to kill a mosquito on your grandma's shoulder - sure, you'll get the mosquito, but imagine how your grandma feels afterward... this is not a very practical solution.
User avatar
Rachael
Webmaster
 
Joined: 13 Jan 2004
Discord: Rachael#3767
Twitch ID: madamerachelle
Github ID: madame-rachelle

Re: Disable applying texture resize to console font

Postby Graf Zahl » Sat May 18, 2019 1:29 pm

I'll never understand what the obsession with those scaling modes is. 5x and 6x barely give an advantage, for any normal use 4x with texture filtering is enough. The same is true for 3x, it barely makes a difference to 2x or 4x. Fact is that those odd factors have a degrading effect on the mipmaps which isn't present in 2x and 4x which makes these look better in most cases than the supposedly higher ones - except for extreme closeups.
User avatar
Graf Zahl
Lead GZDoom Developer
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Disable applying texture resize to console font

Postby _mental_ » Sat May 18, 2019 2:11 pm

Mipmaps are not created for font textures because of their clamping mode. This works correctly in OpenGL backend but not in Vulkan one.
In fact, this topic should be moved to Vulkan render bugs with its title changed accordingly.
No need to remove any scaling factors. Let’s fix ignored clamping mode in Vulkan backend.
I think my PR is wrong. We need to pass clamp value to VkHardwareTexture like in OpenGL backend.
_mental_
 
 
 
Joined: 07 Aug 2011

Re: Disable applying texture resize to console font

Postby Rachael » Sat May 18, 2019 2:33 pm

_mental_ wrote:In fact, this topic should be moved to Vulkan render bugs with its title changed accordingly.

Done.
User avatar
Rachael
Webmaster
 
Joined: 13 Jan 2004
Discord: Rachael#3767
Twitch ID: madamerachelle
Github ID: madame-rachelle

Next

Return to Closed Bugs

Who is online

Users browsing this forum: No registered users and 2 guests