From: Julien Isorce Date: Thu, 2 May 2019 22:57:04 +0000 (-0700) Subject: r600: implement resource_get_info X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a77512635e22b1e31a90dc5ce9d50d5cdf33e7b9;p=mesa.git r600: implement resource_get_info Factoring code with resource_get_handle. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=110443 Signed-off-by: Julien Isorce Reviewed-by: Dave Airlie airlied@redhat.com --- diff --git a/src/gallium/drivers/r600/r600_texture.c b/src/gallium/drivers/r600/r600_texture.c index 71606df38d9..27565e0aa0c 100644 --- a/src/gallium/drivers/r600/r600_texture.c +++ b/src/gallium/drivers/r600/r600_texture.c @@ -442,6 +442,32 @@ static void r600_reallocate_texture_inplace(struct r600_common_context *rctx, p_atomic_inc(&rctx->screen->dirty_tex_counter); } +static void r600_texture_get_info(struct pipe_screen* screen, + struct pipe_resource *resource, + unsigned *pstride, + unsigned *poffset) +{ + struct r600_common_screen *rscreen = (struct r600_common_screen*)screen; + struct r600_texture *rtex = (struct r600_texture*)resource; + unsigned stride = 0; + unsigned offset = 0; + + if (!rscreen || !rtex) + return; + + if (resource->target != PIPE_BUFFER) { + offset = rtex->surface.u.legacy.level[0].offset; + stride = rtex->surface.u.legacy.level[0].nblk_x * + rtex->surface.bpe; + } + + if (pstride) + *pstride = stride; + + if (poffset) + *poffset = offset; +} + static boolean r600_texture_get_handle(struct pipe_screen* screen, struct pipe_context *ctx, struct pipe_resource *resource, @@ -500,9 +526,6 @@ static boolean r600_texture_get_handle(struct pipe_screen* screen, rscreen->ws->buffer_set_metadata(res->buf, &metadata); } - offset = rtex->surface.u.legacy.level[0].offset; - stride = rtex->surface.u.legacy.level[0].nblk_x * - rtex->surface.bpe; slice_size = (uint64_t)rtex->surface.u.legacy.level[0].slice_size_dw * 4; } else { /* Move a suballocated buffer into a non-suballocated allocation. */ @@ -532,11 +555,11 @@ static boolean r600_texture_get_handle(struct pipe_screen* screen, } /* Buffers */ - offset = 0; - stride = 0; slice_size = 0; } + r600_texture_get_info(screen, resource, &stride, &offset); + if (res->b.is_shared) { /* USAGE_EXPLICIT_FLUSH must be cleared if at least one user * doesn't set it. @@ -1957,6 +1980,7 @@ void r600_init_screen_texture_functions(struct r600_common_screen *rscreen) { rscreen->b.resource_from_handle = r600_texture_from_handle; rscreen->b.resource_get_handle = r600_texture_get_handle; + rscreen->b.resource_get_info = r600_texture_get_info; rscreen->b.resource_from_memobj = r600_texture_from_memobj; rscreen->b.memobj_create_from_handle = r600_memobj_from_handle; rscreen->b.memobj_destroy = r600_memobj_destroy;