Fix HITMAN 3 boot, layered presentation, and socket imports #851

Manually merged
github merged 5 commits from gh-pr/851/head into gh-pr/851/base 2026-11-26 09:35:04 +00:00
Owner

@⁠Pcniado on GitHub · 2026-09-26 13:26 UTC · original
Pcniado:fix/ppsa16388-boot → main · +959 −285 · 21 files · 5 commits · merged 2026-09-26 22:13 UTC

Gets Hitman WOA in game

https://github.com/user-attachments/assets/317db928-16ff-4153-b451-1e28e863def0

This pull request introduces significant improvements to the GPU video output and presentation pipeline, focusing on robust handling of overlay planes, enhanced error checking, and expanded support for flip modes. The changes add support for overlay rendering, improve how unmapped GPU buffers are handled, and extend the set of valid flip modes. Additionally, the code now gracefully handles edge cases that previously resulted in program termination.

The most important changes are:

Overlay Plane and Presentation Enhancements:

  • Added support for a new overlay plane in the video output pipeline, including the new shader file gpu_blit_texture_overlay.frag, its integration into the build system, and updates to the Presenter and swapchain code to manage overlay frames and image views. (CMakeLists.txt, src/graphics/host_gpu/shaders/gpu_blit_texture_overlay.frag, src/graphics/presentation/presenter.h, src/graphics/presentation/window/swapchain.cpp) [1] [2] [3] [4] [5] [6] [7]

Error Handling and Buffer Management:

  • Improved handling of unmapped GPU buffers and vertex ranges: instead of terminating the program, the code now logs unmapped regions and uses null buffers when necessary, preventing crashes and improving robustness. (src/graphics/host_gpu/renderer/pipeline/descriptors.cpp, src/graphics/host_gpu/renderer/renderDraw.cpp) [1] [2] [3]

Flip Mode and Video Output Robustness:

  • Greatly expanded the set of valid flip modes and improved flip mode validation, including new constants and more descriptive error logging. (src/graphics/presentation/videoOut.cpp) [1] [2] [3] [4] [5]
  • Refactored the flip queue to support overlay handling, including changes to request structures, queue logic, and synchronization, allowing simultaneous main and overlay frame presentation. (src/graphics/presentation/videoOut.cpp) [1] [2] [3] [4] [5] [6] [7]

Debuggability:

  • Enhanced logging for GPU flip submission failures, including hexadecimal error codes for easier debugging. (src/graphics/host_gpu/renderer/sync.cpp)

These changes collectively make the video output pipeline more robust, extensible, and maintainable, especially in handling overlays and error conditions.

ai assisted, however code reviewed and tested by me

**@⁠Pcniado** on GitHub · 2026-09-26 13:26 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/851) `Pcniado:fix/ppsa16388-boot` → `main` · +959 −285 · 21 files · 5 commits · merged 2026-09-26 22:13 UTC Gets Hitman WOA in game https://github.com/user-attachments/assets/317db928-16ff-4153-b451-1e28e863def0 This pull request introduces significant improvements to the GPU video output and presentation pipeline, focusing on robust handling of overlay planes, enhanced error checking, and expanded support for flip modes. The changes add support for overlay rendering, improve how unmapped GPU buffers are handled, and extend the set of valid flip modes. Additionally, the code now gracefully handles edge cases that previously resulted in program termination. The most important changes are: **Overlay Plane and Presentation Enhancements:** * Added support for a new overlay plane in the video output pipeline, including the new shader file `gpu_blit_texture_overlay.frag`, its integration into the build system, and updates to the `Presenter` and swapchain code to manage overlay frames and image views. (`CMakeLists.txt`, `src/graphics/host_gpu/shaders/gpu_blit_texture_overlay.frag`, `src/graphics/presentation/presenter.h`, `src/graphics/presentation/window/swapchain.cpp`) [[1]](diffhunk://#diff-1e7de1ae2d059d21e1dd75d5812d5a34b0222cef273b7c3a2af62eb747f9d20aR304) [[2]](diffhunk://#diff-ca6cd7e0639c61ba220262dc45d7cb03876b9fc91c574668f4caccf8e4b1c57fR1-R10) [[3]](diffhunk://#diff-a8f5f23bbd88dcade5e8e7d6dac34cad34628790b976117d4389f4e206871c66L30-R31) [[4]](diffhunk://#diff-38d0a77906975a21ff6eb1e663f98a460ab115b88df150b9b77315856629dd18R7-R8) [[5]](diffhunk://#diff-38d0a77906975a21ff6eb1e663f98a460ab115b88df150b9b77315856629dd18R31) [[6]](diffhunk://#diff-38d0a77906975a21ff6eb1e663f98a460ab115b88df150b9b77315856629dd18R49-R52) [[7]](diffhunk://#diff-38d0a77906975a21ff6eb1e663f98a460ab115b88df150b9b77315856629dd18R198-R201) **Error Handling and Buffer Management:** * Improved handling of unmapped GPU buffers and vertex ranges: instead of terminating the program, the code now logs unmapped regions and uses null buffers when necessary, preventing crashes and improving robustness. (`src/graphics/host_gpu/renderer/pipeline/descriptors.cpp`, `src/graphics/host_gpu/renderer/renderDraw.cpp`) [[1]](diffhunk://#diff-839c30293b64e9f64013feeec8462f0a22adea19da6423e627b52c65fd8193aaR807-R816) [[2]](diffhunk://#diff-2041a82a26d7b4b6b5e8d4071e6528091a87fdba471b24506e67e7c97793b891R712-R722) [[3]](diffhunk://#diff-2041a82a26d7b4b6b5e8d4071e6528091a87fdba471b24506e67e7c97793b891L743-R757) **Flip Mode and Video Output Robustness:** * Greatly expanded the set of valid flip modes and improved flip mode validation, including new constants and more descriptive error logging. (`src/graphics/presentation/videoOut.cpp`) [[1]](diffhunk://#diff-d62b046301e570c7a7e471cbac4a789d0b564f7695228c95be97e372135ae935R53-R67) [[2]](diffhunk://#diff-d62b046301e570c7a7e471cbac4a789d0b564f7695228c95be97e372135ae935L501-R530) [[3]](diffhunk://#diff-d62b046301e570c7a7e471cbac4a789d0b564f7695228c95be97e372135ae935R540) [[4]](diffhunk://#diff-d62b046301e570c7a7e471cbac4a789d0b564f7695228c95be97e372135ae935L522-R555) [[5]](diffhunk://#diff-d62b046301e570c7a7e471cbac4a789d0b564f7695228c95be97e372135ae935L1470-L1472) * Refactored the flip queue to support overlay handling, including changes to request structures, queue logic, and synchronization, allowing simultaneous main and overlay frame presentation. (`src/graphics/presentation/videoOut.cpp`) [[1]](diffhunk://#diff-d62b046301e570c7a7e471cbac4a789d0b564f7695228c95be97e372135ae935L204-R217) [[2]](diffhunk://#diff-d62b046301e570c7a7e471cbac4a789d0b564f7695228c95be97e372135ae935R232) [[3]](diffhunk://#diff-d62b046301e570c7a7e471cbac4a789d0b564f7695228c95be97e372135ae935R259) [[4]](diffhunk://#diff-d62b046301e570c7a7e471cbac4a789d0b564f7695228c95be97e372135ae935L876-R908) [[5]](diffhunk://#diff-d62b046301e570c7a7e471cbac4a789d0b564f7695228c95be97e372135ae935R919) [[6]](diffhunk://#diff-d62b046301e570c7a7e471cbac4a789d0b564f7695228c95be97e372135ae935L1123-L1128) [[7]](diffhunk://#diff-d62b046301e570c7a7e471cbac4a789d0b564f7695228c95be97e372135ae935R1200-R1276) **Debuggability:** * Enhanced logging for GPU flip submission failures, including hexadecimal error codes for easier debugging. (`src/graphics/host_gpu/renderer/sync.cpp`) These changes collectively make the video output pipeline more robust, extensible, and maintainable, especially in handling overlays and error conditions. ai assisted, however code reviewed and tested by me
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:35:02 +00:00
github manually merged commit fe6b7e84ae into gh-pr/851/base 2026-11-26 09:35:04 +00:00
Author
Owner

@⁠Copilot on GitHub · 2026-09-26 13:31 UTC · original
On src/graphics/presentation/videoOut.cpp line 1167 (outdated):

@@ -1120,12 +1152,41 @@ bool FlipQueue::Flip(uint32_t micros) {
 	if (m_processing) {
 		EXIT("video-out flip queue processing is already active\n");
 	}
-	if (m_requests.front().state != RequestState::Ready) {
+	const auto find_ready = [this](bool main_port) {
+		for (auto it = m_requests.begin(); it != m_requests.end(); ++it) {
+			if (it->state != RequestState::Ready) {
+				return m_requests.end();
+			}
+			if ((it->handle == VIDEO_OUT_MAIN_HANDLE) == main_port) {
+				return it;
+			}
+		}
+		return m_requests.end();
+	};
+	auto main_it    = find_ready(true);
+	auto overlay_it = find_ready(false);

The new selection can process a ready request that is not at the front (for example, a main request behind an overlay request), but Cancel only waits when the front request belongs to the closing config. Closing that main handle can therefore erase or encounter its Presenting request while Flip is using it, leading to the existing fatal checks or a frame being presented after close. Cancellation and processing need to track/wait for the selected non-front request(s), not just the queue front.

**@⁠Copilot** on GitHub · 2026-09-26 13:31 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/851#discussion_r4111509552) On `src/graphics/presentation/videoOut.cpp` line 1167 (outdated): ```diff @@ -1120,12 +1152,41 @@ bool FlipQueue::Flip(uint32_t micros) { if (m_processing) { EXIT("video-out flip queue processing is already active\n"); } - if (m_requests.front().state != RequestState::Ready) { + const auto find_ready = [this](bool main_port) { + for (auto it = m_requests.begin(); it != m_requests.end(); ++it) { + if (it->state != RequestState::Ready) { + return m_requests.end(); + } + if ((it->handle == VIDEO_OUT_MAIN_HANDLE) == main_port) { + return it; + } + } + return m_requests.end(); + }; + auto main_it = find_ready(true); + auto overlay_it = find_ready(false); ``` The new selection can process a ready request that is not at the front (for example, a main request behind an overlay request), but `Cancel` only waits when the front request belongs to the closing config. Closing that main handle can therefore erase or encounter its `Presenting` request while `Flip` is using it, leading to the existing fatal checks or a frame being presented after close. Cancellation and processing need to track/wait for the selected non-front request(s), not just the queue front.
Author
Owner

@⁠Copilot on GitHub · 2026-09-26 13:31 UTC · original
On src/graphics/presentation/window/swapchain.cpp line 530 (outdated):

@@ -492,6 +527,7 @@ Swapchain::~Swapchain() {
 }
 
 void Swapchain::Destroy() {
+	DestroyOverlayPipeline();

This destroys the overlay pipeline before waiting for the graphics queue to become idle. A submitted presentation command may still reference m_overlay_pipeline (and its layout, shaders, sampler, or descriptor layout), so swapchain recreation can destroy Vulkan objects while they are in flight; move this cleanup after queue.waitIdle().

**@⁠Copilot** on GitHub · 2026-09-26 13:31 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/851#discussion_r4111509567) On `src/graphics/presentation/window/swapchain.cpp` line 530 (outdated): ```diff @@ -492,6 +527,7 @@ Swapchain::~Swapchain() { } void Swapchain::Destroy() { + DestroyOverlayPipeline(); ``` This destroys the overlay pipeline before waiting for the graphics queue to become idle. A submitted presentation command may still reference `m_overlay_pipeline` (and its layout, shaders, sampler, or descriptor layout), so swapchain recreation can destroy Vulkan objects while they are in flight; move this cleanup after `queue.waitIdle()`.
Author
Owner

@⁠copilot-pull-request-reviewer[bot] on GitHub · 2026-09-26 13:31 UTC · original · reviewed

Copilot review overview

Unresolved critical and moderate issues remain in the swapchain, video-output, and networking paths.

Review effort: Lite
Findings: 3 High severity · 1 Medium severity

Open (4)
What changed in this PR

Improves HITMAN 3 boot compatibility with GPU overlay presentation, expanded flip handling, safer buffer management, and networking/API additions.

Changes:

  • Adds overlay compositing and shader integration.
  • Expands video-output queue and flip-mode support.
  • Handles unmapped GPU memory and errors more safely.
  • Adds networking, VideoOut, and shader/recompiler updates.
File Summary Review notes
src/​libs/​network.h Declares peer-name lookup. —
src/​libs/​network.cpp Implements peer-name lookup. Moderate issue (4 votes): preserves the wrong errno for invalid descriptors.
src/​libs/​libVideoOut.cpp Adds VideoOut exports/stubs. —
src/​libs/​libNet.cpp Adds networking wrappers and exports. Moderate issues (1 vote each): send and recv failures store negative errno values.
src/​libs/​libKernel.cpp Exports getpeername. —
src/​kernel/​memory.h Declares mapping checks. —
src/​kernel/​memory.cpp Handles unmapped ranges safely. —
src/​graphics/​shader/​recompiler/​frontend/​decode/​VectorAluOps.cpp Adds opcode modifier support. —
src/​graphics/​presentation/​window/​window.cpp Improves controller error handling. —
src/​graphics/​presentation/​window/​swapchain.cpp Adds overlay composition and resources. Critical issues (4 and 2 votes): destroys overlay resources before GPU idle and releases overlay frames with stale presentation ticks. Moderate issue (1 vote): shader-read retry synchronization is invalid.
src/​graphics/​presentation/​videoOut.cpp Expands flip modes and overlay queue handling. Critical issue (3 votes): cancellation can race with selected non-front requests. Moderate issue (1 vote): SUB handles are incorrectly classified as overlays.
src/​graphics/​presentation/​presenter.h Extends presentation support for overlays. —
src/​graphics/​host_gpu/​shaders/​gpu_blit_texture_overlay.frag Adds overlay sampling shader. —
src/​graphics/​host_gpu/​renderer/​sync.cpp Improves flip failure logging. —
src/​graphics/​host_gpu/​renderer/​renderDraw.cpp Handles unmapped vertex ranges. —
src/​graphics/​host_gpu/​renderer/​pipeline/​descriptors.cpp Handles unmapped descriptors. —
CMakeLists.txt Registers the overlay shader. —

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

**@⁠copilot-pull-request-reviewer[bot]** on GitHub · 2026-09-26 13:31 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/851#pullrequestreview-5326051751) · **reviewed** <!-- ccr-overview-v2 --> ## Copilot review overview ### 🟡 Changes recommended Unresolved critical and moderate issues remain in the swapchain, video-output, and networking paths. **Review effort:** Lite **Findings:** 3 <picture><source media="(prefers-color-scheme: dark)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/high-v2-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/high-v2-light.svg"><img src="https://github.githubassets.com/static/images/icons/copilot-code-review/high-v2-light.png" alt="High severity" width="62" height="18" align="texttop"></picture> · 1 <picture><source media="(prefers-color-scheme: dark)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-light.svg"><img src="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-light.png" alt="Medium severity" width="62" height="18" align="texttop"></picture> <details open> <summary><strong>Open (4)</strong></summary> - <picture><source media="(prefers-color-scheme: dark)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/high-v2-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/high-v2-light.svg"><img src="https://github.githubassets.com/static/images/icons/copilot-code-review/high-v2-light.png" alt="High severity" width="62" height="18" align="texttop"></picture> [Cancellation ignores selected non-front requests](#discussion_r4111509552) · New - <picture><source media="(prefers-color-scheme: dark)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/high-v2-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/high-v2-light.svg"><img src="https://github.githubassets.com/static/images/icons/copilot-code-review/high-v2-light.png" alt="High severity" width="62" height="18" align="texttop"></picture> [Overlay pipeline is destroyed while commands may be in flight](#discussion_r4111509567) · New - <picture><source media="(prefers-color-scheme: dark)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/high-v2-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/high-v2-light.svg"><img src="https://github.githubassets.com/static/images/icons/copilot-code-review/high-v2-light.png" alt="High severity" width="62" height="18" align="texttop"></picture> [Overlay present tick is not updated before release](#discussion_r4111509579) · New - <picture><source media="(prefers-color-scheme: dark)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-light.svg"><img src="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-light.png" alt="Medium severity" width="62" height="18" align="texttop"></picture> [Invalid descriptor errno is overwritten](#discussion_r4111509584) · New </details> <details> <summary><strong>What changed in this PR</strong></summary> Improves HITMAN 3 boot compatibility with GPU overlay presentation, expanded flip handling, safer buffer management, and networking/API additions. **Changes:** - Adds overlay compositing and shader integration. - Expands video-output queue and flip-mode support. - Handles unmapped GPU memory and errors more safely. - Adds networking, VideoOut, and shader/recompiler updates. | File | Summary | Review notes | |---|---|---| | `src/​libs/​network.h` | Declares peer-name lookup. | — | | `src/​libs/​network.cpp` | Implements peer-name lookup. | Moderate issue (4 votes): preserves the wrong errno for invalid descriptors. | | `src/​libs/​libVideoOut.cpp` | Adds VideoOut exports/stubs. | — | | `src/​libs/​libNet.cpp` | Adds networking wrappers and exports. | Moderate issues (1 vote each): send and recv failures store negative errno values. | | `src/​libs/​libKernel.cpp` | Exports `getpeername`. | — | | `src/​kernel/​memory.h` | Declares mapping checks. | — | | `src/​kernel/​memory.cpp` | Handles unmapped ranges safely. | — | | `src/​graphics/​shader/​recompiler/​frontend/​decode/​VectorAluOps.cpp` | Adds opcode modifier support. | — | | `src/​graphics/​presentation/​window/​window.cpp` | Improves controller error handling. | — | | `src/​graphics/​presentation/​window/​swapchain.cpp` | Adds overlay composition and resources. | Critical issues (4 and 2 votes): destroys overlay resources before GPU idle and releases overlay frames with stale presentation ticks. Moderate issue (1 vote): shader-read retry synchronization is invalid. | | `src/​graphics/​presentation/​videoOut.cpp` | Expands flip modes and overlay queue handling. | Critical issue (3 votes): cancellation can race with selected non-front requests. Moderate issue (1 vote): SUB handles are incorrectly classified as overlays. | | `src/​graphics/​presentation/​presenter.h` | Extends presentation support for overlays. | — | | `src/​graphics/​host_gpu/​shaders/​gpu_blit_texture_overlay.frag` | Adds overlay sampling shader. | — | | `src/​graphics/​host_gpu/​renderer/​sync.cpp` | Improves flip failure logging. | — | | `src/​graphics/​host_gpu/​renderer/​renderDraw.cpp` | Handles unmapped vertex ranges. | — | | `src/​graphics/​host_gpu/​renderer/​pipeline/​descriptors.cpp` | Handles unmapped descriptors. | — | | `CMakeLists.txt` | Registers the overlay shader. | — | </details> --- 💡 <a href="/KytyPS5/KytyPS5/new/main?filename=.github/skills/code-review/SKILL.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add a `code-review` agent skill</a> or configure MCP servers for context-aware, tailored reviews. <a href="https://docs.github.com/copilot/how-tos/use-copilot-agents/request-a-code-review/use-code-review?tool=webui#mcp-servers-and-agent-skills" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn more in the docs.</a>
Author
Owner

@⁠Copilot on GitHub · 2026-09-26 13:31 UTC · original
On src/graphics/presentation/window/swapchain.cpp line 1086 (outdated):

@@ -812,10 +1081,16 @@ void Presenter::Present(Frame& frame, bool reuse) {
 		                                         std::memory_order_release);
 		m_impl->window.UpdateTitle();
 		m_impl->frames.Release(&frame, true);
+		if (overlay != nullptr) {
+			m_impl->frames.Release(overlay, false);
+		}

The overlay frame is submitted in the same presentation command as frame, but only frame.present_tick is updated. Releasing the overlay with its old tick lets the frame pool reacquire and overwrite its image before the presentation command has finished sampling it; copy the submission tick to overlay->present_tick before releasing it (and do the same in the drop path below).

**@⁠Copilot** on GitHub · 2026-09-26 13:31 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/851#discussion_r4111509579) On `src/graphics/presentation/window/swapchain.cpp` line 1086 (outdated): ```diff @@ -812,10 +1081,16 @@ void Presenter::Present(Frame& frame, bool reuse) { std::memory_order_release); m_impl->window.UpdateTitle(); m_impl->frames.Release(&frame, true); + if (overlay != nullptr) { + m_impl->frames.Release(overlay, false); + } ``` The overlay frame is submitted in the same presentation command as `frame`, but only `frame.present_tick` is updated. Releasing the overlay with its old tick lets the frame pool reacquire and overwrite its image before the presentation command has finished sampling it; copy the submission tick to `overlay->present_tick` before releasing it (and do the same in the drop path below).
Author
Owner

@⁠Copilot on GitHub · 2026-09-26 13:31 UTC · original
On src/libs/network.cpp line 2017 (outdated):

@@ -2002,6 +2002,32 @@ int KYTY_SYSV_ABI Getsockname(int s, void* addr, uint32_t* addrlen) {
 	return result;
 }
 
+int KYTY_SYSV_ABI Getpeername(int s, void* addr, uint32_t* addrlen) {
+	PRINT_NAME();
+
+	LOGF("\t s       = %d\n"
+	     "\t addr    = 0x%016" PRIx64 "\n"
+	     "\t addrlen = 0x%016" PRIx64 "\n",
+	     s, reinterpret_cast<uint64_t>(addr), reinterpret_cast<uint64_t>(addrlen));
+
+	NativeSocket socket = INVALID_NATIVE_SOCKET;
+	SocketSlot   state;
+	if (!GetSocketBackend(s, &socket, &state)) {
+		return SetGuestSocketError(Posix::POSIX_ENOTCONN);
+	}

When the descriptor is invalid, GetSocketBackend has already set POSIX_EBADF, but this branch overwrites it with POSIX_ENOTCONN. That makes getpeername report the wrong errno for bad descriptors; preserve the error set by GetSocketBackend as Getsockname does.

**@⁠Copilot** on GitHub · 2026-09-26 13:31 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/851#discussion_r4111509584) On `src/libs/network.cpp` line 2017 (outdated): ```diff @@ -2002,6 +2002,32 @@ int KYTY_SYSV_ABI Getsockname(int s, void* addr, uint32_t* addrlen) { return result; } +int KYTY_SYSV_ABI Getpeername(int s, void* addr, uint32_t* addrlen) { + PRINT_NAME(); + + LOGF("\t s = %d\n" + "\t addr = 0x%016" PRIx64 "\n" + "\t addrlen = 0x%016" PRIx64 "\n", + s, reinterpret_cast<uint64_t>(addr), reinterpret_cast<uint64_t>(addrlen)); + + NativeSocket socket = INVALID_NATIVE_SOCKET; + SocketSlot state; + if (!GetSocketBackend(s, &socket, &state)) { + return SetGuestSocketError(Posix::POSIX_ENOTCONN); + } ``` When the descriptor is invalid, `GetSocketBackend` has already set `POSIX_EBADF`, but this branch overwrites it with `POSIX_ENOTCONN`. That makes `getpeername` report the wrong errno for bad descriptors; preserve the error set by `GetSocketBackend` as `Getsockname` does.
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-09-26 13:32 UTC · original · edited 2026-09-26 22:24 UTC

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

📝 Walkthrough

Walkthrough

The changes add optional overlay rendering and port-aware video flip scheduling. GPU buffer handling now reports unmapped spans and uses empty or null buffers for unavailable ranges. Networking exports add peer-address lookup, connect, send, and receive wrappers. The VideoOut library registers two handlers. Gamepad event handling adds failure checks, and vector ALU decoding gains additional opcode rules.

Suggested reviewers: nmzik

Priority: ➖ Normal

Change: Bug fix

Merge Risk: 🟠 High · up to f4d8d

The new overlay presentation can corrupt displayed frames or cause GPU device loss. It can also replace the main game image with overlay content. Unplugging a controller that failed to open can crash the emulator. The new networking APIs report incorrect errors. These should be fixed before merging.

Security Architecture Review

Security architecture risk: 🟡 Moderate · up to f4d8d

Multi-port presentation introduces a cancellation race that can terminate the application or update a port after it closes. The apparent impact is confined to the application process, but guest-controlled timing makes the failure material.

Retained concerns

  • Medium · security · inferred: Port-aware selection breaks cancellation's front-of-queue ownership assumption. Closing a port during presentation can terminate on a presenting main request or leave an overlay outside cancellation tracking; subsequent completion can update closed or reopened port state.
Security review details

Security Blast Radius

  • inferred — A guest able to submit and close video-output ports can exercise the affected transition. The evidenced termination reaches the application process; broader tenant, host-service, or environment exposure is not established.

Security Findings and Attack Paths

  • inferred — When a ready main request is not at the queue front, concurrent port closure can reach cancellation's fatal presenting-request check. An overlay removed for presentation instead escapes the queue scan, allowing completion after closure without a request-generation check.

Trust Boundaries and Controls

  • observed — The new LibNet wrappers use existing backend socket operations and error translation. POSIX already exports Connect, Send, and Recv, so the added library exports do not by themselves establish newly available host-network operations.
  • observed — Getpeername requires a mapped socket and non-null output pointers before calling the host; its guest-address conversion is also used by pre-existing socket operations.

Resilience and Maintainability Implications

  • observed — Cancellation tracks queued requests, while the new presentation path can hold an overlay only in a local request copy. Event registrations are generation-tagged, but completion uses the current port configuration without comparing it with the completed request's generation.

Hardening Proposals

  • proposed — Keep every in-flight port request represented until completion or cancellation, wait for the specific port's presentation to finish before closing it, and reject completion against a changed port generation.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 1.96% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 51 functions across 15 files. (2 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the main changes: HITMAN 3 boot fixes, layered presentation, and socket imports.
Description check ✅ Passed The description is directly related to the changeset and explains overlay presentation, flip handling, buffer robustness, logging, and library imports.
Full details: Docstring Coverage

Explanation

Docstring coverage is 1.96% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 51 functions across 15 files. (2 skipped: 2 unsupported.)


Comment @coderabbitai help to get the list of available commands.

**@⁠coderabbitai[bot]** on GitHub · 2026-09-26 13:32 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/851#issuecomment-5846682687) · edited 2026-09-26 22:24 UTC <!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- review_stack_entry_start --> <a href="https://app.coderabbit.ai/change-stack/KytyPS5/KytyPS5/pull/851"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=2" alt="Review in Change Stack →" width="220" height="32"></a> Navigate logical layers of code changes, visualize relationships, and explore their blast radius. <!-- review_stack_entry_end --> <!-- walkthrough_start --> <details> <summary>📝 Walkthrough</summary> ## Walkthrough The changes add optional overlay rendering and port-aware video flip scheduling. GPU buffer handling now reports unmapped spans and uses empty or null buffers for unavailable ranges. Networking exports add peer-address lookup, connect, send, and receive wrappers. The VideoOut library registers two handlers. Gamepad event handling adds failure checks, and vector ALU decoding gains additional opcode rules. **Suggested reviewers:** `nmzik` </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ➖ Normal <!-- change_assessment_commit:"f4d8d633d55ed9592937b88a78a8673f43df6b03" --> **Change:** Bug fix <!-- change_assessment_end --> <!-- final_review_risk_start --> **Merge Risk:** _🟠 High_ · up to `f4d8d` <!-- final_review_risk_coverage:{"sourceCommitId":"f4d8d633d55ed9592937b88a78a8673f43df6b03","coveredCommitId":"f4d8d633d55ed9592937b88a78a8673f43df6b03","kind":"reviewed"} --> The new overlay presentation can corrupt displayed frames or cause GPU device loss. It can also replace the main game image with overlay content. Unplugging a controller that failed to open can crash the emulator. The new networking APIs report incorrect errors. These should be fixed before merging. <!-- final_review_risk_end --> <!-- architecture_review_start --> ### Security Architecture Review **Security architecture risk:** _🟡 Moderate_ · up to `f4d8d` Multi-port presentation introduces a cancellation race that can terminate the application or update a port after it closes. The apparent impact is confined to the application process, but guest-controlled timing makes the failure material. **Retained concerns** - **Medium · security · inferred:** Port-aware selection breaks cancellation's front-of-queue ownership assumption. Closing a port during presentation can terminate on a presenting main request or leave an overlay outside cancellation tracking; subsequent completion can update closed or reopened port state. <details> <summary>Security review details</summary> **Security Blast Radius** - _inferred_ — A guest able to submit and close video-output ports can exercise the affected transition. The evidenced termination reaches the application process; broader tenant, host-service, or environment exposure is not established. **Security Findings and Attack Paths** - _inferred_ — When a ready main request is not at the queue front, concurrent port closure can reach cancellation's fatal presenting-request check. An overlay removed for presentation instead escapes the queue scan, allowing completion after closure without a request-generation check. **Trust Boundaries and Controls** - _observed_ — The new LibNet wrappers use existing backend socket operations and error translation. POSIX already exports Connect, Send, and Recv, so the added library exports do not by themselves establish newly available host-network operations. - _observed_ — Getpeername requires a mapped socket and non-null output pointers before calling the host; its guest-address conversion is also used by pre-existing socket operations. **Resilience and Maintainability Implications** - _observed_ — Cancellation tracks queued requests, while the new presentation path can hold an overlay only in a local request copy. Event registrations are generation-tagged, but completion uses the current port configuration without comparing it with the completed request's generation. **Hardening Proposals** - _proposed_ — Keep every in-flight port request represented until completion or cancellation, wait for the specific port's presentation to finish before closing it, and reject completion against a changed port generation. </details> <!-- architecture_review_end --> <!-- pre_merge_checks_walkthrough_start --> <details> <summary>🚥 Pre-merge checks | ✅ 4 | ❌ 1</summary> ### ❌ Failed checks (1 warning) | Check name | Status | Explanation | Resolution | | :----------------: | :--------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- | | Docstring Coverage | ⚠️ Warning | Docstring coverage is 1.96% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 51 functions across 15 files. (2 skipped: … | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary>✅ Passed checks (4 passed)</summary> | Check name | Status | Explanation | | :------------------------: | :------- | :------------------------------------------------------------------------------------------------------------------------------------------------------ | | Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. | | Title check | ✅ Passed | The title clearly identifies the main changes: HITMAN 3 boot fixes, layered presentation, and socket imports. | | Description check | ✅ Passed | The description is directly related to the changeset and explains overlay presentation, flip handling, buffer robustness, logging, and library imports. | </details> <details> <summary>Full details: Docstring Coverage</summary> **Explanation** Docstring coverage is 1.96% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 51 functions across 15 files. (2 skipped: 2 unsupported.) </details> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- tips_start --> --- <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-09-26 13:32 UTC · original
On src/graphics/presentation/videoOut.cpp line 1179 (outdated):

@@ -1120,12 +1152,41 @@ bool FlipQueue::Flip(uint32_t micros) {
 	if (m_processing) {
 		EXIT("video-out flip queue processing is already active\n");
 	}
-	if (m_requests.front().state != RequestState::Ready) {
+	const auto find_ready = [this](bool main_port) {
+		for (auto it = m_requests.begin(); it != m_requests.end(); ++it) {
+			if (it->state != RequestState::Ready) {
+				return m_requests.end();
+			}
+			if ((it->handle == VIDEO_OUT_MAIN_HANDLE) == main_port) {
+				return it;
+			}
+		}
+		return m_requests.end();
+	};
+	auto main_it    = find_ready(true);
+	auto overlay_it = find_ready(false);
+	if (main_it == m_requests.end()) {
+		const bool main_queued = std::any_of(m_requests.begin(), m_requests.end(),
+		                                     [](const auto& request) {
+			                                     return request.handle == VIDEO_OUT_MAIN_HANDLE;
+		                                     });
+		if (main_queued) {
+			m_mutex.Unlock();
+			return false;
+		}
+		main_it    = overlay_it;
+		overlay_it = m_requests.end();
+	}

🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

Do not promote a non-main request to the main presentation frame.

When no main-handle request is queued, Line 1177 moves the ready overlay or sub-port request into main_it. Presenter::Present then blits that frame opaquely over the whole swapchain and ignores its alpha. It also stores the frame as m_last_frame, so paused and system-overlay refreshes show it again.

This happens whenever an overlay port flips on a vblank where the main port has no queued flip. The trigger is common, because the ports flip independently. The displayed main image is then replaced by overlay content, such as a transparent or black HUD, and the result is flicker or a wrong frame.

Present an overlay-only request over the last main frame instead. One option is to acquire PrepareLastFrame() as the source. Another option is to complete the overlay request without replacing the source frame.

**@⁠coderabbitai[bot]** on GitHub · 2026-09-26 13:32 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/851#discussion_r4111513763) On `src/graphics/presentation/videoOut.cpp` line 1179 (outdated): ```diff @@ -1120,12 +1152,41 @@ bool FlipQueue::Flip(uint32_t micros) { if (m_processing) { EXIT("video-out flip queue processing is already active\n"); } - if (m_requests.front().state != RequestState::Ready) { + const auto find_ready = [this](bool main_port) { + for (auto it = m_requests.begin(); it != m_requests.end(); ++it) { + if (it->state != RequestState::Ready) { + return m_requests.end(); + } + if ((it->handle == VIDEO_OUT_MAIN_HANDLE) == main_port) { + return it; + } + } + return m_requests.end(); + }; + auto main_it = find_ready(true); + auto overlay_it = find_ready(false); + if (main_it == m_requests.end()) { + const bool main_queued = std::any_of(m_requests.begin(), m_requests.end(), + [](const auto& request) { + return request.handle == VIDEO_OUT_MAIN_HANDLE; + }); + if (main_queued) { + m_mutex.Unlock(); + return false; + } + main_it = overlay_it; + overlay_it = m_requests.end(); + } ``` _🎯 Functional Correctness_ | _🟠 Major_ | _🏗️ Heavy lift_ **Do not promote a non-main request to the main presentation frame.** When no main-handle request is queued, Line 1177 moves the ready overlay or sub-port request into `main_it`. `Presenter::Present` then blits that frame opaquely over the whole swapchain and ignores its alpha. It also stores the frame as `m_last_frame`, so paused and system-overlay refreshes show it again. This happens whenever an overlay port flips on a vblank where the main port has no queued flip. The trigger is common, because the ports flip independently. The displayed main image is then replaced by overlay content, such as a transparent or black HUD, and the result is flicker or a wrong frame. Present an overlay-only request over the last main frame instead. One option is to acquire `PrepareLastFrame()` as the source. Another option is to complete the overlay request without replacing the source frame. <!-- fingerprinting:phantom:medusa:pangolin --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:0eb5a918da951ac1559d7f9a --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-09-26 13:32 UTC · original
On src/graphics/presentation/window/swapchain.cpp line 1086 (outdated):

@@ -812,10 +1081,16 @@ void Presenter::Present(Frame& frame, bool reuse) {
 		                                         std::memory_order_release);
 		m_impl->window.UpdateTitle();
 		m_impl->frames.Release(&frame, true);
+		if (overlay != nullptr) {
+			m_impl->frames.Release(overlay, false);
+		}

🩺 Stability & Availability | 🔴 Critical | ⚡ Quick win

Set overlay->present_tick before the overlay frame is released.

On Line 1072, Presenter::Present sets frame.present_tick from swapchain.Submit. It does not update overlay->present_tick. The present command buffer samples overlay->sample_view. The overlay frame is then released back to FramePool. FramePool::Acquire calls WaitForFrame, which waits only on the stored present_tick. For the overlay frame, that value is stale. As a result, a later PrepareFrame or PrepareBlankFrame can run CopyFrom or Clear on the overlay image while the present submission still reads it. Configure can also call DeleteImage and destroy sample_view while they are still in use. The result is a data race on the GPU, which can corrupt the overlay or cause device loss.

Proposed fix
 			swapchain.RecordPresentCommands(command, frame, overlay, draw_system_overlay);
 			frame.present_tick = swapchain.Submit(m_impl->present_scheduler);
+			if (overlay != nullptr) {
+				overlay->present_tick = frame.present_tick;
+			}
**@⁠coderabbitai[bot]** on GitHub · 2026-09-26 13:32 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/851#discussion_r4111513766) On `src/graphics/presentation/window/swapchain.cpp` line 1086 (outdated): ```diff @@ -812,10 +1081,16 @@ void Presenter::Present(Frame& frame, bool reuse) { std::memory_order_release); m_impl->window.UpdateTitle(); m_impl->frames.Release(&frame, true); + if (overlay != nullptr) { + m_impl->frames.Release(overlay, false); + } ``` _🩺 Stability & Availability_ | _🔴 Critical_ | _⚡ Quick win_ **Set `overlay->present_tick` before the overlay frame is released.** On Line 1072, `Presenter::Present` sets `frame.present_tick` from `swapchain.Submit`. It does not update `overlay->present_tick`. The present command buffer samples `overlay->sample_view`. The overlay frame is then released back to `FramePool`. `FramePool::Acquire` calls `WaitForFrame`, which waits only on the stored `present_tick`. For the overlay frame, that value is stale. As a result, a later `PrepareFrame` or `PrepareBlankFrame` can run `CopyFrom` or `Clear` on the overlay image while the present submission still reads it. `Configure` can also call `DeleteImage` and destroy `sample_view` while they are still in use. The result is a data race on the GPU, which can corrupt the overlay or cause device loss. <details> <summary>Proposed fix</summary> ```diff swapchain.RecordPresentCommands(command, frame, overlay, draw_system_overlay); frame.present_tick = swapchain.Submit(m_impl->present_scheduler); + if (overlay != nullptr) { + overlay->present_tick = frame.present_tick; + } ``` </details> <!-- fingerprinting:phantom:medusa:pangolin --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:a117e06cbb58880a152442c8 --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-09-26 13:32 UTC · original
On src/graphics/presentation/window/window.cpp line 315 (outdated):

@@ -306,14 +309,26 @@ static void GameEventController([[maybe_unused]] const EventController& f) {
 
 	if (f.added) {
 		auto* pad = SDL_OpenGamepad(f.id);
-		EXIT_NOT_IMPLEMENTED(pad == nullptr);
-		int id = SDL_GetJoystickID(SDL_GetGamepadJoystick(pad));
-		Controller::Connect(id);
+		if (pad == nullptr) {
+			Log::WriteToConsoleAndLog(
+			    fmt::format("Warning: cannot open controller {}: {}\n", f.id, SDL_GetError()));
+			return;

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Keep failed gamepad opens out of the fatal removal path.

If SDL_OpenGamepad or SDL_GetGamepadJoystick fails, this handler returns without calling Controller::Connect. A later removal event still calls Controller::Disconnect(f.id). That function calls EXIT_IF when the ID was never registered, so removing this gamepad can terminate the application. Make removal of an unregistered ID safe, while preserving cleanup of any opened gamepad. The null check around SDL_CloseGamepad does not protect the disconnect call. (wiki.libsdl.org)

Also applies to: 322-322

**@⁠coderabbitai[bot]** on GitHub · 2026-09-26 13:32 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/851#discussion_r4111513767) On `src/graphics/presentation/window/window.cpp` line 315 (outdated): ```diff @@ -306,14 +309,26 @@ static void GameEventController([[maybe_unused]] const EventController& f) { if (f.added) { auto* pad = SDL_OpenGamepad(f.id); - EXIT_NOT_IMPLEMENTED(pad == nullptr); - int id = SDL_GetJoystickID(SDL_GetGamepadJoystick(pad)); - Controller::Connect(id); + if (pad == nullptr) { + Log::WriteToConsoleAndLog( + fmt::format("Warning: cannot open controller {}: {}\n", f.id, SDL_GetError())); + return; ``` _🩺 Stability & Availability_ | _🟠 Major_ | _⚡ Quick win_ **Keep failed gamepad opens out of the fatal removal path.** If `SDL_OpenGamepad` or `SDL_GetGamepadJoystick` fails, this handler returns without calling `Controller::Connect`. A later removal event still calls `Controller::Disconnect(f.id)`. That function calls `EXIT_IF` when the ID was never registered, so removing this gamepad can terminate the application. Make removal of an unregistered ID safe, while preserving cleanup of any opened gamepad. The null check around `SDL_CloseGamepad` does not protect the disconnect call. ([wiki.libsdl.org](https://wiki.libsdl.org/SDL3/SDL_GetGamepadFromID?utm_source=openai)) Also applies to: 322-322 <!-- fingerprinting:phantom:poseidon:wombat --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:d0e1b36b2831639e3fa3c4d8 --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-09-26 13:32 UTC · original
On src/graphics/shader/recompiler/frontend/decode/VectorAluOps.cpp line 1409 (outdated):

@@ -1400,6 +1402,11 @@ bool HasUnsupportedNativeVop3Modifiers(Opcode opcode, bool permlane, bool mad_mi
 	}
 	switch (opcode) {
 		case Opcode::V_LDEXP_F32: return (abs & ~1u) != 0u || op_sel != 0u || (neg & ~1u) != 0u;
+		case Opcode::V_CUBEID_F32:
+		case Opcode::V_CUBESC_F32:
+		case Opcode::V_CUBETC_F32:
+		case Opcode::V_CUBEMA_F32:
+			return op_sel != 0u;

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Reject or implement cube clamp and omod before accepting them.

When op_sel is zero, this branch accepts nonzero clamp or omod. DecodeVop3 then clears both fields because the cube opcodes are not listed in SupportsNativeVop3Clamp or SupportsNativeVop3ResultModifiers. The decoded instruction loses its output modifiers. AMDGPU GFX10/GFX11 instruction syntax lists clamp and omod for these cube opcodes. (rocmdocs.amd.com)

Reject those fields here until the decoder and translation path support them.

**@⁠coderabbitai[bot]** on GitHub · 2026-09-26 13:32 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/851#discussion_r4111513768) On `src/graphics/shader/recompiler/frontend/decode/VectorAluOps.cpp` line 1409 (outdated): ```diff @@ -1400,6 +1402,11 @@ bool HasUnsupportedNativeVop3Modifiers(Opcode opcode, bool permlane, bool mad_mi } switch (opcode) { case Opcode::V_LDEXP_F32: return (abs & ~1u) != 0u || op_sel != 0u || (neg & ~1u) != 0u; + case Opcode::V_CUBEID_F32: + case Opcode::V_CUBESC_F32: + case Opcode::V_CUBETC_F32: + case Opcode::V_CUBEMA_F32: + return op_sel != 0u; ``` _🎯 Functional Correctness_ | _🟡 Minor_ | _⚡ Quick win_ **Reject or implement cube `clamp` and `omod` before accepting them.** When `op_sel` is zero, this branch accepts nonzero `clamp` or `omod`. `DecodeVop3` then clears both fields because the cube opcodes are not listed in `SupportsNativeVop3Clamp` or `SupportsNativeVop3ResultModifiers`. The decoded instruction loses its output modifiers. AMDGPU GFX10/GFX11 instruction syntax lists `clamp` and `omod` for these cube opcodes. ([rocmdocs.amd.com](https://rocmdocs.amd.com/projects/llvm-project/en/latest/LLVM/llvm/html/AMDGPU/AMDGPUAsmGFX1030.html?utm_source=openai)) Reject those fields here until the decoder and translation path support them. <!-- fingerprinting:phantom:triton:serval --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:8e62579dab1c1b6385f19902 --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-09-26 13:32 UTC · original
On src/libs/libNet.cpp line 178 (outdated):

@@ -163,6 +163,29 @@ int KYTY_SYSV_ABI NetSetsockopt(int s, int level, int optname, const void* optva
 	return FinishSocketCall(Net::Setsockopt(s, level, optname, optval, optlen));
 }
 
+int KYTY_SYSV_ABI NetConnect(int s, const void* addr, uint32_t addrlen) {
+	if (addr != nullptr) {
+		LOGF("\t connect: socket=%d addrlen=%u\n", s, addrlen);
+	}
+	return FinishSocketCall(Net::Connect(s, addr, addrlen));
+}
+
+int64_t KYTY_SYSV_ABI NetSend(int s, const void* buf, uint64_t len, int flags) {
+	const auto result = Net::Send(s, buf, len, flags);
+	if (result < 0) {
+		*GetNetErrorAddr() = PosixToNetError(*Posix::GetErrorAddr());
+	}
+	return result;

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Use the Net error contract for failed sends and receives.

If Net::Send or Net::Recv fails, these wrappers return the POSIX -1 and store a negative NET_ERROR_* code in g_net_errno. FinishSocketCall instead returns the Net error code and stores a positive Net error number. Apply that conversion on failure while preserving the int64_t byte count on success.

Also applies to: 183-186

**@⁠coderabbitai[bot]** on GitHub · 2026-09-26 13:32 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/851#discussion_r4111513769) On `src/libs/libNet.cpp` line 178 (outdated): ```diff @@ -163,6 +163,29 @@ int KYTY_SYSV_ABI NetSetsockopt(int s, int level, int optname, const void* optva return FinishSocketCall(Net::Setsockopt(s, level, optname, optval, optlen)); } +int KYTY_SYSV_ABI NetConnect(int s, const void* addr, uint32_t addrlen) { + if (addr != nullptr) { + LOGF("\t connect: socket=%d addrlen=%u\n", s, addrlen); + } + return FinishSocketCall(Net::Connect(s, addr, addrlen)); +} + +int64_t KYTY_SYSV_ABI NetSend(int s, const void* buf, uint64_t len, int flags) { + const auto result = Net::Send(s, buf, len, flags); + if (result < 0) { + *GetNetErrorAddr() = PosixToNetError(*Posix::GetErrorAddr()); + } + return result; ``` _🗄️ Data Integrity & Integration_ | _🟠 Major_ | _⚡ Quick win_ **Use the Net error contract for failed sends and receives.** If `Net::Send` or `Net::Recv` fails, these wrappers return the POSIX `-1` and store a negative `NET_ERROR_*` code in `g_net_errno`. `FinishSocketCall` instead returns the Net error code and stores a positive Net error number. Apply that conversion on failure while preserving the `int64_t` byte count on success. Also applies to: 183-186 <!-- fingerprinting:phantom:poseidon:wombat --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:45f2e70299650811dccd3c59 --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-09-26 13:32 UTC · original
On src/libs/network.cpp line 2016 (outdated):

@@ -2002,6 +2002,32 @@ int KYTY_SYSV_ABI Getsockname(int s, void* addr, uint32_t* addrlen) {
 	return result;
 }
 
+int KYTY_SYSV_ABI Getpeername(int s, void* addr, uint32_t* addrlen) {
+	PRINT_NAME();
+
+	LOGF("\t s       = %d\n"
+	     "\t addr    = 0x%016" PRIx64 "\n"
+	     "\t addrlen = 0x%016" PRIx64 "\n",
+	     s, reinterpret_cast<uint64_t>(addr), reinterpret_cast<uint64_t>(addrlen));
+
+	NativeSocket socket = INVALID_NATIVE_SOCKET;
+	SocketSlot   state;
+	if (!GetSocketBackend(s, &socket, &state)) {
+		return SetGuestSocketError(Posix::POSIX_ENOTCONN);

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Preserve the socket lookup error.

If s is invalid or closed, GetSocketBackend sets POSIX_EBADF. This branch replaces that error with POSIX_ENOTCONN, so the new POSIX export reports a connection-state error for a bad descriptor. Return -1 without changing the error, as Getsockname does.

**@⁠coderabbitai[bot]** on GitHub · 2026-09-26 13:32 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/851#discussion_r4111513770) On `src/libs/network.cpp` line 2016 (outdated): ```diff @@ -2002,6 +2002,32 @@ int KYTY_SYSV_ABI Getsockname(int s, void* addr, uint32_t* addrlen) { return result; } +int KYTY_SYSV_ABI Getpeername(int s, void* addr, uint32_t* addrlen) { + PRINT_NAME(); + + LOGF("\t s = %d\n" + "\t addr = 0x%016" PRIx64 "\n" + "\t addrlen = 0x%016" PRIx64 "\n", + s, reinterpret_cast<uint64_t>(addr), reinterpret_cast<uint64_t>(addrlen)); + + NativeSocket socket = INVALID_NATIVE_SOCKET; + SocketSlot state; + if (!GetSocketBackend(s, &socket, &state)) { + return SetGuestSocketError(Posix::POSIX_ENOTCONN); ``` _🎯 Functional Correctness_ | _🟠 Major_ | _⚡ Quick win_ **Preserve the socket lookup error.** If `s` is invalid or closed, `GetSocketBackend` sets `POSIX_EBADF`. This branch replaces that error with `POSIX_ENOTCONN`, so the new POSIX export reports a connection-state error for a bad descriptor. Return `-1` without changing the error, as `Getsockname` does. <!-- fingerprinting:phantom:poseidon:wombat --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:8af4c781b7dc5567931d284d --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-09-26 13:32 UTC · original
On src/libs/network.cpp line 2025 (outdated):

@@ -2002,6 +2002,32 @@ int KYTY_SYSV_ABI Getsockname(int s, void* addr, uint32_t* addrlen) {
 	return result;
 }
 
+int KYTY_SYSV_ABI Getpeername(int s, void* addr, uint32_t* addrlen) {
+	PRINT_NAME();
+
+	LOGF("\t s       = %d\n"
+	     "\t addr    = 0x%016" PRIx64 "\n"
+	     "\t addrlen = 0x%016" PRIx64 "\n",
+	     s, reinterpret_cast<uint64_t>(addr), reinterpret_cast<uint64_t>(addrlen));
+
+	NativeSocket socket = INVALID_NATIVE_SOCKET;
+	SocketSlot   state;
+	if (!GetSocketBackend(s, &socket, &state)) {
+		return SetGuestSocketError(Posix::POSIX_ENOTCONN);
+	}
+	if (addr == nullptr || addrlen == nullptr) {
+		return SetGuestSocketError(Posix::POSIX_EFAULT);
+	}
+
+	sockaddr_storage host_addr {};
+	SocketLength     host_addrlen = sizeof(host_addr);
+	if (::getpeername(socket, reinterpret_cast<sockaddr*>(&host_addr), &host_addrlen) != 0) {
+		return SetHostSocketError();

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Map an unconnected socket to POSIX_ENOTCONN on non-Windows hosts.

If host getpeername fails with ENOTCONN, SetHostSocketError calls ConvertHostSocketError. Its non-Windows branch has no ENOTCONN case, so this new API reports POSIX_EIO instead. Add that mapping before returning the host error to the guest.

**@⁠coderabbitai[bot]** on GitHub · 2026-09-26 13:32 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/851#discussion_r4111513773) On `src/libs/network.cpp` line 2025 (outdated): ```diff @@ -2002,6 +2002,32 @@ int KYTY_SYSV_ABI Getsockname(int s, void* addr, uint32_t* addrlen) { return result; } +int KYTY_SYSV_ABI Getpeername(int s, void* addr, uint32_t* addrlen) { + PRINT_NAME(); + + LOGF("\t s = %d\n" + "\t addr = 0x%016" PRIx64 "\n" + "\t addrlen = 0x%016" PRIx64 "\n", + s, reinterpret_cast<uint64_t>(addr), reinterpret_cast<uint64_t>(addrlen)); + + NativeSocket socket = INVALID_NATIVE_SOCKET; + SocketSlot state; + if (!GetSocketBackend(s, &socket, &state)) { + return SetGuestSocketError(Posix::POSIX_ENOTCONN); + } + if (addr == nullptr || addrlen == nullptr) { + return SetGuestSocketError(Posix::POSIX_EFAULT); + } + + sockaddr_storage host_addr {}; + SocketLength host_addrlen = sizeof(host_addr); + if (::getpeername(socket, reinterpret_cast<sockaddr*>(&host_addr), &host_addrlen) != 0) { + return SetHostSocketError(); ``` _🎯 Functional Correctness_ | _🟠 Major_ | _⚡ Quick win_ **Map an unconnected socket to `POSIX_ENOTCONN` on non-Windows hosts.** If host `getpeername` fails with `ENOTCONN`, `SetHostSocketError` calls `ConvertHostSocketError`. Its non-Windows branch has no `ENOTCONN` case, so this new API reports `POSIX_EIO` instead. Add that mapping before returning the host error to the guest. <!-- fingerprinting:phantom:poseidon:wombat --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:5897f705da8ba352145497de --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-09-26 13:32 UTC · original · reviewed

Actionable comments posted: 7


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 7a1b74e1-2e16-402a-9833-9f71b2f3cf51

📥 Commits

Reviewing files that changed from the base of the PR and between 16b83a034c and f4d8d633d55ed9592937b88a78a8673f43df6b03.

📒 Files selected for processing (17)
  • CMakeLists.txt
  • src/graphics/host_gpu/renderer/pipeline/descriptors.cpp
  • src/graphics/host_gpu/renderer/renderDraw.cpp
  • src/graphics/host_gpu/renderer/sync.cpp
  • src/graphics/host_gpu/shaders/gpu_blit_texture_overlay.frag
  • src/graphics/presentation/presenter.h
  • src/graphics/presentation/videoOut.cpp
  • src/graphics/presentation/window/swapchain.cpp
  • src/graphics/presentation/window/window.cpp
  • src/graphics/shader/recompiler/frontend/decode/VectorAluOps.cpp
  • src/kernel/memory.cpp
  • src/kernel/memory.h
  • src/libs/libKernel.cpp
  • src/libs/libNet.cpp
  • src/libs/libVideoOut.cpp
  • src/libs/network.cpp
  • src/libs/network.h

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

**@⁠coderabbitai[bot]** on GitHub · 2026-09-26 13:32 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/851#pullrequestreview-5326055642) · **reviewed** **Actionable comments posted: 7** --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml **Review profile**: CHILL **Plan**: Advanced **Run ID**: `7a1b74e1-2e16-402a-9833-9f71b2f3cf51` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 16b83a034cdc7abed2482605c77921b10056d83c and f4d8d633d55ed9592937b88a78a8673f43df6b03. </details> <details> <summary>📒 Files selected for processing (17)</summary> * `CMakeLists.txt` * `src/graphics/host_gpu/renderer/pipeline/descriptors.cpp` * `src/graphics/host_gpu/renderer/renderDraw.cpp` * `src/graphics/host_gpu/renderer/sync.cpp` * `src/graphics/host_gpu/shaders/gpu_blit_texture_overlay.frag` * `src/graphics/presentation/presenter.h` * `src/graphics/presentation/videoOut.cpp` * `src/graphics/presentation/window/swapchain.cpp` * `src/graphics/presentation/window/window.cpp` * `src/graphics/shader/recompiler/frontend/decode/VectorAluOps.cpp` * `src/kernel/memory.cpp` * `src/kernel/memory.h` * `src/libs/libKernel.cpp` * `src/libs/libNet.cpp` * `src/libs/libVideoOut.cpp` * `src/libs/network.cpp` * `src/libs/network.h` </details> **Included review availability:** This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
This discussion has been locked. Commenting is limited to contributors.
No description provided.