v3dv/format: use XYZ1 swizzle for three-component formats
authorAlejandro Piñeiro <apinheiro@igalia.com>
Wed, 28 Oct 2020 13:08:10 +0000 (14:08 +0100)
committerAlejandro Piñeiro <apinheiro@igalia.com>
Thu, 29 Oct 2020 10:06:44 +0000 (11:06 +0100)
So far for the formats E5B9G9R9_UFLOAT_PACK32 and
B10G11R11_UFLOAT_PACK32 we were using a XYZW swizzle. But from Vulkan
spec those are three-component, without alpha, formats. So we should
use XYZ1 instead, as we were already doing for other three-component
formats.

Curiously the only case where this raised a problem were when using
clamp to border with transparent black. This change allows us to
remove the code that handled only that specific case.

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7355>

src/broadcom/vulkan/v3dv_cmd_buffer.c
src/broadcom/vulkan/v3dv_formats.c

index df0ea4f..2f07ead 100644 (file)
@@ -2928,27 +2928,6 @@ cmd_buffer_populate_v3d_key(struct v3d_key *key,
          if (key->tex[combined_idx].return_size == 32) {
             v3d_key_return_size = 32;
          }
-
-         /* Note: In general, we don't need to do anything for the swizzle, as
-          * that is handled with the swizzle info at the Texture State, and the
-          * default values for key->tex[].swizzle were already filled up at
-          * the pipeline creation time.
-          *
-          * The only exeption in which we want to apply a texture swizzle
-          * lowering in the shader is to force alpha to 1 when using clamp
-          * to border with transparent black in combination with specific
-          * formats.
-          */
-         if (sampler && sampler->clamp_to_transparent_black_border) {
-            switch (vk_format) {
-            case VK_FORMAT_E5B9G9R9_UFLOAT_PACK32:
-            case VK_FORMAT_B10G11R11_UFLOAT_PACK32:
-               key->tex[combined_idx].swizzle[3] = PIPE_SWIZZLE_1;
-               break;
-            default:
-               break;
-            }
-         }
       }
       v3d_key_update_return_size(cmd_buffer->state.pipeline, key,
                                  v3d_key_return_size);
index e2d9622..e7587f5 100644 (file)
@@ -134,8 +134,8 @@ static const struct v3dv_format format_table[] = {
    FORMAT(A8B8G8R8_SRGB_PACK32,    SRGB8_ALPHA8, RGBA8,         SWIZ_XYZW, 16, true), /* RGBA8 sRGB */
    FORMAT(A2B10G10R10_UNORM_PACK32,RGB10_A2,     RGB10_A2,      SWIZ_XYZW, 16, true),
    FORMAT(A2B10G10R10_UINT_PACK32, RGB10_A2UI,   RGB10_A2UI,    SWIZ_XYZW, 16, true),
-   FORMAT(E5B9G9R9_UFLOAT_PACK32,  NO,           RGB9_E5,       SWIZ_XYZW, 16, true),
-   FORMAT(B10G11R11_UFLOAT_PACK32, R11F_G11F_B10F,R11F_G11F_B10F, SWIZ_XYZW, 16, true),
+   FORMAT(E5B9G9R9_UFLOAT_PACK32,  NO,           RGB9_E5,       SWIZ_XYZ1, 16, true),
+   FORMAT(B10G11R11_UFLOAT_PACK32, R11F_G11F_B10F,R11F_G11F_B10F, SWIZ_XYZ1, 16, true),
 
    /* Depth */
    FORMAT(D16_UNORM,               D16,          DEPTH_COMP16,  SWIZ_X001, 32, false),