-
Notifications
You must be signed in to change notification settings - Fork 35
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
Add proposal for scalar layout for constant buffers #317
base: main
Are you sure you want to change the base?
Conversation
@microsoft-github-policy-service agree company="AMD" |
A few thoughts/questions, mostly around some extra details that would be useful. UsageI think you're suggesting we add a source-level attribute something like:
Is that correct? Should we also have a command line argument to change the default value? Expected AlignmentsCan you expand a bit on the expected alignments for different types? Most C & C++ compilers do support vector types with 16-byte alignment, so they wouldn't necessarily be aligned to their element component. How would the new packing rules apply for something like: struct MyConstants {
int X;
int64_t Y[2];
int16_t Z[3];
float __attribute__((vector_size(4))) V; // equivalent to float4
}; |
Yes that's what I'm thinking yep, and I agree a compiler flag to switch the default would be useful.
In the Vulkan version of this feature against SPIR-V, vector size doesn't change the alignment requirements; we basically treat them the same as arrays of floats. So the alignment required is that of a float - 4 bytes. I would expect the same here for float4 in HLSL. Granted this is not the same as C/C++ language extensions, but vectors aren't really treated the same way on modern GPUs as they are in CPU ISAs, which is why it works this way in Vulkan (and every supporting vendor's hardware). I could see an argument for matching C/C++ vector extensions, but it's going to depend on what developers want to see here. We could add in a way to switch between these two packing modes if we think it's helpful though. |
This proposal adds an attribute to specify that the layout of constant buffers uses C-style packing rules, according to the size of the scalar components of matrices and vectors, rather than the packing rules currently used for constant buffers when they are involved.