[Mesa-dev] [PATCH 07/15] virgl: use virgl_screen/surface upcast wrappers
Emil Velikov
emil.l.velikov at gmail.com
Thu Oct 29 04:59:38 PDT 2015
Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
---
src/gallium/drivers/virgl/virgl_context.c | 2 +-
src/gallium/drivers/virgl/virgl_encode.c | 4 ++--
src/gallium/drivers/virgl/virgl_encode.h | 5 +++++
src/gallium/drivers/virgl/virgl_resource.c | 4 ++--
src/gallium/drivers/virgl/virgl_screen.h | 2 +-
5 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/src/gallium/drivers/virgl/virgl_context.c b/src/gallium/drivers/virgl/virgl_context.c
index 2b6b356..32dde06 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 d825397..4493c3f 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 eabc421..d792369 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 758dd6b..52425f4 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 82b876f..1a24eec 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;
}
--
2.6.2
More information about the mesa-dev
mailing list