[Mesa-dev] [PATCH] virgl: fix flushing while removing sampler views
marcandre.lureau at redhat.com
marcandre.lureau at redhat.com
Tue Sep 13 18:00:35 UTC 2016
From: Marc-André Lureau <marcandre.lureau at redhat.com>
When updating the sampler views, virgl might need to flush. After
flushing, the resources are reattached, however, the sampler
enabled_mask isn't yet updated, and some views could be in the process
of being removed, which lead to the following crash:
Thread 1 "heaven_x64" received signal SIGSEGV, Segmentation fault.
0x00007f83893cc3de in virgl_attach_res_sampler_views (vctx=vctx at entry=0x1c22c00, shader_type=shader_type at entry=1) at virgl_context.c:113
113 res = virgl_resource(tinfo->views[i]->base.texture);
(gdb) bt
#0 0x00007f83893cc3de in virgl_attach_res_sampler_views (vctx=vctx at entry=0x1c22c00, shader_type=shader_type at entry=1) at virgl_context.c:113
#1 0x00007f83893cc703 in virgl_reemit_res (vctx=0x1c22c00) at virgl_context.c:182
#2 virgl_flush_eq (ctx=ctx at entry=0x1c22c00, closure=0x1c22c00) at virgl_context.c:637
#3 0x00007f83893ccbf8 in virgl_flush_from_st (ctx=0x1c22c00, fence=<optimized out>, flags=<optimized out>) at virgl_context.c:659
#4 0x00007f83893cd6b0 in virgl_encoder_write_cmd_dword (ctx=ctx at entry=0x1c22c00, dword=dword at entry=67075) at virgl_encode.c:43
#5 0x00007f83893cd76b in virgl_encode_delete_object (ctx=0x1c22c00, handle=1306480, object=object at entry=6) at virgl_encode.c:72
#6 0x00007f83893ccc81 in virgl_destroy_sampler_view (ctx=<optimized out>, view=0x7aca1b0) at virgl_context.c:741
#7 0x00007f83893cca17 in pipe_sampler_view_reference (view=0x0, ptr=0x1c22fc8) at ../../../../src/gallium/auxiliary/util/u_inlines.h:151
#8 virgl_set_sampler_views (ctx=0x1c22c00, shader_type=1, start_slot=<optimized out>, num_views=<optimized out>, views=<optimized out>) at virgl_context.c:724
#9 0x00007f8388fffd68 in cso_set_sampler_views (ctx=0x1ca2ee0, shader_stage=<optimized out>, count=9, views=<optimized out>) at cso_cache/cso_context.c:1301
#10 0x00007f8388e670c1 in update_textures (st=<optimized out>, mesa_shader=<optimized out>, prog=<optimized out>, max_units=16, sampler_views=0x1c8c140, num_textures=0x1c8c644) at state_tracker/st_atom_texture.c:465
#11 0x00007f8388e6296d in st_validate_state (st=st at entry=0x1c8a710, pipeline=pipeline at entry=ST_PIPELINE_RENDER) at state_tracker/st_atom.c:289
#12 0x00007f8388e8343b in st_draw_vbo (ctx=0x1c50600, prims=0x7ffe99b5a580, nr_prims=1, ib=0x7ffe99b5a560, index_bounds_valid=<optimized out>, min_index=<optimized out>, max_index=<optimized out>, tfb_vertcount=0x0, stream=0,
indirect=0x0) at state_tracker/st_draw.c:176
#13 0x00007f8388e44d34 in vbo_validated_drawrangeelements (ctx=ctx at entry=0x1c50600, mode=mode at entry=4, index_bounds_valid=index_bounds_valid at entry=0 '\000', start=start at entry=4294967295, end=end at entry=4294967295, count=count at entry=2688,
type=5123, indices=0x0, basevertex=0, numInstances=1, baseInstance=0) at vbo/vbo_exec_array.c:849
#14 0x00007f8388e44db5 in vbo_exec_DrawElementsInstanced (mode=4,
#count=2688, type=5123, indices=0x0, numInstances=1) at
#vbo/vbo_exec_array.c:1030
Instead, remove the views from enabled_mask immediately.
Signed-off-by: Marc-André Lureau <marcandre.lureau at redhat.com>
---
src/gallium/drivers/virgl/virgl_context.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/gallium/drivers/virgl/virgl_context.c b/src/gallium/drivers/virgl/virgl_context.c
index 9007583..55144d5 100644
--- a/src/gallium/drivers/virgl/virgl_context.c
+++ b/src/gallium/drivers/virgl/virgl_context.c
@@ -711,6 +711,7 @@ static void virgl_set_sampler_views(struct pipe_context *ctx,
pipe_sampler_view_reference((struct pipe_sampler_view **)&tinfo->views[i], NULL);
}
+ tinfo->enabled_mask &= ~disable_mask;
for (i = 0; i < num_views; i++) {
struct virgl_sampler_view *grview = virgl_sampler_view(views[i]);
@@ -721,12 +722,11 @@ static void virgl_set_sampler_views(struct pipe_context *ctx,
new_mask |= 1 << i;
pipe_sampler_view_reference((struct pipe_sampler_view **)&tinfo->views[i], views[i]);
} else {
+ tinfo->enabled_mask &= ~(1 << i);
pipe_sampler_view_reference((struct pipe_sampler_view **)&tinfo->views[i], NULL);
- disable_mask |= 1 << i;
}
}
- tinfo->enabled_mask &= ~disable_mask;
tinfo->enabled_mask |= new_mask;
virgl_encode_set_sampler_views(vctx, shader_type, start_slot, num_views, tinfo->views);
virgl_attach_res_sampler_views(vctx, shader_type);
--
2.10.0
More information about the mesa-dev
mailing list