Fix build to support MSVC (partially)
Bug: 141411491
TODO: Build the rest of the tests.
Change-Id: I585204494df9ce99e80e2ddb6e019772ced9f7eb
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5de7652..cb5eb57 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,14 +1,22 @@
project(gfx-streaming-kit)
cmake_minimum_required(VERSION 3.11)
+
+if (WIN32)
+ add_definitions("-DUNICODE -D_UNICODE -DNOMINMAX -DEMUGL_BUILD -DVK_USE_PLATFORM_WIN32_KHR -DBUILDING_EMUGL_COMMON_SHARED")
+endif()
+
find_package(Threads)
include(ExternalProject)
enable_testing()
-set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
+# set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/distribution)
-SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3 -O3")
+if (WIN32)
+else()
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3 -O3")
+endif()
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_C_STANDARD 11)
@@ -44,7 +52,9 @@
# Fake Android guest#########################3##################################
-add_subdirectory(fake-android-guest)
+if (NOT WIN32)
+ add_subdirectory(fake-android-guest)
+endif()
# Frontends#####################################################################
diff --git a/base/CMakeLists.txt b/base/CMakeLists.txt
index 8c8806d..d92b779 100644
--- a/base/CMakeLists.txt
+++ b/base/CMakeLists.txt
@@ -1,5 +1,4 @@
if (WIN32)
- add_subdirectory(msvc-posix-compat)
endif()
set(gfxstream-base-common-sources
@@ -28,6 +27,7 @@
SharedMemory_posix.cpp
Thread_pthread.cpp)
set(gfxstream-base-windows-sources
+ msvc.cpp
SharedMemory_win32.cpp
Thread_win32.cpp
Win32UnicodeString.cpp)
diff --git a/base/ConditionVariable.h b/base/ConditionVariable.h
index 3094a8e..9a53308 100644
--- a/base/ConditionVariable.h
+++ b/base/ConditionVariable.h
@@ -16,6 +16,10 @@
#include "base/Compiler.h"
#include "base/Lock.h"
+#include "base/System.h"
+
+#include <algorithm>
+#include <inttypes.h>
#ifdef _WIN32
#include <windows.h>
@@ -105,7 +109,7 @@
}
bool timedWait(StaticLock *userLock, uint64_t waitUntilUs) {
- const auto now = System::get()->getUnixTimeUs();
+ const auto now = android::base::getUnixTimeUs();
const auto timeout =
std::max<uint64_t>(0, waitUntilUs - now) / 1000;
return ::SleepConditionVariableSRW(
diff --git a/base/DecompressingStream.cpp b/base/DecompressingStream.cpp
index fc27be0..03f00a8 100644
--- a/base/DecompressingStream.cpp
+++ b/base/DecompressingStream.cpp
@@ -17,10 +17,6 @@
#include "base/StreamSerializing.h"
#include "lz4.h"
-#ifdef _MSC_VER
-#include "msvc-posix.h"
-#endif
-
#include <errno.h>
#include <cassert>
diff --git a/base/DecompressingStream.h b/base/DecompressingStream.h
index 37ea109..a9bef6d 100644
--- a/base/DecompressingStream.h
+++ b/base/DecompressingStream.h
@@ -18,10 +18,6 @@
#include "base/SmallVector.h"
#include "base/Stream.h"
-#ifdef _MSC_VER
-#include "msvc-posix.h"
-#endif
-
namespace android {
namespace base {
diff --git a/base/FileUtils.cpp b/base/FileUtils.cpp
index b822a55..fff91aa 100644
--- a/base/FileUtils.cpp
+++ b/base/FileUtils.cpp
@@ -19,8 +19,9 @@
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
+#include "msvc.h"
#ifdef _MSC_VER
-#include "msvc-posix.h"
+//#include "msvc-posix.h"
#else
#include <unistd.h>
#endif
diff --git a/base/PathUtils.cpp b/base/PathUtils.cpp
index 7f152b1..06e11be 100644
--- a/base/PathUtils.cpp
+++ b/base/PathUtils.cpp
@@ -320,6 +320,12 @@
return wpath;
}
+/* access function */
+#define F_OK 0 /* test for existence of file */
+#define X_OK 0x01 /* test for execute or search permission */
+#define W_OK 0x02 /* test for write permission */
+#define R_OK 0x04 /* test for read permission */
+
static int GetWin32Mode(int mode) {
// Convert |mode| to win32 permission bits.
int win32mode = 0x0;
diff --git a/base/SharedLibrary.cpp b/base/SharedLibrary.cpp
index aac7457..b05d838 100644
--- a/base/SharedLibrary.cpp
+++ b/base/SharedLibrary.cpp
@@ -57,7 +57,7 @@
return paths;
}
-SharedLibrary::LibraryMap SharedLibrary::s_libraryMap = LibraryMap();
+static SharedLibrary::LibraryMap s_libraryMap;
// static
SharedLibrary* SharedLibrary::open(const char* libraryName) {
@@ -92,7 +92,7 @@
char* error,
size_t errorSize) {
GL_LOG("SharedLibrary::open for [%s] (win32): call LoadLibrary\n", libraryName);
- HMODULE lib = LoadLibrary(libraryName);
+ HMODULE lib = LoadLibraryA(libraryName);
// Try a bit harder to find the shared library if we cannot find it.
if (!lib) {
@@ -103,7 +103,7 @@
auto libName = PathUtils::join(path, libraryName);
GL_LOG("SharedLibrary::open for [%s]: trying [%s]\n",
libraryName, libName.c_str());
- lib = LoadLibrary(libName.c_str());
+ lib = LoadLibraryA(libName.c_str());
GL_LOG("SharedLibrary::open for [%s]: trying [%s]. found? %d\n",
libraryName, libName.c_str(), lib != nullptr);
}
diff --git a/base/SharedLibrary.h b/base/SharedLibrary.h
index c9e5c8d..53cb4b2 100644
--- a/base/SharedLibrary.h
+++ b/base/SharedLibrary.h
@@ -99,8 +99,6 @@
private:
- static LibraryMap s_libraryMap;
-
static SharedLibrary* do_open(const char* libraryName,
char* error,
size_t errorSize);
diff --git a/base/SharedMemory.h b/base/SharedMemory.h
index 5724c19..86079d7 100644
--- a/base/SharedMemory.h
+++ b/base/SharedMemory.h
@@ -15,7 +15,8 @@
#ifdef _WIN32
#ifdef _MSC_VER
-#include "msvc-posix.h"
+#include "base\msvc.h"
+#include <windows.h>
#else
#include <windows.h>
#endif // _MSC_VER
diff --git a/base/SharedMemory_win32.cpp b/base/SharedMemory_win32.cpp
index e904493..6b253f1 100644
--- a/base/SharedMemory_win32.cpp
+++ b/base/SharedMemory_win32.cpp
@@ -11,26 +11,26 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "android/base/memory/SharedMemory.h"
+#include "base/SharedMemory.h"
#include <cassert>
#include <string>
-#include "android/base/files/PathUtils.h"
-#include "android/base/system/Win32UnicodeString.h"
+#include "base/PathUtils.h"
+#include "base/Win32UnicodeString.h"
namespace android {
namespace base {
-SharedMemory::SharedMemory(StringView name, size_t size) : mSize(size) {
- constexpr StringView kFileUri = "file://";
+SharedMemory::SharedMemory(const std::string& name, size_t size) : mSize(size) {
+ const std::string kFileUri = "file://";
if (name.find(kFileUri, 0) == 0) {
mShareType = ShareType::FILE_BACKED;
auto path = name.substr(kFileUri.size());
mName = PathUtils::recompose(PathUtils::decompose(path));
} else {
mShareType = ShareType::SHARED_MEMORY;
- mName = "SHM_" + name.str();
+ mName = "SHM_" + name;
}
}
diff --git a/base/StdioStream.h b/base/StdioStream.h
index b71325d..7bef6af 100644
--- a/base/StdioStream.h
+++ b/base/StdioStream.h
@@ -17,9 +17,6 @@
#include "base/Compiler.h"
#include "base/Stream.h"
-#ifdef _MSC_VER
-#include "msvc-posix.h"
-#endif
#include <stdio.h>
diff --git a/base/Stream.h b/base/Stream.h
index 01a9964..a4d2b7f 100644
--- a/base/Stream.h
+++ b/base/Stream.h
@@ -14,6 +14,8 @@
#pragma once
+#include "msvc.h"
+
#include <string>
#include <inttypes.h>
diff --git a/base/System.cpp b/base/System.cpp
index 0e0ad7e..ee4a3bb 100644
--- a/base/System.cpp
+++ b/base/System.cpp
@@ -3,12 +3,16 @@
#include "base/System.h"
#ifdef _WIN32
+#include "base/Win32UnicodeString.h"
#include <windows.h>
+#include "msvc.h"
#endif
+#include <vector>
+
#ifdef _MSC_VER
-#include "msvc-posix.h"
-#include "dirent.h"
+// #include "msvc-posix.h"
+// #include <dirent.h>
#else
#include <time.h>
#include <sys/time.h>
@@ -23,8 +27,11 @@
using FileSize = uint64_t;
#ifdef _WIN32
+
+using android::base::Win32UnicodeString;
+
// Return |path| as a Unicode string, while discarding trailing separators.
-Win32UnicodeString win32Path(StringView path) {
+Win32UnicodeString win32Path(const char* path) {
Win32UnicodeString wpath(path);
// Get rid of trailing directory separators, Windows doesn't like them.
size_t size = wpath.size();
@@ -149,7 +156,7 @@
int fdStat(int fd, PathStat* st) {
#ifdef _WIN32
- return fstat64(fd, st);
+ return _fstat64(fd, st);
#else // !_WIN32
return HANDLE_EINTR(fstat(fd, st));
#endif // !_WIN32
@@ -161,9 +168,15 @@
}
PathStat st;
int ret = fdStat(fd, &st);
+#ifdef _WIN32
+ if (ret < 0 || !(st.st_mode & _S_IFREG)) {
+ return false;
+ }
+#else
if (ret < 0 || !S_ISREG(st.st_mode)) {
return false;
}
+#endif
// This is off_t on POSIX and a 32/64 bit integral type on windows based on
// the host / compiler combination. We cast everything to 64 bit unsigned to
// play safe.
@@ -309,5 +322,125 @@
return res;
}
+
+#ifdef _WIN32
+// Based on chromium/src/base/file_version_info_win.cc's CreateFileVersionInfoWin
+// Currently used to query Vulkan DLL's on the system and blacklist known
+// problematic DLLs
+// static
+// Windows 10 funcs
+typedef DWORD (*get_file_version_info_size_w_t)(LPCWSTR, LPDWORD);
+typedef DWORD (*get_file_version_info_w_t)(LPCWSTR, DWORD, DWORD, LPVOID);
+// Windows 8 funcs
+typedef DWORD (*get_file_version_info_size_ex_w_t)(DWORD, LPCWSTR, LPDWORD);
+typedef DWORD (*get_file_version_info_ex_w_t)(DWORD, LPCWSTR, DWORD, DWORD, LPVOID);
+// common
+typedef int (*ver_query_value_w_t)(LPCVOID, LPCWSTR, LPVOID, PUINT);
+static get_file_version_info_size_w_t getFileVersionInfoSizeW_func = 0;
+static get_file_version_info_w_t getFileVersionInfoW_func = 0;
+static get_file_version_info_size_ex_w_t getFileVersionInfoSizeExW_func = 0;
+static get_file_version_info_ex_w_t getFileVersionInfoExW_func = 0;
+static ver_query_value_w_t verQueryValueW_func = 0;
+static bool getFileVersionInfoFuncsAvailable = false;
+static bool getFileVersionInfoExFuncsAvailable = false;
+static bool canQueryFileVersion = false;
+
+bool initFileVersionInfoFuncs() {
+ // LOG(VERBOSE) << "querying file version info API...";
+ if (canQueryFileVersion) return true;
+ HMODULE kernelLib = GetModuleHandleA("kernelbase");
+ if (!kernelLib) return false;
+ // LOG(VERBOSE) << "found kernelbase.dll";
+ getFileVersionInfoSizeW_func =
+ (get_file_version_info_size_w_t)GetProcAddress(kernelLib, "GetFileVersionInfoSizeW");
+ if (!getFileVersionInfoSizeW_func) {
+ // LOG(VERBOSE) << "GetFileVersionInfoSizeW not found. Not on Windows 10?";
+ } else {
+ // LOG(VERBOSE) << "GetFileVersionInfoSizeW found. On Windows 10?";
+ }
+ getFileVersionInfoW_func =
+ (get_file_version_info_w_t)GetProcAddress(kernelLib, "GetFileVersionInfoW");
+ if (!getFileVersionInfoW_func) {
+ // LOG(VERBOSE) << "GetFileVersionInfoW not found. Not on Windows 10?";
+ } else {
+ // LOG(VERBOSE) << "GetFileVersionInfoW found. On Windows 10?";
+ }
+ getFileVersionInfoFuncsAvailable =
+ getFileVersionInfoSizeW_func && getFileVersionInfoW_func;
+ if (!getFileVersionInfoFuncsAvailable) {
+ getFileVersionInfoSizeExW_func =
+ (get_file_version_info_size_ex_w_t)GetProcAddress(kernelLib, "GetFileVersionInfoSizeExW");
+ getFileVersionInfoExW_func =
+ (get_file_version_info_ex_w_t)GetProcAddress(kernelLib, "GetFileVersionInfoExW");
+ getFileVersionInfoExFuncsAvailable =
+ getFileVersionInfoSizeExW_func && getFileVersionInfoExW_func;
+ }
+ if (!getFileVersionInfoFuncsAvailable &&
+ !getFileVersionInfoExFuncsAvailable) {
+ // LOG(VERBOSE) << "Cannot get file version info funcs";
+ return false;
+ }
+ verQueryValueW_func =
+ (ver_query_value_w_t)GetProcAddress(kernelLib, "VerQueryValueW");
+ if (!verQueryValueW_func) {
+ // LOG(VERBOSE) << "VerQueryValueW not found";
+ return false;
+ }
+ // LOG(VERBOSE) << "VerQueryValueW found. Can query file versions";
+ canQueryFileVersion = true;
+ return true;
+}
+
+bool queryFileVersionInfo(const char* path, int* major, int* minor, int* build_1, int* build_2) {
+ if (!initFileVersionInfoFuncs()) return false;
+ if (!canQueryFileVersion) return false;
+ const Win32UnicodeString pathWide(path);
+ DWORD dummy;
+ DWORD length = 0;
+ const DWORD fileVerGetNeutral = 0x02;
+ if (getFileVersionInfoFuncsAvailable) {
+ length = getFileVersionInfoSizeW_func(pathWide.c_str(), &dummy);
+ } else if (getFileVersionInfoExFuncsAvailable) {
+ length = getFileVersionInfoSizeExW_func(fileVerGetNeutral, pathWide.c_str(), &dummy);
+ }
+ if (length == 0) {
+ // LOG(VERBOSE) << "queryFileVersionInfo: path not found: " << path.str().c_str();
+ return false;
+ }
+ std::vector<uint8_t> data(length, 0);
+ if (getFileVersionInfoFuncsAvailable) {
+ if (!getFileVersionInfoW_func(pathWide.c_str(), dummy, length, data.data())) {
+ // LOG(VERBOSE) << "GetFileVersionInfoW failed";
+ return false;
+ }
+ } else if (getFileVersionInfoExFuncsAvailable) {
+ if (!getFileVersionInfoExW_func(fileVerGetNeutral, pathWide.c_str(), dummy, length, data.data())) {
+ // LOG(VERBOSE) << "GetFileVersionInfoExW failed";
+ return false;
+ }
+ }
+ VS_FIXEDFILEINFO* fixedFileInfo = nullptr;
+ UINT fixedFileInfoLength;
+ if (!verQueryValueW_func(
+ data.data(),
+ L"\\",
+ reinterpret_cast<void**>(&fixedFileInfo),
+ &fixedFileInfoLength)) {
+ // LOG(VERBOSE) << "VerQueryValueW failed";
+ return false;
+ }
+ if (major) *major = HIWORD(fixedFileInfo->dwFileVersionMS);
+ if (minor) *minor = LOWORD(fixedFileInfo->dwFileVersionMS);
+ if (build_1) *build_1 = HIWORD(fixedFileInfo->dwFileVersionLS);
+ if (build_2) *build_2 = LOWORD(fixedFileInfo->dwFileVersionLS);
+ return true;
+}
+#else
+bool queryFileVersionInfo(const char*, int*, int*, int*, int*) {
+ return false;
+}
+#endif // _WIN32
+
+
} // namespace base
} // namespace android
diff --git a/base/System.h b/base/System.h
index 9ed0817..7c4bc96 100644
--- a/base/System.h
+++ b/base/System.h
@@ -24,5 +24,7 @@
CpuTime cpuTime();
+bool queryFileVersionInfo(const char* filename, int* major, int* minor, int* build1, int* build2);
+
} // namespace base
} // namespace android
diff --git a/base/Thread_win32.cpp b/base/Thread_win32.cpp
index 3bd4736..e2efda7 100644
--- a/base/Thread_win32.cpp
+++ b/base/Thread_win32.cpp
@@ -58,7 +58,6 @@
if (WaitForSingleObject(mThread, INFINITE) == WAIT_FAILED) {
return false;
}
- DCHECK(mFinished);
if (exitStatus) {
*exitStatus = mExitStatus;
diff --git a/base/Win32UnicodeString.cpp b/base/Win32UnicodeString.cpp
index 3658940..e1ad487 100644
--- a/base/Win32UnicodeString.cpp
+++ b/base/Win32UnicodeString.cpp
@@ -35,6 +35,11 @@
reset(str);
}
+Win32UnicodeString::Win32UnicodeString(const std::string& str)
+ : mStr(nullptr), mSize(0u) {
+ reset(str.c_str());
+}
+
Win32UnicodeString::Win32UnicodeString(size_t size) : mStr(nullptr), mSize(0u) {
resize(size);
}
@@ -110,7 +115,7 @@
} else {
wchar_t* oldStr = mStr;
mStr = new wchar_t[newSize + 1u];
- size_t copySize = std::min(newSize, mSize);
+ size_t copySize = std::min<size_t>(newSize, mSize);
::memcpy(mStr, oldStr ? oldStr : L"", copySize * sizeof(wchar_t));
mStr[copySize] = L'\0';
mStr[newSize] = L'\0';
diff --git a/base/Win32UnicodeString.h b/base/Win32UnicodeString.h
index 58eda61..710355f 100644
--- a/base/Win32UnicodeString.h
+++ b/base/Win32UnicodeString.h
@@ -47,6 +47,7 @@
// Initialize a new instance from an existing string instance |str|.
explicit Win32UnicodeString(const char* str);
+ explicit Win32UnicodeString(const std::string& str);
// Initialize by reserving enough room for a string of |size| UTF-16
// codepoints.
diff --git a/base/Win32UnicodeString_unittest.cpp b/base/Win32UnicodeString_unittest.cpp
index 32e8e9e..e1f3952 100644
--- a/base/Win32UnicodeString_unittest.cpp
+++ b/base/Win32UnicodeString_unittest.cpp
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "android/base/system/Win32UnicodeString.h"
+#include "base/Win32UnicodeString.h"
#include <gtest/gtest.h>
diff --git a/base/msvc-posix-compat/include/msvc-posix.h b/base/msvc-posix-compat/include/msvc-posix.h
index 164f73d..8a0181b 100644
--- a/base/msvc-posix-compat/include/msvc-posix.h
+++ b/base/msvc-posix-compat/include/msvc-posix.h
@@ -52,6 +52,17 @@
#define W_OK 2 /* Check for write permission */
#define R_OK 4 /* Check for read permission */
+typedef int mode_t;
+#ifdef _WIN64
+typedef int64_t pid_t;
+#else
+typedef int pid_t;
+#endif
+#define STDIN_FILENO _fileno(stdin)
+#define STDOUT_FILENO _fileno(stdout)
+#define STDERR_FILENO _fileno(stderr)
+#define lseek(a, b, c) _lseek(a, b, c)
+#define lseek64 _lseeki64
// These functions were deprecated and replaced with ISO C++ conformant ones
// in MSVC 2017.
diff --git a/base/msvc.cpp b/base/msvc.cpp
new file mode 100644
index 0000000..255c8e3
--- /dev/null
+++ b/base/msvc.cpp
@@ -0,0 +1,140 @@
+// Copyright 2020 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include <io.h>
+
+#include "base/msvc.h"
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sysinfoapi.h>
+
+#define FILETIME_1970 116444736000000000ull
+#define HECTONANOSEC_PER_SEC 10000000ull
+
+int mkstemp(char* t) {
+ // TODO(joshuaduong): Support unicode (b/117322783)
+ int len = strlen(t) + 1;
+ errno_t err = _mktemp_s(t, len);
+
+ if (err != 0) {
+ return -1;
+ }
+
+ return _sopen(t, _O_RDWR | _O_CREAT | _O_EXCL | _O_BINARY, _SH_DENYRW,
+ _S_IREAD | _S_IWRITE);
+}
+
+// From https://msdn.microsoft.com/en-us/library/28d5ce15.aspx
+int asprintf(char** buf, const char* format, ...) {
+ va_list args;
+ int len;
+
+ if (buf == NULL) {
+ return -1;
+ }
+
+ // retrieve the variable arguments
+ va_start(args, format);
+
+ len = _vscprintf(format, args) // _vscprintf doesn't count
+ + 1; // terminating '\0'
+
+ if (len <= 0) {
+ return len;
+ }
+
+ *buf = (char*)malloc(len * sizeof(char));
+
+ vsprintf(*buf, format, args); // C4996
+ // Note: vsprintf is deprecated; consider using vsprintf_s instead
+ return len;
+}
+
+// From https://msdn.microsoft.com/en-us/library/28d5ce15.aspx
+static int vasprintf(char** buf, const char* format, va_list args) {
+ int len;
+
+ if (buf == NULL) {
+ return -1;
+ }
+
+ len = _vscprintf(format, args) // _vscprintf doesn't count
+ + 1; // terminating '\0'
+
+ if (len <= 0) {
+ return len;
+ }
+
+ *buf = (char*)malloc(len * sizeof(char));
+
+ vsprintf(*buf, format, args); // C4996
+ // Note: vsprintf is deprecated; consider using vsprintf_s instead
+ return len;
+}
+
+// This is a poor resolution timer, but at least it
+// is available on Win7 and older. System.cpp will install
+// a better one.
+static SystemTime getSystemTime = (SystemTime)GetSystemTimeAsFileTime;
+
+int getntptimeofday(struct timespec*, struct timezone*);
+
+int getntptimeofday(struct timespec* tp, struct timezone* z) {
+ int res = 0;
+ union {
+ unsigned long long ns100; /*time since 1 Jan 1601 in 100ns units */
+ FILETIME ft;
+ } _now;
+ TIME_ZONE_INFORMATION TimeZoneInformation;
+ DWORD tzi;
+
+ if (z != NULL) {
+ if ((tzi = GetTimeZoneInformation(&TimeZoneInformation)) !=
+ TIME_ZONE_ID_INVALID) {
+ z->tz_minuteswest = TimeZoneInformation.Bias;
+ if (tzi == TIME_ZONE_ID_DAYLIGHT)
+ z->tz_dsttime = 1;
+ else
+ z->tz_dsttime = 0;
+ } else {
+ z->tz_minuteswest = 0;
+ z->tz_dsttime = 0;
+ }
+ }
+
+ if (tp != NULL) {
+ getSystemTime((FileTime*)&_now.ft); /* 100-nanoseconds since 1-1-1601 */
+ /* The actual accuracy on XP seems to be 125,000 nanoseconds = 125
+ * microseconds = 0.125 milliseconds */
+ _now.ns100 -= FILETIME_1970; /* 100 nano-seconds since 1-1-1970 */
+ tp->tv_sec =
+ _now.ns100 / HECTONANOSEC_PER_SEC; /* seconds since 1-1-1970 */
+ tp->tv_nsec = (long)(_now.ns100 % HECTONANOSEC_PER_SEC) *
+ 100; /* nanoseconds */
+ }
+ return res;
+}
+
+int gettimeofday(struct timeval* p, struct timezone* z) {
+ struct timespec tp;
+
+ if (getntptimeofday(&tp, z))
+ return -1;
+ p->tv_sec = tp.tv_sec;
+ p->tv_usec = (tp.tv_nsec / 1000);
+ return 0;
+}
diff --git a/base/msvc.h b/base/msvc.h
new file mode 100644
index 0000000..9e908b7
--- /dev/null
+++ b/base/msvc.h
@@ -0,0 +1,128 @@
+#pragma once
+
+#ifndef __linux__
+// Make sure these are defined and don't change anything if used.
+enum {
+ SOCK_CLOEXEC = 0,
+#ifndef __APPLE__
+ O_CLOEXEC = 0
+#endif
+};
+#endif // !__linux__
+
+#ifdef _MSC_VER
+
+#include <windows.h>
+#include <BaseTsd.h>
+
+#include <direct.h>
+#include <fcntl.h>
+#include <io.h>
+#include <process.h>
+#include <stdint.h>
+#include <sys/stat.h>
+#include <time.h>
+#include <winsock.h>
+
+typedef SSIZE_T ssize_t;
+
+typedef int mode_t;
+#ifdef _WIN64
+typedef int64_t pid_t;
+#else
+typedef int pid_t;
+#endif
+#define STDIN_FILENO _fileno(stdin)
+#define STDOUT_FILENO _fileno(stdout)
+#define STDERR_FILENO _fileno(stderr)
+#define lseek(a, b, c) _lseek(a, b, c)
+#define lseek64 _lseeki64
+
+struct FileTime {
+ uint32_t dwLowDateTime;
+ uint32_t dwHighDateTime;
+};
+
+// Need <dirent.h>
+
+// Define for convenience only in mingw. This is
+// convenient for the _access function in Windows.
+#define F_OK 0 /* Check for file existence */
+#define X_OK 1 /* Check for execute permission (not supported in Windows) */
+#define W_OK 2 /* Check for write permission */
+#define R_OK 4 /* Check for read permission */
+
+typedef int mode_t;
+#ifdef _WIN64
+typedef int64_t pid_t;
+#else
+typedef int pid_t;
+#endif
+#define STDIN_FILENO _fileno(stdin)
+#define STDOUT_FILENO _fileno(stdout)
+#define STDERR_FILENO _fileno(stderr)
+#define lseek(a, b, c) _lseek(a, b, c)
+#define lseek64 _lseeki64
+
+// These functions were deprecated and replaced with ISO C++ conformant ones
+// in MSVC 2017.
+/*
+#define strdup _strdup
+#define mkdir _mkdir
+#define rmdir _rmdir
+#define getcwd _getcwd
+#define getpid _getpid
+#define close _close
+#define open _open
+#define read _read
+#define write _write
+#define creat _creat
+*/
+
+// From <fcntl.h>
+#define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR)
+
+// From <sys/types.h>
+typedef int64_t off64_t;
+
+// From <sys/cdefs.h>
+#ifdef __cplusplus
+#define __BEGIN_DECLS extern "C" {
+#define __END_DECLS }
+#else
+#define __BEGIN_DECLS /* empty */
+#define __END_DECLS /* empty */
+#endif
+
+
+typedef void (*SystemTime)(FileTime*);
+
+// From <sys/time.h>
+struct timezone {
+ int tz_minuteswest; /* of Greenwich */
+ int tz_dsttime; /* type of dst correction to apply */
+};
+
+// From <strings.h>
+#define strcasecmp _stricmp
+#define strncasecmp _strnicmp
+
+// From <stdio.h>
+#define fseeko64 _fseeki64
+#define ftello64 _ftelli64
+
+// From <linux/limits.h>
+#define PATH_MAX MAX_PATH
+
+__BEGIN_DECLS
+
+
+extern SystemTime getSystemTime;
+extern int gettimeofday(struct timeval* tp, struct timezone* tz);
+extern int asprintf(char** buf, const char* format, ...);
+extern int vasprintf(char** buf, const char* format, va_list args);
+extern int mkstemp(char* t);
+
+__END_DECLS
+
+#endif
diff --git a/base/ring_buffer.cpp b/base/ring_buffer.cpp
index 3592412..c4dc39b 100644
--- a/base/ring_buffer.cpp
+++ b/base/ring_buffer.cpp
@@ -16,7 +16,7 @@
#include <errno.h>
#include <string.h>
#ifdef _MSC_VER
-#include "msvc-posix.h"
+#include "base/msvc.h"
#else
#include <sys/time.h>
#endif
diff --git a/base/ring_buffer_unittest.cpp b/base/ring_buffer_unittest.cpp
index 2086b54..c41296e 100644
--- a/base/ring_buffer_unittest.cpp
+++ b/base/ring_buffer_unittest.cpp
@@ -22,7 +22,7 @@
#include <errno.h>
#ifdef _MSC_VER
-#include "msvc-posix.h"
+#include "base/msvc.h"
#else
#include <sys/time.h>
#endif
diff --git a/base/testing/file_io.cpp b/base/testing/file_io.cpp
index a93d442..9d10bc6 100644
--- a/base/testing/file_io.cpp
+++ b/base/testing/file_io.cpp
@@ -31,7 +31,7 @@
#include "base/PathUtils.h"
using android::base::PathUtils;
using android::base::Win32UnicodeString;
-using android::base::ScopedCPtr;
+// using android::base::ScopedCPtr;
#endif
// Provide different macros for different number of string arguments where each
diff --git a/base/testing/file_io.h b/base/testing/file_io.h
index 89da31a..0f7824b 100644
--- a/base/testing/file_io.h
+++ b/base/testing/file_io.h
@@ -14,7 +14,7 @@
#pragma once
#ifdef _MSC_VER
- #include "msvc-posix.h"
+ #include "base/msvc.h"
#endif
#include <stdio.h>
diff --git a/host-common/address_space_graphics.cpp b/host-common/address_space_graphics.cpp
index f9c6294..e254e0f 100644
--- a/host-common/address_space_graphics.cpp
+++ b/host-common/address_space_graphics.cpp
@@ -69,8 +69,8 @@
mInitialized = true;
}
- void setConsumer(ConsumerInterface interface) {
- mConsumerInterface = interface;
+ void setConsumer(ConsumerInterface iface) {
+ mConsumerInterface = iface;
}
ConsumerInterface getConsumerInterface() {
@@ -392,8 +392,8 @@
// static
void AddressSpaceGraphicsContext::setConsumer(
- ConsumerInterface interface) {
- sGlobals()->setConsumer(interface);
+ ConsumerInterface iface) {
+ sGlobals()->setConsumer(iface);
}
AddressSpaceGraphicsContext::AddressSpaceGraphicsContext(bool isVirtio) :
diff --git a/host-common/dma_device.h b/host-common/dma_device.h
index b5731e2..328ce83 100644
--- a/host-common/dma_device.h
+++ b/host-common/dma_device.h
@@ -19,11 +19,7 @@
#include "render_api_types.h"
#ifdef _MSC_VER
-# ifdef BUILDING_EMUGL_COMMON_SHARED
# define EMUGL_COMMON_API __declspec(dllexport)
-# else
-# define EMUGL_COMMON_API __declspec(dllimport)
-#endif
#else
# define EMUGL_COMMON_API
#endif
diff --git a/host-common/opengl/NativeGpuInfo_windows.cpp b/host-common/opengl/NativeGpuInfo_windows.cpp
index f792a0d..a162647 100755
--- a/host-common/opengl/NativeGpuInfo_windows.cpp
+++ b/host-common/opengl/NativeGpuInfo_windows.cpp
@@ -12,21 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "android/opengl/NativeGpuInfo.h"
+#include "NativeGpuInfo.h"
-#include "android/base/StringFormat.h"
-#include "android/base/StringView.h"
-#include "android/base/Uuid.h"
-#include "android/base/containers/SmallVector.h"
-#include "android/base/files/PathUtils.h"
-#include "android/base/memory/ScopedPtr.h"
-#include "android/base/misc/FileUtils.h"
-#include "android/base/misc/StringUtils.h"
-#include "android/base/system/System.h"
-#include "android/base/system/Win32UnicodeString.h"
-#include "android/crashreport/crash-handler.h"
-
-#include "android/utils/path.h"
+#include "base/StringFormat.h"
+#include "base/SmallVector.h"
+#include "base/StringFormat.h"
+#include "base/PathUtils.h"
+#include "base/System.h"
+#include "base/Win32UnicodeString.h"
#include <windows.h>
#include <d3d9.h>
@@ -37,15 +30,9 @@
#include <string>
#include <tuple>
-using android::base::makeCustomScopedPtr;
using android::base::PathUtils;
-using android::base::RunOptions;
using android::base::SmallFixedVector;
-using android::base::startsWith;
using android::base::StringFormat;
-using android::base::StringView;
-using android::base::System;
-using android::base::Uuid;
using android::base::Win32UnicodeString;
static std::string& toLower(std::string& s) {
@@ -82,6 +69,11 @@
gpulist->currGpu().device_id = std::move(toLower(result));
}
+static bool startsWith(const std::string& string, const std::string& prefix) {
+ return string.size() >= prefix.size() &&
+ memcmp(string.data(), prefix.data(), prefix.size()) == 0;
+}
+
static void add_predefined_gpu_dlls(GpuInfo* gpu) {
const std::string& currMake = gpu->make;
if (currMake == "NVIDIA" || startsWith(gpu->model, "NVIDIA")) {
@@ -127,8 +119,6 @@
return;
}
- auto keyCloser = makeCustomScopedPtr(hkey, ::RegCloseKey);
-
SmallFixedVector<wchar_t, 256> name;
SmallFixedVector<BYTE, 1024> value;
for (int i = 0;; ++i) {
@@ -188,34 +178,36 @@
}
}
}
+
+ ::RegCloseKey(hkey);
}
static const int kGPUInfoQueryTimeoutMs = 5000;
-static std::string load_gpu_info_wmic() {
- auto guid = Uuid::generateFast().toString();
- // WMIC doesn't allow one to have any unquoted '-' characters in file name,
- // so let's get rid of them.
- guid.erase(std::remove(guid.begin(), guid.end(), '-'), guid.end());
- auto tempName = PathUtils::join(System::get()->getTempDir(),
- StringFormat("gpuinfo_%s.txt", guid));
-
- auto deleteTempFile = makeCustomScopedPtr(
- &tempName,
- [](const std::string* name) { path_delete_file(name->c_str()); });
- if (!System::get()->runCommand(
- {"wmic", StringFormat("/OUTPUT:%s", tempName), "path",
- "Win32_VideoController", "get", "/value"},
- RunOptions::WaitForCompletion | RunOptions::TerminateOnTimeout,
- kGPUInfoQueryTimeoutMs)) {
- return {};
- }
- auto res = android::readFileIntoString(tempName);
- return res ? Win32UnicodeString::convertToUtf8(
- (const wchar_t*)res->c_str(),
- res->size() / sizeof(wchar_t))
- : std::string{};
-}
+// static std::string load_gpu_info_wmic() {
+// auto guid = Uuid::generateFast().toString();
+// // WMIC doesn't allow one to have any unquoted '-' characters in file name,
+// // so let's get rid of them.
+// guid.erase(std::remove(guid.begin(), guid.end(), '-'), guid.end());
+// auto tempName = PathUtils::join(System::get()->getTempDir(),
+// StringFormat("gpuinfo_%s.txt", guid));
+//
+// auto deleteTempFile = makeCustomScopedPtr(
+// &tempName,
+// [](const std::string* name) { path_delete_file(name->c_str()); });
+// if (!System::get()->runCommand(
+// {"wmic", StringFormat("/OUTPUT:%s", tempName), "path",
+// "Win32_VideoController", "get", "/value"},
+// RunOptions::WaitForCompletion | RunOptions::TerminateOnTimeout,
+// kGPUInfoQueryTimeoutMs)) {
+// return {};
+// }
+// auto res = android::readFileIntoString(tempName);
+// return res ? Win32UnicodeString::convertToUtf8(
+// (const wchar_t*)res->c_str(),
+// res->size() / sizeof(wchar_t))
+// : std::string{};
+// }
void parse_gpu_info_list_windows(const std::string& contents,
GpuInfoList* gpulist) {
@@ -299,10 +291,10 @@
gpu.make = vendoridBuf;
gpu.device_id = deviceidBuf;
gpu.model = &descriptionBuf[0];
- crashhandler_append_message_format(
- "gpu found. vendor id %04x device id 0x%04x\n",
- (unsigned int)(id.VendorId),
- (unsigned int)(id.DeviceId));
+ // crashhandler_append_message_format(
+ // "gpu found. vendor id %04x device id 0x%04x\n",
+ // (unsigned int)(id.VendorId),
+ // (unsigned int)(id.DeviceId));
return true;
}
}
@@ -313,8 +305,7 @@
void getGpuInfoListNative(GpuInfoList* gpus) {
if (queryGpuInfoD3D(gpus)) return;
- crashhandler_append_message_format(
- "d3d gpu query failed.\n");
+ // crashhandler_append_message_format("d3d gpu query failed.\n");
DISPLAY_DEVICEW device = { sizeof(device) };
@@ -330,7 +321,7 @@
// Now try inspecting the registry directly; |device|.DeviceKey can be a
// path to the GPU information key.
- static constexpr StringView prefix = "\\Registry\\Machine\\";
+ static const std::string prefix = "\\Registry\\Machine\\";
if (startsWith(Win32UnicodeString::convertToUtf8(device.DeviceKey),
prefix)) {
load_gpu_registry_info(device.DeviceKey + prefix.size(), &gpu);
@@ -339,9 +330,10 @@
}
if (gpus->infos.empty()) {
+ // Everything failed; bail.
// Everything failed - fall back to the good^Wbad old WMIC command.
- auto gpuInfoWmic = load_gpu_info_wmic();
- parse_gpu_info_list_windows(gpuInfoWmic, gpus);
+ // auto gpuInfoWmic = load_gpu_info_wmic();
+ // parse_gpu_info_list_windows(gpuInfoWmic, gpus);
}
}
@@ -350,32 +342,32 @@
bool badAmdVulkanDriverVersion() {
int major, minor, build_1, build_2;
- crashhandler_append_message_format(
- "checking for bad AMD Vulkan driver version...\n");
+ // crashhandler_append_message_format(
+ // "checking for bad AMD Vulkan driver version...\n");
- if (!System::queryFileVersionInfo("amdvlk64.dll", &major, &minor, &build_1, &build_2)) {
- crashhandler_append_message_format(
- "amdvlk64.dll not found. Checking for amdvlk32...\n");
- if (!System::queryFileVersionInfo("amdvlk32.dll", &major, &minor, &build_1, &build_2)) {
- crashhandler_append_message_format(
- "amdvlk32.dll not found. No bad AMD Vulkan driver versions found.\n");
+ if (!android::base::queryFileVersionInfo("amdvlk64.dll", &major, &minor, &build_1, &build_2)) {
+ // crashhandler_append_message_format(
+ // "amdvlk64.dll not found. Checking for amdvlk32...\n");
+ if (!android::base::queryFileVersionInfo("amdvlk32.dll", &major, &minor, &build_1, &build_2)) {
+ // crashhandler_append_message_format(
+ // "amdvlk32.dll not found. No bad AMD Vulkan driver versions found.\n");
// Information about amdvlk64 not availble; not blacklisted
return false;
}
}
- crashhandler_append_message_format(
- "AMD driver info found. Version: %d.%d.%d.%d\n",
- major, minor, build_1, build_2);
+ // crashhandler_append_message_format(
+ // "AMD driver info found. Version: %d.%d.%d.%d\n",
+ // major, minor, build_1, build_2);
bool isBad = (major == 1 && minor == 0 && build_1 <= 54);
if (isBad) {
- crashhandler_append_message_format(
- "Is bad AMD driver version; blacklisting.\n");
+ // crashhandler_append_message_format(
+ // "Is bad AMD driver version; blacklisting.\n");
} else {
- crashhandler_append_message_format(
- "Not known bad AMD driver version; passing.\n");
+ // crashhandler_append_message_format(
+ // "Not known bad AMD driver version; passing.\n");
}
return isBad;
@@ -395,19 +387,19 @@
bool badVulkanDllVersion() {
int major, minor, build_1, build_2;
- crashhandler_append_message_format(
- "checking for bad vulkan-1.dll version...\n");
+ // crashhandler_append_message_format(
+ // "checking for bad vulkan-1.dll version...\n");
- if (!System::queryFileVersionInfo("vulkan-1.dll", &major, &minor, &build_1, &build_2)) {
- crashhandler_append_message_format(
- "info on vulkan-1.dll cannot be found, continue.\n");
+ if (!android::base::queryFileVersionInfo("vulkan-1.dll", &major, &minor, &build_1, &build_2)) {
+ // crashhandler_append_message_format(
+ // "info on vulkan-1.dll cannot be found, continue.\n");
// Information about vulkan-1.dll not available; not blacklisted
return false;
}
- crashhandler_append_message_format(
- "vulkan-1.dll version: %d.%d.%d.%d\n",
- major, minor, build_1, build_2);
+ // crashhandler_append_message_format(
+ // "vulkan-1.dll version: %d.%d.%d.%d\n",
+ // major, minor, build_1, build_2);
// Ban all Windows Vulkan drivers < 1.1;
// they sometimes advertise vkEnumerateInstanceVersion
@@ -419,11 +411,11 @@
major == 1 && minor == 0;
if (isBad) {
- crashhandler_append_message_format(
- "Is bad vulkan-1.dll version; blacklisting.\n");
+ // crashhandler_append_message_format(
+ // "Is bad vulkan-1.dll version; blacklisting.\n");
} else {
- crashhandler_append_message_format(
- "Not known bad vulkan-1.dll version; continue.\n");
+ // crashhandler_append_message_format(
+ // "Not known bad vulkan-1.dll version; continue.\n");
}
return isBad;
diff --git a/host-common/opengl/logger.cpp b/host-common/opengl/logger.cpp
index 96d38ef..8c9b954 100644
--- a/host-common/opengl/logger.cpp
+++ b/host-common/opengl/logger.cpp
@@ -23,6 +23,9 @@
#include <stdarg.h>
#include <stdio.h>
#include <string>
+
+#include "base/msvc.h"
+
#ifndef _MSC_VER
#include <sys/time.h>
#endif
diff --git a/host-common/opengles.cpp b/host-common/opengles.cpp
index bc51b8a..23ce576 100644
--- a/host-common/opengles.cpp
+++ b/host-common/opengles.cpp
@@ -263,7 +263,7 @@
android::emulation::registerOnLastRefCallback(
sRenderLib->getOnLastColorBufferRef());
- ConsumerInterface interface = {
+ ConsumerInterface iface = {
// create
[](struct asg_context context,
ConsumerCallbacks callbacks) {
@@ -281,7 +281,7 @@
// load
[](void* consumer, android::base::Stream* stream) { },
};
- AddressSpaceGraphicsContext::setConsumer(interface);
+ AddressSpaceGraphicsContext::setConsumer(iface);
if (!sRenderer) {
D("Can't start OpenGLES renderer?");
diff --git a/stream-servers/CMakeLists.txt b/stream-servers/CMakeLists.txt
index cefd756..de6afda 100644
--- a/stream-servers/CMakeLists.txt
+++ b/stream-servers/CMakeLists.txt
@@ -73,6 +73,11 @@
gfxstream-vulkan-server
gfxstream-snapshot
apigen-codec-common)
+
+if (WIN32)
+ target_link_libraries(gfxstream_backend PRIVATE D3d9.lib)
+endif()
+
target_include_directories(
gfxstream_backend
PUBLIC
diff --git a/stream-servers/NativeSubWindow_win32.cpp b/stream-servers/NativeSubWindow_win32.cpp
index a69f8f3..762ac10 100644
--- a/stream-servers/NativeSubWindow_win32.cpp
+++ b/stream-servers/NativeSubWindow_win32.cpp
@@ -41,16 +41,16 @@
void* repaint_callback_param, int hideWindow){
static const char className[] = "subWin";
- WNDCLASS wc = {};
- if (!GetClassInfo(GetModuleHandle(NULL), className, &wc)) {
+ WNDCLASSA wc = {};
+ if (!GetClassInfoA(GetModuleHandle(NULL), className, &wc)) {
wc.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;// redraw if size changes
wc.lpfnWndProc = &subWindowProc; // points to window procedure
wc.cbWndExtra = sizeof(void*) ; // save extra window memory
wc.lpszClassName = className; // name of window class
- RegisterClass(&wc);
+ RegisterClassA(&wc);
}
- EGLNativeWindowType ret = CreateWindowEx(
+ EGLNativeWindowType ret = CreateWindowExA(
WS_EX_NOPARENTNOTIFY, // do not bother our parent window
className,
"sub",
diff --git a/stream-servers/glestranslator/EGL/CMakeLists.txt b/stream-servers/glestranslator/EGL/CMakeLists.txt
index 96bb44c..89c2990 100644
--- a/stream-servers/glestranslator/EGL/CMakeLists.txt
+++ b/stream-servers/glestranslator/EGL/CMakeLists.txt
@@ -50,7 +50,6 @@
endif()
if (WIN32)
- target_link_libraries(EGL_translator_static PUBLIC "gdi32::gdi32")
elseif (APPLE)
target_link_libraries(EGL_translator_static PUBLIC "-framework AppKit")
else()
diff --git a/stream-servers/glestranslator/EGL/EglOsApi_wgl.cpp b/stream-servers/glestranslator/EGL/EglOsApi_wgl.cpp
index 4a1cd61..2122214 100755
--- a/stream-servers/glestranslator/EGL/EglOsApi_wgl.cpp
+++ b/stream-servers/glestranslator/EGL/EglOsApi_wgl.cpp
@@ -15,16 +15,14 @@
*/
#include "EglOsApi.h"
-#include "android/base/synchronization/Lock.h"
+#include "base/Lock.h"
+#include "base/SharedLibrary.h"
#include "CoreProfileConfigs.h"
-#include "emugl/common/lazy_instance.h"
-#include "emugl/common/logging.h"
-#include "emugl/common/shared_library.h"
-#include "emugl/common/thread_store.h"
+#include "host-common/logging.h"
#include "GLcommon/GLLibrary.h"
-#include "OpenglCodecCommon/ErrorLog.h"
+#include "apigen-codec-common/ErrorLog.h"
#include <windows.h>
#include <wingdi.h>
@@ -35,6 +33,7 @@
#include <EGL/eglext.h>
+#include <memory>
#include <unordered_map>
#include <unordered_set>
@@ -64,7 +63,7 @@
namespace {
-using emugl::SharedLibrary;
+using android::base::SharedLibrary;
typedef GlLibrary::GlFunctionPointer GlFunctionPointer;
// Returns true if an extension is include in a given extension list.
@@ -221,7 +220,7 @@
LIST_WGL_FUNCTIONS(LOAD_WGL_POINTER)
if (systemLib) {
- HMODULE gdi32 = GetModuleHandle("gdi32.dll");
+ HMODULE gdi32 = GetModuleHandleA("gdi32.dll");
LIST_GDI32_FUNCTIONS(LOAD_WGL_GDI32_POINTER)
} else {
LIST_GDI32_FUNCTIONS(LOAD_WGL_INNER_POINTER)
@@ -255,8 +254,8 @@
// it can be used to create a device context and associated
// OpenGL rendering context. Return NULL on failure.
HWND createDummyWindow() {
- WNDCLASSEX wcx;
- wcx.cbSize = sizeof(wcx); // size of structure
+ WNDCLASSA wcx;
+ // wcx.cbSize = sizeof(wcx); // size of structure
wcx.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW; // redraw if size changes
wcx.lpfnWndProc = dummyWndProc; // points to window procedure
wcx.cbClsExtra = 0; // no extra class memory
@@ -267,11 +266,10 @@
wcx.hbrBackground = NULL; // no background brush
wcx.lpszMenuName = NULL; // name of menu resource
wcx.lpszClassName = "DummyWin"; // name of window class
- wcx.hIconSm = (HICON) NULL; // small class icon
- RegisterClassEx(&wcx);
+ RegisterClassA(&wcx);
- HWND hwnd = CreateWindowEx(WS_EX_CLIENTEDGE,
+ HWND hwnd = CreateWindowExA(WS_EX_CLIENTEDGE,
"DummyWin",
"Dummy",
WS_POPUP,
@@ -675,7 +673,7 @@
// ::SetPixelFormat() depending on GPU emulation configuration. See
// technical notes above for details.
explicit WinGlobals(const WglBaseDispatch* dispatch)
- : mDispatch(dispatch), mTls(onThreadTermination) {}
+ : mDispatch(dispatch) {}
// Return a thread-local device context that can be used to list
// available pixel formats for the host window. The caller cannot use
@@ -777,25 +775,20 @@
// on thread exit. Return nullptr on failure.
HDC getInternalDC(const WinPixelFormat* format) {
int formatId = format ? format->configId() : 0;
- auto map = reinterpret_cast<ConfigMap*>(mTls.get());
- if (!map) {
- map = new ConfigMap();
- mTls.set(map);
- }
+ static thread_local ConfigMap configMap;
- auto it = map->find(formatId);
- if (it != map->end()) {
+ auto it = configMap.find(formatId);
+ if (it != configMap.end()) {
return it->second.dc();
}
ConfigDC newValue(format, mDispatch);
HDC result = newValue.dc();
- map->emplace(formatId, std::move(newValue));
+ configMap.emplace(formatId, std::move(newValue));
return result;
}
const WglBaseDispatch* mDispatch = nullptr;
- emugl::ThreadStore mTls;
HDC mNontrivialDC = nullptr;
};
@@ -1027,7 +1020,7 @@
return ret;
}
- virtual emugl::SmartPtr<EglOS::Context> createContext(
+ virtual std::shared_ptr<EglOS::Context> createContext(
EGLint profileMask,
const EglOS::PixelFormat* pixelFormat,
EglOS::Context* sharedContext) {
@@ -1338,11 +1331,14 @@
GL_LOG("%s: Dispatch initialized\n", __FUNCTION__);
}
-emugl::LazyInstance<WinEngine> sHostEngine = LAZY_INSTANCE_INIT;
+static WinEngine* sHostEngine() {
+ static WinEngine* e = new WinEngine;
+ return e;
+}
} // namespace
// static
EglOS::Engine* EglOS::Engine::getHostInstance() {
- return sHostEngine.ptr();
+ return sHostEngine();
}
diff --git a/stream-servers/glestranslator/GLES_V2/GLESv2Imp.cpp b/stream-servers/glestranslator/GLES_V2/GLESv2Imp.cpp
index 1ef5290..6eaf5f3 100644
--- a/stream-servers/glestranslator/GLES_V2/GLESv2Imp.cpp
+++ b/stream-servers/glestranslator/GLES_V2/GLESv2Imp.cpp
@@ -53,7 +53,7 @@
#ifdef _MSC_VER
-#include "msvc-posix.h"
+#include "base/msvc.h"
#else
#include <sys/time.h>
#endif
diff --git a/stream-servers/glestranslator/GLcommon/CMakeLists.txt b/stream-servers/glestranslator/GLcommon/CMakeLists.txt
index 796a3e9..72cc4ff 100644
--- a/stream-servers/glestranslator/GLcommon/CMakeLists.txt
+++ b/stream-servers/glestranslator/GLcommon/CMakeLists.txt
@@ -30,11 +30,11 @@
target_compile_options(GLcommon PUBLIC -Wno-inconsistent-missing-override)
if (LINUX)
- target_link_libraries(GLcommon linux-x86_64 PRIVATE "-ldl" "-Wl,-Bsymbolic")
+ target_link_libraries(GLcommon PRIVATE "-ldl" "-Wl,-Bsymbolic")
endif()
if (WIN32)
- target_link_libraries(GLcommon windows PRIVATE "gdi32::gdi32" "-Wl,--add-stdcall-alias")
+ target_link_libraries(GLcommon PRIVATE "-Wl,--add-stdcall-alias")
endif()
# android_add_test(TARGET GLcommon_unittests SRC # cmake-format: sortable
diff --git a/stream-servers/glestranslator/GLcommon/GLDispatch.cpp b/stream-servers/glestranslator/GLcommon/GLDispatch.cpp
index 22239a9..7b39896 100644
--- a/stream-servers/glestranslator/GLcommon/GLDispatch.cpp
+++ b/stream-servers/glestranslator/GLcommon/GLDispatch.cpp
@@ -118,7 +118,7 @@
android::base::Lock GLDispatch::s_lock;
#define GL_DISPATCH_DEFINE_POINTER(return_type, function_name, signature, args) \
- GL_APICALL return_type (GL_APIENTRY *GLDispatch::function_name) signature = NULL;
+ return_type (*GLDispatch::function_name) signature = NULL;
LIST_GLES_FUNCTIONS(GL_DISPATCH_DEFINE_POINTER, GL_DISPATCH_DEFINE_POINTER)
diff --git a/stream-servers/glestranslator/include/GLcommon/GLDispatch.h b/stream-servers/glestranslator/include/GLcommon/GLDispatch.h
index d40f375..01c7087 100644
--- a/stream-servers/glestranslator/include/GLcommon/GLDispatch.h
+++ b/stream-servers/glestranslator/include/GLcommon/GLDispatch.h
@@ -40,7 +40,7 @@
class GlLibrary;
#define GLES_DECLARE_METHOD(return_type, function_name, signature, args) \
- static GL_APICALL return_type (GL_APIENTRY *function_name) signature;
+ static return_type (*function_name) signature;
using EGLGetProcAddressFunc = std::function<void*(const char* name)>;
diff --git a/stream-servers/testlibs/CMakeLists.txt b/stream-servers/testlibs/CMakeLists.txt
index 770889c..a102144 100644
--- a/stream-servers/testlibs/CMakeLists.txt
+++ b/stream-servers/testlibs/CMakeLists.txt
@@ -4,7 +4,7 @@
elseif (WIN32)
set(oswindow-platform-sources
windows/WindowsTimer.cpp
- windows/Windows_system-utils.cpp
+ windows/Windows_system_utils.cpp
windows/win32/Win32Window.cpp)
else()
set(oswindow-platform-sources
diff --git a/stream-servers/vulkan/CMakeLists.txt b/stream-servers/vulkan/CMakeLists.txt
index 3ea514b..0bc1621 100644
--- a/stream-servers/vulkan/CMakeLists.txt
+++ b/stream-servers/vulkan/CMakeLists.txt
@@ -13,7 +13,7 @@
target_link_libraries(gfxstream-vulkan-server PUBLIC OpenglRender_vulkan_cereal gfxstream-compressedTextures apigen-codec-common gfxstream-base)
if (WIN32)
-android_target_compile_definitions(gfxstream-vulkan-server windows PRIVATE -DVK_USE_PLATFORM_WIN32_KHR)
+target_compile_definitions(gfxstream-vulkan-server PRIVATE -DVK_USE_PLATFORM_WIN32_KHR)
endif()
target_compile_options(gfxstream-vulkan-server PRIVATE -fvisibility=hidden -Wno-unused-value -Wno-return-type -Wno-return-type-c-linkage)
diff --git a/stream-servers/vulkan/VkCommonOperations.cpp b/stream-servers/vulkan/VkCommonOperations.cpp
index 4505747..1fd8eac 100644
--- a/stream-servers/vulkan/VkCommonOperations.cpp
+++ b/stream-servers/vulkan/VkCommonOperations.cpp
@@ -1927,7 +1927,7 @@
subplaneExtent.width,
subplaneExtent.height,
{
- swapUV ? VK_IMAGE_ASPECT_PLANE_2_BIT : VK_IMAGE_ASPECT_PLANE_1_BIT,
+ (VkImageAspectFlags)(swapUV ? VK_IMAGE_ASPECT_PLANE_2_BIT : VK_IMAGE_ASPECT_PLANE_1_BIT),
0, 0, 1,
},
{ 0, 0, 0 },
@@ -1941,7 +1941,7 @@
subplaneExtent.width,
subplaneExtent.height,
{
- swapUV ? VK_IMAGE_ASPECT_PLANE_1_BIT : VK_IMAGE_ASPECT_PLANE_2_BIT,
+ (VkImageAspectFlags)(swapUV ? VK_IMAGE_ASPECT_PLANE_1_BIT : VK_IMAGE_ASPECT_PLANE_2_BIT),
0, 0, 1,
},
{ 0, 0, 0 },
diff --git a/stream-servers/vulkan/VkDecoderGlobalState.cpp b/stream-servers/vulkan/VkDecoderGlobalState.cpp
index b0b24ad..b38b1ce 100644
--- a/stream-servers/vulkan/VkDecoderGlobalState.cpp
+++ b/stream-servers/vulkan/VkDecoderGlobalState.cpp
@@ -4593,7 +4593,7 @@
int dispatchZ = _layerCount;
if (isEtc2) {
- Etc2PushConstant pushConstant = {compFormat, baseLayer};
+ Etc2PushConstant pushConstant = {(uint32_t)compFormat, baseLayer};
if (extent.depth > 1) {
// 3D texture
pushConstant.baseLayer = 0;
@@ -4641,7 +4641,7 @@
}
AstcPushConstant pushConstant = {
{compressedBlockWidth, compressedBlockHeight},
- compFormat,
+ (uint32_t)compFormat,
baseLayer,
srgb,
smallBlock,
diff --git a/third-party/angle/src/common/third_party/base/anglebase/numerics/safe_conversions.h b/third-party/angle/src/common/third_party/base/anglebase/numerics/safe_conversions.h
index b37a36c..5c1e54a 100644
--- a/third-party/angle/src/common/third_party/base/anglebase/numerics/safe_conversions.h
+++ b/third-party/angle/src/common/third_party/base/anglebase/numerics/safe_conversions.h
@@ -10,6 +10,7 @@
#include <limits>
#include <type_traits>
+
#include "anglebase/logging.h"
#include "anglebase/numerics/safe_conversions_impl.h"