summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIago Toral Quiroga <itoral@igalia.com>2020-07-03 10:06:28 +0200
committerMarge Bot <eric+marge@anholt.net>2020-10-13 21:21:31 +0000
commit3bd02a729a63513cd8f44e766b47ef4ddbc08c20 (patch)
treea2e925ffc4883163ac44a66a05b08d789bc22059
parentf156c5dc4d60464722fe6f1a589b0061b47a2d47 (diff)
v3dv: fix color border clamping with specific formats
For some reason, CTS expects E5B9G9R9 and B10G11R11 with transparent black border clamping produce alpha 1 instead of 0. Since border color takes precedence over the texture state swizzle, the only way to fix this is to lower the texture swizzle in the shader to set alpha to 1. Fixes: dEQP-VK.pipeline.sampler.view_type.*b10g11r11*clamp_to_border_transparent_black dEQP-VK.pipeline.sampler.view_type.*e5b9g9r9*.clamp_to_border_transparent_black Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
-rw-r--r--src/broadcom/vulkan/v3dv_cmd_buffer.c25
-rw-r--r--src/broadcom/vulkan/v3dv_device.c23
-rw-r--r--src/broadcom/vulkan/v3dv_private.h1
3 files changed, 40 insertions, 9 deletions
diff --git a/src/broadcom/vulkan/v3dv_cmd_buffer.c b/src/broadcom/vulkan/v3dv_cmd_buffer.c
index 7926defa86f..d96df92f2c0 100644
--- a/src/broadcom/vulkan/v3dv_cmd_buffer.c
+++ b/src/broadcom/vulkan/v3dv_cmd_buffer.c
@@ -2625,11 +2625,26 @@ cmd_buffer_populate_v3d_key(struct v3d_key *key,
key->tex[combined_idx].return_channels = 4;
}
- /* Note: 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 on
- * the pipeline populate.
- */
+ /* 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 (image_view->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;
+ }
+ }
}
}
}
diff --git a/src/broadcom/vulkan/v3dv_device.c b/src/broadcom/vulkan/v3dv_device.c
index aa4e75310b0..14a06479be7 100644
--- a/src/broadcom/vulkan/v3dv_device.c
+++ b/src/broadcom/vulkan/v3dv_device.c
@@ -2016,10 +2016,10 @@ pack_sampler_state(struct v3dv_sampler *sampler,
{
enum V3DX(Border_Color_Mode) border_color_mode;
- /* FIXME: direct border_color_mode mapping would work with some specific
- * formats, but some others it would be needed to use
- * V3D_BORDER_COLOR_FOLLOWS, and fill up
- * SAMPLER_STATE.border_color_word_[0/1/2/3]
+ /* For now we only support the preset Vulkan border color modes. If we
+ * want to implement VK_EXT_custom_border_color in the future we would have
+ * to use V3D_BORDER_COLOR_FOLLOWS, and fill up border_color_word_[0/1/2/3]
+ * SAMPLER_STATE.
*/
switch (pCreateInfo->borderColor) {
case VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK:
@@ -2039,6 +2039,21 @@ pack_sampler_state(struct v3dv_sampler *sampler,
break;
}
+ /* For some texture formats, when clamping to transparent black border the
+ * CTS expects alpha to be set to 1 instead of 0, but the border color mode
+ * will take priority over the texture state swizzle, so the only way to
+ * fix that is to apply a swizzle in the shader. Here we keep track of
+ * whether we are activating that mode and we will decide if we need to
+ * activate the texture swizzle lowering in the shader key at compile time
+ * depending on the actual texture format.
+ */
+ if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER ||
+ pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER ||
+ pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) &&
+ border_color_mode == V3D_BORDER_COLOR_0000) {
+ sampler->clamp_to_transparent_black_border = true;
+ }
+
v3dv_pack(sampler->sampler_state, SAMPLER_STATE, s) {
if (pCreateInfo->anisotropyEnable) {
s.anisotropy_enable = true;
diff --git a/src/broadcom/vulkan/v3dv_private.h b/src/broadcom/vulkan/v3dv_private.h
index e19dbc87d8c..506aa1d206e 100644
--- a/src/broadcom/vulkan/v3dv_private.h
+++ b/src/broadcom/vulkan/v3dv_private.h
@@ -1381,6 +1381,7 @@ struct v3dv_descriptor_map {
struct v3dv_sampler {
bool compare_enable;
bool unnormalized_coordinates;
+ bool clamp_to_transparent_black_border;
/* Prepacked SAMPLER_STATE, that is referenced as part of the tmu
* configuration. If needed it will be copied to the descriptor info during