Retrieve the texture serial from the incomplete texture when sampler-incomplete.

TRAC #23127
Signed-off-by: Geoff Lang
Signed-off-by: Jamie Madill
Author: Nicolas Capens

git-svn-id: http://angleproject.googlecode.com/svn/trunk@2209 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/common/version.h b/src/common/version.h
index db66e14..a4a9597 100644
--- a/src/common/version.h
+++ b/src/common/version.h
@@ -1,7 +1,7 @@
 #define MAJOR_VERSION 1
 #define MINOR_VERSION 0
 #define BUILD_VERSION 0
-#define BUILD_REVISION 2208
+#define BUILD_REVISION 2209
 
 #define STRINGIFY(x) #x
 #define MACRO_STRINGIFY(x) STRINGIFY(x)
diff --git a/src/libGLESv2/Context.cpp b/src/libGLESv2/Context.cpp
index e150aee..3dd2cd8 100644
--- a/src/libGLESv2/Context.cpp
+++ b/src/libGLESv2/Context.cpp
@@ -1,5 +1,5 @@
 //
-// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
+// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 //
@@ -2436,46 +2436,45 @@
             TextureType textureType = programBinary->getSamplerTextureType(type, samplerIndex);
 
             Texture *texture = getSamplerTexture(textureUnit, textureType);
+            
+            if (!texture->isSamplerComplete())
+            {
+                texture = getIncompleteTexture(textureType);
+            }
+
             unsigned int texSerial = texture->getTextureSerial();
 
             if (appliedTextureSerial[samplerIndex] != texSerial || texture->hasDirtyParameters() || texture->hasDirtyImages())
             {
                 IDirect3DBaseTexture9 *d3dTexture = texture->getTexture();
 
-                if (d3dTexture)
+                if (appliedTextureSerial[samplerIndex] != texSerial || texture->hasDirtyParameters())
                 {
-                    if (appliedTextureSerial[samplerIndex] != texSerial || texture->hasDirtyParameters())
+                    GLenum wrapS = texture->getWrapS();
+                    GLenum wrapT = texture->getWrapT();
+                    GLenum minFilter = texture->getMinFilter();
+                    GLenum magFilter = texture->getMagFilter();
+                    float maxAnisotropy = texture->getMaxAnisotropy();
+
+                    mDevice->SetSamplerState(d3dSampler, D3DSAMP_ADDRESSU, es2dx::ConvertTextureWrap(wrapS));
+                    mDevice->SetSamplerState(d3dSampler, D3DSAMP_ADDRESSV, es2dx::ConvertTextureWrap(wrapT));
+
+                    mDevice->SetSamplerState(d3dSampler, D3DSAMP_MAGFILTER, es2dx::ConvertMagFilter(magFilter, maxAnisotropy));
+                    D3DTEXTUREFILTERTYPE d3dMinFilter, d3dMipFilter;
+                    es2dx::ConvertMinFilter(minFilter, &d3dMinFilter, &d3dMipFilter, maxAnisotropy);
+                    mDevice->SetSamplerState(d3dSampler, D3DSAMP_MINFILTER, d3dMinFilter);
+                    mDevice->SetSamplerState(d3dSampler, D3DSAMP_MIPFILTER, d3dMipFilter);
+                    mDevice->SetSamplerState(d3dSampler, D3DSAMP_MAXMIPLEVEL, texture->getLodOffset());
+
+                    if (supportsTextureFilterAnisotropy())
                     {
-                        GLenum wrapS = texture->getWrapS();
-                        GLenum wrapT = texture->getWrapT();
-                        GLenum minFilter = texture->getMinFilter();
-                        GLenum magFilter = texture->getMagFilter();
-                        float maxAnisotropy = texture->getMaxAnisotropy();
-
-                        mDevice->SetSamplerState(d3dSampler, D3DSAMP_ADDRESSU, es2dx::ConvertTextureWrap(wrapS));
-                        mDevice->SetSamplerState(d3dSampler, D3DSAMP_ADDRESSV, es2dx::ConvertTextureWrap(wrapT));
-
-                        mDevice->SetSamplerState(d3dSampler, D3DSAMP_MAGFILTER, es2dx::ConvertMagFilter(magFilter, maxAnisotropy));
-                        D3DTEXTUREFILTERTYPE d3dMinFilter, d3dMipFilter;
-                        es2dx::ConvertMinFilter(minFilter, &d3dMinFilter, &d3dMipFilter, maxAnisotropy);
-                        mDevice->SetSamplerState(d3dSampler, D3DSAMP_MINFILTER, d3dMinFilter);
-                        mDevice->SetSamplerState(d3dSampler, D3DSAMP_MIPFILTER, d3dMipFilter);
-                        mDevice->SetSamplerState(d3dSampler, D3DSAMP_MAXMIPLEVEL, texture->getLodOffset());
-
-                        if (supportsTextureFilterAnisotropy())
-                        {
-                            mDevice->SetSamplerState(d3dSampler, D3DSAMP_MAXANISOTROPY, (DWORD)maxAnisotropy);
-                        }
-                    }
-
-                    if (appliedTextureSerial[samplerIndex] != texSerial || texture->hasDirtyImages())
-                    {
-                        mDevice->SetTexture(d3dSampler, d3dTexture);
+                        mDevice->SetSamplerState(d3dSampler, D3DSAMP_MAXANISOTROPY, (DWORD)maxAnisotropy);
                     }
                 }
-                else
+
+                if (appliedTextureSerial[samplerIndex] != texSerial || texture->hasDirtyImages())
                 {
-                    mDevice->SetTexture(d3dSampler, getIncompleteTexture(textureType)->getTexture());
+                    mDevice->SetTexture(d3dSampler, d3dTexture);
                 }
 
                 appliedTextureSerial[samplerIndex] = texSerial;
diff --git a/src/libGLESv2/Texture.cpp b/src/libGLESv2/Texture.cpp
index 71ec4d8..e78c5e3 100644
--- a/src/libGLESv2/Texture.cpp
+++ b/src/libGLESv2/Texture.cpp
@@ -1535,11 +1535,6 @@
 
 IDirect3DBaseTexture9 *Texture::getTexture()
 {
-    if (!isSamplerComplete())
-    {
-        return NULL;
-    }
-
     // ensure the underlying texture is created
     if (getStorage(false) == NULL)
     {