Skip to content

Commit a14e151

Browse files
committed
Merge branch 'master' of https://github.com/hrydgard/ppsspp into VR
# Conflicts: # Core/Core.cpp # GPU/GLES/Framebuffer.cpp # GPU/GLES/ShaderManager.cpp # GPU/GLES/TextureCache.cpp # UI/NativeApp.cpp # Windows/EmuThread.cpp # Windows/GPU/WindowsGLContext.cpp # Windows/GPU/WindowsGLContext.h # unittest/UnitTest.cpp
2 parents b56a723 + f081229 commit a14e151

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+881
-635
lines changed

Common/Common.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@ class NonCopyable
120120
#define __chdir chdir
121121
#endif
122122

123-
#if defined __GNUC__
123+
#if !defined(__GNUC__) && (defined(_M_X64) || defined(_M_IX86))
124+
# define _M_SSE 0x402
125+
#else
124126
# if defined __SSE4_2__
125127
# define _M_SSE 0x402
126128
# elif defined __SSE4_1__
@@ -132,8 +134,6 @@ class NonCopyable
132134
# elif defined __SSE2__
133135
# define _M_SSE 0x200
134136
# endif
135-
#elif ((_MSC_VER >= 1500) || __INTEL_COMPILER) && !defined(_XBOX) // Visual Studio 2008
136-
# define _M_SSE 0x402
137137
#endif
138138

139139
#include "Swap.h"

Common/Common.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@
236236
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
237237
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
238238
</ClInclude>
239+
<ClInclude Include="GraphicsContext.h" />
239240
<ClInclude Include="KeyMap.h" />
240241
<ClInclude Include="Log.h" />
241242
<ClInclude Include="LogManager.h" />

Common/Common.vcxproj.filters

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
<ClInclude Include="GL\GLInterfaceBase.h">
5858
<Filter>GL</Filter>
5959
</ClInclude>
60+
<ClInclude Include="GraphicsContext.h" />
6061
</ItemGroup>
6162
<ItemGroup>
6263
<ClCompile Include="stdafx.cpp" />

Common/ConsoleListener.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#include "ConsoleListener.h" // Common
3434
#include "Atomics.h"
3535

36-
#if defined(_WIN32) && !defined(_XBOX)
36+
#if defined(USING_WIN_UI)
3737
const int LOG_PENDING_MAX = 120 * 10000;
3838
const int LOG_LATENCY_DELAY_MS = 20;
3939
const int LOG_SHUTDOWN_DELAY_MS = 250;
@@ -51,7 +51,7 @@ volatile u32 ConsoleListener::logPendingWritePos = 0;
5151

5252
ConsoleListener::ConsoleListener() : bHidden(true)
5353
{
54-
#if defined(_WIN32) && !defined(_XBOX)
54+
#if defined(USING_WIN_UI)
5555
hConsole = NULL;
5656
bUseColor = true;
5757

@@ -62,7 +62,7 @@ ConsoleListener::ConsoleListener() : bHidden(true)
6262
logPending = new char[LOG_PENDING_MAX];
6363
}
6464
++refCount;
65-
#elif defined(_XBOX)
65+
#elif defined(_WIN32)
6666
bUseColor = false;
6767
#else
6868
bUseColor = isatty(fileno(stdout));
@@ -104,7 +104,7 @@ bool WINAPI ConsoleHandler(DWORD msgType)
104104
// Name is the window title
105105
void ConsoleListener::Init(bool AutoOpen, int Width, int Height, const char *Title)
106106
{
107-
#if defined(_WIN32) && !defined(_XBOX)
107+
#if defined(USING_WIN_UI)
108108
openWidth_ = Width;
109109
openHeight_ = Height;
110110
title_ = ConvertUTF8ToWString(Title);
@@ -116,7 +116,7 @@ void ConsoleListener::Init(bool AutoOpen, int Width, int Height, const char *Tit
116116

117117
void ConsoleListener::Open()
118118
{
119-
#if defined(_WIN32) && !defined(_XBOX)
119+
#if defined(USING_WIN_UI)
120120
if (!GetConsoleWindow())
121121
{
122122
// Open the console window and create the window handle for GetStdHandle()
@@ -150,7 +150,7 @@ void ConsoleListener::Open()
150150

151151
void ConsoleListener::Show(bool bShow)
152152
{
153-
#if defined(_WIN32) && !defined(_XBOX)
153+
#if defined(USING_WIN_UI)
154154
if (bShow && bHidden)
155155
{
156156
if (!IsOpen())
@@ -169,15 +169,15 @@ void ConsoleListener::Show(bool bShow)
169169

170170
void ConsoleListener::UpdateHandle()
171171
{
172-
#if defined(_WIN32) && !defined(_XBOX)
172+
#if defined(USING_WIN_UI)
173173
hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
174174
#endif
175175
}
176176

177177
// Close the console window and close the eventual file handle
178178
void ConsoleListener::Close()
179179
{
180-
#if defined(_WIN32) && !defined(_XBOX)
180+
#if defined(USING_WIN_UI)
181181
if (hConsole == NULL)
182182
return;
183183

@@ -215,7 +215,7 @@ void ConsoleListener::Close()
215215

216216
bool ConsoleListener::IsOpen()
217217
{
218-
#if defined(_WIN32) && !defined(_XBOX)
218+
#if defined(USING_WIN_UI)
219219
return (hConsole != NULL);
220220
#else
221221
return true;
@@ -229,7 +229,7 @@ bool ConsoleListener::IsOpen()
229229
void ConsoleListener::BufferWidthHeight(int BufferWidth, int BufferHeight, int ScreenWidth, int ScreenHeight, bool BufferFirst)
230230
{
231231
_dbg_assert_msg_(COMMON, IsOpen(), "Don't call this before opening the console.");
232-
#if defined(_WIN32) && !defined(_XBOX)
232+
#if defined(USING_WIN_UI)
233233
BOOL SB, SW;
234234
if (BufferFirst)
235235
{
@@ -254,7 +254,7 @@ void ConsoleListener::BufferWidthHeight(int BufferWidth, int BufferHeight, int S
254254
void ConsoleListener::LetterSpace(int Width, int Height)
255255
{
256256
_dbg_assert_msg_(COMMON, IsOpen(), "Don't call this before opening the console.");
257-
#if defined(_WIN32) && !defined(_XBOX)
257+
#if defined(USING_WIN_UI)
258258
// Get console info
259259
CONSOLE_SCREEN_BUFFER_INFO ConInfo;
260260
GetConsoleScreenBufferInfo(hConsole, &ConInfo);
@@ -280,7 +280,7 @@ void ConsoleListener::LetterSpace(int Width, int Height)
280280
#endif
281281
}
282282

283-
#if defined(_WIN32) && !defined(_XBOX)
283+
#if defined(USING_WIN_UI)
284284
COORD ConsoleListener::GetCoordinates(int BytesRead, int BufferWidth)
285285
{
286286
COORD Ret = {0, 0};
@@ -505,7 +505,7 @@ void ConsoleListener::WriteToConsole(LogTypes::LOG_LEVELS Level, const char *Tex
505505
void ConsoleListener::PixelSpace(int Left, int Top, int Width, int Height, bool Resize)
506506
{
507507
_dbg_assert_msg_(COMMON, IsOpen(), "Don't call this before opening the console.");
508-
#if defined(_WIN32) && !defined(_XBOX)
508+
#if defined(USING_WIN_UI)
509509
// Check size
510510
if (Width < 8 || Height < 12) return;
511511

@@ -589,7 +589,7 @@ void ConsoleListener::PixelSpace(int Left, int Top, int Width, int Height, bool
589589

590590
void ConsoleListener::Log(LogTypes::LOG_LEVELS Level, const char *Text)
591591
{
592-
#if defined(_WIN32) && !defined(_XBOX)
592+
#if defined(USING_WIN_UI)
593593
if (hThread == NULL && IsOpen())
594594
WriteToConsole(Level, Text, strlen(Text));
595595
else
@@ -623,7 +623,7 @@ void ConsoleListener::Log(LogTypes::LOG_LEVELS Level, const char *Text)
623623
void ConsoleListener::ClearScreen(bool Cursor)
624624
{
625625
_dbg_assert_msg_(COMMON, IsOpen(), "Don't call this before opening the console.");
626-
#if defined(_WIN32) && !defined(_XBOX)
626+
#if defined(USING_WIN_UI)
627627
COORD coordScreen = { 0, 0 };
628628
DWORD cCharsWritten;
629629
CONSOLE_SCREEN_BUFFER_INFO csbi;

Common/ConsoleListener.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class ConsoleListener : public LogListener {
3636
void LetterSpace(int Width, int Height);
3737
void BufferWidthHeight(int BufferWidth, int BufferHeight, int ScreenWidth, int ScreenHeight, bool BufferFirst);
3838
void PixelSpace(int Left, int Top, int Width, int Height, bool);
39-
#if defined(_WIN32) && !defined(_XBOX)
39+
#if defined(USING_WIN_UI)
4040
COORD GetCoordinates(int BytesRead, int BufferWidth);
4141
#endif
4242
void Log(LogTypes::LOG_LEVELS, const char *Text);
@@ -45,7 +45,7 @@ class ConsoleListener : public LogListener {
4545
void Show(bool bShow);
4646
bool Hidden() const { return bHidden; }
4747
private:
48-
#if defined(_WIN32) && !defined(_XBOX)
48+
#if defined(USING_WIN_UI)
4949
HWND hWnd;
5050
HANDLE hConsole;
5151

Common/GraphicsContext.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#pragma once
2+
3+
#include <string>
4+
5+
#include "thin3d/thin3d.h"
6+
7+
// Init is done differently on each platform, and done close to the creation, so it's
8+
// expected to be implemented by subclasses.
9+
class GraphicsContext {
10+
public:
11+
virtual ~GraphicsContext() {}
12+
13+
virtual void Shutdown() = 0;
14+
virtual void SwapInterval(int interval) = 0;
15+
16+
virtual void SwapBuffers() = 0;
17+
18+
// Used during window resize. Must be called from the window thread,
19+
// not the rendering thread or CPU thread.
20+
virtual void Pause() {}
21+
virtual void Resume() {}
22+
23+
virtual void Resize() = 0;
24+
25+
virtual Thin3DContext *CreateThin3DContext() = 0;
26+
};
27+
28+
class DummyGraphicsContext : public GraphicsContext {
29+
public:
30+
void Shutdown() override {}
31+
void SwapInterval(int interval) override {}
32+
void SwapBuffers() override {}
33+
void Resize() override {}
34+
35+
Thin3DContext *CreateThin3DContext() override { return nullptr; }
36+
};

Common/KeyMap.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
#if defined(SDL)
1919
#include <SDL_keyboard.h>
20-
#elif defined(_WIN32) && !defined(_XBOX)
21-
#include <windows.h>
20+
#elif defined(USING_WIN_UI)
21+
#include "CommonWindows.h"
2222
#endif
2323
#include <set>
2424

@@ -377,7 +377,7 @@ void SetDefaultKeyMap(DefaultMaps dmap, bool replace) {
377377
azerty = true;
378378
else if (q == 'q' && w == 'w' && y == 'z')
379379
qwertz = true;
380-
#elif defined(_WIN32) && !defined(_XBOX)
380+
#elif defined(USING_WIN_UI)
381381
HKL localeId = GetKeyboardLayout(0);
382382
// TODO: Is this list complete enough?
383383
switch ((int)(intptr_t)localeId & 0xFFFF) {

Common/LogManager.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ LogManager::LogManager() {
119119
#if !(defined(MOBILE_DEVICE) || defined(_XBOX)) || defined(_DEBUG)
120120
log_[i]->AddListener(fileLog_);
121121
log_[i]->AddListener(consoleLog_);
122-
#if defined(_MSC_VER) && !defined(_XBOX)
122+
#if defined(_MSC_VER) && defined(USING_WIN_UI)
123123
if (IsDebuggerPresent() && debuggerLog_ != NULL && LOG_MSC_OUTPUTDEBUG)
124124
log_[i]->AddListener(debuggerLog_);
125125
#endif
@@ -134,7 +134,7 @@ LogManager::~LogManager() {
134134
if (fileLog_ != NULL)
135135
logManager_->RemoveListener((LogTypes::LOG_TYPE)i, fileLog_);
136136
logManager_->RemoveListener((LogTypes::LOG_TYPE)i, consoleLog_);
137-
#ifdef _MSC_VER
137+
#if defined(_MSC_VER) && defined(USING_WIN_UI)
138138
logManager_->RemoveListener((LogTypes::LOG_TYPE)i, debuggerLog_);
139139
#endif
140140
#endif

Common/MemoryUtil.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,12 @@ void *AllocateExecutableMemory(size_t size, bool exec) {
177177
else if (exec && (uintptr_t)map_hint <= 0xFFFFFFFF) {
178178
// Round up if we're below 32-bit mark, probably allocating sequentially.
179179
map_hint += round_page(size);
180+
181+
// If we moved ahead too far, skip backwards and recalculate.
182+
// When we free, we keep moving forward and eventually move too far.
183+
if ((uintptr_t)map_hint - (uintptr_t) &hint_location >= 0x70000000) {
184+
map_hint = 0;
185+
}
180186
}
181187
#endif
182188

Common/MsgHandler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ bool MsgAlert(bool yes_no, int Style, const char* format, ...)
7070
// Default non library dependent panic alert
7171
bool MsgHandler(const char* caption, const char* text, bool yes_no, int Style)
7272
{
73-
#if defined(_WIN32) && !defined(_XBOX)
73+
#if defined(USING_WIN_UI)
7474
int STYLE = MB_ICONINFORMATION;
7575
if (Style == QUESTION) STYLE = MB_ICONQUESTION;
7676
if (Style == WARNING) STYLE = MB_ICONWARNING;

Common/Timer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,14 @@ std::string Timer::GetTimeElapsedFormatted() const
153153
// Get current time
154154
void Timer::IncreaseResolution()
155155
{
156-
#if defined(_WIN32) && !defined(_XBOX)
156+
#if defined(USING_WIN_UI)
157157
timeBeginPeriod(1);
158158
#endif
159159
}
160160

161161
void Timer::RestoreResolution()
162162
{
163-
#if defined(_WIN32) && !defined(_XBOX)
163+
#if defined(USING_WIN_UI)
164164
timeEndPeriod(1);
165165
#endif
166166
}

Core/Compatibility.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,4 @@ void Compatibility::Clear() {
4242
void Compatibility::LoadIniSection(IniFile &iniFile, std::string section) {
4343
iniFile.Get(section.c_str(), "NoDepthRounding", &flags_.NoDepthRounding, flags_.NoDepthRounding);
4444
iniFile.Get(section.c_str(), "PixelDepthRounding", &flags_.PixelDepthRounding, flags_.PixelDepthRounding);
45-
iniFile.Get(section.c_str(), "DepthRangeHack", &flags_.DepthRangeHack, flags_.DepthRangeHack);
4645
}

Core/Compatibility.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
struct CompatFlags {
4848
bool NoDepthRounding;
4949
bool PixelDepthRounding;
50-
bool DepthRangeHack;
5150
};
5251

5352
class IniFile;

0 commit comments

Comments
 (0)