[Mesa-dev] [PATCH 4/5] gallium: replace DRM_CONF_SHARE_FD with PIPE_CAP_DMABUF
Marek Olšák
maraeo at gmail.com
Tue Apr 23 01:23:47 UTC 2019
From: Marek Olšák <marek.olsak at amd.com>
---
src/gallium/auxiliary/target-helpers/drm_helper.h | 11 -----------
src/gallium/auxiliary/util/u_screen.c | 7 +++++++
src/gallium/docs/source/screen.rst | 2 ++
src/gallium/include/pipe/p_defines.h | 1 +
src/gallium/include/state_tracker/drm_driver.h | 6 ------
src/gallium/state_trackers/dri/dri2.c | 5 +----
src/gallium/targets/d3dadapter9/drm.c | 4 +---
src/gallium/targets/pipe-loader/pipe_i915.c | 11 -----------
src/gallium/targets/pipe-loader/pipe_msm.c | 11 -----------
src/gallium/targets/pipe-loader/pipe_nouveau.c | 11 -----------
src/gallium/targets/pipe-loader/pipe_r300.c | 11 -----------
src/gallium/targets/pipe-loader/pipe_r600.c | 11 -----------
src/gallium/targets/pipe-loader/pipe_radeonsi.c | 7 -------
src/gallium/targets/pipe-loader/pipe_vmwgfx.c | 11 -----------
14 files changed, 12 insertions(+), 97 deletions(-)
diff --git a/src/gallium/auxiliary/target-helpers/drm_helper.h b/src/gallium/auxiliary/target-helpers/drm_helper.h
index a89c47e4861..101e0e2c22c 100644
--- a/src/gallium/auxiliary/target-helpers/drm_helper.h
+++ b/src/gallium/auxiliary/target-helpers/drm_helper.h
@@ -1,33 +1,22 @@
#ifndef DRM_HELPER_H
#define DRM_HELPER_H
#include <stdio.h>
#include "target-helpers/inline_debug_helper.h"
#include "target-helpers/drm_helper_public.h"
#include "state_tracker/drm_driver.h"
#include "util/xmlpool.h"
-static const struct drm_conf_ret share_fd_ret = {
- .type = DRM_CONF_BOOL,
- .val.val_bool = true,
-};
-
const struct drm_conf_ret *
pipe_default_configuration_query(enum drm_conf conf)
{
- switch (conf) {
- case DRM_CONF_SHARE_FD:
- return &share_fd_ret;
- default:
- break;
- }
return NULL;
}
#ifdef GALLIUM_I915
#include "i915/drm/i915_drm_public.h"
#include "i915/i915_public.h"
struct pipe_screen *
pipe_i915_create_screen(int fd, const struct pipe_screen_config *config)
{
diff --git a/src/gallium/auxiliary/util/u_screen.c b/src/gallium/auxiliary/util/u_screen.c
index 6864c76c355..8857cf2beef 100644
--- a/src/gallium/auxiliary/util/u_screen.c
+++ b/src/gallium/auxiliary/util/u_screen.c
@@ -348,14 +348,21 @@ u_pipe_screen_get_param_defaults(struct pipe_screen *pscreen,
case PIPE_CAP_MAX_VARYINGS:
return 8;
case PIPE_CAP_COMPUTE_GRID_INFO_LAST_BLOCK:
return 0;
case PIPE_CAP_COMPUTE_SHADER_DERIVATIVES:
case PIPE_CAP_MAX_FRAMES_IN_FLIGHT:
return 0;
+ case PIPE_CAP_DMABUF:
+#ifdef PIPE_OS_LINUX
+ return 1;
+#else
+ return 0;
+#endif
+
default:
unreachable("bad PIPE_CAP_*");
}
}
diff --git a/src/gallium/docs/source/screen.rst b/src/gallium/docs/source/screen.rst
index 20ee9a29c34..fdcdcecb0f2 100644
--- a/src/gallium/docs/source/screen.rst
+++ b/src/gallium/docs/source/screen.rst
@@ -512,20 +512,22 @@ The integer capabilities:
* ``PIPE_CAP_TGSI_SKIP_SHRINK_IO_ARRAYS``: Whether the TGSI pass to shrink IO
arrays should be skipped and enforce keeping the declared array sizes instead.
A driver might rely on the input mapping that was defined with the original
GLSL code.
* ``PIPE_CAP_IMAGE_LOAD_FORMATTED``: True if a format for image loads does not need to be specified in the shader IR
* ``PIPE_CAP_PREFER_COMPUTE_BLIT_FOR_MULTIMEDIA``: Whether VDPAU, VAAPI, and
OpenMAX should use a compute-based blit instead of pipe_context::blit.
* ``PIPE_CAP_MAX_FRAMES_IN_FLIGHT``: Maximum number of frames that state
trackers should allow to be in flight before throttling pipe_context
execution. 0 = throttling is disabled.
+* ``PIPE_CAP_DMABUF``: Whether Linux DMABUF handles are supported by
+ resource_from_handle and resource_get_handle.
.. _pipe_capf:
PIPE_CAPF_*
^^^^^^^^^^^^^^^^
The floating-point capabilities are:
* ``PIPE_CAPF_MAX_LINE_WIDTH``: The maximum width of a regular line.
* ``PIPE_CAPF_MAX_LINE_WIDTH_AA``: The maximum width of a smoothed line.
diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h
index e626193ccaf..a1514b6d9a2 100644
--- a/src/gallium/include/pipe/p_defines.h
+++ b/src/gallium/include/pipe/p_defines.h
@@ -874,20 +874,21 @@ enum pipe_cap
PIPE_CAP_RGB_OVERRIDE_DST_ALPHA_BLEND,
PIPE_CAP_DEST_SURFACE_SRGB_CONTROL,
PIPE_CAP_NIR_COMPACT_ARRAYS,
PIPE_CAP_MAX_VARYINGS,
PIPE_CAP_COMPUTE_GRID_INFO_LAST_BLOCK,
PIPE_CAP_COMPUTE_SHADER_DERIVATIVES,
PIPE_CAP_TGSI_SKIP_SHRINK_IO_ARRAYS,
PIPE_CAP_IMAGE_LOAD_FORMATTED,
PIPE_CAP_PREFER_COMPUTE_BLIT_FOR_MULTIMEDIA,
PIPE_CAP_MAX_FRAMES_IN_FLIGHT,
+ PIPE_CAP_DMABUF,
};
/**
* Possible bits for PIPE_CAP_CONTEXT_PRIORITY_MASK param, which should
* return a bitmask of the supported priorities. If the driver does not
* support prioritized contexts, it can return 0.
*
* Note that these match __DRI2_RENDER_HAS_CONTEXT_PRIORITY_*
*/
#define PIPE_CONTEXT_PRIORITY_LOW (1 << 0)
diff --git a/src/gallium/include/state_tracker/drm_driver.h b/src/gallium/include/state_tracker/drm_driver.h
index 8094734b672..3f52f1be885 100644
--- a/src/gallium/include/state_tracker/drm_driver.h
+++ b/src/gallium/include/state_tracker/drm_driver.h
@@ -8,44 +8,38 @@
struct pipe_screen;
struct pipe_screen_config;
struct pipe_context;
struct pipe_resource;
/**
* Configuration queries.
*/
enum drm_conf {
- /* Can this driver, running on this kernel, import and export dma-buf fds? */
- DRM_CONF_SHARE_FD, /* DRM_CONF_BOOL. */
/* XML string describing the available config options. */
DRM_CONF_XML_OPTIONS, /* DRM_CONF_POINTER */
DRM_CONF_MAX
};
/**
* Type of configuration answer
*/
enum drm_conf_type {
- DRM_CONF_BOOL,
- DRM_CONF_FLOAT,
DRM_CONF_POINTER
};
/**
* Return value from the configuration function.
*/
struct drm_conf_ret {
enum drm_conf_type type;
union {
- bool val_bool;
- float val_float;
void *val_pointer;
} val;
};
struct drm_driver_descriptor
{
/**
* Identifying prefix/suffix of the binary, used by the pipe-loader.
*/
const char *driver_name;
diff --git a/src/gallium/state_trackers/dri/dri2.c b/src/gallium/state_trackers/dri/dri2.c
index 2a4a6ac6dad..f7672bcae06 100644
--- a/src/gallium/state_trackers/dri/dri2.c
+++ b/src/gallium/state_trackers/dri/dri2.c
@@ -1901,21 +1901,20 @@ static const __DRIextension *dri_robust_screen_extensions[] = {
* This is the driver specific part of the createNewScreen entry point.
*
* Returns the struct gl_config supported by this driver.
*/
static const __DRIconfig **
dri2_init_screen(__DRIscreen * sPriv)
{
const __DRIconfig **configs;
struct dri_screen *screen;
struct pipe_screen *pscreen = NULL;
- const struct drm_conf_ret *dmabuf_ret;
screen = CALLOC_STRUCT(dri_screen);
if (!screen)
return NULL;
screen->sPriv = sPriv;
screen->fd = sPriv->fd;
(void) mtx_init(&screen->opencl_func_mutex, mtx_plain);
sPriv->driverPrivate = (void *)screen;
@@ -1925,27 +1924,25 @@ dri2_init_screen(__DRIscreen * sPriv)
pscreen = pipe_loader_create_screen(screen->dev);
}
if (!pscreen)
goto release_pipe;
screen->default_throttle_frames =
pscreen->get_param(pscreen, PIPE_CAP_MAX_FRAMES_IN_FLIGHT);
- dmabuf_ret = pipe_loader_configuration(screen->dev, DRM_CONF_SHARE_FD);
-
if (pscreen->resource_create_with_modifiers)
dri2ImageExtension.createImageWithModifiers =
dri2_create_image_with_modifiers;
- if (dmabuf_ret && dmabuf_ret->val.val_bool) {
+ if (pscreen->get_param(pscreen, PIPE_CAP_DMABUF)) {
uint64_t cap;
if (drmGetCap(sPriv->fd, DRM_CAP_PRIME, &cap) == 0 &&
(cap & DRM_PRIME_CAP_IMPORT)) {
dri2ImageExtension.createImageFromFds = dri2_from_fds;
dri2ImageExtension.createImageFromDmaBufs = dri2_from_dma_bufs;
dri2ImageExtension.createImageFromDmaBufs2 = dri2_from_dma_bufs2;
if (pscreen->query_dmabuf_modifiers) {
dri2ImageExtension.queryDmaBufFormats = dri2_query_dma_buf_formats;
dri2ImageExtension.queryDmaBufModifiers =
diff --git a/src/gallium/targets/d3dadapter9/drm.c b/src/gallium/targets/d3dadapter9/drm.c
index 1c8460f7f03..4418ceb93d6 100644
--- a/src/gallium/targets/d3dadapter9/drm.c
+++ b/src/gallium/targets/d3dadapter9/drm.c
@@ -198,21 +198,20 @@ read_descriptor( struct d3dadapter9_context *ctx,
drvid->DeviceIdentifier.Data4[7] = 0x81;
}
static HRESULT WINAPI
drm_create_adapter( int fd,
ID3DAdapter9 **ppAdapter )
{
struct d3dadapter9drm_context *ctx = CALLOC_STRUCT(d3dadapter9drm_context);
HRESULT hr;
bool different_device;
- const struct drm_conf_ret *dmabuf_ret = NULL;
driOptionCache defaultInitOptions;
driOptionCache userInitOptions;
int throttling_value_user = -2;
int override_vendorid = -1;
if (!ctx) { return E_OUTOFMEMORY; }
ctx->base.destroy = drm_destroy;
/* Although the fd is provided from external source, mesa/nine
@@ -228,22 +227,21 @@ drm_create_adapter( int fd,
return D3DERR_DRIVERINTERNALERROR;
}
ctx->base.hal = pipe_loader_create_screen(ctx->dev);
if (!ctx->base.hal) {
ERR("Unable to load requested driver.\n");
drm_destroy(&ctx->base);
return D3DERR_DRIVERINTERNALERROR;
}
- dmabuf_ret = pipe_loader_configuration(ctx->dev, DRM_CONF_SHARE_FD);
- if (!dmabuf_ret || !dmabuf_ret->val.val_bool) {
+ if (!ctx->base.hal->get_param(ctx->base.hal, PIPE_CAP_DMABUF)) {
ERR("The driver is not capable of dma-buf sharing."
"Abandon to load nine state tracker\n");
drm_destroy(&ctx->base);
return D3DERR_DRIVERINTERNALERROR;
}
ctx->base.throttling_value =
ctx->base.hal->get_param(ctx->base.hal, PIPE_CAP_MAX_FRAMES_IN_FLIGHT);
ctx->base.throttling = ctx->base.throttling_value > 0;
diff --git a/src/gallium/targets/pipe-loader/pipe_i915.c b/src/gallium/targets/pipe-loader/pipe_i915.c
index 841990e0e23..61429858445 100644
--- a/src/gallium/targets/pipe-loader/pipe_i915.c
+++ b/src/gallium/targets/pipe-loader/pipe_i915.c
@@ -16,28 +16,17 @@ create_screen(int fd, const struct pipe_screen_config *config)
screen = i915_screen_create(iws);
if (!screen)
return NULL;
screen = debug_screen_wrap(screen);
return screen;
}
-static const struct drm_conf_ret share_fd_ret = {
- .type = DRM_CONF_BOOL,
- .val.val_bool = true,
-};
-
static const struct drm_conf_ret *drm_configuration(enum drm_conf conf)
{
- switch (conf) {
- case DRM_CONF_SHARE_FD:
- return &share_fd_ret;
- default:
- break;
- }
return NULL;
}
PUBLIC
DRM_DRIVER_DESCRIPTOR("i915", create_screen, drm_configuration)
diff --git a/src/gallium/targets/pipe-loader/pipe_msm.c b/src/gallium/targets/pipe-loader/pipe_msm.c
index eb38be586ac..004db95e78a 100644
--- a/src/gallium/targets/pipe-loader/pipe_msm.c
+++ b/src/gallium/targets/pipe-loader/pipe_msm.c
@@ -10,28 +10,17 @@ create_screen(int fd, const struct pipe_screen_config *config)
screen = fd_drm_screen_create(fd, NULL);
if (!screen)
return NULL;
screen = debug_screen_wrap(screen);
return screen;
}
-static const struct drm_conf_ret share_fd_ret = {
- .type = DRM_CONF_BOOL,
- .val.val_bool = true,
-};
-
static const struct drm_conf_ret *drm_configuration(enum drm_conf conf)
{
- switch (conf) {
- case DRM_CONF_SHARE_FD:
- return &share_fd_ret;
- default:
- break;
- }
return NULL;
}
PUBLIC
DRM_DRIVER_DESCRIPTOR("msm", create_screen, drm_configuration)
diff --git a/src/gallium/targets/pipe-loader/pipe_nouveau.c b/src/gallium/targets/pipe-loader/pipe_nouveau.c
index ead5a182738..9adba1c85c0 100644
--- a/src/gallium/targets/pipe-loader/pipe_nouveau.c
+++ b/src/gallium/targets/pipe-loader/pipe_nouveau.c
@@ -10,28 +10,17 @@ create_screen(int fd, const struct pipe_screen_config *config)
screen = nouveau_drm_screen_create(fd);
if (!screen)
return NULL;
screen = debug_screen_wrap(screen);
return screen;
}
-static const struct drm_conf_ret share_fd_ret = {
- .type = DRM_CONF_BOOL,
- .val.val_bool = true,
-};
-
static const struct drm_conf_ret *drm_configuration(enum drm_conf conf)
{
- switch (conf) {
- case DRM_CONF_SHARE_FD:
- return &share_fd_ret;
- default:
- break;
- }
return NULL;
}
PUBLIC
DRM_DRIVER_DESCRIPTOR("nouveau", create_screen, drm_configuration)
diff --git a/src/gallium/targets/pipe-loader/pipe_r300.c b/src/gallium/targets/pipe-loader/pipe_r300.c
index 2a03580223d..1c42f4e36ad 100644
--- a/src/gallium/targets/pipe-loader/pipe_r300.c
+++ b/src/gallium/targets/pipe-loader/pipe_r300.c
@@ -6,28 +6,17 @@
static struct pipe_screen *
create_screen(int fd, const struct pipe_screen_config *config)
{
struct radeon_winsys *sws;
sws = radeon_drm_winsys_create(fd, config, r300_screen_create);
return sws ? debug_screen_wrap(sws->screen) : NULL;
}
-static const struct drm_conf_ret share_fd_ret = {
- .type = DRM_CONF_BOOL,
- .val.val_bool = true,
-};
-
static const struct drm_conf_ret *drm_configuration(enum drm_conf conf)
{
- switch (conf) {
- case DRM_CONF_SHARE_FD:
- return &share_fd_ret;
- default:
- break;
- }
return NULL;
}
PUBLIC
DRM_DRIVER_DESCRIPTOR("r300", create_screen, drm_configuration)
diff --git a/src/gallium/targets/pipe-loader/pipe_r600.c b/src/gallium/targets/pipe-loader/pipe_r600.c
index a35e0a6179f..f5f1c446e2d 100644
--- a/src/gallium/targets/pipe-loader/pipe_r600.c
+++ b/src/gallium/targets/pipe-loader/pipe_r600.c
@@ -6,28 +6,17 @@
static struct pipe_screen *
create_screen(int fd, const struct pipe_screen_config *config)
{
struct radeon_winsys *rw;
rw = radeon_drm_winsys_create(fd, config, r600_screen_create);
return rw ? debug_screen_wrap(rw->screen) : NULL;
}
-static const struct drm_conf_ret share_fd_ret = {
- .type = DRM_CONF_BOOL,
- .val.val_bool = true,
-};
-
static const struct drm_conf_ret *drm_configuration(enum drm_conf conf)
{
- switch (conf) {
- case DRM_CONF_SHARE_FD:
- return &share_fd_ret;
- default:
- break;
- }
return NULL;
}
PUBLIC
DRM_DRIVER_DESCRIPTOR("r600", create_screen, drm_configuration)
diff --git a/src/gallium/targets/pipe-loader/pipe_radeonsi.c b/src/gallium/targets/pipe-loader/pipe_radeonsi.c
index 947c9e1990e..09c06b380d6 100644
--- a/src/gallium/targets/pipe-loader/pipe_radeonsi.c
+++ b/src/gallium/targets/pipe-loader/pipe_radeonsi.c
@@ -13,36 +13,29 @@ create_screen(int fd, const struct pipe_screen_config *config)
/* First, try amdgpu. */
rw = amdgpu_winsys_create(fd, config, radeonsi_screen_create);
if (!rw)
rw = radeon_drm_winsys_create(fd, config, radeonsi_screen_create);
return rw ? debug_screen_wrap(rw->screen) : NULL;
}
-static const struct drm_conf_ret share_fd_ret = {
- .type = DRM_CONF_BOOL,
- .val.val_bool = true,
-};
-
static const struct drm_conf_ret *drm_configuration(enum drm_conf conf)
{
static const struct drm_conf_ret xml_options_ret = {
.type = DRM_CONF_POINTER,
.val.val_pointer =
#include "radeonsi/si_driinfo.h"
};
switch (conf) {
- case DRM_CONF_SHARE_FD:
- return &share_fd_ret;
case DRM_CONF_XML_OPTIONS:
return &xml_options_ret;
default:
break;
}
return NULL;
}
PUBLIC
DRM_DRIVER_DESCRIPTOR("radeonsi", create_screen, drm_configuration)
diff --git a/src/gallium/targets/pipe-loader/pipe_vmwgfx.c b/src/gallium/targets/pipe-loader/pipe_vmwgfx.c
index 3b8c748594c..c4484e03344 100644
--- a/src/gallium/targets/pipe-loader/pipe_vmwgfx.c
+++ b/src/gallium/targets/pipe-loader/pipe_vmwgfx.c
@@ -16,28 +16,17 @@ create_screen(int fd, const struct pipe_screen_config *config)
screen = svga_screen_create(sws);
if (!screen)
return NULL;
screen = debug_screen_wrap(screen);
return screen;
}
-static const struct drm_conf_ret share_fd_ret = {
- .type = DRM_CONF_BOOL,
- .val.val_bool = true,
-};
-
static const struct drm_conf_ret *drm_configuration(enum drm_conf conf)
{
- switch (conf) {
- case DRM_CONF_SHARE_FD:
- return &share_fd_ret;
- default:
- break;
- }
return NULL;
}
PUBLIC
DRM_DRIVER_DESCRIPTOR("vmwgfx", create_screen, drm_configuration)
--
2.17.1
More information about the mesa-dev
mailing list