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

Reduced struct sizes using align for x64 platforms, fields carefully moved #19047

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

Conversation

GermanAizek
Copy link
Contributor

@GermanAizek GermanAizek commented Apr 12, 2024

Tested only on Debug

Before RAM util (master):

image

After RAM util (align-struct-64):

image

Copy link
Owner

@hrydgard hrydgard left a comment

Choose a reason for hiding this comment

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

These are good for things like the Vulkan/OpenGL structs.

However, when structs are used to define arrays like SamplerDef which are not accessed very often, I think clarity matters more than saving a few bytes.

So, I have marked a couple that I would like to be reverted.

Comment on lines +105 to +107
const char* name;
SamplerFlags flags;
int binding; // Might only be used by some backends.
Copy link
Owner

Choose a reason for hiding this comment

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

This particular one won't matter for performance, here I prefer the original order, looks better in the table using the struct later.

// branches
u32 branchTarget;
int branchRegisterNum;
Copy link
Owner

Choose a reason for hiding this comment

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

move this one int down again, I liked having it next to isBranchToRegister. It's aligned with no waste anyway since it's after exactly four bools.

int* columnOrder;
int columnCount;
Copy link
Owner

Choose a reason for hiding this comment

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

This is another one I'd prefer to revert because it makes the tables that use the struct look less nice.

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.

None yet

2 participants