Matteo Bruni : wined3d: End transform feedback on SO buffer destruction even if the D3D buffer isn't bound.

Alexandre Julliard julliard at winehq.org
Tue Oct 19 16:07:47 CDT 2021


Module: wine
Branch: master
Commit: e2abbf9c583a203c135a5a0c79cf23b228603bd6
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=e2abbf9c583a203c135a5a0c79cf23b228603bd6

Author: Matteo Bruni <mbruni at codeweavers.com>
Date:   Tue Oct 19 17:43:47 2021 +0200

wined3d: End transform feedback on SO buffer destruction even if the D3D buffer isn't bound.

It might still be bound in GL.

Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/wined3d/buffer.c | 16 ++++++++++------
 dlls/wined3d/device.c |  2 +-
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c
index d259b64bfaf..854fa71aefe 100644
--- a/dlls/wined3d/buffer.c
+++ b/dlls/wined3d/buffer.c
@@ -145,12 +145,16 @@ static void wined3d_buffer_gl_destroy_buffer_object(struct wined3d_buffer_gl *bu
     if (!buffer_gl->b.buffer_object)
         return;
 
-    if (context_gl->c.transform_feedback_active && resource->bind_count
-            && resource->bind_flags & WINED3D_BIND_STREAM_OUTPUT)
-    {
-        /* We have to make sure that transform feedback is not active
-         * when deleting a potentially bound transform feedback buffer.
-         * This may happen when the device is being destroyed. */
+    if (context_gl->c.transform_feedback_active && (resource->bind_flags & WINED3D_BIND_STREAM_OUTPUT)
+            && wined3d_context_is_graphics_state_dirty(&context_gl->c, STATE_STREAM_OUTPUT))
+    {
+        /* It's illegal to (un)bind GL_TRANSFORM_FEEDBACK_BUFFER while transform
+         * feedback is active. Deleting a buffer implicitly unbinds it, so we
+         * need to end transform feedback here if this buffer was bound.
+         *
+         * This should only be possible if STATE_STREAM_OUTPUT is dirty; if we
+         * do a draw call before destroying this buffer then the draw call will
+         * already rebind the GL target. */
         WARN("Deleting buffer object for buffer %p, disabling transform feedback.\n", buffer_gl);
         wined3d_context_gl_end_transform_feedback(context_gl);
     }
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 86945485e20..1c584b93fe0 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -1182,7 +1182,7 @@ void wined3d_device_uninit_3d(struct wined3d_device *device)
         wined3d_texture_decref(texture);
     }
 
-    wined3d_device_context_emit_reset_state(&device->cs->c, false);
+    wined3d_device_context_emit_reset_state(&device->cs->c, true);
     state_cleanup(state);
 
     wine_rb_clear(&device->samplers, device_free_sampler, NULL);




More information about the wine-cvs mailing list