From 093251776f56c3065c69c5a397301f84802e3e29 Mon Sep 17 00:00:00 2001
From: Robert Bragg <robert@linux.intel.com>
Date: Wed, 7 Jul 2010 19:23:57 +0100
Subject: [PATCH] material: set ->layer_index on new layers for unit0

We were mistakenly only initializing layer->layer_index for new layers
associated with texture units > 0. This had gone unnoticed because
normally layers associated with texture unit0 have a layer index of 0
too. Mutter was hitting this issue because it was initializing layer 1
before layer 0 for one of its materials so layer 1 was temporarily
associated with texture unit 0.
---
 cogl/cogl-material.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cogl/cogl-material.c b/cogl/cogl-material.c
index 6a0bda21b..e1b121a56 100644
--- a/cogl/cogl-material.c
+++ b/cogl/cogl-material.c
@@ -1841,8 +1841,8 @@ _cogl_material_get_layer (CoglMaterial *material,
       /* Since we passed a newly allocated layer we wouldn't expect
        * _set_layer_unit() to have to allocate *another* layer. */
       g_assert (new == layer);
-      layer->index = layer_index;
     }
+  layer->index = layer_index;
 
   for (i = 0; i < layer_info.n_layers_to_shift; i++)
     {