瀏覽代碼

Adding some resource loading tracing info

Panagiotis Christopoulos Charitos 9 年之前
父節點
當前提交
4a2cec835e

+ 1 - 0
include/anki/core/App.h

@@ -164,6 +164,7 @@ private:
 	String m_settingsDir; ///< The path that holds the configuration
 	String m_cacheDir; ///< This is used as a cache
 	F32 m_timerTick;
+	U64 m_resourceCompletedAsyncTaskCount = 0;
 
 	ANKI_USE_RESULT Error initInternal(const ConfigSet& config,
 		AllocAlignedCallback allocCb,

+ 1 - 0
include/anki/core/Trace.h

@@ -66,6 +66,7 @@ enum class TraceCounterType
 	RENDERER_SHADOW_PASSES,
 	RENDERER_MERGED_DRAWCALLS,
 	RENDERER_REFLECTIONS,
+	RESOURCE_ASYNC_TASKS,
 	SCENE_NODES_UPDATED,
 
 	COUNT

+ 2 - 2
include/anki/renderer/Renderer.h

@@ -376,7 +376,7 @@ anki_internal:
 	{
 		return m_globTimestamp;
 	}
-	
+
 	/// Returns true if there were resources loaded or loading async tasks that
 	/// got completed.
 	Bool resourcesLoaded() const
@@ -433,7 +433,7 @@ private:
 
 	FramebufferPtr m_outputFb;
 	UVec2 m_outputFbSize;
-	
+
 	U64 m_prevLoadRequestCount = 0;
 	U64 m_prevAsyncTasksCompleted = 0;
 	Bool m_resourcesDirty = true;

+ 2 - 2
include/anki/resource/AsyncLoader.h

@@ -79,7 +79,7 @@ public:
 	{
 		return m_alloc;
 	}
-	
+
 	/// Get the total number of completed tasks.
 	U64 getCompletedTaskCount() const
 	{
@@ -97,7 +97,7 @@ private:
 	Bool8 m_quit = false;
 	Bool8 m_paused = false;
 	Bool8 m_sync = false;
-	
+
 	Atomic<U64> m_completedTaskCount = {0};
 
 	/// Thread callback

+ 3 - 14
include/anki/resource/ResourceManager.h

@@ -184,17 +184,6 @@ anki_internal:
 		m_shadersPrependedSource.create(m_alloc, cstr);
 	}
 
-	void setRenderer(Renderer* r)
-	{
-		m_r = r;
-	}
-
-	const Renderer& getRenderer() const
-	{
-		ANKI_ASSERT(m_r);
-		return *m_r;
-	}
-
 	const String& _getShadersPrependedSource() const
 	{
 		return m_shadersPrependedSource;
@@ -222,20 +211,20 @@ anki_internal:
 	{
 		return *m_asyncLoader;
 	}
-	
+
 	/// Get the number of times loadResource() was called.
 	U64 getLoadingRequestCount() const
 	{
 		return m_loadRequestCount;
 	}
-	
+
+	/// Get the total number of completed async tasks.
 	U64 getAsyncTaskCompletedCount() const;
 
 private:
 	GrManager* m_gr = nullptr;
 	PhysicsWorld* m_physics = nullptr;
 	ResourceFilesystem* m_fs = nullptr;
-	Renderer* m_r = nullptr;
 	ResourceAllocator<U8> m_alloc;
 	TempResourceAllocator<U8> m_tmpAlloc;
 	String m_cacheDir;

+ 1 - 1
sandbox/config.xml

@@ -34,7 +34,7 @@
 	<dbg.enabled>0</dbg.enabled>
 	<tm.enabled>1</tm.enabled>
 	<width>1920</width>
-	<height>1088</height>
+	<height>1080</height>
 	<renderingQuality>1</renderingQuality>
 	<lodDistance>20</lodDistance>
 	<samples>1</samples>

+ 7 - 1
src/core/App.cpp

@@ -281,7 +281,6 @@ Error App::initInternal(const ConfigSet& config_,
 
 	m_resources->_setShadersPrependedSource(
 		m_renderer->getMaterialShaderSource().toCString());
-	m_resources->setRenderer(&m_renderer->getOffscreenRenderer());
 
 	//
 	// Scene
@@ -391,6 +390,13 @@ Error App::mainLoop()
 
 		m_gr->swapBuffers();
 
+		// Update the trace info with some async loader stats
+		U64 asyncTaskCount =
+			m_resources->getAsyncLoader().getCompletedTaskCount();
+		ANKI_TRACE_INC_COUNTER(RESOURCE_ASYNC_TASKS,
+			asyncTaskCount - m_resourceCompletedAsyncTaskCount);
+		m_resourceCompletedAsyncTaskCount = asyncTaskCount;
+
 		// Now resume the loader
 		m_resources->getAsyncLoader().resume();
 

+ 1 - 0
src/core/Trace.cpp

@@ -54,6 +54,7 @@ static Array<const char*, U(TraceCounterType::COUNT)> counterNames = {
 		"RENDERER_SHADOW_PASSES",
 		"RENDERER_MERGED_DRAWCALLS",
 		"RENDERER_REFLECTIONS",
+		"RESOURCE_ASYNC_TASKS",
 		"SCENE_NODES_UPDATED"}};
 
 #define ANKI_TRACE_FILE_ERROR()                                                \

+ 3 - 2
src/renderer/Renderer.cpp

@@ -240,10 +240,11 @@ Error Renderer::render(RenderingContext& ctx)
 		commonUniforms->m_nearFarLinearizeDepth.w());
 
 	commonUniforms->m_projectionMatrix = frc.getProjectionMatrix();
-	
+
 	// Check if resources got loaded
 	if(m_prevLoadRequestCount != m_resources->getLoadingRequestCount()
-		|| m_prevAsyncTasksCompleted != m_resources->getAsyncTaskCompletedCount())
+		|| m_prevAsyncTasksCompleted
+			!= m_resources->getAsyncTaskCompletedCount())
 	{
 		m_prevLoadRequestCount = m_resources->getLoadingRequestCount();
 		m_prevAsyncTasksCompleted = m_resources->getAsyncTaskCompletedCount();