Commit Graph

6179 Commits

Author SHA1 Message Date
Triang3l 91d5ba444a [Base/Kernel] Add and use truncating null-terminating string copying 2020-11-15 11:27:59 -06:00
Joel Linn 68cf47e245 [threading] Fix Fence for multiple waiting threads 2020-11-15 11:12:05 -06:00
Sandy Carter d7094fae52 [threading linux] Implement native_handle
Move wait implementation to not use native_handle.
Implement native_handle for each primitive using posix natives.
2020-11-15 11:12:05 -06:00
Sandy Carter e945a13957 [threading linux] Implement suspend count
Add suspend count to thread implementation.
Increment suspend count on suspend and decrement on resume.
Wait on suspend count to be decremented to 0.
Return suspend count on suspend and on resume before incr/decr.
Fix naming of resume suspend count to make clear that suspend count is
before incr/decr.
Add test.
2020-11-15 11:12:05 -06:00
Sandy Carter 382dd8860f [threading] Change thread names to suit pthread
Shorten names to 16.
Rename Win32 to Windowing.
Shorten GraphicsSystem thread names due to 16 length limit of pthread.
Without this change, both show up as GraphicsSystem.
Remove redundant "Worker" and "Thread" from names.
Remove redundant thread handle from thread name.
2020-11-15 11:12:05 -06:00
Sandy Carter a503b6222f [threads linux] Free and signal suspended threads
Give other threads access to initially suspended threads by signalling
conditional variable before waiting for state to be changed again.
2020-11-15 11:12:05 -06:00
Sandy Carter e11fa0372d [threading linux] Implement Signal and Wait
Add Signal abstract function to handles.
Test SignalAndWait.
2020-11-15 11:12:05 -06:00
Sandy Carter cb905fb195 [threading] Add complex wait on multiple test 2020-11-15 11:12:05 -06:00
Sandy Carter e9e269622b [threading linux] Implement TLS
Implement TLSHandle with pthread_key_t.

Test Alloc, Free, Get and Set.
2020-11-15 11:12:05 -06:00
Sandy Carter 634f87f63b [threading linux] Implement Callback Queuing
Add thread local bool for alertable state.
Use real-time event interrupt to run callback.
Fix sleep duration from miliseconds (microseconds / 1000) to seconds in sleep
command.
Add note for future implementation.

Ignore real-time event 37 in .gdbinit which is used to signal callback.

Test AlertableSleep
Test Thread QueueUserCallback.
TODO: Test alerted wait result when using IO functions.
2020-11-15 11:12:05 -06:00
Sandy Carter 4397f25325 [threading linux] Implement suspendable pthreads
Use real-time event interrupt to communicate suspend in timely manner.
Use conditional_variable to implement suspend wait and resume trigger.

Ignore real-time event 36 in .gdbinit which is used to signal suspend.

Test suspending threads.
2020-11-15 11:12:05 -06:00
Sandy Carter b2912e7891 [threading linux] Wait for thread start 2020-11-15 11:12:05 -06:00
Sandy Carter b91203a0b5 [threading linux] Implement basic Thread function
Add Basic Tests on Threads
2020-11-15 11:12:05 -06:00
Sandy Carter c2de074d5c [threading linux] Implement Timer
Test Manual Reset and Synchronization timers single threaded.
Test Cancelling timers.
Test WaitMultiple.
Ignore real-time event 35 in .gdbinit which is used to signal timer.

Callbacks don't seem to be called so testing them is difficult.
2020-11-15 11:12:05 -06:00
Sandy Carter 331bb0ea9a [threading linux] Implement Mutant
Keep track of recursive locks with owner and count of locks.
Only allow recursive locks from same thread and increment count.
Only allow first locks from when count is zero.

Test acquiring and releasing mutant on same and on different threads.
Test Release return values.
Test WaitAll and WaitAny.
2020-11-15 11:12:05 -06:00
Sandy Carter 5d0efedaf4 [threading linux] Implement Semaphore
Test acquiring and releasing semaphores on same and on different threads.
Test previous_count values.
Test WaitAll and WaitAny.

Add tests for invalid semaphore creation parameters but disactivated as
they do not pass on any platform. These should be enabled and the
implementations fixed to match documentation.
2020-11-15 11:12:05 -06:00
Sandy Carter 75d54e2fa2 [threading linux] Make PosixCondition base class
Add PosixConditionBase as base class for Waitables to use common
primitives mutex and conditional variable
Add abstract signaled() and post_execution() to use single WaitMultiple
implementation.
2020-11-15 11:12:05 -06:00
Sandy Carter 6e13a38cad [threading linux] Implement WaitMultiple
Make conditional_variable and mutex static and create generalisation of
Wait for vector of handles.
Use std::any for waitany and std::all for waitall
2020-11-15 11:12:05 -06:00
Sandy Carter 4ce9eddfb9 [threading] Test WaitAll and WaitAny with Events 2020-11-15 11:12:05 -06:00
Sandy Carter 9d20adfa77 [threading linux] Implement Events
Remove file-descriptor specific wait implementation to PosixFdHandle class
which breaks on waits of non-fd handles.
Replace with PosixConditionHandle and extend to support auto reset and
initial values.
Simplify mutex and conditional variable use with stdlib versions which
wrap these primitives but provide better C++ interface.
Test Event and Reset
2020-11-15 11:12:05 -06:00
Sandy Carter f9d708265f [threading linux] Fix events with closed handles
Linux: Remove copy and destroy call in make_unique invokation which closes
handles on all events.
Testing: Add Wait test for Events set and unset.
2020-11-15 11:12:05 -06:00
Sandy Carter 4280a6451d [threading] Simplify and test Fence
Remove atomic boolean in fence. Variable signaled_ is already protected
by mutex.
Remove wait loop with single predicate wait protected with mutex.

Add Fence Signal and Wait tests
Test signaling without waiting.
Test signaling before waiting.
Test signaling twice before waiting.
Test synchronizing threads with fence.

Few REQUIRES were used to test as there are no return codes.
A failing test may hang indefinitely or cause a segfault which would still
register as a fail.
2020-11-15 11:12:05 -06:00
Sandy Carter b5ea686475 [threading] Implement Posix HighResolutionTimer
Implement HighResolutionTimer for Posix by using native timers.
Callbacks are triggered with realtime interrupts if they are supported.
Create an enum to track user-defined interrupts as well as an initializer and
handler to register these interrupts per thread.
Add test cases for timers for both single and multiple.
Fix Sleep function to continue sleeping if interrupted by system.
Add local .gdbinit to ignore signal 34 which is used by high res timer
2020-11-15 11:12:05 -06:00
Sandy Carter d8d8a7dbb8 [threading linux] Fix nanosleep using microseconds
Add Sleep Test for 50ms.
Fix Sleep under linux that was using microseconds as nanoseconds.
Factor timespec creation to template function using div/mod and nanoseconds
from duration cast.
2020-11-15 11:12:05 -06:00
Sandy Carter 6c79c93f2b [threading] Add basic threading tests
Test logical_processor_count() 3 times to test static return value stays
correct.
Run EnableAffinityConfiguration(). No asserts possible.
Test setting thread id, test using uint32_t max to reset.
Test setting thread name. No asserts possible.
Test running MaybeYield(). No obvious more complex test case.
Test running SyncMemory(). No obvious more complex test case.
2020-11-15 11:12:05 -06:00
Triang3l 56a07c1773 [GPU] Scissor in draw_util 2020-11-15 16:34:23 +03:00
Joel Linn 171c97c929 Start CLion by invoking `xb devenv` when available 2020-11-14 13:30:06 -06:00
Joel Linn 9233f85c30 [docs] CMake generation. 2020-11-14 13:30:06 -06:00
Joel Linn 06214c544a [CPU] std::sort compare: satisfy comp(a,a)==false 2020-11-14 13:30:06 -06:00
Joel Linn 8b1ebe1130 Premake: Reorder links to speed up building.
- Re-enable LTO on clang.
- Set AR on travis so it builds with LTO.
2020-11-14 13:30:06 -06:00
Joel Linn 9dea6b3f62 Add premake cmake generator.
`./build/CMakeLists.txt` is generated by `./xb.bat premake --devenv=cmake` and enables use of other IDEs like `CLion` for example.
2020-11-14 13:30:06 -06:00
Joel Linn 2a076c924f Refactor premake scripts. 2020-11-14 13:30:06 -06:00
Sandy Carter e348cacc6d [debugging linux] Implement functions
Check TracerPid in /proc/self/status for attached debugger.
Add SIGTRAP handler to prevent signal from halting app while not running
in a debugger.
Log DebugPrint in clog (stderr).
2020-11-14 13:17:15 -06:00
Radosław Gliński f8d7652dc4
[Kernel] Remove remaining SHIM usage from xam_net (#1671) 2020-11-14 19:30:56 +03:00
Triang3l a319617185 [Kernel] Thread affinity cleanup 2020-11-14 18:09:47 +03:00
Gliniak 2dc6b0b2ad [Kernel/Thread] Added missing paramteter to KeSetAffinityThread 2020-11-14 17:48:30 +03:00
Triang3l fe9b5b4a8f [D3D12] Cleanup: remove inline 2020-11-14 17:02:09 +03:00
Triang3l 6b988d43c7 [D3D12] Cleanup: pipeline state -> pipeline, other things 2020-11-14 16:43:18 +03:00
Gliniak 87a3c5fac2 [GPU] Added Stub for Packet: PM4_WAIT_FOR_IDLE 2020-11-10 22:48:00 +03:00
Triang3l e196edc989 [Base] Use the original XEPACKEDSTRUCT/UNION names on MSVC 2020-11-08 19:41:41 +03:00
Triang3l 6ac4d3e0c9 [DXBC] Fix texture binding reference use-after-grow 2020-11-06 13:00:22 +03:00
Triang3l ae3b68c7b6 [DXBC] Fast mul path only for fully identical components because neg is post-abs 2020-10-30 22:31:30 +03:00
Triang3l feb8258a5e [DXBC] Multiplication signed zero handling 2020-10-30 22:14:38 +03:00
Joel Linn adebaba799 Allow building without git. 2020-10-28 20:31:36 -05:00
Triang3l 9bbe4365d1 [GPU] Fix adaptive quad tessellation inside factors 2020-10-27 21:01:55 +03:00
gibbed 2b8f347b0b [XAM] Stub xuids usage xeXamUserReadProfileSettingsEx.
[XAM] Stub valid xuids usage xeXamUserReadProfileSettingsEx.
2020-10-26 16:07:37 -05:00
Gliniak 10db913ca2 [Kernel/Xam] XNotifyGetNext - Overall improvements 2020-10-26 15:43:51 -05:00
Triang3l 445d78452f [DXBC] Pop aL on loop end 2020-10-25 19:50:24 +03:00
Triang3l ca9086f3ba [GPU] Add a comment about non-positive tessellation factors 2020-10-19 23:02:20 +03:00
Triang3l 9081046e7b [D3D12] Remove SRV[unbounded] and UAV overlap in bindless root sig 2020-10-18 22:09:08 +03:00