iris: Properly support alpha and luminance-alpha formats

For texturing, we map alpha formats to the corresponding red format,
as many alpha formats are outright missing, and red is more efficient
when sampling anyway.

When rendering to A8_UNORM, we use that format directly, so the image
gets the shader output's .a/.w channel, rather than the .r/.x channel.

All other A* formats are non-renderable, so we can't do much and just
mark them as unsupported for rendering.  Fortunately, GL only requires
rendering to A8_UNORM, so that works out.

According to Andre Heider and Timur Kristóf, this fixes font rendering
in Witcher 1 (via nine).  Andre also reported that it fixes Unigine
Heaven (presumably via nine).

v2: Use the same swizzle for both sampler views and "render targets".
    BLORP expects the read swizzle, and will take the inverse when
    setting up the destination swizzle (and actually applying it in
    the shaders).  We ignore the format swizzle when setting up normal
    rendering SURFACE_STATEs, which is necessary because it would be
    an illegal shader channel select combination.  Thanks to Jason
    Ekstrand for pointing out that BLORP took an inverse swizzle.

Tested-by: Timur Kristóf <timur.kristof@gmail.com>
Tested-by: Andre Heider <a.heider@gmail.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
This commit is contained in:
Kenneth Graunke
2019-02-21 22:49:40 -08:00
parent fbc51c4c95
commit 809a81ec3a
4 changed files with 117 additions and 85 deletions

View File

@@ -406,7 +406,7 @@ iris_blit(struct pipe_context *ctx, const struct pipe_blit_info *info)
&src_surf, info->src.level, info->src.box.z + slice,
src_fmt.fmt, src_fmt.swizzle,
&dst_surf, info->dst.level, info->dst.box.z + slice,
dst_fmt.fmt, ISL_SWIZZLE_IDENTITY,
dst_fmt.fmt, dst_fmt.swizzle,
src_x0, src_y0, src_x1, src_y1,
dst_x0, dst_y0, dst_x1, dst_y1,
filter, mirror_x, mirror_y);