vk/0.130: Implement vkGetPhysicalDeviceMemoryProperties()

This commit is contained in:
Chad Versace 2015-07-09 19:49:19 -07:00
parent c7f512721c
commit df2a013881
2 changed files with 57 additions and 2 deletions

View file

@ -910,6 +910,11 @@ typedef enum {
} VkMemoryPropertyFlagBits;
typedef VkFlags VkMemoryPropertyFlags;
typedef enum {
VK_MEMORY_HEAP_HOST_LOCAL = 0x00000001,
} VkMemoryHeapFlagBits;
typedef VkFlags VkMemoryHeapFlags;
typedef enum {
VK_DEVICE_CREATE_VALIDATION_BIT = 0x00000001,
} VkDeviceCreateFlagBits;
@ -1272,8 +1277,20 @@ typedef struct {
} VkPhysicalDeviceQueueProperties;
typedef struct {
bool32_t supportsMigration;
bool32_t supportsPinning;
VkMemoryPropertyFlags propertyFlags;
uint32_t heapIndex;
} VkMemoryType;
typedef struct {
VkDeviceSize size;
VkMemoryHeapFlags flags;
} VkMemoryHeap;
typedef struct {
uint32_t memoryTypeCount;
VkMemoryType memoryTypes[VK_MAX_MEMORY_TYPES];
uint32_t memoryHeapCount;
VkMemoryHeap memoryHeaps[VK_MAX_MEMORY_HEAPS];
} VkPhysicalDeviceMemoryProperties;
typedef void (VKAPI *PFN_vkVoidFunction)(void);
@ -1962,6 +1979,7 @@ typedef VkResult (VKAPI *PFN_vkGetPhysicalDeviceLimits)(VkPhysicalDevice physica
typedef VkResult (VKAPI *PFN_vkGetPhysicalDeviceProperties)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties* pProperties);
typedef VkResult (VKAPI *PFN_vkGetPhysicalDeviceQueueCount)(VkPhysicalDevice physicalDevice, uint32_t* pCount);
typedef VkResult (VKAPI *PFN_vkGetPhysicalDeviceQueueProperties)(VkPhysicalDevice physicalDevice, uint32_t count, VkPhysicalDeviceQueueProperties* pQueueProperties);
typedef VkResult (VKAPI *PFN_vkGetPhysicalDeviceMemoryProperties)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceMemoryProperties* pMemoryProperies);
typedef PFN_vkVoidFunction (VKAPI *PFN_vkGetInstanceProcAddr)(VkInstance instance, const char* pName);
typedef PFN_vkVoidFunction (VKAPI *PFN_vkGetDeviceProcAddr)(VkDevice device, const char* pName);
typedef VkResult (VKAPI *PFN_vkCreateDevice)(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo* pCreateInfo, VkDevice* pDevice);
@ -2108,6 +2126,10 @@ VkResult VKAPI vkGetPhysicalDeviceQueueProperties(
uint32_t count,
VkPhysicalDeviceQueueProperties* pQueueProperties);
VkResult VKAPI vkGetPhysicalDeviceMemoryProperties(
VkPhysicalDevice physicalDevice,
VkPhysicalDeviceMemoryProperties* pMemoryProperies);
PFN_vkVoidFunction VKAPI vkGetInstanceProcAddr(
VkInstance instance,
const char* pName);

View file

@ -422,6 +422,39 @@ VkResult anv_GetPhysicalDeviceQueueProperties(
return VK_SUCCESS;
}
VkResult anv_GetPhysicalDeviceMemoryProperties(
VkPhysicalDevice physicalDevice,
VkPhysicalDeviceMemoryProperties* pMemoryProperties)
{
ANV_FROM_HANDLE(anv_physical_device, physical_device, physicalDevice);
size_t aperture_size;
size_t heap_size;
if (anv_gem_get_aperture(physical_device, &aperture_size) == -1)
return vk_error(VK_ERROR_UNAVAILABLE);
/* Reserve some wiggle room for the driver by exposing only 75% of the
* aperture to the heap.
*/
heap_size = 3 * aperture_size / 4;
/* The property flags below are valid only for llc platforms. */
pMemoryProperties->memoryTypeCount = 1;
pMemoryProperties->memoryTypes[0] = (VkMemoryType) {
.propertyFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT,
.heapIndex = 1,
};
pMemoryProperties->memoryHeapCount = 1;
pMemoryProperties->memoryHeaps[0] = (VkMemoryHeap) {
.size = heap_size,
.flags = VK_MEMORY_HEAP_HOST_LOCAL,
};
return VK_SUCCESS;
}
PFN_vkVoidFunction anv_GetInstanceProcAddr(
VkInstance instance,
const char* pName)