SharpDX.Toolkit throws error when loading effect. HRESULT: [0x80070057]

0

Here I have an application based on SharpDX, it's supposed to simulate particles using Computer Shader. I run it on Win 8.1 computer at Intel HD 3000 videocard. By the way, samples from SharpDX with Computer Shader and (or) Vertex Shader with requirments like fx_4_0 or Profile = 10.0 runs flawlesly.

The problem is, when it comes to loading the shader via Content.Load<Effect>() it throws an exception from SharpDX.Direct3D11.Device.CreateVertexShader()

The exception is as follows:

[SharpDX.SharpDXException]  {
     SharpDX.SharpDXException: HRESULT: [0x80070057],
     Module: [General], ApiCode: [E_INVALIDARG/Invalid Arguments], 
     Message: The parameter is incorrect.
at SharpDX.Result.CheckError()
at SharpDX.Direct3D11.Device.CreateVertexShader(IntPtr shaderBytecodeRef, PointerSize bytecodeLength, ClassLinkage classLinkageRef, VertexShader vertexShaderOut)
at SharpDX.Direct3D11.VertexShader..ctor(Device device, Byte[] shaderBytecode, ClassLinkage linkage)
at SharpDX.Toolkit.Graphics.EffectPool.GetOrCompileShader(EffectShaderType shaderType, Int32 index, Int32 soRasterizedStream, StreamOutputElement[] soElements, String& profileError)
...
at SharpDX.Toolkit.Content.ContentManager.Load[T](String assetName, Object options)

Well, I've looked around for a while, but nowhere found a complite explanation - what exactly happens here? As stated here, the problem likely is with the VertexShader arguments, but as I'm newbie in shader development, I can't be shure. Nonetheless, here is the shader file:

struct Particle
{
    float3 Position;
    float3 Velocity;
};

StructuredBuffer<Particle> Particles : register(t0);
cbuffer Params : register(b0)
{
    float4x4 View;
    float4x4 Projection;
};

struct VertexInput
{
    uint VertexID : SV_VertexID;
};

struct PixelInput
{
    float4 Position : SV_POSITION; 
};

struct PixelOutput
{
    float4 Color : SV_TARGET0;
};

PixelInput DefaultVS(VertexInput input)
{
    PixelInput output = (PixelInput)0;

    Particle particle = Particles[input.VertexID];

    float4 worldPosition = float4(particle.Position, 1);
    float4 viewPosition = mul(worldPosition, View);
    output.Position = mul(viewPosition, Projection);
    return output;
}

PixelOutput DefaultPS(PixelInput input)
{
    PixelOutput output = (PixelOutput)0;

    output.Color = float4((float3)0.1, 1);

    return output;
}

technique ParticleRender
{
    pass DefaultPass
    {
        Profile = 10.0;
        VertexShader = DefaultVS;
        GeometryShader = 0;
        PixelShader = DefaultPS;
    }
}

I suppose, the problem lies in VertexInput structure, and uint VertexID : SV_VertexID; because in sapmles I've never met anything like this. By the vay, the application came from , so it you know russian, you are welcome to go see the origin :). Also, full solution can be loaded form here

My code for effect loading is Content.Load<Effect>("ParticleRender"); and full stack trace is

at SharpDX.Result.CheckError()
at SharpDX.Direct3D11.Device.CreateVertexShader(IntPtr shaderBytecodeRef, PointerSize bytecodeLength, ClassLinkage classLinkageRef,  VertexShader vertexShaderOut)
at SharpDX.Direct3D11.VertexShader..ctor(Device device, Byte[] shaderBytecode, ClassLinkage linkage)
at SharpDX.Toolkit.Graphics.EffectPool.GetOrCompileShader(EffectShaderType shaderType, Int32 index, Int32 soRasterizedStream,  StreamOutputElement[] soElements, String& profileError)
at SharpDX.Toolkit.Graphics.EffectPass.InitStageBlock(StageBlock stageBlock, Logger logger)
at SharpDX.Toolkit.Graphics.EffectPass.Initialize(Logger logger)
at SharpDX.Toolkit.Graphics.Effect.InitializeFrom(Effect effectDataArg, Effect cloneFromEffect)
at SharpDX.Toolkit.Graphics.Effect.CreateInstanceFrom(GraphicsDevice device, EffectData effectData, EffectPool effectPool)
at SharpDX.Toolkit.Graphics.Effect..ctor(GraphicsDevice device, EffectData effectData, EffectPool effectPool)
at SharpDX.Toolkit.Graphics.EffectContentReader.ReadContent(IContentManager readerManager, GraphicsDevice device, ContentReaderParameters&  parameters)
at SharpDX.Toolkit.Graphics.GraphicsResourceContentReaderBase`1.SharpDX.Toolkit.Content.IContentReader.ReadContent(IContentManager  readerManager, ContentReaderParameters& parameters)
at SharpDX.Toolkit.Content.ContentManager.LoadAssetWithDynamicContentReader(Type assetType, String assetName, Stream stream, Object options)
at SharpDX.Toolkit.Content.ContentManager.Load(Type assetType, String assetName, Object options)
at SharpDX.Toolkit.Content.ContentManager.Load[T](String assetName, Object options)
at GPUParticles.Logic.LoadContent() in f:\Users\Maxim\UserData\Programming\GPUParticlesSources\GPUParticles\Logic.cs:line 63
at SharpDX.Toolkit.Game.InitializeBeforeRun()
at SharpDX.Toolkit.GameWindowDesktop.RunRenderLoop()
at SharpDX.Toolkit.GameWindowDesktop.Run()
at SharpDX.Toolkit.GamePlatform.Run(GameContext gameContext)
at SharpDX.Toolkit.Game.Run(GameContext gameContext)
at GPUParticles.Program.Main() in f:\Users\Maxim\UserData\Programming\GPUParticlesSources\GPUParticles\Program.cs:line 22}  SharpDX.SharpDXException
c#
hlsl
sharpdx
asked on Stack Overflow Feb 4, 2015 by Max Polovyi • edited Feb 4, 2015 by Max Polovyi

2 Answers

0

Whenever you have a SharpDXException, please follow "How to debug sharpDX exception"

It turned out that in reality the Intel 3000 do not have the support of the ComputeShader, despite having the support of the DirectX 10.0

answered on Stack Overflow Mar 23, 2015 by Max Polovyi
0

just stumbled over this as I had a similar error with monogame and trying to load a shader.

In my case this error was related to the graphicsDevice profile not being set to

HiDef

    graphics = new GraphicsDeviceManager(this);
    graphics.GraphicsProfile = GraphicsProfile.HiDef;

Cheers,

Stephan

answered on Stack Overflow May 7, 2018 by Stephan

User contributions licensed under CC BY-SA 3.0