layers: GH1889, check for CLAMP_TO_EDGE ext enable

Using this addressing mode in CreateSampler should generate an error
if the extension is not enabled.
Also added layer validation test for this check and updated the error
database.

Change-Id: If0a434976aa4bb30ab23ff6babb95df3af7a4efd
diff --git a/layers/parameter_validation.cpp b/layers/parameter_validation.cpp
index e75b736..ee33ef8 100644
--- a/layers/parameter_validation.cpp
+++ b/layers/parameter_validation.cpp
@@ -2471,6 +2471,20 @@
             skip |= validate_ranged_enum(report_data, "vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor",
                                          VK_BORDER_COLOR_BEGIN_RANGE, VK_BORDER_COLOR_END_RANGE, pCreateInfo->borderColor);
         }
+
+        // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE, the
+        // VK_KHR_sampler_mirror_clamp_to_edge extension must be enabled
+        if (!device_data->extensions.vk_khr_sampler_mirror_clamp_to_edge &&
+            ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
+             (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
+             (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE))) {
+            skip |=
+                log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
+                        VALIDATION_ERROR_1260086e, LayerName,
+                        "vkCreateSampler(): A VkSamplerAddressMode value is set to VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE "
+                        "but the VK_KHR_sampler_mirror_clamp_to_edge extension has not been enabled. %s",
+                        validation_error_map[VALIDATION_ERROR_1260086e]);
+        }
     }
 
     if (!skip) {
diff --git a/layers/vk_validation_error_database.txt b/layers/vk_validation_error_database.txt
index b16aae7..2281f77 100644
--- a/layers/vk_validation_error_database.txt
+++ b/layers/vk_validation_error_database.txt
@@ -1146,7 +1146,7 @@
 VALIDATION_ERROR_12600868~^~N~^~Unknown~^~vkCreateSampler~^~VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076~^~core~^~The spec valid usage text states 'If unnormalizedCoordinates is VK_TRUE, anisotropyEnable must be VK_FALSE' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076)~^~
 VALIDATION_ERROR_1260086a~^~N~^~Unknown~^~vkCreateSampler~^~VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077~^~core~^~The spec valid usage text states 'If unnormalizedCoordinates is VK_TRUE, compareEnable must be VK_FALSE' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077)~^~
 VALIDATION_ERROR_1260086c~^~N~^~Unknown~^~vkCreateSampler~^~VUID-VkSamplerCreateInfo-addressModeU-01078~^~core~^~The spec valid usage text states 'If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a valid VkBorderColor value' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkSamplerCreateInfo-addressModeU-01078)~^~
-VALIDATION_ERROR_1260086e~^~N~^~Unknown~^~vkCreateSampler~^~VUID-VkSamplerCreateInfo-addressModeU-01079~^~core~^~The spec valid usage text states 'If the VK_KHR_sampler_mirror_clamp_to_edge extension is not enabled, addressModeU, addressModeV and addressModeW must not be VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkSamplerCreateInfo-addressModeU-01079)~^~
+VALIDATION_ERROR_1260086e~^~Y~^~MirrorClampToEdgeNotEnabled~^~vkCreateSampler~^~VUID-VkSamplerCreateInfo-addressModeU-01079~^~core~^~The spec valid usage text states 'If the VK_KHR_sampler_mirror_clamp_to_edge extension is not enabled, addressModeU, addressModeV and addressModeW must not be VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkSamplerCreateInfo-addressModeU-01079)~^~
 VALIDATION_ERROR_12600870~^~N~^~Unknown~^~vkCreateSampler~^~VUID-VkSamplerCreateInfo-compareEnable-01080~^~core~^~The spec valid usage text states 'If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkSamplerCreateInfo-compareEnable-01080)~^~
 VALIDATION_ERROR_12600872~^~N~^~Unknown~^~vkCreateSampler~^~VUID-VkSamplerCreateInfo-magFilter-01081~^~(VK_IMG_filter_cubic)~^~The spec valid usage text states 'If either magFilter or minFilter is VK_FILTER_CUBIC_IMG, anisotropyEnable must be VK_FALSE' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-VkSamplerCreateInfo-magFilter-01081)~^~
 VALIDATION_ERROR_12609005~^~N~^~Unknown~^~vkCreateSampler~^~VUID-VkSamplerCreateInfo-flags-zerobitmask~^~core~^~The spec valid usage text states 'flags must be 0' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkSamplerCreateInfo-flags-zerobitmask)~^~implicit, TBD in parameter validation layer.