Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
#if defined(_WIN32)

#if defined(_DEBUG)
//#include <float.h>
//unsigned int fp_control_state = _controlfp(_EM_INEXACT, _MCW_EM);
#endif

#include "Headers/PlatformDefines.h"
#include <iostream>
#if defined(USE_VLD)
#include <vld.h>
#endif
#include <direct.h>

// We are actually importing GL specific libraries in code mainly for
// maintenance reasons
// We can easily adjust them as needed. Same thing with PhysX libs
#pragma comment(lib, "opengl32.lib")
#pragma comment(lib, "SDL2.lib")
#pragma comment(lib, "OpenAL32.lib")
#pragma comment(lib, "SDL2_mixer.lib")
#pragma comment(lib, "Winmm.lib")
#pragma comment(lib, "OpenCL.lib")

#ifdef _DEBUG
#pragma comment(lib, "DbgHelp.lib")

#pragma comment(lib, "glbindingd.lib")
#pragma comment(lib, "OIS_static_d.lib")
#pragma comment(lib, "assimp_d.lib")
#pragma comment(lib, "IL_d.lib")
#pragma comment(lib, "libpng_d.lib")
#pragma comment(lib, "jpeg_d.lib")
#pragma comment(lib, "libmng_d.lib")
#pragma comment(lib, "libtiff_d.lib")
#pragma comment(lib, "freetype_d.lib")
#pragma comment(lib, "zlib_d.lib")
#pragma comment(lib, "SILLY_d.lib")
#pragma comment(lib, "pcre_d.lib")
#pragma comment(lib, "expat_d.lib")

#pragma comment(lib, "CEGUIOpenGLRenderer-0_Static_d.lib")
#pragma comment(lib, "CEGUIBase-0_Static_d.lib")
#pragma comment(lib, "CEGUISILLYImageCodec_Static_d.lib")
#pragma comment(lib, "CEGUICoreWindowRendererSet_Static_d.lib")
#pragma comment(lib, "CEGUIExpatParser_Static_d.lib")

#pragma comment(lib, "PhysXProfileSDKDEBUG.lib")
#pragma comment(lib, "PhysX3CookingDEBUG_x64.lib")
#pragma comment(lib, "PhysX3DEBUG_x64.lib")
#pragma comment(lib, "PhysX3CommonDEBUG_x64.lib")
#pragma comment(lib, "PhysX3ExtensionsDEBUG.lib")
#pragma comment(lib, "PhysXVisualDebuggerSDKDEBUG.lib")

#else  //_DEBUG
#pragma comment(lib, "glbinding.lib")
#pragma comment(lib, "OIS_static.lib")
#pragma comment(lib, "assimp.lib")
#pragma comment(lib, "IL.lib")
#pragma comment(lib, "libpng.lib")
#pragma comment(lib, "jpeg.lib")
#pragma comment(lib, "libmng.lib")
#pragma comment(lib, "libtiff.lib")
#pragma comment(lib, "freetype.lib")
#pragma comment(lib, "zlib.lib")
#pragma comment(lib, "SILLY.lib")
#pragma comment(lib, "pcre.lib")
#pragma comment(lib, "expat.lib")
#pragma comment(lib, "CEGUIOpenGLRenderer-0_Static.lib")
#pragma comment(lib, "CEGUIBase-0_Static.lib")
#pragma comment(lib, "CEGUISILLYImageCodec_Static.lib")
#pragma comment(lib, "CEGUICoreWindowRendererSet_Static.lib")
#pragma comment(lib, "CEGUIExpatParser_Static.lib")

#if defined(_PROFILE)
    #pragma comment(lib, "PhysXProfileSDKCHECKED.lib")
    #pragma comment(lib, "PhysX3CookingCHECKED_x64.lib")
    #pragma comment(lib, "PhysX3CHECKED_x64.lib")
    #pragma comment(lib, "PhysX3CommonCHECKED_x64.lib")
    #pragma comment(lib, "PhysX3ExtensionsCHECKED.lib")
    #pragma comment(lib, "PhysXVisualDebuggerSDKCHECKED.lib")
#else
    #pragma comment(lib, "PhysXProfileSDK.lib")
    #pragma comment(lib, "PhysX3Cooking_x64.lib")
    #pragma comment(lib, "PhysX3_x64.lib")
    #pragma comment(lib, "PhysX3Common_x64.lib")
    #pragma comment(lib, "PhysX3Extensions.lib")
    #pragma comment(lib, "PhysXVisualDebuggerSDK.lib")
#endif

#endif  //_DEBUG

#ifdef WIN32_LEAN_AND_MEAN
#undef WIN32_LEAN_AND_MEAN
// SDL redefines WIN32_LEAN_AND_MEAN
#include <SDL_syswm.h>
#endif

#ifdef FORCE_HIGHPERFORMANCE_GPU
extern "C" {
    _declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
    _declspec(dllexport) DWORD AmdPowerXpressRequestHighPerformance = 0x00000001;
}

#endif

void* malloc_aligned(const size_t size, size_t alignment) {
    return _aligned_malloc(size, alignment);
}

void  malloc_free(void*& ptr) {
	_aligned_free(ptr);
}

LRESULT DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
    return FALSE;
}

namespace Divide {
    //https://msdn.microsoft.com/en-us/library/windows/desktop/ms679360%28v=vs.85%29.aspx
    static CHAR * getLastErrorText(CHAR *pBuf, LONG bufSize) {
        DWORD retSize;
        LPTSTR pTemp = NULL;

        if (bufSize < 16) {
            if (bufSize > 0) {
                pBuf[0] = '\0';
            }
            return(pBuf);
        }

        retSize = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
                                FORMAT_MESSAGE_FROM_SYSTEM |
                                FORMAT_MESSAGE_ARGUMENT_ARRAY,
                                NULL,
                                GetLastError(),
                                LANG_NEUTRAL,
                                (LPTSTR)&pTemp,
                                0,
                                NULL);

        if (!retSize || pTemp == NULL) {
            pBuf[0] = '\0';
        } else {
            pTemp[strlen(pTemp) - 2] = '\0'; //remove cr and newline character
            sprintf(pBuf, "%0.*s (0x%x)", bufSize - 16, pTemp, GetLastError());
            LocalFree((HLOCAL)pTemp);
        }
        return(pBuf);
    }

    void getWindowHandle(void* window, SysInfo& info) {
        SDL_SysWMinfo wmInfo;
        SDL_VERSION(&wmInfo.version);
        SDL_GetWindowWMInfo(static_cast<SDL_Window*>(window), &wmInfo);
        info._windowHandle = wmInfo.info.win.window;
    }

    bool PlatformInit() {
        return PlatformPostInit();
    }

    bool PlatformClose() {
        return true;
    }

    bool CheckMemory(const U32 physicalRAMNeeded, SysInfo& info) {
        MEMORYSTATUSEX status; 
        status.dwLength = sizeof(status);
        BOOL infoStatus = GlobalMemoryStatusEx(&status);
        if (infoStatus != FALSE) {
            info._availableRam = status.ullAvailPhys;
            return info._availableRam > physicalRAMNeeded;
        } else {
            CHAR msgText[256];
            getLastErrorText(msgText,sizeof(msgText));
            std::cerr << msgText << std::endl;
        }
        return false;
    }


    const DWORD MS_VC_EXCEPTION = 0x406D1388;

#pragma pack(push,8)
    typedef struct tagTHREADNAME_INFO
    {
        DWORD dwType; // Must be 0x1000.
        LPCSTR szName; // Pointer to name (in user addr space).
        DWORD dwThreadID; // Thread ID (-1=caller thread).
        DWORD dwFlags; // Reserved for future use, must be zero.
    } THREADNAME_INFO;
#pragma pack(pop)

    void setThreadName(U32 threadID, const char* threadName) {
        // DWORD dwThreadID = ::GetThreadId( static_cast<HANDLE>( t.native_handle() ) );

        THREADNAME_INFO info;
        info.dwType = 0x1000;
        info.szName = threadName;
        info.dwThreadID = threadID;
        info.dwFlags = 0;

        __try
        {
            RaiseException(MS_VC_EXCEPTION, 0, sizeof(info) / sizeof(ULONG_PTR), (ULONG_PTR*)&info);
        }
        __except (EXCEPTION_EXECUTE_HANDLER)
        {
        }
    }

    void setThreadName(const char* threadName) {
        setThreadName(GetCurrentThreadId(), threadName);
    }

    void setThreadName(std::thread* thread, const char* threadName) {
        DWORD threadId = ::GetThreadId(static_cast<HANDLE>(thread->native_handle()));
        setThreadName(threadId, threadName);
    }

    bool createDirectory(const char* path) {
        return _mkdir(path) == 0;
    }

}; //namespace Divide

#endif //defined(_WIN32)

Commits for Divide-Framework/trunk/Source Code/Platform/PlatformDefinesWindows.cpp

Diff revisions: vs.
Revision Author Commited Message
832 Diff Diff IonutCava picture IonutCava Thu 26 Jan, 2017 17:23:11 +0000

[IonutCava]
- More path related work
- Initial code to centralize file I/O (does not compile yet)

816 Diff Diff IonutCava picture IonutCava Fri 13 Jan, 2017 17:05:20 +0000

[IonutCava]
- Allow per player scene state and input source
— Add SceneStatePerPlayer class
— Add device index to InputParams objects.
— ToDo: map players to devide indices

783 Diff Diff IonutCava picture IonutCava Fri 14 Oct, 2016 15:50:34 +0000

[IonutCava]
- More cleanup of the Frustum class
- Change random number generation system to use the C++11 <random> features. (default engine set to Mersenne Twister and using a uniform distribution as default)

768 Diff Diff IonutCava picture IonutCava Fri 09 Sep, 2016 14:38:51 +0000

[IonutCava]
- Refactored framework entry points (init, step, shutdown) to allow the addition of hot code reloading in the future

758 Diff Diff IonutCava picture IonutCava Tue 02 Aug, 2016 16:05:09 +0000

[IonutCava]
- Added a cross platform method of naming threads (helps with debugging)
- Reduced dependency on VAR.dvd_drawID in shaders.
- Work on Single/Multi thread toggle for GFX resource loading (crashes, bugs, etc)
- Fix a bug in TaskPool where task states were never actually updated properly
- Change threadpool implementation to use std::thread instead of boost::thread

750 Diff Diff IonutCava picture IonutCava Thu 07 Jul, 2016 16:02:03 +0000

[IonutCava]
- Static analysis based fixes and improvements

686 Diff Diff IonutCava picture IonutCava Thu 21 Apr, 2016 16:24:19 +0000

[IonutCava]
- Refactor the scene self-registering system to prevent linker related issues
- Add a SGNRelationshipCache class that can quickly verify if any 2 given nodes are related in any way
— This should speed up Octree updates by a lot

note: The template refactoring code has significantly slowed down performance for reasons yet unknown. Investigating.

660 Diff Diff IonutCava picture IonutCava Mon 21 Mar, 2016 17:11:19 +0000

[IonutCava]
- Finish Parent<->Children thread pool system
- Use new thread pool system for most multithreaded tasks in the engine: culling, sorting, light preparation, etc
- Add platform specific init/close calls at the start and end of the main function for future use

636 Diff Diff IonutCava picture IonutCava Fri 29 Jan, 2016 17:07:16 +0000

[IonutCava]
- Octree implementation updates (still not 100% functional)

540 IonutCava picture IonutCava Wed 28 Oct, 2015 19:06:28 +0000

[IonutCava]
- Remove the “Platform” folder from the Platform project as the name is redundant. Move files one level up