Jump to content
• ### What is your GameDev Story?

• Advertisement

# DX11 i'm confusing with with dx11 shader

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

##### Share on other sites
Advertisement
A float is 32 bits wide and 4x32 == 128, so you thought correctly.

#### Share this post

##### Share on other sites

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

##### 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

##### 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

##### 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

##### Share on other sites

• Advertisement
• Advertisement
• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

(You must login to your GameDev.net account.)

• ### Popular Now

• 10
• 11
• 13
• 9
• 11
• Advertisement
• ### Forum Statistics

• Total Topics
634090
• Total Posts
3015434
×

## Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!