Jump to content
  • Advertisement
Sign in to follow this  
thecheeselover

HLSL semantic & Xna data type problem

This topic is 2221 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

Hello,

I'm actually trying to pass a byte into my vertex shader's input, but because I didn't see any semantic of the byte data type, I'm trying to pass an uint. I have a little problem with Xna when I try to pass my uint : I don't see any kind of vertex element format that is close to be like a uint. Everything things I see are floating points or vectors. How can I pass my uint if there is no vertex element format for this type of data? Also, is there a way I could pass a byte (without a semantic) into my vertex shader's input?

Thank you,
thecheeselover

Share this post


Link to post
Share on other sites
Advertisement
DX9 shaders don't support integer operations or data types, they only work with floating point. Consequently, all vertex element formats will either specify a floating point format or will convert from integer to floating point. You can use the uint type in your HLSL code, but when the shader is compiled it will only use floating point instructions.

Share this post


Link to post
Share on other sites

DX9 shaders don't support integer operations or data types, they only work with floating point. Consequently, all vertex element formats will either specify a floating point format or will convert from integer to floating point. You can use the uint type in your HLSL code, but when the shader is compiled it will only use floating point instructions.


What about DX10 shaders? Do they support integers or it's the same as DX9? Also, if I use a half (half float), will the shader still convert it into a 32 bit float?

Thank you! :)

Share this post


Link to post
Share on other sites
DX10 does have integer support.

The half data type will have the precision of at least a 16-bit float, on some hardware it will be higher. If you need more precision use floats.

Share this post


Link to post
Share on other sites

DX10 does have integer support.

The half data type will have the precision of at least a 16-bit float, on some hardware it will be higher. If you need more precision use floats.


Thank you. Now for my main questions:

How can I pass a uint from Xna to my shader if there is no vertex element format for this type of data? Also, is there a way I could pass a byte (without a semantic) into my vertex shader's input?

Share this post


Link to post
Share on other sites
A float can't represent the full range of values of a uint, and DX9 shaders can only work with floats (and half floats). You'll start losing precision once you go over 2^24. That means passing a uint to a DX9 shader isn't possible. However you can convert it to a float first and then pass it over if you don't need the full range of values.

A float can easily represent the full range of values of a byte, so just convert it to a float and pass it to the shader in any way you want.

What are you trying to achieve by doing this?

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!