Skip to content

Multi-dimensional array support in safe struct generator - #415

Merged
spencer-lunarg merged 1 commit into
KhronosGroup:mainfrom
nima-davari-huawei:multidimensional-arrays-in-safe-structs
Sep 29, 2026
Merged

spencer-lunarg merged 1 commit into
KhronosGroup:mainfrom
nima-davari-huawei:multidimensional-arrays-in-safe-structs

Conversation

@nima-davari-huawei

Copy link
Copy Markdown
Contributor

The safe struct generator assumes len(member.fixedSizeArray) is always 1, and it does not handle multi-dimensional arrays properly. Here is an example:

  • float matrix[4][4];

This MR adds a new code branch to handle such cases. Here is an example of what the new code would generate for the above example.

Before MR:

for (uint32_t i = 0; i < 4; ++i) {
    matrix[i] = in_struct->matrix[i]; // Does not compile
}

After MR:

for (uint32_t i0 = 0; i0 < 4; ++i0) {
    for (uint32_t i1 = 0; i1 < 4; ++i1) {
        matrix[i0][i1] = in_struct->matrix[i0][i1];
    }
}

Note that no auto-generated code needs to be checked in with the MR as it does not affect any existing structs.

@CLAassistant

CLAassistant commented Sep 29, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@spencer-lunarg
spencer-lunarg merged commit ad949c9 into KhronosGroup:main Sep 29, 2026
16 checks passed
@spencer-lunarg

Copy link
Copy Markdown
Contributor

@nima-davari-huawei thanks, now it will be simpler when you need this for future extensions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants