radv/gfx10: fix intensity formats by setting ALPHA_IS_ON_MSB

Submitted by Samuel Pitoiset on July 24, 2019, 1:03 p.m.

Details

Message ID 20190724130330.24374-1-samuel.pitoiset@gmail.com
State New
Headers show
Series "radv/gfx10: fix intensity formats by setting ALPHA_IS_ON_MSB" ( rev: 1 ) in Mesa

Not browsing as part of any series.

Commit Message

Samuel Pitoiset July 24, 2019, 1:03 p.m.
This fixes
dEQP-VK.rasterization.primitive_size.points.point_size_*

This also fixes some black squares with the Sascha SSAO demo.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
---
 src/amd/vulkan/radv_image.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/src/amd/vulkan/radv_image.c b/src/amd/vulkan/radv_image.c
index 09413333cbb..59d6d0ced78 100644
--- a/src/amd/vulkan/radv_image.c
+++ b/src/amd/vulkan/radv_image.c
@@ -617,6 +617,19 @@  static unsigned gfx9_border_color_swizzle(const enum vk_swizzle swizzle[4])
 	return bc_swizzle;
 }
 
+static bool vi_alpha_is_on_msb(struct radv_device *device, VkFormat format)
+{
+	const struct vk_format_description *desc = vk_format_description(format);
+
+	/* Formats with 3 channels can't have alpha. */
+	if (desc->nr_channels == 3)
+		return true; /* same as xxxA; is any value OK here? */
+
+	if (device->physical_device->rad_info.chip_class >= GFX10 && desc->nr_channels == 1)
+		return desc->swizzle[3] == VK_SWIZZLE_X;
+
+	return radv_translate_colorswap(format, false) <= 1;
+}
 /**
  * Build the sampler view descriptor for a texture (GFX10).
  */
@@ -695,7 +708,7 @@  gfx10_make_texture_descriptor(struct radv_device *device,
 
 		state[6] |= S_00A018_MAX_UNCOMPRESSED_BLOCK_SIZE(V_028C78_MAX_BLOCK_SIZE_256B) |
 			    S_00A018_MAX_COMPRESSED_BLOCK_SIZE(V_028C78_MAX_BLOCK_SIZE_128B) |
-			    S_00A018_ALPHA_IS_ON_MSB(swap <= 1);
+			    S_00A018_ALPHA_IS_ON_MSB(vi_alpha_is_on_msb(device, vk_format));
 	}
 
 	/* Initialize the sampler view for FMASK. */

Comments

On Wed, Jul 24, 2019 at 3:00 PM Samuel Pitoiset
<samuel.pitoiset@gmail.com> wrote:
>
> This fixes
> dEQP-VK.rasterization.primitive_size.points.point_size_*
>
> This also fixes some black squares with the Sascha SSAO demo.
>
> Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
> ---
>  src/amd/vulkan/radv_image.c | 15 ++++++++++++++-
>  1 file changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/src/amd/vulkan/radv_image.c b/src/amd/vulkan/radv_image.c
> index 09413333cbb..59d6d0ced78 100644
> --- a/src/amd/vulkan/radv_image.c
> +++ b/src/amd/vulkan/radv_image.c
> @@ -617,6 +617,19 @@ static unsigned gfx9_border_color_swizzle(const enum vk_swizzle swizzle[4])
>         return bc_swizzle;
>  }
>
> +static bool vi_alpha_is_on_msb(struct radv_device *device, VkFormat format)
> +{
> +       const struct vk_format_description *desc = vk_format_description(format);
> +
> +       /* Formats with 3 channels can't have alpha. */
> +       if (desc->nr_channels == 3)
> +               return true; /* same as xxxA; is any value OK here? */

I don't think this is correct. For formats with multiple channels,
this bit is not about "does this format have alpha", but "is the alpha
channel on MSB or LSB". IIRC even for RG the "alpha" is just the G
component, no explicit alpha needed.


> +
> +       if (device->physical_device->rad_info.chip_class >= GFX10 && desc->nr_channels == 1)
> +               return desc->swizzle[3] == VK_SWIZZLE_X;
> +
> +       return radv_translate_colorswap(format, false) <= 1;
> +}
>  /**
>   * Build the sampler view descriptor for a texture (GFX10).
>   */
> @@ -695,7 +708,7 @@ gfx10_make_texture_descriptor(struct radv_device *device,
>
>                 state[6] |= S_00A018_MAX_UNCOMPRESSED_BLOCK_SIZE(V_028C78_MAX_BLOCK_SIZE_256B) |
>                             S_00A018_MAX_COMPRESSED_BLOCK_SIZE(V_028C78_MAX_BLOCK_SIZE_128B) |
> -                           S_00A018_ALPHA_IS_ON_MSB(swap <= 1);
> +                           S_00A018_ALPHA_IS_ON_MSB(vi_alpha_is_on_msb(device, vk_format));
>         }
>
>         /* Initialize the sampler view for FMASK. */
> --
> 2.22.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev