d3d1x: don't crash on drivers not supporting vertex or geometry sampling
authorLuca Barbieri <luca@luca-barbieri.com>
Fri, 24 Sep 2010 12:28:31 +0000 (14:28 +0200)
committerLuca Barbieri <luca@luca-barbieri.com>
Fri, 24 Sep 2010 13:12:19 +0000 (15:12 +0200)
src/gallium/state_trackers/d3d1x/gd3d11/d3d11.cpp
src/gallium/state_trackers/d3d1x/gd3d11/d3d11_context.h
src/gallium/state_trackers/d3d1x/gd3d11/d3d11_screen.h

index 42678fab4d091033e82b74dac891c125cb8aacb6..27cfebc1b9c47000c0f3128a776bc95ddfd967a8 100644 (file)
@@ -125,6 +125,7 @@ struct GalliumD3D11Caps
        bool render_condition;
        unsigned constant_buffers[D3D11_STAGES];
        unsigned stages;
+       unsigned stages_with_sampling;
 };
 
 typedef GalliumDXGIDevice<
index d7c1c921b710af6f44a4d9366abd021677c48075..4abb4ac6b0f6c6b73c78693634ed07a3d4f3ec26 100644 (file)
@@ -158,6 +158,12 @@ struct GalliumD3D10Device : public GalliumD3D10ScreenImpl<threadsafe>
                }
                if(!pipe->set_stream_output_buffers)
                        caps.so = false;
+               if(!pipe->set_geometry_sampler_views)
+                       caps.stages_with_sampling &=~ (1 << PIPE_SHADER_GEOMETRY);
+               if(!pipe->set_fragment_sampler_views)
+                       caps.stages_with_sampling &=~ (1 << PIPE_SHADER_FRAGMENT);
+               if(!pipe->set_vertex_sampler_views)
+                       caps.stages_with_sampling &=~ (1 << PIPE_SHADER_VERTEX);
 
                update_flags = 0;
 
@@ -505,7 +511,7 @@ struct GalliumD3D10Device : public GalliumD3D10ScreenImpl<threadsafe>
                {
                        while(num_shader_resource_views[s] && !sampler_views[s][num_shader_resource_views[s] - 1]) \
                                --num_shader_resource_views[s];
-                       if(s < caps.stages)
+                       if((1 << s) & caps.stages_with_sampling)
                        {
                                struct pipe_sampler_view* views_to_bind[PIPE_MAX_SAMPLERS];
                                unsigned num_views_to_bind = shaders[s] ? shaders[s]->slot_to_resource.size() : 0;
@@ -532,7 +538,7 @@ struct GalliumD3D10Device : public GalliumD3D10ScreenImpl<threadsafe>
                {
                        while(num_samplers[s] && !sampler_csos[s].v[num_samplers[s] - 1])
                                --num_samplers[s];
-                       if(s < caps.stages)
+                       if((1 << s) & caps.stages_with_sampling)
                        {
                                void* samplers_to_bind[PIPE_MAX_SAMPLERS];
                                unsigned num_samplers_to_bind = shaders[s] ? shaders[s]->slot_to_sampler.size() : 0;
index 528d32c4b1eb23283b3d2b4dc660f031a182cf71..1ecd67ca474081037cc6dca9a6b17835181fcf1b 100644 (file)
@@ -101,6 +101,10 @@ struct GalliumD3D11ScreenImpl : public GalliumD3D11Screen
                        screen_caps.stages = i + 1;
                }
 
+               screen_caps.stages_with_sampling = (1 << screen_caps.stages) - 1;
+               if(!screen->get_param(screen, PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS))
+                       screen_caps.stages_with_sampling &=~ (1 << PIPE_SHADER_VERTEX);
+
                memset(format_support, 0xff, sizeof(format_support));
 
                float default_level;