Removed system.h and system.c (replaced by System class)
This commit is contained in:
parent
cd37d45e98
commit
ea25cdaa55
18 changed files with 77 additions and 104 deletions
|
@ -9,7 +9,7 @@
|
|||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include "tools.h"
|
||||
#include "rendering/system.h"
|
||||
#include "System.h"
|
||||
|
||||
/*************** PreviewChunk ***************/
|
||||
class PreviewChunk
|
||||
|
@ -168,7 +168,7 @@ void PreviewDrawingThread::run()
|
|||
/*************** PreviewDrawingManager ***************/
|
||||
PreviewDrawingManager::PreviewDrawingManager()
|
||||
{
|
||||
_thread_count = systemGetCoreCount();
|
||||
_thread_count = System::getCoreCount();
|
||||
}
|
||||
|
||||
void PreviewDrawingManager::startThreads()
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "rendering/system.h"
|
||||
#include "System.h"
|
||||
#include "rendering/tools.h"
|
||||
#include "rendering/tools/cache.h"
|
||||
#include "rendering/tools/texture.h"
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
#include <string.h>
|
||||
#include "../tools.h"
|
||||
#include "../renderer.h"
|
||||
#include "../system.h"
|
||||
|
||||
static int _inited = 0;
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
#include <string.h>
|
||||
#include "../tools.h"
|
||||
#include "../renderer.h"
|
||||
#include "../system.h"
|
||||
|
||||
/******************** Fake ********************/
|
||||
static AtmosphereResult _fakeApplyAerialPerspective(Renderer* renderer, Vector3 location, Color base)
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
#include "tools/data.h"
|
||||
#include "system.h"
|
||||
#include "scenery.h"
|
||||
#include "render.h"
|
||||
#include "main.h"
|
||||
|
@ -12,7 +11,6 @@
|
|||
|
||||
void paysagesInit()
|
||||
{
|
||||
systemInit();
|
||||
if (!dataInit())
|
||||
{
|
||||
/* TODO Add error callback (for interface) */
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
|
||||
#include "renderer.h"
|
||||
#include "camera.h"
|
||||
#include "system.h"
|
||||
#include "PictureFile.h"
|
||||
#include "Thread.h"
|
||||
#include "Mutex.h"
|
||||
#include "System.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
#include "renderer.h"
|
||||
|
||||
#include "tools/lighting.h"
|
||||
#include "system.h"
|
||||
#include "System.h"
|
||||
#include "Thread.h"
|
||||
#include "render.h"
|
||||
#include "scenery.h"
|
||||
#include "tools.h"
|
||||
#include "Thread.h"
|
||||
|
||||
static RayCastingResult _RAYCASTING_NULL = {0};
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@ INCLUDEPATH += $$PWD/..
|
|||
|
||||
SOURCES += main.c \
|
||||
tools.c \
|
||||
system.c \
|
||||
scenery.c \
|
||||
renderer.c \
|
||||
render.c \
|
||||
|
@ -69,7 +68,6 @@ SOURCES += main.c \
|
|||
|
||||
HEADERS += \
|
||||
tools.h \
|
||||
system.h \
|
||||
scenery.h \
|
||||
renderer.h \
|
||||
render.h \
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
#include "rendering/tools/color.h"
|
||||
#include "rendering/tools/euclid.h"
|
||||
#include "rendering/render.h"
|
||||
#include "rendering/system.h"
|
||||
|
||||
static AtmosphereDefinition* _atmosphere;
|
||||
static CameraDefinition* _camera;
|
||||
|
|
|
@ -1,63 +0,0 @@
|
|||
#include "system.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifndef NDEBUG
|
||||
#define DEBUG_ONETHREAD 1
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
static int _core_count = 1;
|
||||
|
||||
static int _getCoreCount()
|
||||
{
|
||||
int core_count = 1;
|
||||
#ifdef WIN32
|
||||
DWORD processAffinityMask;
|
||||
DWORD systemAffinityMask;
|
||||
|
||||
if (GetProcessAffinityMask( GetCurrentProcess(),
|
||||
&processAffinityMask,
|
||||
&systemAffinityMask)){
|
||||
processAffinityMask = (processAffinityMask & 0x55555555)
|
||||
+ (processAffinityMask >> 1 & 0x55555555);
|
||||
processAffinityMask = (processAffinityMask & 0x33333333)
|
||||
+ (processAffinityMask >> 2 & 0x33333333);
|
||||
processAffinityMask = (processAffinityMask & 0x0f0f0f0f)
|
||||
+ (processAffinityMask >> 4 & 0x0f0f0f0f);
|
||||
processAffinityMask = (processAffinityMask & 0x00ff00ff)
|
||||
+ (processAffinityMask >> 8 & 0x00ff00ff);
|
||||
core_count = (processAffinityMask & 0x0000ffff)
|
||||
+ (processAffinityMask >>16 & 0x0000ffff);
|
||||
}
|
||||
#endif
|
||||
#ifdef _SC_NPROCESSORS_ONLN
|
||||
core_count = (int)sysconf(_SC_NPROCESSORS_ONLN);
|
||||
#endif
|
||||
#ifdef DEBUG_ONETHREAD
|
||||
core_count = 1;
|
||||
#endif
|
||||
return core_count;
|
||||
}
|
||||
|
||||
void systemInit()
|
||||
{
|
||||
_core_count = _getCoreCount();
|
||||
}
|
||||
|
||||
int systemGetCoreCount()
|
||||
{
|
||||
return _core_count;
|
||||
}
|
||||
|
||||
int systemGetFileSize(const char* path)
|
||||
{
|
||||
struct stat st;
|
||||
stat(path, &st);
|
||||
return st.st_size;
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
#ifndef _PAYSAGES_SYSTEM_H_
|
||||
#define _PAYSAGES_SYSTEM_H_
|
||||
|
||||
/* Library dependent features */
|
||||
|
||||
#include "rendering_global.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
RENDERINGSHARED_EXPORT void systemInit();
|
||||
RENDERINGSHARED_EXPORT int systemGetCoreCount();
|
||||
|
||||
RENDERINGSHARED_EXPORT int systemGetFileSize(const char* path);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -1,7 +1,8 @@
|
|||
#include "parallel.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include "../system.h"
|
||||
#include <stdlib.h>
|
||||
#include "System.h"
|
||||
#include "Thread.h"
|
||||
#include "Mutex.h"
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include "../system.h"
|
||||
#include "System.h"
|
||||
#include "PictureFile.h"
|
||||
|
||||
struct Texture2D
|
||||
|
|
27
src/system/System.cpp
Normal file
27
src/system/System.cpp
Normal file
|
@ -0,0 +1,27 @@
|
|||
#include "System.h"
|
||||
|
||||
#include <QThread>
|
||||
#include <QDebug>
|
||||
|
||||
static int core_count = -1;
|
||||
|
||||
int System::getCoreCount()
|
||||
{
|
||||
if (core_count < 0)
|
||||
{
|
||||
core_count = QThread::idealThreadCount();
|
||||
if (core_count <= 0)
|
||||
{
|
||||
qWarning() << "Can't find number of CPU cores, using only 1";
|
||||
core_count = 1;
|
||||
}
|
||||
}
|
||||
return core_count;
|
||||
}
|
||||
|
||||
// Transitional C-API
|
||||
|
||||
int systemGetCoreCount()
|
||||
{
|
||||
return System::getCoreCount();
|
||||
}
|
35
src/system/System.h
Normal file
35
src/system/System.h
Normal file
|
@ -0,0 +1,35 @@
|
|||
#ifndef SYSTEM_H
|
||||
#define SYSTEM_H
|
||||
|
||||
#include "system_global.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
namespace paysages
|
||||
{
|
||||
namespace system
|
||||
{
|
||||
|
||||
/*!
|
||||
* \brief Access to system info
|
||||
*/
|
||||
class SYSTEMSHARED_EXPORT System
|
||||
{
|
||||
public:
|
||||
static int getCoreCount();
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Transitional C-API
|
||||
int systemGetCoreCount();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // SYSTEM_H
|
|
@ -15,13 +15,15 @@ CONFIG(release, debug|release): DEFINES += NDEBUG
|
|||
SOURCES += \
|
||||
PictureFile.cpp \
|
||||
Thread.cpp \
|
||||
Mutex.cpp
|
||||
Mutex.cpp \
|
||||
System.cpp
|
||||
|
||||
HEADERS += \
|
||||
system_global.h \
|
||||
PictureFile.h \
|
||||
Thread.h \
|
||||
Mutex.h
|
||||
Mutex.h \
|
||||
System.h
|
||||
|
||||
unix:!symbian {
|
||||
maemo5 {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
#include "rendering/main.h"
|
||||
#include "rendering/system.h"
|
||||
#include "System.h"
|
||||
|
||||
int tests_cpu_count;
|
||||
extern void test_euclid_case(Suite* s);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "testing/common.h"
|
||||
#include "rendering/system.h"
|
||||
#include "System.h"
|
||||
#include "rendering/scenery.h"
|
||||
|
||||
#define OUTPUT_WIDTH 400
|
||||
|
|
Loading…
Reference in a new issue