[PR #4057] [CLOSED] Fix: Device loss caused by image overlap (Partial) #3903

Closed
opened 2026-02-27 22:05:24 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/shadps4-emu/shadPS4/pull/4057
Author: @wuguo13842
Created: 2/20/2026
Status: Closed

Base: mainHead: Fix_Device_loss_caused_by_image_overlap_(Partial)


📝 Commits (1)

  • c1589eb Fix: Device loss caused by image overlap (Partial)

📊 Changes

4 files changed (+272 additions, -47 deletions)

View changed files

📝 src/video_core/renderer_vulkan/vk_rasterizer.cpp (+134 -1)
📝 src/video_core/renderer_vulkan/vk_rasterizer.h (+5 -1)
📝 src/video_core/texture_cache/image.h (+4 -1)
📝 src/video_core/texture_cache/texture_cache.cpp (+129 -44)

📄 Description

Root Cause:

  • When an existing image in the texture cache overlaps with a new image request at the same address but with incompatible properties, ResolveOverlap detects block size mismatch and returns an empty ID indicating the need for a new image
  • However, when attempting to copy data from the source image to the new image, CopyImage fails due to the source image being in an invalid state (pitch=0 or sample count=0), causing device loss

Changes:

  1. Added detection for pitch mismatch and block size mismatch in ResolveOverlap, returning empty ID to indicate the need for a new image instead of reusing
  2. Modified FindImage to recognize cases requiring a new image and create a fresh image instance
  3. Temporarily disabled image copy logic to prevent device loss; CopyImage function needs further fixes

Status: Partial completion - images can be created normally, but content
copying functionality is currently disabled

修复: 图像重叠导致的设备丢失问题 (部分完成)

问题原因:

  • 当纹理缓存中已存在图像与新请求图像地址相同但属性不兼容时, ResolveOverlap 检测到块大小不匹配,返回空ID指示需要创建新图像
  • 但在尝试从源图像复制数据到新图像时,由于源图像可能处于无效状态 (pitch=0 或采样数为0),导致 CopyImage 调用失败,引发设备丢失

本次修改:

  1. 在 ResolveOverlap 中添加了对 pitch 不匹配、块大小不匹配等情况的检测, 返回空ID指示需要创建新图像而非直接复用
  2. 在 FindImage 中识别需要新图像的情况,创建全新的图像实例
  3. 暂时禁用图像复制逻辑以避免设备丢失,后续需要进一步修复 CopyImage 函数

状态:部分完成,图像已能正常创建,但内容复制功能暂未启用


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/shadps4-emu/shadPS4/pull/4057 **Author:** [@wuguo13842](https://github.com/wuguo13842) **Created:** 2/20/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `Fix_Device_loss_caused_by_image_overlap_(Partial)` --- ### 📝 Commits (1) - [`c1589eb`](https://github.com/shadps4-emu/shadPS4/commit/c1589eb8f6576251d5c0931bda1a1416a873d4f4) Fix: Device loss caused by image overlap (Partial) ### 📊 Changes **4 files changed** (+272 additions, -47 deletions) <details> <summary>View changed files</summary> 📝 `src/video_core/renderer_vulkan/vk_rasterizer.cpp` (+134 -1) 📝 `src/video_core/renderer_vulkan/vk_rasterizer.h` (+5 -1) 📝 `src/video_core/texture_cache/image.h` (+4 -1) 📝 `src/video_core/texture_cache/texture_cache.cpp` (+129 -44) </details> ### 📄 Description Root Cause: - When an existing image in the texture cache overlaps with a new image request at the same address but with incompatible properties, ResolveOverlap detects block size mismatch and returns an empty ID indicating the need for a new image - However, when attempting to copy data from the source image to the new image, CopyImage fails due to the source image being in an invalid state (pitch=0 or sample count=0), causing device loss Changes: 1. Added detection for pitch mismatch and block size mismatch in ResolveOverlap, returning empty ID to indicate the need for a new image instead of reusing 2. Modified FindImage to recognize cases requiring a new image and create a fresh image instance 3. Temporarily disabled image copy logic to prevent device loss; CopyImage function needs further fixes Status: Partial completion - images can be created normally, but content copying functionality is currently disabled 修复: 图像重叠导致的设备丢失问题 (部分完成) 问题原因: - 当纹理缓存中已存在图像与新请求图像地址相同但属性不兼容时, ResolveOverlap 检测到块大小不匹配,返回空ID指示需要创建新图像 - 但在尝试从源图像复制数据到新图像时,由于源图像可能处于无效状态 (pitch=0 或采样数为0),导致 CopyImage 调用失败,引发设备丢失 本次修改: 1. 在 ResolveOverlap 中添加了对 pitch 不匹配、块大小不匹配等情况的检测, 返回空ID指示需要创建新图像而非直接复用 2. 在 FindImage 中识别需要新图像的情况,创建全新的图像实例 3. 暂时禁用图像复制逻辑以避免设备丢失,后续需要进一步修复 CopyImage 函数 状态:部分完成,图像已能正常创建,但内容复制功能暂未启用 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 22:05:24 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/shadPS4#3903
No description provided.