Jump to content
  • Advertisement
Sign in to follow this  
Baesky

DX11 i'm confusing with with dx11 shader

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

[font="Consolas"][font="Consolas"]
does all width of a register is 4 floats lang? how can a martix aligned with one register?


i thought a register is 128bit, matrix is 128bit x 4.
cbuffer cbChangeOnResize : register( b1 )

{

matrix Projection;

};

cbuffer cbNeverChanges : register( b0 )

{

matrix View;

};

[/font][/font]

Share this post


Link to post
Share on other sites
Advertisement

A float is 32 bits wide and 4x32 == 128, so you thought correctly.



but a Matrix could be 128*4 , am i right?
so how can you set a container which only can hold 4 floats to store a matrix which cap is 4X4 floats?

plz~ :)

Share this post


Link to post
Share on other sites
[float]\
[float] \ b
[float] / 0 <----- [font="Consolas"]matrix View 4[float]x4[float][/font]
[float]/
[float]\
[float] \ b
[float] / 1
[float]/
[float]\
[float] \ b
[float] / 2
[float]/


look the pic, if i use view to fill b0, obviously it even occupy not b0 and b1,b2, the space still not enough...

Share this post


Link to post
Share on other sites
As you said in your first post, a matrix is 128bit x 4.

Each row of the matrix occupies one register.

Share this post


Link to post
Share on other sites
I think you are confusing constant buffers with constant registers from the older API levels. A constant buffer holds a bunch of data, which can consist of some combination of floats, ints and bools (and structs of them as well). These data are used to fill 4 component vector registers.

Each complete constant buffer is bound to a single buffer slot with the ID3D11DeviceContext::xSSetConstantBuffers(...). These buffer slots are not the same as a register - they are only used to reference a complete constant buffer. So it can appear that each matrix is only taking up a single four component register when in reality it is taking up one constant buffer slot.

However, to the best of my knowledge the constant buffers are referenced with the cb0, cb1, ..., cb[n] syntax instead of just a "b[n]" syntax. I don't normally track the slots that each buffer uses, so I'm not 100% sure about that point though... It would probably be easy to check if you produce a code listing from your shader with the FXC.exe tool (which can be found in the SDK).

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!