Browse Source

Fixed shader memory use calculation.

Lasse Öörni 13 năm trước cách đây
mục cha
commit
6b14fcbf86

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

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