equal
deleted
inserted
replaced
26 #define WINAPI_FAMILY_WINRT 0 |
26 #define WINAPI_FAMILY_WINRT 0 |
27 #endif |
27 #endif |
28 #if WINAPI_FAMILY_WINRT |
28 #if WINAPI_FAMILY_WINRT |
29 #include <d3dcompiler.h> |
29 #include <d3dcompiler.h> |
30 #endif |
30 #endif |
|
31 |
|
32 // D3DCompile optimization can be overzealous and cause very visible bugs, |
|
33 // so we disable it when compiling shaders to preserve correctness. |
|
34 #define D3D_SKIP_OPT (1 << 2) |
31 |
35 |
32 /* Error state */ |
36 /* Error state */ |
33 |
37 |
34 static char error_buffer[1024] = { '\0' }; |
38 static char error_buffer[1024] = { '\0' }; |
35 |
39 |
286 ID3D10Blob **blob) |
290 ID3D10Blob **blob) |
287 { |
291 { |
288 const MOJOSHADER_parseData *pd = shader->parseData; |
292 const MOJOSHADER_parseData *pd = shader->parseData; |
289 HRESULT result = ctx->D3DCompileFunc(src, src_len, pd->mainfn, |
293 HRESULT result = ctx->D3DCompileFunc(src, src_len, pd->mainfn, |
290 NULL, NULL, pd->mainfn, "vs_4_0", |
294 NULL, NULL, pd->mainfn, "vs_4_0", |
291 0, 0, blob, blob); |
295 D3D_SKIP_OPT, 0, blob, blob); |
292 |
296 |
293 if (result < 0) |
297 if (result < 0) |
294 { |
298 { |
295 set_error((const char *) ID3D10Blob_GetBufferPointer(*blob)); |
299 set_error((const char *) ID3D10Blob_GetBufferPointer(*blob)); |
296 ID3D10Blob_Release(*blob); |
300 ID3D10Blob_Release(*blob); |
496 needs_free = 0; |
500 needs_free = 0; |
497 } // else |
501 } // else |
498 |
502 |
499 result = ctx->D3DCompileFunc(source, strlen(source), |
503 result = ctx->D3DCompileFunc(source, strlen(source), |
500 pshader->parseData->mainfn, NULL, NULL, |
504 pshader->parseData->mainfn, NULL, NULL, |
501 pshader->parseData->mainfn, "ps_4_0", 0, 0, |
505 pshader->parseData->mainfn, "ps_4_0", |
502 &blob, &blob); |
506 D3D_SKIP_OPT, 0, &blob, &blob); |
503 |
507 |
504 if (result < 0) |
508 if (result < 0) |
505 { |
509 { |
506 set_error((const char *) ID3D10Blob_GetBufferPointer(blob)); |
510 set_error((const char *) ID3D10Blob_GetBufferPointer(blob)); |
507 ctx->free_fn((void *) source, ctx->malloc_data); |
511 ctx->free_fn((void *) source, ctx->malloc_data); |