From 67faf0641d9eac10996246909d3671fa690ee2e5 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Sun, 30 Aug 2020 15:55:51 +0200 Subject: rhi: vulkan: Enable features on the device The silly fine-grained enabling of features on the VkDevice seems to be ignored in practice by the implementations, but wideLines becomes relevant because the validation layers warns if a line width is set on the pipeline without enabling the feature on the device. So to play nice, enable the features we care about. Change-Id: I0c64a0d10a8279fe43d899118b0d6f0e4f875d41 Reviewed-by: Andy Nichols --- src/gui/rhi/qrhivulkan.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'src/gui/rhi/qrhivulkan.cpp') diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp index ab74376bc5..28463398bb 100644 --- a/src/gui/rhi/qrhivulkan.cpp +++ b/src/gui/rhi/qrhivulkan.cpp @@ -442,6 +442,7 @@ bool QRhiVulkan::create(QRhi::Flags flags) return false; } physDev = physDevs[physDevIndex]; + f->vkGetPhysicalDeviceProperties(physDev, &physDevProperties); } else { f->vkGetPhysicalDeviceProperties(physDev, &physDevProperties); qCDebug(QRHI_LOG_INFO, "Using imported physical device '%s' %d.%d.%d (api %d.%d.%d vendor 0x%X device 0x%X type %d)", @@ -457,6 +458,8 @@ bool QRhiVulkan::create(QRhi::Flags flags) physDevProperties.deviceType); } + f->vkGetPhysicalDeviceFeatures(physDev, &physDevFeatures); + // Choose queue and create device, unless the device was specified in importParams. if (!importedDevice) { // We only support combined graphics+present queues. When it comes to @@ -562,6 +565,20 @@ bool QRhiVulkan::create(QRhi::Flags flags) devInfo.enabledExtensionCount = uint32_t(requestedDevExts.count()); devInfo.ppEnabledExtensionNames = requestedDevExts.constData(); + VkPhysicalDeviceFeatures features; + memset(&features, 0, sizeof(features)); + if (physDevFeatures.wideLines) + features.wideLines = VK_TRUE; + if (physDevFeatures.largePoints) + features.largePoints = VK_TRUE; + if (physDevFeatures.textureCompressionETC2) + features.textureCompressionETC2 = VK_TRUE; + if (physDevFeatures.textureCompressionASTC_LDR) + features.textureCompressionASTC_LDR = VK_TRUE; + if (physDevFeatures.textureCompressionBC) + features.textureCompressionBC = VK_TRUE; + devInfo.pEnabledFeatures = &features; + VkResult err = f->vkCreateDevice(physDev, &devInfo, nullptr, &dev); if (err != VK_SUCCESS) { qWarning("Failed to create device: %d", err); @@ -599,13 +616,11 @@ bool QRhiVulkan::create(QRhi::Flags flags) hasCompute = (queueFamilyProps[gfxQueueFamilyIdx].queueFlags & VK_QUEUE_COMPUTE_BIT) != 0; timestampValidBits = queueFamilyProps[gfxQueueFamilyIdx].timestampValidBits; - f->vkGetPhysicalDeviceProperties(physDev, &physDevProperties); ubufAlign = physDevProperties.limits.minUniformBufferOffsetAlignment; // helps little with an optimal offset of 1 (on some drivers) when the spec // elsewhere states that the minimum bufferOffset is 4... texbufAlign = qMax(4, physDevProperties.limits.optimalBufferCopyOffsetAlignment); - f->vkGetPhysicalDeviceFeatures(physDev, &physDevFeatures); hasWideLines = physDevFeatures.wideLines; if (!importedAllocator) { -- cgit v1.2.3