v3dv: pretend to initialize a physical device

Just to keep us moving forward for now. Later, we should probably
revisit this after running on real hardware or after enabling
the simulator.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
This commit is contained in:
Iago Toral Quiroga 2019-11-28 09:48:29 +01:00 committed by Marge Bot
parent 36e07a0ab9
commit fc52dc8d7d
2 changed files with 29 additions and 2 deletions

View file

@ -22,6 +22,7 @@
*/
#include <assert.h>
#include <fcntl.h>
#include <stdbool.h>
#include <string.h>
#include <sys/mman.h>
@ -205,7 +206,9 @@ v3dv_CreateInstance(const VkInstanceCreateInfo *pCreateInfo,
static void
physical_device_finish(struct v3dv_physical_device *device)
{
/* FIXME: stub */
close(device->local_fd);
if (device->master_fd >= 0)
close(device->master_fd);
}
void
@ -240,7 +243,25 @@ physical_device_init(struct v3dv_physical_device *device,
struct v3dv_instance *instance,
drmDevicePtr drm_device)
{
/* FIXME stub */
const char *path = drm_device->nodes[DRM_NODE_RENDER];
int32_t fd = open(path, O_RDWR | O_CLOEXEC);
if (fd < 0)
return vk_error(instance, VK_ERROR_INCOMPATIBLE_DRIVER);
device->_loader_data.loaderMagic = ICD_LOADER_MAGIC;
device->instance = instance;
assert(strlen(path) < ARRAY_SIZE(device->path));
snprintf(device->path, ARRAY_SIZE(device->path), "%s", path);
/* FIXME: we will have to do plenty more here */
device->name = "Broadcom Video Core VI";
device->local_fd = fd;
device->master_fd = -1;
uint8_t zeroes[VK_UUID_SIZE] = { 0 };
memcpy(device->pipeline_cache_uuid, zeroes, VK_UUID_SIZE);
return VK_SUCCESS;
}

View file

@ -85,6 +85,12 @@ struct v3dv_physical_device {
struct v3dv_device_extension_table supported_extensions;
struct v3dv_physical_device_dispatch_table dispatch;
char path[20];
const char *name;
int32_t local_fd;
int32_t master_fd;
uint8_t pipeline_cache_uuid[VK_UUID_SIZE];
/* FIXME: stub */
};