From 4111fb6c782cab8fdfef139589cf077940e98596 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20R=C3=A5nge?= Date: Wed, 14 Sep 2022 23:28:45 +0200 Subject: [PATCH] Relax shader strictness in RELEASE mode (#13998) Disables strictness and warnings as errors for custom pixel shaders in RELEASE. Windows terminal is not telling the user why the shader won't compile which makes it very frustrating for the shader hacker. After trying the recent preview none of my shaders loaded anymore in Windows Terminal Preview which made me very sad. I had no idea what was wrong with them. After cloning the git repo, building it, fighting an issue that prevent DEBUG SDK from being used I finally was able to identify some issues that were blocking my shaders. > error X3556: integer modulus may be much slower, try using uints if possible. > error X4000: use of potentially uninitialized variable (rayCylinder) While the first one is a good warning I don't think it is an error and the tools I use didn't flag it so was hard to know. The second one I was staring at the code and was unable to identify what exactly was causing the issues, I fumbled with the code a few times and just felt the fun drain away. IMHO: I want it to be fun to develop shaders for windows terminal. Fighting invisible errors are not fun. I am not after building production shaders for Windows Terminal, I want some cool effects. So while I am as a .NET developer always runs with Warning as errors I don't think it's the right option here. Especially since Windows Terminal doesn't tell what is the problem. However, I understand if the shaders you ship with Windows Terminal should be free of errors and silly mistakes, so I kept the stricter setting in DEBUG mode. Loaded Windows Terminal in RELEASE and DEBUG mode and validated that RELEASE mode had reduced strictness but DEBUG retained the previous more restrictive mode. (cherry picked from commit b4b6636b4952ac8ff6a9864f641973bb49d91ce4) Service-Card-Id: 85660397 Service-Version: 1.16 (cherry picked from commit b899d49a260f380cfedb4dd8a2c3791cdd9a481e) --- src/renderer/atlas/AtlasEngine.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/renderer/atlas/AtlasEngine.cpp b/src/renderer/atlas/AtlasEngine.cpp index 91046f34d43..966eea7dbd6 100644 --- a/src/renderer/atlas/AtlasEngine.cpp +++ b/src/renderer/atlas/AtlasEngine.cpp @@ -681,11 +681,18 @@ void AtlasEngine::_createResources() break; } - static constexpr auto flags = D3DCOMPILE_PACK_MATRIX_COLUMN_MAJOR | D3DCOMPILE_ENABLE_STRICTNESS | D3DCOMPILE_WARNINGS_ARE_ERRORS + static constexpr auto flags = + D3DCOMPILE_PACK_MATRIX_COLUMN_MAJOR #ifdef NDEBUG - | D3DCOMPILE_OPTIMIZATION_LEVEL3; + | D3DCOMPILE_OPTIMIZATION_LEVEL3; #else - | D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION; + // Only enable strictness and warnings in DEBUG mode + // as these settings makes it very difficult to develop + // shaders as windows terminal is not telling the user + // what's wrong, windows terminal just fails. + // Keep it in DEBUG mode to catch errors in shaders + // shipped with windows terminal + | D3DCOMPILE_ENABLE_STRICTNESS | D3DCOMPILE_WARNINGS_ARE_ERRORS | D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION; #endif wil::com_ptr error;