[SOLVED] Effect load errors with latest build (DirectX)

I know that with the latest dev builds, things will be broken. With the content pipeline processor, my shader compiles with no errors, so I assume there’s no inline errors. It may be naïve to assume that though. The link to my shader is here. I’m sure there’s plenty of work to be done with the shaders, but this is my first time doing anything shader related, so bear with me here.
The code to load the shader is typically embedded into one of my scenes, but even when it’s loaded in Game.LoadContent(), it still throws the same errors. The error is as follows:
SharpDX.SharpDXException: 'HRESULT: [0x80070057], Module: [General], ApiCode: [E_INVALIDARG/Invalid Arguments], Message: The parameter is incorrect.
with the stacktrace being
at SharpDX.Result.CheckError()\r\n at SharpDX.Direct3D11.Device.CreatePixelShader(IntPtr shaderBytecodeRef, PointerSize bytecodeLength, ClassLinkage classLinkageRef, PixelShader pixelShaderOut)\r\n at SharpDX.Direct3D11.PixelShader..ctor(Device device, Byte[] shaderBytecode, ClassLinkage linkage)\r\n at Microsoft.Xna.Framework.Graphics.Shader.CreatePixelShader()\r\n at Microsoft.Xna.Framework.Graphics.Shader.PlatformConstruct(Boolean isVertexShader, Byte[] shaderBytecode)\r\n at Microsoft.Xna.Framework.Graphics.Shader..ctor(GraphicsDevice device, BinaryReader reader)\r\n at Microsoft.Xna.Framework.Graphics.Effect.ReadEffect(BinaryReader reader)\r\n at Microsoft.Xna.Framework.Graphics.Effect..ctor(GraphicsDevice graphicsDevice, Byte[] effectCode, Int32 index, Int32 count)\r\n at Microsoft.Xna.Framework.Content.EffectReader.Read(ContentReader input, Effect existingInstance)\r\n at Microsoft.Xna.Framework.Content.ContentTypeReader`1.Read(ContentReader input, Object existingInstance)\r\n at Microsoft.Xna.Framework.Content.ContentReader.InnerReadObject[T](T existingInstance)\r\n at Microsoft.Xna.Framework.Content.ContentReader.ReadObject[T]()\r\n at Microsoft.Xna.Framework.Content.ContentReader.ReadAsset[T]()\r\n at Microsoft.Xna.Framework.Content.ContentManager.ReadAsset[T](String assetName, Action`1 recordDisposableObject)\r\n at Microsoft.Xna.Framework.Content.ContentManager.Load[T](String assetName)\r\n at Welt.WeltGame.LoadContent() in C:\\Users\\dubst\\Documents\\welt\\Welt\\WeltGame.cs:line 101\r\n at Microsoft.Xna.Framework.Game.Initialize()\r\n at Welt.WeltGame.Initialize() in C:\\Users\\dubst\\Documents\\welt\\Welt\\WeltGame.cs:line 183\r\n at Microsoft.Xna.Framework.Game.DoInitialize()\r\n at Microsoft.Xna.Framework.Game.Run(GameRunBehavior runBehavior)\r\n at Welt.Program.Main(String[] args) in C:\\Users\\dubst\\Documents\\welt\\Welt\\Program.cs:line 19
I understand that SharpDX is throwing the error when it attempts to check the pixel shader for errors, but I’m confused as to what’s throwing the errors. With previous builds of MonoGame, this never happened. The shader hasn’t been changed for a couple weeks now with the last successful build of my game being beginning of Jan.
If I don’t ever load this shader, everything works fine. This tells me the graphics device and graphics device manager are loaded and initialized properly. I’ve been pulling my hair out for 2 days now trying to figure this out and any help is appreciated. I’m not sure if perhaps I’m just being stupid or if there’s a legitimate issue with the Effect compiler.

1 Like

Make sure the GraphicsProfile is set to HiDef. The best way to do that is to set the GraphicsProfile property of the GraphicsDeviceManager in your game constructor. There is an open issue for throwing a nicer exception in this case.

6 Likes

Awesome, that worked. I didn’t see it in the issues list. Thanks a ton!

1 Like