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

Helix3D/SharpDX not working on Windows 10 with only DirectX 12 installed #257

Closed
janjensendk opened this issue Feb 25, 2016 · 6 comments
Closed

Comments

@janjensendk
Copy link

Problem:
The "Effects" part of Helix3D/SharpDX does not work on a newly installed Windows 10 machine, where only DirectX 12 is installed. It gives the following error trace:

System.Windows.Markup.XamlParseException: The invocation of the constructor on type 'MyNamespace.MyClass' that matches the specified binding constraints threw an exception. ---> System.DllNotFoundException: Unable to find [sharpdx_direct3d11_effects_x64.dll] in the PATH
   at SharpDX.Utilities.LoadLibrary(String dllName)
   at SharpDX.Direct3D11.D3DX11Effects.get_DllHandle0()
   at SharpDX.Direct3D11.D3DX11Effects.get_D3DX11CreateEffectFromMemory_()
   at SharpDX.Direct3D11.D3DX11Effects.CreateEffectFromMemory(IntPtr dataRef, PointerSize dataLength, Int32 fXFlags, Device deviceRef, Effect effectOut)
   at SharpDX.Direct3D11.Effect..ctor(Device device, Byte[] effectByteCode, EffectFlags fxFlags)
   at HelixToolkit.Wpf.SharpDX.DefaultEffectsManager.RegisterEffect(Byte[] shaderEffectBytecode, RenderTechnique[] techniques, EffectFlags eFlags)
   at HelixToolkit.Wpf.SharpDX.DefaultEffectsManager.RegisterEffect(String shaderEffectString, RenderTechnique[] techniques, ShaderFlags sFlags, EffectFlags eFlags)
   at HelixToolkit.Wpf.SharpDX.DefaultEffectsManager.RegisterDefaultLayoutsAndEffects(String shaderEffectString, InputLayout& defaultInputLayout, InputLayout& cubeMapInputLayout)
   at HelixToolkit.Wpf.SharpDX.DefaultEffectsManager.InitEffects()
   at HelixToolkit.Wpf.SharpDX.DefaultEffectsManager..ctor(IRenderTechniquesManager renderTechniquesManager)
   at MyNamespace.MyClass.ctor()
   --- End of inner exception stack trace ---

The message is actually useless because the "sharpdx_direct3d11_effects_x64.dll" is available next to the application .exe. In reality it fails to load the .dll file, because the effects.dll fails to find/load another .dll (D3DCompiler_43.dll). I used Dependency Walker to figure that out.

Steps to reproduce:

  • Get a freshly installed Windows 10 machine, where only the basics has been installed: (.NET 4.6 and DirectX 12).
  • Try to run any of the DXSharp samples which uses effects.

Possible workaround 1:
Windows 10 users must manually install an older version of DirectX (10?) where D3DCompiler_43.dll is present. From what I can see, Windows 10 only comes with DirectX 12 (with D3DCompiler_47.dll) on a newly installed machine. Remark: Machines upgraded from Win7/8 did not have any problems, since they already had previous versions of DirectX.

Possible workaround 2:
Include D3DCompiler_43.dll in the same way as the sharpdx_direct3d11_effects_x86/64.dll's.

If I search my machine for "D3DCompiler_*", I can find applications like Firefox which has followed this route.

I implemented this approach in my application, but I had to force x86 compilation in order to make sure the D3DCompiler_43.dll matched (it exists in both 32-bit and 64-bit versions, with the exact same name...). It was not pretty, but it allows my application to run on stock Windows 10 machines without having to install extra stuff.

@smischke
Copy link
Contributor

There were a few others who had this issue before (not Windows 10 specific). You need to install the DirectX runtime. It's a more or less known requirement.
https://www.microsoft.com/en-us/download/details.aspx?id=8109

Maybe we can get rid of the this dependency when using only compiled shaders by default (which we are already doing afaik) and dropping the support for runtime compiled shaders. A custom EffectsManager in an optional or custom assembly could then provide runtime compiled shaders. A material system like in game engines where the shader (source code) is part of the material is nice, but this is not a game engine in the first place.

@janjensendk
Copy link
Author

Thanks for the answer.

Unfortunately installing DirectX is not always that simple. Running the wrong dxsetup.exe will just tell the user that the latest version of DirectX (12) is already installed. So for this to be robust, the correct dxsetup must be bundled and silently installed.

Like you said, this is not a game engine, so it would be reasonable to expect this to run just on .NET and the latest DirectX, without having to resort of installing more specific (older) dependencies.

I can see that SharpDX has upgraded sharpdx_direct3d11_effects.dll in their main branch, but since they also ditched support for the SharpDX.Toolkit, I guess its out of the question for Helix3D to just upgrade to the latest version of SharpDX and check if that handles the D3DCompiler 43 vs 47 thing more gracefully.

@SiNeumann
Copy link
Contributor

I think upgrading to ShardDX 3.01 could clear a lot of headache in this regard, unfortunately the have a lot of breaking changes so it would be a lot of work + SharpDX.Toolbox is not yet updated and as far as I can see it HelixToolkit.SharpDx relies on this.

@Pierre-de-la-Verre
Copy link

Hi

I'm not sure if I'm here on the right forum, but let's see:

I just installed "Dynamo" for Revit,
https://forum.dynamobim.com/
http://dynamoprimer.com/en/

and sometime I get this message (and sometimes an immediately crash):

SharpDX.SharpDXException: HRESULT: [0x887A0005], Module: [SharpDX.DXGI], ApiCode: [DXGI_ERROR_DEVICE_REMOVED/DeviceRemoved], Message: Die GPU-Geräteinstanz wurde angehalten. Verwenden Sie GetDeviceRemovedReason, um die erforderliche Aktion zu bestimmen.

   bei SharpDX.Result.CheckError()
   bei SharpDX.Direct3D11.Device.CreateBuffer(BufferDescription& descRef, Nullable`1 initialDataRef, Buffer bufferOut)
   bei SharpDX.Direct3D11.Buffer..ctor(Device device, DataStream data, BufferDescription description)
   bei HelixToolkit.Wpf.SharpDX.RenderUtil.CreateBuffer[T](Device device, BindFlags flags, Int32 sizeofT, T[] range)
   bei HelixToolkit.Wpf.SharpDX.LineGeometryModel3D.Attach(IRenderHost host)
   bei Dynamo.Wpf.ViewModels.Watch3D.DynamoLineGeometryModel3D.Attach(IRenderHost host)
   bei HelixToolkit.Wpf.SharpDX.Viewport3DX.HelixToolkit.Wpf.SharpDX.IRenderer.Attach(IRenderHost host)
   bei HelixToolkit.Wpf.SharpDX.DPFCanvas.Render()
   bei HelixToolkit.Wpf.SharpDX.DPFCanvas.UpdateAndRender()

Is this the same problem - and the same solution?

Thanks

Peter

@holance
Copy link
Member

holance commented Jul 12, 2017

Try to download the helix toolkit source and run the helix toolkit demos. Maybe dynamo is still using the old version.

@Pierre-de-la-Verre
Copy link

For me, it is OK now: Revit 2018 with Dynamo 1.3.1 runs without crashes ...

@holance holance closed this as completed Jul 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants