mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-04-09 20:30:35 +02:00
nvk: advertize memory heaps and types
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
This commit is contained in:
parent
b2b13b1944
commit
cd4e67c536
3 changed files with 43 additions and 1 deletions
|
|
@ -176,6 +176,27 @@ nvk_physical_device_try_create(struct nvk_instance *instance,
|
|||
device->instance = instance;
|
||||
device->dev = ndev;
|
||||
|
||||
device->mem_heaps[0].flags = VK_MEMORY_HEAP_DEVICE_LOCAL_BIT;
|
||||
device->mem_types[0].propertyFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
|
||||
device->mem_types[0].heapIndex = 0;
|
||||
|
||||
if (ndev->vram_size) {
|
||||
device->mem_type_cnt = 2;
|
||||
device->mem_heap_cnt = 2;
|
||||
|
||||
device->mem_heaps[0].size = ndev->vram_size;
|
||||
device->mem_heaps[1].size = ndev->gart_size;
|
||||
device->mem_heaps[1].flags = 0;
|
||||
device->mem_types[1].heapIndex = 1;
|
||||
device->mem_types[1].propertyFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT;
|
||||
} else {
|
||||
device->mem_type_cnt = 1;
|
||||
device->mem_heap_cnt = 1;
|
||||
|
||||
device->mem_heaps[0].size = ndev->gart_size;
|
||||
device->mem_types[0].propertyFlags |= VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT;
|
||||
}
|
||||
|
||||
*device_out = device;
|
||||
|
||||
return VK_SUCCESS;
|
||||
|
|
@ -296,6 +317,18 @@ VKAPI_ATTR void VKAPI_CALL
|
|||
nvk_GetPhysicalDeviceMemoryProperties2(VkPhysicalDevice physicalDevice,
|
||||
VkPhysicalDeviceMemoryProperties2 *pMemoryProperties)
|
||||
{
|
||||
VK_FROM_HANDLE(nvk_physical_device, pdevice, physicalDevice);
|
||||
|
||||
pMemoryProperties->memoryProperties.memoryHeapCount = pdevice->mem_heap_cnt;
|
||||
for (int i = 0; i < pdevice->mem_heap_cnt; i++) {
|
||||
pMemoryProperties->memoryProperties.memoryHeaps[i] = pdevice->mem_heaps[i];
|
||||
}
|
||||
|
||||
pMemoryProperties->memoryProperties.memoryTypeCount = pdevice->mem_type_cnt;
|
||||
for (int i = 0; i < pdevice->mem_type_cnt; i++) {
|
||||
pMemoryProperties->memoryProperties.memoryTypes[i] = pdevice->mem_types[i];
|
||||
}
|
||||
|
||||
vk_foreach_struct(ext, pMemoryProperties->pNext)
|
||||
{
|
||||
switch (ext->sType) {
|
||||
|
|
|
|||
|
|
@ -16,6 +16,12 @@ struct nvk_physical_device {
|
|||
|
||||
/* Link in nvk_instance::physical_devices */
|
||||
struct list_head link;
|
||||
|
||||
// TODO: add mapable VRAM heap if possible
|
||||
VkMemoryHeap mem_heaps[2];
|
||||
VkMemoryType mem_types[2];
|
||||
uint8_t mem_heap_cnt;
|
||||
uint8_t mem_type_cnt;
|
||||
};
|
||||
|
||||
VK_DEFINE_HANDLE_CASTS(nvk_physical_device,
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "util/os_misc.h"
|
||||
|
||||
struct nouveau_ws_device_priv {
|
||||
struct nouveau_ws_device base;
|
||||
struct nouveau_drm *drm;
|
||||
|
|
@ -49,7 +51,8 @@ nouveau_ws_device_new(int fd)
|
|||
device->base.device_id = device_id;
|
||||
device->base.chipset = dev->chipset;
|
||||
device->base.vram_size = dev->vram_size;
|
||||
device->base.gart_size = dev->gart_size;
|
||||
os_get_available_system_memory(&device->base.gart_size);
|
||||
device->base.gart_size = MIN2(device->base.gart_size, dev->gart_size);
|
||||
device->base.is_integrated = dev->vram_size == 0;
|
||||
device->drm = drm;
|
||||
device->dev = dev;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue