mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-22 12:59:07 -06:00
Moving more code into performance files
This commit is contained in:
@@ -97,9 +97,12 @@ public:
|
||||
void takeScreenshot();
|
||||
void toggleInfoText(bool b);
|
||||
|
||||
// Performance measurements
|
||||
void setPerformanceMeasurements(bool performanceMeasurements);
|
||||
bool doesPerformanceMeasurements() const;
|
||||
|
||||
|
||||
|
||||
void serialize(SyncBuffer* syncBuffer);
|
||||
void deserialize(SyncBuffer* syncBuffer);
|
||||
|
||||
|
||||
@@ -30,8 +30,6 @@
|
||||
namespace openspace {
|
||||
namespace performance {
|
||||
|
||||
|
||||
|
||||
struct PerformanceLayout {
|
||||
static const int8_t Version = 0;
|
||||
static const int LengthName = 256;
|
||||
@@ -42,7 +40,7 @@ struct PerformanceLayout {
|
||||
|
||||
int32_t nEntries;
|
||||
|
||||
struct PerformanceLayoutEntry {
|
||||
struct SceneGraphPerformanceLayout {
|
||||
char name[LengthName];
|
||||
float renderTime[NumberValues];
|
||||
float updateRenderable[NumberValues];
|
||||
@@ -52,8 +50,21 @@ struct PerformanceLayout {
|
||||
int32_t currentUpdateRenderable;
|
||||
int32_t currentUpdateEphemeris;
|
||||
};
|
||||
SceneGraphPerformanceLayout sceneGraphEntries[MaxValues];
|
||||
|
||||
struct FunctionPerformanceLayout {
|
||||
char name[LengthName];
|
||||
float time[NumberValues];
|
||||
int32_t currentTime;
|
||||
};
|
||||
FunctionPerformanceLayout functionEntries[MaxValues];
|
||||
};
|
||||
|
||||
struct FunctionPerformanceHelper {
|
||||
FunctionPerformanceHelper();
|
||||
~FunctionPerformanceHelper();
|
||||
|
||||
|
||||
PerformanceLayoutEntry entries[MaxValues];
|
||||
};
|
||||
|
||||
} // namespace performance
|
||||
|
||||
@@ -726,13 +726,10 @@ bool RenderEngine::doesPerformanceMeasurements() const {
|
||||
void RenderEngine::storePerformanceMeasurements() {
|
||||
using namespace performance;
|
||||
|
||||
|
||||
const int nNodes = static_cast<int>(scene()->allSceneGraphNodes().size());
|
||||
int nNodes = static_cast<int>(scene()->allSceneGraphNodes().size());
|
||||
if (!_performanceMemory) {
|
||||
|
||||
// Compute the total size
|
||||
const int totalSize = sizeof(int8_t) + 4 * sizeof(int32_t) +
|
||||
PerformanceLayout::MaxValues * sizeof(PerformanceLayout::PerformanceLayoutEntry);
|
||||
const int totalSize = sizeof(PerformanceLayout);
|
||||
LINFO("Create shared memory of " << totalSize << " bytes");
|
||||
|
||||
try {
|
||||
@@ -746,11 +743,9 @@ void RenderEngine::storePerformanceMeasurements() {
|
||||
_performanceMemory = new ghoul::SharedMemory(PerformanceMeasurementSharedData);
|
||||
void* ptr = _performanceMemory->memory();
|
||||
|
||||
// Using the placement-new to create a PerformanceLayout in the shared memory
|
||||
PerformanceLayout* layout = new (ptr) PerformanceLayout(nNodes);
|
||||
|
||||
|
||||
memset(layout->entries, 0, PerformanceLayout::MaxValues * sizeof(PerformanceLayout::PerformanceLayoutEntry));
|
||||
|
||||
for (int i = 0; i < nNodes; ++i) {
|
||||
SceneGraphNode* node = scene()->allSceneGraphNodes()[i];
|
||||
|
||||
|
||||
@@ -24,13 +24,25 @@
|
||||
|
||||
#include <openspace/util/performancemeasurement.h>
|
||||
|
||||
#include <cstring>
|
||||
|
||||
namespace openspace {
|
||||
namespace performance {
|
||||
|
||||
PerformanceLayout::PerformanceLayout(int32_t nEntries)
|
||||
: nEntries(nEntries)
|
||||
{
|
||||
std::memset(
|
||||
sceneGraphEntries,
|
||||
0,
|
||||
MaxValues * sizeof(SceneGraphPerformanceLayout)
|
||||
);
|
||||
|
||||
std::memset(
|
||||
functionEntries,
|
||||
0,
|
||||
MaxValues * sizeof(FunctionPerformanceLayout)
|
||||
);
|
||||
}
|
||||
|
||||
} // namespace performance
|
||||
|
||||
Reference in New Issue
Block a user