Kaynağa Gözat

Added profiling blocks to shader loading.
Renamed Engine::DumpProfilingData() to Engine::DumpProfiler() to be shorter to type on the console.

Lasse Öörni 12 yıl önce
ebeveyn
işleme
0ef6e3f135

+ 1 - 1
Docs/ScriptAPI.dox

@@ -5851,7 +5851,7 @@ Methods:<br>
 - void SendEvent(const String&, VariantMap& arg1 = VariantMap ( ))
 - void SendEvent(const String&, VariantMap& arg1 = VariantMap ( ))
 - void RunFrame()
 - void RunFrame()
 - void Exit()
 - void Exit()
-- void DumpProfilingData()
+- void DumpProfiler()
 - void DumpResources()
 - void DumpResources()
 - void DumpMemory()
 - void DumpMemory()
 - Console@ CreateConsole()
 - Console@ CreateConsole()

+ 1 - 1
Engine/Engine/Engine.cpp

@@ -377,7 +377,7 @@ void Engine::Exit()
     exiting_ = true;
     exiting_ = true;
 }
 }
 
 
-void Engine::DumpProfilingData()
+void Engine::DumpProfiler()
 {
 {
     Profiler* profiler = GetSubsystem<Profiler>();
     Profiler* profiler = GetSubsystem<Profiler>();
     if (profiler)
     if (profiler)

+ 1 - 1
Engine/Engine/Engine.h

@@ -63,7 +63,7 @@ public:
     /// Close the application window and set the exit flag.
     /// Close the application window and set the exit flag.
     void Exit();
     void Exit();
     /// Dump profiling information to the log.
     /// Dump profiling information to the log.
-    void DumpProfilingData();
+    void DumpProfiler();
     /// Dump information of all resources to the log.
     /// Dump information of all resources to the log.
     void DumpResources();
     void DumpResources();
     /// Dump information of all memory allocations to the log. Supported in MSVC debug mode only.
     /// Dump information of all memory allocations to the log. Supported in MSVC debug mode only.

+ 1 - 1
Engine/Engine/EngineAPI.cpp

@@ -100,7 +100,7 @@ static void RegisterEngine(asIScriptEngine* engine)
     RegisterObject<Engine>(engine, "Engine");
     RegisterObject<Engine>(engine, "Engine");
     engine->RegisterObjectMethod("Engine", "void RunFrame()", asMETHOD(Engine, RunFrame), asCALL_THISCALL);
     engine->RegisterObjectMethod("Engine", "void RunFrame()", asMETHOD(Engine, RunFrame), asCALL_THISCALL);
     engine->RegisterObjectMethod("Engine", "void Exit()", asMETHOD(Engine, Exit), asCALL_THISCALL);
     engine->RegisterObjectMethod("Engine", "void Exit()", asMETHOD(Engine, Exit), asCALL_THISCALL);
-    engine->RegisterObjectMethod("Engine", "void DumpProfilingData()", asMETHOD(Engine, DumpProfilingData), asCALL_THISCALL);
+    engine->RegisterObjectMethod("Engine", "void DumpProfiler()", asMETHOD(Engine, DumpProfiler), asCALL_THISCALL);
     engine->RegisterObjectMethod("Engine", "void DumpResources()", asMETHOD(Engine, DumpResources), asCALL_THISCALL);
     engine->RegisterObjectMethod("Engine", "void DumpResources()", asMETHOD(Engine, DumpResources), asCALL_THISCALL);
     engine->RegisterObjectMethod("Engine", "void DumpMemory()", asMETHOD(Engine, DumpMemory), asCALL_THISCALL);
     engine->RegisterObjectMethod("Engine", "void DumpMemory()", asMETHOD(Engine, DumpMemory), asCALL_THISCALL);
     engine->RegisterObjectMethod("Engine", "Console@+ CreateConsole()", asMETHOD(Engine, CreateConsole), asCALL_THISCALL);
     engine->RegisterObjectMethod("Engine", "Console@+ CreateConsole()", asMETHOD(Engine, CreateConsole), asCALL_THISCALL);

+ 1 - 1
Engine/Graphics/Direct3D9/D3D9Graphics.cpp

@@ -941,7 +941,7 @@ void Graphics::SetShaders(ShaderVariation* vs, ShaderVariation* ps)
             if (!vs->IsFailed())
             if (!vs->IsFailed())
             {
             {
                 PROFILE(CreateVertexShader);
                 PROFILE(CreateVertexShader);
-
+                
                 bool success = vs->Create();
                 bool success = vs->Create();
                 if (success)
                 if (success)
                     LOGDEBUG("Created vertex shader " + vs->GetName());
                     LOGDEBUG("Created vertex shader " + vs->GetName());

+ 14 - 8
Engine/Graphics/Direct3D9/D3D9Shader.cpp

@@ -91,6 +91,8 @@ bool Shader::Load(Deserializer& source)
     File* sourceFile = dynamic_cast<File*>(&source);
     File* sourceFile = dynamic_cast<File*>(&source);
     if (sourceFile && !sourceFile->IsPackaged())
     if (sourceFile && !sourceFile->IsPackaged())
     {
     {
+        PROFILE(CheckTimestamps);
+        
         FileSystem* fileSystem = GetSubsystem<FileSystem>();
         FileSystem* fileSystem = GetSubsystem<FileSystem>();
         
         
         if (fileSystem && !fileSystem->HasRegisteredPaths())
         if (fileSystem && !fileSystem->HasRegisteredPaths())
@@ -159,15 +161,19 @@ bool Shader::Load(Deserializer& source)
         globalDefineValues.Push("1");
         globalDefineValues.Push("1");
     }
     }
     
     
-    if (!vsParser_.Parse(VS, shaders, globalDefines, globalDefineValues))
     {
     {
-        LOGERROR("VS: " + vsParser_.GetErrorMessage());
-        return false;
-    }
-    if (!psParser_.Parse(PS, shaders, globalDefines, globalDefineValues))
-    {
-        LOGERROR("PS: " + psParser_.GetErrorMessage());
-        return false;
+        PROFILE(ParseShaderDefinition);
+        
+        if (!vsParser_.Parse(VS, shaders, globalDefines, globalDefineValues))
+        {
+            LOGERROR("VS: " + vsParser_.GetErrorMessage());
+            return false;
+        }
+        if (!psParser_.Parse(PS, shaders, globalDefines, globalDefineValues))
+        {
+            LOGERROR("PS: " + psParser_.GetErrorMessage());
+            return false;
+        }
     }
     }
     
     
     // If variations had already been created, clear their bytecode
     // If variations had already been created, clear their bytecode

+ 1 - 1
Engine/Graphics/Octree.cpp

@@ -560,7 +560,7 @@ void Octree::UpdateDrawables(const FrameInfo& frame)
     if (drawableUpdates_.Empty())
     if (drawableUpdates_.Empty())
         return;
         return;
     
     
-    PROFILE(AnimateDrawables);
+    PROFILE(UpdateDrawables);
     
     
     Scene* scene = GetScene();
     Scene* scene = GetScene();
     WorkQueue* queue = GetSubsystem<WorkQueue>();
     WorkQueue* queue = GetSubsystem<WorkQueue>();

+ 2 - 0
Engine/Graphics/OpenGL/OGLGraphics.cpp

@@ -967,6 +967,8 @@ void Graphics::SetShaders(ShaderVariation* vs, ShaderVariation* ps)
         else
         else
         {
         {
             // Link a new combination
             // Link a new combination
+            PROFILE(LinkShaders);
+            
             SharedPtr<ShaderProgram> newProgram(new ShaderProgram(this, vs, ps));
             SharedPtr<ShaderProgram> newProgram(new ShaderProgram(this, vs, ps));
             if (newProgram->Link())
             if (newProgram->Link())
             {
             {

+ 20 - 12
Engine/Graphics/OpenGL/OGLShader.cpp

@@ -80,24 +80,32 @@ bool Shader::Load(Deserializer& source)
         return false;
         return false;
     }
     }
     
     
-    if (!vsParser_.Parse(VS, shaders))
     {
     {
-        LOGERROR("VS: " + vsParser_.GetErrorMessage());
-        return false;
-    }
-    if (!psParser_.Parse(PS, shaders))
-    {
-        LOGERROR("PS: " + psParser_.GetErrorMessage());
-        return false;
+        PROFILE(ParseShaderDefinition);
+        
+        if (!vsParser_.Parse(VS, shaders))
+        {
+            LOGERROR("VS: " + vsParser_.GetErrorMessage());
+            return false;
+        }
+        if (!psParser_.Parse(PS, shaders))
+        {
+            LOGERROR("PS: " + psParser_.GetErrorMessage());
+            return false;
+        }
     }
     }
     
     
     String path, fileName, extension;
     String path, fileName, extension;
     SplitPath(GetName(), path, fileName, extension);
     SplitPath(GetName(), path, fileName, extension);
     
     
-    if (!ProcessSource(vsSourceCode_, vsSourceCodeLength_, path + fileName + ".vert"))
-        return false;
-    if (!ProcessSource(psSourceCode_, psSourceCodeLength_, path + fileName + ".frag"))
-        return false;
+    {
+        PROFILE(LoadShaderSource);
+        
+        if (!ProcessSource(vsSourceCode_, vsSourceCodeLength_, path + fileName + ".vert"))
+            return false;
+        if (!ProcessSource(psSourceCode_, psSourceCodeLength_, path + fileName + ".frag"))
+            return false;
+    }
     
     
     // If variations had already been created, release them and set new source code
     // If variations had already been created, release them and set new source code
     /// \todo Should also update defines
     /// \todo Should also update defines