瀏覽代碼

Nothing important

Panagiotis Christopoulos Charitos 13 年之前
父節點
當前提交
1e6778d8ac
共有 5 個文件被更改,包括 26 次插入13 次删除
  1. 1 1
      CMakeLists.txt
  2. 1 0
      include/anki/gl/BufferObject.h
  3. 2 1
      include/anki/renderer/Tiler.h
  4. 7 0
      src/gl/BufferObject.cpp
  5. 15 11
      src/renderer/Tiler.cpp

+ 1 - 1
CMakeLists.txt

@@ -74,7 +74,7 @@ MESSAGE("++ AnKi window backend: ${ANKI_WINDOW_BACKEND}")
 # Build type
 IF(CMAKE_BUILD_TYPE STREQUAL Debug)
 ELSE()
-	SET(FLAGS " -s -ffast-math ")
+	SET(FLAGS " -s -ffast-math -march=native ")
 
 	SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAGS}")
 	SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${FLAGS}")

+ 1 - 0
include/anki/gl/BufferObject.h

@@ -127,6 +127,7 @@ public:
 		return glId != 0;
 	}
 
+	/// Set the binding for this buffer
 	void setBinding(GLuint binding) const
 	{
 		ANKI_ASSERT(target == GL_TRANSFORM_FEEDBACK_BUFFER 

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

@@ -37,7 +37,8 @@ public:
 	/// nullptr then check all tiles and return the IDS if the tiles that the
 	/// cs is on
 	Bool test(const CollisionShape& cs,
-		Array<U32, TILES_X_COUNT * TILES_Y_COUNT>* tileIds = nullptr) const;
+		Array<U32, TILES_X_COUNT * TILES_Y_COUNT>* tileIds = nullptr,
+		const Bool skipNearPlaneCheck = false) const;
 
 private:
 	/// A screen tile

+ 7 - 0
src/gl/BufferObject.cpp

@@ -3,6 +3,9 @@
 #include "anki/gl/GlException.h"
 #include "anki/util/Exception.h"
 
+/// Instead of map/unmap use glBufferSubData() when writing to the whole buffer
+#define USE_BUFFER_DATA_ON_WRITE 1
+
 namespace anki {
 
 //==============================================================================
@@ -87,11 +90,15 @@ void BufferObject::write(void* buff, U32 offset, U32 size)
 	ANKI_ASSERT(offset + size <= sizeInBytes);
 	bind();
 
+#if USE_BUFFER_DATA_ON_WRITE
+	glBufferSubData(target, offset, sizeInBytes, buff);
+#else
 	void* mapped = map(offset, size, 
 		GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_RANGE_BIT);
 	
 	memcpy(mapped, buff, size);
 	unmap();
+#endif
 }
 
 } // end namespace anki

+ 15 - 11
src/renderer/Tiler.cpp

@@ -179,18 +179,13 @@ void Tiler::updateTiles(Camera& cam, const Texture& depthMap)
 	//
 	// Issue the min/max draw call
 	//
+
 	prog->bind();
 	GlStateSingleton::get().setViewport(0, 0, TILES_X_COUNT, TILES_Y_COUNT);
 	prog->findUniformVariable("depthMap").set(depthMap);
 
 	r->drawQuad();
 
-#if ANKI_GL == ANKI_GL_ES
-	// For Mali T6xx do a flush because the GPU will stay doing nothing until 
-	// read pixels later on where it will be forced to flush
-	glFlush();
-#endif
-
 	//
 	// Read pixels from the min/max pass
 	//
@@ -275,17 +270,24 @@ void Tiler::update2Planes(Camera& cam,
 
 //==============================================================================
 Bool Tiler::test(const CollisionShape& cs,
-	Array<U32, TILES_X_COUNT * TILES_Y_COUNT>* tileIds) const
+	Array<U32, TILES_X_COUNT * TILES_Y_COUNT>* tileIds,
+	const Bool skipNearPlaneCheck) const
 {
+	static_assert(Frustum::FP_NEAR == 0, "Frustum::FP_NEAR should be 0");
+
+	U startPlane = (skipNearPlaneCheck) ? 1 : 0;
+
 	if(tileIds)
 	{
+		// Check all tiles
+
 		U32* ip = &(*tileIds)[0];
 		for(U i = 0; i < tiles1d.getSize(); i++)
 		{
 			Bool inside = true;
-			for(const Plane& plane : tiles1d[i].planesWSpace)
+			for(U j = startPlane; j < Frustum::FP_COUNT; j++)
 			{
-				if(cs.testPlane(plane) < 0.0)
+				if(cs.testPlane(tiles1d[i].planesWSpace[j]) < 0.0)
 				{
 					inside = false;
 					break;
@@ -302,12 +304,14 @@ Bool Tiler::test(const CollisionShape& cs,
 	}
 	else
 	{
+		// Check at least one
+
 		for(const Tile& tile : tiles1d)
 		{
 			Bool inside = true;
-			for(const Plane& plane : tile.planesWSpace)
+			for(U j = startPlane; j < Frustum::FP_COUNT; j++)
 			{
-				if(cs.testPlane(plane) < 0.0)
+				if(cs.testPlane(tile.planesWSpace[j]) < 0.0)
 				{
 					inside = false;
 					break;