broadcom/vc5: Remove the u_resource_vtbl usage.
authorEric Anholt <eric@anholt.net>
Tue, 10 Oct 2017 20:56:55 +0000 (13:56 -0700)
committerEric Anholt <eric@anholt.net>
Thu, 12 Oct 2017 19:44:27 +0000 (12:44 -0700)
Like for vc4, this was just a wasted indirection.

src/gallium/drivers/vc5/vc5_resource.c
src/gallium/drivers/vc5/vc5_resource.h
src/gallium/drivers/vc5/vc5_simulator.c

index 8dbdb71e7350e6e79a9368a89a42141c788785d4..42d58791f6c47760d4106f2d4453bb70d479efbd 100644 (file)
@@ -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;
index 3440fdc947b19189ef3309364b09c72281484860..e65cb8c8fee4c339da346bd0fa72e5def88481d4 100644 (file)
@@ -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;
index 3f783ea5b13d0ae28571975f716addd764625a10..fc6a38d372bf3f0dd154ea169c267706fb53b4e9 100644 (file)
@@ -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);