Misc: Remove unused code

This commit is contained in:
Connor McLaughlin
2022-08-22 19:55:38 +10:00
parent 43869bf74c
commit 7bbacd2392
100 changed files with 114 additions and 2979 deletions

View File

@ -3,7 +3,7 @@
#include <cstdlib>
#include <mutex>
#if defined(_WIN32) && !defined(_UWP)
#if defined(_WIN32)
#include "windows_headers.h"
#include <intrin.h>
#include <tlhelp32.h>
@ -13,7 +13,7 @@ static std::mutex s_AssertFailedMutex;
static inline void FreezeThreads(void** ppHandle)
{
#if defined(_WIN32) && !defined(_UWP)
#if defined(_WIN32)
HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0);
if (hSnapshot != INVALID_HANDLE_VALUE)
{
@ -43,7 +43,7 @@ static inline void FreezeThreads(void** ppHandle)
static inline void ResumeThreads(void* pHandle)
{
#if defined(_WIN32) && !defined(_UWP)
#if defined(_WIN32)
HANDLE hSnapshot = (HANDLE)pHandle;
if (pHandle != INVALID_HANDLE_VALUE)
{
@ -79,7 +79,7 @@ void Y_OnAssertFailed(const char* szMessage, const char* szFunction, const char*
char szMsg[512];
std::snprintf(szMsg, sizeof(szMsg), "%s in function %s (%s:%u)", szMessage, szFunction, szFile, uLine);
#if defined(_WIN32) && !defined(_UWP)
#if defined(_WIN32)
SetConsoleTextAttribute(GetStdHandle(STD_ERROR_HANDLE), FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY);
WriteConsoleA(GetStdHandle(STD_ERROR_HANDLE), szMsg, static_cast<DWORD>(std::strlen(szMsg)), NULL, NULL);
OutputDebugStringA(szMsg);
@ -114,7 +114,7 @@ void Y_OnPanicReached(const char* szMessage, const char* szFunction, const char*
char szMsg[512];
std::snprintf(szMsg, sizeof(szMsg), "%s in function %s (%s:%u)", szMessage, szFunction, szFile, uLine);
#if defined(_WIN32) && !defined(_UWP)
#if defined(_WIN32)
SetConsoleTextAttribute(GetStdHandle(STD_ERROR_HANDLE), FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY);
WriteConsoleA(GetStdHandle(STD_ERROR_HANDLE), szMsg, static_cast<DWORD>(std::strlen(szMsg)), NULL, NULL);
OutputDebugStringA(szMsg);

View File

@ -286,7 +286,7 @@ public:
{
if (m_discarded)
{
#if defined(_WIN32) && !defined(_UWP)
#if defined(_WIN32)
// delete the temporary file
if (!DeleteFileW(StringUtil::UTF8StringToWideString(m_temporaryFileName).c_str()))
{
@ -294,14 +294,6 @@ public:
"AtomicUpdatedFileByteStream::~AtomicUpdatedFileByteStream(): Failed to delete temporary file '%s'",
m_temporaryFileName.c_str());
}
#elif defined(_UWP)
// delete the temporary file
if (!DeleteFileFromAppW(StringUtil::UTF8StringToWideString(m_temporaryFileName).c_str()))
{
Log_WarningPrintf(
"AtomicUpdatedFileByteStream::~AtomicUpdatedFileByteStream(): Failed to delete temporary file '%s'",
m_temporaryFileName.c_str());
}
#else
// delete the temporary file
if (remove(m_temporaryFileName.c_str()) < 0)
@ -326,7 +318,7 @@ public:
fflush(m_pFile);
#if defined(_WIN32) && !defined(_UWP)
#if defined(_WIN32)
// move the atomic file name to the original file name
if (!MoveFileExW(StringUtil::UTF8StringToWideString(m_temporaryFileName).c_str(),
StringUtil::UTF8StringToWideString(m_originalFileName).c_str(), MOVEFILE_REPLACE_EXISTING))
@ -339,17 +331,6 @@ public:
{
m_committed = true;
}
#elif defined(_UWP)
if (!FileSystem::RenamePath(m_temporaryFileName.c_str(), m_originalFileName.c_str()))
{
Log_WarningPrintf("AtomicUpdatedFileByteStream::Commit(): Failed to rename temporary file '%s' to '%s'",
m_temporaryFileName.c_str(), m_originalFileName.c_str());
m_discarded = true;
}
else
{
m_committed = true;
}
#else
// move the atomic file name to the original file name
if (rename(m_temporaryFileName.c_str(), m_originalFileName.c_str()) < 0)
@ -1049,7 +1030,6 @@ std::unique_ptr<ByteStream> ByteStream::OpenFile(const char* fileName, u32 openM
{
DebugAssert(openMode & (BYTESTREAM_OPEN_CREATE | BYTESTREAM_OPEN_WRITE));
#ifdef _WIN32
#ifndef _UWP
// generate the temporary file name
u32 fileNameLength = static_cast<u32>(std::strlen(fileName));
char* temporaryFileName = (char*)alloca(fileNameLength + 8);
@ -1058,35 +1038,14 @@ std::unique_ptr<ByteStream> ByteStream::OpenFile(const char* fileName, u32 openM
// fill in random characters
_mktemp_s(temporaryFileName, fileNameLength + 8);
const std::wstring wideTemporaryFileName(StringUtil::UTF8StringToWideString(temporaryFileName));
#else
// On UWP, preserve the extension, as it affects permissions.
std::string temporaryFileName;
const char* extension = std::strrchr(fileName, '.');
if (extension)
temporaryFileName.append(fileName, extension - fileName);
else
temporaryFileName.append(fileName);
temporaryFileName.append("_XXXXXX");
_mktemp_s(temporaryFileName.data(), temporaryFileName.size() + 1);
if (extension)
temporaryFileName.append(extension);
const std::wstring wideTemporaryFileName(StringUtil::UTF8StringToWideString(temporaryFileName));
#endif
// massive hack here
DWORD desiredAccess = GENERIC_WRITE;
if (openMode & BYTESTREAM_OPEN_READ)
desiredAccess |= GENERIC_READ;
#ifndef _UWP
HANDLE hFile =
CreateFileW(wideTemporaryFileName.c_str(), desiredAccess, FILE_SHARE_DELETE, NULL, CREATE_NEW, 0, NULL);
#else
HANDLE hFile =
CreateFile2FromAppW(wideTemporaryFileName.c_str(), desiredAccess, FILE_SHARE_DELETE, CREATE_NEW, nullptr);
#endif
if (hFile == INVALID_HANDLE_VALUE)
return nullptr;

View File

@ -2,15 +2,15 @@
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemDefinitionGroup>
<ClCompile>
<PreprocessorDefinitions Condition="('$(BuildingForUWP)'!='true' And '$(Platform)'!='ARM64')">WITH_OPENGL=1;WITH_VULKAN=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories Condition="('$(BuildingForUWP)'!='true' And '$(Platform)'!='ARM64')">$(SolutionDir)dep\glad\include;$(SolutionDir)dep\vulkan\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions Condition="'$(Platform)'!='ARM64'">WITH_OPENGL=1;WITH_VULKAN=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories Condition="'$(Platform)'!='ARM64'">$(SolutionDir)dep\glad\include;$(SolutionDir)dep\vulkan\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)dep\fmt\include;$(SolutionDir)dep\stb\include;$(SolutionDir)dep\glslang;$(SolutionDir)dep\zlib\include;$(SolutionDir)dep\minizip\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup>
<Link>
<AdditionalDependencies Condition="('$(BuildingForUWP)'!='true' And '$(Platform)'!='ARM64')">$(RootBuildDir)glad\glad.lib;$(RootBuildDir)glslang\glslang.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies Condition="'$(Platform)'!='ARM64'">$(RootBuildDir)glad\glad.lib;$(RootBuildDir)glslang\glslang.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>$(RootBuildDir)zstd\zstd.lib;$(RootBuildDir)fmt\fmt.lib;$(RootBuildDir)zlib\zlib.lib;$(RootBuildDir)minizip\minizip.lib;$(RootBuildDir)lzma\lzma.lib;d3dcompiler.lib;d3d11.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>

View File

@ -27,35 +27,30 @@
<ClInclude Include="fifo_queue.h" />
<ClInclude Include="file_system.h" />
<ClInclude Include="gl\context.h">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64' Or '$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="gl\context_wgl.h">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64' Or '$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="gl\loader.h">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64' Or '$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="gl\program.h">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64' Or '$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="gl\shader_cache.h">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64' Or '$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="gl\stream_buffer.h">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64' Or '$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="gl\texture.h">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64' Or '$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="hash_combine.h" />
<ClInclude Include="heap_array.h" />
<ClInclude Include="http_downloader.h" />
<ClInclude Include="http_downloader_uwp.h">
<ExcludedFromBuild Condition="'$(BuildingForUWP)'!='true'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="http_downloader_winhttp.h">
<ExcludedFromBuild Condition="'$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="http_downloader_winhttp.h" />
<ClInclude Include="image.h" />
<ClInclude Include="layered_settings_interface.h" />
<ClInclude Include="log.h" />
@ -74,52 +69,48 @@
<ClInclude Include="string.h" />
<ClInclude Include="heterogeneous_containers.h" />
<ClInclude Include="string_util.h" />
<ClInclude Include="thirdparty\StackWalker.h">
<ExcludedFromBuild Condition="'$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="thirdparty\StackWalker.h" />
<ClInclude Include="threading.h" />
<ClInclude Include="timer.h" />
<ClInclude Include="types.h" />
<ClInclude Include="minizip_helpers.h" />
<ClInclude Include="vulkan\builders.h">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64' Or '$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="vulkan\context.h">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64' Or '$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="vulkan\entry_points.h">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64' Or '$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="vulkan\loader.h">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64' Or '$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="vulkan\shader_cache.h">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64' Or '$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="vulkan\shader_compiler.h">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64' Or '$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="vulkan\staging_buffer.h">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64' Or '$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="vulkan\staging_texture.h">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64' Or '$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="vulkan\stream_buffer.h">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64' Or '$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="vulkan\swap_chain.h">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64' Or '$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="vulkan\texture.h">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64' Or '$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="vulkan\util.h">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64' Or '$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="win32_progress_callback.h">
<ExcludedFromBuild Condition="'$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="win32_progress_callback.h" />
<ClInclude Include="windows_headers.h" />
<ClInclude Include="window_info.h" />
</ItemGroup>
@ -142,30 +133,25 @@
<ClCompile Include="d3d12\util.cpp" />
<ClCompile Include="file_system.cpp" />
<ClCompile Include="gl\context.cpp">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64' Or '$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="gl\context_wgl.cpp">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64' Or '$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="gl\program.cpp">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64' Or '$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="gl\shader_cache.cpp">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64' Or '$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="gl\stream_buffer.cpp">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64' Or '$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="gl\texture.cpp">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64' Or '$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="http_downloader.cpp" />
<ClCompile Include="http_downloader_uwp.cpp">
<ExcludedFromBuild Condition="'$(BuildingForUWP)'!='true'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="http_downloader_winhttp.cpp">
<ExcludedFromBuild Condition="'$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="http_downloader_winhttp.cpp" />
<ClCompile Include="image.cpp" />
<ClCompile Include="layered_settings_interface.cpp" />
<ClCompile Include="log.cpp" />
@ -176,47 +162,43 @@
<ClCompile Include="sha1_digest.cpp" />
<ClCompile Include="string.cpp" />
<ClCompile Include="string_util.cpp" />
<ClCompile Include="thirdparty\StackWalker.cpp">
<ExcludedFromBuild Condition="'$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="thirdparty\StackWalker.cpp" />
<ClCompile Include="threading.cpp" />
<ClCompile Include="timer.cpp" />
<ClCompile Include="vulkan\builders.cpp">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64' Or '$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="vulkan\context.cpp">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64' Or '$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="vulkan\loader.cpp">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64' Or '$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="vulkan\shader_cache.cpp">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64' Or '$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="vulkan\shader_compiler.cpp">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64' Or '$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="vulkan\staging_buffer.cpp">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64' Or '$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="vulkan\staging_texture.cpp">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64' Or '$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="vulkan\stream_buffer.cpp">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64' Or '$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="vulkan\swap_chain.cpp">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64' Or '$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="vulkan\texture.cpp">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64' Or '$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="vulkan\util.cpp">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64' Or '$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="win32_progress_callback.cpp">
<ExcludedFromBuild Condition="'$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="win32_progress_callback.cpp" />
<ClCompile Include="window_info.cpp" />
</ItemGroup>
<ItemGroup>
@ -224,7 +206,7 @@
</ItemGroup>
<ItemGroup>
<None Include="vulkan\entry_points.inl">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64' Or '$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</None>
</ItemGroup>
<PropertyGroup Label="Globals">
@ -239,4 +221,4 @@
</ClCompile>
</ItemDefinitionGroup>
<Import Project="..\..\dep\msvc\vsprops\Targets.props" />
</Project>
</Project>

View File

@ -117,7 +117,6 @@
<ClInclude Include="d3d12\shader_cache.h">
<Filter>d3d12</Filter>
</ClInclude>
<ClInclude Include="http_downloader_uwp.h" />
<ClInclude Include="http_downloader_winhttp.h" />
<ClInclude Include="http_downloader.h" />
<ClInclude Include="vulkan\entry_points.h">
@ -245,7 +244,6 @@
</ClCompile>
<ClCompile Include="http_downloader_winhttp.cpp" />
<ClCompile Include="http_downloader.cpp" />
<ClCompile Include="http_downloader_uwp.cpp" />
<ClCompile Include="vulkan\loader.cpp">
<Filter>vulkan</Filter>
</ClCompile>
@ -279,4 +277,4 @@
<Filter>vulkan</Filter>
</None>
</ItemGroup>
</Project>
</Project>

View File

@ -4,7 +4,7 @@
#include <cinttypes>
#include <cstdio>
#if defined(_WIN32) && !defined(_UWP)
#if defined(_WIN32)
#include "windows_headers.h"
#include "thirdparty/StackWalker.h"

View File

@ -6,10 +6,6 @@
#include <d3dcompiler.h>
Log_SetChannel(D3D12::ShaderCache);
#ifdef _UWP
#include <winrt/Windows.System.Profile.h>
#endif
namespace D3D12 {
#pragma pack(push, 1)
@ -24,19 +20,7 @@ struct CacheIndexEntry
};
#pragma pack(pop)
static bool CanUsePipelineCache()
{
#ifdef _UWP
// GetCachedBlob crashes on XBox UWP for some reason...
const auto version_info = winrt::Windows::System::Profile::AnalyticsInfo::VersionInfo();
const auto device_family = version_info.DeviceFamily();
return (device_family != L"Windows.Xbox");
#else
return true;
#endif
}
ShaderCache::ShaderCache() : m_use_pipeline_cache(CanUsePipelineCache()) {}
ShaderCache::ShaderCache() = default;
ShaderCache::~ShaderCache()
{
@ -80,17 +64,14 @@ void ShaderCache::Open(std::string_view base_path, D3D_FEATURE_LEVEL feature_lev
CreateNew(shader_index_filename, shader_blob_filename, m_shader_index_file, m_shader_blob_file);
}
if (m_use_pipeline_cache)
{
const std::string base_pipelines_filename = GetCacheBaseFileName(base_path, "pipelines", feature_level, debug);
const std::string pipelines_index_filename = base_pipelines_filename + ".idx";
const std::string pipelines_blob_filename = base_pipelines_filename + ".bin";
const std::string base_pipelines_filename = GetCacheBaseFileName(base_path, "pipelines", feature_level, debug);
const std::string pipelines_index_filename = base_pipelines_filename + ".idx";
const std::string pipelines_blob_filename = base_pipelines_filename + ".bin";
if (!ReadExisting(pipelines_index_filename, pipelines_blob_filename, m_pipeline_index_file, m_pipeline_blob_file,
m_pipeline_index))
{
CreateNew(pipelines_index_filename, pipelines_blob_filename, m_pipeline_index_file, m_pipeline_blob_file);
}
if (!ReadExisting(pipelines_index_filename, pipelines_blob_filename, m_pipeline_index_file, m_pipeline_blob_file,
m_pipeline_index))
{
CreateNew(pipelines_index_filename, pipelines_blob_filename, m_pipeline_index_file, m_pipeline_blob_file);
}
}
}
@ -110,14 +91,10 @@ void ShaderCache::InvalidatePipelineCache()
m_pipeline_index_file = nullptr;
}
if (m_use_pipeline_cache)
{
const std::string base_pipelines_filename =
GetCacheBaseFileName(m_base_path, "pipelines", m_feature_level, m_debug);
const std::string pipelines_index_filename = base_pipelines_filename + ".idx";
const std::string pipelines_blob_filename = base_pipelines_filename + ".bin";
CreateNew(pipelines_index_filename, pipelines_blob_filename, m_pipeline_index_file, m_pipeline_blob_file);
}
const std::string base_pipelines_filename = GetCacheBaseFileName(m_base_path, "pipelines", m_feature_level, m_debug);
const std::string pipelines_index_filename = base_pipelines_filename + ".idx";
const std::string pipelines_blob_filename = base_pipelines_filename + ".bin";
CreateNew(pipelines_index_filename, pipelines_blob_filename, m_pipeline_index_file, m_pipeline_blob_file);
}
bool ShaderCache::CreateNew(const std::string& index_filename, const std::string& blob_filename, std::FILE*& index_file,

View File

@ -111,7 +111,6 @@ private:
CacheIndex m_pipeline_index;
D3D_FEATURE_LEVEL m_feature_level = D3D_FEATURE_LEVEL_11_0;
bool m_use_pipeline_cache = false;
bool m_debug = false;
};

View File

@ -23,19 +23,6 @@
#include <share.h>
#include <shlobj.h>
#include <winioctl.h>
#if defined(_UWP)
#include <fcntl.h>
#include <io.h>
#include <winrt/Windows.ApplicationModel.h>
#include <winrt/Windows.Devices.Enumeration.h>
#include <winrt/Windows.Foundation.Collections.h>
#include <winrt/Windows.Foundation.h>
#include <winrt/Windows.Storage.FileProperties.h>
#include <winrt/Windows.Storage.Search.h>
#include <winrt/Windows.Storage.h>
#endif
#else
#include <dirent.h>
#include <errno.h>
@ -514,7 +501,7 @@ std::vector<std::string> FileSystem::GetRootDirectoryList()
{
std::vector<std::string> results;
#if defined(_WIN32) && !defined(_UWP)
#if defined(_WIN32)
char buf[256];
const DWORD size = GetLogicalDriveStringsA(sizeof(buf), buf);
if (size != 0 && size < (sizeof(buf) - 1))
@ -527,28 +514,6 @@ std::vector<std::string> FileSystem::GetRootDirectoryList()
ptr += len + 1u;
}
}
#elif defined(_UWP)
if (const auto install_location = winrt::Windows::ApplicationModel::Package::Current().InstalledLocation();
install_location)
{
if (const auto path = install_location.Path(); !path.empty())
results.push_back(StringUtil::WideStringToUTF8String(path));
}
if (const auto local_location = winrt::Windows::Storage::ApplicationData::Current().LocalFolder(); local_location)
{
if (const auto path = local_location.Path(); !path.empty())
results.push_back(StringUtil::WideStringToUTF8String(path));
}
const auto devices = winrt::Windows::Storage::KnownFolders::RemovableDevices();
const auto folders_task(devices.GetFoldersAsync());
for (const auto& storage_folder : folders_task.get())
{
const auto path = storage_folder.Path();
if (!path.empty())
results.push_back(StringUtil::WideStringToUTF8String(path));
}
#else
const char* home_path = std::getenv("HOME");
if (home_path)
@ -588,127 +553,6 @@ std::string Path::Combine(const std::string_view& base, const std::string_view&
return ret;
}
#ifdef _UWP
static std::FILE* OpenCFileUWP(const wchar_t* wfilename, const wchar_t* mode, FileSystem::FileShareMode share_mode)
{
DWORD access = 0;
DWORD share = 0;
DWORD disposition = 0;
switch (share_mode)
{
case FileSystem::FileShareMode::DenyNone:
share = FILE_SHARE_READ | FILE_SHARE_WRITE;
break;
case FileSystem::FileShareMode::DenyRead:
share = FILE_SHARE_WRITE;
break;
case FileSystem::FileShareMode::DenyWrite:
share = FILE_SHARE_READ;
break;
case FileSystem::FileShareMode::DenyReadWrite:
default:
share = 0;
break;
}
int flags = 0;
const wchar_t* tmode = mode;
while (*tmode)
{
if (*tmode == L'r' && *(tmode + 1) == L'+')
{
access = GENERIC_READ | GENERIC_WRITE;
disposition = OPEN_EXISTING;
flags |= _O_RDWR;
tmode += 2;
}
else if (*tmode == L'w' && *(tmode + 1) == L'+')
{
access = GENERIC_READ | GENERIC_WRITE;
disposition = CREATE_ALWAYS;
flags |= _O_RDWR | _O_CREAT | _O_TRUNC;
tmode += 2;
}
else if (*tmode == L'a' && *(tmode + 1) == L'+')
{
access = GENERIC_READ | GENERIC_WRITE;
disposition = CREATE_ALWAYS;
flags |= _O_RDWR | _O_APPEND | _O_CREAT | _O_TRUNC;
tmode += 2;
}
else if (*tmode == L'r')
{
access = GENERIC_READ;
disposition = OPEN_EXISTING;
flags |= _O_RDONLY;
tmode++;
}
else if (*tmode == L'w')
{
access = GENERIC_WRITE;
disposition = CREATE_ALWAYS;
flags |= _O_WRONLY | _O_CREAT | _O_TRUNC;
tmode++;
}
else if (*tmode == L'a')
{
access = GENERIC_READ | GENERIC_WRITE;
disposition = CREATE_ALWAYS;
flags |= _O_WRONLY | _O_APPEND | _O_CREAT | _O_TRUNC;
tmode++;
}
else if (*tmode == L'b')
{
flags |= _O_BINARY;
tmode++;
}
else if (*tmode == L'S')
{
flags |= _O_SEQUENTIAL;
tmode++;
}
else if (*tmode == L'R')
{
flags |= _O_RANDOM;
tmode++;
}
else
{
Log_ErrorPrintf("Unknown mode flags: '%s'", StringUtil::WideStringToUTF8String(mode).c_str());
return nullptr;
}
}
HANDLE hFile = CreateFileFromAppW(wfilename, access, share, nullptr, disposition, 0, nullptr);
if (hFile == INVALID_HANDLE_VALUE)
return nullptr;
if (flags & _O_APPEND && !SetFilePointerEx(hFile, LARGE_INTEGER{}, nullptr, FILE_END))
{
Log_ErrorPrintf("SetFilePointerEx() failed: %08X", GetLastError());
CloseHandle(hFile);
return nullptr;
}
int fd = _open_osfhandle(reinterpret_cast<intptr_t>(hFile), flags);
if (fd < 0)
{
CloseHandle(hFile);
return nullptr;
}
std::FILE* fp = _wfdopen(fd, mode);
if (!fp)
{
_close(fd);
return nullptr;
}
return fp;
}
#endif // _UWP
std::FILE* FileSystem::OpenCFile(const char* filename, const char* mode)
{
#ifdef _WIN32
@ -718,13 +562,7 @@ std::FILE* FileSystem::OpenCFile(const char* filename, const char* mode)
{
std::FILE* fp;
if (_wfopen_s(&fp, wfilename.c_str(), wmode.c_str()) != 0)
{
#ifdef _UWP
return OpenCFileUWP(wfilename.c_str(), wmode.c_str(), FileShareMode::DenyReadWrite);
#else
return nullptr;
#endif
}
return fp;
}
@ -744,10 +582,7 @@ int FileSystem::OpenFDFile(const char* filename, int flags, int mode)
#ifdef _WIN32
const std::wstring wfilename(StringUtil::UTF8StringToWideString(filename));
if (!wfilename.empty())
{
// TODO: UWP
return _wopen(wfilename.c_str(), flags, mode);
}
return -1;
#else
@ -792,11 +627,7 @@ std::FILE* FileSystem::OpenSharedCFile(const char* filename, const char* mode, F
if (fp)
return fp;
#ifdef _UWP
return OpenCFileUWP(wfilename.c_str(), wmode.c_str(), share_mode);
#else
return nullptr;
#endif
#else
return std::fopen(filename, mode);
#endif
@ -1023,19 +854,6 @@ static u32 TranslateWin32Attributes(u32 Win32Attributes)
return r;
}
static DWORD WrapGetFileAttributes(const wchar_t* path)
{
#ifndef _UWP
return GetFileAttributesW(path);
#else
WIN32_FILE_ATTRIBUTE_DATA fad;
if (!GetFileAttributesExFromAppW(path, GetFileExInfoStandard, &fad))
return INVALID_FILE_ATTRIBUTES;
return fad.dwFileAttributes;
#endif
}
static u32 RecursiveFindFiles(const char* origin_path, const char* parent_path, const char* path, const char* pattern,
u32 flags, FileSystem::FindResultsArray* results)
{
@ -1057,12 +875,7 @@ static u32 RecursiveFindFiles(const char* origin_path, const char* parent_path,
std::string utf8_filename;
utf8_filename.reserve((sizeof(wfd.cFileName) / sizeof(wfd.cFileName[0])) * 2);
#ifndef _UWP
HANDLE hFind = FindFirstFileW(StringUtil::UTF8StringToWideString(tempStr).c_str(), &wfd);
#else
HANDLE hFind = FindFirstFileExFromAppW(StringUtil::UTF8StringToWideString(tempStr).c_str(), FindExInfoBasic, &wfd,
FindExSearchNameMatch, nullptr, 0);
#endif
if (hFind == INVALID_HANDLE_VALUE)
return 0;
@ -1244,7 +1057,6 @@ bool FileSystem::StatFile(const char* path, FILESYSTEM_STAT_DATA* sd)
if (wpath.empty())
return false;
#ifndef _UWP
// determine attributes for the path. if it's a directory, things have to be handled differently..
DWORD fileAttributes = GetFileAttributesW(wpath.c_str());
if (fileAttributes == INVALID_FILE_ATTRIBUTES)
@ -1284,17 +1096,6 @@ bool FileSystem::StatFile(const char* path, FILESYSTEM_STAT_DATA* sd)
sd->ModificationTime = ConvertFileTimeToUnixTime(bhfi.ftLastWriteTime);
sd->Size = static_cast<s64>(((u64)bhfi.nFileSizeHigh) << 32 | (u64)bhfi.nFileSizeLow);
return true;
#else
WIN32_FILE_ATTRIBUTE_DATA fad;
if (!GetFileAttributesExFromAppW(wpath.c_str(), GetFileExInfoStandard, &fad))
return false;
sd->Attributes = TranslateWin32Attributes(fad.dwFileAttributes);
sd->CreationTime = ConvertFileTimeToUnixTime(fad.ftCreationTime);
sd->ModificationTime = ConvertFileTimeToUnixTime(fad.ftLastWriteTime);
sd->Size = static_cast<s64>(((u64)fad.nFileSizeHigh) << 32 | (u64)fad.nFileSizeLow);
return true;
#endif
}
bool FileSystem::StatFile(std::FILE* fp, FILESYSTEM_STAT_DATA* sd)
@ -1335,7 +1136,7 @@ bool FileSystem::FileExists(const char* path)
return false;
// determine attributes for the path. if it's a directory, things have to be handled differently..
DWORD fileAttributes = WrapGetFileAttributes(wpath.c_str());
DWORD fileAttributes = GetFileAttributesW(wpath.c_str());
if (fileAttributes == INVALID_FILE_ATTRIBUTES)
return false;
@ -1357,7 +1158,7 @@ bool FileSystem::DirectoryExists(const char* path)
return false;
// determine attributes for the path. if it's a directory, things have to be handled differently..
DWORD fileAttributes = WrapGetFileAttributes(wpath.c_str());
DWORD fileAttributes = GetFileAttributesW(wpath.c_str());
if (fileAttributes == INVALID_FILE_ATTRIBUTES)
return false;
@ -1373,11 +1174,7 @@ bool FileSystem::DirectoryIsEmpty(const char* path)
wpath += L"\\*";
WIN32_FIND_DATAW wfd;
#ifndef _UWP
HANDLE hFind = FindFirstFileW(wpath.c_str(), &wfd);
#else
HANDLE hFind = FindFirstFileExFromAppW(wpath.c_str(), FindExInfoBasic, &wfd, FindExSearchNameMatch, nullptr, 0);
#endif
if (hFind == INVALID_HANDLE_VALUE)
return true;
@ -1406,14 +1203,9 @@ bool FileSystem::CreateDirectory(const char* Path, bool Recursive)
if (wpath.empty())
return false;
// try just flat-out, might work if there's no other segments that have to be made
#ifndef _UWP
// try just flat-out, might work if there's no other segments that have to be made
if (CreateDirectoryW(wpath.c_str(), nullptr))
return true;
#else
if (CreateDirectoryFromAppW(wpath.c_str(), nullptr))
return true;
#endif
if (!Recursive)
return false;
@ -1423,7 +1215,7 @@ bool FileSystem::CreateDirectory(const char* Path, bool Recursive)
if (lastError == ERROR_ALREADY_EXISTS)
{
// check the attributes
u32 Attributes = WrapGetFileAttributes(wpath.c_str());
u32 Attributes = GetFileAttributesW(wpath.c_str());
if (Attributes != INVALID_FILE_ATTRIBUTES && Attributes & FILE_ATTRIBUTE_DIRECTORY)
return true;
else
@ -1442,11 +1234,7 @@ bool FileSystem::CreateDirectory(const char* Path, bool Recursive)
{
if (wpath[i] == L'\\' || wpath[i] == L'/')
{
#ifndef _UWP
const BOOL result = CreateDirectoryW(tempPath.c_str(), nullptr);
#else
const BOOL result = CreateDirectoryFromAppW(tempPath.c_str(), nullptr);
#endif
if (!result)
{
lastError = GetLastError();
@ -1466,11 +1254,7 @@ bool FileSystem::CreateDirectory(const char* Path, bool Recursive)
// re-create the end if it's not a separator, check / as well because windows can interpret them
if (wpath[pathLength - 1] != L'\\' && wpath[pathLength - 1] != L'/')
{
#ifndef _UWP
const BOOL result = CreateDirectoryW(wpath.c_str(), nullptr);
#else
const BOOL result = CreateDirectoryFromAppW(wpath.c_str(), nullptr);
#endif
if (!result)
{
lastError = GetLastError();
@ -1495,15 +1279,11 @@ bool FileSystem::DeleteFile(const char* path)
return false;
const std::wstring wpath(StringUtil::UTF8StringToWideString(path));
const DWORD fileAttributes = WrapGetFileAttributes(wpath.c_str());
const DWORD fileAttributes = GetFileAttributesW(wpath.c_str());
if (fileAttributes == INVALID_FILE_ATTRIBUTES || fileAttributes & FILE_ATTRIBUTE_DIRECTORY)
return false;
#ifndef _UWP
return (DeleteFileW(wpath.c_str()) == TRUE);
#else
return (DeleteFileFromAppW(wpath.c_str()) == TRUE);
#endif
}
bool FileSystem::RenamePath(const char* old_path, const char* new_path)
@ -1511,29 +1291,11 @@ bool FileSystem::RenamePath(const char* old_path, const char* new_path)
const std::wstring old_wpath(StringUtil::UTF8StringToWideString(old_path));
const std::wstring new_wpath(StringUtil::UTF8StringToWideString(new_path));
#ifndef _UWP
if (!MoveFileExW(old_wpath.c_str(), new_wpath.c_str(), MOVEFILE_REPLACE_EXISTING))
{
Log_ErrorPrintf("MoveFileEx('%s', '%s') failed: %08X", old_path, new_path, GetLastError());
return false;
}
#else
// try moving if it doesn't exist, since ReplaceFile fails on non-existing destinations
if (WrapGetFileAttributes(new_wpath.c_str()) != INVALID_FILE_ATTRIBUTES)
{
if (!DeleteFileFromAppW(new_wpath.c_str()))
{
Log_ErrorPrintf("DeleteFileFromAppW('%s') failed: %08X", new_wpath.c_str(), GetLastError());
return false;
}
}
if (!MoveFileFromAppW(old_wpath.c_str(), new_wpath.c_str()))
{
Log_ErrorPrintf("MoveFileFromAppW('%s', '%s') failed: %08X", old_path, new_path, GetLastError());
return false;
}
#endif
return true;
}
@ -1551,10 +1313,8 @@ std::string FileSystem::GetProgramPath()
// Fall back to the main module if this fails.
HMODULE module = nullptr;
#ifndef _UWP
GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
reinterpret_cast<LPCWSTR>(&GetProgramPath), &module);
#endif
for (;;)
{
@ -1610,13 +1370,8 @@ bool FileSystem::SetPathCompression(const char* path, bool enable)
const bool isFile = !(attrs & FILE_ATTRIBUTE_DIRECTORY);
const DWORD flags = isFile ? FILE_ATTRIBUTE_NORMAL : (FILE_FLAG_BACKUP_SEMANTICS | FILE_ATTRIBUTE_DIRECTORY);
#ifndef _UWP
const HANDLE handle = CreateFileW(wpath.c_str(), FILE_GENERIC_WRITE | FILE_GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_DELETE, nullptr, OPEN_EXISTING, flags, nullptr);
#else
const HANDLE handle = CreateFileFromAppW(wpath.c_str(), FILE_GENERIC_WRITE | FILE_GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_DELETE, nullptr, OPEN_EXISTING, flags, nullptr);
#endif
if (handle == INVALID_HANDLE_VALUE)
return false;

View File

@ -1,165 +0,0 @@
#include "http_downloader_uwp.h"
#include "assert.h"
#include "log.h"
#include "string_util.h"
#include "timer.h"
#include <algorithm>
Log_SetChannel(HTTPDownloaderWinHttp);
#include <winrt/Windows.Foundation.h>
#include <winrt/Windows.Storage.Streams.h>
#include <winrt/Windows.Web.Http.Headers.h>
using namespace winrt::Windows::Foundation;
using namespace winrt::Windows::Web::Http;
namespace Common {
HTTPDownloaderUWP::HTTPDownloaderUWP(std::string user_agent) : HTTPDownloader(), m_user_agent(std::move(user_agent)) {}
HTTPDownloaderUWP::~HTTPDownloaderUWP() = default;
std::unique_ptr<HTTPDownloader> HTTPDownloader::Create(const char* user_agent)
{
std::string user_agent_str;
if (user_agent)
user_agent_str = user_agent;
return std::make_unique<HTTPDownloaderUWP>(user_agent ? std::string(user_agent) : std::string());
}
HTTPDownloader::Request* HTTPDownloaderUWP::InternalCreateRequest()
{
Request* req = new Request();
return req;
}
void HTTPDownloaderUWP::InternalPollRequests()
{
// noop - uses async
}
bool HTTPDownloaderUWP::StartRequest(HTTPDownloader::Request* request)
{
Request* req = static_cast<Request*>(request);
try
{
const std::wstring url_wide(StringUtil::UTF8StringToWideString(req->url));
const Uri uri(url_wide);
if (!m_user_agent.empty() &&
!req->client.DefaultRequestHeaders().UserAgent().TryParseAdd(StringUtil::UTF8StringToWideString(m_user_agent)))
{
Log_WarningPrintf("Failed to set user agent to '%s'", m_user_agent.c_str());
}
if (req->type == Request::Type::Post)
{
const HttpStringContent post_content(StringUtil::UTF8StringToWideString(req->post_data),
winrt::Windows::Storage::Streams::UnicodeEncoding::Utf8,
L"application/x-www-form-urlencoded");
req->request_async = req->client.PostAsync(uri, post_content);
}
else
{
req->request_async = req->client.GetAsync(uri);
}
req->request_async.Completed(
[req](const IAsyncOperationWithProgress<HttpResponseMessage, HttpProgress>& operation, AsyncStatus status) {
if (status == AsyncStatus::Completed)
{
Log_DevPrintf("Request for '%s' completed start portion", req->url.c_str());
try
{
req->state.store(Request::State::Receiving);
req->start_time = Common::Timer::GetCurrentValue();
const HttpResponseMessage response(req->request_async.get());
req->status_code = static_cast<s32>(response.StatusCode());
const IHttpContent content(response.Content());
req->receive_async = content.ReadAsBufferAsync();
req->receive_async.Completed(
[req](
const IAsyncOperationWithProgress<winrt::Windows::Storage::Streams::IBuffer, uint64_t>& inner_operation,
AsyncStatus inner_status) {
if (inner_status == AsyncStatus::Completed)
{
const winrt::Windows::Storage::Streams::IBuffer buffer(inner_operation.get());
if (buffer && buffer.Length() > 0)
{
req->data.resize(buffer.Length());
std::memcpy(req->data.data(), buffer.data(), req->data.size());
}
Log_DevPrintf("End of request '%s', %zu bytes received", req->url.c_str(), req->data.size());
req->state.store(Request::State::Complete);
}
else if (inner_status == AsyncStatus::Canceled)
{
// don't do anything, the request has been freed
}
else
{
Log_ErrorPrintf("Request for '%s' failed during recieve phase: %08X", req->url.c_str(),
inner_operation.ErrorCode().value);
req->status_code = -1;
req->state.store(Request::State::Complete);
}
});
}
catch (const winrt::hresult_error& err)
{
Log_ErrorPrintf("Failed to receive HTTP request for '%s': %08X %s", req->url.c_str(), err.code(),
StringUtil::WideStringToUTF8String(err.message()).c_str());
req->status_code = -1;
req->state.store(Request::State::Complete);
}
req->receive_async = nullptr;
}
else if (status == AsyncStatus::Canceled)
{
// don't do anything, the request has been freed
}
else
{
Log_ErrorPrintf("Request for '%s' failed during start phase: %08X", req->url.c_str(),
operation.ErrorCode().value);
req->status_code = -1;
req->state.store(Request::State::Complete);
}
req->request_async = nullptr;
});
}
catch (const winrt::hresult_error& err)
{
Log_ErrorPrintf("Failed to start HTTP request for '%s': %08X %s", req->url.c_str(), err.code(),
StringUtil::WideStringToUTF8String(err.message()).c_str());
req->callback(-1, req->data);
delete req;
return false;
}
Log_DevPrintf("Started HTTP request for '%s'", req->url.c_str());
req->state = Request::State::Started;
req->start_time = Common::Timer::GetCurrentValue();
return true;
}
void HTTPDownloaderUWP::CloseRequest(HTTPDownloader::Request* request)
{
Request* req = static_cast<Request*>(request);
if (req->request_async)
req->request_async.Cancel();
if (req->receive_async)
req->receive_async.Cancel();
req->client.Close();
delete req;
}
} // namespace FrontendCommon

View File

@ -1,38 +0,0 @@
#pragma once
#pragma once
#include "http_downloader.h"
#include "common/windows_headers.h"
#include <winrt/windows.Web.Http.h>
namespace Common {
class HTTPDownloaderUWP final : public HTTPDownloader
{
public:
HTTPDownloaderUWP(std::string user_agent);
~HTTPDownloaderUWP() override;
protected:
Request* InternalCreateRequest() override;
void InternalPollRequests() override;
bool StartRequest(HTTPDownloader::Request* request) override;
void CloseRequest(HTTPDownloader::Request* request) override;
private:
struct Request : HTTPDownloader::Request
{
std::wstring object_name;
winrt::Windows::Web::Http::HttpClient client;
winrt::Windows::Foundation::IAsyncOperationWithProgress<winrt::Windows::Web::Http::HttpResponseMessage,
winrt::Windows::Web::Http::HttpProgress>
request_async{nullptr};
winrt::Windows::Foundation::IAsyncOperationWithProgress<winrt::Windows::Storage::Streams::IBuffer, uint64_t>
receive_async{};
};
std::string m_user_agent;
};
} // namespace FrontendCommon

View File

@ -212,7 +212,7 @@ Threading::ThreadHandle& Threading::ThreadHandle::operator=(const ThreadHandle&
u64 Threading::ThreadHandle::GetCPUTime() const
{
#if defined(_WIN32) && !defined(_UWP) && !defined(_M_ARM64)
#if defined(_WIN32) && !defined(_M_ARM64)
u64 ret = 0;
if (m_native_handle)
QueryThreadCycleTime((HANDLE)m_native_handle, &ret);
@ -459,7 +459,7 @@ Threading::ThreadHandle& Threading::Thread::operator=(Thread&& thread)
u64 Threading::GetThreadCpuTime()
{
#if defined(_WIN32) && !defined(_UWP) && !defined(_M_ARM64)
#if defined(_WIN32) && !defined(_M_ARM64)
u64 ret = 0;
QueryThreadCycleTime(GetCurrentThread(), &ret);
return ret;
@ -477,7 +477,7 @@ u64 Threading::GetThreadCpuTime()
u64 Threading::GetThreadTicksPerSecond()
{
#if defined(_WIN32) && !defined(_UWP) && !defined(_M_ARM64)
#if defined(_WIN32) && !defined(_M_ARM64)
// On x86, despite what the MS documentation says, this basically appears to be rdtsc.
// So, the frequency is our base clock speed (and stable regardless of power management).
static u64 frequency = 0;

View File

@ -113,7 +113,6 @@ void Timer::SleepUntil(Value value, bool exact)
if (diff <= 0)
return;
#ifndef _UWP
HANDLE timer = GetSleepTimer();
if (timer)
{
@ -131,7 +130,6 @@ void Timer::SleepUntil(Value value, bool exact)
return;
}
}
#endif
// falling back to sleep... bad.
Sleep(static_cast<DWORD>(static_cast<std::uint64_t>(diff) / 1000000));

View File

@ -2,7 +2,7 @@
#include "common/log.h"
Log_SetChannel(WindowInfo);
#if defined(_WIN32) && !defined(_UWP)
#if defined(_WIN32)
#include "common/windows_headers.h"
#include <dwmapi.h>

View File

@ -8,7 +8,6 @@ struct WindowInfo
{
Surfaceless,
Win32,
WinRT,
X11,
Wayland,
MacOS,

View File

@ -7,23 +7,14 @@
#define NOMINMAX 1
#endif
// require vista+, but don't set it when compiling for UWP
#ifndef WINAPI_FAMILY
// require vista+
#ifdef _WIN32_WINNT
#undef _WIN32_WINNT
#endif
#define _WIN32_WINNT _WIN32_WINNT_VISTA
#endif
#include <windows.h>
// hurr i'm windows, i like to conflict, fixme properly later please...
#if defined(FindTexture)
#undef FindTexture
#endif
#if defined(DrawText)
#undef DrawText
#endif
#if defined(CreateDirectory)
#undef CreateDirectory
#endif
@ -33,12 +24,3 @@
#if defined(DeleteFile)
#undef DeleteFile
#endif
#if defined(Yield)
#undef Yield
#endif
#if defined(LoadIcon)
#undef LoadIcon
#endif
#if defined(GetObject)
#undef GetObject
#endif