Mesa (main): anv: Allow unused VkSpecializationMapEntries

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jul 20 21:52:56 UTC 2021


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

Author: Iván Briano <ivan.briano at intel.com>
Date:   Tue Jul 20 11:55:58 2021 -0700

anv: Allow unused VkSpecializationMapEntries

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

Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11987>

---

 src/intel/vulkan/anv_pipeline.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/src/intel/vulkan/anv_pipeline.c b/src/intel/vulkan/anv_pipeline.c
index 5ffb575d75f..599da83c40d 100644
--- a/src/intel/vulkan/anv_pipeline.c
+++ b/src/intel/vulkan/anv_pipeline.c
@@ -117,8 +117,27 @@ anv_shader_compile_to_nir(struct anv_device *device,
          case 1:
             spec_entries[i].value.u8 = *(const uint8_t *)data;
             break;
+         case 0:
          default:
-            assert(!"Invalid spec constant size");
+            /* 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;
          }
       }



More information about the mesa-commit mailing list