softpipe/gs: fix a crash when a gs isn't present
authorZack Rusin <zackr@vmware.com>
Tue, 15 Jun 2010 10:12:56 +0000 (06:12 -0400)
committerZack Rusin <zackr@vmware.com>
Tue, 15 Jun 2010 13:12:19 +0000 (09:12 -0400)
src/gallium/drivers/softpipe/sp_state_sampler.c

index 09b0ffc1dad7500f58d5534a5b44c9a1f62535e1..79d9516ad9cf949fd0841cb6b71e5f7d40b5e762 100644 (file)
@@ -350,23 +350,27 @@ softpipe_reset_sampler_varients(struct softpipe_context *softpipe)
       }
    }
 
-   for (i = 0; i <= softpipe->gs->max_sampler; i++) {
-      if (softpipe->geometry_samplers[i]) {
-         struct pipe_resource *texture = NULL;
-
-         if (softpipe->geometry_sampler_views[i]) {
-            texture = softpipe->geometry_sampler_views[i]->texture;
+   if (softpipe->gs) {
+      for (i = 0; i <= softpipe->gs->max_sampler; i++) {
+         if (softpipe->geometry_samplers[i]) {
+            struct pipe_resource *texture = NULL;
+
+            if (softpipe->geometry_sampler_views[i]) {
+               texture = softpipe->geometry_sampler_views[i]->texture;
+            }
+
+            softpipe->tgsi.geom_samplers_list[i] =
+               get_sampler_varient(
+                  i,
+                  sp_sampler(softpipe->geometry_samplers[i]),
+                  texture,
+                  TGSI_PROCESSOR_GEOMETRY );
+
+            sp_sampler_varient_bind_texture(
+               softpipe->tgsi.geom_samplers_list[i],
+               softpipe->geometry_tex_cache[i],
+               texture );
          }
-
-         softpipe->tgsi.geom_samplers_list[i] =
-            get_sampler_varient( i,
-                                 sp_sampler(softpipe->geometry_samplers[i]),
-                                 texture,
-                                 TGSI_PROCESSOR_GEOMETRY );
-
-         sp_sampler_varient_bind_texture( softpipe->tgsi.geom_samplers_list[i],
-                                          softpipe->geometry_tex_cache[i],
-                                          texture );
       }
    }