mesa
mesa copied to clipboard
vc4: Try direct memory access for nearest-filtered raster textures
Right now when we try to texture from a raster texture, we make a shadow copy of the texture that's tiled, because 2708B0's raster texture sampling is broken. This is unfortunate because it means that the cost of sampling from the texture scales with the total size of the texture rather than the size of the sampling being done, and there's definitely an extra load and store even if you were sampling the full texture once.
If we recognized that we were doing non-mipmapped nearest filtering and no complicated wrapping, we could probably lower our texture accesses to direct memory access and do the math in the shader to figure out which texel to fetch. This would save us the whole shadow copy trouble, at the cost of slower per-sample access compared to the shadow alternative.
A implementation is here https://github.com/jonasarrow/mesa_freedesktop/commit/48d5a1c76d2e843cf9054524e9aba4c9d6b8fbc8 . Not all wrapping/clamping modes implemented, LOD is completely ignored and interpolation is NEAREST. For the X11-desktop it works. I think, we could even support linear filtering and then 3D textures in raster layout.
Commit https://github.com/jonasarrow/mesa_freedesktop/commit/5459cb8a203d0e23f94187ffd7180a7acc1949d4 is a little bit faster (omitting ITOF twice) and fixes bad addressing which cause funny rendering under X. If we want to support different strides, a field has to be added to the texture, then it could be read directly. This would allow relaxed requirements for the shared textures.