r300g: store/return the stride for winsys_handle in winsys
authorMarek Olšák <maraeo@gmail.com>
Thu, 8 Jul 2010 20:32:39 +0000 (22:32 +0200)
committerMarek Olšák <maraeo@gmail.com>
Thu, 8 Jul 2010 20:39:52 +0000 (22:39 +0200)
src/gallium/drivers/r300/r300_texture.c
src/gallium/drivers/r300/r300_winsys.h
src/gallium/winsys/radeon/drm/radeon_r300.c

index 6206570fca473ecf417a28b1c2374ddb52040f49..094f22dd37a18627dd03aa3bc48d59b605fbfe68 100644 (file)
@@ -37,9 +37,6 @@
 
 #include "pipe/p_screen.h"
 
-/* XXX NO! just no! */
-#include "state_tracker/drm_driver.h"
-
 enum r300_dim {
     DIM_WIDTH  = 0,
     DIM_HEIGHT = 1
@@ -938,9 +935,8 @@ static boolean r300_texture_get_handle(struct pipe_screen* screen,
         return FALSE;
     }
 
-    whandle->stride = r300_texture_get_stride(r300_screen(screen), tex, 0);
-
-    return rws->buffer_get_handle(rws, tex->buffer, whandle);
+    return rws->buffer_get_handle(rws, tex->buffer, whandle,
+                    r300_texture_get_stride(r300_screen(screen), tex, 0));
 }
 
 struct u_resource_vtbl r300_texture_vtbl = 
@@ -1074,6 +1070,7 @@ r300_texture_from_handle(struct pipe_screen* screen,
     struct r300_screen* rscreen = r300_screen(screen);
     struct r300_winsys_buffer *buffer;
     struct r300_texture* tex;
+    unsigned stride;
     boolean override_zb_flags;
 
     /* Support only 2D textures without mipmaps */
@@ -1083,8 +1080,7 @@ r300_texture_from_handle(struct pipe_screen* screen,
         return NULL;
     }
 
-    /* XXX make the winsys return the stride_override, see i915_resource_texture.c:830 */
-    buffer = rws->buffer_from_handle(rws, whandle->handle);
+    buffer = rws->buffer_from_handle(rws, whandle, &stride);
     if (!buffer) {
         return NULL;
     }
@@ -1100,7 +1096,7 @@ r300_texture_from_handle(struct pipe_screen* screen,
     tex->b.b.screen = screen;
     tex->domain = R300_DOMAIN_VRAM;
 
-    tex->stride_override = whandle->stride;
+    tex->stride_override = stride;
 
     /* one ref already taken */
     tex->buffer = buffer;
@@ -1112,7 +1108,7 @@ r300_texture_from_handle(struct pipe_screen* screen,
                "Pitch: % 4i, Dim: %ix%i, Format: %s\n",
                tex->macrotile ? "YES" : " NO",
                tex->microtile ? "YES" : " NO",
-               whandle->stride / util_format_get_blocksize(base->format),
+               stride / util_format_get_blocksize(base->format),
                base->width0, base->height0,
                util_format_short_name(base->format));
 
index 3b5e9eec602033c9c26ec8cdcb4ca18faf37c1f9..7687eac53eb4ca077906d83de71b410fc16beb24 100644 (file)
@@ -148,11 +148,13 @@ struct r300_winsys_screen {
                          enum r300_value_id vid);
 
     struct r300_winsys_buffer *(*buffer_from_handle)(struct r300_winsys_screen *winsys,
-                                                     unsigned handle);
+                                                     struct winsys_handle *whandle,
+                                                     unsigned *stride);
 
     boolean (*buffer_get_handle)(struct r300_winsys_screen *winsys,
                                 struct r300_winsys_buffer *buffer,
-                                struct winsys_handle *whandle);
+                                 struct winsys_handle *whandle,
+                                 unsigned stride);
 
     boolean (*is_buffer_referenced)(struct r300_winsys_screen *winsys,
                                     struct r300_winsys_buffer *buffer,
index cb26447606d503019ea7cc309f8d3473f6ccd86c..51cfc0fd40027a6b2f387ddf82c5185fce19a7ed 100644 (file)
@@ -136,20 +136,25 @@ static boolean radeon_r300_winsys_is_buffer_referenced(struct r300_winsys_screen
 }
 
 static struct r300_winsys_buffer *radeon_r300_winsys_buffer_from_handle(struct r300_winsys_screen *rws,
-                                                                        unsigned handle)
+                                                                        struct winsys_handle *whandle,
+                                                                        unsigned *stride)
 {
     struct radeon_libdrm_winsys *ws = radeon_winsys_screen(rws);
     struct pb_buffer *_buf;
 
-    _buf = radeon_drm_bufmgr_create_buffer_from_handle(ws->kman, handle);
+    *stride = whandle->stride;
+
+    _buf = radeon_drm_bufmgr_create_buffer_from_handle(ws->kman, whandle->handle);
     return radeon_libdrm_winsys_buffer(_buf);
 }
 
 static boolean radeon_r300_winsys_buffer_get_handle(struct r300_winsys_screen *rws,
                                                    struct r300_winsys_buffer *buffer,
-                                                    struct winsys_handle *whandle)
+                                                    struct winsys_handle *whandle,
+                                                    unsigned stride)
 {
     struct pb_buffer *_buf = radeon_pb_buffer(buffer);
+    whandle->stride = stride;
     return radeon_drm_bufmgr_get_handle(_buf, whandle);
 }