Browse Source

Add D3D11 sampler states. Fix crash on empty vertex declaration. Fix Matrix3x3 uniforms on D3D11. Modify gpuObjects_ to PODVector.

Lasse Öörni 10 years ago
parent
commit
876d1834eb

+ 4 - 4
Source/Urho3D/Graphics/Direct3D11/D3D11ConstantBuffer.cpp

@@ -113,13 +113,13 @@ void ConstantBuffer::SetVector3ArrayParameter(unsigned offset, unsigned rows, co
         return; // Would overflow the buffer
         return; // Would overflow the buffer
 
 
     float* dest = (float*)&shadowData_[offset];
     float* dest = (float*)&shadowData_[offset];
-    float* src = (float*)data;
+    const float* src = (const float*)data;
 
 
     while (rows--)
     while (rows--)
     {
     {
-        dest[0] = src[0];
-        dest[1] = src[1];
-        dest[2] = src[2];
+        *dest++ = *src++;
+        *dest++ = *src++;
+        *dest++ = *src++;
         ++dest; // Skip over the w coordinate
         ++dest; // Skip over the w coordinate
     }
     }
 
 

+ 54 - 20
Source/Urho3D/Graphics/Direct3D11/D3D11Graphics.cpp

@@ -266,7 +266,7 @@ Graphics::~Graphics()
         MutexLock lock(gpuObjectMutex_);
         MutexLock lock(gpuObjectMutex_);
 
 
         // Release all GPU objects that still exist
         // Release all GPU objects that still exist
-        for (Vector<GPUObject*>::Iterator i = gpuObjects_.Begin(); i != gpuObjects_.End(); ++i)
+        for (PODVector<GPUObject*>::Iterator i = gpuObjects_.Begin(); i != gpuObjects_.End(); ++i)
             (*i)->Release();
             (*i)->Release();
         gpuObjects_.Clear();
         gpuObjects_.Clear();
     }
     }
@@ -1238,6 +1238,12 @@ void Graphics::SetTexture(unsigned index, Texture* texture)
             texture = texture->GetBackupTexture();
             texture = texture->GetBackupTexture();
     }
     }
     
     
+    if (texture && texture->GetParametersDirty())
+    {
+        texture->UpdateParameters();
+        textures_[index] = 0; // Force reassign
+    }
+
     if (texture != textures_[index])
     if (texture != textures_[index])
     {
     {
         if (firstDirtyTexture_ >= MAX_TEXTURE_UNITS)
         if (firstDirtyTexture_ >= MAX_TEXTURE_UNITS)
@@ -1252,13 +1258,39 @@ void Graphics::SetTexture(unsigned index, Texture* texture)
 
 
         textures_[index] = texture;
         textures_[index] = texture;
         impl_->shaderResourceViews_[index] = texture ? (ID3D11ShaderResourceView*)texture->GetShaderResourceView() : 0;
         impl_->shaderResourceViews_[index] = texture ? (ID3D11ShaderResourceView*)texture->GetShaderResourceView() : 0;
+        impl_->samplers_[index] = texture ? (ID3D11SamplerState*)texture->GetSampler() : 0;
         texturesDirty_ = true;
         texturesDirty_ = true;
     }
     }
 }
 }
 
 
 void Graphics::SetDefaultTextureFilterMode(TextureFilterMode mode)
 void Graphics::SetDefaultTextureFilterMode(TextureFilterMode mode)
 {
 {
-    defaultTextureFilterMode_ = mode;
+    if (mode != defaultTextureFilterMode_)
+    {
+        defaultTextureFilterMode_ = mode;
+        SetTextureParametersDirty();
+    }
+}
+
+void Graphics::SetTextureAnisotropy(unsigned level)
+{
+    if (level != textureAnisotropy_)
+    {
+        textureAnisotropy_ = level;
+        SetTextureParametersDirty();
+    }
+}
+
+void Graphics::SetTextureParametersDirty()
+{
+    MutexLock lock(gpuObjectMutex_);
+
+    for (PODVector<GPUObject*>::Iterator i = gpuObjects_.Begin(); i != gpuObjects_.End(); ++i)
+    {
+        Texture* texture = dynamic_cast<Texture*>(*i);
+        if (texture)
+            texture->SetParametersDirty();
+    }
 }
 }
 
 
 void Graphics::ResetRenderTargets()
 void Graphics::ResetRenderTargets()
@@ -1363,14 +1395,6 @@ void Graphics::SetViewport(const IntRect& rect)
     SetScissorTest(false);
     SetScissorTest(false);
 }
 }
 
 
-void Graphics::SetTextureAnisotropy(unsigned level)
-{
-    if (level < 1)
-        level = 1;
-    
-    /// \todo Implement
-}
-
 void Graphics::SetBlendMode(BlendMode mode)
 void Graphics::SetBlendMode(BlendMode mode)
 {
 {
     if (mode != blendMode_)
     if (mode != blendMode_)
@@ -2305,6 +2329,7 @@ void Graphics::ResetCachedState()
     {
     {
         textures_[i] = 0;
         textures_[i] = 0;
         impl_->shaderResourceViews_[i] = 0;
         impl_->shaderResourceViews_[i] = 0;
+        impl_->samplers_[i] = 0;
     }
     }
 
 
     for (unsigned i = 0; i < MAX_RENDERTARGETS; ++i)
     for (unsigned i = 0; i < MAX_RENDERTARGETS; ++i)
@@ -2386,8 +2411,12 @@ void Graphics::PrepareDraw()
         // Set same textures for both vertex & pixel shaders
         // Set same textures for both vertex & pixel shaders
         impl_->deviceContext_->VSSetShaderResources(firstDirtyTexture_, lastDirtyTexture_ - firstDirtyTexture_ + 1,
         impl_->deviceContext_->VSSetShaderResources(firstDirtyTexture_, lastDirtyTexture_ - firstDirtyTexture_ + 1,
             &impl_->shaderResourceViews_[firstDirtyTexture_]);
             &impl_->shaderResourceViews_[firstDirtyTexture_]);
+        impl_->deviceContext_->VSSetSamplers(firstDirtyTexture_, lastDirtyTexture_ - firstDirtyTexture_ + 1,
+            &impl_->samplers_[firstDirtyTexture_]);
         impl_->deviceContext_->PSSetShaderResources(firstDirtyTexture_, lastDirtyTexture_ - firstDirtyTexture_ + 1,
         impl_->deviceContext_->PSSetShaderResources(firstDirtyTexture_, lastDirtyTexture_ - firstDirtyTexture_ + 1,
             &impl_->shaderResourceViews_[firstDirtyTexture_]);
             &impl_->shaderResourceViews_[firstDirtyTexture_]);
+        impl_->deviceContext_->PSSetSamplers(firstDirtyTexture_, lastDirtyTexture_ - firstDirtyTexture_ + 1,
+            &impl_->samplers_[firstDirtyTexture_]);
 
 
         firstDirtyTexture_ = lastDirtyTexture_ = M_MAX_UNSIGNED;
         firstDirtyTexture_ = lastDirtyTexture_ = M_MAX_UNSIGNED;
         texturesDirty_ = false;
         texturesDirty_ = false;
@@ -2401,19 +2430,24 @@ void Graphics::PrepareDraw()
         unsigned long long newVertexDeclarationHash = 0;
         unsigned long long newVertexDeclarationHash = 0;
         for (unsigned i = 0; i < MAX_VERTEX_STREAMS; ++i)
         for (unsigned i = 0; i < MAX_VERTEX_STREAMS; ++i)
             newVertexDeclarationHash |= (unsigned long long)elementMasks_[i] << (i * 13);
             newVertexDeclarationHash |= (unsigned long long)elementMasks_[i] << (i * 13);
-        newVertexDeclarationHash |= (unsigned long long)vertexShader_->GetElementMask() << 51;
-        if (newVertexDeclarationHash != vertexDeclarationHash_)
+
+        // Do not create input layout if no vertex buffers / elements
+        if (newVertexDeclarationHash)
         {
         {
-            HashMap<unsigned long long, SharedPtr<VertexDeclaration> >::Iterator i = vertexDeclarations_.Find(newVertexDeclarationHash);
-            if (i == vertexDeclarations_.End())
+            newVertexDeclarationHash |= (unsigned long long)vertexShader_->GetElementMask() << 51;
+            if (newVertexDeclarationHash != vertexDeclarationHash_)
             {
             {
-                SharedPtr<VertexDeclaration> newVertexDeclaration(new VertexDeclaration(this, vertexShader_, vertexBuffers_,
-                    elementMasks_));
-                i = vertexDeclarations_.Insert(MakePair(newVertexDeclarationHash, newVertexDeclaration));
+                HashMap<unsigned long long, SharedPtr<VertexDeclaration> >::Iterator i = vertexDeclarations_.Find(newVertexDeclarationHash);
+                if (i == vertexDeclarations_.End())
+                {
+                    SharedPtr<VertexDeclaration> newVertexDeclaration(new VertexDeclaration(this, vertexShader_, vertexBuffers_,
+                        elementMasks_));
+                    i = vertexDeclarations_.Insert(MakePair(newVertexDeclarationHash, newVertexDeclaration));
+                }
+    
+                impl_->deviceContext_->IASetInputLayout((ID3D11InputLayout*)i->second_->GetInputLayout());
+                vertexDeclarationHash_ = newVertexDeclarationHash;
             }
             }
-
-            impl_->deviceContext_->IASetInputLayout((ID3D11InputLayout*)i->second_->GetInputLayout());
-            vertexDeclarationHash_ = newVertexDeclarationHash;
         }
         }
 
 
         vertexDeclarationDirty_ = false;
         vertexDeclarationDirty_ = false;

+ 3 - 1
Source/Urho3D/Graphics/Direct3D11/D3D11Graphics.h

@@ -177,6 +177,8 @@ public:
     void SetDefaultTextureFilterMode(TextureFilterMode mode);
     void SetDefaultTextureFilterMode(TextureFilterMode mode);
     /// Set texture anisotropy.
     /// Set texture anisotropy.
     void SetTextureAnisotropy(unsigned level);
     void SetTextureAnisotropy(unsigned level);
+    /// Dirty texture parameters of all textures (when global settings change.)
+    void SetTextureParametersDirty();
     /// Reset all rendertargets, depth-stencil surface and viewport.
     /// Reset all rendertargets, depth-stencil surface and viewport.
     void ResetRenderTargets();
     void ResetRenderTargets();
     /// Reset specific rendertarget.
     /// Reset specific rendertarget.
@@ -494,7 +496,7 @@ private:
     /// Largest scratch buffer request this frame.
     /// Largest scratch buffer request this frame.
     unsigned maxScratchBufferRequest_;
     unsigned maxScratchBufferRequest_;
     /// GPU objects.
     /// GPU objects.
-    Vector<GPUObject*> gpuObjects_;
+    PODVector<GPUObject*> gpuObjects_;
     /// Scratch buffers.
     /// Scratch buffers.
     Vector<ScratchBuffer> scratchBuffers_;
     Vector<ScratchBuffer> scratchBuffers_;
     /// Shadow map dummy color texture format.
     /// Shadow map dummy color texture format.

+ 3 - 0
Source/Urho3D/Graphics/Direct3D11/D3D11GraphicsImpl.cpp

@@ -43,7 +43,10 @@ GraphicsImpl::GraphicsImpl() :
         renderTargetViews_[i] = 0;
         renderTargetViews_[i] = 0;
 
 
     for (unsigned i = 0; i < MAX_TEXTURE_UNITS; ++i)
     for (unsigned i = 0; i < MAX_TEXTURE_UNITS; ++i)
+    {
         shaderResourceViews_[i] = 0;
         shaderResourceViews_[i] = 0;
+        samplers_[i] = 0;
+    }
 
 
     for (unsigned i = 0; i < MAX_VERTEX_STREAMS; ++i)
     for (unsigned i = 0; i < MAX_VERTEX_STREAMS; ++i)
     {
     {

+ 2 - 0
Source/Urho3D/Graphics/Direct3D11/D3D11GraphicsImpl.h

@@ -77,6 +77,8 @@ private:
     HashMap<unsigned, ID3D11RasterizerState*> rasterizerStates_;
     HashMap<unsigned, ID3D11RasterizerState*> rasterizerStates_;
     /// Bound shader resource views.
     /// Bound shader resource views.
     ID3D11ShaderResourceView* shaderResourceViews_[MAX_TEXTURE_UNITS];
     ID3D11ShaderResourceView* shaderResourceViews_[MAX_TEXTURE_UNITS];
+    /// Bound sampler state objects.
+    ID3D11SamplerState* samplers_[MAX_TEXTURE_UNITS];
     /// Bound vertex buffers.
     /// Bound vertex buffers.
     ID3D11Buffer* vertexBuffers_[MAX_VERTEX_STREAMS];
     ID3D11Buffer* vertexBuffers_[MAX_VERTEX_STREAMS];
     /// Bound constant buffers.
     /// Bound constant buffers.

+ 61 - 1
Source/Urho3D/Graphics/Direct3D11/D3D11Texture.cpp

@@ -21,6 +21,7 @@
 //
 //
 
 
 #include "../../IO/FileSystem.h"
 #include "../../IO/FileSystem.h"
+#include "../../IO/Log.h"
 #include "../../Graphics/Graphics.h"
 #include "../../Graphics/Graphics.h"
 #include "../../Graphics/GraphicsImpl.h"
 #include "../../Graphics/GraphicsImpl.h"
 #include "../../Graphics/Material.h"
 #include "../../Graphics/Material.h"
@@ -54,10 +55,27 @@ static const char* filterModeNames[] =
     0
     0
 };
 };
 
 
+static const D3D11_FILTER d3dFilterMode[] =
+{
+    D3D11_FILTER_MIN_MAG_MIP_POINT,
+    D3D11_FILTER_MIN_MAG_LINEAR_MIP_POINT,
+    D3D11_FILTER_MIN_MAG_MIP_LINEAR,
+    D3D11_FILTER_ANISOTROPIC
+};
+
+static const D3D11_TEXTURE_ADDRESS_MODE d3dAddressMode[] = 
+{
+    D3D11_TEXTURE_ADDRESS_WRAP,
+    D3D11_TEXTURE_ADDRESS_MIRROR,
+    D3D11_TEXTURE_ADDRESS_CLAMP,
+    D3D11_TEXTURE_ADDRESS_BORDER
+};
+
 Texture::Texture(Context* context) :
 Texture::Texture(Context* context) :
     Resource(context),
     Resource(context),
     GPUObject(GetSubsystem<Graphics>()),
     GPUObject(GetSubsystem<Graphics>()),
     shaderResourceView_(0),
     shaderResourceView_(0),
+    sampler_(0),
     format_(DXGI_FORMAT_UNKNOWN),
     format_(DXGI_FORMAT_UNKNOWN),
     usage_(TEXTURE_STATIC),
     usage_(TEXTURE_STATIC),
     levels_(0),
     levels_(0),
@@ -66,7 +84,8 @@ Texture::Texture(Context* context) :
     height_(0),
     height_(0),
     depth_(0),
     depth_(0),
     filterMode_(FILTER_DEFAULT),
     filterMode_(FILTER_DEFAULT),
-    sRGB_(false)
+    sRGB_(false),
+    parametersDirty_(true)
 {
 {
     for (int i = 0; i < MAX_COORDS; ++i)
     for (int i = 0; i < MAX_COORDS; ++i)
         addressMode_[i] = ADDRESS_WRAP;
         addressMode_[i] = ADDRESS_WRAP;
@@ -89,16 +108,19 @@ void Texture::SetNumLevels(unsigned levels)
 void Texture::SetFilterMode(TextureFilterMode mode)
 void Texture::SetFilterMode(TextureFilterMode mode)
 {
 {
     filterMode_ = mode;
     filterMode_ = mode;
+    parametersDirty_ = true;
 }
 }
 
 
 void Texture::SetAddressMode(TextureCoordinate coord, TextureAddressMode mode)
 void Texture::SetAddressMode(TextureCoordinate coord, TextureAddressMode mode)
 {
 {
     addressMode_[coord] = mode;
     addressMode_[coord] = mode;
+    parametersDirty_ = true;
 }
 }
 
 
 void Texture::SetBorderColor(const Color& color)
 void Texture::SetBorderColor(const Color& color)
 {
 {
     borderColor_ = color;
     borderColor_ = color;
+    parametersDirty_ = true;
 }
 }
 
 
 void Texture::SetSRGB(bool enable)
 void Texture::SetSRGB(bool enable)
@@ -107,6 +129,7 @@ void Texture::SetSRGB(bool enable)
         enable &= graphics_->GetSRGBSupport();
         enable &= graphics_->GetSRGBSupport();
     
     
     sRGB_ = enable;
     sRGB_ = enable;
+    parametersDirty_ = true;
 }
 }
 
 
 void Texture::SetBackupTexture(Texture* texture)
 void Texture::SetBackupTexture(Texture* texture)
@@ -272,6 +295,43 @@ void Texture::SetParameters(const XMLElement& element)
     }
     }
 }
 }
 
 
+void Texture::SetParametersDirty()
+{
+    parametersDirty_ = true;
+}
+
+void Texture::UpdateParameters()
+{
+    if (!parametersDirty_ || !object_)
+        return;
+
+    // Release old sampler
+    if (sampler_)
+    {
+        ((ID3D11SamplerState*)sampler_)->Release();
+        sampler_ = 0;
+    }
+
+    D3D11_SAMPLER_DESC samplerDesc;
+    memset(&samplerDesc, 0, sizeof samplerDesc);
+    samplerDesc.Filter = d3dFilterMode[filterMode_ != FILTER_DEFAULT ? filterMode_ : graphics_->GetDefaultTextureFilterMode()];
+    samplerDesc.AddressU = d3dAddressMode[addressMode_[0]];
+    samplerDesc.AddressV = d3dAddressMode[addressMode_[1]];
+    samplerDesc.AddressW = d3dAddressMode[addressMode_[2]];
+    samplerDesc.MaxAnisotropy = graphics_->GetTextureAnisotropy();
+    samplerDesc.ComparisonFunc = D3D11_COMPARISON_LESS_EQUAL;
+    samplerDesc.MinLOD = -M_INFINITY;
+    samplerDesc.MaxLOD = M_INFINITY;
+    memcpy(&samplerDesc.BorderColor, borderColor_.Data(), 4 * sizeof(float));
+
+    graphics_->GetImpl()->GetDevice()->CreateSamplerState(&samplerDesc, (ID3D11SamplerState**)&sampler_);
+
+    if (!sampler_)
+        LOGERROR("Failed to create sampler state");
+
+    parametersDirty_ = false;
+}
+
 SharedArrayPtr<unsigned char> Texture::ConvertRGBToRGBA(int width, int height, const unsigned char* data)
 SharedArrayPtr<unsigned char> Texture::ConvertRGBToRGBA(int width, int height, const unsigned char* data)
 {
 {
     if (!width || !height)
     if (!width || !height)

+ 12 - 0
Source/Urho3D/Graphics/Direct3D11/D3D11Texture.h

@@ -98,13 +98,21 @@ public:
     unsigned GetDataSize(int width, int height, int depth) const;
     unsigned GetDataSize(int width, int height, int depth) const;
     /// Return data size in bytes for a pixel or block row.
     /// Return data size in bytes for a pixel or block row.
     unsigned GetRowDataSize(int width) const;
     unsigned GetRowDataSize(int width) const;
+    /// Return whether the parameters are dirty.
+    bool GetParametersDirty() const { return parametersDirty_; }
 
 
     /// Set additional parameters from an XML file.
     /// Set additional parameters from an XML file.
     void SetParameters(XMLFile* xml);
     void SetParameters(XMLFile* xml);
     /// Set additional parameters from an XML element.
     /// Set additional parameters from an XML element.
     void SetParameters(const XMLElement& element);
     void SetParameters(const XMLElement& element);
+    /// Mark parameters dirty. Called by Graphics.
+    void SetParametersDirty();
+    /// Create sampler state object after parameters have been changed. Called by Graphics when assigning the texture.
+    void UpdateParameters();
     /// Return shader resource view.
     /// Return shader resource view.
     void* GetShaderResourceView() const { return shaderResourceView_; }
     void* GetShaderResourceView() const { return shaderResourceView_; }
+    /// Return sampler state object.
+    void* GetSampler() const { return sampler_; }
     
     
     /// Convert RGB data to RGBA for loading into a texture.
     /// Convert RGB data to RGBA for loading into a texture.
     static SharedArrayPtr<unsigned char> ConvertRGBToRGBA(int width, int height, const unsigned char* data);
     static SharedArrayPtr<unsigned char> ConvertRGBToRGBA(int width, int height, const unsigned char* data);
@@ -117,6 +125,8 @@ protected:
     
     
     /// Shader resource view.
     /// Shader resource view.
     void* shaderResourceView_;
     void* shaderResourceView_;
+    /// Sampler state object.
+    void* sampler_;
     /// Texture format.
     /// Texture format.
     unsigned format_;
     unsigned format_;
     /// Texture usage type.
     /// Texture usage type.
@@ -141,6 +151,8 @@ protected:
     Color borderColor_;
     Color borderColor_;
     /// sRGB sampling and writing mode flag.
     /// sRGB sampling and writing mode flag.
     bool sRGB_;
     bool sRGB_;
+    /// Parameters dirty flag.
+    bool parametersDirty_;
     /// Backup texture.
     /// Backup texture.
     SharedPtr<Texture> backupTexture_;
     SharedPtr<Texture> backupTexture_;
 };
 };

+ 6 - 0
Source/Urho3D/Graphics/Direct3D11/D3D11Texture2D.cpp

@@ -120,6 +120,12 @@ void Texture2D::Release()
             ((ID3D11ShaderResourceView*)shaderResourceView_)->Release();
             ((ID3D11ShaderResourceView*)shaderResourceView_)->Release();
             shaderResourceView_ = 0;
             shaderResourceView_ = 0;
         }
         }
+
+        if (sampler_)
+        {
+            ((ID3D11SamplerState*)sampler_)->Release();
+            sampler_ = 0;
+        }
     }
     }
     else
     else
     {
     {

+ 6 - 0
Source/Urho3D/Graphics/Direct3D11/D3D11Texture3D.cpp

@@ -164,6 +164,12 @@ void Texture3D::Release()
             ((ID3D11ShaderResourceView*)shaderResourceView_)->Release();
             ((ID3D11ShaderResourceView*)shaderResourceView_)->Release();
             shaderResourceView_ = 0;
             shaderResourceView_ = 0;
         }
         }
+
+        if (sampler_)
+        {
+            ((ID3D11SamplerState*)sampler_)->Release();
+            sampler_ = 0;
+        }
     }
     }
     else
     else
     {
     {

+ 6 - 0
Source/Urho3D/Graphics/Direct3D11/D3D11TextureCube.cpp

@@ -256,6 +256,12 @@ void TextureCube::Release()
             ((ID3D11ShaderResourceView*)shaderResourceView_)->Release();
             ((ID3D11ShaderResourceView*)shaderResourceView_)->Release();
             shaderResourceView_ = 0;
             shaderResourceView_ = 0;
         }
         }
+
+        if (sampler_)
+        {
+            ((ID3D11SamplerState*)sampler_)->Release();
+            sampler_ = 0;
+        }
     }
     }
 }
 }
 
 

+ 3 - 0
Source/Urho3D/Graphics/Direct3D11/D3D11VertexDeclaration.cpp

@@ -60,6 +60,9 @@ VertexDeclaration::VertexDeclaration(Graphics* graphics, ShaderVariation* vertex
         }
         }
     }
     }
 
 
+    if (elementDescs.Empty())
+        return;
+
     ID3D11InputLayout* d3dInputLayout = 0;
     ID3D11InputLayout* d3dInputLayout = 0;
     const PODVector<unsigned char>& byteCode = vertexShader->GetByteCode();
     const PODVector<unsigned char>& byteCode = vertexShader->GetByteCode();
 
 

+ 3 - 3
Source/Urho3D/Graphics/Direct3D9/D3D9Graphics.cpp

@@ -294,7 +294,7 @@ Graphics::~Graphics()
         MutexLock lock(gpuObjectMutex_);
         MutexLock lock(gpuObjectMutex_);
 
 
         // Release all GPU objects that still exist
         // Release all GPU objects that still exist
-        for (Vector<GPUObject*>::Iterator i = gpuObjects_.Begin(); i != gpuObjects_.End(); ++i)
+        for (PODVector<GPUObject*>::Iterator i = gpuObjects_.Begin(); i != gpuObjects_.End(); ++i)
             (*i)->Release();
             (*i)->Release();
         gpuObjects_.Clear();
         gpuObjects_.Clear();
     }
     }
@@ -2675,7 +2675,7 @@ void Graphics::OnDeviceLost()
     {
     {
         MutexLock lock(gpuObjectMutex_);
         MutexLock lock(gpuObjectMutex_);
 
 
-        for (Vector<GPUObject*>::Iterator i = gpuObjects_.Begin(); i != gpuObjects_.End(); ++i)
+        for (PODVector<GPUObject*>::Iterator i = gpuObjects_.Begin(); i != gpuObjects_.End(); ++i)
             (*i)->OnDeviceLost();
             (*i)->OnDeviceLost();
     }
     }
     
     
@@ -2687,7 +2687,7 @@ void Graphics::OnDeviceReset()
     {
     {
         MutexLock lock(gpuObjectMutex_);
         MutexLock lock(gpuObjectMutex_);
 
 
-        for (Vector<GPUObject*>::Iterator i = gpuObjects_.Begin(); i != gpuObjects_.End(); ++i)
+        for (PODVector<GPUObject*>::Iterator i = gpuObjects_.Begin(); i != gpuObjects_.End(); ++i)
             (*i)->OnDeviceReset();
             (*i)->OnDeviceReset();
     }
     }
     
     

+ 1 - 1
Source/Urho3D/Graphics/Direct3D9/D3D9Graphics.h

@@ -502,7 +502,7 @@ private:
     /// Largest scratch buffer request this frame.
     /// Largest scratch buffer request this frame.
     unsigned maxScratchBufferRequest_;
     unsigned maxScratchBufferRequest_;
     /// GPU objects.
     /// GPU objects.
-    Vector<GPUObject*> gpuObjects_;
+    PODVector<GPUObject*> gpuObjects_;
     /// Scratch buffers.
     /// Scratch buffers.
     Vector<ScratchBuffer> scratchBuffers_;
     Vector<ScratchBuffer> scratchBuffers_;
     /// Vertex declarations.
     /// Vertex declarations.

+ 4 - 4
Source/Urho3D/Graphics/OpenGL/OGLGraphics.cpp

@@ -1530,7 +1530,7 @@ void Graphics::SetTextureParametersDirty()
 {
 {
     MutexLock lock(gpuObjectMutex_);
     MutexLock lock(gpuObjectMutex_);
     
     
-    for (Vector<GPUObject*>::Iterator i = gpuObjects_.Begin(); i != gpuObjects_.End(); ++i)
+    for (PODVector<GPUObject*>::Iterator i = gpuObjects_.Begin(); i != gpuObjects_.End(); ++i)
     {
     {
         Texture* texture = dynamic_cast<Texture*>(*i);
         Texture* texture = dynamic_cast<Texture*>(*i);
         if (texture)
         if (texture)
@@ -2349,14 +2349,14 @@ void Graphics::Release(bool clearGPUObjects, bool closeWindow)
             // Shader programs are also GPU objects; clear them first to avoid list modification during iteration
             // Shader programs are also GPU objects; clear them first to avoid list modification during iteration
             shaderPrograms_.Clear();
             shaderPrograms_.Clear();
 
 
-            for (Vector<GPUObject*>::Iterator i = gpuObjects_.Begin(); i != gpuObjects_.End(); ++i)
+            for (PODVector<GPUObject*>::Iterator i = gpuObjects_.Begin(); i != gpuObjects_.End(); ++i)
                 (*i)->Release();
                 (*i)->Release();
             gpuObjects_.Clear();
             gpuObjects_.Clear();
         }
         }
         else
         else
         {
         {
             // We are not shutting down, but recreating the context: mark GPU objects lost
             // We are not shutting down, but recreating the context: mark GPU objects lost
-            for (Vector<GPUObject*>::Iterator i = gpuObjects_.Begin(); i != gpuObjects_.End(); ++i)
+            for (PODVector<GPUObject*>::Iterator i = gpuObjects_.Begin(); i != gpuObjects_.End(); ++i)
                 (*i)->OnDeviceLost();
                 (*i)->OnDeviceLost();
                 
                 
             // In this case clear shader programs last so that they do not attempt to delete their OpenGL program
             // In this case clear shader programs last so that they do not attempt to delete their OpenGL program
@@ -2435,7 +2435,7 @@ void Graphics::Restore()
     {
     {
         MutexLock lock(gpuObjectMutex_);
         MutexLock lock(gpuObjectMutex_);
         
         
-        for (Vector<GPUObject*>::Iterator i = gpuObjects_.Begin(); i != gpuObjects_.End(); ++i)
+        for (PODVector<GPUObject*>::Iterator i = gpuObjects_.Begin(); i != gpuObjects_.End(); ++i)
             (*i)->OnDeviceReset();
             (*i)->OnDeviceReset();
     }
     }
 
 

+ 1 - 1
Source/Urho3D/Graphics/OpenGL/OGLGraphics.h

@@ -504,7 +504,7 @@ private:
     /// Largest scratch buffer request this frame.
     /// Largest scratch buffer request this frame.
     unsigned maxScratchBufferRequest_;
     unsigned maxScratchBufferRequest_;
     /// GPU objects.
     /// GPU objects.
-    Vector<GPUObject*> gpuObjects_;
+    PODVector<GPUObject*> gpuObjects_;
     /// Scratch buffers.
     /// Scratch buffers.
     Vector<ScratchBuffer> scratchBuffers_;
     Vector<ScratchBuffer> scratchBuffers_;
     /// Shadow map dummy color texture format.
     /// Shadow map dummy color texture format.