Mesa (master): d3d1x: fix deadlocks on non-recursive mutex

Luca Barbieri lb at kemper.freedesktop.org
Thu Sep 23 11:38:28 UTC 2010


Module: Mesa
Branch: master
Commit: 17ad9972f4b998dbf1a046780b6bde461d721dd0
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=17ad9972f4b998dbf1a046780b6bde461d721dd0

Author: Luca Barbieri <luca at luca-barbieri.com>
Date:   Thu Sep 23 03:35:50 2010 +0200

d3d1x: fix deadlocks on non-recursive mutex

---

 .../state_trackers/d3d1x/gd3d11/d3d11_context.h    |   20 +++++++++++++++-----
 1 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_context.h b/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_context.h
index 032cb0e..7e49c3a 100644
--- a/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_context.h
+++ b/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_context.h
@@ -901,7 +901,6 @@ struct GalliumD3D10Device : public GalliumD3D10ScreenImpl<threadsafe>
 
 	void set_clip()
 	{
-		SYNCHRONIZED;
 		pipe_clip_state clip;
 		clip.nr = 0;
 		clip.depth_clamp = depth_clamp;
@@ -1588,7 +1587,7 @@ changed:
 	}
 #endif
 
-	virtual void STDMETHODCALLTYPE RestoreGalliumStateBlitOnly()
+	void restore_gallium_state_blit_only()
 	{
 		pipe->bind_blend_state(pipe, blend_state.p ? blend_state.p->object : default_blend);
 		pipe->bind_depth_stencil_alpha_state(pipe, depth_stencil_state.p ? depth_stencil_state.p->object : default_depth_stencil);
@@ -1607,6 +1606,12 @@ changed:
 		update_flags |= UPDATE_VERTEX_BUFFERS | (1 << (UPDATE_SAMPLERS_SHIFT + D3D11_STAGE_PS)) | (1 << (UPDATE_VIEWS_SHIFT + D3D11_STAGE_PS));
 	}
 
+	virtual void STDMETHODCALLTYPE RestoreGalliumStateBlitOnly()
+	{
+		SYNCHRONIZED;
+		restore_gallium_state_blit_only();
+	}
+
 	virtual void STDMETHODCALLTYPE GenerateMips(
 			__in  ID3D11ShaderResourceView *pShaderResourceView)
 	{
@@ -1620,13 +1625,13 @@ changed:
 		if(pipe->render_condition)
 			pipe->render_condition(pipe, 0, 0);
 		util_gen_mipmap(gen_mipmap, view->object, 0, 0, view->object->texture->last_level, PIPE_TEX_FILTER_LINEAR);
-		RestoreGalliumStateBlitOnly();
+		restore_gallium_state_blit_only();
 	}
 
 	virtual void STDMETHODCALLTYPE RestoreGalliumState()
 	{
 		SYNCHRONIZED;
-		RestoreGalliumStateBlitOnly();
+		restore_gallium_state_blit_only();
 
 		set_index_buffer();
 		set_stencil_ref();
@@ -1707,7 +1712,12 @@ changed:
 
 	virtual void STDMETHODCALLTYPE ClearState(void)
 	{
-		SYNCHRONIZED;
+		/* we don't take a lock here because we would deadlock otherwise
+		 * TODO: this is probably incorrect, because ClearState should likely be atomic.
+		 * However, I can't think of any correct usage that would be affected by this
+		 * being non-atomic, and making this atomic is quite expensive and complicates
+		 * the code
+		 */
 
 		// we qualify all calls so that we avoid virtual dispatch and might get them inlined
 		// TODO: make sure all this gets inlined, which might require more compiler flags




More information about the mesa-commit mailing list