vfs_gpu: offer 'vfs_gpu_env' call

* retrieve Genode::Env from plugin, this way no mesa applications need to
  be changed.
* add 'vfs_gpu' api
* remove when all required functionality is implemented within the plugin.

issue #4380
This commit is contained in:
Sebastian Sumpf 2022-01-13 17:51:25 +01:00 committed by Norman Feske
parent b98e07ed34
commit a3976f0468
7 changed files with 65 additions and 5 deletions

View File

@ -0,0 +1 @@
REP_INC_DIR += src/lib/vfs/gpu

View File

@ -0,0 +1,3 @@
_Z11vfs_gpu_envv T
_Z18vfs_gpu_connectionm T
vfs_file_system_factory T

View File

@ -0,0 +1,13 @@
MIRROR_FROM_REP_DIR := \
src/lib/vfs/gpu/vfs_gpu.h \
lib/import/import-vfs_gpu.mk \
lib/symbols/vfs_gpu
content: $(MIRROR_FROM_REP_DIR)
$(MIRROR_FROM_REP_DIR):
$(mirror_from_rep_dir)
LICENSE:
cp $(GENODE_DIR)/LICENSE $@

View File

@ -0,0 +1 @@
2022-01-14-b 717f2b436a763c3ac1a752ae3fa9b194c786f1a9

View File

@ -0,0 +1 @@
vfs_gpu

View File

@ -21,6 +21,8 @@
#include <util/xml_generator.h>
#include <vfs/single_file_system.h>
#include "vfs_gpu.h"
namespace Vfs_gpu
{
using namespace Vfs;
@ -135,10 +137,9 @@ struct Vfs_gpu::File_system : Single_file_system
static Vfs_gpu::File_system *_fs { nullptr };
/**
* XXX: return GPU session for given ID, retrieved by 'stat->inode'.
* This function is used, for example, by libdrm via (dlopen/dlsym).
* This function is used, for example, by libdrm
*/
Gpu::Connection *vfs_gpu_connection(unsigned long id)
{
@ -149,15 +150,25 @@ Gpu::Connection *vfs_gpu_connection(unsigned long id)
try {
return _fs->_handle_space.apply<Gpu_vfs_handle>(
Id_space::Id { .value = id },
[] (Gpu_vfs_handle &handle) {
return &handle._gpu_session; });
Id_space::Id { .value = id },
[] (Gpu_vfs_handle &handle)
{
return &handle._gpu_session;
}
);
} catch (...) { }
return nullptr;
}
static Vfs::Env *_env { nullptr };
Genode::Env *vfs_gpu_env()
{
return _env ? &_env->env() : nullptr;
}
/**************************
** VFS plugin interface **
**************************/
@ -169,6 +180,7 @@ extern "C" Vfs::File_system_factory *vfs_file_system_factory(void)
Vfs::File_system *create(Vfs::Env &vfs_env,
Genode::Xml_node node) override
{
_env = &vfs_env;
try {
_fs = new (vfs_env.alloc()) Vfs_gpu::File_system(vfs_env, node);
return _fs;

View File

@ -0,0 +1,29 @@
/*
* \brief Public interface for libdrm
* \author Sebastian Sumpf
* \date 2022-01-14
*
* This is a interim solution becaues libdrm currently needs access to the
* GPU::Connection and Genode::Env. Once all the necessary features are provided
* by this plugin this interface is removed.
*/
/*
* Copyright (C) 2022 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
#ifndef _VFS_GPU_H_
#define _VFS_GPU_H_
namespace Gpu { class Connection; }
Gpu::Connection *vfs_gpu_connection(unsigned long);
namespace Genode { class Env; }
Genode::Env *vfs_gpu_env();
#endif /* _VFS_GPU_H_ */