[Solved] Invalid Shader Version Issue

Started by
5 comments, last by Dryak 13 years, 6 months ago
Hello everyone.

I am currently working on making a game engine and I have been following the tutorials on http://www.directxtutorial.com/ learning DirectX 11.

Everything was going well until a few hours ago when I hit a brick wall.

I'm currently trying to get a triangle to render.
However, the shaders aren't being created and I get an invalid argument return.
Also since I have debugging turned on, I get the below read out in the output window.

D3D11: ERROR: ID3D11Device::CreateVertexShader: Invalid shader version provided: vs_5_0 [ STATE_CREATION ERROR #167: CREATEVERTEXSHADER_INVALIDSHADERTYPE ]

D3D11: ERROR: ID3D11Device::CreatePixelShader: Invalid shader version provided: ps_5_0 [ STATE_CREATION ERROR #193: CREATEPIXELSHADER_INVALIDSHADERTYPE ]


However, when I run the (near) exact same code from the DirectX tutorial from the DirectX sample browser, the triangle renders just fine, so I know the problem has to be in my code and not my hardware. I've tried v4 with the same result and anything below v3 just crashes.

After comparing my code very closely to all the tutorials I have, I am looking to see if anyone here can help me figure this out.

I've included links to all my code files. They are in the format of a basic game engine and all the included files just need to be compiled in a DirectX ready project.

<br><br>Thanks in advance for looking at this.<br>-Dryak<br><br><!--EDIT--><span class=editedby><!--/EDIT-->[Edited by - Dryak on October 6, 2010 2:06:02 AM]<!--EDIT--></span><!--/EDIT-->
Advertisement
What feature level is your D3D device? (which should match the maximum feature level possible for your video card). It would seem that you probably do not have support for featurelevel 11.0 which is required for sm5.0. You have to compile the shader to at least match the hardware feature level.
Hey, thanks for replying.

I don't know the max feature level but I do know that I have a nVidia 8800GT.

However, as I said above, the Shaders tutorial out of the DirectX 11 Sample Browser runs just fine. Any thoughts on how thats possible?
The sample is adjusting the compile to work with any of the feature levels. Your video card is DX10 only, so can only create a shader that was compiled to vs_4_0/ps_4_0.
I've tried compiling using v4 and I get the same result.

I've also copied over the code from the same which determines the feature level and it didn't work.
Could you update the code you posted to include the changes. Be sure to add in the variable to detect what feature level device was created. What feature level does it successfully create?

Ah, I see the problem. The feature levels are attempted in order from the featureLevels parameter that you passed to CreateDevice. The first feature level to successfully create will return. In this case, that would be a level 9.1 device, which would require you to compile your shader code to vs_4_0_level_9_1 and ps_4_0_level_9_1 targets. Reorder your feature level array to be in descending order.
Thank you, that has made it work just fine.
Also, thanks extra for the quick replies!

This topic is closed to new replies.

Advertisement