浏览代码

Fixed shader memory use calculation.

Lasse Öörni 13 年之前
父节点
当前提交
6b14fcbf86
共有 2 个文件被更改,包括 8 次插入2 次删除
  1. 2 1
      Engine/Graphics/Direct3D9/D3D9Shader.cpp
  2. 6 1
      Engine/Graphics/OpenGL/OGLShader.cpp

+ 2 - 1
Engine/Graphics/Direct3D9/D3D9Shader.cpp

@@ -148,7 +148,8 @@ bool Shader::Load(Deserializer& source)
         i->second_->SetByteCode(SharedArrayPtr<unsigned char>());
     }
     
-    SetMemoryUse(sizeof(Shader) + 2 * sizeof(ShaderParser));
+    SetMemoryUse(sizeof(Shader) + 2 * sizeof(ShaderParser) + (vsVariations_.Size() + psVariations_.Size()) *
+        sizeof(ShaderVariation));
     return true;
 }
 

+ 6 - 1
Engine/Graphics/OpenGL/OGLShader.cpp

@@ -93,7 +93,8 @@ bool Shader::Load(Deserializer& source)
     for (HashMap<StringHash, SharedPtr<ShaderVariation> >::Iterator i = psVariations_.Begin(); i != psVariations_.End(); ++i)
         i->second_->Release();
     
-    SetMemoryUse(sizeof(Shader) + 2 * sizeof(ShaderParser) + vsSourceCodeLength_ + psSourceCodeLength_);
+    SetMemoryUse(sizeof(Shader) + 2 * sizeof(ShaderParser) + (vsVariations_.Size() + psVariations_.Size()) *
+        sizeof(ShaderVariation));
     
     return true;
 }
@@ -124,6 +125,8 @@ ShaderVariation* Shader::GetVariation(ShaderType type, const String& name)
                 i->second_->SetName(fullName);
                 i->second_->SetSourceCode(vsSourceCode_, vsSourceCodeLength_);
                 i->second_->SetDefines(combination.defines_, combination.defineValues_);
+                
+                SetMemoryUse(GetMemoryUse() + sizeof(ShaderVariation));
             }
             
             return i->second_;
@@ -153,6 +156,8 @@ ShaderVariation* Shader::GetVariation(ShaderType type, const String& name)
                 i->second_->SetName(fullName);
                 i->second_->SetSourceCode(psSourceCode_, psSourceCodeLength_);
                 i->second_->SetDefines(combination.defines_, combination.defineValues_);
+                
+                SetMemoryUse(GetMemoryUse() + sizeof(ShaderVariation));
             }
             
             return i->second_;