Commit Graph

674 Commits

Author SHA1 Message Date
Herman S.
cf013fdc15 [Base/Posix] mapped_memory portability and correctness fixes
Replace Linux-specific fstat64/ftruncate64 with portable POSIX equivalents.
Fix mmap error check to use MAP_FAILED instead of null pointer comparison.
Remove unconditional ftruncate after mmap that could corrupt files.
Add zero-length guard.
2026-03-26 23:10:47 +09:00
Herman S.
19e9d0c2de [Base/Posix] filesystem portability and correctness fixes
Replace Linux-specific fseeko64/ftello64/ftruncate64 with portable
POSIX equivalents.
Fix pread/pwrite error handling that assigned -1 to unsigned size_t.
Implement SetAttributes via chmod instead of stubbing it out.
Fix potential overflow in Unix-to-Windows filetime conversion.
Clean up unused removeCallback.
2026-03-26 23:10:47 +09:00
Herman S.
cb12f7fa1e [Build] Generalize POSIX platform guards
Most non-Windows code paths use standard POSIX APIs (sockets, signals,
dlopen, threading) that work on any POSIX platform. Change Linux-specific
guards to !WIN32 or #else where the code is portable. Linux-specific
APIs (SIGRTMIN, Vulkan/X11, fontconfig/GTK) remain Linux-guarded.
2026-03-26 23:10:47 +09:00
Herman S.
3efc88abbb [Base] Fix math.h portability: use __builtin_ffs and fix lzcnt narrowing
ffs() can collide with POSIX macro definitions on some platforms;
__builtin_ffs is the portable GCC/Clang intrinsic. log2_floor/log2_ceil
passed template types directly to lzcnt which has only uint32_t and
uint64_t overloads, causing implicit narrowing on smaller types.
2026-03-26 16:28:27 +09:00
Wunkolo
dd3ffeb9cb [a64] Implement FEAT_LSE optimizations
Adds `platform_arm64` similar to `platform_arm64` to populate a 64-bit feature-flag value and creates a `a64_extension_mask` configuration-mask for the detection and utilization of certain arm ISA features. The first feature being `FEAT_LSE` which maps to `XBYAK_AARCH64_HWCAP_ATOMIC`.

Just like the x64 backend, implements `IsFeatureEnabled` to the emitter for checking if the host processor supports a certain subset of feature flag(s) at once.

Optimizes `OPCODE_ATOMIC_EXCHANGE`, `OPCODE_ATOMIC_COMPARE_EXCHANGE`,
and `OPCODE_RESERVED_STORE` with `FEAT_LSE` instructions.
2026-03-25 14:31:53 +09:00
Wunkolo
5b9c13b23f [a64] Implement raw clock with CNTVCT_EL0
Implements a raw clock by directly accessing the `CNTVCT_EL0` and
`CNTFRQ_EL0` registers by using `mrs` intrinsics.

Should allow for a raw-clock to work on all ARM platforms without having
to make a per-platform implementation for any further a64 platforms like
MacOS or Linux or Android and such.
2026-03-25 13:30:51 +09:00
Herman S.
883c2030d0 [ARM64] Initial commit for arm64 backend
Based entirely off existing xbyak x86 implementation and available
tests. Still needs a lot of optimization and testing on non-Windows
platforms.

So far passes all tests and boots at least some games on Windows.
2026-03-22 15:57:37 +09:00
Herman S.
3bf6823e5b [ARM64] Fix constexpr -> const for NEON vector types.
constexpr uint8x16_t isn't valid on all compilers since vcombine_u8/vcreate_u8
aren't constexpr
2026-03-21 01:30:32 +09:00
Herman S.
1e8f1837cf [Build] Use CMAKE_BINARY_DIR for output paths and version.h include
version.h is now found via CMAKE_BINARY_DIR on the include path instead
of a hardcoded "build/version.h" path. This allows out-of-tree and
multi-config builds to each generate and find their own version header
without colliding.
2026-03-21 01:30:31 +09:00
Herman S.
9fbcdae5dc [Base] Limit AVX startup checks to AMD64 2026-03-17 13:55:38 +09:00
Herman S.
f3a456d353 [Base/Debugging] Replaces x86 hack with arch agnostic Win32 API call 2026-03-17 13:30:56 +09:00
Herman S.
61639c8906 [Threading/Posix] Fix issue with nested suspend
When SuspendThread is called on an already-suspended thread, it would send
another pthread_kill signal, which would nest signal handlers and create
multiple outstanding sem_wait calls while Resume only posts once when count
reaches 0. Instead we increment suspend count and skip redundant signal.
2026-03-16 09:25:55 +09:00
Herman S.
ecae4b6a0b [Base/Mem] Add platform guard for AVX/SSE streaming stores in vastcpy.
Prevents build failures on non-x86 platforms
2026-03-16 09:24:59 +09:00
Herman S.
c7f041ced0 [Base] Fix from_chars float parsing assertion on MSVC 2026-03-15 16:34:34 +09:00
Herman S.
6f18c98502 [Thread/Posix] Fix thread suspend deadlock
Replace std::mutex/condition_variable with sem_wait/sem_post for thread
suspension, as WaitSuspended is called from the SIGRTMIN signal handler
where pthread_mutex_lock is not async-signal-safe.
2026-03-10 23:55:27 +09:00
Herman S.
4f1394bbaa [Kernel/Threading] Fix some kernel threading issues
- broken atomic exchange on linux
- spinlock release memory buffer
- race in thread suspension
- removed misleading volatile qualifiers
2026-03-10 23:53:03 +09:00
Herman S.
c4bd0c3f33 [Testing] Inclrease timer test timeout and update default test targets
The threading test is verifying that the timer fires, not that it fires
within a specific timeout, so increasing to 100 to keep it from failing
randomly. Also removing xenia-cpu-ppc-tests from list of default targets
as they take forever to run, they can still be run run using xb test
with --target xenia-cpu-ppc-tests explicitly.
2026-03-10 16:49:41 +09:00
Gliniak
ce94f7fc03 [Base] Win-Style assertion on linux. No more forced termination while debugging 2026-03-09 19:40:20 +01:00
Herman S.
bf6e1a81eb [Posix] Fix DeallocFixed crashes / memory leaks
BaseHeap::Dispose() walks the page table and calls
DeallocFixed(addr, 0, kRelease) for every allocated page region.
These addresses are within file-backed view mappings (i.e. guest memory).
On Windows, VirtualFree on file-mapped pages silently returns FALSE.
On POSIX, the code hit assert_always() and crashed. Changed to return false
to match Windows behavior.

Memory leaks from munmap(addr, 0):

Callers passed length=0 to DeallocFixed(kRelease). On Windows this works because
VirtualFree(addr, 0, MEM_RELEASE) means "release the entire region" — Windows
ignores the length parameter for MEM_RELEASE and always frees the whole
allocation. On POSIX, munmap(addr, 0) fails with EINVAL, so the memory was
silently leaked every time.
2026-03-09 13:43:56 +09:00
Herman S.
52297ea8f8 [Linux] Implement fast mutex similar to Windows version 2026-03-09 13:43:56 +09:00
Herman S.
15483b02af [Memory] Linux cleanup shm files on exit
Prevents running out of /dev/shm space and crashing the whole system.
2026-03-09 13:43:56 +09:00
Herman S.
ae1706d1dc [Threads] Ensure proper RTTI/vtable emission for PosixWaitHandle 2026-03-09 13:43:56 +09:00
Herman S.
174d2d4205 [Posix Threading] Robust mutexes 2026-03-09 13:43:56 +09:00
Herman S.
1ae82023ea [Posix Threads] Refactored condition variables from static to per-instance members and replaced deadlock-prone predicate-based WaitMultiple with polling using try_lock. 2026-03-09 13:43:56 +09:00
Herman S.
c9eba5daf8 [Threading] Signal handler / self-suspension improvements 2026-03-09 13:43:56 +09:00
Herman S.
81dd887e74 [Kernel] Thread suspend for posix to match windows semantics 2026-03-09 13:43:56 +09:00
Herman S.
32b8c341ee [Kernel] ReleaseSemaphore for Posix to match Windows semantics 2026-03-09 13:43:56 +09:00
Herman S.
28e48410c5 Fix potential buffer overflow in posix memory handling 2026-03-09 13:43:56 +09:00
Herman S.
77535b7cec [Base] Replace CRITICAL_SECTION with SRWLOCK based mutexes
xe_fast_mutex now also asserts on recursive lock attempts
2026-03-09 00:19:32 +09:00
Herman S.
de63bb18a6 [Base] Use function-local static for global_mutex
File-scope static initialization order is undefined across translation
units. Code that acquires the global critical region during early startup
could run before the mutex constructor, operating on uninitialized state.
A function-local static is constructed on first use, guaranteeing the
mutex is initialized before any caller can access it.
2026-03-09 00:18:08 +09:00
Gliniak
6446150a5e [Cmake] Moved tests to separate folders 2026-03-06 19:59:38 +01:00
Herman S.
71c5702ee8 [Build] Convert build system to raw cmake and remove premake layer 2026-03-04 17:37:36 +09:00
Adrian
8d5565da8a [Misc] Fixed missing guard header (#887) 2026-02-23 17:07:23 +09:00
Herman S.
434644c301 Merge commit 'f2fabfdf0' into canary_experimental
Sync changes from master up to before the recent GPU changes, those will be
merged later
2026-02-17 16:59:38 +09:00
Herman S.
09a15fbedc [Testing] Get tests running (dirty hack for linux) 2026-02-13 13:32:39 +09:00
Adrian
ac66db337b [XAM] Fixed size used in read_u16string_and_swap 2025-12-22 19:33:47 +01:00
oltolm
492fa7c632 use concepts instead of SFINAE 2025-12-22 10:00:52 +01:00
Gliniak
90a7cc4fee [GPU] Changed default readback_resolve to none 2025-12-04 20:12:34 +01:00
Gliniak
dd29365970 [APU] Switched to New XMA decoder as default
- Added codepath for "consume only" pass. This should resolve constant clicking in Source engine games.
- Added smaller performance improvements to decoder
2025-12-01 23:58:33 +01:00
Herman S.
93adb2bb95 [Config] Gracefully handle type mismatches in cvars.
Detect cvar type mismatch and reset to default value, as well
as show message to the user that the cvar from the config has
been updated.
2025-12-01 17:38:34 +01:00
Gliniak
892aa85913 [Premake] Remove AVX2 requirement from linux build
Co-authored-by: has207 <429230+has207@users.noreply.github.com>
2025-11-03 22:17:45 +01:00
Gliniak
e6828af5e7 [Base] Fixed issue with unnecessary null terminator after reading u16string 2025-10-30 21:57:08 +01:00
Adrian
299ba08983 [APP] Detect PR builds with XE_BUILD_IS_PR 2025-10-30 08:19:28 +01:00
Gliniak
51414f3e1e [Logging] Added ability to disable GPU related logs 2025-10-29 21:16:40 +01:00
Gliniak
2e9c459846 [Kernel] Fixed issue with WINE crash while opening played titles or achievements tab 2025-10-08 11:16:07 +02:00
guccigang420
01ae24e46e [Base/Memory] Fix VirtualQuery length parameter 2025-08-20 13:34:39 +03:00
Gliniak
419c0149c9 [Base] Post merge fixes 2025-08-15 18:06:57 +02:00
Gliniak
c4bd676c5e Merge branch 'master' of https://github.com/xenia-project/xenia into canary_experimental 2025-08-15 15:37:50 +02:00
Triang3l
b5432ab83f [Vulkan] Refactoring and fixes for VulkanProvider and related areas
Enable portability subset physical device enumeration.

Don't use Vulkan 1.1+ logical devices on Vulkan 1.0 instances due to the
VkApplicationInfo::apiVersion specification.

Make sure all extension dependencies are enabled when creating a device.

Prefer exposing feature support over extension support via the device
interface to avoid causing confusion with regard to promoted extensions
(especially those that required some features as extensions, but had those
features made optional when they were promoted).

Allow creating presentation-only devices, not demanding any optional
features beyond the basic Vulkan 1.0, for use cases such as internal tools
or CPU rendering.

Require the independentBlend feature for GPU emulation as working around is
complicated, while support is almost ubiquitous.

Move the graphics system initialization fatal error message to xenia_main
after attempting to initialize all implementations, for automatic fallback
to other implementations in the future.

Log Vulkan driver info.

Improve Vulkan debug message logging, enabled by default.

Refactor code, with simplified logic for enabling extensions and layers.
2025-08-14 23:44:21 +03:00
Margen67
8b6cb9c287 [Premake, 3PP] Formatting/cleanup 2025-08-11 21:03:31 -07:00