turnip: Gather some device info.

This commit is contained in:
Bas Nieuwenhuizen 2018-08-09 11:09:01 +02:00 committed by Chia-I Wu
parent 7922d50bd4
commit 13ff7ffbcb
3 changed files with 60 additions and 2 deletions

View File

@ -77,9 +77,13 @@ libvulkan_freedreno = shared_library(
'vulkan_freedreno',
[libtu_files, tu_entrypoints, tu_extensions_c, vk_format_table_c],
include_directories : [
inc_common, inc_compiler, inc_vulkan_util,
inc_common,
inc_compiler,
inc_vulkan_util,
inc_freedreno,
],
link_with : [
libfreedreno_drm,
libvulkan_util,
libmesa_util,
],

View File

@ -75,6 +75,8 @@ tu_physical_device_init(struct tu_physical_device *device,
drmVersionPtr version;
int fd;
int master_fd = -1;
struct fd_pipe *tmp_pipe = NULL;
uint64_t val;
fd = open(path, O_RDWR | O_CLOEXEC);
if (fd < 0) {
@ -130,7 +132,49 @@ tu_physical_device_init(struct tu_physical_device *device,
device->master_fd = master_fd;
device->local_fd = fd;
if (tu_device_get_cache_uuid(0 /* TODO */, device->cache_uuid)) {
device->drm_device = fd_device_new_dup(fd);
if (!device->drm_device) {
result = vk_errorf(
instance, VK_ERROR_INITIALIZATION_FAILED, "could not create the libdrm device");
goto fail;
}
tmp_pipe = fd_pipe_new(device->drm_device, FD_PIPE_3D);
if (!tmp_pipe) {
result = vk_errorf(
instance, VK_ERROR_INITIALIZATION_FAILED, "could not open the 3D pipe");
goto fail;
}
if (fd_pipe_get_param(tmp_pipe, FD_GPU_ID, &val)) {
result = vk_errorf(
instance, VK_ERROR_INITIALIZATION_FAILED, "could not get GPU ID");
goto fail;
}
device->gpu_id = val;
if (fd_pipe_get_param(tmp_pipe, FD_GMEM_SIZE, &val)) {
result = vk_errorf(
instance, VK_ERROR_INITIALIZATION_FAILED, "could not get GMEM size");
goto fail;
}
device->gmem_size = val;
fd_pipe_del(tmp_pipe);
tmp_pipe = NULL;
memset(device->name, 0, sizeof(device->name));
sprintf(device->name, "FD%d", device->gpu_id);
switch(device->gpu_id) {
case 530:
break;
default:
if (instance->debug_flags & TU_DEBUG_STARTUP)
tu_logi("Device '%s' is not supported.", device->name);
goto fail;
}
if (tu_device_get_cache_uuid(device->gpu_id, device->cache_uuid)) {
result = vk_errorf(
instance, VK_ERROR_INITIALIZATION_FAILED, "cannot generate UUID");
goto fail;
@ -160,6 +204,10 @@ tu_physical_device_init(struct tu_physical_device *device,
return VK_SUCCESS;
fail:
if (tmp_pipe)
fd_pipe_del(tmp_pipe);
if (device->drm_device)
fd_device_del(device->drm_device);
close(fd);
if (master_fd != -1)
close(master_fd);

View File

@ -66,6 +66,8 @@ typedef uint32_t xcb_window_t;
#include <vulkan/vulkan.h>
#include <vulkan/vulkan_intel.h>
#include "drm/freedreno_ringbuffer.h"
#include "tu_entrypoints.h"
#define MAX_VBS 32
@ -292,6 +294,10 @@ struct tu_physical_device
int local_fd;
int master_fd;
struct fd_device *drm_device;
unsigned gpu_id;
uint32_t gmem_size;
/* This is the drivers on-disk cache used as a fallback as opposed to
* the pipeline cache defined by apps.
*/