Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to fallback to a software/CPU based renderer when GPU is not available? #469

Closed
ngugcx opened this issue Oct 31, 2021 · 13 comments

Comments

@ngugcx
Copy link

ngugcx commented Oct 31, 2021

I noticed that the druid apps just not start without any errors when testing with my Window 7 virtual machines (run by virtualbox).
When GPU is not available for renderering, like in some kinds of remote desktop sessions, or virtual machines, is it possible to fallback to a software/CPU based renderer?

@raphlinus
Copy link
Contributor

It should be falling back to CPU rendering (using the warp renderer). There are probably still warning messages just from not finding the Windows 10 calls, and we should clean those up.

Could you post the error log?

@ngugcx
Copy link
Author

ngugcx commented Oct 31, 2021

PS C:\test> .\hello.exe
PS C:\test> �[2mNov 01 07:31:11.963�[0m �[32m INFO�[0m druid_shell::backend::windows::util: No shcore.dll
�[2mNov 01 07:31:11.963�[0m �[32m INFO�[0m druid_shell::backend::windows::util: Could not load `GetDpiForSystem`. Window
s 10 or later is needed
�[2mNov 01 07:31:11.963�[0m �[32m INFO�[0m druid_shell::backend::windows::util: Could not load `GetDpiForWindow`. Window
s 10 or later is needed
�[2mNov 01 07:31:11.979�[0m �[32m INFO�[0m druid_shell::backend::windows::util: Could not load `SetProcessDpiAwarenessCo
ntext`. Windows 10 or later is needed
�[2mNov 01 07:31:11.979�[0m �[32m INFO�[0m druid_shell::backend::windows::util: Could not load `GetSystemMetricsForDpi`.
 Windows 10 or later is needed
�[2mNov 01 07:31:11.979�[0m �[32m INFO�[0m druid_shell::backend::windows::util: No dcomp.dll
�[2mNov 01 07:31:11.979�[0m �[34mDEBUG�[0m druid::localization: available locales [], current zh-CN
�[2mNov 01 07:31:11.979�[0m �[34mDEBUG�[0m druid::localization: resolved: [en-US]
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: hresult 80004002', druid-shell\src\backend\windo
ws\window.rs:1350:48
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Looks like a limitation of druid_shell.
By the way, why it's not working "set RUST_BACKTRACE=1" in Dos?

druid-shell\src\backend\windows\window.rs
image

@raphlinus
Copy link
Contributor

Interesting. This shouldn't be happening. Here's a related StackOverflow question. Can you try changing D2D1_FACTORY_TYPE_MULTI_THREADED to D2D1_FACTORY_TYPE_SINGLE_THREADED in piet-direct2d/src/d2d.rs , and maybe also turning off the warnings?

@ngugcx
Copy link
Author

ngugcx commented Nov 1, 2021

Sure.
Is there an easy way to use my local piet repo with druid?

@raphlinus
Copy link
Contributor

You'll probably find success using the [patch] mechanism of Cargo.

@ngugcx
Copy link
Author

ngugcx commented Nov 1, 2021

Tried, the same error and logs.
By the way, I built on my Windows 10 desktop.

@raphlinus
Copy link
Contributor

This sounds like a dup of #443. Do you have Windows 7 platform update installed? We're absolutely not targeting anything earlier than that, and are considering raising our minimum version requirements anyway.

@ngugcx
Copy link
Author

ngugcx commented Nov 1, 2021

Ooops! I must have amnesia!!!

@ngugcx ngugcx closed this as completed Nov 1, 2021
@ngugcx ngugcx reopened this Nov 1, 2021
@ngugcx
Copy link
Author

ngugcx commented Nov 1, 2021

One more question.
Can I force it to fall back to CPU rendering from my druid app?

@raphlinus
Copy link
Contributor

I don't think it's a question of CPU rendering, it's because we're using the D2D1 interface which is not supported on pre-platform update Windows 7. And no, we're not going to make that change, as it comes with some really painful limitations, for example the fact that you have to discard and rebuild resources on certain events; note that the rebuild_resources method was originally for this, but should probably be removed now.

It's fine to ask, and I'd be happy to make it work if it didn't come with serious drawbacks, but the official answer is that Windows 7 with platform update is the earliest version we support.

@ngugcx
Copy link
Author

ngugcx commented Nov 1, 2021

I was not asking to support pre-platform update Windows 7.
I just want to know if there is a way to force to CPU rendering for debug purpose.

@raphlinus
Copy link
Contributor

Ah, I misunderstood. Here's the place to patch druid: https://github.com/linebender/druid/blob/master/druid-shell/src/backend/windows/dcomp.rs#L54. Remove D3D_DRIVER_TYPE_HARDWARE or put WARP first, depending on how you want fallback to behave.

@Arquios
Copy link

Arquios commented Dec 20, 2022

Hi, i found the solution!!!, Windows 7 SP1 32-bit needs the "Platform Update for Windows 7" patch (Windows6.1-KB2670838-x86.msu), the patch activates and improves the Direct2D library (the d2d1.dll file among other things) with version 1.1, since the one installed in Windows 7 SP1 is present but disabled by default in addition to an outdated version of d2d1.dll, it is worth mentioning that this does not happen in 64-bit versions of windows because it is already activated.

I had been fighting with this for 3 days, I have successfully tested it on 8 computers that had the same problem and in various forums like this one or this one they mention the advantages of using it.

Note: If once the patch is installed it doesn't work, try the command to force the registry with "regsrv32 C:\Windows\System32\d2d1.dll" to unlock it and even if it gives an error it will work when you try again, it happened to me on 1 of the 8 computers.

Note 2: Don't forget to compile using the --target i686-pc-windows-msvc in your cargo command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants