r300g: fix color tiling for buffer from X server.
authorDave Airlie <airlied@redhat.com>
Sat, 3 Apr 2010 11:52:09 +0000 (21:52 +1000)
committerDave Airlie <airlied@redhat.com>
Sat, 3 Apr 2010 11:54:49 +0000 (21:54 +1000)
The tiling setup needs a bit of work, but this should be good enough for now,
when we get buffers from the kernel we need to store their tiling properties.

Signed-off-by: Dave Airlie <airlied@redhat.com>
src/gallium/drivers/r300/r300_texture.c
src/gallium/drivers/r300/r300_winsys.h
src/gallium/winsys/radeon/drm/radeon_buffer.h
src/gallium/winsys/radeon/drm/radeon_drm_buffer.c
src/gallium/winsys/radeon/drm/radeon_r300.c

index e7bac615dff9346e6191bf70b4cd9a38f06a6823..a9c9e14ba7cf275856c7f3dd0ff1998c63a98ad5 100644 (file)
@@ -909,6 +909,7 @@ static struct pipe_texture*
     /* one ref already taken */
     tex->buffer = buffer;
 
+    rws->buffer_get_tiling(rws, buffer, &tex->microtile, &tex->macrotile);
     return (struct pipe_texture*)tex;
 }
 
index acfa5dbeb9c020214a0fc1cc0f68a8549b748832..d8d0c609d25ea6cf585bc0dd093708910c4e4181 100644 (file)
@@ -146,6 +146,11 @@ struct r300_winsys_screen {
 
     void (*reset_bos)(struct r300_winsys_screen *winsys);
 
+    void (*buffer_get_tiling)(struct r300_winsys_screen *winsys,
+                              struct r300_winsys_buffer *buffer,
+                              enum r300_buffer_tiling *microtiled,
+                              enum r300_buffer_tiling *macrotiled);
+
     void (*buffer_set_tiling)(struct r300_winsys_screen *winsys,
                               struct r300_winsys_buffer *buffer,
                               uint32_t pitch,
index 218a3763018057d7416c6a43e9e411ffa95422d9..8782d675df24961422b2d9382ad4dc4ee75cbf20 100644 (file)
@@ -72,6 +72,10 @@ void radeon_drm_bufmgr_write_reloc(struct pb_buffer *_buf,
 struct pb_buffer *radeon_drm_bufmgr_create_buffer_from_handle(struct pb_manager *_mgr,
                                                              uint32_t handle);
 
+void radeon_drm_bufmgr_get_tiling(struct pb_buffer *_buf,
+                                  enum r300_buffer_tiling *microtiled,
+                                  enum r300_buffer_tiling *macrotiled);
+
 void radeon_drm_bufmgr_set_tiling(struct pb_buffer *_buf,
                                   enum r300_buffer_tiling microtiled,
                                   enum r300_buffer_tiling macrotiled,
index 66f613224579be1a5572f3a36ee79aed19ee861c..5fd20cc7754f06d3ca7919f948b2bcf292c46b67 100644 (file)
@@ -304,7 +304,24 @@ boolean radeon_drm_bufmgr_get_handle(struct pb_buffer *_buf,
     }
     return TRUE;
 }
-                                          
+
+void radeon_drm_bufmgr_get_tiling(struct pb_buffer *_buf,
+                                  enum r300_buffer_tiling *microtiled,
+                                  enum r300_buffer_tiling *macrotiled)
+{
+    struct radeon_drm_buffer *buf = get_drm_buffer(_buf);
+    uint32_t flags = 0, pitch;
+
+    radeon_bo_get_tiling(buf->bo, &flags, &pitch);
+
+    *microtiled = R300_BUFFER_LINEAR;
+    *macrotiled = R300_BUFFER_LINEAR;
+    if (flags & RADEON_BO_FLAGS_MICRO_TILE)
+       *microtiled = R300_BUFFER_TILED;
+
+    if (flags & RADEON_BO_FLAGS_MACRO_TILE)
+       *macrotiled = R300_BUFFER_TILED;
+}
 
 void radeon_drm_bufmgr_set_tiling(struct pb_buffer *_buf,
                                   enum r300_buffer_tiling microtiled,
index 38fcf889c8b401395c3206eddb0fd727a58cd9d5..935c1d84d02dfedafb0220f1ea5e5da71feb790b 100644 (file)
@@ -72,6 +72,15 @@ static void radeon_r300_winsys_buffer_set_tiling(struct r300_winsys_screen *rws,
     radeon_drm_bufmgr_set_tiling(_buf, microtiled, macrotiled, pitch);
 }
 
+static void radeon_r300_winsys_buffer_get_tiling(struct r300_winsys_screen *rws,
+                                                 struct r300_winsys_buffer *buf,
+                                                 enum r300_buffer_tiling *microtiled,
+                                                 enum r300_buffer_tiling *macrotiled)
+{
+    struct pb_buffer *_buf = radeon_pb_buffer(buf);
+    radeon_drm_bufmgr_get_tiling(_buf, microtiled, macrotiled);
+}
+
 static void *radeon_r300_winsys_buffer_map(struct r300_winsys_screen *ws,
                                           struct r300_winsys_buffer *buf,
                                           unsigned usage)
@@ -320,6 +329,7 @@ radeon_setup_winsys(int fd, struct radeon_libdrm_winsys* ws)
     ws->base.buffer_create = radeon_r300_winsys_buffer_create;
     ws->base.buffer_destroy = radeon_r300_winsys_buffer_destroy;
     ws->base.buffer_set_tiling = radeon_r300_winsys_buffer_set_tiling;
+    ws->base.buffer_get_tiling = radeon_r300_winsys_buffer_get_tiling;
     ws->base.buffer_map = radeon_r300_winsys_buffer_map;
     ws->base.buffer_unmap = radeon_r300_winsys_buffer_unmap;
     ws->base.buffer_reference = radeon_r300_winsys_buffer_reference;