virgl: use virgl_screen/surface upcast wrappers
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Reviewed-by: Dave Airlie <airlied@redhat.com>
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user