summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEmil Velikov <[email protected]>2015-10-28 10:48:31 +0000
committerEmil Velikov <[email protected]>2015-10-30 17:37:08 +0000
commit6b123fa07ff9d73d6e67416c2372eab5c17282b6 (patch)
tree4a77a0546c32450d71a7d49608ba1f9725f07c24 /src
parent1f43e4e1a3395592a9d0843cdba725a2ea45fa74 (diff)
virgl: add virgl_context/sampler_view/so_target() upcast wrappers
Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Dave Airlie <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/virgl/virgl_buffer.c6
-rw-r--r--src/gallium/drivers/virgl/virgl_context.c98
-rw-r--r--src/gallium/drivers/virgl/virgl_context.h17
-rw-r--r--src/gallium/drivers/virgl/virgl_encode.c2
-rw-r--r--src/gallium/drivers/virgl/virgl_query.c12
-rw-r--r--src/gallium/drivers/virgl/virgl_streamout.c8
-rw-r--r--src/gallium/drivers/virgl/virgl_texture.c4
7 files changed, 82 insertions, 65 deletions
diff --git a/src/gallium/drivers/virgl/virgl_buffer.c b/src/gallium/drivers/virgl/virgl_buffer.c
index 93fb29598a9..96cb82c4a90 100644
--- a/src/gallium/drivers/virgl/virgl_buffer.c
+++ b/src/gallium/drivers/virgl/virgl_buffer.c
@@ -43,7 +43,7 @@ static void *virgl_buffer_transfer_map(struct pipe_context *ctx,
const struct pipe_box *box,
struct pipe_transfer **transfer)
{
- struct virgl_context *vctx = (struct virgl_context *)ctx;
+ struct virgl_context *vctx = virgl_context(ctx);
struct virgl_screen *vs = virgl_screen(ctx->screen);
struct virgl_buffer *vbuf = virgl_buffer(resource);
struct virgl_transfer *trans;
@@ -97,7 +97,7 @@ static void *virgl_buffer_transfer_map(struct pipe_context *ctx,
static void virgl_buffer_transfer_unmap(struct pipe_context *ctx,
struct pipe_transfer *transfer)
{
- struct virgl_context *vctx = (struct virgl_context *)ctx;
+ struct virgl_context *vctx = virgl_context(ctx);
struct virgl_transfer *trans = (struct virgl_transfer *)transfer;
struct virgl_buffer *vbuf = virgl_buffer(transfer->resource);
@@ -119,7 +119,7 @@ static void virgl_buffer_transfer_flush_region(struct pipe_context *ctx,
struct pipe_transfer *transfer,
const struct pipe_box *box)
{
- struct virgl_context *vctx = (struct virgl_context *)ctx;
+ struct virgl_context *vctx = virgl_context(ctx);
struct virgl_buffer *vbuf = virgl_buffer(transfer->resource);
if (!vbuf->on_list) {
diff --git a/src/gallium/drivers/virgl/virgl_context.c b/src/gallium/drivers/virgl/virgl_context.c
index 31464595dad..f222e532bf0 100644
--- a/src/gallium/drivers/virgl/virgl_context.c
+++ b/src/gallium/drivers/virgl/virgl_context.c
@@ -195,7 +195,7 @@ static struct pipe_surface *virgl_create_surface(struct pipe_context *ctx,
struct pipe_resource *resource,
const struct pipe_surface *templ)
{
- struct virgl_context *vctx = (struct virgl_context *)ctx;
+ struct virgl_context *vctx = virgl_context(ctx);
struct virgl_surface *surf;
struct virgl_resource *res = virgl_resource(resource);
uint32_t handle;
@@ -230,7 +230,7 @@ static struct pipe_surface *virgl_create_surface(struct pipe_context *ctx,
static void virgl_surface_destroy(struct pipe_context *ctx,
struct pipe_surface *psurf)
{
- struct virgl_context *vctx = (struct virgl_context *)ctx;
+ struct virgl_context *vctx = virgl_context(ctx);
struct virgl_surface *surf = (struct virgl_surface *)psurf;
pipe_resource_reference(&surf->base.texture, NULL);
@@ -241,7 +241,7 @@ static void virgl_surface_destroy(struct pipe_context *ctx,
static void *virgl_create_blend_state(struct pipe_context *ctx,
const struct pipe_blend_state *blend_state)
{
- struct virgl_context *vctx = (struct virgl_context *)ctx;
+ struct virgl_context *vctx = virgl_context(ctx);
uint32_t handle;
handle = virgl_object_assign_handle();
@@ -253,7 +253,7 @@ static void *virgl_create_blend_state(struct pipe_context *ctx,
static void virgl_bind_blend_state(struct pipe_context *ctx,
void *blend_state)
{
- struct virgl_context *vctx = (struct virgl_context *)ctx;
+ struct virgl_context *vctx = virgl_context(ctx);
uint32_t handle = (unsigned long)blend_state;
virgl_encode_bind_object(vctx, handle, VIRGL_OBJECT_BLEND);
}
@@ -261,7 +261,7 @@ static void virgl_bind_blend_state(struct pipe_context *ctx,
static void virgl_delete_blend_state(struct pipe_context *ctx,
void *blend_state)
{
- struct virgl_context *vctx = (struct virgl_context *)ctx;
+ struct virgl_context *vctx = virgl_context(ctx);
uint32_t handle = (unsigned long)blend_state;
virgl_encode_delete_object(vctx, handle, VIRGL_OBJECT_BLEND);
}
@@ -269,7 +269,7 @@ static void virgl_delete_blend_state(struct pipe_context *ctx,
static void *virgl_create_depth_stencil_alpha_state(struct pipe_context *ctx,
const struct pipe_depth_stencil_alpha_state *blend_state)
{
- struct virgl_context *vctx = (struct virgl_context *)ctx;
+ struct virgl_context *vctx = virgl_context(ctx);
uint32_t handle;
handle = virgl_object_assign_handle();
@@ -280,7 +280,7 @@ static void *virgl_create_depth_stencil_alpha_state(struct pipe_context *ctx,
static void virgl_bind_depth_stencil_alpha_state(struct pipe_context *ctx,
void *blend_state)
{
- struct virgl_context *vctx = (struct virgl_context *)ctx;
+ struct virgl_context *vctx = virgl_context(ctx);
uint32_t handle = (unsigned long)blend_state;
virgl_encode_bind_object(vctx, handle, VIRGL_OBJECT_DSA);
}
@@ -288,7 +288,7 @@ static void virgl_bind_depth_stencil_alpha_state(struct pipe_context *ctx,
static void virgl_delete_depth_stencil_alpha_state(struct pipe_context *ctx,
void *dsa_state)
{
- struct virgl_context *vctx = (struct virgl_context *)ctx;
+ struct virgl_context *vctx = virgl_context(ctx);
uint32_t handle = (unsigned long)dsa_state;
virgl_encode_delete_object(vctx, handle, VIRGL_OBJECT_DSA);
}
@@ -296,7 +296,7 @@ static void virgl_delete_depth_stencil_alpha_state(struct pipe_context *ctx,
static void *virgl_create_rasterizer_state(struct pipe_context *ctx,
const struct pipe_rasterizer_state *rs_state)
{
- struct virgl_context *vctx = (struct virgl_context *)ctx;
+ struct virgl_context *vctx = virgl_context(ctx);
uint32_t handle;
handle = virgl_object_assign_handle();
@@ -307,7 +307,7 @@ static void *virgl_create_rasterizer_state(struct pipe_context *ctx,
static void virgl_bind_rasterizer_state(struct pipe_context *ctx,
void *rs_state)
{
- struct virgl_context *vctx = (struct virgl_context *)ctx;
+ struct virgl_context *vctx = virgl_context(ctx);
uint32_t handle = (unsigned long)rs_state;
virgl_encode_bind_object(vctx, handle, VIRGL_OBJECT_RASTERIZER);
@@ -316,7 +316,7 @@ static void virgl_bind_rasterizer_state(struct pipe_context *ctx,
static void virgl_delete_rasterizer_state(struct pipe_context *ctx,
void *rs_state)
{
- struct virgl_context *vctx = (struct virgl_context *)ctx;
+ struct virgl_context *vctx = virgl_context(ctx);
uint32_t handle = (unsigned long)rs_state;
virgl_encode_delete_object(vctx, handle, VIRGL_OBJECT_RASTERIZER);
}
@@ -324,7 +324,7 @@ static void virgl_delete_rasterizer_state(struct pipe_context *ctx,
static void virgl_set_framebuffer_state(struct pipe_context *ctx,
const struct pipe_framebuffer_state *state)
{
- struct virgl_context *vctx = (struct virgl_context *)ctx;
+ struct virgl_context *vctx = virgl_context(ctx);
vctx->framebuffer = *state;
virgl_encoder_set_framebuffer_state(vctx, state);
@@ -336,7 +336,7 @@ static void virgl_set_viewport_states(struct pipe_context *ctx,
unsigned num_viewports,
const struct pipe_viewport_state *state)
{
- struct virgl_context *vctx = (struct virgl_context *)ctx;
+ struct virgl_context *vctx = virgl_context(ctx);
virgl_encoder_set_viewport_states(vctx, start_slot, num_viewports, state);
}
@@ -344,7 +344,7 @@ static void *virgl_create_vertex_elements_state(struct pipe_context *ctx,
unsigned num_elements,
const struct pipe_vertex_element *elements)
{
- struct virgl_context *vctx = (struct virgl_context *)ctx;
+ struct virgl_context *vctx = virgl_context(ctx);
uint32_t handle = virgl_object_assign_handle();
virgl_encoder_create_vertex_elements(vctx, handle,
num_elements, elements);
@@ -355,7 +355,7 @@ static void *virgl_create_vertex_elements_state(struct pipe_context *ctx,
static void virgl_delete_vertex_elements_state(struct pipe_context *ctx,
void *ve)
{
- struct virgl_context *vctx = (struct virgl_context *)ctx;
+ struct virgl_context *vctx = virgl_context(ctx);
uint32_t handle = (unsigned long)ve;
virgl_encode_delete_object(vctx, handle, VIRGL_OBJECT_VERTEX_ELEMENTS);
@@ -364,7 +364,7 @@ static void virgl_delete_vertex_elements_state(struct pipe_context *ctx,
static void virgl_bind_vertex_elements_state(struct pipe_context *ctx,
void *ve)
{
- struct virgl_context *vctx = (struct virgl_context *)ctx;
+ struct virgl_context *vctx = virgl_context(ctx);
uint32_t handle = (unsigned long)ve;
virgl_encode_bind_object(vctx, handle, VIRGL_OBJECT_VERTEX_ELEMENTS);
}
@@ -374,7 +374,7 @@ static void virgl_set_vertex_buffers(struct pipe_context *ctx,
unsigned num_buffers,
const struct pipe_vertex_buffer *buffers)
{
- struct virgl_context *vctx = (struct virgl_context *)ctx;
+ struct virgl_context *vctx = virgl_context(ctx);
util_set_vertex_buffers_count(vctx->vertex_buffer,
&vctx->num_vertex_buffers,
@@ -385,7 +385,7 @@ static void virgl_set_vertex_buffers(struct pipe_context *ctx,
static void virgl_hw_set_vertex_buffers(struct pipe_context *ctx)
{
- struct virgl_context *vctx = (struct virgl_context *)ctx;
+ struct virgl_context *vctx = virgl_context(ctx);
if (vctx->vertex_array_dirty) {
virgl_encoder_set_vertex_buffers(vctx, vctx->num_vertex_buffers, vctx->vertex_buffer);
@@ -396,21 +396,21 @@ static void virgl_hw_set_vertex_buffers(struct pipe_context *ctx)
static void virgl_set_stencil_ref(struct pipe_context *ctx,
const struct pipe_stencil_ref *ref)
{
- struct virgl_context *vctx = (struct virgl_context *)ctx;
+ struct virgl_context *vctx = virgl_context(ctx);
virgl_encoder_set_stencil_ref(vctx, ref);
}
static void virgl_set_blend_color(struct pipe_context *ctx,
const struct pipe_blend_color *color)
{
- struct virgl_context *vctx = (struct virgl_context *)ctx;
+ struct virgl_context *vctx = virgl_context(ctx);
virgl_encoder_set_blend_color(vctx, color);
}
static void virgl_set_index_buffer(struct pipe_context *ctx,
const struct pipe_index_buffer *ib)
{
- struct virgl_context *vctx = (struct virgl_context *)ctx;
+ struct virgl_context *vctx = virgl_context(ctx);
if (ib) {
pipe_resource_reference(&vctx->index_buffer.buffer, ib->buffer);
@@ -423,7 +423,7 @@ static void virgl_set_index_buffer(struct pipe_context *ctx,
static void virgl_hw_set_index_buffer(struct pipe_context *ctx,
struct pipe_index_buffer *ib)
{
- struct virgl_context *vctx = (struct virgl_context *)ctx;
+ struct virgl_context *vctx = virgl_context(ctx);
virgl_encoder_set_index_buffer(vctx, ib);
virgl_attach_res_index_buffer(vctx);
}
@@ -432,7 +432,7 @@ static void virgl_set_constant_buffer(struct pipe_context *ctx,
uint shader, uint index,
struct pipe_constant_buffer *buf)
{
- struct virgl_context *vctx = (struct virgl_context *)ctx;
+ struct virgl_context *vctx = virgl_context(ctx);
if (buf) {
if (!buf->user_buffer){
@@ -459,7 +459,7 @@ void virgl_transfer_inline_write(struct pipe_context *ctx,
unsigned stride,
unsigned layer_stride)
{
- struct virgl_context *vctx = (struct virgl_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_buffer *vbuf = virgl_buffer(res);
@@ -480,7 +480,7 @@ static void *virgl_shader_encoder(struct pipe_context *ctx,
const struct pipe_shader_state *shader,
unsigned type)
{
- struct virgl_context *vctx = (struct virgl_context *)ctx;
+ struct virgl_context *vctx = virgl_context(ctx);
uint32_t handle;
struct tgsi_token *new_tokens;
int ret;
@@ -525,7 +525,7 @@ virgl_delete_fs_state(struct pipe_context *ctx,
void *fs)
{
uint32_t handle = (unsigned long)fs;
- struct virgl_context *vctx = (struct virgl_context *)ctx;
+ struct virgl_context *vctx = virgl_context(ctx);
virgl_encode_delete_object(vctx, handle, VIRGL_OBJECT_SHADER);
}
@@ -535,7 +535,7 @@ virgl_delete_gs_state(struct pipe_context *ctx,
void *gs)
{
uint32_t handle = (unsigned long)gs;
- struct virgl_context *vctx = (struct virgl_context *)ctx;
+ struct virgl_context *vctx = virgl_context(ctx);
virgl_encode_delete_object(vctx, handle, VIRGL_OBJECT_SHADER);
}
@@ -545,7 +545,7 @@ virgl_delete_vs_state(struct pipe_context *ctx,
void *vs)
{
uint32_t handle = (unsigned long)vs;
- struct virgl_context *vctx = (struct virgl_context *)ctx;
+ struct virgl_context *vctx = virgl_context(ctx);
virgl_encode_delete_object(vctx, handle, VIRGL_OBJECT_SHADER);
}
@@ -554,7 +554,7 @@ static void virgl_bind_vs_state(struct pipe_context *ctx,
void *vss)
{
uint32_t handle = (unsigned long)vss;
- struct virgl_context *vctx = (struct virgl_context *)ctx;
+ struct virgl_context *vctx = virgl_context(ctx);
virgl_encode_bind_shader(vctx, handle, PIPE_SHADER_VERTEX);
}
@@ -563,7 +563,7 @@ static void virgl_bind_gs_state(struct pipe_context *ctx,
void *vss)
{
uint32_t handle = (unsigned long)vss;
- struct virgl_context *vctx = (struct virgl_context *)ctx;
+ struct virgl_context *vctx = virgl_context(ctx);
virgl_encode_bind_shader(vctx, handle, PIPE_SHADER_GEOMETRY);
}
@@ -573,7 +573,7 @@ static void virgl_bind_fs_state(struct pipe_context *ctx,
void *vss)
{
uint32_t handle = (unsigned long)vss;
- struct virgl_context *vctx = (struct virgl_context *)ctx;
+ struct virgl_context *vctx = virgl_context(ctx);
virgl_encode_bind_shader(vctx, handle, PIPE_SHADER_FRAGMENT);
}
@@ -583,7 +583,7 @@ static void virgl_clear(struct pipe_context *ctx,
const union pipe_color_union *color,
double depth, unsigned stencil)
{
- struct virgl_context *vctx = (struct virgl_context *)ctx;
+ struct virgl_context *vctx = virgl_context(ctx);
virgl_encode_clear(vctx, buffers, color, depth, stencil);
}
@@ -591,7 +591,7 @@ static void virgl_clear(struct pipe_context *ctx,
static void virgl_draw_vbo(struct pipe_context *ctx,
const struct pipe_draw_info *dinfo)
{
- struct virgl_context *vctx = (struct virgl_context *)ctx;
+ struct virgl_context *vctx = virgl_context(ctx);
struct virgl_screen *rs = virgl_screen(ctx->screen);
struct pipe_index_buffer ib = {};
struct pipe_draw_info info = *dinfo;
@@ -645,7 +645,7 @@ static void virgl_flush_from_st(struct pipe_context *ctx,
struct pipe_fence_handle **fence,
enum pipe_flush_flags flags)
{
- struct virgl_context *vctx = (struct virgl_context *)ctx;
+ struct virgl_context *vctx = virgl_context(ctx);
struct virgl_screen *rs = virgl_screen(ctx->screen);
struct virgl_buffer *buf, *tmp;
@@ -667,7 +667,7 @@ static struct pipe_sampler_view *virgl_create_sampler_view(struct pipe_context *
struct pipe_resource *texture,
const struct pipe_sampler_view *state)
{
- struct virgl_context *vctx = (struct virgl_context *)ctx;
+ struct virgl_context *vctx = virgl_context(ctx);
struct virgl_sampler_view *grview = CALLOC_STRUCT(virgl_sampler_view);
uint32_t handle;
struct virgl_resource *res;
@@ -695,7 +695,7 @@ static void virgl_set_sampler_views(struct pipe_context *ctx,
unsigned num_views,
struct pipe_sampler_view **views)
{
- struct virgl_context *vctx = (struct virgl_context *)ctx;
+ struct virgl_context *vctx = virgl_context(ctx);
int i;
uint32_t disable_mask = ~((1ull << num_views) - 1);
struct virgl_textures_info *tinfo = &vctx->samplers[shader_type];
@@ -712,7 +712,7 @@ static void virgl_set_sampler_views(struct pipe_context *ctx,
}
for (i = 0; i < num_views; i++) {
- struct virgl_sampler_view *grview = (struct virgl_sampler_view *)views[i];
+ struct virgl_sampler_view *grview = virgl_sampler_view(views[i]);
if (views[i] == (struct pipe_sampler_view *)tinfo->views[i])
continue;
@@ -735,8 +735,8 @@ static void virgl_set_sampler_views(struct pipe_context *ctx,
static void virgl_destroy_sampler_view(struct pipe_context *ctx,
struct pipe_sampler_view *view)
{
- struct virgl_context *vctx = (struct virgl_context *)ctx;
- struct virgl_sampler_view *grview = (struct virgl_sampler_view *)view;
+ struct virgl_context *vctx = virgl_context(ctx);
+ struct virgl_sampler_view *grview = virgl_sampler_view(view);
virgl_encode_delete_object(vctx, grview->handle, VIRGL_OBJECT_SAMPLER_VIEW);
pipe_resource_reference(&view->texture, NULL);
@@ -746,7 +746,7 @@ static void virgl_destroy_sampler_view(struct pipe_context *ctx,
static void *virgl_create_sampler_state(struct pipe_context *ctx,
const struct pipe_sampler_state *state)
{
- struct virgl_context *vctx = (struct virgl_context *)ctx;
+ struct virgl_context *vctx = virgl_context(ctx);
uint32_t handle;
handle = virgl_object_assign_handle();
@@ -758,7 +758,7 @@ static void *virgl_create_sampler_state(struct pipe_context *ctx,
static void virgl_delete_sampler_state(struct pipe_context *ctx,
void *ss)
{
- struct virgl_context *vctx = (struct virgl_context *)ctx;
+ struct virgl_context *vctx = virgl_context(ctx);
uint32_t handle = (unsigned long)ss;
virgl_encode_delete_object(vctx, handle, VIRGL_OBJECT_SAMPLER_STATE);
@@ -769,7 +769,7 @@ static void virgl_bind_sampler_states(struct pipe_context *ctx,
unsigned num_samplers,
void **samplers)
{
- struct virgl_context *vctx = (struct virgl_context *)ctx;
+ struct virgl_context *vctx = virgl_context(ctx);
uint32_t handles[32];
int i;
for (i = 0; i < num_samplers; i++) {
@@ -781,7 +781,7 @@ static void virgl_bind_sampler_states(struct pipe_context *ctx,
static void virgl_set_polygon_stipple(struct pipe_context *ctx,
const struct pipe_poly_stipple *ps)
{
- struct virgl_context *vctx = (struct virgl_context *)ctx;
+ struct virgl_context *vctx = virgl_context(ctx);
virgl_encoder_set_polygon_stipple(vctx, ps);
}
@@ -790,21 +790,21 @@ static void virgl_set_scissor_states(struct pipe_context *ctx,
unsigned num_scissor,
const struct pipe_scissor_state *ss)
{
- struct virgl_context *vctx = (struct virgl_context *)ctx;
+ struct virgl_context *vctx = virgl_context(ctx);
virgl_encoder_set_scissor_state(vctx, start_slot, num_scissor, ss);
}
static void virgl_set_sample_mask(struct pipe_context *ctx,
unsigned sample_mask)
{
- struct virgl_context *vctx = (struct virgl_context *)ctx;
+ struct virgl_context *vctx = virgl_context(ctx);
virgl_encoder_set_sample_mask(vctx, sample_mask);
}
static void virgl_set_clip_state(struct pipe_context *ctx,
const struct pipe_clip_state *clip)
{
- struct virgl_context *vctx = (struct virgl_context *)ctx;
+ struct virgl_context *vctx = virgl_context(ctx);
virgl_encoder_set_clip_state(vctx, clip);
}
@@ -816,7 +816,7 @@ static void virgl_resource_copy_region(struct pipe_context *ctx,
unsigned src_level,
const struct pipe_box *src_box)
{
- struct virgl_context *vctx = (struct virgl_context *)ctx;
+ struct virgl_context *vctx = virgl_context(ctx);
struct virgl_resource *dres = (struct virgl_resource *)dst;
struct virgl_resource *sres = (struct virgl_resource *)src;
@@ -836,7 +836,7 @@ virgl_flush_resource(struct pipe_context *pipe,
static void virgl_blit(struct pipe_context *ctx,
const struct pipe_blit_info *blit)
{
- struct virgl_context *vctx = (struct virgl_context *)ctx;
+ 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;
@@ -848,7 +848,7 @@ static void virgl_blit(struct pipe_context *ctx,
static void
virgl_context_destroy( struct pipe_context *ctx )
{
- struct virgl_context *vctx = (struct virgl_context *)ctx;
+ struct virgl_context *vctx = virgl_context(ctx);
struct virgl_screen *rs = virgl_screen(ctx->screen);
vctx->framebuffer.zsbuf = NULL;
diff --git a/src/gallium/drivers/virgl/virgl_context.h b/src/gallium/drivers/virgl/virgl_context.h
index 948ea2d552b..3d8d3ce8bd4 100644
--- a/src/gallium/drivers/virgl/virgl_context.h
+++ b/src/gallium/drivers/virgl/virgl_context.h
@@ -79,6 +79,23 @@ struct virgl_context {
uint32_t hw_sub_ctx_id;
};
+static inline struct virgl_sampler_view *
+virgl_sampler_view(struct pipe_sampler_view *view)
+{
+ return (struct virgl_sampler_view *)view;
+};
+
+static inline struct virgl_so_target *
+virgl_so_target(struct pipe_stream_output_target *target)
+{
+ return (struct virgl_so_target *)target;
+}
+
+static inline struct virgl_context *virgl_context(struct pipe_context *ctx)
+{
+ return (struct virgl_context *)ctx;
+}
+
struct pipe_context *virgl_context_create(struct pipe_screen *pscreen,
void *priv, unsigned flags);
diff --git a/src/gallium/drivers/virgl/virgl_encode.c b/src/gallium/drivers/virgl/virgl_encode.c
index b4b49a21494..f3fca89394d 100644
--- a/src/gallium/drivers/virgl/virgl_encode.c
+++ b/src/gallium/drivers/virgl/virgl_encode.c
@@ -825,7 +825,7 @@ int virgl_encoder_set_so_targets(struct virgl_context *ctx,
virgl_encoder_write_cmd_dword(ctx, VIRGL_CMD0(VIRGL_CCMD_SET_STREAMOUT_TARGETS, 0, num_targets + 1));
virgl_encoder_write_dword(ctx->cbuf, append_bitmask);
for (i = 0; i < num_targets; i++) {
- struct virgl_so_target *tg = (struct virgl_so_target *)targets[i];
+ struct virgl_so_target *tg = virgl_so_target(targets[i]);
virgl_encoder_write_dword(ctx->cbuf, tg->handle);
}
return 0;
diff --git a/src/gallium/drivers/virgl/virgl_query.c b/src/gallium/drivers/virgl/virgl_query.c
index f79be5f2f09..ea50f2f9341 100644
--- a/src/gallium/drivers/virgl/virgl_query.c
+++ b/src/gallium/drivers/virgl/virgl_query.c
@@ -42,7 +42,7 @@ static void virgl_render_condition(struct pipe_context *ctx,
boolean condition,
uint mode)
{
- struct virgl_context *vctx = (struct virgl_context *)ctx;
+ struct virgl_context *vctx = virgl_context(ctx);
struct virgl_query *query = (struct virgl_query *)q;
uint32_t handle = 0;
if (q)
@@ -53,7 +53,7 @@ static void virgl_render_condition(struct pipe_context *ctx,
static struct pipe_query *virgl_create_query(struct pipe_context *ctx,
unsigned query_type, unsigned index)
{
- struct virgl_context *vctx = (struct virgl_context *)ctx;
+ struct virgl_context *vctx = virgl_context(ctx);
struct virgl_query *query;
uint32_t handle;
@@ -81,7 +81,7 @@ static struct pipe_query *virgl_create_query(struct pipe_context *ctx,
static void virgl_destroy_query(struct pipe_context *ctx,
struct pipe_query *q)
{
- struct virgl_context *vctx = (struct virgl_context *)ctx;
+ struct virgl_context *vctx = virgl_context(ctx);
struct virgl_query *query = (struct virgl_query *)q;
virgl_encode_delete_object(vctx, query->handle, VIRGL_OBJECT_QUERY);
@@ -93,7 +93,7 @@ static void virgl_destroy_query(struct pipe_context *ctx,
static boolean virgl_begin_query(struct pipe_context *ctx,
struct pipe_query *q)
{
- struct virgl_context *vctx = (struct virgl_context *)ctx;
+ struct virgl_context *vctx = virgl_context(ctx);
struct virgl_query *query = (struct virgl_query *)q;
query->buf->clean = FALSE;
@@ -104,7 +104,7 @@ static boolean virgl_begin_query(struct pipe_context *ctx,
static void virgl_end_query(struct pipe_context *ctx,
struct pipe_query *q)
{
- struct virgl_context *vctx = (struct virgl_context *)ctx;
+ struct virgl_context *vctx = virgl_context(ctx);
struct virgl_query *query = (struct virgl_query *)q;
struct pipe_box box;
@@ -122,7 +122,7 @@ static boolean virgl_get_query_result(struct pipe_context *ctx,
boolean wait,
union pipe_query_result *result)
{
- struct virgl_context *vctx = (struct virgl_context *)ctx;
+ struct virgl_context *vctx = virgl_context(ctx);
struct virgl_query *query = (struct virgl_query *)q;
struct pipe_transfer *transfer;
struct virgl_host_query_state *host_state;
diff --git a/src/gallium/drivers/virgl/virgl_streamout.c b/src/gallium/drivers/virgl/virgl_streamout.c
index 95420f688d3..c3cbcffc193 100644
--- a/src/gallium/drivers/virgl/virgl_streamout.c
+++ b/src/gallium/drivers/virgl/virgl_streamout.c
@@ -32,7 +32,7 @@ static struct pipe_stream_output_target *virgl_create_so_target(
unsigned buffer_offset,
unsigned buffer_size)
{
- struct virgl_context *vctx = (struct virgl_context *)ctx;
+ struct virgl_context *vctx = virgl_context(ctx);
struct virgl_resource *res = (struct virgl_resource *)buffer;
struct virgl_so_target *t = CALLOC_STRUCT(virgl_so_target);
uint32_t handle;
@@ -55,8 +55,8 @@ static struct pipe_stream_output_target *virgl_create_so_target(
static void virgl_destroy_so_target(struct pipe_context *ctx,
struct pipe_stream_output_target *target)
{
- struct virgl_context *vctx = (struct virgl_context *)ctx;
- struct virgl_so_target *t = (struct virgl_so_target *)target;
+ struct virgl_context *vctx = virgl_context(ctx);
+ struct virgl_so_target *t = virgl_so_target(target);
pipe_resource_reference(&t->base.buffer, NULL);
virgl_encode_delete_object(vctx, t->handle, VIRGL_OBJECT_STREAMOUT_TARGET);
@@ -68,7 +68,7 @@ static void virgl_set_so_targets(struct pipe_context *ctx,
struct pipe_stream_output_target **targets,
const unsigned *offset)
{
- struct virgl_context *vctx = (struct virgl_context *)ctx;
+ struct virgl_context *vctx = virgl_context(ctx);
int i;
for (i = 0; i < num_targets; i++) {
pipe_resource_reference(&vctx->so_targets[i].base.buffer, targets[i]->buffer);
diff --git a/src/gallium/drivers/virgl/virgl_texture.c b/src/gallium/drivers/virgl/virgl_texture.c
index 4fbdb69c586..1838fdf4798 100644
--- a/src/gallium/drivers/virgl/virgl_texture.c
+++ b/src/gallium/drivers/virgl/virgl_texture.c
@@ -124,7 +124,7 @@ static void *virgl_texture_transfer_map(struct pipe_context *ctx,
const struct pipe_box *box,
struct pipe_transfer **transfer)
{
- struct virgl_context *vctx = (struct virgl_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;
enum pipe_format format = resource->format;
@@ -205,7 +205,7 @@ static void *virgl_texture_transfer_map(struct pipe_context *ctx,
static void virgl_texture_transfer_unmap(struct pipe_context *ctx,
struct pipe_transfer *transfer)
{
- struct virgl_context *vctx = (struct virgl_context *)ctx;
+ struct virgl_context *vctx = virgl_context(ctx);
struct virgl_transfer *trans = (struct virgl_transfer *)transfer;
struct virgl_texture *vtex = (struct virgl_texture *)transfer->resource;
uint32_t l_stride;