virgl: Set bind when creating temp resource.
authorLepton Wu <lepton@chromium.org>
Mon, 8 Apr 2019 16:39:46 +0000 (09:39 -0700)
committerGurchetan Singh <gurchetansingh@chromium.org>
Wed, 10 Apr 2019 02:25:25 +0000 (19:25 -0700)
virgl render complains about "Illegal resource" when running
dEQP-EGL.functional.color_clears.single_context.gles2.rgb888_window,
the reason is that a zero bind value was given for temp resource.

Signed-off-by: Lepton Wu <lepton@chromium.org>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
src/gallium/drivers/virgl/virgl_texture.c

index 1832309aa49dfeab9b9f6bca2ab573517e26dc06..45315b7bb2494d2b38316b8b0ee5a0f29de5de79 100644 (file)
@@ -60,12 +60,22 @@ static void virgl_copy_region_with_blit(struct pipe_context *pipe,
       pipe->blit(pipe, &blit);
    }
 }
+
+static unsigned int temp_bind(unsigned int orig)
+{
+   if (orig & ~(PIPE_BIND_RENDER_TARGET | PIPE_BIND_DEPTH_STENCIL |
+                PIPE_BIND_SAMPLER_VIEW))
+      fprintf(stderr, "Waring, possibly unhandled bind: %x\n", orig);
+   return orig & (PIPE_BIND_DEPTH_STENCIL | PIPE_BIND_RENDER_TARGET);
+}
+
 static void virgl_init_temp_resource_from_box(struct pipe_resource *res,
                                               struct pipe_resource *orig,
                                               const struct pipe_box *box,
                                               unsigned level, unsigned flags)
 {
    memset(res, 0, sizeof(*res));
+   res->bind = temp_bind(orig->bind);
    res->format = orig->format;
    res->width0 = box->width;
    res->height0 = box->height;