[clang] [HLSL][NFC] Move packoffset validation to separate function and calculate offsets in bytes (PR #121989)

Helena Kotas via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 7 16:03:36 PST 2025


================
@@ -4721,9 +4721,9 @@ def HLSLPackOffset: HLSLAnnotationAttr {
   let Args = [IntArgument<"Subcomponent">, IntArgument<"Component">];
   let Documentation = [HLSLPackOffsetDocs];
   let AdditionalMembers = [{
-      unsigned getOffset() {
-        return subcomponent * 4 + component;
-      }
+  unsigned getOffsetInBytes() {
----------------
hekota wrote:

The `subcomponent` number is a row index and each row is 16 bytes long. The `component` number is 0-3 and it is an index of one of the 4 elements on the row (`xyzw`). So if you have `packoffset(c2.y)`, the subcomponent is 2, component is 1, and the byte offset is 2*16 + 4.

Previously this was returning the offset as a number of 4-byte elements from the start of the buffer and the packoffset validation was converting it to bits by multiplying it by 32. I am changing all of these to use bytes.

https://github.com/llvm/llvm-project/pull/121989


More information about the cfe-commits mailing list