[Mesa-dev] [PATCH] loader: fix the no-modifiers case

Bas Nieuwenhuizen bas at basnieuwenhuizen.nl
Tue Jan 22 21:45:16 UTC 2019


Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>

On Tue, Jan 22, 2019 at 10:20 PM Kristian Høgsberg <hoegsberg at gmail.com> wrote:
>
> On Tue, Jan 22, 2019 at 11:45 AM Rob Clark <robdclark at gmail.com> wrote:
> >
> > Normally modifiers take precendence over use flags, as they are more
> > explicit.  But if the driver supports modifiers, but the xserver does
> > not, then we should fallback to the old mechanism of allocating a buffer
> > using 'use' flags.
> >
> > Fixes: 069fdd5f9facbd72fb6a289696c7b74e3237e70f
> > Signed-off-by: Rob Clark <robdclark at gmail.com>
>
> Reviewed-by: Kristian H. Kristensen <hoegsberg at chromium.org>
>
> > ---
> > Backport note:  This fixes an issue with enabling UBWC in freedreno/a6xx
> > (which is something I'd like to land soonish, but not something that
> > exists yet in release branches).  Unless a similar issue is reported in
> > other drivers, this may not be worth backporting to release branches, at
> > least not until it has had some soak time in master.
> >
> > Backtrace to explain the issue:
> >
> >   Breakpoint 1, fd_resource_create_with_modifiers (pscreen=0x574ae0, tmpl=0x7fffffdbf0, modifiers=0x7fffffdb38, count=1)
> >       at ../src/gallium/drivers/freedreno/freedreno_resource.c:838
> >   838           struct fd_screen *screen = fd_screen(pscreen);
> >   1: *tmpl = {reference = {count = 0}, width0 = 800, height0 = 600, depth0 = 1, array_size = 1, format = PIPE_FORMAT_B8G8R8A8_UNORM,
> >     target = PIPE_TEXTURE_2D, last_level = 0, nr_samples = 0, nr_storage_samples = 0, usage = 0, bind = 1572874, flags = 0, next = 0x0,
> >     screen = 0x0}
> >   (gdb) bt
> >   #0  fd_resource_create_with_modifiers (pscreen=0x574ae0, tmpl=0x7fffffdbf0, modifiers=0x7fffffdb38, count=1) at ../src/gallium/drivers/freedreno/freedreno_resource.c:838
> >   #1  0x0000007fbde33330 in fd_resource_create (pscreen=0x574ae0, tmpl=0x7fffffdbf0) at ../src/gallium/drivers/freedreno/freedreno_resource.c:956
> >   #2  0x0000007fbe54e2a4 in u_transfer_helper_resource_create (pscreen=0x574ae0, templ=0x7fffffdbf0) at ../src/gallium/auxiliary/util/u_transfer_helper.c:126
> >   #3  0x0000007fbdcc8148 in dri2_create_image_common (_screen=0x570530, width=800, height=600, format=4099, use=19, modifiers=0x0, count=0, loaderPrivate=0x6c4160) at ../src/gallium/state_trackers/dri/dri2.c:1039
> >   #4  0x0000007fbdcc8214 in dri2_create_image (_screen=0x570530, width=800, height=600, format=4099, use=19, loaderPrivate=0x6c4160) at ../src/gallium/state_trackers/dri/dri2.c:1061
> >   #5  0x0000007fbec89a30 in dri3_alloc_render_buffer (draw=0x531418, format=4099, width=800, height=600, depth=24) at ../src/loader/loader_dri3_helper.c:1341
> >   #6  0x0000007fbec8aab4 in dri3_get_buffer (driDrawable=0x5387b0, format=4099, buffer_type=loader_dri3_buffer_back, draw=0x531418) at ../src/loader/loader_dri3_helper.c:1822
> >   #7  0x0000007fbec8b10c in loader_dri3_get_buffers (driDrawable=0x5387b0, format=4099, stamp=0x64d480, loaderPrivate=0x531418, buffer_mask=1, buffers=0x7fffffdf20) at ../src/loader/loader_dri3_helper.c:2021
> >   #8  0x0000007fbdcc68c4 in dri_image_drawable_get_buffers (drawable=0x64d480, images=0x7fffffdf20, statts=0x65ee90, statts_count=2) at ../src/gallium/state_trackers/dri/dri2.c:339
> >   #9  0x0000007fbdcc6c44 in dri2_allocate_textures (ctx=0x5a7540, drawable=0x64d480, statts=0x65ee90, statts_count=2) at ../src/gallium/state_trackers/dri/dri2.c:466
> >   #10 0x0000007fbdccb580 in dri_st_framebuffer_validate (stctx=0x535cf0, stfbi=0x64d480, statts=0x65ee90, count=2, out=0x7fffffe0c8) at ../src/gallium/state_trackers/dri/dri_drawable.c:85
> >   #11 0x0000007fbe048c84 in st_framebuffer_validate (stfb=0x65e9c0, st=0x535cf0) at ../src/mesa/state_tracker/st_manager.c:222
> >   #12 0x0000007fbe04a884 in st_api_make_current (stapi=0x7fbe8d90d8 <st_gl_api>, stctxi=0x535cf0, stdrawi=0x64d480, streadi=0x64d480) at ../src/mesa/state_tracker/st_manager.c:1074
> >   #13 0x0000007fbdccaf44 in dri_make_current (cPriv=0x67bdc0, driDrawPriv=0x5387b0, driReadPriv=0x5387b0) at ../src/gallium/state_trackers/dri/dri_context.c:301
> >   #14 0x0000007fbdcc2910 in driBindContext (pcp=0x67bdc0, pdp=0x5387b0, prp=0x5387b0) at ../src/mesa/drivers/dri/common/dri_util.c:579
> >   #15 0x0000007fbec6b7e0 in dri3_bind_context (context=0x51ccd0, old=0x7fbecd0798 <dummyContext>, draw=2097154, read=2097154) at ../src/glx/dri3_glx.c:210
> >   #16 0x0000007fbec4b010 in MakeContextCurrent (dpy=0x503d00, draw=2097154, read=2097154, gc_user=0x51ccd0) at ../src/glx/glxcurrent.c:220
> >   #17 0x0000007fbec4b184 in glXMakeCurrent (dpy=0x503d00, draw=2097154, gc=0x51ccd0) at ../src/glx/glxcurrent.c:267
> >   #18 0x0000007fbee8deac in ?? () from /lib64/libGLX.so.0
> >   #19 0x0000007fbee8f7d4 in ?? () from /lib64/libGLX.so.0
> >   #20 0x000000000040b330 in GLStateGLX::valid() ()
> >   #21 0x0000000000409a28 in CanvasGeneric::do_make_current() ()
> >   #22 0x000000000040a4f0 in CanvasGeneric::reset() ()
> >   #23 0x0000000000406714 in main ()
> >   (gdb)
> >
> > In dri3_alloc_render_buffer() the request gets turned into
> > createImageWithModifiers() but in dri2_create_image_common() it gets
> > turned back into pscreen->create_resource() (ie. without modifiers) so
> > we've lost the information from the 'use' flags that the buffer is
> > shared and cannot differentiate the allocation from other internal
> > buffer allocations.
> >
> >  src/loader/loader_dri3_helper.c | 20 ++++++++++++++------
> >  1 file changed, 14 insertions(+), 6 deletions(-)
> >
> > diff --git a/src/loader/loader_dri3_helper.c b/src/loader/loader_dri3_helper.c
> > index 20fe4cbdabc..ad9b9d87b05 100644
> > --- a/src/loader/loader_dri3_helper.c
> > +++ b/src/loader/loader_dri3_helper.c
> > @@ -1319,12 +1319,20 @@ dri3_alloc_render_buffer(struct loader_dri3_drawable *draw, unsigned int format,
> >
> >           free(mod_reply);
> >
> > -         buffer->image = draw->ext->image->createImageWithModifiers(draw->dri_screen,
> > -                                                                    width, height,
> > -                                                                    format,
> > -                                                                    modifiers,
> > -                                                                    count,
> > -                                                                    buffer);
> > +         /* don't use createImageWithModifiers() if we have no
> > +          * modifiers, other things depend on the use flags when
> > +          * there are no modifiers to know that a buffer can be
> > +          * shared.
> > +          */
> > +         if (modifiers) {
> > +            buffer->image = draw->ext->image->createImageWithModifiers(draw->dri_screen,
> > +                                                                       width, height,
> > +                                                                       format,
> > +                                                                       modifiers,
> > +                                                                       count,
> > +                                                                       buffer);
> > +         }
> > +
> >           free(modifiers);
> >        }
> >  #endif
> > --
> > 2.20.1
> >
> > _______________________________________________
> > mesa-dev mailing list
> > mesa-dev at lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/mesa-dev
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list