Search code examples
hlsldirect3d

What does those D3DCOMPILE constants mean?


In the D3DCompiler library there's these flags called "D3DCompile Constants", but the description that Microsoft give us about them is very brief and difficult to have proper understanding of what they do. I wish someone could be able to explain at least what those three mean:

D3DCOMPILE_PARTIAL_PRECISION, D3DCOMPILE_NO_PRESHADER, D3DCOMPILE_ALL_RESOURCES_BOUND

Solution

  • That doc page is pretty poor. It's just the content of D3DCompiler.h comments put into a Markdown page. I'll see about submitting some edits to help it at least a little. Most of these flags are aliases for older D3DX constants as listed on Microsoft Docs where they are better documented at the moment.

    UPDATE: The Microsoft Docs page has been updated.

    The D3DCOMPILE_PARTIAL_PRECISION flag is equivalent to FXC's /Gpp switch and is an alias for D3DXSHADER_PARTIALPRECISION. It basically treats float32 values as float16 in some cases and enable use of some approximation functions.

    The D3DCOMPILE_NO_PRESHADER flag is equivalent to FXC's /Op switch and is an alias for D3DXSHADER_PARTIALPRECISION. This feature is deprecated and only applies to legacy Direct3D 9 era "Effects" (FX). See this Microsoft Docs page for what this was about.

    D3DCOMPILE_RESOURCES_MAY_ALIAS, D3DCOMPILE_ENABLE_UNBOUNDED_DESCRIPTOR_TABLES, and D3DCOMPILE_ALL_RESOURCES_BOUND flags are HLSL options for informing the HLSL compiler some assumptions when performing optimizations for DirectX 12 Shader Model 5.1.

    Note for DirectX 12, D3DCompile and FXC.EXE are legacy and only support Shader Model 5.1. For DirectX12, you should use Shader Model 6 via the DXIL compiler and DXC.EXE command-line tool. See GitHub.