Skip to content

Commit b34c2be

Browse files
committed
Merge branch 'main' into win-arm64-msvc
2 parents 6a5219f + 4ee027d commit b34c2be

30 files changed

Lines changed: 1007 additions & 667 deletions

.gdbinit

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
python
2+
3+
import gdb
4+
import re
5+
6+
7+
class BetypePrinter:
8+
PATTERN = re.compile("^betype<.*>$")
9+
10+
def __init__(self, obj):
11+
self._obj = obj
12+
13+
def to_string(self):
14+
underlying = self._obj["m_value"]
15+
reversed_bytes = bytes(reversed(underlying.bytes))
16+
return gdb.Value(reversed_bytes, underlying.type)
17+
18+
class MemptrPrinter:
19+
PATTERN = re.compile("^MEMPTR<.*>$")
20+
21+
def __init__(self, obj):
22+
self._ptr_type = obj.type.strip_typedefs().unqualified().template_argument(0).pointer()
23+
self._guest_address = obj["m_value"].cast(gdb.lookup_type("uint32"))
24+
25+
def ptr(self):
26+
if self._guest_address == 0:
27+
return gdb.Value(0, self._ptr_type)
28+
base_addr = gdb.parse_and_eval('memory_base', global_context=True)
29+
return (self._guest_address + base_addr).reinterpret_cast(self._ptr_type)
30+
31+
def children(self):
32+
return [("raw", self.ptr())]
33+
34+
def to_string(self):
35+
return self._guest_address.format_string(format="x")
36+
37+
def lookup(val):
38+
tag = val.type.strip_typedefs().unqualified().tag
39+
if tag is None:
40+
return None
41+
printers = [BetypePrinter, MemptrPrinter]
42+
for printer in printers:
43+
if printer.PATTERN.match(tag):
44+
return printer(val)
45+
return None
46+
47+
gdb.pretty_printers.append(lookup)

CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ if (ENABLE_VCPKG)
5151
# CONFIG option
5252
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG TRUE)
5353
if (WIN32)
54-
message(STATUS "CPU Arch is: $ENV{PROCESSOR_ARCHITECTURE}")
55-
if($ENV{PROCESSOR_ARCHITECTURE} MATCHES "x86_64|amd64|AMD64")
54+
message(STATUS "CPU Arch is: $ENV{CEMU_ARCHITECTURE}")
55+
if($ENV{CEMU_ARCHITECTURE} MATCHES "x86_64|amd64|AMD64")
5656
set(VCPKG_TARGET_TRIPLET "x64-windows-static" CACHE STRING "" FORCE)
5757
set(VCPKG_HOST_TRIPLET "x64-windows-static" CACHE STRING "" FORCE)
5858
else()
@@ -169,7 +169,7 @@ find_package(ZLIB REQUIRED)
169169
find_package(zstd MODULE REQUIRED) # MODULE so that zstd::zstd is available
170170
find_package(OpenSSL COMPONENTS Crypto SSL REQUIRED)
171171
find_package(glm REQUIRED)
172-
find_package(fmt 9 REQUIRED)
172+
find_package(fmt 12.1 REQUIRED)
173173
find_package(PNG REQUIRED)
174174

175175
if(ENABLE_SDL)

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,17 @@ If coding isn't your thing, testing games and making detailed bug reports or upd
5050

5151
Questions about Cemu's software architecture can also be answered on Discord (or through the Matrix bridge).
5252

53+
#### AI generated contributions:
54+
55+
We ask that all code submitted is written and understood by a human. You can use AI for planning, designing, reviewing and for asking questions about the codebase, but the code itself needs to be written by you. As a small exception you can use intellisense-style AI code autocompletion for pure boilerplate code as long as it's only a small part of your submission. To further clarify, when we ask for "human written" that excludes letting an AI write the code and then paraphrasing it. In other words, we are asking for human effort.
56+
57+
Why this policy exists:
58+
59+
We have relatively low reviewing capacity and requiring human-written code increases the quality and trustworthyness of submitted pull requests. There are also general concerns with AI usage in emulation:
60+
- LLMs tend to make up solutions that work on the surface but are generally not accurate in the emulation sense
61+
- There is evidence that LLMs have been trained on leaked proprietary SDKs and we cannot verify the origin of the knowledge. This is especially a problem for core emulation logic
62+
63+
Please keep these points in mind when contributing to Cemu. Contributions that do not follow this policy may be rejected.
64+
5365
## License
5466
Cemu is licensed under [Mozilla Public License 2.0](/LICENSE.txt). Exempt from this are all files in the dependencies directory for which the licenses of the original code apply as well as some individual files in the src folder, as specified in those file headers respectively.

dependencies/ih264d/common/armv8/ih264_weighted_bi_pred_av8.s

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ ih264_weighted_bi_pred_luma_av8:
142142
sxtw x4, w4
143143
sxtw x5, w5
144144
stp x19, x20, [sp, #-16]!
145+
add w6, w6, #1 //w6 = log_WD + 1
146+
neg w10, w6 //w10 = -(log_WD + 1)
147+
dup v0.8h, w10 //Q0 = -(log_WD + 1) (32-bit)
145148
#ifndef __APPLE__
146149
ldr w8, [sp, #80] //Load wt2 in w8
147150
ldr w9, [sp, #88] //Load ofst1 in w9
@@ -155,9 +158,6 @@ ih264_weighted_bi_pred_luma_av8:
155158
ldr w11, [sp, #92] //Load ht in w11
156159
ldr w12, [sp, #96] //Load wd in w12
157160
#endif
158-
add w6, w6, #1 //w6 = log_WD + 1
159-
neg w10, w6 //w10 = -(log_WD + 1)
160-
dup v0.8h, w10 //Q0 = -(log_WD + 1) (32-bit)
161161
add w9, w9, #1 //w9 = ofst1 + 1
162162
add w9, w9, w10 //w9 = ofst1 + ofst2 + 1
163163
mov v2.s[0], w7

dist/windows/Cemu.manifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
33
<dependency>
44
<dependentAssembly>
5-
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="" publicKeyToken="6595b64144ccf1df" language="*"></assemblyIdentity>
5+
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"></assemblyIdentity>
66
</dependentAssembly>
77
</dependency>
88
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"><security><requestedPrivileges>

src/Cafe/CafeSystem.cpp

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -499,21 +499,43 @@ namespace CafeSystem
499499
std::string GetWindowsNamedVersion(uint32& buildNumber)
500500
{
501501
char productName[256];
502+
char buildNumberStr[32];
503+
char featureVersion[32];
502504
HKEY hKey;
503505
DWORD dwType = REG_SZ;
504506
DWORD dwSize = sizeof(productName);
507+
buildNumber = 0;
508+
featureVersion[0] = '\0';
505509
if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS)
506510
{
507511
if (RegQueryValueExA(hKey, "ProductName", NULL, &dwType, (LPBYTE)productName, &dwSize) != ERROR_SUCCESS)
508512
strcpy(productName, "Windows");
513+
dwType = REG_SZ;
514+
dwSize = sizeof(buildNumberStr);
515+
if (RegQueryValueExA(hKey, "CurrentBuildNumber", NULL, &dwType, (LPBYTE)buildNumberStr, &dwSize) == ERROR_SUCCESS)
516+
buildNumber = (uint32)atoi(buildNumberStr);
517+
dwType = REG_SZ;
518+
dwSize = sizeof(featureVersion);
519+
if (RegQueryValueExA(hKey, "DisplayVersion", NULL, &dwType, (LPBYTE)featureVersion, &dwSize) != ERROR_SUCCESS)
520+
{
521+
dwType = REG_SZ;
522+
dwSize = sizeof(featureVersion);
523+
if (RegQueryValueExA(hKey, "ReleaseId", NULL, &dwType, (LPBYTE)featureVersion, &dwSize) != ERROR_SUCCESS)
524+
featureVersion[0] = '\0';
525+
}
509526
RegCloseKey(hKey);
510527
}
511-
OSVERSIONINFO osvi;
512-
ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
513-
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
514-
GetVersionEx(&osvi);
515-
buildNumber = osvi.dwBuildNumber;
516-
return std::string(productName);
528+
std::string result(productName);
529+
// ProductName still reads as "Windows 10" on Windows 11. Find and replace with "Windows 11" based on build number.
530+
if (buildNumber >= 22000)
531+
{
532+
size_t pos = result.find("Windows 10");
533+
if (pos != std::string::npos)
534+
result.replace(pos, 10, "Windows 11");
535+
}
536+
if (featureVersion[0] != '\0')
537+
result += fmt::format(" {}", featureVersion);
538+
return result;
517539
}
518540
#endif
519541

@@ -950,19 +972,30 @@ namespace CafeSystem
950972
{
951973
if (sLaunchModeIsStandalone)
952974
return CosCapabilityBits::All;
975+
976+
CosCapabilityBits resultMask = static_cast<CosCapabilityBits>(0);
977+
for (const auto& pack : GraphicPack2::GetActiveGraphicPacks())
978+
{
979+
for (const auto& permissionOverrides : pack->GetPermissionOverrides())
980+
{
981+
if (permissionOverrides.first == group)
982+
resultMask |= static_cast<CosCapabilityBits>(permissionOverrides.second);
983+
}
984+
}
985+
953986
auto& update = sGameInfo_ForegroundTitle.GetUpdate();
954987
if (update.IsValid())
955988
{
956989
ParsedCosXml* cosXml = update.GetCosInfo();
957990
if (cosXml)
958-
return cosXml->GetCapabilityBits(group);
991+
return cosXml->GetCapabilityBits(group) | resultMask;
959992
}
960993
auto& base = sGameInfo_ForegroundTitle.GetBase();
961994
if(base.IsValid())
962995
{
963996
ParsedCosXml* cosXml = base.GetCosInfo();
964997
if (cosXml)
965-
return cosXml->GetCapabilityBits(group);
998+
return cosXml->GetCapabilityBits(group) | resultMask;
966999
}
9671000
return CosCapabilityBits::All;
9681001
}

src/Cafe/GraphicPack/GraphicPack2.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,39 @@ GraphicPack2::GraphicPack2(fs::path rulesPath, IniParser& rules)
451451
}
452452
}
453453
}
454+
else if (boost::iequals(currentSectionName, "Permissions"))
455+
{
456+
std::array<std::pair<std::string_view, CosCapabilityGroup>, 15> permissionTable
457+
{{
458+
{"BSP", CosCapabilityGroup::BSP},
459+
{"DK", CosCapabilityGroup::DK},
460+
{"USB", CosCapabilityGroup::USB},
461+
{"UHS", CosCapabilityGroup::UHS},
462+
{"FS", CosCapabilityGroup::FS},
463+
{"MCP", CosCapabilityGroup::MCP},
464+
{"NIM", CosCapabilityGroup::NIM},
465+
{"ACT", CosCapabilityGroup::ACT},
466+
{"FPD", CosCapabilityGroup::FPD},
467+
{"BOSS", CosCapabilityGroup::BOSS},
468+
{"ACP", CosCapabilityGroup::ACP},
469+
{"PDM", CosCapabilityGroup::PDM},
470+
{"AC", CosCapabilityGroup::AC},
471+
{"NDM", CosCapabilityGroup::NDM},
472+
{"NSEC", CosCapabilityGroup::NSEC}
473+
}};
474+
475+
for (const auto& [name, group] : permissionTable)
476+
{
477+
const auto permissionOption = rules.FindOption(name);
478+
if (permissionOption)
479+
{
480+
cemuLog_log(LogType::Force, "Graphic pack \"{}\": has permission mask {} for {}", GetNormalizedPathString(), *permissionOption, name);
481+
uint64 permissionMask = ConvertString<uint64>(*permissionOption, 16);
482+
m_permissions.push_back({group, permissionMask});
483+
}
484+
485+
}
486+
}
454487
}
455488

456489
if (m_version >= 5)

src/Cafe/GraphicPack/GraphicPack2.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include "util/helpers/helpers.h"
44
#include "Cemu/ExpressionParser/ExpressionParser.h"
5+
#include "Cafe/TitleList/TitleInfo.h"
56
#include "Cafe/HW/Latte/Renderer/RendererOuputShader.h"
67
#include "util/helpers/Serializer.h"
78
#include "Cafe/OS/RPL/rpl.h"
@@ -147,6 +148,9 @@ class GraphicPack2
147148

148149
[[nodiscard]] const std::vector<PresetPtr>& GetPresets() const { return m_presets; }
149150
[[nodiscard]] std::unordered_map<std::string, std::vector<PresetPtr>> GetCategorizedPresets(std::vector<std::string>& order) const;
151+
152+
// permissions
153+
const std::vector<std::pair<CosCapabilityGroup, uint64>>& GetPermissionOverrides() { return m_permissions; }
150154

151155
// shaders
152156
void LoadShaders();
@@ -264,6 +268,9 @@ class GraphicPack2
264268

265269
// ram mappings
266270
std::vector<std::pair<MPTR, MPTR>> m_ramMappings;
271+
272+
// permissions
273+
std::vector<std::pair<CosCapabilityGroup, uint64>> m_permissions;
267274

268275
// patches
269276
void LoadPatchFiles(); // loads Cemuhook or Cemu patches

0 commit comments

Comments
 (0)