panfrost/nir: Add nir_lower_blend pass
authorAlyssa Rosenzweig <alyssa@rosenzweig.io>
Mon, 6 May 2019 02:06:02 +0000 (02:06 +0000)
committerAlyssa Rosenzweig <alyssa@rosenzweig.io>
Sun, 19 May 2019 17:54:56 +0000 (17:54 +0000)
commita1885b2a353e02347e03d2fcb540cac1e5801e0a
tree4168c3be1a079638431d2f1d3d8586bb6902e3dc
parent6b2457e75c28d60c3045c6d3d7d8f6d9f08d25d6
panfrost/nir: Add nir_lower_blend pass

This new lowering pass implements the OpenGL ES blend pipeline in
shaders, applicable to hardware lacking full-featured blending hardware
(including Midgard/Bifrost and vc4). This pass is run on a fragment
shader, rewriting the store to a blended version, loading in the
framebuffer destination color and constant color via intrinsics as
necessary. This pass is sufficient for OpenGL ES 2.0 and is verified to
pass dEQP's blend tests. MIN/MAX modes are included and tested as well.
That said, at present it has the following limitations:

 - MRT is not supported (ES3).
 - sRGB support is missing (ES3).
 - Extended blending is not yet ported from GLSL IR lowering (ES3.2)
 - Dual-source blending is not supported. (N/A)
 - Logic ops are not supported. (N/A)

v2: Fix code conventions (per Ian Romanick's feedback). Implement color
masks.

This pass should be in common nir/ space, but due to non-technical
reasons, for now it's in Panfrost space. In the future, depending if
other drivers need some of the functionality, we can move this back to
src/compiler/nir space.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
src/gallium/drivers/panfrost/meson.build
src/gallium/drivers/panfrost/midgard/nir_lower_blend.c [new file with mode: 0644]
src/gallium/drivers/panfrost/midgard/nir_lower_blend.h [new file with mode: 0644]
src/gallium/drivers/panfrost/pan_blend_shaders.c