Mesa (master): radv: check enabled device features.

Dave Airlie airlied at kemper.freedesktop.org
Mon Jul 24 07:17:19 UTC 2017


Module: Mesa
Branch: master
Commit: 22b59b99cbee00689b68f1781ed0a10d74ffc49e
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=22b59b99cbee00689b68f1781ed0a10d74ffc49e

Author: Dave Airlie <airlied at redhat.com>
Date:   Mon Jul 24 07:16:40 2017 +0100

radv: check enabled device features.

The spec says we should return VK_ERROR_FEATURE_NOT_PRESENT.

Ported from anv.

Fixes CTS test dEQP-VK.api.device_init.create_device_unsupported_features

Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
Signed-off-by: Dave Airlie <airlied at redhat.com>

---

 src/amd/vulkan/radv_device.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
index 619e0f2fbe..111bc7e957 100644
--- a/src/amd/vulkan/radv_device.c
+++ b/src/amd/vulkan/radv_device.c
@@ -1045,6 +1045,19 @@ VkResult radv_CreateDevice(
 			return vk_error(VK_ERROR_EXTENSION_NOT_PRESENT);
 	}
 
+	/* Check enabled features */
+	if (pCreateInfo->pEnabledFeatures) {
+		VkPhysicalDeviceFeatures supported_features;
+		radv_GetPhysicalDeviceFeatures(physicalDevice, &supported_features);
+		VkBool32 *supported_feature = (VkBool32 *)&supported_features;
+		VkBool32 *enabled_feature = (VkBool32 *)pCreateInfo->pEnabledFeatures;
+		unsigned num_features = sizeof(VkPhysicalDeviceFeatures) / sizeof(VkBool32);
+		for (uint32_t i = 0; i < num_features; i++) {
+			if (enabled_feature[i] && !supported_feature[i])
+				return vk_error(VK_ERROR_FEATURE_NOT_PRESENT);
+		}
+	}
+
 	device = vk_alloc2(&physical_device->instance->alloc, pAllocator,
 			     sizeof(*device), 8,
 			     VK_SYSTEM_ALLOCATION_SCOPE_DEVICE);




More information about the mesa-commit mailing list