January 30th, 2025

Agility SDK 1.716.0-preview & 1.615-retail: Shader hash bypass

The D3D runtime as of 1.615 officially supports applications opting to bypass shader hash validation.

The historical purpose of the hash that the DX shader compiler embeds in every shader binary was to give the D3D runtime to confidence that shaders being given to it are well formed.  The assumption was that a hashed shader likely came from an official compiler that ran its validator run on the code, and also that there was no memory corruption after that.  These assumptions still apply by default.  Meaning most developers that just want to use DXC to compile shaders and pass them to D3D can continue to do so, ignoring the changes described here.

Over time development scenarios have cropped up that don’t conform to this default workflow, requiring shaders that aren’t hashed by DXC.  In these cases, developers had no choice but to reverse engineer the hash algorithm so they could run it themselves. From now on, apps don’t have to do this workaround, as instead there is a sentinel BYPASS hash value that an app can choose to embed in any shader binary.  The runtime will just let them through to drivers.

See the spec for full details here.   The spec includes some examples of situations where bypassing the hash makes sense, and it officially lists the hash algorithm to bless the cases that had to use it as a workaround already.  That workaround is still fine, though the new official bypass might now make more sense to use since it’s simply cleaner and makes the intent obvious.  For instance, as a developer aid, when the debug layer sees a shader that uses the official hash bypass it will run the DXIL validator on it by default.  The debug layer never did this before since it trusted the hash.   This debug layer DXIL validation can also be toggled to run on every shader regardless of hash or disabled entirely.

The PIX team has also provided support for Shader hash bypass, for additional information see this post.

This release follows up on the earlier blog post announcing this plan: Open Sourcing DXIL Validator Hash – DirectX Developer Blog.  There’s a bunch of useful context to be found there if you’re interested.

Category
DirectX

Author

0 comments