Vulkan forces mipmapping on resized console fonts

Bugs that have been investigated and resolved somehow.

Moderator: GZDoom Developers

Forum rules
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.
User avatar
Rachael
Posts: 13542
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her
Contact:

Vulkan forces mipmapping on resized console fonts

Post by Rachael »


(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
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49066
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Disable applying texture resize to console font

Post by Graf Zahl »

What did you do to make it look that bad? For me the font looks really nice with upscaling on
User avatar
Rachael
Posts: 13542
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her
Contact:

Re: Disable applying texture resize to console font

Post by Rachael »

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
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49066
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Disable applying texture resize to console font

Post by Graf Zahl »

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.
_mental_
 
 
Posts: 3812
Joined: Sun Aug 07, 2011 4:32 am

Re: Disable applying texture resize to console font

Post by _mental_ »

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.
dpJudas
 
 
Posts: 3040
Joined: Sat May 28, 2016 1:01 pm

Re: Disable applying texture resize to console font

Post by dpJudas »

Hopefully Graf knows the answer to this one. What does the OpenGL backend do here?
_mental_
 
 
Posts: 3812
Joined: Sun Aug 07, 2011 4:32 am

Re: Disable applying texture resize to console font

Post by _mental_ »

OpenGL backend passes clamp mode to hardware texture, and decision about mipmap generation is made there. I thought Vulkan is different in this regard.
dpJudas
 
 
Posts: 3040
Joined: Sat May 28, 2016 1:01 pm

Re: Disable applying texture resize to console font

Post by dpJudas »

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.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49066
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Disable applying texture resize to console font

Post by Graf Zahl »

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.
_mental_
 
 
Posts: 3812
Joined: Sun Aug 07, 2011 4:32 am

Re: Disable applying texture resize to console font

Post by _mental_ »

I was using 3x and 5x with old xBRZ for a while. Textures were pretty good to me, so I disagree with you here.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49066
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Disable applying texture resize to console font

Post by Graf Zahl »

Read my last 5 words. With normal textures it won't be so obvious but it kills the fonts.
User avatar
Rachael
Posts: 13542
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her
Contact:

Re: Disable applying texture resize to console font

Post by Rachael »

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
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49066
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Disable applying texture resize to console font

Post by Graf Zahl »

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.
_mental_
 
 
Posts: 3812
Joined: Sun Aug 07, 2011 4:32 am

Re: Disable applying texture resize to console font

Post by _mental_ »

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.
User avatar
Rachael
Posts: 13542
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her
Contact:

Re: Disable applying texture resize to console font

Post by Rachael »

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

Return to “Closed Bugs [GZDoom]”