Commit d689d1c0 by Nicolas Capens Committed by Nicolas Capens

Implement extended vkCreateDevice features support.

Implements support for VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2 and other structure types used during Vulkan 1.1 device creation. Bug b/117974925 Change-Id: Ic23067f145322a814ccda7dd44a087d7a4020e3d Reviewed-on: https://swiftshader-review.googlesource.com/c/22689Tested-by: 's avatarNicolas Capens <nicolascapens@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com>
parent dc85364a
...@@ -12,10 +12,12 @@ ...@@ -12,10 +12,12 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#include "VkDevice.hpp"
#include "VkConfig.h" #include "VkConfig.h"
#include "VkDebug.hpp" #include "VkDebug.hpp"
#include "VkDevice.hpp"
#include "VkQueue.hpp" #include "VkQueue.hpp"
#include <new> // Must #include this to use "placement new" #include <new> // Must #include this to use "placement new"
namespace vk namespace vk
...@@ -38,9 +40,20 @@ Device::Device(const Device::CreateInfo* info, void* mem) ...@@ -38,9 +40,20 @@ Device::Device(const Device::CreateInfo* info, void* mem)
for(uint32_t j = 0; j < queueCreateInfo.queueCount; j++, queueID++) for(uint32_t j = 0; j < queueCreateInfo.queueCount; j++, queueID++)
{ {
new (queues + queueID) Queue(queueCreateInfo.queueFamilyIndex, queueCreateInfo.pQueuePriorities[j]); new (&queues[queueID]) Queue(queueCreateInfo.queueFamilyIndex, queueCreateInfo.pQueuePriorities[j]);
} }
} }
if(pCreateInfo->enabledLayerCount)
{
// "The ppEnabledLayerNames and enabledLayerCount members of VkDeviceCreateInfo are deprecated and their values must be ignored by implementations."
UNIMPLEMENTED(); // TODO(b/119321052): UNIMPLEMENTED() should be used only for features that must still be implemented. Use a more informational macro here.
}
if(pCreateInfo->enabledExtensionCount)
{
UNIMPLEMENTED();
}
} }
void Device::destroy(const VkAllocationCallbacks* pAllocator) void Device::destroy(const VkAllocationCallbacks* pAllocator)
......
...@@ -204,14 +204,17 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(VkPhysicalDevice physicalDevice, c ...@@ -204,14 +204,17 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(VkPhysicalDevice physicalDevice, c
TRACE("(VkPhysicalDevice physicalDevice = 0x%X, const VkDeviceCreateInfo* pCreateInfo = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X, VkDevice* pDevice = 0x%X)", TRACE("(VkPhysicalDevice physicalDevice = 0x%X, const VkDeviceCreateInfo* pCreateInfo = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X, VkDevice* pDevice = 0x%X)",
physicalDevice, pCreateInfo, pAllocator, pDevice); physicalDevice, pCreateInfo, pAllocator, pDevice);
if(pCreateInfo->enabledLayerCount || pCreateInfo->enabledExtensionCount) if(pCreateInfo->enabledLayerCount)
{ {
UNIMPLEMENTED(); // "The ppEnabledLayerNames and enabledLayerCount members of VkDeviceCreateInfo are deprecated and their values must be ignored by implementations."
UNIMPLEMENTED(); // TODO(b/119321052): UNIMPLEMENTED() should be used only for features that must still be implemented. Use a more informational macro here.
} }
if(pCreateInfo->pNext) const VkBaseInStructure* extensionCreateInfo = reinterpret_cast<const VkBaseInStructure*>(pCreateInfo->pNext);
while(extensionCreateInfo)
{ {
switch(*reinterpret_cast<const VkStructureType*>(pCreateInfo->pNext)) switch(extensionCreateInfo->sType)
{ {
case VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO: case VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO:
// According to the Vulkan spec, section 2.7.2. Implicit Valid Usage: // According to the Vulkan spec, section 2.7.2. Implicit Valid Usage:
...@@ -220,9 +223,59 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(VkPhysicalDevice physicalDevice, c ...@@ -220,9 +223,59 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(VkPhysicalDevice physicalDevice, c
// internal use by the loader, and do not have corresponding // internal use by the loader, and do not have corresponding
// Vulkan structures in this Specification." // Vulkan structures in this Specification."
break; break;
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2:
{
ASSERT(!pCreateInfo->pEnabledFeatures); // "If the pNext chain includes a VkPhysicalDeviceFeatures2 structure, then pEnabledFeatures must be NULL"
const VkPhysicalDeviceFeatures2* physicalDeviceFeatures2 = reinterpret_cast<const VkPhysicalDeviceFeatures2*>(extensionCreateInfo);
if(!vk::Cast(physicalDevice)->hasFeatures(physicalDeviceFeatures2->features))
{
return VK_ERROR_FEATURE_NOT_PRESENT;
}
}
break;
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES:
{
const VkPhysicalDeviceSamplerYcbcrConversionFeatures* samplerYcbcrConversionFeatures = reinterpret_cast<const VkPhysicalDeviceSamplerYcbcrConversionFeatures*>(extensionCreateInfo);
if(samplerYcbcrConversionFeatures->samplerYcbcrConversion == VK_TRUE)
{
return VK_ERROR_FEATURE_NOT_PRESENT;
}
}
break;
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES:
{
const VkPhysicalDevice16BitStorageFeatures* storage16BitFeatures = reinterpret_cast<const VkPhysicalDevice16BitStorageFeatures*>(extensionCreateInfo);
if(storage16BitFeatures->storageBuffer16BitAccess == VK_TRUE ||
storage16BitFeatures->uniformAndStorageBuffer16BitAccess == VK_TRUE ||
storage16BitFeatures->storagePushConstant16 == VK_TRUE ||
storage16BitFeatures->storageInputOutput16 == VK_TRUE)
{
return VK_ERROR_FEATURE_NOT_PRESENT;
}
}
break;
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTER_FEATURES:
{
const VkPhysicalDeviceVariablePointerFeatures* variablePointerFeatures = reinterpret_cast<const VkPhysicalDeviceVariablePointerFeatures*>(extensionCreateInfo);
if(variablePointerFeatures->variablePointersStorageBuffer == VK_TRUE ||
variablePointerFeatures->variablePointers == VK_TRUE)
{
return VK_ERROR_FEATURE_NOT_PRESENT;
}
}
break;
default: default:
UNIMPLEMENTED(); // "the [driver] must skip over, without processing (other than reading the sType and pNext members) any structures in the chain with sType values not defined by [supported extenions]"
UNIMPLEMENTED(); // TODO(b/119321052): UNIMPLEMENTED() should be used only for features that must still be implemented. Use a more informational macro here.
break;
} }
extensionCreateInfo = extensionCreateInfo->pNext;
} }
ASSERT(pCreateInfo->queueCreateInfoCount > 0); ASSERT(pCreateInfo->queueCreateInfoCount > 0);
...@@ -231,6 +284,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(VkPhysicalDevice physicalDevice, c ...@@ -231,6 +284,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(VkPhysicalDevice physicalDevice, c
{ {
if(!vk::Cast(physicalDevice)->hasFeatures(*(pCreateInfo->pEnabledFeatures))) if(!vk::Cast(physicalDevice)->hasFeatures(*(pCreateInfo->pEnabledFeatures)))
{ {
UNIMPLEMENTED();
return VK_ERROR_FEATURE_NOT_PRESENT; return VK_ERROR_FEATURE_NOT_PRESENT;
} }
} }
...@@ -246,7 +300,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(VkPhysicalDevice physicalDevice, c ...@@ -246,7 +300,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(VkPhysicalDevice physicalDevice, c
} }
ASSERT(queueCreateInfo.queueFamilyIndex < queueFamilyPropertyCount); ASSERT(queueCreateInfo.queueFamilyIndex < queueFamilyPropertyCount);
(void)queueFamilyPropertyCount; // Slence unused variable warning (void)queueFamilyPropertyCount; // Silence unused variable warning
} }
vk::Device::CreateInfo deviceCreateInfo = vk::Device::CreateInfo deviceCreateInfo =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment