aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2018-10-07 20:47:21 -0700
committerKenneth Graunke <[email protected]>2019-02-21 10:26:09 -0800
commitbfbebbaa366152d4804d400715afa58d68af084f (patch)
tree1aafb00eb39d2d44518e6361210d4588e7060453 /src/gallium
parent94569a645837df895e889c7e451e35b8e31556fd (diff)
iris: Use R/RG instead of I/L/A when sampling
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/drivers/iris/iris_formats.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/gallium/drivers/iris/iris_formats.c b/src/gallium/drivers/iris/iris_formats.c
index 2c726cb5fde..290b65880a1 100644
--- a/src/gallium/drivers/iris/iris_formats.c
+++ b/src/gallium/drivers/iris/iris_formats.c
@@ -400,6 +400,26 @@ iris_isl_format_for_pipe_format(enum pipe_format pf)
return table[pf];
}
+static enum pipe_format
+alpha_to_red(enum pipe_format pf)
+{
+ switch (pf) {
+ case PIPE_FORMAT_A8_UNORM: return PIPE_FORMAT_R8_UNORM;
+ case PIPE_FORMAT_A16_UNORM: return PIPE_FORMAT_R16_UNORM;
+ case PIPE_FORMAT_A8_SNORM: return PIPE_FORMAT_R8_SNORM;
+ case PIPE_FORMAT_A16_SNORM: return PIPE_FORMAT_R16_SNORM;
+ case PIPE_FORMAT_A16_FLOAT: return PIPE_FORMAT_R16_FLOAT;
+ case PIPE_FORMAT_A32_FLOAT: return PIPE_FORMAT_R32_FLOAT;
+ case PIPE_FORMAT_A8_UINT: return PIPE_FORMAT_A8_UINT;
+ case PIPE_FORMAT_A8_SINT: return PIPE_FORMAT_A8_SINT;
+ case PIPE_FORMAT_A16_UINT: return PIPE_FORMAT_R16_UINT;
+ case PIPE_FORMAT_A16_SINT: return PIPE_FORMAT_R16_SINT;
+ case PIPE_FORMAT_A32_UINT: return PIPE_FORMAT_R32_UINT;
+ case PIPE_FORMAT_A32_SINT: return PIPE_FORMAT_R32_SINT;
+ default: return pf;
+ }
+}
+
struct iris_format_info
iris_format_for_usage(const struct gen_device_info *devinfo,
enum pipe_format pformat,
@@ -407,6 +427,17 @@ iris_format_for_usage(const struct gen_device_info *devinfo,
{
struct isl_swizzle swizzle = ISL_SWIZZLE_IDENTITY;
+ if ((usage & ISL_SURF_USAGE_TEXTURE_BIT) && !util_format_is_srgb(pformat)) {
+ if (util_format_is_intensity(pformat)) {
+ swizzle = ISL_SWIZZLE(RED, RED, RED, RED);
+ } else if (util_format_is_luminance(pformat)) {
+ swizzle = ISL_SWIZZLE(RED, RED, RED, ONE);
+ } else if (util_format_is_alpha(pformat)) {
+ pformat = alpha_to_red(pformat);
+ swizzle = ISL_SWIZZLE(ZERO, ZERO, ZERO, RED);
+ }
+ }
+
enum isl_format format = iris_isl_format_for_pipe_format(pformat);
/* Convert RGBX into RGBA for rendering or typed image access. */