microsoft / angle

ANGLE: OpenGL ES to DirectX translation
Other
615 stars 166 forks source link

Long shader compile times with D3D11 backend #140

Closed vnen closed 6 years ago

vnen commented 6 years ago

I'm trying to port the Godot Engine for a UWP export. Godot's new renderer is based on OpenGL ES 3.0, so I'm using ANGLE since UWP only supports DirectX rendering.

It works well, but for 3D scenes the shaders take way too long to compile (Godot's shaders can get quite complex) and I get the error 0x887A0005 (DXGI_ERROR_DEVICE_REMOVED) because the app becomes unresponsive for too long trying to compile the shaders.

With help of the rendering expert from Godot I manage to get a simple scene showing up without errors, but it took about 25 seconds to compile the shaders and if I use more objects in the scene, it takes longer, to the point the app is killed again. I notice it uses one core of my Intel i3 CPU fully while it's compiling.

TL;DR: is there something I can do speed up this process? Is there an option in ANGLE to avoid some checkings and make it quicker to compile?

austinkinross commented 6 years ago

Hi! Unfortunately shader compilation is generally slow. The existing D3DCompiler wasn't designed to be used at runtime as aggressively as ANGLE uses it. ANGLE also adds an additional GLSL->HLSL translation layer on top of it which further slows down shader compilation.

There are potential workarounds that may help you though, such as caching compiled shaders (see here for details).

vnen commented 6 years ago

Thanks for the answer and sorry for the long silence, but I haven't got the time to work on this (also kind of ran out of options). I'll see if I get some time to try caching the shaders, though it might be still a problem for the first compile...

Anyway, I'll close this since I have my answer.