[Mesa-dev] [PATCH 2/4] nouveau: Populate PIPE_CAP_PRIME, enabling DRI Image 7 support
christopher.halse.rogers at canonical.com
christopher.halse.rogers at canonical.com
Sun Apr 21 23:38:05 PDT 2013
From: Christopher James Halse Rogers <raof at ubuntu.com>
---
src/gallium/drivers/nouveau/nouveau_screen.c | 19 ++++++++++++++++++-
src/gallium/drivers/nouveau/nouveau_screen.h | 2 ++
src/gallium/drivers/nv30/nv30_screen.c | 6 +++++-
src/gallium/drivers/nv50/nv50_screen.c | 5 ++++-
src/gallium/drivers/nvc0/nvc0_screen.c | 5 ++++-
5 files changed, 33 insertions(+), 4 deletions(-)
diff --git a/src/gallium/drivers/nouveau/nouveau_screen.c b/src/gallium/drivers/nouveau/nouveau_screen.c
index d129a55..6308a91 100644
--- a/src/gallium/drivers/nouveau/nouveau_screen.c
+++ b/src/gallium/drivers/nouveau/nouveau_screen.c
@@ -14,6 +14,7 @@
#include <errno.h>
#include <stdlib.h>
+#include <xf86drm.h>
#include <libdrm/nouveau_drm.h>
#include "nouveau_winsys.h"
@@ -86,7 +87,18 @@ nouveau_screen_bo_from_handle(struct pipe_screen *pscreen,
struct nouveau_bo *bo = 0;
int ret;
- ret = nouveau_bo_name_ref(dev, whandle->handle, &bo);
+ if (whandle->type != DRM_API_HANDLE_TYPE_SHARED &&
+ whandle->type != DRM_API_HANDLE_TYPE_FD) {
+ debug_printf("%s: attempt to import unsupported handle type %d\n",
+ __FUNCTION__, whandle->type);
+ return NULL;
+ }
+
+ if (whandle->type == DRM_API_HANDLE_TYPE_SHARED)
+ ret = nouveau_bo_name_ref(dev, whandle->handle, &bo);
+ else
+ ret = nouveau_bo_prime_handle_ref(dev, whandle->handle, &bo);
+
if (ret) {
debug_printf("%s: ref name 0x%08x failed with %d\n",
__FUNCTION__, whandle->handle, ret);
@@ -111,6 +123,8 @@ nouveau_screen_bo_get_handle(struct pipe_screen *pscreen,
} else if (whandle->type == DRM_API_HANDLE_TYPE_KMS) {
whandle->handle = bo->handle;
return TRUE;
+ } else if (whandle->type == DRM_API_HANDLE_TYPE_FD) {
+ return nouveau_bo_set_prime(bo, (int *)&whandle->handle) == 0;
} else {
return FALSE;
}
@@ -161,6 +175,9 @@ nouveau_screen_init(struct nouveau_screen *screen, struct nouveau_device *dev)
if (!ret)
screen->cpu_gpu_time_delta = time - screen->cpu_gpu_time_delta * 1000;
+ screen->prime_caps = 0;
+ ret = drmGetCap(dev->fd, DRM_CAP_PRIME, &screen->prime_caps);
+
pscreen->get_name = nouveau_screen_get_name;
pscreen->get_vendor = nouveau_screen_get_vendor;
diff --git a/src/gallium/drivers/nouveau/nouveau_screen.h b/src/gallium/drivers/nouveau/nouveau_screen.h
index 7f15d10..fc5531b 100644
--- a/src/gallium/drivers/nouveau/nouveau_screen.h
+++ b/src/gallium/drivers/nouveau/nouveau_screen.h
@@ -47,6 +47,8 @@ struct nouveau_screen {
int64_t cpu_gpu_time_delta;
+ uint64_t prime_caps;
+
boolean hint_buf_keep_sysmem_copy;
#ifdef NOUVEAU_ENABLE_DRIVER_STATISTICS
diff --git a/src/gallium/drivers/nv30/nv30_screen.c b/src/gallium/drivers/nv30/nv30_screen.c
index 97471a7..d014fb9 100644
--- a/src/gallium/drivers/nv30/nv30_screen.c
+++ b/src/gallium/drivers/nv30/nv30_screen.c
@@ -31,6 +31,8 @@
#include "nv30-40_3d.xml.h"
#include "nv01_2d.xml.h"
+#include <drm.h>
+
#include "nouveau/nouveau_fence.h"
#include "nv30_screen.h"
#include "nv30_context.h"
@@ -124,13 +126,15 @@ nv30_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
case PIPE_CAP_TEXTURE_BUFFER_OFFSET_ALIGNMENT:
case PIPE_CAP_QUERY_PIPELINE_STATISTICS:
case PIPE_CAP_TEXTURE_BORDER_COLOR_QUIRK:
- case PIPE_CAP_PRIME:
return 0;
case PIPE_CAP_VERTEX_BUFFER_OFFSET_4BYTE_ALIGNED_ONLY:
case PIPE_CAP_VERTEX_BUFFER_STRIDE_4BYTE_ALIGNED_ONLY:
case PIPE_CAP_VERTEX_ELEMENT_SRC_OFFSET_4BYTE_ALIGNED_ONLY:
case PIPE_CAP_PREFER_BLIT_BASED_TEXTURE_TRANSFER:
return 1;
+ case PIPE_CAP_PRIME:
+ return screen->base.prime_caps &
+ (DRM_PRIME_CAP_EXPORT | DRM_PRIME_CAP_IMPORT);
default:
debug_printf("unknown param %d\n", param);
return 0;
diff --git a/src/gallium/drivers/nv50/nv50_screen.c b/src/gallium/drivers/nv50/nv50_screen.c
index 1177c1b..7194604 100644
--- a/src/gallium/drivers/nv50/nv50_screen.c
+++ b/src/gallium/drivers/nv50/nv50_screen.c
@@ -24,6 +24,8 @@
#include "util/u_format_s3tc.h"
#include "pipe/p_screen.h"
+#include <drm.h>
+
#include "nv50_context.h"
#include "nv50_screen.h"
@@ -189,7 +191,8 @@ nv50_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
case PIPE_CAP_TEXTURE_BORDER_COLOR_QUIRK:
return PIPE_QUIRK_TEXTURE_BORDER_COLOR_SWIZZLE_NV50;
case PIPE_CAP_PRIME:
- return 0;
+ return nouveau_screen(pscreen)->prime_caps &
+ (DRM_PRIME_CAP_EXPORT | DRM_PRIME_CAP_IMPORT);
default:
NOUVEAU_ERR("unknown PIPE_CAP %d\n", param);
return 0;
diff --git a/src/gallium/drivers/nvc0/nvc0_screen.c b/src/gallium/drivers/nvc0/nvc0_screen.c
index e3eff40..c2ae7e1 100644
--- a/src/gallium/drivers/nvc0/nvc0_screen.c
+++ b/src/gallium/drivers/nvc0/nvc0_screen.c
@@ -24,6 +24,8 @@
#include "util/u_format_s3tc.h"
#include "pipe/p_screen.h"
+#include <drm.h>
+
#include "vl/vl_decoder.h"
#include "vl/vl_video_buffer.h"
@@ -179,7 +181,8 @@ nvc0_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
case PIPE_CAP_TEXTURE_BORDER_COLOR_QUIRK:
return PIPE_QUIRK_TEXTURE_BORDER_COLOR_SWIZZLE_NV50;
case PIPE_CAP_PRIME:
- return 0;
+ return nouveau_screen(pscreen)->prime_caps &
+ (DRM_PRIME_CAP_EXPORT | DRM_PRIME_CAP_IMPORT);
default:
NOUVEAU_ERR("unknown PIPE_CAP %d\n", param);
return 0;
--
1.8.1.2
More information about the mesa-dev
mailing list