vc4: Avoid a null-deref if a sampler index isn't used.
authorEric Anholt <eric@anholt.net>
Mon, 18 Aug 2014 22:50:48 +0000 (15:50 -0700)
committerEric Anholt <eric@anholt.net>
Tue, 19 Aug 2014 15:47:13 +0000 (08:47 -0700)
Part of fixing ARB_fragment_program/sparse-samplers

src/gallium/drivers/vc4/vc4_program.c

index 20f7a4489dc20ce5ea758f96d57a4a055bbf9c79..fa598473aabd14ea5871f2dc8a19290cac6be419 100644 (file)
@@ -1270,8 +1270,11 @@ static void
 vc4_setup_shared_key(struct vc4_key *key, struct vc4_texture_stateobj *texstate)
 {
         for (int i = 0; i < texstate->num_textures; i++) {
-                struct pipe_resource *prsc = texstate->textures[i]->texture;
-                key->tex_format[i] = prsc->format;
+                struct pipe_sampler_view *sampler = texstate->textures[i];
+                if (sampler) {
+                        struct pipe_resource *prsc = sampler->texture;
+                        key->tex_format[i] = prsc->format;
+                }
         }
 }