Documentation for "Packing Rules for Constant Variables" is wrong

Vadim Chuprakov 1 Reputation point
2022-10-12T16:10:03.887+00:00

Documentation for Packing Rules for Constant Variables (https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-packing-rules or https://github.com/MicrosoftDocs/win32/blob/da3bae6a0e8408f155ae39f99105e317f9e8f082/desktop-src/direct3dhlsl/dx-graphics-hlsl-packing-rules.md?plain=1#L115) is wrong.

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

Shader code looks like this:
249823-reflect-shader-hlsl-code.png

And my program output:
249814-reflect-shader-out.png

So, size of constant buffer is 32 bytes. I assume, it is packed like this:
249728-reflect-shader-hlsl-structure.png

Documentation stands, that:
249758-reflect-shader-hlsl-structure-doc.png

I assume, it is packed like this:
249797-reflect-shader-hlsl-structure-docs.png

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,523 questions
C++
C++
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,636 questions
{count} votes