Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constant buffers language spec - initial draft #419

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

hekota
Copy link
Member

@hekota hekota commented Mar 4, 2025

Adds constant buffers to the language spec.

image
image
image
image

@github-actions github-actions bot added the language-spec Issue with completed spec label Mar 4, 2025
@hekota hekota marked this pull request as ready for review March 4, 2025 22:22
@V-FEXrt V-FEXrt self-assigned this Mar 18, 2025
@V-FEXrt V-FEXrt self-requested a review March 18, 2025 16:12
@V-FEXrt V-FEXrt removed their assignment Mar 18, 2025
third one and \texttt{w} or \texttt{a} is the fourth, and last element of the
vector.

\p Shader constant that has a structure, array or matrix type must always be
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing the answer is "backwards compatibility" but is there a strong argument against something like

Shader constant that has a structure, array or matrix type must always be
16-byte row-aligned. Therefore it may not specify a packoffset-element

My first thought on why not is that it could create "unbalanced" code like

  cbuffer MyConstants {
    MyStruct Foo : packoffset(c0);
    float Foo : packoffset(c1.x);
  };

but beyond that I'm not sure. Since its necessary to check x/y/z anyways it seems like the change would complicate implementations

In the end, I guess I'd just like to hear your thoughts on why it was picked to be this. Personally I'm torn because I prefer the language consistency of keeping it but also dislike the idea of language feature that does "nothing"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea why it was done like that. Maybe @tex3d would know?


\p For example
\begin{HLSL}
float4 CameraPos : register(c2);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly asking for historical context. Why is it called a register in $Globasl but packoffset for the rest?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My guess is there was just a single constant buffer $Globals before cbuffer blocks and packoffset were added, and register was an established annotation at that time. So it just got extended with a 'c' value and new meaning.
@tex3d - please correct me if I am wrong! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
language-spec Issue with completed spec
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants