Mesa (main): radv: allow unused VkSpecializationMapEntries

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Jul 26 12:48:41 UTC 2021


Module: Mesa
Branch: main
Commit: 0497588eac63e2b43ba2ff46f7edd103ba6fdf3c
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=0497588eac63e2b43ba2ff46f7edd103ba6fdf3c

Author: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Date:   Mon Jul 26 13:47:13 2021 +0200

radv: allow unused VkSpecializationMapEntries

Fixes future CTS: dEQP-VK.pipeline.spec_constant.*.basic.*unused_*

Cc: 21.2 mesa-stable
Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12062>

---

 src/amd/vulkan/radv_shader.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/src/amd/vulkan/radv_shader.c b/src/amd/vulkan/radv_shader.c
index 2c1832ea10d..2dc7be4c5d6 100644
--- a/src/amd/vulkan/radv_shader.c
+++ b/src/amd/vulkan/radv_shader.c
@@ -485,6 +485,24 @@ radv_shader_compile_to_nir(struct radv_device *device, struct vk_shader_module *
             case 1:
                memcpy(&spec_entries[i].value.u8, data, sizeof(uint8_t));
                break;
+            case 0:
+               /* The Vulkan spec says:
+                *
+                *    "For a constantID specialization constant declared in a shader, size must match
+                *    the byte size of the constantID. If the specialization constant is of type
+                *    boolean, size must be the byte size of VkBool32."
+                *
+                * Therefore, since only scalars can be decorated as specialization constants, we can
+                * assume that if it doesn't have a size of 1, 2, 4, or 8, any use in a shader would
+                * be invalid usage.  The spec further says:
+                *
+                *    "If a constantID value is not a specialization constant ID used in the shader,
+                *    that map entry does not affect the behavior of the pipeline."
+                *
+                * so we should ignore any invalid specialization constants rather than crash or
+                * error out when we see one.
+                */
+               break;
             default:
                assert(!"Invalid spec constant size");
                break;



More information about the mesa-commit mailing list