[PR #3079] [MERGED] texture_cache: Implement color<->depth copies #3203

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

📋 Pull Request Information

Original PR: https://github.com/shadps4-emu/shadPS4/pull/3079
Author: @raphaelthegreat
Created: 6/10/2025
Status: Merged
Merged: 6/11/2025
Merged by: @squidbus

Base: mainHead: depth-color-copy


📝 Commits (4)

  • 2b3eef0 texture_cache: Implement color to depth copies and vise versa
  • 2554ea5 ir_passes: Adjust shared memory barrier pass to cover more cases
  • 78de61e texture_cache: Remove unused code
  • 3bf38d6 review comment

📊 Changes

7 files changed (+157 additions, -54 deletions)

View changed files

📝 src/shader_recompiler/ir/passes/shared_memory_barrier_pass.cpp (+23 -12)
📝 src/video_core/buffer_cache/buffer_cache.cpp (+6 -4)
📝 src/video_core/buffer_cache/buffer_cache.h (+16 -7)
📝 src/video_core/renderer_vulkan/vk_rasterizer.cpp (+2 -2)
📝 src/video_core/texture_cache/image.cpp (+96 -17)
📝 src/video_core/texture_cache/image.h (+2 -1)
📝 src/video_core/texture_cache/texture_cache.cpp (+12 -11)

📄 Description

This fixes the skybox clouds covering everything in the screen in Driveclub (CUSA00093).

The game uses a compute shader with the depth buffer as input and generates a R32 image based on it. Later when rendering the clouds texture it binds that image as a D32 target with writes disabled to control which ones are rendered. The code for handling depth and color overlaps already existed, but the actual copy was unimplemented so it just discarded the old color image and resulted in empty depth buffer, allowing all clouds to render and overlap the screen. The copy is implemented here by using an intermediate buffer, as vulkan doesn't allow image copies with different aspects.

The compute shader that generated the R32 texture also had an issue with divergence on NVIDIA which I also fixed here while at it. The main shader is covered by an if condition, so all blocks had branch_depth = 1, which prevented barrier insertion. To address this, the branch_depth variable is replaced with a divergence_depth one which is the same but only increments when the branch has a divergent condition.


🔄 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/3079 **Author:** [@raphaelthegreat](https://github.com/raphaelthegreat) **Created:** 6/10/2025 **Status:** ✅ Merged **Merged:** 6/11/2025 **Merged by:** [@squidbus](https://github.com/squidbus) **Base:** `main` ← **Head:** `depth-color-copy` --- ### 📝 Commits (4) - [`2b3eef0`](https://github.com/shadps4-emu/shadPS4/commit/2b3eef0114b696fdcdf847b65ab884c3ac6ed659) texture_cache: Implement color to depth copies and vise versa - [`2554ea5`](https://github.com/shadps4-emu/shadPS4/commit/2554ea55aa29744411bf182d7614766b5730d6d6) ir_passes: Adjust shared memory barrier pass to cover more cases - [`78de61e`](https://github.com/shadps4-emu/shadPS4/commit/78de61ec7038027e155f46c89866de93430e89f5) texture_cache: Remove unused code - [`3bf38d6`](https://github.com/shadps4-emu/shadPS4/commit/3bf38d6b8cd6326bb03ab6bdaaed269cee7e4a6d) review comment ### 📊 Changes **7 files changed** (+157 additions, -54 deletions) <details> <summary>View changed files</summary> 📝 `src/shader_recompiler/ir/passes/shared_memory_barrier_pass.cpp` (+23 -12) 📝 `src/video_core/buffer_cache/buffer_cache.cpp` (+6 -4) 📝 `src/video_core/buffer_cache/buffer_cache.h` (+16 -7) 📝 `src/video_core/renderer_vulkan/vk_rasterizer.cpp` (+2 -2) 📝 `src/video_core/texture_cache/image.cpp` (+96 -17) 📝 `src/video_core/texture_cache/image.h` (+2 -1) 📝 `src/video_core/texture_cache/texture_cache.cpp` (+12 -11) </details> ### 📄 Description This fixes the skybox clouds covering everything in the screen in Driveclub (CUSA00093). The game uses a compute shader with the depth buffer as input and generates a R32 image based on it. Later when rendering the clouds texture it binds that image as a D32 target with writes disabled to control which ones are rendered. The code for handling depth and color overlaps already existed, but the actual copy was unimplemented so it just discarded the old color image and resulted in empty depth buffer, allowing all clouds to render and overlap the screen. The copy is implemented here by using an intermediate buffer, as vulkan doesn't allow image copies with different aspects. The compute shader that generated the R32 texture also had an issue with divergence on NVIDIA which I also fixed here while at it. The main shader is covered by an if condition, so all blocks had branch_depth = 1, which prevented barrier insertion. To address this, the branch_depth variable is replaced with a divergence_depth one which is the same but only increments when the branch has a divergent condition. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 22:02:49 +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#3203
No description provided.