d3d1x: fix/improve OMSetRenderTargets
authorChristoph Bumiller <e0425955@student.tuwien.ac.at>
Thu, 20 Oct 2011 18:43:11 +0000 (20:43 +0200)
committerChristoph Bumiller <e0425955@student.tuwien.ac.at>
Fri, 21 Oct 2011 21:00:38 +0000 (23:00 +0200)
Don't count trailing NULL RTVs.
Don't skip update if only DSV has changed.

src/gallium/state_trackers/d3d1x/gd3d11/d3d11_context.h

index d6b640025a0cafeffb93f3a8a69b22b885460270..6385fc123ca6a15e0b146257f3eda9a4110a38f2 100644 (file)
@@ -1188,31 +1188,38 @@ struct GalliumD3D10Device : public GalliumD3D10ScreenImpl<threadsafe>
                ID3D11DepthStencilView  *new_depth_stencil_view)
        {
                SYNCHRONIZED;
+
+               bool update = false;
+               unsigned i, num;
+
+               if(depth_stencil_view.p != new_depth_stencil_view) {
+                       update = true;
+                       depth_stencil_view = new_depth_stencil_view;
+               }
+
                if(!new_render_target_views)
                        count = 0;
-               if(count == num_render_target_views)
-               {
-                       for(unsigned i = 0; i < count; ++i)
-                       {
-                               if(new_render_target_views[i] != render_target_views[i].p)
-                                       goto changed;
-                       }
-                       return;
-               }
-changed:
-               depth_stencil_view = new_depth_stencil_view;
-               unsigned i;
-               for(i = 0; i < count; ++i)
-               {
-                       render_target_views[i] = new_render_target_views[i];
+
+               for(num = 0, i = 0; i < count; ++i) {
 #if API >= 11
+                       // XXX: is unbinding the UAVs here correct ?
                        om_unordered_access_views[i] = (ID3D11UnorderedAccessView*)NULL;
 #endif
+                       if(new_render_target_views[i] != render_target_views[i].p) {
+                               update = true;
+                               render_target_views[i] = new_render_target_views[i];
+                       }
+                       if(new_render_target_views[i])
+                               num = i + 1;
                }
-               for(; i < num_render_target_views; ++i)
-                       render_target_views[i] = (ID3D11RenderTargetView*)NULL;
-               num_render_target_views = count;
-               set_framebuffer();
+               if(num != num_render_target_views) {
+                       update = true;
+                       for(; i < num_render_target_views; ++i)
+                               render_target_views[i] = (ID3D11RenderTargetView*)NULL;
+               }
+               num_render_target_views = num;
+               if(update)
+                       set_framebuffer();
        }
 
        virtual void STDMETHODCALLTYPE OMGetRenderTargets(