Jump to content

  • Log In with Google      Sign In   
  • Create Account


Setting shader constants: Purpose of various functions


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
3 replies to this topic

#1 cdoubleplusgood   Members   -  Reputation: 793

Like
0Likes
Like

Posted 11 October 2013 - 02:43 AM

Hi Folks,

 

I have 2 questions regarding the various shader constant functions in IDirect3D9Device, e.g. SetVertexShaderConstantB/F/I.

 

1. Is my assumption correct that both SetVertexShaderConstantF and SetVertexShaderConstantI simply stuff a multiple of 128 bit into one or more constant registers, and there is not actual difference between them? That means, if I had a float[4] and cast a pointer to them to int*, I could use SetVertexShaderConstantI instead of SetVertexShaderConstantF with the same result. (No, I'm not actually going to do this; I just try to understand what goes on behind the scenes.)

2. What does SetVertexShaderConstantB do? How many bits in the constant register are taken for one BOOL? Both SetVertexShaderConstantF and SetVertexShaderConstantI take 4 values or a multiple of them; why is this different for SetVertexShaderConstantB?

 

Thanks!

 



Sponsor:

#2 Tordin   Members   -  Reputation: 604

Like
0Likes
Like

Posted 11 October 2013 - 07:06 AM

As i understand it´s just a naming convention and probably has to do some with how the shaders compiles and optimize. but in the end everything is just bytes.

I Dx11, it´s not named F/B/I and just SetConstantBuffer. And thats also why i assume it´s the same here and more of a naming convention than anything.

 

and if you read on msdn, there is no real hints that it would be anydiffrent.


"There will be major features. none to be thought of yet"

#3 Hodgman   Moderators   -  Reputation: 27690

Like
1Likes
Like

Posted 11 October 2013 - 08:15 AM

In DX9, the F version sets the c registers, the I version sets the i registers and the B version sets the b registers.

 

http://msdn.microsoft.com/en-us/library/windows/desktop/bb172963(v=vs.85).aspx

 

In HLSL SM2/3 (DX9), float, int and bool variables are all quite different, and are stored in these different types of registers.

 

As above, in SM4/5 (DX10/11) things have changed and you instead use SetConstantBuffer to bind constant buffers to b registers (b now == buffer, not bool), and ints/bools/floats exist inside these buffers.


Edited by Hodgman, 11 October 2013 - 08:16 AM.


#4 cdoubleplusgood   Members   -  Reputation: 793

Like
0Likes
Like

Posted 11 October 2013 - 08:24 AM


In DX9, the F version sets the c registers, the I version sets the i registers and the B version sets the b registers.

So I was completely wrong.

Thanks!






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