Skip to content

Document constant buffers in the language spec #357

@hekota

Description

@hekota

We need to add constant buffers to the HLSL language spec.
That includes documenting the different ways to declare a constant buffer (cbuffer vs. ConstantBuffer), cbuffer and packoffset grammar, and rules on what exactly is allowed inside a cbuffer declaration.

DXC currently supports quite a few more or less unusual constructs such as:

  • nested cbuffer declarations
  • multiple cbuffer declarations with the same name
  • constants defined outside of cbuffer context (to be placed in $Globals constant buffer and bound to first register b0)
  • namespace declarations inside cbuffer context
  • function definitions inside cbuffer context

The spec should clarify which of these are we going to support in Clang.

@tex3d put together an example that these various interesting cases here:
https://godbolt.org/z/E4cdx7xj8

Same shader with FXC:
https://shader-playground.timjones.io/39c0683735c0cd79b5970b5116765940

One difference between FXC and DXC in the nested cbuffer case. FXC binds outer cbuffer declaration before the nested one while DXC binds it after.

Related issues:

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions