Skip to content

Commit

Permalink
Relax shader strictness in RELEASE mode (#13998)
Browse files Browse the repository at this point in the history
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 b4b6636)
Service-Card-Id: 85660397
Service-Version: 1.16
(cherry picked from commit b899d49)
  • Loading branch information
mrange authored and DHowett committed Sep 16, 2022
1 parent 94742d1 commit 4111fb6
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/renderer/atlas/AtlasEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<ID3DBlob> error;
Expand Down

0 comments on commit 4111fb6

Please sign in to comment.