From: Chia-I Wu Date: Mon, 13 May 2019 17:42:08 +0000 (-0700) Subject: virgl: remove support for buffer surfaces X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=440982cdd6e50797853eb78b6edf9401ba5a93b8;p=mesa.git virgl: remove support for buffer surfaces st/mesa does not need it and virglrenderer does not really support it. Remove the support so that we are sure pipe_surface never refers to a buffer resource. Signed-off-by: Chia-I Wu Reviewed-by: Alexandros Frantzis Reviewed-by: Gurchetan Singh --- diff --git a/src/gallium/drivers/virgl/virgl_context.c b/src/gallium/drivers/virgl/virgl_context.c index 24775930d86..25f841a2b51 100644 --- a/src/gallium/drivers/virgl/virgl_context.c +++ b/src/gallium/drivers/virgl/virgl_context.c @@ -229,6 +229,10 @@ static struct pipe_surface *virgl_create_surface(struct pipe_context *ctx, struct virgl_resource *res = virgl_resource(resource); uint32_t handle; + /* no support for buffer surfaces */ + if (resource->target == PIPE_BUFFER) + return NULL; + surf = CALLOC_STRUCT(virgl_surface); if (!surf) return NULL; @@ -244,18 +248,13 @@ static struct pipe_surface *virgl_create_surface(struct pipe_context *ctx, pipe_resource_reference(&surf->base.texture, resource); surf->base.context = ctx; surf->base.format = templ->format; - if (resource->target != PIPE_BUFFER) { - surf->base.width = u_minify(resource->width0, templ->u.tex.level); - surf->base.height = u_minify(resource->height0, templ->u.tex.level); - surf->base.u.tex.level = templ->u.tex.level; - surf->base.u.tex.first_layer = templ->u.tex.first_layer; - surf->base.u.tex.last_layer = templ->u.tex.last_layer; - } else { - surf->base.width = templ->u.buf.last_element - templ->u.buf.first_element + 1; - surf->base.height = resource->height0; - surf->base.u.buf.first_element = templ->u.buf.first_element; - surf->base.u.buf.last_element = templ->u.buf.last_element; - } + + surf->base.width = u_minify(resource->width0, templ->u.tex.level); + surf->base.height = u_minify(resource->height0, templ->u.tex.level); + surf->base.u.tex.level = templ->u.tex.level; + surf->base.u.tex.first_layer = templ->u.tex.first_layer; + surf->base.u.tex.last_layer = templ->u.tex.last_layer; + virgl_encoder_create_surface(vctx, handle, res, &surf->base); surf->handle = handle; return &surf->base; diff --git a/src/gallium/drivers/virgl/virgl_encode.c b/src/gallium/drivers/virgl/virgl_encode.c index 72fecf43d02..ee524c883d9 100644 --- a/src/gallium/drivers/virgl/virgl_encode.c +++ b/src/gallium/drivers/virgl/virgl_encode.c @@ -489,14 +489,11 @@ int virgl_encoder_create_surface(struct virgl_context *ctx, virgl_encoder_write_dword(ctx->cbuf, handle); virgl_encoder_write_res(ctx, res); virgl_encoder_write_dword(ctx->cbuf, templat->format); - if (templat->texture->target == PIPE_BUFFER) { - virgl_encoder_write_dword(ctx->cbuf, templat->u.buf.first_element); - virgl_encoder_write_dword(ctx->cbuf, templat->u.buf.last_element); - } else { - virgl_encoder_write_dword(ctx->cbuf, templat->u.tex.level); - virgl_encoder_write_dword(ctx->cbuf, templat->u.tex.first_layer | (templat->u.tex.last_layer << 16)); - } + assert(templat->texture->target != PIPE_BUFFER); + virgl_encoder_write_dword(ctx->cbuf, templat->u.tex.level); + virgl_encoder_write_dword(ctx->cbuf, templat->u.tex.first_layer | (templat->u.tex.last_layer << 16)); + return 0; }