From dbf9e4fbf824a7ad8536641c2be0695aaa10e85f Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 10 Oct 2017 13:56:55 -0700 Subject: [PATCH] broadcom/vc5: Remove the u_resource_vtbl usage. Like for vc4, this was just a wasted indirection. --- src/gallium/drivers/vc5/vc5_resource.c | 37 +++++++++++++-------------------- src/gallium/drivers/vc5/vc5_resource.h | 2 +- src/gallium/drivers/vc5/vc5_simulator.c | 4 ++-- 3 files changed, 18 insertions(+), 25 deletions(-) diff --git a/src/gallium/drivers/vc5/vc5_resource.c b/src/gallium/drivers/vc5/vc5_resource.c index 8dbdb71e735..42d58791f6c 100644 --- a/src/gallium/drivers/vc5/vc5_resource.c +++ b/src/gallium/drivers/vc5/vc5_resource.c @@ -43,7 +43,7 @@ static bool vc5_resource_bo_alloc(struct vc5_resource *rsc) { - struct pipe_resource *prsc = &rsc->base.b; + struct pipe_resource *prsc = &rsc->base; struct pipe_screen *pscreen = prsc->screen; struct vc5_bo *bo; int layers = (prsc->target == PIPE_TEXTURE_3D ? @@ -88,7 +88,7 @@ vc5_resource_transfer_unmap(struct pipe_context *pctx, slice->stride, trans->map, ptrans->stride, slice->tiling, rsc->cpp, - rsc->base.b.height0, + rsc->base.height0, &ptrans->box); } free(trans->map); @@ -293,7 +293,7 @@ vc5_resource_transfer_map(struct pipe_context *pctx, ptrans->box.z * rsc->cube_map_stride, slice->stride, slice->tiling, rsc->cpp, - rsc->base.b.height0, + rsc->base.height0, &ptrans->box); } return trans->map; @@ -324,8 +324,10 @@ vc5_resource_destroy(struct pipe_screen *pscreen, static boolean vc5_resource_get_handle(struct pipe_screen *pscreen, + struct pipe_context *pctx, struct pipe_resource *prsc, - struct winsys_handle *whandle) + struct winsys_handle *whandle, + unsigned usage) { struct vc5_resource *rsc = vc5_resource(prsc); struct vc5_bo *bo = rsc->bo; @@ -352,18 +354,10 @@ vc5_resource_get_handle(struct pipe_screen *pscreen, return FALSE; } -static const struct u_resource_vtbl vc5_resource_vtbl = { - .resource_get_handle = vc5_resource_get_handle, - .resource_destroy = vc5_resource_destroy, - .transfer_map = vc5_resource_transfer_map, - .transfer_flush_region = u_default_transfer_flush_region, - .transfer_unmap = vc5_resource_transfer_unmap, -}; - static void vc5_setup_slices(struct vc5_resource *rsc, const char *caller) { - struct pipe_resource *prsc = &rsc->base.b; + struct pipe_resource *prsc = &rsc->base; uint32_t width = prsc->width0; uint32_t height = prsc->height0; uint32_t pot_width = util_next_power_of_two(width); @@ -481,14 +475,13 @@ vc5_resource_setup(struct pipe_screen *pscreen, struct vc5_resource *rsc = CALLOC_STRUCT(vc5_resource); if (!rsc) return NULL; - struct pipe_resource *prsc = &rsc->base.b; + struct pipe_resource *prsc = &rsc->base; *prsc = *tmpl; pipe_reference_init(&prsc->reference, 1); prsc->screen = pscreen; - rsc->base.vtbl = &vc5_resource_vtbl; if (prsc->nr_samples <= 1) rsc->cpp = util_format_get_blocksize(tmpl->format); else @@ -520,7 +513,7 @@ vc5_resource_create_with_modifiers(struct pipe_screen *pscreen, { bool linear_ok = find_modifier(DRM_FORMAT_MOD_LINEAR, modifiers, count); struct vc5_resource *rsc = vc5_resource_setup(pscreen, tmpl); - struct pipe_resource *prsc = &rsc->base.b; + struct pipe_resource *prsc = &rsc->base; /* Use a tiled layout if we can, for better 3D performance. */ bool should_tile = true; @@ -584,7 +577,7 @@ vc5_resource_from_handle(struct pipe_screen *pscreen, { struct vc5_screen *screen = vc5_screen(pscreen); struct vc5_resource *rsc = vc5_resource_setup(pscreen, tmpl); - struct pipe_resource *prsc = &rsc->base.b; + struct pipe_resource *prsc = &rsc->base; struct vc5_resource_slice *slice = &rsc->slices[0]; if (!rsc) @@ -738,16 +731,16 @@ vc5_resource_screen_init(struct pipe_screen *pscreen) vc5_resource_create_with_modifiers; pscreen->resource_create = vc5_resource_create; pscreen->resource_from_handle = vc5_resource_from_handle; - pscreen->resource_get_handle = u_resource_get_handle_vtbl; - pscreen->resource_destroy = u_resource_destroy_vtbl; + pscreen->resource_get_handle = vc5_resource_get_handle; + pscreen->resource_destroy = vc5_resource_destroy; } void vc5_resource_context_init(struct pipe_context *pctx) { - pctx->transfer_map = u_transfer_map_vtbl; - pctx->transfer_flush_region = u_transfer_flush_region_vtbl; - pctx->transfer_unmap = u_transfer_unmap_vtbl; + pctx->transfer_map = vc5_resource_transfer_map; + pctx->transfer_flush_region = u_default_transfer_flush_region; + pctx->transfer_unmap = vc5_resource_transfer_unmap; pctx->buffer_subdata = u_default_buffer_subdata; pctx->texture_subdata = u_default_texture_subdata; pctx->create_surface = vc5_create_surface; diff --git a/src/gallium/drivers/vc5/vc5_resource.h b/src/gallium/drivers/vc5/vc5_resource.h index 3440fdc947b..e65cb8c8fee 100644 --- a/src/gallium/drivers/vc5/vc5_resource.h +++ b/src/gallium/drivers/vc5/vc5_resource.h @@ -103,7 +103,7 @@ struct vc5_surface { }; struct vc5_resource { - struct u_resource base; + struct pipe_resource base; struct vc5_bo *bo; struct vc5_resource_slice slices[VC5_MAX_MIP_LEVELS]; uint32_t cube_map_stride; diff --git a/src/gallium/drivers/vc5/vc5_simulator.c b/src/gallium/drivers/vc5/vc5_simulator.c index 3f783ea5b13..fc6a38d372b 100644 --- a/src/gallium/drivers/vc5/vc5_simulator.c +++ b/src/gallium/drivers/vc5/vc5_simulator.c @@ -439,7 +439,7 @@ vc5_simulator_flush(struct vc5_context *vc5, ctex->bo->size); #endif - for (int y = 0; y < ctex->base.b.height0; y++) { + for (int y = 0; y < ctex->base.height0; y++) { memcpy(ctex->bo->map + y * sim_stride, csim_bo->winsys_map + y * winsys_stride, row_len); @@ -490,7 +490,7 @@ vc5_simulator_flush(struct vc5_context *vc5, return ret; if (ctex && csim_bo->winsys_map) { - for (int y = 0; y < ctex->base.b.height0; y++) { + for (int y = 0; y < ctex->base.height0; y++) { memcpy(csim_bo->winsys_map + y * winsys_stride, ctex->bo->map + y * sim_stride, row_len); -- 2.11.0