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 NVRHI shaderCompiler to retry if parallel compilation fails #3

Closed
wants to merge 21 commits into from

Conversation

SRSaunders
Copy link

@SRSaunders SRSaunders commented Jan 26, 2023

This corrects an issue with parallel shader compilation on macOS, where a pipe resource limitation is hit that causes occasional failures. Not observed when parallel compilation is disabled.

Solution is to check pclose() result + status and retry task again under specific conditions:

  1. Child process failure (result == -1 and errno == ECHILD) - on all platforms
  2. Shell failure (WEXITSTATUS(result) == 127) - on posix platforms only (linux/macOS)

Retries are limited to a minimum total of 10 across all shaders, up to a maximum failure rate of 5%. This should be plenty. Failure rate observed on macOS Monterey is about 3-5 shell failures out of ~360 shader variations, or about 1.0-1.5%. This solution is general but solves the macOS issue.

Tested on Windows 10, Manjaro Linux, and macOS Monterey.

@SRSaunders
Copy link
Author

SRSaunders commented Feb 17, 2023

Hi Robert - any chance you could have a look at this one? I would like to push a change to RBDoom3BFG that depends on this NVRHI tools fix: Remove macOS-specifics from compileshaders.cmake and revert to original code. I don't think the auto build check failures on Windows are due to this tools PR.

UPDATE: added two one small commit - a) replace sprintf() with snprintf() in shaderCompiler for buffer security and to eliminate compiler warning, and b) update the stencil parameter for type consistency in ClearDepthStencilAttachment() stencil parameter type change moved into a separate PR containing another more important type fix

@SRSaunders
Copy link
Author

No longer needed since this is now included in main at ShaderMake.

@SRSaunders SRSaunders closed this Feb 25, 2024
@SRSaunders SRSaunders deleted the shadercomp-retry branch February 25, 2024 23:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants