Jump to content
  • Advertisement
Sign in to follow this  
thomasvantroyen

difference between xna 4 or directx 10 HLSL?

This topic is 2528 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi,

i've been using Xna 4 for quite a while now (2D mostly), but with the rumours about xna disappearing I thought to check out the real stuff (c++ & directX 10 sdk) and learn more about the 3D using the very good "Introduction to DirectX 10 game programming" book.

Doing this I discovered something weird (to me, that is). The HLSL in my book on DirectX 10 is different than XNA 4's. I'm starting to think XNA 4 is not directX 10, but then again i'm quite certain my XNA 4 games won't run on WinXP machines, so DirectX 9c is not supported.

Anyway, when i try to compile HLSL code from my DX10 book in XNA 4, i must change these things until it compiles:
* "technique10" should be "technique"
* SetGeometryShader must be deleted, it errors about the shader version that's not supported
* the VS and PS version stated in the technique, are not supported (only <= 3_0 works)

So, why is there a difference, what am I missing between native DX10 and XNA 4? And if it's DX9c after all, why doesn't XNA 4 work on WinXP?

Sample: (DirectX 10 effect)

[font="Consolas"][size="2"][font="Consolas"][size="2"]cbuffer cbPerObject[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]{[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]float4x4 gWVP; [/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]};[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]void VS(float3 iPosL : POSITION,[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]float4 iColor : COLOR,[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]out float4 oPosH : SV_POSITION,[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]out float4 oColor : COLOR)[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]{[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]// Transform to homogeneous clip space.[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]oPosH = mul(float4(iPosL, 1.0f), gWVP);[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]// Just pass vertex color into the pixel shader.[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]oColor = iColor;[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]}[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]float4 PS(float4 posH : SV_POSITION,[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]float4 color : COLOR) : SV_Target[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]{[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]return color;[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]}[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"][color=#B22222]technique10 ColorTech[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]{[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]pass P0[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]{[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]SetVertexShader( CompileShader( [color=#B22222]vs_4_0, VS() ) );[/font][/font]
[color=#B22222][font="Consolas"][size="2"][font="Consolas"][size="2"]SetGeometryShader( NULL );[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]SetPixelShader( CompileShader( [color=#B22222]ps_4_0, PS() ) );[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]}[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]}[/font][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"] [/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]thanks[/font][/font]

Share this post


Link to post
Share on other sites
Advertisement
XNA 4 is built on D3D9. It absolutely works on Windows XP. XP is there in the list of supported operatoring systems. If your game doesn't work on XP, then there must be a problem with your game or how you're deploying it.

D3D10 brought some huge changes when it came out, and a lot of them had to do with Shader Model 4.0 which brought a lot of new shader features. There were also changes to the effect framework (which is seperate from core shaders), which is why you had to change "technique" to "technique10".

If you want to learn D3D10/D3D11, then I'm afraid you're going to have to actually use those API's. XNA is limited to a subset of D3D9-era functionality, which means you're going to get to a point in your book where there's no way to translate it back to XNA and SM3.0. If you want to know what you're missing out on by sticking with SM3.0, there's some info in the documentation:

http://msdn.microsof...v=vs.85%29.aspx

http://msdn.microsof...v=vs.85%29.aspx

http://msdn.microsoft.com/en-us/library/windows/desktop/ff476342%28v=vs.85%29.aspx

Share this post


Link to post
Share on other sites
thanks, after googling around a bit more, i indeed found out it's actually DX9 but with some non-standardized features (in hidef profile) that only work by DX10 supporting hardware. that's probably the reason why it's not working on xp machines, they often don't have DX10 hardware.

But thanks for clarifying even more.

So, i guess I'll have to learn C++ with all the difficult COM syntax and macro's. I'm a pro .NET guy for about 8 years, but damn, advanced C++ is hard to learn in absence of decent code completion and helping descriptions popping up everywhere. pitty c++ hasnt changed much the last decade. Even c++11 doesn't bring much improvement on the usability-domain imho. The IDE is just not very helpfull, like c# or any more mainstream language.

Ah well, i guess my hobby-games will have to settle with DX 9 :) It's more about the AI to me anyway.

thanks

Share this post


Link to post
Share on other sites
Yeah you also have the option of managed wrappers like SlimDX and SharpDX. They fully expose D3D10/D3D11, so you don't lose out on anything that you would have by using native C++.

Share this post


Link to post
Share on other sites
i'm speechless...

you just made my day, or probably even my year :)

i already wondered why there wasn't anybody making some .NET interop of DX, but i figured XNA (what i thought to be DX10 before today) made any such attempt obsolete and that explained why no decent interop project existed.. but apparently they DO exist !!

thank you for your service but please close the door behind you, XNA :)

thanks a whole lot!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!