Jump to content

  • Log In with Google      Sign In   
  • Create Account


HLSL semantic & Xna data type problem


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 thecheeselover   Members   -  Reputation: 308

Like
0Likes
Like

Posted 16 June 2012 - 05:38 PM

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
Hide yo cheese! Hide yo wife!

Sponsor:

#2 MJP   Moderators   -  Reputation: 10235

Like
1Likes
Like

Posted 17 June 2012 - 01:25 AM

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.

#3 thecheeselover   Members   -  Reputation: 308

Like
0Likes
Like

Posted 17 June 2012 - 06:49 AM

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! :)
Hide yo cheese! Hide yo wife!

#4 Adam_42   Crossbones+   -  Reputation: 2361

Like
1Likes
Like

Posted 17 June 2012 - 08:00 AM

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.

#5 thecheeselover   Members   -  Reputation: 308

Like
0Likes
Like

Posted 17 June 2012 - 09:46 AM

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?
Hide yo cheese! Hide yo wife!

#6 Adam_42   Crossbones+   -  Reputation: 2361

Like
0Likes
Like

Posted 17 June 2012 - 03:21 PM

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?

#7 thecheeselover   Members   -  Reputation: 308

Like
0Likes
Like

Posted 17 June 2012 - 04:36 PM

I only want to pass a byte for each vertex and then use a switch statement to check if the value is 0, 1, 2, 3, 4 or 5.
Hide yo cheese! Hide yo wife!




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS