Get SharpDXException Invalid Parameters when try to create a new Texture for DirectX 9 on 32bit NVidia Quadro M1000M

1

I created a control that render over WPF using SharpDX. The code runs fine in most computer, video cards and configurations..

However, I am having issues when the app using the component is compiled for X86 and used in a NVIDIA Quadro M1000M or in AMD Radeon R5 430. If the app is compile in x64 all works fine.

This is what I am using:

 format = SharpDX.Direct3D9.Format.A8R8G8B8;
 //target.Description.Width = 10,  target.Description.Height = 10.
 this.renderTarget = new SharpDX.Direct3D9.Texture(WPFImageSource.device, target.Description.Width, target.Description.Height, 1, Usage.RenderTarget, format, Pool.Default, ref handle);

Any idea will be welcome. Edit: This is the exception details:

Exception Setup D3D Enviroment: SharpDX.SharpDXException: HRESULT: [0x80070057], Module: [General], ApiCode: [E_INVALIDARG/Invalid Arguments], Message: The parameter is incorrect.

   at SharpDX.Result.CheckError() in C:\projects\sharpdx\Source\SharpDX\Result.cs:line 195
   at SharpDX.Direct3D9.Device.CreateTexture(Int32 width, Int32 height, Int32 levels, Int32 usage, Format format, Pool pool, Texture textureOut, IntPtr sharedHandleRef) in C:\projects\sharpdx\Source\SharpDX.Direct3D9\Generated\Interfaces.cs:line 5089
   at SharpDX.Direct3D9.Texture..ctor(Device device, Int32 width, Int32 height, Int32 levelCount, Usage usage, Format format, Pool pool, IntPtr& sharedHandle) in C:\projects\sharpdx\Source\SharpDX.Direct3D9\Texture.cs:line 65
   at EV3D.Rendering.WPFImageSource.SetRenderTarget(Texture2D target) in D:\projects\ev3dsdk\EVRenderer_WPF\WPFImageSource.cs:line 118
Exception Setup D3D Enviroment: SharpDX.SharpDXException: HRESULT: [0x80070057], Module: [General], ApiCode: [E_INVALIDARG/Invalid Arguments], Message: The parameter is incorrect.

   at EV3D.Rendering.WPFImageSource.SetRenderTarget(Texture2D target) in D:\projects\ev3dsdk\EVRenderer_WPF\WPFImageSource.cs:line 131
   at EV3D.Rendering.EVRenderContext.CreateAndBindTargets() in D:\projects\ev3dsdk\EVRenderer_WPF\EVRenderContext.cs:line 420
   at EV3D.Rendering.EVRenderContext.StartD3D() in D:\projects\ev3dsdk\EVRenderer_WPF\EVRenderContext.cs:line 276
textures
nvidia
sharpdx
direct3d9
asked on Stack Overflow Dec 5, 2019 by Daniel Rojas • edited Dec 5, 2019 by Daniel Rojas

1 Answer

0

I finally figure out the issue. We were creating two device context, one for DX11 and the one of DX9 to be able to render over WPF. However, when create the device for DX9 I was passing all time the adapter index 0, but when we create the DX11 device I select the "best adapter" that not necessarily was the same. So you can imagine why this happen.

So, this problem only give in systems with 2 video cards.

answered on Stack Overflow Dec 9, 2019 by Daniel Rojas

User contributions licensed under CC BY-SA 3.0