|
From: <axl...@us...> - 2009-03-15 22:18:11
|
Revision: 181
http://hgengine.svn.sourceforge.net/hgengine/?rev=181&view=rev
Author: axlecrusher
Date: 2009-03-15 22:17:56 +0000 (Sun, 15 Mar 2009)
Log Message:
-----------
update to semaphore and count VBO draw commands
Modified Paths:
--------------
Mercury2/src/MSemaphore.cpp
Mercury2/src/MSemaphore.h
Mercury2/src/Mercury2.cpp
Mercury2/src/MercuryVBO.cpp
Mercury2/src/MercuryVBO.h
Mercury2/src/RenderableNode.cpp
Modified: Mercury2/src/MSemaphore.cpp
===================================================================
--- Mercury2/src/MSemaphore.cpp 2009-03-15 20:46:54 UTC (rev 180)
+++ Mercury2/src/MSemaphore.cpp 2009-03-15 22:17:56 UTC (rev 181)
@@ -5,11 +5,16 @@
{
}
-unsigned long MSemaphore::ReadValue()
+unsigned long MSemaphore::Read()
{
return __sync_or_and_fetch(&m_counter, 0);
}
+unsigned long MSemaphore::ReadAndClear()
+{
+ return __sync_fetch_and_and(&m_counter, 0);
+}
+
unsigned long MSemaphore::Decrement()
{
return __sync_sub_and_fetch(&m_counter, 1);
Modified: Mercury2/src/MSemaphore.h
===================================================================
--- Mercury2/src/MSemaphore.h 2009-03-15 20:46:54 UTC (rev 180)
+++ Mercury2/src/MSemaphore.h 2009-03-15 22:17:56 UTC (rev 181)
@@ -6,7 +6,8 @@
public:
MSemaphore();
- unsigned long ReadValue();
+ unsigned long Read();
+ unsigned long ReadAndClear();
unsigned long Decrement();
unsigned long Increment();
Modified: Mercury2/src/Mercury2.cpp
===================================================================
--- Mercury2/src/Mercury2.cpp 2009-03-15 20:46:54 UTC (rev 180)
+++ Mercury2/src/Mercury2.cpp 2009-03-15 22:17:56 UTC (rev 181)
@@ -17,7 +17,7 @@
MSemaphore UpdateLoopGo;
void* UpdateThread(void* node)
{
- while( UpdateLoopGo.ReadValue() < 1 )
+ while( UpdateLoopGo.Read() < 1 )
{
MercuryNode* n = (MercuryNode*)node;
n->RecursiveUpdate(0.01f);
@@ -69,7 +69,8 @@
fpsTimer.Touch(timer);
if (fpsTimer.Age() > 1)
{
- printf("FPS: %f\n", m_count/fpsTimer.Age());
+ float batches = MercuryVBO::ResetBatchCount()/(float)m_count;
+ printf("FPS: %f, VBO batches %f\n", m_count/fpsTimer.Age(), batches);
m_count = 0;
fpsTimer = timer;
}
Modified: Mercury2/src/MercuryVBO.cpp
===================================================================
--- Mercury2/src/MercuryVBO.cpp 2009-03-15 20:46:54 UTC (rev 180)
+++ Mercury2/src/MercuryVBO.cpp 2009-03-15 22:17:56 UTC (rev 181)
@@ -50,6 +50,7 @@
}
glDrawRangeElements(GL_TRIANGLES, 0, m_indexData.Length()-1, m_indexData.Length(), GL_UNSIGNED_SHORT, NULL);
+ m_vboBatches.Increment();
m_lastVBOrendered = this;
@@ -88,6 +89,8 @@
}
void* MercuryVBO::m_lastVBOrendered = NULL;
+MSemaphore MercuryVBO::m_vboBatches;
+
/****************************************************************************
* Copyright (C) 2008 by Joshua Allen *
* *
Modified: Mercury2/src/MercuryVBO.h
===================================================================
--- Mercury2/src/MercuryVBO.h 2009-03-15 20:46:54 UTC (rev 180)
+++ Mercury2/src/MercuryVBO.h 2009-03-15 22:17:56 UTC (rev 181)
@@ -5,6 +5,8 @@
#include <AlignedBuffer.h>
#include <BoundingBox.h>
+#include <MSemaphore.h>
+
class MercuryVBO : public MercuryAsset
{
public:
@@ -15,6 +17,9 @@
void AllocateVertexSpace(unsigned int count);
void AllocateIndexSpace(unsigned int count);
+
+ static uint32_t BatchCount() { return m_vboBatches.Read(); }
+ static uint32_t ResetBatchCount() { return m_vboBatches.ReadAndClear(); }
private:
virtual void InitVBO();
@@ -27,6 +32,8 @@
AlignedBuffer<float> m_vertexData;
AlignedBuffer<uint16_t> m_indexData;
BoundingBox* m_boundingBox;
+
+ static MSemaphore m_vboBatches;
};
#endif
Modified: Mercury2/src/RenderableNode.cpp
===================================================================
--- Mercury2/src/RenderableNode.cpp 2009-03-15 20:46:54 UTC (rev 180)
+++ Mercury2/src/RenderableNode.cpp 2009-03-15 22:17:56 UTC (rev 181)
@@ -163,14 +163,14 @@
unsigned long RenderableNode::Spinlock( unsigned long value )
{
unsigned long waited = 0;
- while (m_semaphore.ReadValue() != value) ++waited;
+ while (m_semaphore.Read() != value) ++waited;
return waited;
}
unsigned long RenderableNode::SpinlockWait( unsigned long value, unsigned long usec )
{
unsigned long waited = 0;
- while (m_semaphore.ReadValue() != value)
+ while (m_semaphore.Read() != value)
{
// waited=true;
++waited;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|