[virglrenderer-devel] Strange graphical glitches under virgl.

Gert Wollny gert.wollny at collabora.com
Tue Jul 24 05:53:21 UTC 2018


Hi Lepton, 

great to hear that you've found what is the problem. 

Am Montag, den 23.07.2018, 20:28 -0700 schrieb Lepton Wu:
> I think I find what happened here:
> 
> The GL_SCISSOR_TEST is enabled while info->scissor_enable is false.
> In such case,  vrend_renderer_blit_int will change
> GL_SCISSOR_TEST  to disabled status.  I tried a simple
> patch which just restore its status fixed this issue.
> glCopySub... works because it doesn't touch the status of
> GL_SCISSOR_TEST
> 
> Need to figure out if it's valid that  info->scissor_enable == false
> while GL_SCISSOR_TEST enabled. If that's unexpected, we still need to
> figure out why this happen, if that's expected, then just
> keep/restore GL_SCISSOR_TEST in vrend_renderer_blit_int should be
> fine.
My guess is that it's the same problem that we had with gallium
"clear", where the guest doesn't send the updated rasterization state,
because it is all handled inside gallium, so we had to change the state
for what gallium clear expects, and then restore it. 

Regarding GL_SCISSOR_TEST, I suspect that gallium already applies this
to change the blit range (hence no need to send a chang with scissors
to the driver), and that the gallium blit call really wants the full
rectangle to be copied. but I'll have to check the mesa code.

Best, 
Gert 

> On Mon, Jul 23, 2018 at 5:39 PM Lepton Wu <lepton at chromium.org>
> wrote:
> > 
> > FYI, I have a CL which is using another way to do copy and it seems
> > it
> > fixes this bug for me also, but I still don't know the bug in  the
> > current copy_int code. Will continue to work on it.
> > 
> > This is my patch which "fix" this issue for me:
> > 
> > diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c
> > index 5f8ff23..70b191b 100644
> > --- a/src/vrend_renderer.c
> > +++ b/src/vrend_renderer.c
> > @@ -6019,6 +6019,31 @@ void
> > vrend_renderer_resource_copy_region(struct
> > vrend_context *ctx,
> > 
> >  }
> > 
> > +static void simple_copy(struct vrend_context *ctx,
> > + struct vrend_resource *src_res,
> > + struct vrend_resource *dst_res,
> > + const struct pipe_blit_info* info) {
> > +   GLint read_fbo = 0;
> > +   glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, &read_fbo);
> > +   glBindFramebuffer(GL_READ_FRAMEBUFFER, ctx->sub-
> > >blit_fb_ids[0]);
> > +   glFramebufferTexture2DEXT(GL_READ_FRAMEBUFFER,
> > GL_DEPTH_STENCIL_ATTACHMENT,
> > +             GL_TEXTURE_2D, 0, 0);
> > +   glFramebufferTexture2DEXT(GL_READ_FRAMEBUFFER,
> > GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, src_res->id, 0);
> > +   GLint current_2d = 0;
> > +   glGetIntegerv(GL_TEXTURE_BINDING_2D, &current_2d);
> > +   glBindTexture(GL_TEXTURE_2D, dst_res->id);
> > +   glCopyTexSubImage2D(GL_TEXTURE_2D, 0,
> > +   info->dst.box.x,
> > +   info->dst.box.y,
> > +   info->src.box.x,
> > +   info->src.box.y,
> > +   info->src.box.width,
> > +   info->src.box.height);
> > +    glBindTexture(GL_TEXTURE_2D, current_2d);
> > +    glFramebufferTexture2DEXT(GL_READ_FRAMEBUFFER,
> > GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
> > +    glBindFramebuffer(GL_READ_FRAMEBUFFER, read_fbo);
> > +}
> > +
> >  static void vrend_renderer_blit_int(struct vrend_context *ctx,
> >                                      struct vrend_resource
> > *src_res,
> >                                      struct vrend_resource
> > *dst_res,
> > @@ -6085,6 +6110,22 @@ static void vrend_renderer_blit_int(struct
> > vrend_context *ctx,
> >        return;
> >     }
> > 
> > +   if (filter == GL_NEAREST &&
> > +       src_res->base.format == dst_res->base.format &&
> > +       src_res->base.format == PIPE_FORMAT_B8G8R8A8_UNORM &&
> > +       info->mask == PIPE_MASK_RGBA &&
> > +       info->src.box.width == info->dst.box.width &&
> > +       info->src.box.height == info->dst.box.height &&
> > +       info->src.box.x == info->dst.box.x &&
> > +       info->src.box.y == info->dst.box.y &&
> > +       info->src.box.depth == info->dst.box.depth &&
> > +       info->src.box.depth == 1 &&
> > +       info->src.box.z == info->dst.box.z &&
> > +       info->src.box.z == 0 ) {
> > +     simple_copy(ctx, src_res, dst_res, info);
> > +     return;
> > +   }
> > +
> >     if (info->mask & PIPE_MASK_Z)
> >        glmask |= GL_DEPTH_BUFFER_BIT;
> >     if (info->mask & PIPE_MASK_S)
> > 
> > 
> > On Mon, Jul 23, 2018 at 2:13 PM Lepton Wu <lepton at chromium.org>
> > wrote:
> > > 
> > > Hi Gert,
> > > Thanks for trying to reproduce it. I really appreciate your help
> > > on this issue.
> > > 
> > > FYI, I just tried on 2 different linux desktop with different
> > > host gpu
> > > and I can reproduce on both machines. Since you can't reproduce
> > > it,
> > > this could be
> > > something related with  my guest. Here is my setup:
> > > 
> > > 1. Both desktop runs Debian stretch.
> > > 2. One desktop come with amd rx480 gpu and I install amd-gpu-pro
> > > driver on it. Another desktop just come with integrated intel gpu
> > > (intel G4600 CPU) and I am just using default
> > > mesa driver come with debian distribution.
> > > 3. I just install libepoxy-dev from debian official repo which is
> > > version 1.3.1-2
> > > 4. For virglrenderder, I just get code from git and then do this
> > > :
> > > "git checkout -b buggy be3b107", this is the last commit before
> > > the
> > > glCopyimagesubdata change.
> > > 5. For qemu, I compile it like this:
> > >     export PKG_CONFIG_PATH=$HOME/virgl/lib/pkgconfig
> > >      ./configure --target-list=x86_64-softmmu --disable-gtk
> > > --enable-virglrenderer --audio-drv-list=pa
> > > 6. For guest, as I said before, it's a chrome os guest. It can be
> > > get like this:
> > >     wget https://storage.googleapis.com/chrome_os_emulator/sysimg
> > > _67-10575.63.0.zip
> > >     unzip -x sysimg_67-10575.63.0.zip
> > >     qemu-img convert -O raw x86/userdata.img rawdata.img
> > >     cat x86/system.img rawdata.img x86/vendor.img > disk.img
> > >  7. I am running qemu with the following flags:
> > >      qemu-img create -f qcow2 -b disk.img disk.img.qcow2
> > >      x86_64-softmmu/qemu-system-x86_64 -soundhw hda -enable-kvm
> > > -m
> > > 4096 -net nic,model=virtio -net user,hostfwd=tcp:127.0.0.1:9222-
> > > :22
> > > -device virtio-vga -display sdl,gl=on -device usb-ehci -device
> > > usb-tablet -show-cursor -smp 4 disk.img.qcow2
> > > 
> > >     At the login screen,  it will ask for gmail account,  I just
> > > skip
> > > this step by click "More options", and then click "Guest mode".
> > > 
> > > On Sun, Jul 22, 2018 at 4:35 AM Gert Wollny <gert.wollny at collabor
> > > a.com> wrote:
> > > > 
> > > > Am Freitag, den 20.07.2018, 14:12 -0700 schrieb Lepton Wu:
> > > > > Hi,
> > > > > 
> > > > > I have an issue which I recorded a video  to show the bug:
> > > > > https://youtu.be/ECGDCMAOTxs
> > > > > You can see, sometimes, there is a "wrong block" of
> > > > > rendering. It's
> > > > > always some kind of rectangle somewhere.
> > > > > A strange part is: I've never seen this kind of issue if I am
> > > > > running
> > > > > 3D android games under virgl. Games always
> > > > > running fine. But for Chrome, it sometimes come with this
> > > > > kind of
> > > > > weird graphics.
> > > > 
> > > > I was not able to reproduce the issue.
> > > > I used the latest master of virglrenderer and mesa on an Intel
> > > > Kabylake
> > > >  host, and disabled the copy_image copy path via
> > > >   MESA_EXTENSION_OVERRIDE=-GL_ARGB_copy_image
> > > > so that virglrenderer could not use this shortcut for copy-
> > > > blits.
> > > > 
> > > > Inside the guest I used Ubuntu bionic with the latest updates
> > > > and a PPA
> > > >  kernel: Linux version 4.16.0-041600-generic (kernel at kathleen)
> > > > (4.16 is needed to support report host caps v2 to the guest).
> > > > 
> > > > I tried both blackbox and a gnome-session with chromium-browser 
> > > > and I
> > > > didn't seen any of these artifacts. What is actually the
> > > > desktop
> > > > environment that you were using?
> > > > 
> > > > best,
> > > > Gert
> > > > 
> > > > 
> > > > 
> > > > 
> 
> _______________________________________________
> virglrenderer-devel mailing list
> virglrenderer-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/virglrenderer-devel


More information about the virglrenderer-devel mailing list