Skip to content

Commit

Permalink
Merge pull request #816 from SunDaw/d3d11-retry
Browse files Browse the repository at this point in the history
try creating D3D11Device without debug flag if failed
  • Loading branch information
RobDangerous authored Oct 10, 2023
2 parents 2dcc2bc + 5d47206 commit 16ad473
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,16 @@ void kinc_g4_internal_init(void) {
#endif
HRESULT result = D3D11CreateDevice(adapter, D3D_DRIVER_TYPE_HARDWARE, NULL, flags, featureLevels, ARRAYSIZE(featureLevels), D3D11_SDK_VERSION,
&dx_ctx.device, &featureLevel, &dx_ctx.context);

#ifdef _DEBUG
if (result == E_FAIL || result == DXGI_ERROR_SDK_COMPONENT_MISSING) {
kinc_log(KINC_LOG_LEVEL_WARNING, "%s", "Failed to create device with D3D11_CREATE_DEVICE_DEBUG, trying without");
flags &= ~D3D11_CREATE_DEVICE_DEBUG;
result = D3D11CreateDevice(adapter, D3D_DRIVER_TYPE_HARDWARE, NULL, flags, featureLevels, ARRAYSIZE(featureLevels), D3D11_SDK_VERSION,
&dx_ctx.device, &featureLevel, &dx_ctx.context);
}
#endif

if (result != S_OK) {
kinc_log(KINC_LOG_LEVEL_WARNING, "%s", "Falling back to the WARP driver, things will be slow.");
kinc_microsoft_affirm(D3D11CreateDevice(adapter, D3D_DRIVER_TYPE_WARP, NULL, flags, featureLevels, ARRAYSIZE(featureLevels), D3D11_SDK_VERSION,
Expand Down

0 comments on commit 16ad473

Please sign in to comment.