From 61a26cdfdc9c75a83c0d362c973d5436fe077be4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Thu, 8 Jul 2010 22:32:39 +0200 Subject: [PATCH] r300g: store/return the stride for winsys_handle in winsys --- src/gallium/drivers/r300/r300_texture.c | 16 ++++++---------- src/gallium/drivers/r300/r300_winsys.h | 6 ++++-- src/gallium/winsys/radeon/drm/radeon_r300.c | 11 ++++++++--- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c index 6206570fca4..094f22dd37a 100644 --- a/src/gallium/drivers/r300/r300_texture.c +++ b/src/gallium/drivers/r300/r300_texture.c @@ -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)); diff --git a/src/gallium/drivers/r300/r300_winsys.h b/src/gallium/drivers/r300/r300_winsys.h index 3b5e9eec602..7687eac53eb 100644 --- a/src/gallium/drivers/r300/r300_winsys.h +++ b/src/gallium/drivers/r300/r300_winsys.h @@ -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, diff --git a/src/gallium/winsys/radeon/drm/radeon_r300.c b/src/gallium/winsys/radeon/drm/radeon_r300.c index cb26447606d..51cfc0fd400 100644 --- a/src/gallium/winsys/radeon/drm/radeon_r300.c +++ b/src/gallium/winsys/radeon/drm/radeon_r300.c @@ -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); } -- 2.30.2