[PR #3103] [MERGED] texture_cache: Implement color to multisampled depth blit pass #3226

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

📋 Pull Request Information

Original PR: https://github.com/shadps4-emu/shadPS4/pull/3103
Author: @raphaelthegreat
Created: 6/16/2025
Status: Merged
Merged: 6/16/2025
Merged by: @georgemoralis

Base: mainHead: color-ms-depth


📝 Commits (1)

  • 05f9c6d texture_cache: Implement color to multisampled depth blit pass

📊 Changes

9 files changed (+356 additions, -10 deletions)

View changed files

📝 CMakeLists.txt (+4 -2)
📝 src/video_core/host_shaders/CMakeLists.txt (+1 -0)
src/video_core/host_shaders/color_to_ms_depth.frag (+15 -0)
📝 src/video_core/renderer_vulkan/vk_scheduler.h (+1 -0)
src/video_core/texture_cache/blit_helper.cpp (+256 -0)
src/video_core/texture_cache/blit_helper.h (+55 -0)
📝 src/video_core/texture_cache/image_info.h (+1 -0)
📝 src/video_core/texture_cache/texture_cache.cpp (+21 -8)
📝 src/video_core/texture_cache/texture_cache.h (+2 -0)

📄 Description

This fixes the snow and rain particles covering all of the screen inside the car in Driveclub (CUSA00093). It also fixes the windshield and other depth related bugs in Cayoosh Point race.

It is yet another silly aliasing case between color and depth buffers, but a little more complicated than just R32 and D32 images. The color is an R32G32B32A32 texture written by a compute shader and the depth is 4x multi-sampled D32 image. The guest essentially utilizes the hardware layout of the samples to avoid doing a conversion pass and alias the memory instead.

Vulkan doesn't' allow buffer->image copies when the image has more than 1 sample. Also since the target is a depth buffer we can't bind it as a multi-sampled storage image and write to it. So to implement the conversion this PR add a helper blit pass with a fullscreen pass that reads from the input texture channels and writes to gl_FragDepth.

Also because this depth buffer is bound alongside an HTILE buffer (something that didn't happen in previous case), I've also added some code to prevent initialize HTILE meta to cleared state when the depth buffer is created through overlap, so the conversion done isn't lost to a clear


🔄 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/3103 **Author:** [@raphaelthegreat](https://github.com/raphaelthegreat) **Created:** 6/16/2025 **Status:** ✅ Merged **Merged:** 6/16/2025 **Merged by:** [@georgemoralis](https://github.com/georgemoralis) **Base:** `main` ← **Head:** `color-ms-depth` --- ### 📝 Commits (1) - [`05f9c6d`](https://github.com/shadps4-emu/shadPS4/commit/05f9c6d6be53efcc0bce64112d29c1b9ce1549fc) texture_cache: Implement color to multisampled depth blit pass ### 📊 Changes **9 files changed** (+356 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `CMakeLists.txt` (+4 -2) 📝 `src/video_core/host_shaders/CMakeLists.txt` (+1 -0) ➕ `src/video_core/host_shaders/color_to_ms_depth.frag` (+15 -0) 📝 `src/video_core/renderer_vulkan/vk_scheduler.h` (+1 -0) ➕ `src/video_core/texture_cache/blit_helper.cpp` (+256 -0) ➕ `src/video_core/texture_cache/blit_helper.h` (+55 -0) 📝 `src/video_core/texture_cache/image_info.h` (+1 -0) 📝 `src/video_core/texture_cache/texture_cache.cpp` (+21 -8) 📝 `src/video_core/texture_cache/texture_cache.h` (+2 -0) </details> ### 📄 Description This fixes the snow and rain particles covering all of the screen inside the car in Driveclub (CUSA00093). It also fixes the windshield and other depth related bugs in Cayoosh Point race. It is yet another silly aliasing case between color and depth buffers, but a little more complicated than just R32 and D32 images. The color is an R32G32B32A32 texture written by a compute shader and the depth is 4x multi-sampled D32 image. The guest essentially utilizes the hardware layout of the samples to avoid doing a conversion pass and alias the memory instead. Vulkan doesn't' allow buffer->image copies when the image has more than 1 sample. Also since the target is a depth buffer we can't bind it as a multi-sampled storage image and write to it. So to implement the conversion this PR add a helper blit pass with a fullscreen pass that reads from the input texture channels and writes to gl_FragDepth. Also because this depth buffer is bound alongside an HTILE buffer (something that didn't happen in previous case), I've also added some code to prevent initialize HTILE meta to cleared state when the depth buffer is created through overlap, so the conversion done isn't lost to a clear --- <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:54 +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#3226
No description provided.