summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers
diff options
context:
space:
mode:
authorRafael Antognolli <[email protected]>2019-03-07 15:32:38 -0800
committerKenneth Graunke <[email protected]>2019-03-13 14:45:13 -0700
commit1281368d02a22d08a892fbfda4cecc1219cde895 (patch)
treef31fa5b3e54f57c397f77ae87b59d57d3bc35d51 /src/gallium/drivers
parent9159a5bbf882f94c48c21371049fef2d03d3dafd (diff)
iris: Convert RGBX to RGBA always.
In i965, we disable the use of RGBX formats, so the higher layers of Mesa choose the equivalent RGBA format, and swizzle the alpha channel to 1.0. However, Gallium won't do that. We need to explicitly convert it to RGBA. Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r--src/gallium/drivers/iris/iris_formats.c41
1 files changed, 27 insertions, 14 deletions
diff --git a/src/gallium/drivers/iris/iris_formats.c b/src/gallium/drivers/iris/iris_formats.c
index 91c86efca4d..ec7fd77f3a9 100644
--- a/src/gallium/drivers/iris/iris_formats.c
+++ b/src/gallium/drivers/iris/iris_formats.c
@@ -344,20 +344,33 @@ iris_format_for_usage(const struct gen_device_info *devinfo,
swizzle = ISL_SWIZZLE(RED, GREEN, BLUE, ONE);
}
- if (usage & ISL_SURF_USAGE_RENDER_TARGET_BIT) {
- if (isl_format_is_rgbx(format) &&
- !isl_format_supports_rendering(devinfo, format)) {
- format = isl_format_rgbx_to_rgba(format);
- } else if (pformat == PIPE_FORMAT_A8_UNORM) {
- /* Most of the hardware A/LA formats are not renderable, except
- * for A8_UNORM. SURFACE_STATE's shader channel select fields
- * cannot be used to swap RGB and A channels when rendering (as
- * it could impact alpha blending), so we have to use the actual
- * A8_UNORM format when rendering.
- */
- format = ISL_FORMAT_A8_UNORM;
- swizzle = ISL_SWIZZLE_IDENTITY;
- }
+ if ((usage & ISL_SURF_USAGE_RENDER_TARGET_BIT) &&
+ pformat == PIPE_FORMAT_A8_UNORM) {
+ /* Most of the hardware A/LA formats are not renderable, except
+ * for A8_UNORM. SURFACE_STATE's shader channel select fields
+ * cannot be used to swap RGB and A channels when rendering (as
+ * it could impact alpha blending), so we have to use the actual
+ * A8_UNORM format when rendering.
+ */
+ format = ISL_FORMAT_A8_UNORM;
+ swizzle = ISL_SWIZZLE_IDENTITY;
+ }
+
+ /* We choose RGBA over RGBX for rendering the hardware doesn't support
+ * rendering to RGBX. However, when this internal override is used on Gen9+,
+ * fast clears don't work correctly.
+ *
+ * i965 fixes this by pretending to not support RGBX formats, and the higher
+ * layers of Mesa pick the RGBA format instead. Gallium doesn't work that
+ * way, and might choose a different format, like BGRX instead of RGBX,
+ * which will also cause problems when sampling from a surface fast cleared
+ * as RGBX. So we always choose RGBA instead of RGBX explicitly
+ * here.
+ */
+ if (isl_format_is_rgbx(format) &&
+ !isl_format_supports_rendering(devinfo, format)) {
+ format = isl_format_rgbx_to_rgba(format);
+ swizzle = ISL_SWIZZLE(RED, GREEN, BLUE, ONE);
}
return (struct iris_format_info) { .fmt = format, .swizzle = swizzle };