diff options
Diffstat (limited to 'src/freedreno')
-rw-r--r-- | src/freedreno/vulkan/meson.build | 6 | ||||
-rw-r--r-- | src/freedreno/vulkan/tu_device.c | 50 | ||||
-rw-r--r-- | src/freedreno/vulkan/tu_private.h | 6 |
3 files changed, 60 insertions, 2 deletions
diff --git a/src/freedreno/vulkan/meson.build b/src/freedreno/vulkan/meson.build index b7de6bd5bb8..a9380509afc 100644 --- a/src/freedreno/vulkan/meson.build +++ b/src/freedreno/vulkan/meson.build @@ -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, ], diff --git a/src/freedreno/vulkan/tu_device.c b/src/freedreno/vulkan/tu_device.c index 7e0f7638b8c..9e47c19c61c 100644 --- a/src/freedreno/vulkan/tu_device.c +++ b/src/freedreno/vulkan/tu_device.c @@ -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); diff --git a/src/freedreno/vulkan/tu_private.h b/src/freedreno/vulkan/tu_private.h index 2f035951956..21237fd14e7 100644 --- a/src/freedreno/vulkan/tu_private.h +++ b/src/freedreno/vulkan/tu_private.h @@ -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. */ |