• Advertisement
Sign in to follow this  

Setting shader constants: Purpose of various functions

This topic is 1560 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 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!

 

Share this post


Link to post
Share on other sites
Advertisement

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites


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!

Share this post


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

  • Advertisement