ZDoom / Raze

Build engine port backed by GZDoom tech. Currently supports Duke Nukem 3D, Blood, Shadow Warrior, Redneck Rampage and Powerslave/Exhumed.
691 stars 59 forks source link

[BUG] [Duke 3D] [Raze 0.8] - Palette emulation causes texture corruption #219

Closed mgtroyas closed 3 years ago

mgtroyas commented 3 years ago

Enabling palette emulation causes texture corruption. Also bilinear/trilinear filtering is not applied with this option.

Windows 10 and AMD Radeon RX580.

This didn't happen on previous versions. Happens on both OpenGL and Vulkan renderers.

Duke_0000

sinisterseed commented 3 years ago

Vulkan is currently nonfunctional.

I will check the said corruption to see for myself, but regarding texture filtering, that is normal. It is simply how the palette works, it has quite a few technological blocks. No advanced features can work with it, such as Anisotropic Filtering, Texture Filtering, or dynamic lights. It is a take or leave kind of feature, you get the palette but lose advanced visual features in the process.

There is no way to fix this.

sinisterseed commented 3 years ago

Tried to reproduce the corruption as well, thinking that it may have been some peculiarity in that area, but it's solid for me, no issues whatsoever.

In this case, I can only suggest you update your drivers if you haven't already, that would be a prime cause for graphical glitches.

mgtroyas commented 3 years ago

You're right. I tried Raze 7.3 and corruption is still there. I updated Radeon Software/drivers some weeks ago, so yes it can be the cause.

sinisterseed commented 3 years ago

Do you also experience this, or a variation thereof, in 0.6 for instance?

mgtroyas commented 3 years ago

No, in 0.6 with same settings (overwriting Raze files), it's fixed. As soon as I overwrite with 8.1 files, the issue returns.

sinisterseed commented 3 years ago

Make sure you did delete and let the game generate another configuration file after upgrading, as keeping old important files can lead to bizarre issues sometimes.

That's a bit puzzling if 0.6 was fine. I wonder what's going on here. My guess is, it's something in the palette as I can reproduce a similar effect but in GDX if I enable anisotropic filtering while the palette is enabled. It's also AMD hardware.

mgtroyas commented 3 years ago

Did a clean install of 8.1 on an empty folder: only Raze files and the DUKE3D.GRP file. Ran Raze, started a game (L.A. Meltdown rooftop) and as soon as I enabled palette emulation the corruption showed.

Enabling/disabling texture filtering, anisotropic filtering, Multisampling has no instant fix on corruption. But then I tried changing those options, then exiting Raze and running it again: yes, some of those settings is the problem.

I did some tests changing them one by one:

When starting Raze on linear/bilinear/trilinear with palette emulation off as soon I enable palette emulation, bilinear filter is disabled and corruption is shown.

Seems an incompatibility between any mipmap mode different from nearest, and palette emulation.

On Raze 0.6 none of these settings create any image corruption. What's funny is there's also another difference: with linear/bilinear/trilinear filtering enabled, on Raze 0.6 text font on menus is filtered, while in 0.8x (and 0.7x) text is not filtered. Only when disabling palette emulation text on menus is then filtered instantly.

coelckers commented 3 years ago

That's odd - the texture filtering should be completely off with palette emulation enabled. But apparently some state is still bleeding through. Weird.

The filtering in the menu was intentionally changed to make it consistent, i.e. since palette emulation cannot use filtering, the filter also gets disabled for non-paletted content.

sinisterseed commented 3 years ago

Interesting development. Looking at how the corruption is, I had a hunch that it must be something that is still trying to be set while the palette is used instead of being wholly ignored. Similar to GDX I guess, where enabling one of these features also causes a mess of pixels on the whole screen, because it tries to still apply the effects, despite being unsupported.

At least we found what it is. Good catch πŸ‘. Curiously it doesn't happen with the mipmap modes, only the filtering ones.

sinisterseed commented 3 years ago

I was initially wondering how this managed to slip in, but now that I've been trying to reproduce it, I guess I know why.

Because I can't actually reproduce it following the procedure. It's rock solid for me, no corruption anywhere. I wonder if it isn't a change we've made that doesn't play well with AMD hardware.

M1sh2 commented 3 years ago

I have win 10 x64 version 20H2, processor ryzen 5 1600, videocard RX590 8gb with driver adrenaline 20.11.2, tested on e1l2, in toilet too, with palette with anisotropy works on both renders. I had another error, i dont know why on new renders of the Graf Zahl colors are inverted (in gzdoom and raze), after deleting configuration (.ini file), everything works as usually. On screenshot launch with vulkan (with load light, brightmaps) ΠΈΠ·ΠΎΠ±Ρ€Π°ΠΆΠ΅Π½ΠΈΠ΅

sinisterseed commented 3 years ago

So a full AMD system, but slightly different card this time. And no errors. This is making me wonder whether this may be a hardware issue for mgtroyas, though it doesn't explain why he doesn't experience it in the old base.

Regarding Vulkan, we really need to disable it. It is currently selectable but it simply isn't ready yet and doesn't work correctly. Only OpenGL is currently supported.

coelckers commented 3 years ago

So a full AMD system, but slightly different card this time. And no errors this time. This is making me wonder whether this may be a hardware issue for mgtroyas, though it doesn't explain why he doesn't experience it in the old base.

Texture sampler management worked a bit differently in the old version.

mgtroyas commented 3 years ago

I just launched the same install from a laptop with integrated Intel graphics and the corruption doesn't happen. So yes, seems something specific to some AMD graphics cards, at least my RX580.

BTW, if palette emulation isn't compatible with any filtering and mipmaps, I suggest enabling the former disables completely the later, to prevent this issue on the cards that can't handle it.

sinisterseed commented 3 years ago

The thing is, that's exactly what it's supposed to do, so we're going to check if there may be some leaks somewhere as well.

coelckers commented 3 years ago

@mgtroyas Can you please recheck with the next devbuild? I made a small change to the texture creation code.

sinisterseed commented 3 years ago

Or if you want it faster, you can use a CI artifact instead. You can get one from the green check mark next to the commit message, simply press on it - Details - Artifacts - choose a Visual Studio Release build.

Afterwards, extract it into your Raze folder. Note that those are not full builds, so the other libraries and the soundfont are not generated, hence needing an existing or fresh install. And as usual, make sure you delete the configuration file after installing the artifact.

mgtroyas commented 3 years ago

I can confirm it now works as expected on my setup :)

mgtroyas commented 3 years ago

I suppose it's me who must close the issue?

coelckers commented 3 years ago

In this case, yes, because it was undefined driver behavior that's specific to your configuration. I was unable to reproduce the problem with my Geforce.

Thanks for confirming.