st/nine: Immediately upload user provided textures
authorAxel Davy <davyaxel0@gmail.com>
Tue, 22 Jan 2019 19:14:43 +0000 (20:14 +0100)
committerAxel Davy <davyaxel0@gmail.com>
Sat, 26 Jan 2019 18:53:00 +0000 (19:53 +0100)
Fixes regression caused by
42d672fa6a766363e5703f119607f7c7975918aa
st/nine: Bind src not dst in nine_context_box_upload

Before that patch, for user provided textures,
when the texture was destroyed, the safety
check for pending uploads, which according to
the code "Following condition cannot happen currently",
was flushing the queue and thus triggering the upload.

After the patch, the texture destruction was delayed after
the upload. However the user frees the texture buffer,
as it thinks the texture released.

Instead of reverting the faulty patch,
this patch instead flushes the csmt queue right away
after queuing the upload for this type of textures.
This is more future-proof, as we may want to bind the
surface for other reasons in the future.

Signed-off-by: Axel Davy <davyaxel0@gmail.com>
Cc: 18.3 <mesa-stable@lists.freedesktop.org>
src/gallium/state_trackers/nine/surface9.c

index 10518219a0a2b26a66199f9e784190c0b410c67b..ebb2f9d0c466fab5628f30c749c4c83055b5c8b2 100644 (file)
@@ -668,6 +668,19 @@ NineSurface9_CopyMemToDefault( struct NineSurface9 *This,
                             From->data, From->stride,
                             0, /* depth = 1 */
                             &src_box);
+    if (From->texture == D3DRTYPE_TEXTURE) {
+        struct NineTexture9 *tex =
+            NineTexture9(From->base.base.container);
+        /* D3DPOOL_SYSTEMMEM with buffer content passed
+         * from the user: execute the upload right now.
+         * It is possible it is enough to delay upload
+         * until the surface refcount is 0, but the
+         * bind refcount may not be 0, and thus the dtor
+         * is not executed (and doesn't trigger the
+         * pending_uploads_counter check). */
+        if (!tex->managed_buffer)
+            nine_csmt_process(This->base.base.device);
+    }
 
     if (This->data_conversion)
         (void) util_format_translate(This->format_conversion,