Documentation for "Packing Rules for Constant Variables" is wrong

Vadim Chuprakov 1 Reputation point

Documentation for Packing Rules for Constant Variables ( or is wrong.

I'm making constant buffer in DirectX11 HLSL (shader model 5) and introspecting it through the code:

Shader code looks like this:

And my program output:

So, size of constant buffer is 32 bytes. I assume, it is packed like this:

Documentation stands, that:

I assume, it is packed like this:

Documentation's constant buffer is 48 bytes long. Actual (mine): 32 bytes. Structures identical, no special shader compilation flags provided.

This documentations is in category "Shader Model 4", so I also tried "ps_4_0" profile, but nothing has changed.

I generally understand, how packing for HLSL shaders works. I'm trying to write app which uses shader reflection to generate structures of buffers for C++. HLSL's actual packing is ok, but documentation makes me upset, like I'm doing something wrong.

Please, help me to determine where is the mistake.

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,440 questions
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,554 questions
{count} votes