AMD modifiers: cross-GPU compatibility
Requirements:
- Don't want to add precise specs of new GPUs before release of the GPU
- Want to be cross-GPU compatible where possible
- Upstream: Unique modifier per layout (which mostly also implies the previous requirement
- Want to support a small number of modifiers
Use parameters from hardware config per generation
- Pro: Very transparent and can prove well-definedness by generating a layout from the modifier + image params
- Pro: Doesn't need knowledge about which chips exist in a generation
- Con: Potentially a lot of modifiers (currently ~600 for GFX9 in the kernel, though userspace will only support ~10 on any given HW so the intersection should be reasonable)
- Con: Use a significant number of bits in the modifier for parameters
Wrt the large number of modifiers there might be various ideas to reduce, but the core problem is that for the newest generations the tiling config is read from the GPU, so not even the kernel knows beforehand the answer to the question "what are the tiling configs for all the GPUs you support". Of course a list can be added, but AFAIU there is unwillingness from AMD to release those before release.
So that leaves us with stuff like "support all parameter combinations that can be encoded in HW fields" or "support all older HW + whatever is plugged in in the current machine.
Note that the number of combinations exposed by the kernel is so high because for the display unit (almost) all of the parameters are configurable, while the render/texture units do not allow that.
Only exposing support for the current GPU + linear
Only exposing the current GPU + linear would closely mirror existing behavior, and limit the number of active modifiers significantly.
The core thing we need to make sure is that with cross-GPU, we don't accidentally render to the linear texture, and that we render to a tiled texture and then blit to linear (linear is 4x slower to render to on AMD). Tha tsaid we should make sure this happens for all the options because of reasons like VRAM as well.
Use a chip ID as parameter in the modifier
The main problem is that in the end you either
- Give up on GPU cross-compat & modifier uniqueness, or
- Have a total mess of "canonical chip IDs" that can expose some of the information anyway. (not only when you have equivalent chips, but also when you have layouts that do not use all the tiling parameters)
And when you have an error, it is hard to figure out what the best way is to fix it.