Skip to content

Conversation

@s-perron
Copy link
Collaborator

Adds a new test case to verify that the OpAccessChain is generated correctly for inherited members of a struct.

This fixes an issue where the indices for a base class were being prepended to the indices of the derived class, resulting in an incorrect access chain.

Fixes #7968

Adds a new test case to verify that the OpAccessChain is generated correctly for inherited members of a struct.

This fixes an issue where the indices for a base class were being prepended to the indices of the derived class, resulting in an incorrect access chain.

Fixes microsoft#7968
@github-actions
Copy link
Contributor

github-actions bot commented Dec 12, 2025

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff 948629ac48fb6fb8261d1c2dfc443e297841ade1 52cf8afad277bebd25ef9780a54c1688d1ea2ef7 -- tools/clang/lib/SPIRV/SpirvEmitter.cpp
View the diff from clang-format here.
diff --git a/tools/clang/lib/SPIRV/SpirvEmitter.cpp b/tools/clang/lib/SPIRV/SpirvEmitter.cpp
index e47d37e8..c14dc1e6 100644
--- a/tools/clang/lib/SPIRV/SpirvEmitter.cpp
+++ b/tools/clang/lib/SPIRV/SpirvEmitter.cpp
@@ -8862,8 +8862,9 @@ const Expr *SpirvEmitter::collectArrayStructIndices(
       } else if (castExpr->getCastKind() == CK_UncheckedDerivedToBase ||
                  castExpr->getCastKind() == CK_HLSLDerivedToBase) {
         // First the indices for the sub expression.
-        const Expr * base = collectArrayStructIndices(castExpr->getSubExpr(), rawIndex,
-                                         rawIndices, indices, isMSOutAttribute);
+        const Expr *base =
+            collectArrayStructIndices(castExpr->getSubExpr(), rawIndex,
+                                      rawIndices, indices, isMSOutAttribute);
 
         llvm::SmallVector<uint32_t, 4> BaseIdx;
         getBaseClassIndices(castExpr, &BaseIdx);
  • Check this box to apply formatting changes to this branch.

Copy link
Collaborator

@Keenuts Keenuts left a comment

Choose a reason for hiding this comment

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

LGTM!

@Keenuts Keenuts merged commit 4c613aa into microsoft:main Dec 15, 2025
10 checks passed
@github-project-automation github-project-automation bot moved this from New to Done in HLSL Roadmap Dec 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[SPIR-V] Incorrect indexing into cbuffer involving base classes

3 participants