virgl: use virgl_screen/surface upcast wrappers
authorEmil Velikov <emil.l.velikov@gmail.com>
Wed, 28 Oct 2015 11:21:49 +0000 (11:21 +0000)
committerEmil Velikov <emil.l.velikov@gmail.com>
Fri, 30 Oct 2015 17:37:09 +0000 (17:37 +0000)
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
src/gallium/drivers/virgl/virgl_context.c
src/gallium/drivers/virgl/virgl_encode.c
src/gallium/drivers/virgl/virgl_encode.h
src/gallium/drivers/virgl/virgl_resource.c
src/gallium/drivers/virgl/virgl_screen.h

index 2b6b35663883fe74aada496e77cf5fc2ae169e0c..32dde06ae7d4f52acc563f874ec5797e01b54f23 100644 (file)
@@ -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);
index d825397e11b1d0f3668ba8cdd3fe3adde7c324c6..4493c3f8ad2f75544803af4e57640b5717755285 100644 (file)
@@ -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);
    }
 
index eabc421f8614938d29c2227bf66aa89c2a96ba2f..d7923692793fd28a97d6f807aba5c0aeaeec24bb 100644 (file)
@@ -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)
 {
index 758dd6b3e4b803aeaa6a9aed16f2148101f042dd..52425f40e2a24dc16a26b12cbdb69fdb710ab7f6 100644 (file)
@@ -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
index 82b876f9f11a008ec02461095d70ca2c63e40a13..1a24eec1bba134978235d8e4bcc1b87074dba2af 100644 (file)
@@ -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;
 }