Skip to content

st/mesa: Optionally override RGB/RGBX dst alpha blend factors

Kenneth Graunke requested to merge kwg/mesa:st-blend-xrgb into master

Intel's blending hardware does not properly return 1.0 for destination alpha for RGBX formats; it requires the factors to be overridden to either zero or one. Overriding these factors is safe in general, but but Nouveau and Radeon would prefer not to. They already handle this case correctly, and would like to avoid the resulting independent blending (rgb != a), as well as the proliferation of extra blend states.

I considered simply handling this in the driver, but it's not as nice. pipe_blend_state doesn't have any format information, so we'd need the hardware blend state to depend on both pipe_blend_state and pipe_framebuffer_state. Furthermore, Intel GPUs don't have a native RGBX_SNORM format, so I avoid exposing one, which makes RGB_SNORM fall back to RGBA_SNORM. The pipe_surfaces we get in the driver have an RGBA format, making it impossible to tell that there shouldn't be an alpha channel. One could argue that st not handling it in that case is a bug. To work around this, we'd have to expose RGBX pipe formats, mapped to RGBA hardware formats, and add format swizzling special cases. All doable, but it ends up being more code than I'd like.

st_atom_blend already has access to the right information and it's trivial to accomplish there, so we just add a cap bit and do that.

Merge request reports