diff options
| author | 2019-01-07 12:59:33 -0500 | |
|---|---|---|
| committer | 2019-01-07 12:59:33 -0500 | |
| commit | 17a68e5ebe206b75abc5e994ca1bd24539a100f9 (patch) | |
| tree | b15abff9037dd59e9749397a3f3c8d8466d356c9 /src | |
| parent | Merge pull request #1992 from DarkLordZach/move-profile-manager-ui (diff) | |
| parent | service/vi: Correct scaling mode conversions (diff) | |
| download | yuzu-17a68e5ebe206b75abc5e994ca1bd24539a100f9.tar.gz yuzu-17a68e5ebe206b75abc5e994ca1bd24539a100f9.tar.xz yuzu-17a68e5ebe206b75abc5e994ca1bd24539a100f9.zip | |
Merge pull request #1989 from lioncash/set
service/vi: Unstub IApplicationDisplayService's SetLayerScalingMode
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/service/vi/vi.cpp | 97 |
1 files changed, 58 insertions, 39 deletions
diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp index 1bdf19e13..70c933934 100644 --- a/src/core/hle/service/vi/vi.cpp +++ b/src/core/hle/service/vi/vi.cpp | |||
| @@ -32,6 +32,9 @@ | |||
| 32 | 32 | ||
| 33 | namespace Service::VI { | 33 | namespace Service::VI { |
| 34 | 34 | ||
| 35 | constexpr ResultCode ERR_OPERATION_FAILED{ErrorModule::VI, 1}; | ||
| 36 | constexpr ResultCode ERR_UNSUPPORTED{ErrorModule::VI, 6}; | ||
| 37 | |||
| 35 | struct DisplayInfo { | 38 | struct DisplayInfo { |
| 36 | /// The name of this particular display. | 39 | /// The name of this particular display. |
| 37 | char display_name[0x40]{"Default"}; | 40 | char display_name[0x40]{"Default"}; |
| @@ -874,6 +877,22 @@ public: | |||
| 874 | ~IApplicationDisplayService() = default; | 877 | ~IApplicationDisplayService() = default; |
| 875 | 878 | ||
| 876 | private: | 879 | private: |
| 880 | enum class ConvertedScaleMode : u64 { | ||
| 881 | Freeze = 0, | ||
| 882 | ScaleToWindow = 1, | ||
| 883 | ScaleAndCrop = 2, | ||
| 884 | None = 3, | ||
| 885 | PreserveAspectRatio = 4, | ||
| 886 | }; | ||
| 887 | |||
| 888 | enum class NintendoScaleMode : u32 { | ||
| 889 | None = 0, | ||
| 890 | Freeze = 1, | ||
| 891 | ScaleToWindow = 2, | ||
| 892 | ScaleAndCrop = 3, | ||
| 893 | PreserveAspectRatio = 4, | ||
| 894 | }; | ||
| 895 | |||
| 877 | void GetRelayService(Kernel::HLERequestContext& ctx) { | 896 | void GetRelayService(Kernel::HLERequestContext& ctx) { |
| 878 | LOG_WARNING(Service_VI, "(STUBBED) called"); | 897 | LOG_WARNING(Service_VI, "(STUBBED) called"); |
| 879 | 898 | ||
| @@ -974,13 +993,27 @@ private: | |||
| 974 | 993 | ||
| 975 | void SetLayerScalingMode(Kernel::HLERequestContext& ctx) { | 994 | void SetLayerScalingMode(Kernel::HLERequestContext& ctx) { |
| 976 | IPC::RequestParser rp{ctx}; | 995 | IPC::RequestParser rp{ctx}; |
| 977 | const u32 scaling_mode = rp.Pop<u32>(); | 996 | const auto scaling_mode = rp.PopEnum<NintendoScaleMode>(); |
| 978 | const u64 unknown = rp.Pop<u64>(); | 997 | const u64 unknown = rp.Pop<u64>(); |
| 979 | 998 | ||
| 980 | LOG_WARNING(Service_VI, "(STUBBED) called. scaling_mode=0x{:08X}, unknown=0x{:016X}", | 999 | LOG_DEBUG(Service_VI, "called. scaling_mode=0x{:08X}, unknown=0x{:016X}", |
| 981 | scaling_mode, unknown); | 1000 | static_cast<u32>(scaling_mode), unknown); |
| 982 | 1001 | ||
| 983 | IPC::ResponseBuilder rb{ctx, 2}; | 1002 | IPC::ResponseBuilder rb{ctx, 2}; |
| 1003 | |||
| 1004 | if (scaling_mode > NintendoScaleMode::PreserveAspectRatio) { | ||
| 1005 | LOG_ERROR(Service_VI, "Invalid scaling mode provided."); | ||
| 1006 | rb.Push(ERR_OPERATION_FAILED); | ||
| 1007 | return; | ||
| 1008 | } | ||
| 1009 | |||
| 1010 | if (scaling_mode != NintendoScaleMode::ScaleToWindow && | ||
| 1011 | scaling_mode != NintendoScaleMode::PreserveAspectRatio) { | ||
| 1012 | LOG_ERROR(Service_VI, "Unsupported scaling mode supplied."); | ||
| 1013 | rb.Push(ERR_UNSUPPORTED); | ||
| 1014 | return; | ||
| 1015 | } | ||
| 1016 | |||
| 984 | rb.Push(RESULT_SUCCESS); | 1017 | rb.Push(RESULT_SUCCESS); |
| 985 | } | 1018 | } |
| 986 | 1019 | ||
| @@ -1061,51 +1094,37 @@ private: | |||
| 1061 | rb.PushCopyObjects(vsync_event); | 1094 | rb.PushCopyObjects(vsync_event); |
| 1062 | } | 1095 | } |
| 1063 | 1096 | ||
| 1064 | enum class ConvertedScaleMode : u64 { | ||
| 1065 | None = 0, // VI seems to name this as "Unknown" but lots of games pass it, assume it's no | ||
| 1066 | // scaling/default | ||
| 1067 | Freeze = 1, | ||
| 1068 | ScaleToWindow = 2, | ||
| 1069 | Crop = 3, | ||
| 1070 | NoCrop = 4, | ||
| 1071 | }; | ||
| 1072 | |||
| 1073 | // This struct is different, currently it's 1:1 but this might change in the future. | ||
| 1074 | enum class NintendoScaleMode : u32 { | ||
| 1075 | None = 0, | ||
| 1076 | Freeze = 1, | ||
| 1077 | ScaleToWindow = 2, | ||
| 1078 | Crop = 3, | ||
| 1079 | NoCrop = 4, | ||
| 1080 | }; | ||
| 1081 | |||
| 1082 | void ConvertScalingMode(Kernel::HLERequestContext& ctx) { | 1097 | void ConvertScalingMode(Kernel::HLERequestContext& ctx) { |
| 1083 | IPC::RequestParser rp{ctx}; | 1098 | IPC::RequestParser rp{ctx}; |
| 1084 | auto mode = rp.PopEnum<NintendoScaleMode>(); | 1099 | const auto mode = rp.PopEnum<NintendoScaleMode>(); |
| 1085 | LOG_DEBUG(Service_VI, "called mode={}", static_cast<u32>(mode)); | 1100 | LOG_DEBUG(Service_VI, "called mode={}", static_cast<u32>(mode)); |
| 1086 | 1101 | ||
| 1087 | IPC::ResponseBuilder rb{ctx, 4}; | 1102 | const auto converted_mode = ConvertScalingModeImpl(mode); |
| 1088 | rb.Push(RESULT_SUCCESS); | 1103 | |
| 1104 | if (converted_mode.Succeeded()) { | ||
| 1105 | IPC::ResponseBuilder rb{ctx, 4}; | ||
| 1106 | rb.Push(RESULT_SUCCESS); | ||
| 1107 | rb.PushEnum(*converted_mode); | ||
| 1108 | } else { | ||
| 1109 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 1110 | rb.Push(converted_mode.Code()); | ||
| 1111 | } | ||
| 1112 | } | ||
| 1113 | |||
| 1114 | static ResultVal<ConvertedScaleMode> ConvertScalingModeImpl(NintendoScaleMode mode) { | ||
| 1089 | switch (mode) { | 1115 | switch (mode) { |
| 1090 | case NintendoScaleMode::None: | 1116 | case NintendoScaleMode::None: |
| 1091 | rb.PushEnum(ConvertedScaleMode::None); | 1117 | return MakeResult(ConvertedScaleMode::None); |
| 1092 | break; | ||
| 1093 | case NintendoScaleMode::Freeze: | 1118 | case NintendoScaleMode::Freeze: |
| 1094 | rb.PushEnum(ConvertedScaleMode::Freeze); | 1119 | return MakeResult(ConvertedScaleMode::Freeze); |
| 1095 | break; | ||
| 1096 | case NintendoScaleMode::ScaleToWindow: | 1120 | case NintendoScaleMode::ScaleToWindow: |
| 1097 | rb.PushEnum(ConvertedScaleMode::ScaleToWindow); | 1121 | return MakeResult(ConvertedScaleMode::ScaleToWindow); |
| 1098 | break; | 1122 | case NintendoScaleMode::ScaleAndCrop: |
| 1099 | case NintendoScaleMode::Crop: | 1123 | return MakeResult(ConvertedScaleMode::ScaleAndCrop); |
| 1100 | rb.PushEnum(ConvertedScaleMode::Crop); | 1124 | case NintendoScaleMode::PreserveAspectRatio: |
| 1101 | break; | 1125 | return MakeResult(ConvertedScaleMode::PreserveAspectRatio); |
| 1102 | case NintendoScaleMode::NoCrop: | ||
| 1103 | rb.PushEnum(ConvertedScaleMode::NoCrop); | ||
| 1104 | break; | ||
| 1105 | default: | 1126 | default: |
| 1106 | UNIMPLEMENTED_MSG("Unknown scaling mode {}", static_cast<u32>(mode)); | 1127 | return ERR_OPERATION_FAILED; |
| 1107 | rb.PushEnum(ConvertedScaleMode::None); | ||
| 1108 | break; | ||
| 1109 | } | 1128 | } |
| 1110 | } | 1129 | } |
| 1111 | 1130 | ||