Ryujinx/src/Ryujinx.Graphics.Gpu
riperiperi d2f3adbf69
Texture: Fix layout conversion when gobs in z is used with depth = 1 (#5220)
* Texture: Fix layout conversion when gobs in z is used with depth = 1

The size calculator methods deliberately reduce the gob size of textures if they are deemed too small for it. This is required to get correct sizes when iterating mip levels of a texture.

Rendering to a slice of a 3D texture can produce a 3D texture with depth 1, but a gob size matching a much larger texture. We _can't_ "correct" this gob size, as it is intended as a slice of a larger 3D texture. Ignoring it causes layout conversion to break on read and flush.

This caused an issue in Tears of the Kingdom where the compressed 3D texture used for the gloom would always break on OpenGL, and seemingly randomly break on Vulkan. In the first case, the data is forcibly flushed to decompress the BC4 texture on the CPU to upload it as 3D, which was broken due to the incorrect layout. In the second, the data may be randomly flushed if it falls out of the cache, but it will appear correct if it's able to form copy dependencies.

This change only allows gob sizes to be reduced once per mip level. For the purpose of aligned size, it can still be reduced infinitely as our texture cache isn't properly able to handle a view being _misaligned_.

The SizeCalculator has also been changed to reduce the size of rendered depth slices to only include the exact range a single depth slice will cover. (before, the size was way too small with gobs in z reduced to 1, and too large when using the correct value)

Gobs in Y logic remains untouched, we don't support Y slices of textures so it's fine as is.

This is probably worth testing in a few games as it also affects texture size and view logic.

* Improve wording

* Maybe a bit better
2023-06-04 20:25:57 +00:00
..
Engine Implement shader storage buffer operations using new Load/Store instructions (#4993) 2023-06-03 20:12:18 -03:00
Image Texture: Fix layout conversion when gobs in z is used with depth = 1 (#5220) 2023-06-04 20:25:57 +00:00
Memory Implement shader storage buffer operations using new Load/Store instructions (#4993) 2023-06-03 20:12:18 -03:00
Shader Implement shader storage buffer operations using new Load/Store instructions (#4993) 2023-06-03 20:12:18 -03:00
Synchronization GPU: Pre-emptively flush textures that are flushed often (to imported memory when available) (#4711) 2023-05-01 16:05:12 -03:00
ClassId.cs Move solution and projects to src 2023-04-27 23:51:14 +02:00
Constants.cs Implement shader storage buffer operations using new Load/Store instructions (#4993) 2023-06-03 20:12:18 -03:00
GpuChannel.cs Move solution and projects to src 2023-04-27 23:51:14 +02:00
GpuContext.cs GPU: Dispose Renderer after running deferred actions (#5144) 2023-05-31 21:43:20 +00:00
GraphicsConfig.cs Move solution and projects to src 2023-04-27 23:51:14 +02:00
Ryujinx.Graphics.Gpu.csproj Move solution and projects to src 2023-04-27 23:51:14 +02:00
Window.cs Move solution and projects to src 2023-04-27 23:51:14 +02:00