r300g: support new drm_api
authorJoakim Sindholt <opensource@zhasha.com>
Fri, 28 Aug 2009 15:13:49 +0000 (17:13 +0200)
committerJoakim Sindholt <opensource@zhasha.com>
Fri, 28 Aug 2009 15:23:11 +0000 (17:23 +0200)
src/gallium/winsys/drm/radeon/core/radeon_drm.c
src/gallium/winsys/drm/radeon/core/radeon_r300.h

index 8d818cf830122119496e55050b64c8b63afdf6cd..85dfd82ed4d72386a6dd5a1aa27670d9ffcc57a6 100644 (file)
@@ -33,7 +33,7 @@
 /* Create a pipe_screen. */
 struct pipe_screen* radeon_create_screen(struct drm_api* api,
                                          int drmFB,
-                                        struct drm_create_screen_arg *arg)
+                     struct drm_create_screen_arg *arg)
 {
     struct radeon_winsys* winsys = radeon_pipe_winsys(drmFB);
 
@@ -97,26 +97,38 @@ struct pipe_buffer* radeon_buffer_from_handle(struct drm_api* api,
     return &radeon_buffer->base;
 }
 
-boolean radeon_handle_from_buffer(struct drm_api* api,
-                                  struct pipe_screen* screen,
-                                  struct pipe_buffer* buffer,
-                                  unsigned* handle)
+struct pipe_texture*
+radeon_texture_from_shared_handle(struct drm_api *api,
+                                  struct pipe_screen *screen,
+                                  struct pipe_texture *templ,
+                                  const char *name,
+                                  unsigned stride,
+                                  unsigned handle)
 {
-    struct radeon_pipe_buffer* radeon_buffer =
-        (struct radeon_pipe_buffer*)buffer;
-    *handle = radeon_buffer->bo->handle;
-    return TRUE;
+    struct pipe_buffer *buffer;
+
+    buffer = radeon_buffer_from_handle(api,
+                                       screen,
+                                       name,
+                                       handle);
+    if (!buffer)
+        return NULL;
+
+    return screen->texture_blanket(screen, templ, &stride, buffer);
 }
 
-boolean radeon_global_handle_from_buffer(struct drm_api* api,
-                                         struct pipe_screen* screen,
-                                         struct pipe_buffer* buffer,
-                                         unsigned* handle)
+boolean radeon_shared_handle_from_texture(struct drm_api *api,
+                                          struct pipe_screen *screen,
+                                          struct pipe_texture *texture,
+                                          unsigned *stride,
+                                          unsigned *handle)
 {
     int retval, fd;
     struct drm_gem_flink flink;
-    struct radeon_pipe_buffer* radeon_buffer =
-        (struct radeon_pipe_buffer*)buffer;
+    struct radeon_pipe_buffer* radeon_buffer;
+    if (!radeon_buffer_from_texture(api, texture, (struct pipe_buffer **)&radeon_buffer, stride)) {
+        return FALSE;
+    }
 
     if (!radeon_buffer->flinked) {
         fd = ((struct radeon_winsys*)screen->winsys)->priv->fd;
@@ -138,13 +150,30 @@ boolean radeon_global_handle_from_buffer(struct drm_api* api,
     return TRUE;
 }
 
+boolean radeon_local_handle_from_texture(struct drm_api *api,
+                                         struct pipe_screen *screen,
+                                         struct pipe_texture *texture,
+                                         unsigned *stride,
+                                         unsigned *handle)
+{
+    struct pipe_buffer *buffer;
+    if (!radeon_buffer_from_texture(api, texture, &buffer, stride)) {
+        return FALSE;
+    }
+
+    *handle = ((struct radeon_pipe_buffer*)buffer)->bo->handle;
+
+    pipe_buffer_reference(&buffer, NULL);
+
+    return TRUE;
+}
+
 struct drm_api drm_api_hooks = {
     .create_screen = radeon_create_screen,
     .create_context = radeon_create_context,
-    .buffer_from_texture = radeon_buffer_from_texture,
-    .buffer_from_handle = radeon_buffer_from_handle,
-    .handle_from_buffer = radeon_handle_from_buffer,
-    .global_handle_from_buffer = radeon_global_handle_from_buffer,
+    .texture_from_shared_handle = radeon_texture_from_shared_handle,
+    .shared_handle_from_texture = radeon_shared_handle_from_texture,
+    .local_handle_from_texture = radeon_local_handle_from_texture,
 };
 
 struct drm_api* drm_api_create()
index 741c13718895ed4441c1c632b7a34cf863f49d05..775d7937fd85e002c01be668c9693a3a6916260a 100644 (file)
@@ -28,7 +28,7 @@
 #include <stdlib.h>
 #include "drm.h"
 #include "radeon_drm.h"
-#include "radeon_cs.h"
+#include "radeon_cs_gem.h"
 
 #include "r300_winsys.h"