Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PromoteFormatToDepth #1997

Closed
wants to merge 4 commits into from

Conversation

Xphalnos
Copy link
Collaborator

@Xphalnos Xphalnos commented Dec 31, 2024

Adding to image_view.cpp line 43: LOG_ERROR(Render_Vulkan, "Depht Format {}", vk::to_string(format));

And to image_info.cpp line 315: LOG_ERROR(Render_Vulkan, "Depht Format {}", vk::to_string(pixel_format));

When I launched a Unity game that had this error (Pure Farming 2018), the log showed me that R8G8B8A8Unorm was needed. I added it to liverpool_to_vk.h and log changed.

Before:
[Render.Vulkan] vk_pipeline_cache.cpp:CompileModule:478: Compiling fs shader 0xe08b6588
[Render.Vulkan] vk_pipeline_cache.cpp:CompileModule:478: Compiling vs shader 0x7beef78d
[Render.Vulkan] vk_pipeline_cache.cpp:CompileModule:478: Compiling fs shader 0xb9c471f8c7cc37ff
[Render.Vulkan] vk_pipeline_cache.cpp:CompileModule:478: Compiling vs shader 0x54cd30c3f090d822
[Render.Vulkan] sampler.cpp:Sampler:14: Texture requires gamma correction
[Render.Vulkan] vk_pipeline_cache.cpp:CompileModule:478: Compiling fs shader 0x4ae148a6c30c94ab
[Render.Vulkan] vk_pipeline_cache.cpp:CompileModule:478: Compiling vs shader 0xa3590771bc26c480
[Render.Vulkan] vk_pipeline_cache.cpp:CompileModule:478: Compiling fs shader 0x4364ba6b95ea889c
[Render.Vulkan] vk_pipeline_cache.cpp:CompileModule:478: Compiling vs shader 0x616f852af090d822
[Render.Vulkan] vk_pipeline_cache.cpp:CompileModule:478: Compiling fs shader 0xc01241ce766d0a0f
[Render.Vulkan] vk_pipeline_cache.cpp:CompileModule:478: Compiling vs shader 0x8b450099f090d822
[Render.Vulkan] vk_pipeline_cache.cpp:CompileModule:478: Compiling fs shader 0xc3bff6e3b6212b64
[Render.Vulkan] vk_pipeline_cache.cpp:CompileModule:478: Compiling vs shader 0x812ec1a2f090d822
[Render.Vulkan] vk_pipeline_cache.cpp:CompileModule:478: Compiling vs shader 0x812ec1a2f090d822
[Debug] liverpool_to_vk.h:PromoteFormatToDepth:82: Unreachable code!

After:
[Render.Vulkan] vk_pipeline_cache.cpp:CompileModule:478: Compiling fs shader 0xe08b6588
[Render.Vulkan] vk_pipeline_cache.cpp:CompileModule:478: Compiling vs shader 0x7beef78d
[Render.Vulkan] vk_pipeline_cache.cpp:CompileModule:478: Compiling fs shader 0xb9c471f8c7cc37ff
[Render.Vulkan] vk_pipeline_cache.cpp:CompileModule:478: Compiling vs shader 0x54cd30c3f090d822
[Render.Vulkan] sampler.cpp:Sampler:14: Texture requires gamma correction
[Render.Vulkan] vk_pipeline_cache.cpp:CompileModule:478: Compiling fs shader 0x4ae148a6c30c94ab
[Render.Vulkan] vk_pipeline_cache.cpp:CompileModule:478: Compiling vs shader 0xa3590771bc26c480
[Render.Vulkan] vk_pipeline_cache.cpp:CompileModule:478: Compiling fs shader 0x4364ba6b95ea889c
[Render.Vulkan] vk_pipeline_cache.cpp:CompileModule:478: Compiling vs shader 0x616f852af090d822
[Render.Vulkan] vk_pipeline_cache.cpp:CompileModule:478: Compiling fs shader 0xc01241ce766d0a0f
[Render.Vulkan] vk_pipeline_cache.cpp:CompileModule:478: Compiling vs shader 0x8b450099f090d822
[Render.Vulkan] vk_pipeline_cache.cpp:CompileModule:478: Compiling fs shader 0xc3bff6e3b6212b64
[Render.Vulkan] vk_pipeline_cache.cpp:CompileModule:478: Compiling vs shader 0x812ec1a2f090d822

<941 shader compilation (I wasn't going to copy everything.)>

[Render.Vulkan] vk_pipeline_cache.cpp:CompileModule:478: Compiling vs shader 0x3192b094029c07d4
[Render.Vulkan] vk_pipeline_cache.cpp:CompileModule:478: Compiling fs shader 0x86479a572b36012
[Render.Vulkan] vk_pipeline_cache.cpp:CompileModule:478: Compiling fs shader 0x86479a572b36012
[Debug] resource_tracking_pass.cpp:operator():326: Assertion Failed!

If interested:

Log Before (Main):
shad_log.txt

Log After (My PR):
shad_log.txt

I made it return R32Uint because I was inspired by tile_manager.cpp which returns R32Uint to R8G8B8A8Unorm.
Always ready for modifications or testing!

@ArbestRi02
Copy link

shad_log.txt
PC Building SImulator still crashes with this build

@Xphalnos
Copy link
Collaborator Author

Xphalnos commented Dec 31, 2024

shad_log.txt PC Building SImulator still crashes with this build

This is because you have to add each texture format needed.
Can you try with this and send me the log? (I did not copy the DLL files)
shadPS4 Depht Format.zip

@ArbestRi02
Copy link

shad_log.txt
Same error

@Xphalnos
Copy link
Collaborator Author

Sorry, I forgot to change a line.

shadPS4 Depht Format.zip

@ArbestRi02
Copy link

It now goes ingame!
shad_log.txt

@Xphalnos
Copy link
Collaborator Author

Thanks! I added the necessary Depht Format. If you have other games with this error, feel free to send more logs.

@bigol83
Copy link
Contributor

bigol83 commented Dec 31, 2024

Yakuza 0 doesn't crash anymore with promoteformatdepth with this PR 👍

@hspir404
Copy link
Contributor

hspir404 commented Dec 31, 2024

I crashed on this assert in Bloodborne earlier today, while falling off a cliff in the forbidden forest, specifically with that eR8G8B8A8Unorm input. Thanks for the bug fix!

Also would it make sense to add that log statement just before the UNREACHABLE call? Or does that impact performance?

@Xphalnos
Copy link
Collaborator Author

Yakuza 0 doesn't crash anymore with promoteformatdepth with this PR 👍

Have you tried with the PR build or the zip file build?

@Xphalnos
Copy link
Collaborator Author

I crashed on this assert in Bloodborne earlier today, while falling off a cliff in the forbidden forest, specifically with that eR8G8B8A8Unorm input. Thanks for the bug fix!

Also would it make sense to add that log statement just before the UNREACHABLE call? Or does that impact performance?

It doesn't affect performance. Thanks for the idea!
This displays the missing format before crashing.

[Render.Vulkan] vk_pipeline_cache.cpp:CompileModule:478: Compiling fs shader 0xe08b6588
[Render.Vulkan] vk_pipeline_cache.cpp:CompileModule:478: Compiling vs shader 0x7beef78d
[Render.Vulkan] vk_pipeline_cache.cpp:CompileModule:478: Compiling fs shader 0xb9c471f8c7cc37ff
[Render.Vulkan] vk_pipeline_cache.cpp:CompileModule:478: Compiling vs shader 0x54cd30c3f090d822
[Render.Vulkan] sampler.cpp:Sampler:14: Texture requires gamma correction
[Render.Vulkan] vk_pipeline_cache.cpp:CompileModule:478: Compiling fs shader 0x4ae148a6c30c94ab
[Render.Vulkan] vk_pipeline_cache.cpp:CompileModule:478: Compiling vs shader 0xa3590771bc26c480
[Render.Vulkan] vk_pipeline_cache.cpp:CompileModule:478: Compiling fs shader 0x4364ba6b95ea889c
[Render.Vulkan] vk_pipeline_cache.cpp:CompileModule:478: Compiling vs shader 0x616f852af090d822
[Render.Vulkan] vk_pipeline_cache.cpp:CompileModule:478: Compiling fs shader 0xc01241ce766d0a0f
[Render.Vulkan] vk_pipeline_cache.cpp:CompileModule:478: Compiling vs shader 0x8b450099f090d822
[Render.Vulkan] vk_pipeline_cache.cpp:CompileModule:478: Compiling fs shader 0xc3bff6e3b6212b64
[Render.Vulkan] vk_pipeline_cache.cpp:CompileModule:478: Compiling vs shader 0x812ec1a2f090d822
[Render.Vulkan] vk_pipeline_cache.cpp:CompileModule:478: Compiling vs shader 0x812ec1a2f090d822
[Render.Vulkan] liverpool_to_vk.h:PromoteFormatToDepth:84: Unexpected Depht Format R8G8B8A8Unorm
[Debug] liverpool_to_vk.h:PromoteFormatToDepth:86: Unreachable code!

} else if (fmt == vk::Format::eR8G8B8A8Srgb) {
return vk::Format::eR32Uint;
} else {
LOG_ERROR(Render_Vulkan, "Unexpected Depth Format {}", vk::to_string(fmt));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need a separate log line for this, you can just chnage the unreachable below to UNREACHABLE_MSG("Unexpected Depth Format {}", vk::to_string(fmt));

@squidbus
Copy link
Collaborator

I don't think this is actually correct, for one R32Uint is not a depth format and what the tile manager is doing is for a different reason. Need some kind of verification that these formats are actually supposed to be read as depth and how they're supposed to be interpreted.

@Xphalnos
Copy link
Collaborator Author

Xphalnos commented Dec 31, 2024

@squidbus Do you think I can use D32Sfloat because it is made for that right?

@squidbus
Copy link
Collaborator

Do you think I can use D32Sfloat because it is made for that right?

That solves the depth format issue but it still needs to be verified that interpreting it this way is the correct thing to do here.

@Xphalnos Xphalnos force-pushed the Fix_PromoteFormatToDepth branch from 0ca3902 to 076bd74 Compare December 31, 2024 22:07
@Xphalnos
Copy link
Collaborator Author

Do you think I can use D32Sfloat because it is made for that right?

That solves the depth format issue but it still needs to be verified that interpreting it this way is the correct thing to do here.

How can I know if this is correct? By testing, documentation, or something else?

@squidbus
Copy link
Collaborator

Do you think I can use D32Sfloat because it is made for that right?

That solves the depth format issue but it still needs to be verified that interpreting it this way is the correct thing to do here.

How can I know if this is correct? By testing, documentation, or something else?

Well one way could be to find the draws using this in a RenderDoc capture and see if they're working correctly.

@Xphalnos
Copy link
Collaborator Author

Xphalnos commented Jan 3, 2025

This PR takes over #2032.

@Xphalnos Xphalnos closed this Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants