[GAME BUG]: Love Live and a Buffer-to-Image Upload / Texture Cache Regression causing zeroed / black textures
Checklist (we expect you to perform these steps before opening the issue)
- I have searched for a similar issue in this repository and did not find one.
- I am using an official build obtained from releases or updated one of those builds using its in-app updater.
- I have re-dumped the game and performed a clean install without mods and the issue is still present.
- I have disabled all patches and cheats and the issue is still present.
- I have all the required system modules installed.
Describe the Bug
Love Live! School Idol Festival ~after school ACTIVITY~ Wai-Wai! Home Meeting!! (CUSA24620) has suffered a severe graphical regression occur between v0.12.5 and v0.13.0, which persists into current builds. The character, stages, models render pitch black.
Below is a screenshot between version v0.12.5 (left) versus v0.16.0 (right)
v0.12.5 log - shad_log.txt
- Do note that the log may be spammed with
sceKernelConvertLocaltimeToUtc: calledor[Kernel.Fs] <Error> file_system.cpp:253 sceKernelOpen: error = 2, these seem to be normal and doesn't affect gameplay.
v0.16.0 log - shad_log.txt
Reproduction Steps
The steps I did are exactly as followed:
- Boot CUSA24620
Love Live! School Idol Festival ~after school ACTIVITY~ Wai-Wai! Home Meeting!!in shadPS4 v0.13.0 or newer. - Proceed to the main menu.
- Go to Live Show which will load the song selection screen
- Choose Snow Halation as the song
- Chose Hyper Difficulty
- Chose Snow Halation as the costume
- Start the song.
- Observe that the model's skin, hair and certain base clothing render completely black. 8.1. Some parts of specific costumes render correctly because their material shader either bypasses the broken lighting mask or it renders completely fine 8.2. Certain elements of the stage render properly as well.
- Run the exact same steps in v0.12.5. The models, stage and costumes render perfectly.
- Both versions will have some variation of UI corruption occurring. This is an outlier, and the game will work perfectly fine despite this.
All of what is detailed beyond this point is independent of the launcher version, as this is thorough analysis of why the textures are broken between the two release versions. The game will work as it should between the two versions just fine, with no crashes documented on my end.
Deduction and Analysis
I have collected, dumped and analyzed the shaders between v0.12.5 build against the broken v0.16.0 build, as I thought this was originally an issue involving the shader / color buffer, as detailed in issue #4547 with my comment. I discovered the SPIR-V/IR and related are the same between the two versions, which helped me narrow down this issue to a general texture cache / memory sync regression.
My next step was to hook and capture a frame using NVIDIA Nsight Graphics and compare the two versions. Before doing this, I made sure the environment to capture in was as identical as possible; same costumes, same character, same background. When capturing, I made sure to choose the same frame the arms were rendered after the dress and compared the two.
Upon analyzing the captured frames, I focused on the rendering pipeline of the character model for version v0.12.5 first. The shader relies on dynamically generated masks,. specifically a 120x67 R8G8B8A8_UNORM light mask and a 512x512 R16G16_FLOAT depth/material map. The emulator uses a Compute Shader via vkCmdDispatch to untile these from Guest RAM into a linear buffer, before copying them to the image via vkCmdCopyBufferToImage
What I found in v0.12.5 (Working):
The compute shader successfully reads valid data from Guest RAM, decodes it into a linear buffer (which I verified was filled with 255s - White), and copies it to the texture. The shader math evaluates correctly, rendering the model's skin perfectly.
It is worth looking at the 120x67 light mask and the depth/material map here, as the way this is calculated is completely different from v0.16.0. As you can see, the depth/material mask has a yellow background, whereas the light mask is pure white, allowing it to display properly.
What I found in v0.16.0 (Broken):
The vkCmdCopyBufferToImage command still fires, but it copies from a temporary linear buffer that appears to be broken, yielding a different 120x67 R8G8B8A8_UNORM light mask and a 512x512 R16G16_FLOAT depth/material map.
Honing in on Event 470, vkCmdPipelineBarrier2, this is when the 120x67x1 R8G8B8A8_UNORM texture first gets called, which showed a pure blue (0.0, 0.0, 1.0) value, as shown in the screenshot above. This tells me the buffer was broken way before any of the rendering began. I used NSight's Pixel History on the character's arm and verified that the base draw pass does seem to render something correctly (e.g., R: 0.88, G: 0.9, B: 0.91). However, a subsequent draw pass overwrites it with Pitch Black (0, 0, 0,) because that broken light mask evaluates to 0.0.
Looking at the Event Trace immediately prior to vkCmdDispatch, which has the ID numbers 448 and 474 highlighted in Purple, the emulator executes a massive block of commands under the debug labels clearColorBuffer, eliminateFastClearColor, and Toolkit::SurfaceUtil::clearCmaskSurface.
Looking at the buffer before all of this showed the source SSBO, which I'm assuming is representing the PS4 memory (a 93.8 MB Guest RAM storage buffer), is entirely filled with zeroes exactly when the compute shader needs to read it.
Conclusion:
From what I detailed, it appears the emulator's CMASK, or Fast Clear elimination, or Color Buffer logic is misfiring, and is aggressively and erroneously clearing/zeroing out the PS4 memory pool before the untile compute shader has a chance to read the valid CPU writes, resulting in the shader multiplying the character's diffuse colors by zero.
This is backed up from a comment made in issue #4547 by mrsteyk, which I will link here
Compute image clear logic is incorrect, it clears one of the images (120x67 one) to pure non-sense which leads to multiplications by 0 for the albedo (red channel of that texture is nonsense). This was enough to fix the issue on the character selection screen at least.
index df94c4b..bf85c9f 100644
--- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp
+++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp
@@ -521,6 +521,7 @@ bool Rasterizer::IsComputeImageCopy(const Pipeline* pipeline) {
}
bool Rasterizer::IsComputeImageClear(const Pipeline* pipeline) {
+ return false;
if (!pipeline->IsCompute()) {
return false;
}The logic triggers on
cs_0x000000007eb5062fwhich reads only the first dword (out of 16 byte view (GPU moment) which is also a check in IsComputeImageCopy, alongside some other things) and works as a memset. Heuristic for clears should be improved or users should have an ability to disable it per game. It's introduction can be seen as an overall regression.
Despite there existing an issue for Love Live School Idol Festival already, I do believe this could be causing other problems and issues in other games that we do not know of, either because it has not been documented or correlated on this scale before. Therefore, I decided to make this its own issue due to the nature of this behaviour potentially doing such.
(As a side note, I also found a padded 128x64 R16G16B16A16 image outputting scattered rainbow garbage memory, which seems characteristic of raw swizzled CMASK metadata being improperly interpreted as what appears to be color data, which might be surface/memory mismanagement).
Specify OS Version
Windows 11 (23H2)
CPU
AMD Ryzen 9 7900X3D
GPU
NVIDIA Geforce RTX 5090 (Driver 596.49)
Amount of RAM in GB
64 GBs
Amount of VRAM in GB
32 GB
Log File
(see above for logs)
Source: shadps4-emu/shadPS4