From 10db913ca2caf3150c5007acd76839ff53145b56 Mon Sep 17 00:00:00 2001 From: Gliniak Date: Thu, 17 Sep 2020 18:15:56 +0200 Subject: [PATCH 1/3] [Kernel/Xam] XNotifyGetNext - Overall improvements --- src/xenia/kernel/xam/xam_notify.cc | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/xenia/kernel/xam/xam_notify.cc b/src/xenia/kernel/xam/xam_notify.cc index a45b29bdf..b5b0a44d0 100644 --- a/src/xenia/kernel/xam/xam_notify.cc +++ b/src/xenia/kernel/xam/xam_notify.cc @@ -42,15 +42,19 @@ DECLARE_XAM_EXPORT1(XamNotifyCreateListener, kNone, kImplemented); // https://github.com/CodeAsm/ffplay360/blob/master/Common/AtgSignIn.cpp dword_result_t XNotifyGetNext(dword_t handle, dword_t match_id, lpdword_t id_ptr, lpdword_t param_ptr) { - if (!handle) { - return 0; + if (param_ptr) { + *param_ptr = 0; } + if (!id_ptr) { + return X_ERROR_INVALID_PARAMETER; + } + *id_ptr = 0; // Grab listener. auto listener = kernel_state()->object_table()->LookupObject(handle); if (!listener) { - return 0; + return X_ERROR_INVALID_HANDLE; } bool dequeued = false; @@ -65,21 +69,13 @@ dword_result_t XNotifyGetNext(dword_t handle, dword_t match_id, dequeued = listener->DequeueNotification(&id, ¶m); } + *id_ptr = dequeued ? id : 0; // param_ptr may be null - Ghost Recon Advanced Warfighter 2 Demo explicitly // passes nullptr in the code. // https://github.com/xenia-project/xenia/pull/1577 - if (dequeued) { - *id_ptr = id; - if (param_ptr) { - *param_ptr = param; - } - } else { - *id_ptr = 0; - if (param_ptr) { - *param_ptr = 0; - } + if (param_ptr) { + *param_ptr = dequeued ? param : 0; } - return dequeued ? 1 : 0; } DECLARE_XAM_EXPORT2(XNotifyGetNext, kNone, kImplemented, kHighFrequency); From 2b8f347b0b049f3fdce36c7b0a098e684e2c75ab Mon Sep 17 00:00:00 2001 From: gibbed Date: Mon, 26 Oct 2020 16:03:30 -0500 Subject: [PATCH 2/3] [XAM] Stub xuids usage xeXamUserReadProfileSettingsEx. [XAM] Stub valid xuids usage xeXamUserReadProfileSettingsEx. --- src/xenia/kernel/xam/xam_user.cc | 34 +++++++++++++++++++------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/src/xenia/kernel/xam/xam_user.cc b/src/xenia/kernel/xam/xam_user.cc index 16c8dba51..02dda8d2e 100644 --- a/src/xenia/kernel/xam/xam_user.cc +++ b/src/xenia/kernel/xam/xam_user.cc @@ -137,14 +137,21 @@ static_assert_size(X_USER_READ_PROFILE_SETTING, 40); // https://github.com/oukiar/freestyledash/blob/master/Freestyle/Tools/Generic/xboxtools.cpp uint32_t xeXamUserReadProfileSettingsEx(uint32_t title_id, uint32_t user_index, - uint32_t xuid_count, lpvoid_t xuids_ptr, + uint32_t xuid_count, lpqword_t xuids, uint32_t setting_count, lpdword_t setting_ids, uint32_t unk, lpdword_t buffer_size_ptr, lpvoid_t buffer_ptr, uint32_t overlapped_ptr) { - assert_zero(xuid_count); - assert_zero(xuids_ptr.value()); + if (!xuid_count) { + assert_null(xuids); + } else { + assert_true(xuid_count == 1); + assert_not_null(xuids); + // TODO(gibbed): allow proper lookup of arbitrary XUIDs + const auto& user_profile = kernel_state()->user_profile(); + assert_true(static_cast(xuids[0]) == user_profile->xuid()); + } assert_zero(unk); // must have at least 1 to 32 settings @@ -180,7 +187,7 @@ uint32_t xeXamUserReadProfileSettingsEx(uint32_t title_id, uint32_t user_index, } } } - if (xuids_ptr) { + if (xuids) { // needed_header_size *= xuid_count; // needed_extra_size *= !xuid_count; } @@ -276,22 +283,21 @@ uint32_t xeXamUserReadProfileSettingsEx(uint32_t title_id, uint32_t user_index, } dword_result_t XamUserReadProfileSettings( - dword_t title_id, dword_t user_index, dword_t xuid_count, - lpvoid_t xuids_ptr, dword_t setting_count, lpdword_t setting_ids, - lpdword_t buffer_size_ptr, lpvoid_t buffer_ptr, dword_t overlapped_ptr) { + dword_t title_id, dword_t user_index, dword_t xuid_count, lpqword_t xuids, + dword_t setting_count, lpdword_t setting_ids, lpdword_t buffer_size_ptr, + lpvoid_t buffer_ptr, dword_t overlapped_ptr) { return xeXamUserReadProfileSettingsEx( - title_id, user_index, xuid_count, xuids_ptr, setting_count, setting_ids, - 0, buffer_size_ptr, buffer_ptr, overlapped_ptr); + title_id, user_index, xuid_count, xuids, setting_count, setting_ids, 0, + buffer_size_ptr, buffer_ptr, overlapped_ptr); } DECLARE_XAM_EXPORT1(XamUserReadProfileSettings, kUserProfiles, kImplemented); dword_result_t XamUserReadProfileSettingsEx( - dword_t title_id, dword_t user_index, dword_t xuid_count, - lpvoid_t xuids_ptr, dword_t setting_count, lpdword_t setting_ids, - lpdword_t buffer_size_ptr, dword_t unk_2, lpvoid_t buffer_ptr, - dword_t overlapped_ptr) { + dword_t title_id, dword_t user_index, dword_t xuid_count, lpqword_t xuids, + dword_t setting_count, lpdword_t setting_ids, lpdword_t buffer_size_ptr, + dword_t unk_2, lpvoid_t buffer_ptr, dword_t overlapped_ptr) { return xeXamUserReadProfileSettingsEx( - title_id, user_index, xuid_count, xuids_ptr, setting_count, setting_ids, + title_id, user_index, xuid_count, xuids, setting_count, setting_ids, unk_2, buffer_size_ptr, buffer_ptr, overlapped_ptr); } DECLARE_XAM_EXPORT1(XamUserReadProfileSettingsEx, kUserProfiles, kImplemented); From 9bbe4365d13a5297747518d0292d1833d86082ab Mon Sep 17 00:00:00 2001 From: Triang3l Date: Tue, 27 Oct 2020 21:01:55 +0300 Subject: [PATCH 3/3] [GPU] Fix adaptive quad tessellation inside factors --- .../gpu/d3d12/shaders/adaptive_quad.hs.hlsl | 6 ++- .../d3d12/shaders/dxbc/adaptive_quad_hs.cso | Bin 3896 -> 3924 bytes .../gpu/d3d12/shaders/dxbc/adaptive_quad_hs.h | 42 +++++++++--------- .../d3d12/shaders/dxbc/adaptive_quad_hs.txt | 9 ++-- 4 files changed, 31 insertions(+), 26 deletions(-) diff --git a/src/xenia/gpu/d3d12/shaders/adaptive_quad.hs.hlsl b/src/xenia/gpu/d3d12/shaders/adaptive_quad.hs.hlsl index 6e27fe80e..e84d11cb2 100644 --- a/src/xenia/gpu/d3d12/shaders/adaptive_quad.hs.hlsl +++ b/src/xenia/gpu/d3d12/shaders/adaptive_quad.hs.hlsl @@ -39,11 +39,13 @@ XeHSConstantDataOutput XePatchConstant( xe_tessellation_factor_range.x, xe_tessellation_factor_range.y); } + // On the Xbox 360, according to the presentation, the inside factor is the + // minimum of the factors of the edges along the axis. // Direct3D 12: // [0] - along U. // [1] - along V. - output.inside[0u] = min(output.edges[0u], output.edges[2u]); - output.inside[1u] = min(output.edges[1u], output.edges[3u]); + output.inside[0u] = min(output.edges[1u], output.edges[3u]); + output.inside[1u] = min(output.edges[0u], output.edges[2u]); return output; } diff --git a/src/xenia/gpu/d3d12/shaders/dxbc/adaptive_quad_hs.cso b/src/xenia/gpu/d3d12/shaders/dxbc/adaptive_quad_hs.cso index fe88e8054b3d66d4a481f5a67030eba44a1dfa52..d70d8e09634defa8cb910957bf84f7678349dcc7 100644 GIT binary patch delta 171 zcmdlXcSTOpCBn%$bDm_XubD5~$CJC4b}>ZGV`N}p2$?7;&A4Nu>3MF>4NMFSfeg$H zYc})pm@_HLF)*+TF$e(FFfed6Fg7>>X+{Si2GYhrA)(2Ud}>N8N(dzkW*{vJ7Z_N8 pN~B=olPB^COY?&?12G720x?Jh&^nOV(|>pCmz7Z}o?-lHyg%jtGBPkQSWJ|ZW}LIp^gK7`6eb3SKn7-p zrJH$q%$Y>Z7#LWD7zBW77#O%37#WO#l+xr>J~cIVA%zPJEFfX1v=o%KV_;wm4si^b g0+i#Me2`C=6=VhDWJiAC$shP+CQe|P%){>i04SRrIRF3v diff --git a/src/xenia/gpu/d3d12/shaders/dxbc/adaptive_quad_hs.h b/src/xenia/gpu/d3d12/shaders/dxbc/adaptive_quad_hs.h index 84a5d315c..b3e54f890 100644 --- a/src/xenia/gpu/d3d12/shaders/dxbc/adaptive_quad_hs.h +++ b/src/xenia/gpu/d3d12/shaders/dxbc/adaptive_quad_hs.h @@ -1,11 +1,11 @@ // generated from `xb buildhlsl` // source: adaptive_quad.hs.hlsl const uint8_t adaptive_quad_hs[] = { - 0x44, 0x58, 0x42, 0x43, 0x09, 0x4F, 0xBB, 0x85, 0xF4, 0xA9, 0x5A, 0x24, - 0x49, 0x56, 0x0F, 0x66, 0x0D, 0xF9, 0x1F, 0xFD, 0x01, 0x00, 0x00, 0x00, - 0x38, 0x0F, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, + 0x44, 0x58, 0x42, 0x43, 0x69, 0x9E, 0x19, 0x65, 0x4D, 0x36, 0x4D, 0x06, + 0xF1, 0xC9, 0xBB, 0xA5, 0x8A, 0x00, 0x59, 0x9E, 0x01, 0x00, 0x00, 0x00, + 0x54, 0x0F, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0xD4, 0x0A, 0x00, 0x00, 0x08, 0x0B, 0x00, 0x00, 0x3C, 0x0B, 0x00, 0x00, - 0x00, 0x0C, 0x00, 0x00, 0x9C, 0x0E, 0x00, 0x00, 0x52, 0x44, 0x45, 0x46, + 0x00, 0x0C, 0x00, 0x00, 0xB8, 0x0E, 0x00, 0x00, 0x52, 0x44, 0x45, 0x46, 0x94, 0x0A, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x01, 0x05, 0x53, 0x48, 0x00, 0x05, 0x00, 0x00, 0x6A, 0x0A, 0x00, 0x00, 0x13, 0x13, 0x44, 0x25, @@ -257,8 +257,8 @@ const uint8_t adaptive_quad_hs[] = { 0x53, 0x56, 0x5F, 0x54, 0x65, 0x73, 0x73, 0x46, 0x61, 0x63, 0x74, 0x6F, 0x72, 0x00, 0x53, 0x56, 0x5F, 0x49, 0x6E, 0x73, 0x69, 0x64, 0x65, 0x54, 0x65, 0x73, 0x73, 0x46, 0x61, 0x63, 0x74, 0x6F, 0x72, 0x00, 0xAB, 0xAB, - 0x53, 0x48, 0x45, 0x58, 0x94, 0x02, 0x00, 0x00, 0x51, 0x00, 0x03, 0x00, - 0xA5, 0x00, 0x00, 0x00, 0x71, 0x00, 0x00, 0x01, 0x93, 0x20, 0x00, 0x01, + 0x53, 0x48, 0x45, 0x58, 0xB0, 0x02, 0x00, 0x00, 0x51, 0x00, 0x03, 0x00, + 0xAC, 0x00, 0x00, 0x00, 0x71, 0x00, 0x00, 0x01, 0x93, 0x20, 0x00, 0x01, 0x94, 0x20, 0x00, 0x01, 0x95, 0x18, 0x00, 0x01, 0x96, 0x20, 0x00, 0x01, 0x97, 0x18, 0x00, 0x01, 0x6A, 0x08, 0x00, 0x01, 0x59, 0x00, 0x00, 0x07, 0x46, 0x8E, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -305,25 +305,27 @@ const uint8_t adaptive_quad_hs[] = { 0x68, 0x00, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, 0x5B, 0x00, 0x00, 0x04, 0x12, 0x20, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x5B, 0x00, 0x00, 0x04, 0x12, 0xB0, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x04, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x04, 0x12, 0x00, 0x10, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x0A, 0x80, 0x01, 0x00, 0x33, 0x00, 0x00, 0x0A, - 0x22, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0xB0, 0x91, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x07, 0x12, 0x00, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x0A, 0x80, 0x01, 0x80, 0x41, 0x00, 0x00, 0x00, + 0x01, 0x40, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x0A, + 0x12, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0xB0, 0x91, 0x00, 0x0A, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0xB0, 0xD1, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x36, 0x00, 0x00, 0x07, 0x12, 0x20, 0xD0, 0x00, 0x04, 0x00, 0x00, 0x00, - 0x0A, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1A, 0x00, 0x10, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x01, 0x53, 0x54, 0x41, 0x54, - 0x94, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x36, 0x00, 0x00, 0x04, 0x22, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x0A, 0x80, 0x01, 0x00, 0x36, 0x00, 0x00, 0x07, 0x12, 0x20, 0xD0, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x1A, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x0A, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x01, + 0x53, 0x54, 0x41, 0x54, 0x94, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x0B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x0B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, - 0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; diff --git a/src/xenia/gpu/d3d12/shaders/dxbc/adaptive_quad_hs.txt b/src/xenia/gpu/d3d12/shaders/dxbc/adaptive_quad_hs.txt index 398da84c6..6e2b041b8 100644 --- a/src/xenia/gpu/d3d12/shaders/dxbc/adaptive_quad_hs.txt +++ b/src/xenia/gpu/d3d12/shaders/dxbc/adaptive_quad_hs.txt @@ -127,8 +127,9 @@ dcl_output_siv o5.x, finalQuadVInsideTessFactor dcl_temps 1 dcl_indexrange o4.x 2 dcl_indexrange vpc0.x 4 -mov r0.x, vJoinInstanceID.x -min r0.y, vpc[r0.x + 0].x, vpc[r0.x + 2].x -mov o[r0.x + 4].x, r0.y +iadd r0.x, -vJoinInstanceID.x, l(1) +min r0.x, vpc[r0.x + 0].x, vpc[r0.x + 2].x +mov r0.y, vJoinInstanceID.x +mov o[r0.y + 4].x, r0.x ret -// Approximately 14 instruction slots used +// Approximately 15 instruction slots used