summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/virgl/virgl_buffer.c2
-rw-r--r--src/gallium/drivers/virgl/virgl_context.c28
-rw-r--r--src/gallium/drivers/virgl/virgl_encode.c4
-rw-r--r--src/gallium/drivers/virgl/virgl_resource.h10
-rw-r--r--src/gallium/drivers/virgl/virgl_screen.c2
-rw-r--r--src/gallium/drivers/virgl/virgl_streamout.c2
-rw-r--r--src/gallium/drivers/virgl/virgl_texture.c10
7 files changed, 34 insertions, 24 deletions
diff --git a/src/gallium/drivers/virgl/virgl_buffer.c b/src/gallium/drivers/virgl/virgl_buffer.c
index 96cb82c4a90..13e83846219 100644
--- a/src/gallium/drivers/virgl/virgl_buffer.c
+++ b/src/gallium/drivers/virgl/virgl_buffer.c
@@ -98,7 +98,7 @@ static void virgl_buffer_transfer_unmap(struct pipe_context *ctx,
struct pipe_transfer *transfer)
{
struct virgl_context *vctx = virgl_context(ctx);
- struct virgl_transfer *trans = (struct virgl_transfer *)transfer;
+ struct virgl_transfer *trans = virgl_transfer(transfer);
struct virgl_buffer *vbuf = virgl_buffer(transfer->resource);
if (trans->base.usage & PIPE_TRANSFER_WRITE) {
diff --git a/src/gallium/drivers/virgl/virgl_context.c b/src/gallium/drivers/virgl/virgl_context.c
index f222e532bf0..2b6b3566388 100644
--- a/src/gallium/drivers/virgl/virgl_context.c
+++ b/src/gallium/drivers/virgl/virgl_context.c
@@ -88,14 +88,14 @@ static void virgl_attach_res_framebuffer(struct virgl_context *vctx)
surf = vctx->framebuffer.zsbuf;
if (surf) {
- res = (struct virgl_resource *)surf->texture;
+ res = virgl_resource(surf->texture);
if (res)
vws->emit_res(vws, vctx->cbuf, res->hw_res, FALSE);
}
for (i = 0; i < vctx->framebuffer.nr_cbufs; i++) {
surf = vctx->framebuffer.cbufs[i];
if (surf) {
- res = (struct virgl_resource *)surf->texture;
+ res = virgl_resource(surf->texture);
if (res)
vws->emit_res(vws, vctx->cbuf, res->hw_res, FALSE);
}
@@ -114,7 +114,7 @@ static void virgl_attach_res_sampler_views(struct virgl_context *vctx,
i = u_bit_scan(&remaining_mask);
assert(tinfo->views[i]);
- res = (struct virgl_resource *)tinfo->views[i]->base.texture;
+ res = virgl_resource(tinfo->views[i]->base.texture);
if (res)
vws->emit_res(vws, vctx->cbuf, res->hw_res, FALSE);
}
@@ -127,7 +127,7 @@ static void virgl_attach_res_vertex_buffers(struct virgl_context *vctx)
unsigned i;
for (i = 0; i < vctx->num_vertex_buffers; i++) {
- res = (struct virgl_resource *)vctx->vertex_buffer[i].buffer;
+ res = virgl_resource(vctx->vertex_buffer[i].buffer);
if (res)
vws->emit_res(vws, vctx->cbuf, res->hw_res, FALSE);
}
@@ -138,7 +138,7 @@ static void virgl_attach_res_index_buffer(struct virgl_context *vctx)
struct virgl_winsys *vws = virgl_screen(vctx->base.screen)->vws;
struct virgl_resource *res;
- res = (struct virgl_resource *)vctx->index_buffer.buffer;
+ res = virgl_resource(vctx->index_buffer.buffer);
if (res)
vws->emit_res(vws, vctx->cbuf, res->hw_res, FALSE);
}
@@ -150,7 +150,7 @@ static void virgl_attach_res_so_targets(struct virgl_context *vctx)
unsigned i;
for (i = 0; i < vctx->num_so_targets; i++) {
- res = (struct virgl_resource *)vctx->so_targets[i].base.buffer;
+ res = virgl_resource(vctx->so_targets[i].base.buffer);
if (res)
vws->emit_res(vws, vctx->cbuf, res->hw_res, FALSE);
}
@@ -163,7 +163,7 @@ static void virgl_attach_res_uniform_buffers(struct virgl_context *vctx,
struct virgl_resource *res;
unsigned i;
for (i = 0; i < PIPE_MAX_CONSTANT_BUFFERS; i++) {
- res = (struct virgl_resource *)vctx->ubos[shader_type][i];
+ res = virgl_resource(vctx->ubos[shader_type][i]);
if (res) {
vws->emit_res(vws, vctx->cbuf, res->hw_res, FALSE);
}
@@ -436,7 +436,7 @@ static void virgl_set_constant_buffer(struct pipe_context *ctx,
if (buf) {
if (!buf->user_buffer){
- struct virgl_resource *res = (struct virgl_resource *)buf->buffer;
+ struct virgl_resource *res = virgl_resource(buf->buffer);
virgl_encoder_set_uniform_buffer(vctx, shader, index, buf->buffer_offset,
buf->buffer_size, res);
pipe_resource_reference(&vctx->ubos[shader][index], buf->buffer);
@@ -461,7 +461,7 @@ void virgl_transfer_inline_write(struct pipe_context *ctx,
{
struct virgl_context *vctx = virgl_context(ctx);
struct virgl_screen *vs = virgl_screen(ctx->screen);
- struct virgl_resource *grres = (struct virgl_resource *)res;
+ struct virgl_resource *grres = virgl_resource(res);
struct virgl_buffer *vbuf = virgl_buffer(res);
grres->clean = FALSE;
@@ -675,7 +675,7 @@ static struct pipe_sampler_view *virgl_create_sampler_view(struct pipe_context *
if (state == NULL)
return NULL;
- res = (struct virgl_resource *)texture;
+ res = virgl_resource(texture);
handle = virgl_object_assign_handle();
virgl_encode_sampler_view(vctx, handle, res, state);
@@ -817,8 +817,8 @@ static void virgl_resource_copy_region(struct pipe_context *ctx,
const struct pipe_box *src_box)
{
struct virgl_context *vctx = virgl_context(ctx);
- struct virgl_resource *dres = (struct virgl_resource *)dst;
- struct virgl_resource *sres = (struct virgl_resource *)src;
+ struct virgl_resource *dres = virgl_resource(dst);
+ struct virgl_resource *sres = virgl_resource(src);
dres->clean = FALSE;
virgl_encode_resource_copy_region(vctx, dres,
@@ -837,8 +837,8 @@ static void virgl_blit(struct pipe_context *ctx,
const struct pipe_blit_info *blit)
{
struct virgl_context *vctx = virgl_context(ctx);
- struct virgl_resource *dres = (struct virgl_resource *)blit->dst.resource;
- struct virgl_resource *sres = (struct virgl_resource *)blit->src.resource;
+ struct virgl_resource *dres = virgl_resource(blit->dst.resource);
+ struct virgl_resource *sres = virgl_resource(blit->src.resource);
dres->clean = FALSE;
virgl_encode_blit(vctx, dres, sres,
diff --git a/src/gallium/drivers/virgl/virgl_encode.c b/src/gallium/drivers/virgl/virgl_encode.c
index f3fca89394d..d825397e11b 100644
--- a/src/gallium/drivers/virgl/virgl_encode.c
+++ b/src/gallium/drivers/virgl/virgl_encode.c
@@ -378,7 +378,7 @@ int virgl_encoder_set_vertex_buffers(struct virgl_context *ctx,
int i;
virgl_encoder_write_cmd_dword(ctx, VIRGL_CMD0(VIRGL_CCMD_SET_VERTEX_BUFFERS, 0, VIRGL_SET_VERTEX_BUFFERS_SIZE(num_buffers)));
for (i = 0; i < num_buffers; i++) {
- struct virgl_resource *res = (struct virgl_resource *)buffers[i].buffer;
+ struct virgl_resource *res = virgl_resource(buffers[i].buffer);
virgl_encoder_write_dword(ctx->cbuf, buffers[i].stride);
virgl_encoder_write_dword(ctx->cbuf, buffers[i].buffer_offset);
virgl_encoder_write_res(ctx, res);
@@ -392,7 +392,7 @@ int virgl_encoder_set_index_buffer(struct virgl_context *ctx,
int length = VIRGL_SET_INDEX_BUFFER_SIZE(ib);
struct virgl_resource *res = NULL;
if (ib)
- res = (struct virgl_resource *)ib->buffer;
+ res = virgl_resource(ib->buffer);
virgl_encoder_write_cmd_dword(ctx, VIRGL_CMD0(VIRGL_CCMD_SET_INDEX_BUFFER, 0, length));
virgl_encoder_write_res(ctx, res);
diff --git a/src/gallium/drivers/virgl/virgl_resource.h b/src/gallium/drivers/virgl/virgl_resource.h
index 2d0bd8b6400..cae83214ae3 100644
--- a/src/gallium/drivers/virgl/virgl_resource.h
+++ b/src/gallium/drivers/virgl/virgl_resource.h
@@ -94,6 +94,16 @@ static inline struct virgl_buffer *virgl_buffer(struct pipe_resource *r)
return (struct virgl_buffer *)r;
}
+static inline struct virgl_texture *virgl_texture(struct pipe_resource *r)
+{
+ return (struct virgl_texture *)r;
+}
+
+static inline struct virgl_transfer *virgl_transfer(struct pipe_transfer *trans)
+{
+ return (struct virgl_transfer *)trans;
+}
+
struct pipe_resource *virgl_buffer_create(struct virgl_screen *vs,
const struct pipe_resource *templ);
diff --git a/src/gallium/drivers/virgl/virgl_screen.c b/src/gallium/drivers/virgl/virgl_screen.c
index fbc6ababd46..38bff4a50cf 100644
--- a/src/gallium/drivers/virgl/virgl_screen.c
+++ b/src/gallium/drivers/virgl/virgl_screen.c
@@ -479,7 +479,7 @@ static void virgl_flush_frontbuffer(struct pipe_screen *screen,
{
struct virgl_screen *vscreen = virgl_screen(screen);
struct virgl_winsys *vws = vscreen->vws;
- struct virgl_resource *vres = (struct virgl_resource *)res;
+ struct virgl_resource *vres = virgl_resource(res);
if (vws->flush_frontbuffer)
vws->flush_frontbuffer(vws, vres->hw_res, level, layer, winsys_drawable_handle,
diff --git a/src/gallium/drivers/virgl/virgl_streamout.c b/src/gallium/drivers/virgl/virgl_streamout.c
index c3cbcffc193..c449010e40e 100644
--- a/src/gallium/drivers/virgl/virgl_streamout.c
+++ b/src/gallium/drivers/virgl/virgl_streamout.c
@@ -33,7 +33,7 @@ static struct pipe_stream_output_target *virgl_create_so_target(
unsigned buffer_size)
{
struct virgl_context *vctx = virgl_context(ctx);
- struct virgl_resource *res = (struct virgl_resource *)buffer;
+ struct virgl_resource *res = virgl_resource(buffer);
struct virgl_so_target *t = CALLOC_STRUCT(virgl_so_target);
uint32_t handle;
diff --git a/src/gallium/drivers/virgl/virgl_texture.c b/src/gallium/drivers/virgl/virgl_texture.c
index 1838fdf4798..ebc4755f8b0 100644
--- a/src/gallium/drivers/virgl/virgl_texture.c
+++ b/src/gallium/drivers/virgl/virgl_texture.c
@@ -126,7 +126,7 @@ static void *virgl_texture_transfer_map(struct pipe_context *ctx,
{
struct virgl_context *vctx = virgl_context(ctx);
struct virgl_screen *vs = virgl_screen(ctx->screen);
- struct virgl_texture *vtex = (struct virgl_texture *)resource;
+ struct virgl_texture *vtex = virgl_texture(resource);
enum pipe_format format = resource->format;
struct virgl_transfer *trans;
void *ptr;
@@ -206,8 +206,8 @@ static void virgl_texture_transfer_unmap(struct pipe_context *ctx,
struct pipe_transfer *transfer)
{
struct virgl_context *vctx = virgl_context(ctx);
- struct virgl_transfer *trans = (struct virgl_transfer *)transfer;
- struct virgl_texture *vtex = (struct virgl_texture *)transfer->resource;
+ struct virgl_transfer *trans = virgl_transfer(transfer);
+ struct virgl_texture *vtex = virgl_texture(transfer->resource);
uint32_t l_stride;
if (transfer->resource->target != PIPE_TEXTURE_3D &&
@@ -281,7 +281,7 @@ static boolean virgl_texture_get_handle(struct pipe_screen *screen,
struct winsys_handle *whandle)
{
struct virgl_screen *vs = virgl_screen(screen);
- struct virgl_texture *vtex = (struct virgl_texture *)ptex;
+ struct virgl_texture *vtex = virgl_texture(ptex);
return vs->vws->resource_get_handle(vs->vws, vtex->base.hw_res, vtex->stride[0], whandle);
}
@@ -290,7 +290,7 @@ static void virgl_texture_destroy(struct pipe_screen *screen,
struct pipe_resource *res)
{
struct virgl_screen *vs = virgl_screen(screen);
- struct virgl_texture *vtex = (struct virgl_texture *)res;
+ struct virgl_texture *vtex = virgl_texture(res);
vs->vws->resource_unref(vs->vws, vtex->base.hw_res);
FREE(vtex);
}