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);
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);
}
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)
{
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
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
static inline struct virgl_screen *
-virgl_screen( struct pipe_screen *pipe )
+virgl_screen(struct pipe_screen *pipe)
{
return (struct virgl_screen *)pipe;
}