mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 15:33:10 +02:00
more render pipeline optimizations
This commit is contained in:
parent
fcce4753c9
commit
771c604121
4 changed files with 36 additions and 10 deletions
|
@ -101,6 +101,11 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) {
|
|||
double start = usecTimestampNow();
|
||||
// ask the VoxelTree to read the bitstream into the tree
|
||||
_tree->readBitstreamToTree(voxelData, numBytes - 1);
|
||||
if (_renderWarningsOn && _tree->getNodesChangedFromBitstream()) {
|
||||
printLog("readBitstreamToTree()... getNodesChangedFromBitstream=%ld _tree->isDirty()=%s \n",
|
||||
_tree->getNodesChangedFromBitstream(), (_tree->isDirty() ? "yes" : "no") );
|
||||
}
|
||||
|
||||
double end = usecTimestampNow();
|
||||
double elapsedmsec = (end - start)/1000.0;
|
||||
if (_renderWarningsOn && elapsedmsec > 1) {
|
||||
|
@ -178,7 +183,7 @@ void VoxelSystem::setupNewVoxelsForDrawing() {
|
|||
|
||||
void VoxelSystem::copyWrittenDataToReadArrays() {
|
||||
double start = usecTimestampNow();
|
||||
if (_voxelsDirty) {
|
||||
if (_voxelsDirty && _voxelsUpdated) {
|
||||
// lock on the buffer write lock so we can't modify the data when the GPU is reading it
|
||||
pthread_mutex_lock(&_bufferWriteLock);
|
||||
int bytesOfVertices = (_voxelsInArrays * VERTEX_POINTS_PER_VOXEL) * sizeof(GLfloat);
|
||||
|
|
|
@ -125,9 +125,9 @@ void VoxelNode::setFalseColor(colorPart red, colorPart green, colorPart blue) {
|
|||
_currentColor[1] = green;
|
||||
_currentColor[2] = blue;
|
||||
_currentColor[3] = 1; // XXXBHG - False colors are always considered set
|
||||
if (_shouldRender) {
|
||||
//if (_shouldRender) {
|
||||
_isDirty = true;
|
||||
}
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -138,9 +138,9 @@ void VoxelNode::setFalseColored(bool isFalseColored) {
|
|||
memcpy(&_currentColor,&_trueColor,sizeof(nodeColor));
|
||||
}
|
||||
_falseColored = isFalseColored;
|
||||
if (_shouldRender) {
|
||||
//if (_shouldRender) {
|
||||
_isDirty = true;
|
||||
}
|
||||
//}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -153,9 +153,9 @@ void VoxelNode::setColor(const nodeColor& color) {
|
|||
if (!_falseColored) {
|
||||
memcpy(&_currentColor,&color,sizeof(nodeColor));
|
||||
}
|
||||
if (_shouldRender) {
|
||||
//if (_shouldRender) {
|
||||
_isDirty = true;
|
||||
}
|
||||
//}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -132,6 +132,7 @@ int VoxelTree::readNodeData(VoxelNode* destinationNode,
|
|||
destinationNode->addChildAtIndex(i);
|
||||
if (destinationNode->isDirty()) {
|
||||
_isDirty = true;
|
||||
_nodesChangedFromBitstream++;
|
||||
}
|
||||
voxelsCreated++;
|
||||
voxelsCreatedStats.updateAverage(1);
|
||||
|
@ -141,9 +142,14 @@ int VoxelTree::readNodeData(VoxelNode* destinationNode,
|
|||
nodeColor newColor;
|
||||
memcpy(newColor, nodeData + bytesRead, 3);
|
||||
newColor[3] = 1;
|
||||
bool nodeWasDirty = destinationNode->children[i]->isDirty();
|
||||
destinationNode->children[i]->setColor(newColor);
|
||||
if (destinationNode->children[i]->isDirty()) {
|
||||
bool nodeIsDirty = destinationNode->children[i]->isDirty();
|
||||
if (nodeIsDirty) {
|
||||
_isDirty = true;
|
||||
}
|
||||
if (!nodeWasDirty && nodeIsDirty) {
|
||||
_nodesChangedFromBitstream++;
|
||||
}
|
||||
this->voxelsColored++;
|
||||
this->voxelsColoredStats.updateAverage(1);
|
||||
|
@ -152,10 +158,15 @@ int VoxelTree::readNodeData(VoxelNode* destinationNode,
|
|||
}
|
||||
}
|
||||
// average node's color based on color of children
|
||||
bool nodeWasDirty = destinationNode->isDirty();
|
||||
destinationNode->setColorFromAverageOfChildren();
|
||||
if (destinationNode->isDirty()) {
|
||||
bool nodeIsDirty = destinationNode->isDirty();
|
||||
if (nodeIsDirty) {
|
||||
_isDirty = true;
|
||||
}
|
||||
if (!nodeWasDirty && nodeIsDirty) {
|
||||
_nodesChangedFromBitstream++;
|
||||
}
|
||||
|
||||
// give this destination node the child mask from the packet
|
||||
unsigned char childMask = *(nodeData + bytesRead);
|
||||
|
@ -169,10 +180,15 @@ int VoxelTree::readNodeData(VoxelNode* destinationNode,
|
|||
if (oneAtBit(childMask, childIndex)) {
|
||||
if (!destinationNode->children[childIndex]) {
|
||||
// add a child at that index, if it doesn't exist
|
||||
bool nodeWasDirty = destinationNode->isDirty();
|
||||
destinationNode->addChildAtIndex(childIndex);
|
||||
if (destinationNode->isDirty()) {
|
||||
bool nodeIsDirty = destinationNode->isDirty();
|
||||
if (nodeIsDirty) {
|
||||
_isDirty = true;
|
||||
}
|
||||
if (!nodeWasDirty && nodeIsDirty) {
|
||||
_nodesChangedFromBitstream++;
|
||||
}
|
||||
this->voxelsCreated++;
|
||||
this->voxelsCreatedStats.updateAverage(this->voxelsCreated);
|
||||
}
|
||||
|
@ -192,6 +208,8 @@ int VoxelTree::readNodeData(VoxelNode* destinationNode,
|
|||
void VoxelTree::readBitstreamToTree(unsigned char * bitstream, int bufferSizeBytes) {
|
||||
int bytesRead = 0;
|
||||
unsigned char* bitstreamAt = bitstream;
|
||||
|
||||
_nodesChangedFromBitstream = 0;
|
||||
|
||||
// Keep looping through the buffer calling readNodeData() this allows us to pack multiple root-relative Octal codes
|
||||
// into a single network packet. readNodeData() basically goes down a tree from the root, and fills things in from there
|
||||
|
@ -208,6 +226,7 @@ void VoxelTree::readBitstreamToTree(unsigned char * bitstream, int bufferSizeByt
|
|||
bitstreamRootNode = createMissingNode(rootNode, (unsigned char*) bitstreamAt);
|
||||
if (bitstreamRootNode->isDirty()) {
|
||||
_isDirty = true;
|
||||
_nodesChangedFromBitstream++;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -57,6 +57,7 @@ public:
|
|||
|
||||
bool isDirty() const { return _isDirty; };
|
||||
void clearDirtyBit() { _isDirty = false; };
|
||||
unsigned long int getNodesChangedFromBitstream() const { return _nodesChangedFromBitstream; };
|
||||
|
||||
private:
|
||||
int encodeTreeBitstreamRecursion(int maxEncodeLevel, int& currentEncodeLevel,
|
||||
|
@ -73,6 +74,7 @@ private:
|
|||
int readNodeData(VoxelNode *destinationNode, unsigned char* nodeData, int bufferSizeBytes);
|
||||
|
||||
bool _isDirty;
|
||||
unsigned long int _nodesChangedFromBitstream;
|
||||
};
|
||||
|
||||
int boundaryDistanceForRenderLevel(unsigned int renderLevel);
|
||||
|
|
Loading…
Reference in a new issue