Skip to content

Commit

Permalink
Disable D3D11 HLSL optimizations, as they break program behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSpydog committed Jun 24, 2020
1 parent 8d12660 commit 173599d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions mojoshader_d3d11.c
Expand Up @@ -29,6 +29,10 @@
#include <d3dcompiler.h>
#endif

// D3DCompile optimization can be overzealous and cause very visible bugs,
// so we disable it when compiling shaders to preserve correctness.
#define D3D_SKIP_OPT (1 << 2)

/* Error state */

static char error_buffer[1024] = { '\0' };
Expand Down Expand Up @@ -288,7 +292,7 @@ static ID3D11VertexShader *compileVertexShader(MOJOSHADER_d3d11Shader *shader,
const MOJOSHADER_parseData *pd = shader->parseData;
HRESULT result = ctx->D3DCompileFunc(src, src_len, pd->mainfn,
NULL, NULL, pd->mainfn, "vs_4_0",
0, 0, blob, blob);
D3D_SKIP_OPT, 0, blob, blob);

if (result < 0)
{
Expand Down Expand Up @@ -498,8 +502,8 @@ static ID3D11PixelShader *compilePixelShader(MOJOSHADER_d3d11Shader *vshader,

result = ctx->D3DCompileFunc(source, strlen(source),
pshader->parseData->mainfn, NULL, NULL,
pshader->parseData->mainfn, "ps_4_0", 0, 0,
&blob, &blob);
pshader->parseData->mainfn, "ps_4_0",
D3D_SKIP_OPT, 0, &blob, &blob);

if (result < 0)
{
Expand Down

0 comments on commit 173599d

Please sign in to comment.