From: Emil Velikov Date: Wed, 28 Oct 2015 11:21:49 +0000 (+0000) Subject: virgl: use virgl_screen/surface upcast wrappers X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=dafcb21405622eae3f8aa49000142f870549cc9b;p=mesa.git virgl: use virgl_screen/surface upcast wrappers Signed-off-by: Emil Velikov Reviewed-by: Dave Airlie --- diff --git a/src/gallium/drivers/virgl/virgl_context.c b/src/gallium/drivers/virgl/virgl_context.c index 2b6b3566388..32dde06ae7d 100644 --- a/src/gallium/drivers/virgl/virgl_context.c +++ b/src/gallium/drivers/virgl/virgl_context.c @@ -231,7 +231,7 @@ static void virgl_surface_destroy(struct pipe_context *ctx, struct pipe_surface *psurf) { struct virgl_context *vctx = virgl_context(ctx); - struct virgl_surface *surf = (struct virgl_surface *)psurf; + struct virgl_surface *surf = virgl_surface(psurf); pipe_resource_reference(&surf->base.texture, NULL); virgl_encode_delete_object(vctx, surf->handle, VIRGL_OBJECT_SURFACE); diff --git a/src/gallium/drivers/virgl/virgl_encode.c b/src/gallium/drivers/virgl/virgl_encode.c index d825397e11b..4493c3f8ad2 100644 --- a/src/gallium/drivers/virgl/virgl_encode.c +++ b/src/gallium/drivers/virgl/virgl_encode.c @@ -323,14 +323,14 @@ int virgl_encode_clear(struct virgl_context *ctx, int virgl_encoder_set_framebuffer_state(struct virgl_context *ctx, const struct pipe_framebuffer_state *state) { - struct virgl_surface *zsurf = (struct virgl_surface *)state->zsbuf; + struct virgl_surface *zsurf = virgl_surface(state->zsbuf); int i; virgl_encoder_write_cmd_dword(ctx, VIRGL_CMD0(VIRGL_CCMD_SET_FRAMEBUFFER_STATE, 0, VIRGL_SET_FRAMEBUFFER_STATE_SIZE(state->nr_cbufs))); virgl_encoder_write_dword(ctx->cbuf, state->nr_cbufs); virgl_encoder_write_dword(ctx->cbuf, zsurf ? zsurf->handle : 0); for (i = 0; i < state->nr_cbufs; i++) { - struct virgl_surface *surf = (struct virgl_surface *)state->cbufs[i]; + struct virgl_surface *surf = virgl_surface(state->cbufs[i]); virgl_encoder_write_dword(ctx->cbuf, surf ? surf->handle : 0); } diff --git a/src/gallium/drivers/virgl/virgl_encode.h b/src/gallium/drivers/virgl/virgl_encode.h index eabc421f861..d7923692793 100644 --- a/src/gallium/drivers/virgl/virgl_encode.h +++ b/src/gallium/drivers/virgl/virgl_encode.h @@ -29,6 +29,11 @@ struct virgl_surface { uint32_t handle; }; +static inline struct virgl_surface *virgl_surface(struct pipe_surface *surf) +{ + return (struct virgl_surface *)surf; +} + static inline void virgl_encoder_write_dword(struct virgl_cmd_buf *state, uint32_t dword) { diff --git a/src/gallium/drivers/virgl/virgl_resource.c b/src/gallium/drivers/virgl/virgl_resource.c index 758dd6b3e4b..52425f40e2a 100644 --- a/src/gallium/drivers/virgl/virgl_resource.c +++ b/src/gallium/drivers/virgl/virgl_resource.c @@ -54,7 +54,7 @@ bool virgl_res_needs_readback(struct virgl_context *vctx, static struct pipe_resource *virgl_resource_create(struct pipe_screen *screen, const struct pipe_resource *templ) { - struct virgl_screen *vs = (struct virgl_screen *)screen; + struct virgl_screen *vs = virgl_screen(screen); if (templ->target == PIPE_BUFFER) return virgl_buffer_create(vs, templ); else @@ -65,7 +65,7 @@ static struct pipe_resource *virgl_resource_from_handle(struct pipe_screen *scre const struct pipe_resource *templ, struct winsys_handle *whandle) { - struct virgl_screen *vs = (struct virgl_screen *)screen; + struct virgl_screen *vs = virgl_screen(screen); if (templ->target == PIPE_BUFFER) return NULL; else diff --git a/src/gallium/drivers/virgl/virgl_screen.h b/src/gallium/drivers/virgl/virgl_screen.h index 82b876f9f11..1a24eec1bba 100644 --- a/src/gallium/drivers/virgl/virgl_screen.h +++ b/src/gallium/drivers/virgl/virgl_screen.h @@ -40,7 +40,7 @@ struct virgl_screen { static inline struct virgl_screen * -virgl_screen( struct pipe_screen *pipe ) +virgl_screen(struct pipe_screen *pipe) { return (struct virgl_screen *)pipe; }