Просмотр исходного кода

Making timestamp not global & making tiler to work with no square sizes

Panagiotis Christopoulos Charitos 11 лет назад
Родитель
Сommit
5a4dd45031

+ 2 - 2
include/anki/Config.h.cmake

@@ -112,8 +112,8 @@
 #define ANKI_SAFE_ALIGNMENT 16
 
 // Renderer and rendering related config options
-#define ANKI_RENDERER_MAX_TILES_X 32
-#define ANKI_RENDERER_MAX_TILES_Y 32
+#define ANKI_RENDERER_MAX_TILES_X 64
+#define ANKI_RENDERER_MAX_TILES_Y 64
 
 #define ANKI_RENDERER_USE_MATERIAL_UBOS 0
 

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

@@ -8,6 +8,7 @@
 
 #include "anki/util/Allocator.h"
 #include "anki/util/String.h"
+#include "anki/core/Timestamp.h"
 #if ANKI_OS == ANKI_OS_ANDROID
 #	include <android_native_app_glue.h>
 #endif
@@ -83,6 +84,11 @@ public:
 		return m_heapAlloc;
 	}
 
+	Timestamp getGlobalTimestamp() const
+	{
+		return m_globalTimestamp;
+	}
+
 	/// Run the main loop.
 	/// @param callback The user callback to run along with the other main loop
 	///                 code.
@@ -142,6 +148,7 @@ private:
 	ScriptManager* m_script = nullptr;
 
 	// Misc
+	Timestamp m_globalTimestamp = 0;
 	void* m_ctx = nullptr;
 	Threadpool* m_threadpool = nullptr;
 	String m_settingsDir; ///< The path that holds the configuration

+ 4 - 1
include/anki/core/Counters.h

@@ -10,6 +10,7 @@
 #include "anki/util/HighRezTimer.h"
 #include "anki/util/Atomic.h"
 #include "anki/util/Thread.h"
+#include "anki/core/Timestamp.h"
 
 namespace anki {
 
@@ -45,7 +46,8 @@ public:
 	~CountersManager();
 
 	ANKI_USE_RESULT Error create(
-		HeapAllocator<U8> alloc, const CString& cacheDir);
+		HeapAllocator<U8> alloc, const CString& cacheDir,
+		const Timestamp* globalTimestamp);
 
 	void increaseCounter(Counter counter, F64 val);
 	void increaseCounter(Counter counter, U64 val);
@@ -70,6 +72,7 @@ private:
 		U64 m_int;
 	};
 
+	const Timestamp* m_globalTimestamp = nullptr;
 	HeapAllocator<U8> m_alloc;
 	File m_perframeFile;
 	File m_perrunFile;

+ 0 - 15
include/anki/core/Timestamp.h

@@ -13,21 +13,6 @@ namespace anki {
 /// Timestamp type
 typedef U32 Timestamp;
 
-/// Increase the current timestamp. Should be called in the main loop
-inline void increaseGlobTimestamp()
-{
-	extern Timestamp globTimestamp;
-	++globTimestamp;
-}
-
-/// Give the current timestamp. It actually gives the current frame. Used to
-/// indicate updates. It is actually returning the current frame
-inline Timestamp getGlobTimestamp()
-{
-	extern Timestamp globTimestamp;
-	return globTimestamp;
-}
-
 } // end namespace anki
 
 #endif

+ 3 - 3
include/anki/renderer/Hdr.h

@@ -35,7 +35,7 @@ public:
 	void setExposure(const F32 x)
 	{
 		m_exposure = x;
-		m_parameterUpdateTimestamp = getGlobTimestamp();
+		m_parameterUpdateTimestamp = getGlobalTimestamp();
 	}
 
 	U32 getBlurringIterationsCount() const
@@ -86,9 +86,9 @@ private:
 	GlTextureHandle m_hblurRt; ///< pass0Fai with the horizontal blur FAI
 	GlTextureHandle m_vblurRt; ///< The final FAI
 	/// When a parameter changed by the setters
-	Timestamp m_parameterUpdateTimestamp = getGlobTimestamp();
+	Timestamp m_parameterUpdateTimestamp = 0;
 	/// When the commonUbo got updated
-	Timestamp m_commonUboUpdateTimestamp = getGlobTimestamp();
+	Timestamp m_commonUboUpdateTimestamp = 0;
 	GlBufferHandle m_commonBuff;
 
 	Hdr(Renderer* r)

+ 1 - 1
include/anki/renderer/Is.h

@@ -67,7 +67,7 @@ private:
 	GlBufferHandle m_commonBuff;
 
 	/// Track the updates of commonUbo
-	Timestamp m_commonBuffUpdateTimestamp = getGlobTimestamp();
+	Timestamp m_commonBuffUpdateTimestamp = 0;
 
 	/// Contains all the lights
 	GlBufferHandle m_lightsBuff;

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

@@ -26,7 +26,8 @@ public:
 		ResourceManager* resources,
 		GlDevice* gl,
 		HeapAllocator<U8>& alloc,
-		const ConfigSet& config);
+		const ConfigSet& config,
+		const Timestamp* globalTimestamp);
 
 	ANKI_USE_RESULT Error render(SceneGraph& scene);
 
@@ -45,7 +46,6 @@ private:
 	void takeScreenshotTga(const char* filename);
 	ANKI_USE_RESULT Error initGl();
 };
-
 /// @}
 
 } // end namespace anki

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

@@ -238,7 +238,8 @@ public:
 		ResourceManager* resources,
 		GlDevice* gl,
 		HeapAllocator<U8>& alloc,
-		const ConfigSet& config);
+		const ConfigSet& config,
+		const Timestamp* globalTimestamp);
 
 	/// @privatesection
 	/// @{
@@ -266,6 +267,11 @@ public:
 	{
 		return m_shadersPrependedSource;
 	}
+
+	Timestamp getGlobalTimestamp() const
+	{
+		return *m_globalTimestamp;
+	}
 	/// @}
 
 private:
@@ -273,6 +279,7 @@ private:
 	ResourceManager* m_resources;
 	GlDevice* m_gl;
 	HeapAllocator<U8> m_alloc;
+	const Timestamp* m_globalTimestamp = nullptr;
 
 	/// @name Rendering stages
 	/// @{
@@ -311,7 +318,7 @@ private:
 	/// position from the depth
 	Vec4 m_projectionParams;
 
-	Timestamp m_projectionParamsUpdateTimestamp = getGlobTimestamp();
+	Timestamp m_projectionParamsUpdateTimestamp = 0;
 	/// @}
 
 	SceneGraph* m_scene; ///< Current scene

+ 3 - 0
include/anki/renderer/RenderingPass.h

@@ -8,6 +8,7 @@
 
 #include "anki/util/StdTypes.h"
 #include "anki/Gl.h"
+#include "anki/core/Timestamp.h"
 #include "anki/resource/ResourceManager.h"
 #include "anki/resource/ProgramResource.h"
 
@@ -41,6 +42,8 @@ public:
 		m_enabled = e;
 	}
 
+	Timestamp getGlobalTimestamp() const;
+
 protected:
 	Renderer* m_r; ///< Know your father
 	Bool8 m_enabled = false;

+ 1 - 1
include/anki/renderer/Ssao.h

@@ -46,7 +46,7 @@ private:
 	GlPipelineHandle m_hblurPpline;
 	GlPipelineHandle m_vblurPpline;
 	
-	Timestamp m_commonUboUpdateTimestamp = getGlobTimestamp();
+	Timestamp m_commonUboUpdateTimestamp = 0;
 	GlBufferHandle m_uniformsBuff;
 	GlTextureHandle m_noiseTex;
 

+ 1 - 1
include/anki/renderer/Tiler.h

@@ -93,7 +93,7 @@ private:
 	const Camera* m_prevCam = nullptr;
 
 	/// Timestamp for the same reason as prevCam
-	Timestamp m_planes4UpdateTimestamp = getGlobTimestamp();
+	Timestamp m_planes4UpdateTimestamp = 0;
 
 	ANKI_USE_RESULT Error initInternal();
 

+ 5 - 1
include/anki/scene/SceneComponent.h

@@ -38,7 +38,8 @@ public:
 
 	/// Construct the scene component.
 	SceneComponent(Type type, SceneNode* node)
-	:	m_type(type)
+	:	m_node(node),
+		m_type(type)
 	{}
 
 	Type getType() const
@@ -51,6 +52,8 @@ public:
 		return m_timestamp;
 	}
 
+	Timestamp getGlobalTimestamp() const;
+
 	/// Do some reseting before frame starts
 	virtual void reset()
 	{}
@@ -94,6 +97,7 @@ public:
 	}
 
 protected:
+	SceneNode* m_node;
 	Timestamp m_timestamp; ///< Indicates when an update happened
 
 private:

+ 14 - 5
include/anki/scene/SceneGraph.h

@@ -44,7 +44,13 @@ public:
 		U32 frameAllocatorSize,
 		Threadpool* threadpool, 
 		ResourceManager* resources,
-		Input* input);
+		Input* input,
+		const Timestamp* globalTimestamp);
+
+	Timestamp getGlobalTimestamp() const
+	{
+		return m_timestamp;
+	}
 
 	/// @note Return a copy
 	SceneAllocator<U8> getAllocator() const
@@ -65,7 +71,7 @@ public:
 	void setAmbientColor(const Vec4& x)
 	{
 		m_ambientCol = x.xyz();
-		m_ambiendColorUpdateTimestamp = getGlobTimestamp();
+		m_ambiendColorUpdateTimestamp = getGlobalTimestamp();
 	}
 	U32 getAmbientColorUpdateTimestamp() const
 	{
@@ -84,7 +90,7 @@ public:
 	void setActiveCamera(Camera* cam)
 	{
 		m_mainCam = cam;
-		m_activeCameraChangeTimestamp = getGlobTimestamp();
+		m_activeCameraChangeTimestamp = getGlobalTimestamp();
 	}
 	U32 getActiveCameraChangeTimestamp() const
 	{
@@ -178,6 +184,9 @@ public:
 	/// @}
 
 private:
+	const Timestamp* m_globalTimestamp = nullptr;
+	Timestamp m_timestamp = 0; ///< Cached timestamp
+
 	Threadpool* m_threadpool = nullptr;
 	ResourceManager* m_resources = nullptr;
 	GlDevice* m_gl = nullptr;
@@ -192,9 +201,9 @@ private:
 	//SceneDictionary<SceneNode*> m_dict;
 
 	Vec3 m_ambientCol = Vec3(1.0); ///< The global ambient color
-	Timestamp m_ambiendColorUpdateTimestamp = getGlobTimestamp();
+	Timestamp m_ambiendColorUpdateTimestamp = getGlobalTimestamp();
 	Camera* m_mainCam = nullptr;
-	Timestamp m_activeCameraChangeTimestamp = getGlobTimestamp();
+	Timestamp m_activeCameraChangeTimestamp = getGlobalTimestamp();
 
 	EventManager m_events;
 

+ 2 - 0
include/anki/scene/SceneNode.h

@@ -57,6 +57,8 @@ public:
 
 	void setMarkedForDeletion();
 
+	Timestamp getGlobalTimestamp() const;
+
 	SceneAllocator<U8> getSceneAllocator() const;
 
 	SceneFrameAllocator<U8> getSceneFrameAllocator() const;

+ 4 - 1
src/collision/Frustum.cpp

@@ -133,7 +133,10 @@ void Frustum::resetTransform(const Transform& trf)
 {
 	recalculate();
 	m_frustumDirty = false;
-	m_trf = trf;
+	if(&m_trf != &trf)
+	{
+		m_trf = trf;
+	}
 	
 	// Transform the compound
 	CompoundShape::transform(m_trf);

+ 5 - 5
src/core/App.cpp

@@ -148,7 +148,7 @@ Error App::createInternal(const ConfigSet& config_,
 
 #if ANKI_ENABLE_COUNTERS
 	err = CountersManagerSingleton::get().create(
-		m_heapAlloc, m_settingsDir.toCString());
+		m_heapAlloc, m_settingsDir.toCString(), &m_globalTimestamp);
 	if(err) return err;
 
 	err = TraceManagerSingleton::get().create(
@@ -250,7 +250,8 @@ Error App::createInternal(const ConfigSet& config_,
 		m_resources,
 		m_gl,
 		m_heapAlloc,
-		config);
+		config,
+		&m_globalTimestamp);
 	if(err) return err;
 
 	err = m_resources->_setShadersPrependedSource(
@@ -263,7 +264,7 @@ Error App::createInternal(const ConfigSet& config_,
 
 	err = m_scene->create(m_allocCb, m_allocCbData, 
 		config.get("sceneFrameAllocatorSize"), m_threadpool, m_resources,
-		m_input);
+		m_input, &m_globalTimestamp);
 	if(err) return err;
 
 	// Script
@@ -389,8 +390,7 @@ Error App::mainLoop(UserMainLoopCallback callback, void* userData)
 			HighRezTimer::sleep(getTimerTick() - timer.getElapsedTime());
 		}
 
-		// Timestamp
-		increaseGlobTimestamp();
+		++m_globalTimestamp;
 	}
 
 	// Performance ends

+ 2 - 2
src/core/Config.cpp

@@ -70,8 +70,8 @@ Config::Config()
 	newOption("renderingQuality", 1.0); // Applies only to MainRenderer
 	newOption("lodDistance", 10.0); // Distance that used to calculate the LOD
 	newOption("samples", 1);
-	newOption("tilesXCount", 16);
-	newOption("tilesYCount", 16);
+	newOption("tilesXCount", 30);
+	newOption("tilesYCount", 20);
 	newOption("tessellation", true);
 	newOption("sceneFrameAllocatorSize", 1024 * 1024);
 

+ 7 - 5
src/core/Counters.cpp

@@ -8,7 +8,6 @@
 #if ANKI_ENABLE_COUNTERS
 
 #include "anki/core/Counters.h"
-#include "anki/core/Timestamp.h"
 #include "anki/core/App.h"
 #include "anki/util/Array.h"
 #include <cstring>
@@ -54,10 +53,13 @@ static const Array<CounterInfo, (U)Counter::COUNT> cinfo = {{
 
 //==============================================================================
 Error CountersManager::create(
-	HeapAllocator<U8> alloc, const CString& cacheDir)
+	HeapAllocator<U8> alloc, const CString& cacheDir,
+	const Timestamp* globalTimestamp)
 {
 	Error err = ErrorCode::NONE;
 
+	m_globalTimestamp = globalTimestamp;
+
 	U count = static_cast<U>(Counter::COUNT);
 	m_alloc = alloc;
 	
@@ -199,7 +201,7 @@ void CountersManager::resolveFrame()
 	Error err = ErrorCode::NONE;
 
 	// Write new line and frame no
-	err = m_perframeFile.writeText("\n%llu", getGlobTimestamp());
+	err = m_perframeFile.writeText("\n%llu", *m_globalTimestamp);
 
 	U i = 0;
 	for(const CounterInfo& inf : cinfo)
@@ -257,7 +259,7 @@ void CountersManager::flush()
 				if(inf.m_flags & CF_FPS)
 				{
 					err = m_perrunFile.writeText("%" MAX_NAME "f", 
-						(F64)getGlobTimestamp() / m_perrunValues[i].m_float);
+						(F64)(*m_globalTimestamp) / m_perrunValues[i].m_float);
 				}
 				else
 				{
@@ -360,7 +362,7 @@ ThreadTraceManager::ThreadTraceManager()
 	TraceManager& master = TraceManagerSingleton::get();
 	m_master = &master;
 
-	auto index = master.m_threadCount.fetch_add(1);
+	auto index = master.m_threadCount.fetchAdd(1);
 	master.m_threadData[index] = this;
 	m_id = index;
 }

+ 0 - 13
src/core/Timestamp.cpp

@@ -1,13 +0,0 @@
-// Copyright (C) 2014, Panagiotis Christopoulos Charitos.
-// All rights reserved.
-// Code licensed under the BSD License.
-// http://www.anki3d.org/LICENSE
-
-#include "anki/core/Timestamp.h"
-
-namespace anki {
-
-// WARNING: If you change that prepare for allot of pain
-Timestamp globTimestamp = 1;
-
-} // end namespace anki

+ 3 - 3
src/renderer/Hdr.cpp

@@ -132,8 +132,8 @@ Error Hdr::initInternal(const ConfigSet& initializer)
 	if(err) return err;
 
 	// Set timestamps
-	m_parameterUpdateTimestamp = getGlobTimestamp();
-	m_commonUboUpdateTimestamp = getGlobTimestamp();
+	m_parameterUpdateTimestamp = getGlobalTimestamp();
+	m_commonUboUpdateTimestamp = getGlobalTimestamp();
 
 	return err;
 }
@@ -174,7 +174,7 @@ Error Hdr::run(GlCommandBufferHandle& cmdb)
 			return err;
 		}
 
-		m_commonUboUpdateTimestamp = getGlobTimestamp();
+		m_commonUboUpdateTimestamp = getGlobalTimestamp();
 	}
 
 	m_r->getIs()._getRt().bind(cmdb, 0);

+ 4 - 7
src/renderer/Is.cpp

@@ -33,29 +33,26 @@ void clamp(T& in, Y limit)
 
 namespace shader {
 
-class Light
+struct Light
 {
-public:
 	Vec4 m_posRadius;
 	Vec4 m_diffuseColorShadowmapId;
 	Vec4 m_specularColorTexId;
 };
 
-class PointLight: public Light
+struct PointLight: Light
 {};
 
-class SpotLight: public Light
+struct SpotLight: Light
 {
-public:
 	Vec4 m_lightDir;
 	Vec4 m_outerCosInnerCos;
 	Array<Vec4, 4> m_extendPoints;
 	Mat4 m_texProjectionMat; ///< Texture projection matrix
 };
 
-class CommonUniforms
+struct CommonUniforms
 {
-public:
 	Vec4 m_projectionParams;
 	Vec4 m_sceneAmbientColor;
 	Vec4 m_groundLightDir;

+ 4 - 2
src/renderer/MainRenderer.cpp

@@ -28,12 +28,14 @@ Error MainRenderer::create(
 	ResourceManager* resources,
 	GlDevice* gl,
 	HeapAllocator<U8>& alloc,
-	const ConfigSet& config)
+	const ConfigSet& config,
+	const Timestamp* globalTimestamp)
 {
 	Error err = ErrorCode::NONE;
 	ANKI_LOGI("Initializing main renderer...");
 
-	err = Renderer::init(threadpool, resources, gl, alloc, config);
+	err = Renderer::init(threadpool, resources, gl, alloc, config, 
+		globalTimestamp);
 	if(err) return err;
 
 	err = initGl();

+ 4 - 2
src/renderer/Renderer.cpp

@@ -34,8 +34,10 @@ Error Renderer::init(
 	ResourceManager* resources,
 	GlDevice* gl,
 	HeapAllocator<U8>& alloc,
-	const ConfigSet& config)
+	const ConfigSet& config,
+	const Timestamp* globalTimestamp)
 {
+	m_globalTimestamp = globalTimestamp;
 	m_threadpool = threadpool;
 	m_resources = resources;
 	m_gl = gl;
@@ -161,7 +163,7 @@ Error Renderer::render(SceneGraph& scene,
 	{
 		ANKI_ASSERT(cam.getCameraType() == Camera::Type::PERSPECTIVE);
 		computeProjectionParams(fr.getProjectionMatrix());
-		m_projectionParamsUpdateTimestamp = getGlobTimestamp();
+		m_projectionParamsUpdateTimestamp = getGlobalTimestamp();
 	}
 
 	ANKI_COUNTER_START_TIMER(RENDERER_MS_TIME);

+ 6 - 0
src/renderer/RenderingPass.cpp

@@ -9,6 +9,12 @@
 
 namespace anki {
 
+//==============================================================================
+Timestamp RenderingPass::getGlobalTimestamp() const
+{
+	return m_r->getGlobalTimestamp();
+}
+
 //==============================================================================
 GlDevice& RenderingPass::getGlDevice()
 {

+ 1 - 1
src/renderer/Sm.cpp

@@ -222,7 +222,7 @@ Error Sm::doLight(
 		return err;
 	}
 
-	sm->m_timestamp = getGlobTimestamp();
+	sm->m_timestamp = getGlobalTimestamp();
 	lcomp.setShadowMapIndex(sm - &m_sms[0]);
 
 	//

+ 1 - 1
src/renderer/Ssao.cpp

@@ -301,7 +301,7 @@ Error Ssao::run(GlCommandBufferHandle& cmdb)
 		blk.m_projectionMatrix = camFr.getProjectionMatrix().getTransposed();
 
 		m_uniformsBuff.write(cmdb, tmpBuff, 0, 0, tmpBuff.getSize());
-		m_commonUboUpdateTimestamp = getGlobTimestamp();
+		m_commonUboUpdateTimestamp = getGlobalTimestamp();
 	}
 
 	// Draw

+ 78 - 12
src/renderer/Tiler.cpp

@@ -206,7 +206,7 @@ void Tiler::updateTiles(Camera& cam)
 	// Update timestamp
 	if(frustumChanged)
 	{
-		m_planes4UpdateTimestamp = getGlobTimestamp();
+		m_planes4UpdateTimestamp = getGlobalTimestamp();
 	}
 
 	// Sync threads
@@ -250,8 +250,6 @@ void Tiler::testRange(const CollisionShape& cs, Bool nearPlane,
 	U my = (yTo - yFrom) / 2;
 	U mx = (xTo - xFrom) / 2;
 
-	ANKI_ASSERT(my == mx && "Change the algorithm if they are not the same");
-
 	// Handle final
 	if(ANKI_UNLIKELY(my == 0 && mx == 0))
 	{
@@ -331,6 +329,17 @@ void Tiler::testRange(const CollisionShape& cs, Bool nearPlane,
 			}
 		}
 	}
+	else
+	{
+		// Possibly all inside
+		for(U i = 0; i < 2; i++)
+		{
+			for(U j = 0; j < 2; j++)
+			{
+				inside[i][j] = true;
+			}
+		}
+	}
 
 	// Right looking plane check
 	if(mx > 0)
@@ -354,17 +363,74 @@ void Tiler::testRange(const CollisionShape& cs, Bool nearPlane,
 	}
 
 	// Now move lower to the hierarchy
-	for(U y = 0; y < 2; y++)
+	if(mx == 0)
 	{
-		for(U x = 0; x < 2; x++)
+		if(inside[0][0])
 		{
-			if(inside[y][x])
-			{
-				testRange(cs, nearPlane,
-					yFrom + (y * my), yFrom + ((y + 1) * my),
-					xFrom + (x * mx), xFrom + ((x + 1) * mx),
-					visible, count);
-			}
+			testRange(cs, nearPlane,
+				yFrom, yFrom + my,
+				xFrom, xTo,
+				visible, count);
+		}
+
+		if(inside[1][0])
+		{
+			testRange(cs, nearPlane,
+				yFrom + my, yTo,
+				xFrom, xTo,
+				visible, count);
+		}
+	}
+	else if(my == 0)
+	{
+		if(inside[0][0])
+		{
+			testRange(cs, nearPlane,
+				yFrom, yTo,
+				xFrom, xFrom + mx,
+				visible, count);
+		}
+
+		if(inside[0][1])
+		{
+			testRange(cs, nearPlane,
+				yFrom, yTo,
+				xFrom + mx, xTo,
+				visible, count);
+		}
+	}
+	else
+	{
+		if(inside[0][0])
+		{
+			testRange(cs, nearPlane,
+				yFrom, yFrom + my,
+				xFrom, xFrom + mx,
+				visible, count);
+		}
+
+		if(inside[0][1])
+		{
+			testRange(cs, nearPlane,
+				yFrom, yFrom + my,
+				xFrom + mx, xTo,
+				visible, count);
+		}
+
+		if(inside[1][0])
+		{
+			testRange(cs, nearPlane,
+				yFrom + my, yTo,
+				xFrom, xFrom + mx,
+				visible, count);
+		}
+
+		if(inside[1][1])
+		{
+			testRange(cs, nearPlane,
+				yFrom + my, yTo,
+				xFrom + mx, xTo,
+				visible, count);
 		}
 	}
 }

+ 2 - 2
src/scene/Camera.cpp

@@ -25,7 +25,7 @@ public:
 		updated = false;
 
 		MoveComponent& move = node.getComponent<MoveComponent>();
-		if(move.getTimestamp() == getGlobTimestamp())
+		if(move.getTimestamp() == getGlobalTimestamp())
 		{
 			Camera& cam = static_cast<Camera&>(node);
 			cam.onMoveComponentUpdate(move);
@@ -53,7 +53,7 @@ public:
 		updated = false;
 
 		FrustumComponent& fr = node.getComponent<FrustumComponent>();
-		if(fr.getTimestamp() == getGlobTimestamp())
+		if(fr.getTimestamp() == getGlobalTimestamp())
 		{
 			Camera& cam = static_cast<Camera&>(node);
 			cam.onFrustumComponentUpdate(fr);

+ 2 - 2
src/scene/LensFlareComponent.cpp

@@ -33,7 +33,7 @@ GlOcclusionQueryHandle& LensFlareComponent::getOcclusionQueryToTest()
 	m_crntQueryIndex = (m_crntQueryIndex + 1) % m_queries.getSize();
 	
 	// Save the timestamp
-	m_queryTestTimestamp[m_crntQueryIndex] = getGlobTimestamp();
+	m_queryTestTimestamp[m_crntQueryIndex] = getGlobalTimestamp();
 
 	return m_queries[m_crntQueryIndex];
 }
@@ -45,7 +45,7 @@ void LensFlareComponent::getOcclusionQueryToCheck(
 	U idx = (m_crntQueryIndex + 1) % m_queries.getSize();
 
 	if(m_queryTestTimestamp[idx] == MAX_U32
-		|| m_queryTestTimestamp[idx] != getGlobTimestamp() - 2)
+		|| m_queryTestTimestamp[idx] != getGlobalTimestamp() - 2)
 	{
 		queryInvalid = true;
 	}

+ 2 - 2
src/scene/Light.cpp

@@ -29,14 +29,14 @@ public:
 		Light& lnode = static_cast<Light&>(node);
 
 		MoveComponent& move = node.getComponent<MoveComponent>();
-		if(move.getTimestamp() == getGlobTimestamp())
+		if(move.getTimestamp() == node.getGlobalTimestamp())
 		{
 			// Move updated
 			lnode.onMoveUpdate(move);
 		}
 
 		LightComponent& light = node.getComponent<LightComponent>();
-		if(light.getTimestamp() == getGlobTimestamp())
+		if(light.getTimestamp() == node.getGlobalTimestamp())
 		{
 			// Shape updated
 			lnode.onShapeUpdate(light);

+ 2 - 2
src/scene/ModelNode.cpp

@@ -247,7 +247,7 @@ public:
 		updated = false;
 
 		MoveComponent& move = node.getComponent<MoveComponent>();
-		if(move.getTimestamp() == getGlobTimestamp())
+		if(move.getTimestamp() == node.getGlobalTimestamp())
 		{
 			ModelNode& mnode = static_cast<ModelNode&>(node);
 			mnode.onMoveComponentUpdate(move);
@@ -276,7 +276,7 @@ public:
 
 		BodyComponent& bodyc = node.getComponent<BodyComponent>();
 
-		if(bodyc.getTimestamp() == getGlobTimestamp())
+		if(bodyc.getTimestamp() == node.getGlobalTimestamp())
 		{
 			MoveComponent& move = node.getComponent<MoveComponent>();
 			move.setLocalTransform(bodyc.getTransform());

+ 4 - 3
src/scene/ParticleEmitter.cpp

@@ -249,7 +249,7 @@ public:
 		updated = false;
 
 		MoveComponent& move = node.getComponent<MoveComponent>();
-		if(move.getTimestamp() == getGlobTimestamp())
+		if(move.getTimestamp() == node.getGlobalTimestamp())
 		{
 			static_cast<ParticleEmitter&>(node).onMoveComponentUpdate(move);
 		}
@@ -387,7 +387,8 @@ Error ParticleEmitter::buildRendering(RenderingBuildData& data)
 	{
 		ppline.bind(data.m_jobs);
 
-		PtrSize offset = (getGlobTimestamp() % 3) * (m_vertBuff.getSize() / 3);
+		PtrSize offset = 
+			(getGlobalTimestamp() % 3) * (m_vertBuff.getSize() / 3);
 
 		// Position
 		m_vertBuff.bindVertexBuffer(data.m_jobs, 
@@ -491,7 +492,7 @@ Error ParticleEmitter::frameUpdate(F32 prevUpdateTime, F32 crntTime)
 	m_aliveParticlesCount = 0;
 
 	F32* verts = (F32*)(m_vertBuffMapping 
-		+ (getGlobTimestamp() % 3) * (m_vertBuff.getSize() / 3));
+		+ (getGlobalTimestamp() % 3) * (m_vertBuff.getSize() / 3));
 	F32* verts_base = verts;
 	(void)verts_base;
 

+ 1 - 1
src/scene/PlayerNode.cpp

@@ -36,7 +36,7 @@ public:
 
 		F32 y = in.getMousePosition().y();
 		F32 x = in.getMousePosition().x();
-		if(playerc.getTimestamp() == getGlobTimestamp() 
+		if(playerc.getTimestamp() == node.getGlobalTimestamp() 
 			|| y != 0.0 
 			|| x != 0.0)
 		{

+ 7 - 1
src/scene/SceneComponent.cpp

@@ -8,6 +8,12 @@
 
 namespace anki {
 
+//==============================================================================
+Timestamp SceneComponent::getGlobalTimestamp() const
+{
+	return m_node->getGlobalTimestamp();
+}
+
 //==============================================================================
 Error SceneComponent::updateReal(SceneNode& node, F32 prevTime, F32 crntTime,
 	Bool& updated)
@@ -21,7 +27,7 @@ Error SceneComponent::updateReal(SceneNode& node, F32 prevTime, F32 crntTime,
 
 		if(!err)
 		{
-			m_timestamp = getGlobTimestamp();
+			m_timestamp = getGlobalTimestamp();
 		}
 	}
 

+ 5 - 2
src/scene/SceneGraph.cpp

@@ -103,10 +103,12 @@ Error SceneGraph::create(
 	U32 frameAllocatorSize,
 	Threadpool* threadpool, 
 	ResourceManager* resources,
-	Input* input)
+	Input* input,
+	const Timestamp* globalTimestamp)
 {
 	Error err = ErrorCode::NONE;
 
+	m_globalTimestamp = globalTimestamp;
 	m_threadpool = threadpool;
 	m_resources = resources;
 	m_objectsMarkedForDeletionCount.store(0);
@@ -249,6 +251,8 @@ Error SceneGraph::update(F32 prevUpdateTime, F32 crntTime, Renderer& renderer)
 
 	Error err = ErrorCode::NONE;
 
+	m_timestamp = *m_globalTimestamp;
+
 	ANKI_COUNTER_START_TIMER(SCENE_UPDATE_TIME);
 
 	//
@@ -294,7 +298,6 @@ Error SceneGraph::update(F32 prevUpdateTime, F32 crntTime, Renderer& renderer)
 	}
 
 	ANKI_COUNTER_STOP_TIMER_INC(SCENE_UPDATE_TIME);
-
 	return err;
 }
 

+ 6 - 0
src/scene/SceneNode.cpp

@@ -60,6 +60,12 @@ void SceneNode::setMarkedForDeletion()
 	(void)err;
 }
 
+//==============================================================================
+Timestamp SceneNode::getGlobalTimestamp() const
+{
+	return m_scene->getGlobalTimestamp();
+}
+
 //==============================================================================
 SceneAllocator<U8> SceneNode::getSceneAllocator() const
 {

+ 11 - 32
testapp/Main.cpp

@@ -244,7 +244,7 @@ Error init()
 		if(err) return err;
 
 		lightc = point->tryGetComponent<LightComponent>();
-		lightc->setRadius(3.0);
+		lightc->setRadius(0.01);
 		lightc->setDiffuseColor(Vec4(0.6));
 		lightc->setSpecularColor(Vec4(0.6, 0.6, 0.3, 1.0));
 
@@ -264,17 +264,15 @@ Error init()
 	}
 #endif
 
-	/*PhysicsPlayerController::Initializer initp;
-	auto player = scene._getPhysicsWorld().newPlayerController(initp);
-	player->moveToPosition(Vec4(5.0, 2.0, 0.0, 0.0));
-	player->setVelocity(0.0, 0.0, 0.0, Vec4(0.0, 0.0, -1.0, 0.0));*/
-
 #if 1
 	PlayerNode* pnode;
 	scene.newSceneNode<PlayerNode>("player", pnode, Vec4(1.0, 3.0, 0.0, 0.0));
 
 	pnode->addChild(cam);
 
+#endif
+
+#if 0
 	PhysicsCollisionShape::Initializer initc;
 	auto box = 
 		scene._getPhysicsWorld().newCollisionShape<PhysicsBox>(
@@ -282,7 +280,7 @@ Error init()
 
 	PhysicsBody::Initializer init;
 	init.m_shape = box;
-	init.m_startTrf = Transform(Vec4(0.0, -45, 0, 0), 
+	init.m_startTrf = Transform(Vec4(0.0, -15, 0, 0), 
 		Mat3x4(Axisang(toRad(0.0), Vec3(1, 0, 0))), 1.0);
 	scene._getPhysicsWorld().newBody<PhysicsBody>(init);
 #endif
@@ -460,38 +458,19 @@ Error mainLoopExtra(App& app, void*, Bool& quit)
 #endif
 
 #if 0
-	if(in.getKey(KeyCode::L) == 1)
-	{
-		try
-		{
-			ScriptManagerSingleton::get().evalString(
-R"(scene = SceneGraphSingleton.get()
-node = scene:tryFindSceneNode("horse")
-if Anki.userDataValid(node) == 1 then
-	print("valid")
-else 
-	print("invalid")
-end)");
-		}
-		catch(Exception& e)
-		{
-			ANKI_LOGE(e.what());
-		}
-	}
-#endif
-
-	/*if(in.getMousePosition() != Vec2(0.0))
+	if(in.getMousePosition() != Vec2(0.0))
 	{
 		F32 angY = -ang * in.getMousePosition().x() * mouseSensivity *
 			renderer.getAspectRatio();
 
 		mover->rotateLocalY(angY);
 		mover->rotateLocalX(ang * in.getMousePosition().y() * mouseSensivity);
-	}*/
+	}
+#endif
 
 	//execStdinScpripts();
 
-	if(getenv("PROFILE") && getGlobTimestamp() == 2000)
+	if(getenv("PROFILE") && app.getGlobalTimestamp() == 2000)
 	{
 		quit = true;
 		return err;
@@ -539,8 +518,8 @@ Error initSubsystems(int argc, char* argv[])
 	config.set("lodDistance", 20.0);
 	config.set("samples", 1);
 	config.set("tessellation", true);
-	config.set("tilesXCount", 16);
-	config.set("tilesYCount", 16);
+	config.set("tilesXCount", 60);
+	config.set("tilesYCount", 30);
 
 	//config.set("maxTextureSize", 256);