From 83ddf27392f460e4e060f35a6ee449b389a67cbc Mon Sep 17 00:00:00 2001 From: Sandy Carter Date: Wed, 14 Feb 2018 20:57:45 -0800 Subject: [PATCH 1/6] [Test] Fix build_bin_path for case sensitive FS Match xenia-build and premake configuration and platform capitalization with only first letter capitalized in filesystem (Debug, Checked, Released, Linux, Windows, etc). Fix xenia-build test command on linux systems. --- xenia-build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xenia-build b/xenia-build index 0882231a0..3a71853b3 100755 --- a/xenia-build +++ b/xenia-build @@ -389,7 +389,7 @@ def get_build_bin_path(args): platform = 'windows' else: platform = 'linux' - return os.path.join(self_path, 'build', 'bin', platform, args['config']) + return os.path.join(self_path, 'build', 'bin', platform.capitalize(), args['config'].capitalize()) def discover_commands(subparsers): From d75a372780f44c5e84526a45c379b267d23bb732 Mon Sep 17 00:00:00 2001 From: Triang3l Date: Sun, 5 Aug 2018 14:02:58 +0300 Subject: [PATCH 2/6] [GPU] Add info about unknown texture formats --- src/xenia/gpu/texture_info.h | 15 ++++++++++++--- src/xenia/gpu/texture_info_formats.cc | 8 ++++---- src/xenia/gpu/trace_viewer.cc | 4 ++-- src/xenia/gpu/vulkan/texture_config.cc | 5 ++--- src/xenia/gpu/xenos.h | 6 +++--- 5 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/xenia/gpu/texture_info.h b/src/xenia/gpu/texture_info.h index df81fb33a..34ebba279 100644 --- a/src/xenia/gpu/texture_info.h +++ b/src/xenia/gpu/texture_info.h @@ -19,7 +19,8 @@ namespace xe { namespace gpu { -// a2xx_sq_surfaceformat +// a2xx_sq_surfaceformat + D3D::GetGpuFormatFromEDRAMColorFormat::formatMap and +// FMT_ string table from game executables. enum class TextureFormat : uint32_t { k_1_REVERSE = 0, k_1 = 1, @@ -83,7 +84,8 @@ enum class TextureFormat : uint32_t { k_DXT5A = 59, k_CTX1 = 60, k_DXT3A_AS_1_1_1_1 = 61, - k_2_10_10_10_FLOAT = 62, + k_8_8_8_8_GAMMA = 62, + k_2_10_10_10_FLOAT = 63, kUnknown = 0xFFFFFFFFu, }; @@ -111,6 +113,8 @@ inline TextureFormat GetBaseFormat(TextureFormat texture_format) { return TextureFormat::k_10_11_11; case TextureFormat::k_11_11_10_AS_16_16_16_16: return TextureFormat::k_11_11_10; + case TextureFormat::k_8_8_8_8_GAMMA: + return TextureFormat::k_8_8_8_8; default: break; } @@ -208,6 +212,7 @@ inline bool IsSRGBCapable(TextureFormat format) { case TextureFormat::k_2_10_10_10_AS_16_16_16_16: case TextureFormat::k_10_11_11_AS_16_16_16_16: case TextureFormat::k_11_11_10_AS_16_16_16_16: + case TextureFormat::k_8_8_8_8_GAMMA: return true; default: return false; @@ -224,14 +229,18 @@ inline TextureFormat ColorRenderTargetToTextureFormat( case ColorRenderTargetFormat::k_8_8_8_8: return TextureFormat::k_8_8_8_8; case ColorRenderTargetFormat::k_8_8_8_8_GAMMA: - return TextureFormat::k_8_8_8_8; + return TextureFormat::k_8_8_8_8_GAMMA; case ColorRenderTargetFormat::k_2_10_10_10: return TextureFormat::k_2_10_10_10; case ColorRenderTargetFormat::k_2_10_10_10_FLOAT: return TextureFormat::k_2_10_10_10_FLOAT; case ColorRenderTargetFormat::k_16_16: + // TODO(Triang3l): Check if this needs to be k_Shadow according to + // GetGpuFormatFromEDRAMColorFormat. return TextureFormat::k_16_16; case ColorRenderTargetFormat::k_16_16_16_16: + // TODO(Triang3l): Check if this needs to be k_DXV according to + // GetGpuFormatFromEDRAMColorFormat. return TextureFormat::k_16_16_16_16; case ColorRenderTargetFormat::k_16_16_FLOAT: return TextureFormat::k_16_16_FLOAT; diff --git a/src/xenia/gpu/texture_info_formats.cc b/src/xenia/gpu/texture_info_formats.cc index 700a342e5..b4c1c47da 100644 --- a/src/xenia/gpu/texture_info_formats.cc +++ b/src/xenia/gpu/texture_info_formats.cc @@ -33,7 +33,7 @@ const FormatInfo* FormatInfo::Get(uint32_t gpu_format) { FORMAT_INFO(k_8_8 , kUncompressed, 1, 1, 16), FORMAT_INFO(k_Cr_Y1_Cb_Y0 , kCompressed , 2, 1, 16), FORMAT_INFO(k_Y1_Cr_Y0_Cb , kCompressed , 2, 1, 16), - FORMAT_INFO(kUnknown , kUncompressed, 0, 0, 0), // k_Shadow + FORMAT_INFO(k_Shadow , kUncompressed, 1, 1, 32), FORMAT_INFO(k_8_8_8_8_A , kUncompressed, 1, 1, 32), FORMAT_INFO(k_4_4_4_4 , kUncompressed, 1, 1, 16), FORMAT_INFO(k_10_11_11 , kUncompressed, 1, 1, 32), @@ -41,7 +41,7 @@ const FormatInfo* FormatInfo::Get(uint32_t gpu_format) { FORMAT_INFO(k_DXT1 , kCompressed , 4, 4, 4), FORMAT_INFO(k_DXT2_3 , kCompressed , 4, 4, 8), FORMAT_INFO(k_DXT4_5 , kCompressed , 4, 4, 8), - FORMAT_INFO(kUnknown , kUncompressed, 0, 0, 0), // k_DXV + FORMAT_INFO(k_DXV , kUncompressed, 1, 1, 64), FORMAT_INFO(k_24_8 , kUncompressed, 1, 1, 32), FORMAT_INFO(k_24_8_FLOAT , kUncompressed, 1, 1, 32), FORMAT_INFO(k_16 , kUncompressed, 1, 1, 16), @@ -82,8 +82,8 @@ const FormatInfo* FormatInfo::Get(uint32_t gpu_format) { FORMAT_INFO(k_DXT5A , kCompressed , 4, 4, 4), FORMAT_INFO(k_CTX1 , kCompressed , 4, 4, 4), FORMAT_INFO(k_DXT3A_AS_1_1_1_1 , kCompressed , 4, 4, 4), - FORMAT_INFO(kUnknown , kUncompressed, 0, 0, 0), // k_2_10_10_10_FLOAT - FORMAT_INFO(kUnknown , kUncompressed, 0, 0, 0), // invalid + FORMAT_INFO(k_8_8_8_8_GAMMA , kUncompressed, 1, 1, 32), + FORMAT_INFO(k_2_10_10_10_FLOAT , kUncompressed, 1, 1, 32), }; return &format_infos[gpu_format]; } diff --git a/src/xenia/gpu/trace_viewer.cc b/src/xenia/gpu/trace_viewer.cc index 22ebef73d..4e08e7081 100644 --- a/src/xenia/gpu/trace_viewer.cc +++ b/src/xenia/gpu/trace_viewer.cc @@ -990,9 +990,9 @@ static const char* kColorFormatNames[] = { /* 7 */ "k_16_16_16_16_FLOAT", /* 8 */ "unknown(8)", /* 9 */ "unknown(9)", - /* 10 */ "k_2_10_10_10_unknown", + /* 10 */ "k_2_10_10_10_AS_16_16_16_16", /* 11 */ "unknown(11)", - /* 12 */ "k_2_10_10_10_FLOAT_unknown", + /* 12 */ "k_2_10_10_10_FLOAT_AS_16_16_16_16", /* 13 */ "unknown(13)", /* 14 */ "k_32_FLOAT", /* 15 */ "k_32_32_FLOAT", diff --git a/src/xenia/gpu/vulkan/texture_config.cc b/src/xenia/gpu/vulkan/texture_config.cc index 321f9bff0..da3a25ce1 100644 --- a/src/xenia/gpu/vulkan/texture_config.cc +++ b/src/xenia/gpu/vulkan/texture_config.cc @@ -121,9 +121,8 @@ const TextureConfig texture_configs[64] = { /* k_DXT3A_AS_1_1_1_1 */ ___(UNDEFINED), - // Unused. - /* kUnknown */ ___(UNDEFINED), - /* kUnknown */ ___(UNDEFINED), + /* k_8_8_8_8_GAMMA */ ___(R8G8B8A8_UNORM), + /* k_2_10_10_10_FLOAT */ ___(UNDEFINED), }; #undef _cv diff --git a/src/xenia/gpu/xenos.h b/src/xenia/gpu/xenos.h index 256626e65..c02c3422f 100644 --- a/src/xenia/gpu/xenos.h +++ b/src/xenia/gpu/xenos.h @@ -185,9 +185,9 @@ enum class ColorFormat : uint32_t { k_32_FLOAT = 36, k_32_32_FLOAT = 37, k_32_32_32_32_FLOAT = 38, - k_2_10_10_10_FLOAT = 62, - - kUnknown0x36 = 0x36, // not sure, but like 8888 + k_2_10_10_10_AS_16_16_16_16 = 54, + k_8_8_8_8_GAMMA = 62, + k_2_10_10_10_FLOAT = 63, }; enum class VertexFormat : uint32_t { From 1a4fc3bde211b035368c77651099fa26c97336ed Mon Sep 17 00:00:00 2001 From: Triang3l Date: Sun, 19 Aug 2018 15:25:20 +0300 Subject: [PATCH 3/6] [GPU] Add texture signedness enumeration For sign_x, sign_y, sign_z and sign_w fields of xe_gpu_texture_fetch_t. --- src/xenia/gpu/xenos.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/xenia/gpu/xenos.h b/src/xenia/gpu/xenos.h index 256626e65..dc62a0f6e 100644 --- a/src/xenia/gpu/xenos.h +++ b/src/xenia/gpu/xenos.h @@ -63,6 +63,17 @@ enum class ClampMode : uint32_t { kMirrorClampToBorder = 7, }; +// TEX_FORMAT_COMP, known as GPUSIGN on the Xbox 360. +enum class TextureSign : uint32_t { + kUnsigned = 0, + // Two's complement texture data. + kSigned = 1, + // 2*color-1 - http://xboxforums.create.msdn.com/forums/t/107374.aspx + kUnsignedBiased = 2, + // Linearized when sampled. + kGamma = 3, +}; + enum class TextureFilter : uint32_t { kPoint = 0, kLinear = 1, From 37e59464c2d8f84ac59d86b73a6eb86569b06df3 Mon Sep 17 00:00:00 2001 From: "Dr. Chat" Date: Mon, 10 Sep 2018 20:06:16 -0500 Subject: [PATCH 4/6] [UI] Undo warning fix in file_picker_win.cc --- src/xenia/ui/file_picker_win.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/xenia/ui/file_picker_win.cc b/src/xenia/ui/file_picker_win.cc index f97c828cd..cf8e95e88 100644 --- a/src/xenia/ui/file_picker_win.cc +++ b/src/xenia/ui/file_picker_win.cc @@ -36,9 +36,9 @@ class CDialogEventHandler : public IFileDialogEvents, IFACEMETHODIMP QueryInterface(REFIID riid, void** ppv) { static const QITAB qit[] = { {&__uuidof(IFileDialogEvents), - OFFSETOFCLASS(IFileDialogEvents, CDialogEventHandler)}, + (int)OFFSETOFCLASS(IFileDialogEvents, CDialogEventHandler)}, {&__uuidof(IFileDialogControlEvents), - OFFSETOFCLASS(IFileDialogControlEvents, CDialogEventHandler)}, + (int)OFFSETOFCLASS(IFileDialogControlEvents, CDialogEventHandler)}, {0}, }; return QISearch(this, qit, riid, ppv); From 67f0e487f4b545b2ce3c2b130f5af0a6917b4597 Mon Sep 17 00:00:00 2001 From: emoose Date: Mon, 22 Oct 2018 18:00:01 +0100 Subject: [PATCH 5/6] [Kernel] Fix _snwprintf not having format_core wide = true --- src/xenia/kernel/xboxkrnl/xboxkrnl_strings.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/xenia/kernel/xboxkrnl/xboxkrnl_strings.cc b/src/xenia/kernel/xboxkrnl/xboxkrnl_strings.cc index d5ef2d661..2ea47d5d9 100644 --- a/src/xenia/kernel/xboxkrnl/xboxkrnl_strings.cc +++ b/src/xenia/kernel/xboxkrnl/xboxkrnl_strings.cc @@ -925,7 +925,7 @@ SHIM_CALL _snwprintf_shim(PPCContext* ppc_context, KernelState* kernel_state) { StackArgList args(ppc_context, 3); WideStringFormatData data(format); - int32_t count = format_core(ppc_context, data, args, false); + int32_t count = format_core(ppc_context, data, args, true); if (count < 0) { if (buffer_count > 0) { buffer[0] = '\0'; // write a null, just to be safe From bf039172cfc06716e90030fcbbe042e2c9f87499 Mon Sep 17 00:00:00 2001 From: emoose Date: Mon, 22 Oct 2018 18:01:09 +0100 Subject: [PATCH 6/6] [Kernel] Add null pointer checks to xmp_app handlers --- src/xenia/kernel/xam/apps/xmp_app.cc | 78 ++++++++++++++++------------ 1 file changed, 46 insertions(+), 32 deletions(-) diff --git a/src/xenia/kernel/xam/apps/xmp_app.cc b/src/xenia/kernel/xam/apps/xmp_app.cc index 320e893a1..ec02f6acf 100644 --- a/src/xenia/kernel/xam/apps/xmp_app.cc +++ b/src/xenia/kernel/xam/apps/xmp_app.cc @@ -55,34 +55,41 @@ X_RESULT XmpApp::XMPCreateTitlePlaylist(uint32_t songs_ptr, uint32_t song_count, playlist->handle = ++next_playlist_handle_; playlist->name = std::move(playlist_name); playlist->flags = flags; - for (uint32_t i = 0; i < song_count; ++i) { - auto song = std::make_unique(); - song->handle = ++next_song_handle_; - uint8_t* song_base = memory_->TranslateVirtual(songs_ptr + (i * 36)); - song->file_path = xe::load_and_swap( - memory_->TranslateVirtual(xe::load_and_swap(song_base + 0))); - song->name = xe::load_and_swap( - memory_->TranslateVirtual(xe::load_and_swap(song_base + 4))); - song->artist = xe::load_and_swap( - memory_->TranslateVirtual(xe::load_and_swap(song_base + 8))); - song->album = xe::load_and_swap( - memory_->TranslateVirtual(xe::load_and_swap(song_base + 12))); - song->album_artist = xe::load_and_swap( - memory_->TranslateVirtual(xe::load_and_swap(song_base + 16))); - song->genre = xe::load_and_swap( - memory_->TranslateVirtual(xe::load_and_swap(song_base + 20))); - song->track_number = xe::load_and_swap(song_base + 24); - song->duration_ms = xe::load_and_swap(song_base + 28); - song->format = - static_cast(xe::load_and_swap(song_base + 32)); - if (out_song_handles) { - xe::store_and_swap( - memory_->TranslateVirtual(out_song_handles + (i * 4)), song->handle); + if (songs_ptr) { + for (uint32_t i = 0; i < song_count; ++i) { + auto song = std::make_unique(); + song->handle = ++next_song_handle_; + uint8_t* song_base = memory_->TranslateVirtual(songs_ptr + (i * 36)); + song->file_path = + xe::load_and_swap(memory_->TranslateVirtual( + xe::load_and_swap(song_base + 0))); + song->name = xe::load_and_swap(memory_->TranslateVirtual( + xe::load_and_swap(song_base + 4))); + song->artist = xe::load_and_swap(memory_->TranslateVirtual( + xe::load_and_swap(song_base + 8))); + song->album = xe::load_and_swap(memory_->TranslateVirtual( + xe::load_and_swap(song_base + 12))); + song->album_artist = + xe::load_and_swap(memory_->TranslateVirtual( + xe::load_and_swap(song_base + 16))); + song->genre = xe::load_and_swap(memory_->TranslateVirtual( + xe::load_and_swap(song_base + 20))); + song->track_number = xe::load_and_swap(song_base + 24); + song->duration_ms = xe::load_and_swap(song_base + 28); + song->format = static_cast( + xe::load_and_swap(song_base + 32)); + if (out_song_handles) { + xe::store_and_swap( + memory_->TranslateVirtual(out_song_handles + (i * 4)), + song->handle); + } + playlist->songs.emplace_back(std::move(song)); } - playlist->songs.emplace_back(std::move(song)); } - xe::store_and_swap(memory_->TranslateVirtual(out_playlist_handle), - playlist->handle); + if (out_playlist_handle) { + xe::store_and_swap(memory_->TranslateVirtual(out_playlist_handle), + playlist->handle); + } auto global_lock = global_critical_region_.Acquire(); playlists_.insert({playlist->handle, playlist.get()}); @@ -404,12 +411,19 @@ X_RESULT XmpApp::DispatchMessageSync(uint32_t message, uint32_t buffer_ptr, assert_true(xmp_client == 0x00000002); XELOGD("XMPGetPlaybackBehavior(%.8X, %.8X, %.8X)", playback_mode_ptr, repeat_mode_ptr, unk3_ptr); - xe::store_and_swap(memory_->TranslateVirtual(playback_mode_ptr), - static_cast(playback_mode_)); - xe::store_and_swap(memory_->TranslateVirtual(repeat_mode_ptr), - static_cast(repeat_mode_)); - xe::store_and_swap(memory_->TranslateVirtual(unk3_ptr), - unknown_flags_); + if (playback_mode_ptr) { + xe::store_and_swap( + memory_->TranslateVirtual(playback_mode_ptr), + static_cast(playback_mode_)); + } + if (repeat_mode_ptr) { + xe::store_and_swap(memory_->TranslateVirtual(repeat_mode_ptr), + static_cast(repeat_mode_)); + } + if (unk3_ptr) { + xe::store_and_swap(memory_->TranslateVirtual(unk3_ptr), + unknown_flags_); + } return X_ERROR_SUCCESS; } case 0x0007002E: {