Merge remote-tracking branch 'upstream/master' into canary-old-update

This commit is contained in:
illusion98 2020-02-11 05:50:15 -05:00
commit b619e482da
35 changed files with 2357 additions and 6258 deletions

View File

@ -38,11 +38,13 @@ after_build:
- |-
7z a xenia-%appveyor_repo_branch%.zip LICENSE .\build\bin\Windows\Release\xenia-canary.exe
7z a xenia-vfs-dump-%appveyor_repo_branch%.zip LICENSE .\build\bin\Windows\Release\xenia-vfs-dump.exe
7z a SDL2.zip %APPVEYOR_BUILD_FOLDER%\build\bin\%PLATFORM%\%CONFIGURATION%\SDL2.dll
test: off
artifacts:
- path: xenia-$(appveyor_repo_branch).zip
- path: xenia-vfs-dump-$(appveyor_repo_branch).zip
- path: SDL2.zip
deploy: off

3
.gitmodules vendored
View File

@ -52,3 +52,6 @@
[submodule "third_party/cxxopts"]
path = third_party/cxxopts
url = https://github.com/jarro2783/cxxopts.git
[submodule "third_party/SDL2-devel-VC"]
path = third_party/SDL2-devel-VC
url = https://github.com/xenia-project/SDL2-devel-VC.git

View File

@ -332,9 +332,8 @@ bool EmulatorWindow::Initialize() {
return true;
}
void EmulatorWindow::FileDrop(wchar_t* filename) {
std::wstring path = filename;
auto result = emulator_->LaunchPath(path);
void EmulatorWindow::FileDrop(const wchar_t* filename) {
auto result = emulator_->LaunchPath(filename);
if (XFAILED(result)) {
// TODO: Display a message box.
XELOGE("Failed to launch target: %.8X", result);

View File

@ -44,7 +44,7 @@ class EmulatorWindow {
bool Initialize();
void FileDrop(wchar_t* filename);
void FileDrop(const wchar_t* filename);
void FileOpen();
void RecentListUpdater(std::wstring path);
void RecentList(int index);

View File

@ -78,7 +78,7 @@ project("xenia-app")
filter("platforms:Windows")
links({
"delayimp", -- Enable dll delayed loading for msvc
"delayimp", -- This library implements delayed loading on Windows, an MSVC exclusive feature.
"xenia-apu-xaudio2",
"xenia-gpu-d3d12",
"xenia-hid-winkey",
@ -96,6 +96,11 @@ project("xenia-app")
"/DELAYLOAD:SDL2.dll", -- SDL is not mandatory since on windows, XInput is the preferred input method
})
filter("platforms:Windows")
linkoptions({
"/DELAYLOAD:SDL2.dll", -- SDL is not mandatory on Windows, implementations using native APIs are prefered.
})
filter("platforms:Windows")
-- Only create the .user file if it doesn't already exist.
local user_file = project_root.."/build/xenia-app.vcxproj.user"

View File

@ -2,7 +2,7 @@
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2019 Ben Vanik. All rights reserved. *
* Copyright 2020 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/

View File

@ -18,13 +18,12 @@ project("xenia-apu-sdl")
filter("platforms:Windows")
-- On linux we build against the system version (libsdl2-dev)
includedirs({
project_root.."/third_party/SDL2/include/",
project_root.."/third_party/SDL2-devel-VC/include/",
})
libdirs({
project_root.."/third_party/SDL2/lib/x64/",
project_root.."/third_party/SDL2-devel-VC/lib/x64/",
})
-- Copy the dll to the output folder
postbuildcommands({
"{COPY} %{prj.basedir}/"..project_root.."/third_party/SDL2/lib/x64/SDL2.dll %{cfg.targetdir}",
"{COPY} %{prj.basedir}/"..project_root.."/third_party/SDL2-devel-VC/lib/x64/SDL2.dll %{cfg.targetdir}",
})

View File

@ -2,7 +2,7 @@
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2019 Ben Vanik. All rights reserved. *
* Copyright 2020 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/

View File

@ -2,7 +2,7 @@
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2019 Ben Vanik. All rights reserved. *
* Copyright 2020 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/

View File

@ -2,7 +2,7 @@
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2019 Ben Vanik. All rights reserved. *
* Copyright 2020 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/

View File

@ -2,7 +2,7 @@
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2019 Ben Vanik. All rights reserved. *
* Copyright 2020 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/

View File

@ -155,7 +155,7 @@ class PosixFileHandle : public FileHandle {
std::unique_ptr<FileHandle> FileHandle::OpenExisting(std::wstring path,
uint32_t desired_access) {
int open_access;
int open_access = 0;
if (desired_access & FileAccess::kGenericRead) {
open_access |= O_RDONLY;
}

View File

@ -31,12 +31,14 @@ std::wstring GetExecutableFolder() {
}
std::wstring GetUserFolder() {
wchar_t path[MAX_PATH];
if (!SUCCEEDED(SHGetFolderPathW(nullptr, CSIDL_MYDOCUMENTS, nullptr,
SHGFP_TYPE_CURRENT, path))) {
return std::wstring();
std::wstring result;
PWSTR path;
if (SUCCEEDED(SHGetKnownFolderPath(FOLDERID_Documents, KF_FLAG_DEFAULT,
nullptr, &path))) {
result.assign(path);
CoTaskMemFree(path);
}
return std::wstring(path);
return result;
}
bool PathExists(const std::wstring& path) {

View File

@ -233,12 +233,12 @@ inline bool bit_scan_forward(uint64_t v, uint32_t* out_first_set_index) {
#else
inline bool bit_scan_forward(uint32_t v, uint32_t* out_first_set_index) {
int i = ffs(v);
*out_first_set_index = i;
*out_first_set_index = i - 1;
return i != 0;
}
inline bool bit_scan_forward(uint64_t v, uint32_t* out_first_set_index) {
int i = ffsll(v);
*out_first_set_index = i;
*out_first_set_index = i - 1;
return i != 0;
}
#endif // XE_PLATFORM_WIN32

View File

@ -95,7 +95,6 @@ namespace xe {
#if XE_PLATFORM_WIN32
const char kPathSeparator = '\\';
const wchar_t kWPathSeparator = L'\\';
const size_t kMaxPath = 260; // _MAX_PATH
#else
const char kPathSeparator = '/';
const wchar_t kWPathSeparator = L'/';

View File

@ -155,9 +155,13 @@ std::string::size_type find_first_of_case(const std::string& target,
std::wstring to_absolute_path(const std::wstring& path) {
#if XE_PLATFORM_WIN32
wchar_t buffer[kMaxPath];
_wfullpath(buffer, path.c_str(), sizeof(buffer) / sizeof(wchar_t));
return buffer;
std::wstring result;
wchar_t* buffer = _wfullpath(nullptr, path.c_str(), 0);
if (buffer != nullptr) {
result.assign(buffer);
free(buffer);
}
return result;
#else
char buffer[kMaxPath];
realpath(xe::to_string(path).c_str(), buffer);

View File

@ -7,11 +7,13 @@
******************************************************************************
*/
#include "xenia/base/threading.h"
#include "xenia/base/assert.h"
#include "xenia/base/logging.h"
#include "xenia/base/platform_win.h"
#include "xenia/base/threading.h"
typedef HANDLE (*SetThreadDescriptionFn)(HANDLE hThread,
PCWSTR lpThreadDescription);
namespace xe {
namespace threading {
@ -39,14 +41,29 @@ struct THREADNAME_INFO {
};
#pragma pack(pop)
void set_name(DWORD thread_id, const std::string& name) {
void set_name(HANDLE thread, const std::string& name) {
auto kern = GetModuleHandleW(L"kernel32.dll");
if (kern) {
auto set_thread_description =
(SetThreadDescriptionFn)GetProcAddress(kern, "SetThreadDescription");
if (set_thread_description) {
int len = MultiByteToWideChar(CP_ACP, 0, name.c_str(), -1, NULL, 0);
auto str = (LPWSTR)alloca(len * sizeof(WCHAR));
if (str) {
MultiByteToWideChar(CP_ACP, 0, name.c_str(), -1, str, len);
set_thread_description(thread, str);
}
}
}
if (!IsDebuggerPresent()) {
return;
}
THREADNAME_INFO info;
info.dwType = 0x1000;
info.szName = name.c_str();
info.dwThreadID = thread_id;
info.dwThreadID = ::GetThreadId(thread);
info.dwFlags = 0;
__try {
RaiseException(0x406D1388, 0, sizeof(info) / sizeof(ULONG_PTR),
@ -55,13 +72,7 @@ void set_name(DWORD thread_id, const std::string& name) {
}
}
void set_name(const std::string& name) {
set_name(static_cast<DWORD>(-1), name);
}
void set_name(std::thread::native_handle_type handle, const std::string& name) {
set_name(GetThreadId(handle), name);
}
void set_name(const std::string& name) { set_name(GetCurrentThread(), name); }
void MaybeYield() {
SwitchToThread();

View File

@ -82,7 +82,7 @@ class X64CodeCache : public CodeCache {
// This is picked to be high enough to cover whatever we can reasonably
// expect. If we hit issues with this it probably means some corner case
// in analysis triggering.
static const size_t kMaximumFunctionCount = 50000;
static const size_t kMaximumFunctionCount = 100000;
struct UnwindReservation {
size_t data_size = 0;

View File

@ -863,22 +863,20 @@ int InstrEmit_rldclx(PPCHIRBuilder& f, const InstrData& i) {
// b <- mb[5] || mb[0:4]
// m <- MASK(b, 63)
// rA <- r & m
Value* sh =
f.And(f.Truncate(f.LoadGPR(i.X.RB), INT8_TYPE), f.LoadConstantInt8(0x7F));
Value* n = f.And(f.Truncate(f.LoadGPR(i.MDS.RB), INT8_TYPE),
f.LoadConstantInt8(0x3F));
uint32_t mb = (i.MD.MB5 << 5) | i.MD.MB;
uint32_t mb = (i.MDS.MB5 << 5) | i.MDS.MB;
uint64_t m = XEMASK(mb, 63);
Value* v = f.LoadGPR(i.MD.RT);
Value* v = f.LoadGPR(i.MDS.RT);
if (sh) {
v = f.RotateLeft(v, sh);
}
v = f.RotateLeft(v, n);
if (m != 0xFFFFFFFFFFFFFFFF) {
v = f.And(v, f.LoadConstantUint64(m));
}
f.StoreGPR(i.MD.RA, v);
if (i.MD.Rc) {
f.StoreGPR(i.MDS.RA, v);
if (i.MDS.Rc) {
f.UpdateCR(0, v);
}
return 0;
@ -890,22 +888,20 @@ int InstrEmit_rldcrx(PPCHIRBuilder& f, const InstrData& i) {
// b <- mb[5] || mb[0:4]
// m <- MASK(0, b)
// rA <- r & m
Value* sh =
f.And(f.Truncate(f.LoadGPR(i.X.RB), INT8_TYPE), f.LoadConstantInt8(0x7F));
Value* n = f.And(f.Truncate(f.LoadGPR(i.MDS.RB), INT8_TYPE),
f.LoadConstantInt8(0x3F));
uint32_t mb = (i.MD.MB5 << 5) | i.MD.MB;
uint32_t mb = (i.MDS.MB5 << 5) | i.MDS.MB;
uint64_t m = XEMASK(0, mb);
Value* v = f.LoadGPR(i.MD.RT);
Value* v = f.LoadGPR(i.MDS.RT);
if (sh) {
v = f.RotateLeft(v, sh);
}
v = f.RotateLeft(v, n);
if (m != 0xFFFFFFFFFFFFFFFF) {
v = f.And(v, f.LoadConstantUint64(m));
}
f.StoreGPR(i.MD.RA, v);
if (i.MD.Rc) {
f.StoreGPR(i.MDS.RA, v);
if (i.MDS.Rc) {
f.UpdateCR(0, v);
}
return 0;

View File

@ -181,15 +181,16 @@ void DxbcShaderTranslator::Reset() {
}
void DxbcShaderTranslator::DxbcSrc::Write(std::vector<uint32_t>& code,
uint32_t dest_write_mask,
bool is_integer) const {
bool is_integer, uint32_t mask,
bool force_vector) const {
uint32_t operand_token = GetOperandTokenTypeAndIndex();
uint32_t dest_component = DxbcDest::GetMaskSingleComponent(dest_write_mask);
uint32_t select_component = dest_component != UINT32_MAX ? dest_component : 0;
bool dest_is_vector =
dest_write_mask != 0b0000 && dest_component == UINT32_MAX;
uint32_t mask_single_component = DxbcDest::GetMaskSingleComponent(mask);
uint32_t select_component =
mask_single_component != UINT32_MAX ? mask_single_component : 0;
bool is_vector =
force_vector || (mask != 0b0000 && mask_single_component == UINT32_MAX);
if (type_ == DxbcOperandType::kImmediate32) {
if (dest_is_vector) {
if (is_vector) {
operand_token |= uint32_t(DxbcOperandDimension::kVector) |
(uint32_t(DxbcComponentSelection::kSwizzle) << 2) |
(DxbcSrc::kXYZW << 4);
@ -197,11 +198,10 @@ void DxbcShaderTranslator::DxbcSrc::Write(std::vector<uint32_t>& code,
operand_token |= uint32_t(DxbcOperandDimension::kScalar);
}
code.push_back(operand_token);
if (dest_is_vector) {
if (is_vector) {
for (uint32_t i = 0; i < 4; ++i) {
code.push_back((dest_write_mask & (1 << i))
? GetModifiedImmediate(i, is_integer)
: 0);
code.push_back((mask & (1 << i)) ? GetModifiedImmediate(i, is_integer)
: 0);
}
} else {
code.push_back(GetModifiedImmediate(select_component, is_integer));
@ -209,7 +209,7 @@ void DxbcShaderTranslator::DxbcSrc::Write(std::vector<uint32_t>& code,
} else {
switch (GetDimension()) {
case DxbcOperandDimension::kScalar:
if (dest_is_vector) {
if (is_vector) {
operand_token |= uint32_t(DxbcOperandDimension::kVector) |
(uint32_t(DxbcComponentSelection::kSwizzle) << 2) |
(DxbcSrc::kXXXX << 4);
@ -219,17 +219,16 @@ void DxbcShaderTranslator::DxbcSrc::Write(std::vector<uint32_t>& code,
break;
case DxbcOperandDimension::kVector:
operand_token |= uint32_t(DxbcOperandDimension::kVector);
if (dest_is_vector) {
if (is_vector) {
operand_token |= uint32_t(DxbcComponentSelection::kSwizzle) << 2;
// Clear swizzle of unused components to a used value to avoid
// referencing potentially uninitialized register components.
uint32_t used_component;
if (!xe::bit_scan_forward(dest_write_mask, &used_component)) {
if (!xe::bit_scan_forward(mask, &used_component)) {
used_component = 0;
}
for (uint32_t i = 0; i < 4; ++i) {
uint32_t swizzle_index =
(dest_write_mask & (1 << i)) ? i : used_component;
uint32_t swizzle_index = (mask & (1 << i)) ? i : used_component;
operand_token |=
(((swizzle_ >> (swizzle_index * 2)) & 3) << (4 + i * 2));
}
@ -1388,7 +1387,7 @@ void DxbcShaderTranslator::StartTranslation() {
}
// Zero general-purpose registers to prevent crashes when the game references
// them.
// them after only initializing them conditionally.
for (uint32_t i = IsDxbcPixelShader() ? kInterpolatorCount : 0;
i < register_count(); ++i) {
DxbcOpMov(

View File

@ -605,10 +605,10 @@ class DxbcShaderTranslator : public ShaderTranslator {
return DxbcDest(DxbcOperandType::kOutputDepth, 0b0001);
}
static DxbcDest Null() { return DxbcDest(DxbcOperandType::kNull, 0b0000); }
// Must write to all 4 components.
static DxbcDest U(uint32_t index_1d, DxbcIndex index_2d) {
return DxbcDest(DxbcOperandType::kUnorderedAccessView, 0b1111, index_1d,
index_2d);
static DxbcDest U(uint32_t index_1d, DxbcIndex index_2d,
uint32_t write_mask = 0b1111) {
return DxbcDest(DxbcOperandType::kUnorderedAccessView, write_mask,
index_1d, index_2d);
}
uint32_t GetMask() const {
@ -792,12 +792,12 @@ class DxbcShaderTranslator : public ShaderTranslator {
return new_src;
}
uint32_t GetLength(uint32_t dest_write_mask) const {
bool dest_is_vector =
dest_write_mask != 0b0000 &&
DxbcDest::GetMaskSingleComponent(dest_write_mask) == UINT32_MAX;
uint32_t GetLength(uint32_t mask, bool force_vector = false) const {
bool is_vector = force_vector ||
(mask != 0b0000 &&
DxbcDest::GetMaskSingleComponent(mask) == UINT32_MAX);
if (type_ == DxbcOperandType::kImmediate32) {
return dest_is_vector ? 5 : 2;
return is_vector ? 5 : 2;
}
return ((absolute_ || negate_) ? 2 : 1) + DxbcOperandAddress::GetLength();
}
@ -828,43 +828,74 @@ class DxbcShaderTranslator : public ShaderTranslator {
immediate_[(swizzle_ >> (swizzle_index * 2)) & 3], is_integer,
absolute_, negate_);
}
void Write(std::vector<uint32_t>& code, uint32_t dest_write_mask,
bool is_integer) const;
void Write(std::vector<uint32_t>& code, bool is_integer, uint32_t mask,
bool force_vector = false) const;
};
// D3D10_SB_OPCODE_TYPE
enum class DxbcOpcode : uint32_t {
kAdd = 0,
kAnd = 1,
kBreak = 2,
kCall = 4,
kCallC = 5,
kCase = 6,
kDefault = 10,
kDiscard = 13,
kDiv = 14,
kElse = 18,
kEndIf = 21,
kEndLoop = 22,
kEndSwitch = 23,
kEq = 24,
kFToI = 27,
kFToU = 28,
kGE = 29,
kIAdd = 30,
kIf = 31,
kIEq = 32,
kILT = 34,
kIMAd = 35,
kIMax = 36,
kIMin = 37,
kINE = 39,
kIShL = 41,
kIToF = 43,
kLabel = 44,
kLT = 49,
kMAd = 50,
kMin = 51,
kMax = 52,
kMov = 54,
kMovC = 55,
kMul = 56,
kNot = 59,
kOr = 60,
kRet = 62,
kRetC = 63,
kRoundNE = 64,
kSwitch = 76,
kULT = 79,
kUGE = 80,
kUMul = 81,
kUMAd = 82,
kUMax = 83,
kUMin = 84,
kUShR = 85,
kUToF = 86,
kXOr = 87,
kDerivRTXCoarse = 122,
kDerivRTXFine = 123,
kDerivRTYCoarse = 124,
kDerivRTYFine = 125,
kF32ToF16 = 130,
kF16ToF32 = 131,
kFirstBitHi = 135,
kUBFE = 138,
kIBFE = 139,
kBFI = 140,
kLdUAVTyped = 163,
kStoreUAVTyped = 164,
kEvalSampleIndex = 204,
};
@ -883,7 +914,7 @@ class DxbcShaderTranslator : public ShaderTranslator {
shader_code_.reserve(shader_code_.size() + 1 + operands_length);
shader_code_.push_back(DxbcOpcodeToken(opcode, operands_length, saturate));
dest.Write(shader_code_);
src.Write(shader_code_, dest_write_mask, (src_are_integer & 0b1) != 0);
src.Write(shader_code_, (src_are_integer & 0b1) != 0, dest_write_mask);
++stat_.instruction_count;
}
void DxbcEmitAluOp(DxbcOpcode opcode, uint32_t src_are_integer,
@ -896,8 +927,8 @@ class DxbcShaderTranslator : public ShaderTranslator {
shader_code_.reserve(shader_code_.size() + 1 + operands_length);
shader_code_.push_back(DxbcOpcodeToken(opcode, operands_length, saturate));
dest.Write(shader_code_);
src0.Write(shader_code_, dest_write_mask, (src_are_integer & 0b1) != 0);
src1.Write(shader_code_, dest_write_mask, (src_are_integer & 0b10) != 0);
src0.Write(shader_code_, (src_are_integer & 0b1) != 0, dest_write_mask);
src1.Write(shader_code_, (src_are_integer & 0b10) != 0, dest_write_mask);
++stat_.instruction_count;
}
void DxbcEmitAluOp(DxbcOpcode opcode, uint32_t src_are_integer,
@ -911,9 +942,9 @@ class DxbcShaderTranslator : public ShaderTranslator {
shader_code_.reserve(shader_code_.size() + 1 + operands_length);
shader_code_.push_back(DxbcOpcodeToken(opcode, operands_length, saturate));
dest.Write(shader_code_);
src0.Write(shader_code_, dest_write_mask, (src_are_integer & 0b1) != 0);
src1.Write(shader_code_, dest_write_mask, (src_are_integer & 0b10) != 0);
src2.Write(shader_code_, dest_write_mask, (src_are_integer & 0b100) != 0);
src0.Write(shader_code_, (src_are_integer & 0b1) != 0, dest_write_mask);
src1.Write(shader_code_, (src_are_integer & 0b10) != 0, dest_write_mask);
src2.Write(shader_code_, (src_are_integer & 0b100) != 0, dest_write_mask);
++stat_.instruction_count;
}
void DxbcEmitAluOp(DxbcOpcode opcode, uint32_t src_are_integer,
@ -928,10 +959,10 @@ class DxbcShaderTranslator : public ShaderTranslator {
shader_code_.reserve(shader_code_.size() + 1 + operands_length);
shader_code_.push_back(DxbcOpcodeToken(opcode, operands_length, saturate));
dest.Write(shader_code_);
src0.Write(shader_code_, dest_write_mask, (src_are_integer & 0b1) != 0);
src1.Write(shader_code_, dest_write_mask, (src_are_integer & 0b10) != 0);
src2.Write(shader_code_, dest_write_mask, (src_are_integer & 0b100) != 0);
src3.Write(shader_code_, dest_write_mask, (src_are_integer & 0b1000) != 0);
src0.Write(shader_code_, (src_are_integer & 0b1) != 0, dest_write_mask);
src1.Write(shader_code_, (src_are_integer & 0b10) != 0, dest_write_mask);
src2.Write(shader_code_, (src_are_integer & 0b100) != 0, dest_write_mask);
src3.Write(shader_code_, (src_are_integer & 0b1000) != 0, dest_write_mask);
++stat_.instruction_count;
}
void DxbcEmitAluOp(DxbcOpcode opcode, uint32_t src_are_integer,
@ -946,8 +977,8 @@ class DxbcShaderTranslator : public ShaderTranslator {
shader_code_.push_back(DxbcOpcodeToken(opcode, operands_length, saturate));
dest0.Write(shader_code_);
dest1.Write(shader_code_);
src0.Write(shader_code_, dest_write_mask, (src_are_integer & 0b1) != 0);
src1.Write(shader_code_, dest_write_mask, (src_are_integer & 0b10) != 0);
src0.Write(shader_code_, (src_are_integer & 0b1) != 0, dest_write_mask);
src1.Write(shader_code_, (src_are_integer & 0b10) != 0, dest_write_mask);
++stat_.instruction_count;
}
void DxbcEmitFlowOp(DxbcOpcode opcode, const DxbcSrc& src,
@ -956,7 +987,17 @@ class DxbcShaderTranslator : public ShaderTranslator {
shader_code_.reserve(shader_code_.size() + 1 + operands_length);
shader_code_.push_back(DxbcOpcodeToken(opcode, operands_length) |
(test ? (1 << 18) : 0));
src.Write(shader_code_, 0b0000, true);
src.Write(shader_code_, true, 0b0000);
++stat_.instruction_count;
}
void DxbcEmitFlowOp(DxbcOpcode opcode, const DxbcSrc& src0,
const DxbcSrc& src1, bool test = false) {
uint32_t operands_length = src0.GetLength(0b0000) + src1.GetLength(0b0000);
shader_code_.reserve(shader_code_.size() + 1 + operands_length);
shader_code_.push_back(DxbcOpcodeToken(opcode, operands_length) |
(test ? (1 << 18) : 0));
src0.Write(shader_code_, true, 0b0000);
src1.Write(shader_code_, true, 0b0000);
++stat_.instruction_count;
}
@ -970,19 +1011,39 @@ class DxbcShaderTranslator : public ShaderTranslator {
DxbcEmitAluOp(DxbcOpcode::kAnd, 0b11, dest, src0, src1);
++stat_.uint_instruction_count;
}
void DxbcOpBreak() {
shader_code_.push_back(DxbcOpcodeToken(DxbcOpcode::kBreak, 0));
++stat_.instruction_count;
}
void DxbcOpCall(const DxbcSrc& label) {
DxbcEmitFlowOp(DxbcOpcode::kCall, label);
++stat_.static_flow_control_count;
}
void DxbcOpElse() {
shader_code_.push_back(DxbcOpcodeToken(DxbcOpcode::kElse, 0));
void DxbcOpCallC(bool test, const DxbcSrc& src, const DxbcSrc& label) {
DxbcEmitFlowOp(DxbcOpcode::kCallC, src, label, test);
++stat_.dynamic_flow_control_count;
}
void DxbcOpCase(const DxbcSrc& src) {
DxbcEmitFlowOp(DxbcOpcode::kCase, src);
++stat_.static_flow_control_count;
}
void DxbcOpDefault() {
shader_code_.push_back(DxbcOpcodeToken(DxbcOpcode::kDefault, 0));
++stat_.instruction_count;
++stat_.static_flow_control_count;
}
void DxbcOpDiscard(bool test, const DxbcSrc& src) {
DxbcEmitFlowOp(DxbcOpcode::kDiscard, src, test);
}
void DxbcOpDiv(const DxbcDest& dest, const DxbcSrc& src0, const DxbcSrc& src1,
bool saturate = false) {
DxbcEmitAluOp(DxbcOpcode::kDiv, 0b00, dest, src0, src1, saturate);
++stat_.float_instruction_count;
}
void DxbcOpElse() {
shader_code_.push_back(DxbcOpcodeToken(DxbcOpcode::kElse, 0));
++stat_.instruction_count;
}
void DxbcOpEndIf() {
shader_code_.push_back(DxbcOpcodeToken(DxbcOpcode::kEndIf, 0));
++stat_.instruction_count;
@ -995,10 +1056,24 @@ class DxbcShaderTranslator : public ShaderTranslator {
shader_code_.push_back(DxbcOpcodeToken(DxbcOpcode::kEndSwitch, 0));
++stat_.instruction_count;
}
void DxbcOpEq(const DxbcDest& dest, const DxbcSrc& src0,
const DxbcSrc& src1) {
DxbcEmitAluOp(DxbcOpcode::kEq, 0b00, dest, src0, src1);
++stat_.float_instruction_count;
}
void DxbcOpFToI(const DxbcDest& dest, const DxbcSrc& src) {
DxbcEmitAluOp(DxbcOpcode::kFToI, 0b0, dest, src);
++stat_.conversion_instruction_count;
}
void DxbcOpFToU(const DxbcDest& dest, const DxbcSrc& src) {
DxbcEmitAluOp(DxbcOpcode::kFToU, 0b0, dest, src);
++stat_.conversion_instruction_count;
}
void DxbcOpGE(const DxbcDest& dest, const DxbcSrc& src0,
const DxbcSrc& src1) {
DxbcEmitAluOp(DxbcOpcode::kGE, 0b00, dest, src0, src1);
++stat_.float_instruction_count;
}
void DxbcOpIAdd(const DxbcDest& dest, const DxbcSrc& src0,
const DxbcSrc& src1) {
DxbcEmitAluOp(DxbcOpcode::kIAdd, 0b11, dest, src0, src1);
@ -1008,16 +1083,60 @@ class DxbcShaderTranslator : public ShaderTranslator {
DxbcEmitFlowOp(DxbcOpcode::kIf, src, test);
++stat_.dynamic_flow_control_count;
}
void DxbcOpIEq(const DxbcDest& dest, const DxbcSrc& src0,
const DxbcSrc& src1) {
DxbcEmitAluOp(DxbcOpcode::kIEq, 0b11, dest, src0, src1);
++stat_.int_instruction_count;
}
void DxbcOpILT(const DxbcDest& dest, const DxbcSrc& src0,
const DxbcSrc& src1) {
DxbcEmitAluOp(DxbcOpcode::kILT, 0b11, dest, src0, src1);
++stat_.int_instruction_count;
}
void DxbcOpIMAd(const DxbcDest& dest, const DxbcSrc& mul0,
const DxbcSrc& mul1, const DxbcSrc& add) {
DxbcEmitAluOp(DxbcOpcode::kIMAd, 0b111, dest, mul0, mul1, add);
++stat_.int_instruction_count;
}
void DxbcOpIMax(const DxbcDest& dest, const DxbcSrc& src0,
const DxbcSrc& src1) {
DxbcEmitAluOp(DxbcOpcode::kIMax, 0b11, dest, src0, src1);
++stat_.int_instruction_count;
}
void DxbcOpIMin(const DxbcDest& dest, const DxbcSrc& src0,
const DxbcSrc& src1) {
DxbcEmitAluOp(DxbcOpcode::kIMin, 0b11, dest, src0, src1);
++stat_.int_instruction_count;
}
void DxbcOpINE(const DxbcDest& dest, const DxbcSrc& src0,
const DxbcSrc& src1) {
DxbcEmitAluOp(DxbcOpcode::kINE, 0b11, dest, src0, src1);
++stat_.int_instruction_count;
}
void DxbcOpIShL(const DxbcDest& dest, const DxbcSrc& value,
const DxbcSrc& shift) {
DxbcEmitAluOp(DxbcOpcode::kIShL, 0b11, dest, value, shift);
++stat_.int_instruction_count;
}
void DxbcOpIToF(const DxbcDest& dest, const DxbcSrc& src) {
DxbcEmitAluOp(DxbcOpcode::kIToF, 0b1, dest, src);
++stat_.conversion_instruction_count;
}
void DxbcOpLabel(const DxbcSrc& label) {
// The label is source, not destination, for simplicity, to unify it will
// call/callc (in DXBC it's just a zero-component label operand).
uint32_t operands_length = label.GetLength(0b0000);
shader_code_.reserve(shader_code_.size() + 1 + operands_length);
shader_code_.push_back(
DxbcOpcodeToken(DxbcOpcode::kLabel, operands_length));
label.Write(shader_code_, true, 0b0000);
// Doesn't count towards stat_.instruction_count.
}
void DxbcOpLT(const DxbcDest& dest, const DxbcSrc& src0,
const DxbcSrc& src1) {
DxbcEmitAluOp(DxbcOpcode::kLT, 0b00, dest, src0, src1);
++stat_.float_instruction_count;
}
void DxbcOpMAd(const DxbcDest& dest, const DxbcSrc& mul0, const DxbcSrc& mul1,
const DxbcSrc& add, bool saturate = false) {
DxbcEmitAluOp(DxbcOpcode::kMAd, 0b000, dest, mul0, mul1, add, saturate);
@ -1050,10 +1169,43 @@ class DxbcShaderTranslator : public ShaderTranslator {
saturate);
++stat_.movc_instruction_count;
}
void DxbcOpMul(const DxbcDest& dest, const DxbcSrc& src0, const DxbcSrc& src1,
bool saturate = false) {
DxbcEmitAluOp(DxbcOpcode::kMul, 0b00, dest, src0, src1, saturate);
++stat_.float_instruction_count;
}
void DxbcOpNot(const DxbcDest& dest, const DxbcSrc& src) {
DxbcEmitAluOp(DxbcOpcode::kNot, 0b1, dest, src);
++stat_.uint_instruction_count;
}
void DxbcOpOr(const DxbcDest& dest, const DxbcSrc& src0,
const DxbcSrc& src1) {
DxbcEmitAluOp(DxbcOpcode::kOr, 0b11, dest, src0, src1);
++stat_.uint_instruction_count;
}
void DxbcOpRet() {
shader_code_.push_back(DxbcOpcodeToken(DxbcOpcode::kRet, 0));
++stat_.instruction_count;
++stat_.static_flow_control_count;
}
void DxbcOpRetC(bool test, const DxbcSrc& src) {
DxbcEmitFlowOp(DxbcOpcode::kRetC, src, test);
++stat_.dynamic_flow_control_count;
}
void DxbcOpRoundNE(const DxbcDest& dest, const DxbcSrc& src,
bool saturate = false) {
DxbcEmitAluOp(DxbcOpcode::kRoundNE, 0b0, dest, src, saturate);
++stat_.float_instruction_count;
}
void DxbcOpSwitch(const DxbcSrc& src) {
DxbcEmitFlowOp(DxbcOpcode::kSwitch, src);
++stat_.dynamic_flow_control_count;
}
void DxbcOpULT(const DxbcDest& dest, const DxbcSrc& src0,
const DxbcSrc& src1) {
DxbcEmitAluOp(DxbcOpcode::kULT, 0b11, dest, src0, src1);
++stat_.uint_instruction_count;
}
void DxbcOpUGE(const DxbcDest& dest, const DxbcSrc& src0,
const DxbcSrc& src1) {
DxbcEmitAluOp(DxbcOpcode::kUGE, 0b11, dest, src0, src1);
@ -1069,11 +1221,25 @@ class DxbcShaderTranslator : public ShaderTranslator {
DxbcEmitAluOp(DxbcOpcode::kUMAd, 0b111, dest, mul0, mul1, add);
++stat_.uint_instruction_count;
}
void DxbcOpUMax(const DxbcDest& dest, const DxbcSrc& src0,
const DxbcSrc& src1) {
DxbcEmitAluOp(DxbcOpcode::kUMax, 0b11, dest, src0, src1);
++stat_.uint_instruction_count;
}
void DxbcOpUMin(const DxbcDest& dest, const DxbcSrc& src0,
const DxbcSrc& src1) {
DxbcEmitAluOp(DxbcOpcode::kUMin, 0b11, dest, src0, src1);
++stat_.uint_instruction_count;
}
void DxbcOpUShR(const DxbcDest& dest, const DxbcSrc& value,
const DxbcSrc& shift) {
DxbcEmitAluOp(DxbcOpcode::kUShR, 0b11, dest, value, shift);
++stat_.uint_instruction_count;
}
void DxbcOpUToF(const DxbcDest& dest, const DxbcSrc& src) {
DxbcEmitAluOp(DxbcOpcode::kUToF, 0b1, dest, src);
++stat_.conversion_instruction_count;
}
void DxbcOpXOr(const DxbcDest& dest, const DxbcSrc& src0,
const DxbcSrc& src1) {
DxbcEmitAluOp(DxbcOpcode::kXOr, 0b11, dest, src0, src1);
@ -1099,6 +1265,18 @@ class DxbcShaderTranslator : public ShaderTranslator {
DxbcEmitAluOp(DxbcOpcode::kDerivRTYFine, 0b0, dest, src, saturate);
++stat_.float_instruction_count;
}
void DxbcOpF32ToF16(const DxbcDest& dest, const DxbcSrc& src) {
DxbcEmitAluOp(DxbcOpcode::kF32ToF16, 0b0, dest, src);
++stat_.conversion_instruction_count;
}
void DxbcOpF16ToF32(const DxbcDest& dest, const DxbcSrc& src) {
DxbcEmitAluOp(DxbcOpcode::kF16ToF32, 0b1, dest, src);
++stat_.conversion_instruction_count;
}
void DxbcOpFirstBitHi(const DxbcDest& dest, const DxbcSrc& src) {
DxbcEmitAluOp(DxbcOpcode::kFirstBitHi, 0b1, dest, src);
++stat_.uint_instruction_count;
}
void DxbcOpUBFE(const DxbcDest& dest, const DxbcSrc& width,
const DxbcSrc& offset, const DxbcSrc& src) {
DxbcEmitAluOp(DxbcOpcode::kUBFE, 0b111, dest, width, offset, src);
@ -1115,6 +1293,40 @@ class DxbcShaderTranslator : public ShaderTranslator {
DxbcEmitAluOp(DxbcOpcode::kBFI, 0b1111, dest, width, offset, from, to);
++stat_.uint_instruction_count;
}
void DxbcOpLdUAVTyped(const DxbcDest& dest, const DxbcSrc& address,
uint32_t address_components, const DxbcSrc& uav) {
uint32_t dest_write_mask = dest.GetMask();
uint32_t address_mask = (1 << address_components) - 1;
uint32_t operands_length = dest.GetLength() +
address.GetLength(address_mask, true) +
uav.GetLength(dest_write_mask, true);
shader_code_.reserve(shader_code_.size() + 1 + operands_length);
shader_code_.push_back(
DxbcOpcodeToken(DxbcOpcode::kLdUAVTyped, operands_length));
dest.Write(shader_code_);
address.Write(shader_code_, true, address_mask, true);
uav.Write(shader_code_, false, dest_write_mask, true);
++stat_.instruction_count;
++stat_.texture_load_instructions;
}
void DxbcOpStoreUAVTyped(const DxbcDest& dest, const DxbcSrc& address,
uint32_t address_components, const DxbcSrc& value) {
uint32_t dest_write_mask = dest.GetMask();
// Typed UAV writes don't support write masking.
assert_true(dest_write_mask == 0b1111);
uint32_t address_mask = (1 << address_components) - 1;
uint32_t operands_length = dest.GetLength() +
address.GetLength(address_mask, true) +
value.GetLength(dest_write_mask);
shader_code_.reserve(shader_code_.size() + 1 + operands_length);
shader_code_.push_back(
DxbcOpcodeToken(DxbcOpcode::kStoreUAVTyped, operands_length));
dest.Write(shader_code_);
address.Write(shader_code_, true, address_mask, true);
value.Write(shader_code_, false, dest_write_mask);
++stat_.instruction_count;
++stat_.c_texture_store_instructions;
}
void DxbcOpEvalSampleIndex(const DxbcDest& dest, const DxbcSrc& value,
const DxbcSrc& sample_index) {
uint32_t dest_write_mask = dest.GetMask();
@ -1125,8 +1337,8 @@ class DxbcShaderTranslator : public ShaderTranslator {
shader_code_.push_back(
DxbcOpcodeToken(DxbcOpcode::kEvalSampleIndex, operands_length));
dest.Write(shader_code_);
value.Write(shader_code_, dest_write_mask, false);
sample_index.Write(shader_code_, 0b0000, true);
value.Write(shader_code_, false, dest_write_mask);
sample_index.Write(shader_code_, true, 0b0000);
++stat_.instruction_count;
}
@ -1444,15 +1656,9 @@ class DxbcShaderTranslator : public ShaderTranslator {
// multiple times.
void ExportToMemory();
void CompleteVertexOrDomainShader();
// Applies the exponent bias from the constant to one color output.
void CompletePixelShader_ApplyColorExpBias(uint32_t rt_index);
// Discards the SSAA sample if it fails alpha to coverage.
void CompletePixelShader_WriteToRTVs_AlphaToCoverage();
void CompletePixelShader_WriteToRTVs();
// Returns if coverage in system_temp_rov_params_.x is empty.
void CompletePixelShader_ROV_CheckAnyCovered(
bool check_deferred_stencil_write, uint32_t temp,
uint32_t temp_component);
// Masks the sample away from system_temp_rov_params_.x if it's not covered.
void CompletePixelShader_ROV_AlphaToCoverageSample(uint32_t sample_index,
float threshold,

File diff suppressed because it is too large Load Diff

View File

@ -49,12 +49,21 @@ std::pair<std::string, std::string> Shader::Dump(const std::string& base_path,
xe::filesystem::CreateFolder(target_path);
}
char txt_file_name[kMaxPath];
std::snprintf(txt_file_name, xe::countof(txt_file_name),
"%s/shader_%s_%.16" PRIX64 ".%s", base_path.c_str(),
path_prefix, ucode_data_hash_,
shader_type_ == ShaderType::kVertex ? "vert" : "frag");
FILE* f = fopen(txt_file_name, "wb");
const std::string file_name_no_extension =
xe::format_string("%s/shader_%s_%.16" PRIX64, base_path.c_str(),
path_prefix, ucode_data_hash_);
std::string txt_file_name, bin_file_name;
if (shader_type_ == ShaderType::kVertex) {
txt_file_name = file_name_no_extension + ".vert";
bin_file_name = file_name_no_extension + ".bin.vert";
} else {
txt_file_name = file_name_no_extension + ".frag";
bin_file_name = file_name_no_extension + ".bin.frag";
}
FILE* f = fopen(txt_file_name.c_str(), "wb");
if (f) {
fwrite(translated_binary_.data(), 1, translated_binary_.size(), f);
fprintf(f, "\n\n");
@ -72,18 +81,13 @@ std::pair<std::string, std::string> Shader::Dump(const std::string& base_path,
fclose(f);
}
char bin_file_name[kMaxPath];
std::snprintf(bin_file_name, xe::countof(bin_file_name),
"%s/shader_%s_%.16" PRIX64 ".bin.%s", base_path.c_str(),
path_prefix, ucode_data_hash_,
shader_type_ == ShaderType::kVertex ? "vert" : "frag");
f = fopen(bin_file_name, "wb");
f = fopen(bin_file_name.c_str(), "wb");
if (f) {
fwrite(ucode_data_.data(), 4, ucode_data_.size(), f);
fclose(f);
}
return {std::string(txt_file_name), std::string(bin_file_name)};
return {std::move(txt_file_name), std::move(bin_file_name)};
}
} // namespace gpu

View File

@ -2,7 +2,7 @@
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2019 Ben Vanik. All rights reserved. *
* Copyright 2020 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/

View File

@ -19,12 +19,12 @@ project("xenia-hid-sdl")
filter("platforms:Windows")
-- On linux we build against the system version (libsdl2-dev)
includedirs({
project_root.."/third_party/SDL2/include/",
project_root.."/third_party/SDL2-devel-VC/include/",
})
libdirs({
project_root.."/third_party/SDL2/lib/x64/",
project_root.."/third_party/SDL2-devel-VC/lib/x64/",
})
-- Copy the dll to the output folder
postbuildcommands({
"{COPY} %{prj.basedir}/"..project_root.."/third_party/SDL2/lib/x64/SDL2.dll %{cfg.targetdir}",
"{COPY} %{prj.basedir}/"..project_root.."/third_party/SDL2-devel-VC/lib/x64/SDL2.dll %{cfg.targetdir}",
})

View File

@ -2,7 +2,7 @@
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2019 Ben Vanik. All rights reserved. *
* Copyright 2020 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/

View File

@ -2,7 +2,7 @@
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2019 Ben Vanik. All rights reserved. *
* Copyright 2020 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/

View File

@ -2,7 +2,7 @@
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2019 Ben Vanik. All rights reserved. *
* Copyright 2020 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/

View File

@ -2,7 +2,7 @@
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2019 Ben Vanik. All rights reserved. *
* Copyright 2020 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/

View File

@ -97,14 +97,13 @@ dword_result_t NtAllocateVirtualMemory(lpdword_t base_addr_ptr,
}
uint32_t page_size;
if (*base_addr_ptr != 0) {
// TODO(gibbed): ignore specified page size when base address is specified.
// ignore specified page size when base address is specified.
auto heap = kernel_memory()->LookupHeap(*base_addr_ptr);
page_size = heap->page_size();
} else {
// Adjust size.
page_size = 4096;
page_size = 4 * 1024;
if (alloc_type & X_MEM_LARGE_PAGES) {
page_size = 64 * 1024;
}

View File

@ -78,7 +78,7 @@ DECLARE_XBOXKRNL_EXPORT1(ObLookupThreadByThreadId, kNone, kImplemented);
dword_result_t ObReferenceObjectByHandle(dword_t handle,
dword_t object_type_ptr,
lpdword_t out_object_ptr) {
const std::pair<XObject::Type, uint32_t> obj_type_match[] = {
const static std::unordered_map<XObject::Type, uint32_t> obj_type_match = {
{XObject::kTypeEvent, 0xD00EBEEF},
{XObject::kTypeSemaphore, 0xD017BEEF},
{XObject::kTypeThread, 0xD01BBEEF}};
@ -90,16 +90,11 @@ dword_result_t ObReferenceObjectByHandle(dword_t handle,
}
uint32_t native_ptr = object->guest_object();
auto obj_type = obj_type_match.find(object->type());
auto obj_type = std::find_if(
std::begin(obj_type_match), std::end(obj_type_match),
[object](const auto& entry) { return entry.first == object->type(); });
if (obj_type != std::end(obj_type_match)) {
if (object_type_ptr) {
if (object_type_ptr != obj_type->second) {
return X_STATUS_OBJECT_TYPE_MISMATCH;
}
if (obj_type != obj_type_match.end()) {
if (object_type_ptr && object_type_ptr != obj_type->second) {
return X_STATUS_OBJECT_TYPE_MISMATCH;
}
} else {
assert_unhandled_case(object->type());

View File

@ -28,14 +28,14 @@ class UIEvent {
class FileDropEvent : public UIEvent {
public:
FileDropEvent(Window* target, wchar_t* filename)
FileDropEvent(Window* target, const wchar_t* filename)
: UIEvent(target), filename_(filename) {}
~FileDropEvent() override = default;
wchar_t* filename() const { return filename_; }
const wchar_t* filename() const { return filename_; }
private:
wchar_t* filename_ = nullptr;
const wchar_t* filename_ = nullptr;
};
class KeyEvent : public UIEvent {

View File

@ -492,16 +492,19 @@ LRESULT Win32Window::WndProc(HWND hWnd, UINT message, WPARAM wParam,
switch (message) {
case WM_DROPFILES: {
TCHAR lpszFile[MAX_PATH] = {0};
UINT uFiles = 0;
HDROP hDrop = (HDROP)wParam;
// Get number of files dropped
uFiles = DragQueryFile(hDrop, -1, NULL, NULL);
HDROP hDrop = reinterpret_cast<HDROP>(wParam);
std::wstring path;
// Only getting first file dropped (other files ignored)
if (DragQueryFile(hDrop, 0, lpszFile, MAX_PATH)) {
auto e = FileDropEvent(this, lpszFile);
OnFileDrop(&e);
// Get required buffer size
UINT buf_size = DragQueryFileW(hDrop, 0, nullptr, 0);
if (buf_size > 0) {
path.resize(buf_size + 1); // Give space for a null terminator
// Only getting first file dropped (other files ignored)
if (DragQueryFileW(hDrop, 0, &path[0], buf_size + 1)) {
auto e = FileDropEvent(this, path.c_str());
OnFileDrop(&e);
}
}
DragFinish(hDrop);

1
third_party/SDL2-devel-VC vendored Submodule

@ -0,0 +1 @@
Subproject commit f102d8b36395200682108e88bec54bf9acd1004a

View File

@ -649,7 +649,7 @@ class BaseBuildCommand(Command):
else:
result = subprocess.call([
'make',
'-j' if threads is 0 else '-j%d' % threads,
'-j' if threads == 0 else '-j%d' % threads,
'-Cbuild/',
'config=%s_linux' % (args['config']),
] + pass_args + args['target'], shell=False, env=dict(os.environ))