diff options
author | Julien Isorce <[email protected]> | 2019-05-02 15:57:04 -0700 |
---|---|---|
committer | Julien Isorce <[email protected]> | 2019-05-03 05:54:28 +0000 |
commit | a77512635e22b1e31a90dc5ce9d50d5cdf33e7b9 (patch) | |
tree | d3aaedd52a94f5debeb2776627a6cd8b1849365c /src/gallium/drivers/r600 | |
parent | 512a31a41299758f0f60d0452b8c9e8c02238189 (diff) |
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 <[email protected]>
Reviewed-by: Dave Airlie [email protected]
Diffstat (limited to 'src/gallium/drivers/r600')
-rw-r--r-- | src/gallium/drivers/r600/r600_texture.c | 34 |
1 files changed, 29 insertions, 5 deletions
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; |