Commit 9e4d040c by Alexis Hetu Committed by Alexis Hétu

Device and PhysicalDevice features and properties

This cl adds basic functionality to Device and PhysicalDevice features and properties. Every setting and feature is either set to the most basic setting, or disabled, when possible. Bug b/117974925 Change-Id: Ib96630076b8e07e92c59fdf3ae902eeac00639bb Reviewed-on: https://swiftshader-review.googlesource.com/c/21589Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Tested-by: 's avatarAlexis Hétu <sugoi@google.com>
parent a9999ce9
......@@ -15,6 +15,7 @@
#include "VkConfig.h"
#include "VkDebug.hpp"
#include "VkDevice.hpp"
#include "VkQueue.hpp"
#include <new> // Must #include this to use "placement new"
namespace vk
......@@ -65,4 +66,30 @@ VkQueue Device::getQueue(uint32_t queueFamilyIndex, uint32_t queueIndex) const
return queues[queueIndex];
}
void Device::getImageSparseMemoryRequirements(VkImage pImage, uint32_t* pSparseMemoryRequirementCount,
VkSparseImageMemoryRequirements* pSparseMemoryRequirements) const
{
if(!pSparseMemoryRequirements)
{
*pSparseMemoryRequirementCount = 1;
}
else
{
UNIMPLEMENTED();
}
}
void Device::getGroupPeerMemoryFeatures(uint32_t heapIndex, uint32_t localDeviceIndex, uint32_t remoteDeviceIndex,
VkPeerMemoryFeatureFlags* pPeerMemoryFeatures) const
{
UNIMPLEMENTED();
}
void Device::getDescriptorSetLayoutSupport(const VkDescriptorSetLayoutCreateInfo* pCreateInfo,
VkDescriptorSetLayoutSupport* pSupport) const
{
// Mark everything as unsupported
pSupport->supported = VK_FALSE;
}
} // namespace vk
......@@ -16,11 +16,12 @@
#define VK_DEVICE_HPP_
#include "VkObject.hpp"
#include "VkQueue.hpp"
namespace vk
{
class Queue;
class Device
{
public:
......@@ -38,6 +39,12 @@ public:
static size_t ComputeRequiredAllocationSize(const CreateInfo* info);
VkQueue getQueue(uint32_t queueFamilyIndex, uint32_t queueIndex) const;
void getImageSparseMemoryRequirements(VkImage image, uint32_t* pSparseMemoryRequirementCount,
VkSparseImageMemoryRequirements* pSparseMemoryRequirements) const;
void getGroupPeerMemoryFeatures(uint32_t heapIndex, uint32_t localDeviceIndex, uint32_t remoteDeviceIndex,
VkPeerMemoryFeatureFlags* pPeerMemoryFeatures) const;
void getDescriptorSetLayoutSupport(const VkDescriptorSetLayoutCreateInfo* pCreateInfo,
VkDescriptorSetLayoutSupport* pSupport) const;
private:
VkPhysicalDevice physicalDevice = VK_NULL_HANDLE;
......
......@@ -87,6 +87,44 @@ const VkPhysicalDeviceFeatures& PhysicalDevice::getFeatures() const
return features;
}
void PhysicalDevice::getFeatures(VkPhysicalDeviceSamplerYcbcrConversionFeatures* features) const
{
features->samplerYcbcrConversion = VK_FALSE;
}
void PhysicalDevice::getFeatures(VkPhysicalDevice16BitStorageFeatures* features) const
{
features->storageBuffer16BitAccess = VK_FALSE;
features->storageInputOutput16 = VK_FALSE;
features->storagePushConstant16 = VK_FALSE;
features->uniformAndStorageBuffer16BitAccess = VK_FALSE;
}
void PhysicalDevice::getFeatures(VkPhysicalDeviceVariablePointerFeatures* features) const
{
features->variablePointersStorageBuffer = VK_FALSE;
features->variablePointers = VK_FALSE;
}
void PhysicalDevice::getFeatures(VkPhysicalDevice8BitStorageFeaturesKHR* features) const
{
features->storageBuffer8BitAccess = VK_FALSE;
features->uniformAndStorageBuffer8BitAccess = VK_FALSE;
features->storagePushConstant8 = VK_FALSE;
}
void PhysicalDevice::getFeatures(VkPhysicalDeviceMultiviewFeatures* features) const
{
features->multiview = VK_FALSE;
features->multiviewGeometryShader = VK_FALSE;
features->multiviewTessellationShader = VK_FALSE;
}
void PhysicalDevice::getFeatures(VkPhysicalDeviceProtectedMemoryFeatures* features) const
{
features->protectedMemory = VK_FALSE;
}
VkSampleCountFlags PhysicalDevice::getSampleCounts() const
{
return VK_SAMPLE_COUNT_1_BIT | VK_SAMPLE_COUNT_4_BIT;
......@@ -233,6 +271,46 @@ const VkPhysicalDeviceProperties& PhysicalDevice::getProperties() const
return properties;
}
void PhysicalDevice::getProperties(VkPhysicalDeviceIDProperties* properties) const
{
memcpy(properties->deviceUUID, SWIFTSHADER_UUID, VK_UUID_SIZE);
memset(properties->deviceLUID, 0, VK_LUID_SIZE);
memset(properties->driverUUID, 0, VK_UUID_SIZE);
*((uint64_t*)properties->driverUUID) = DRIVER_VERSION;
properties->deviceNodeMask = 0;
properties->deviceLUIDValid = VK_FALSE;
}
void PhysicalDevice::getProperties(VkPhysicalDeviceMaintenance3Properties* properties) const
{
properties->maxMemoryAllocationSize = 1 << 31;
properties->maxPerSetDescriptors = 1024;
}
void PhysicalDevice::getProperties(VkPhysicalDeviceMultiviewProperties* properties) const
{
properties->maxMultiviewInstanceIndex = (1 << 27) - 1;
properties->maxMultiviewViewCount = 6;
}
void PhysicalDevice::getProperties(VkPhysicalDevicePointClippingProperties* properties) const
{
properties->pointClippingBehavior = VK_POINT_CLIPPING_BEHAVIOR_ALL_CLIP_PLANES;
}
void PhysicalDevice::getProperties(VkPhysicalDeviceProtectedMemoryProperties* properties) const
{
properties->protectedNoFault = VK_FALSE;
}
void PhysicalDevice::getProperties(VkPhysicalDeviceSubgroupProperties* properties) const
{
properties->subgroupSize = 1;
properties->supportedStages = VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT | VK_SHADER_STAGE_COMPUTE_BIT;
properties->supportedOperations = VK_SUBGROUP_FEATURE_BASIC_BIT;
properties->quadOperationsInAllStages = VK_FALSE;
}
bool PhysicalDevice::hasFeatures(const VkPhysicalDeviceFeatures& requestedFeatures) const
{
const VkPhysicalDeviceFeatures& availableFeatures = getFeatures();
......@@ -383,4 +461,34 @@ const VkPhysicalDeviceMemoryProperties& PhysicalDevice::getMemoryProperties() co
return properties;
}
void PhysicalDevice::getExternalBufferProperties(const VkPhysicalDeviceExternalBufferInfo* pExternalBufferInfo,
VkExternalBufferProperties* pExternalBufferProperties) const
{
// FIXME: currently ignoring pExternalBufferInfo
pExternalBufferProperties->externalMemoryProperties.compatibleHandleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT;
pExternalBufferProperties->externalMemoryProperties.exportFromImportedHandleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT;
pExternalBufferProperties->externalMemoryProperties.externalMemoryFeatures = VK_EXTERNAL_MEMORY_FEATURE_DEDICATED_ONLY_BIT;
}
void PhysicalDevice::getExternalFenceProperties(const VkPhysicalDeviceExternalFenceInfo* pExternalFenceInfo,
VkExternalFenceProperties* pExternalFenceProperties) const
{
// FIXME: currently ignoring pExternalFenceInfo
pExternalFenceProperties->compatibleHandleTypes = VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_FD_BIT;
pExternalFenceProperties->exportFromImportedHandleTypes = VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_FD_BIT;
pExternalFenceProperties->externalFenceFeatures = VK_EXTERNAL_FENCE_FEATURE_EXPORTABLE_BIT;
}
void PhysicalDevice::getExternalSemaphoreProperties(const VkPhysicalDeviceExternalSemaphoreInfo* pExternalSemaphoreInfo,
VkExternalSemaphoreProperties* pExternalSemaphoreProperties) const
{
// FIXME: currently ignoring pExternalSemaphoreInfo
pExternalSemaphoreProperties->compatibleHandleTypes = VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT;
pExternalSemaphoreProperties->exportFromImportedHandleTypes = VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT;
pExternalSemaphoreProperties->externalSemaphoreFeatures = VK_EXTERNAL_SEMAPHORE_FEATURE_EXPORTABLE_BIT;
}
} // namespace vk
......@@ -31,8 +31,22 @@ public:
static size_t ComputeRequiredAllocationSize(const void*) { return 0; }
const VkPhysicalDeviceFeatures& getFeatures() const;
void getFeatures(VkPhysicalDeviceSamplerYcbcrConversionFeatures* features) const;
void getFeatures(VkPhysicalDevice16BitStorageFeatures* features) const;
void getFeatures(VkPhysicalDeviceVariablePointerFeatures* features) const;
void getFeatures(VkPhysicalDevice8BitStorageFeaturesKHR* features) const;
void getFeatures(VkPhysicalDeviceMultiviewFeatures* features) const;
void getFeatures(VkPhysicalDeviceProtectedMemoryFeatures* features) const;
bool hasFeatures(const VkPhysicalDeviceFeatures& requestedFeatures) const;
const VkPhysicalDeviceProperties& getProperties() const;
void getProperties(VkPhysicalDeviceIDProperties* properties) const;
void getProperties(VkPhysicalDeviceMaintenance3Properties* properties) const;
void getProperties(VkPhysicalDeviceMultiviewProperties* properties) const;
void getProperties(VkPhysicalDevicePointClippingProperties* properties) const;
void getProperties(VkPhysicalDeviceProtectedMemoryProperties* properties) const;
void getProperties(VkPhysicalDeviceSubgroupProperties* properties) const;
void getFormatProperties(VkFormat format, VkFormatProperties* pFormatProperties) const;
void getImageFormatProperties(VkFormat format, VkImageType type, VkImageTiling tiling,
VkImageUsageFlags usage, VkImageCreateFlags flags,
......@@ -41,6 +55,12 @@ public:
void getQueueFamilyProperties(uint32_t pQueueFamilyPropertyCount,
VkQueueFamilyProperties* pQueueFamilyProperties) const;
const VkPhysicalDeviceMemoryProperties& getMemoryProperties() const;
void getExternalBufferProperties(const VkPhysicalDeviceExternalBufferInfo* pExternalBufferInfo,
VkExternalBufferProperties* pExternalBufferProperties) const;
void getExternalFenceProperties(const VkPhysicalDeviceExternalFenceInfo* pExternalFenceInfo,
VkExternalFenceProperties* pExternalFenceProperties) const;
void getExternalSemaphoreProperties(const VkPhysicalDeviceExternalSemaphoreInfo* pExternalSemaphoreInfo,
VkExternalSemaphoreProperties* pExternalSemaphoreProperties) const;
private:
const VkPhysicalDeviceLimits& getLimits() const;
......
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