Skip to content

VideoCommon: Fix padding in shader UIDs - #14795

Open
TellowKrinkle wants to merge 1 commit into
dolphin-emu:masterfrom
TellowKrinkle:UIDPadding
Open

VideoCommon: Fix padding in shader UIDs#14795
TellowKrinkle wants to merge 1 commit into
dolphin-emu:masterfrom
TellowKrinkle:UIDPadding

Conversation

@TellowKrinkle

Copy link
Copy Markdown
Contributor

Looks like over time, shader UIDs' padding bits have gotten completely desynced from where padding bits actually exist / are needed.

This redoes all the padding to match reality, rearranges a few fields to reduce padding where possible, and adds some static_asserts reminding people to look back at the padding if they add things.

BTW, at least according to compiler explorer (and to be verified by CI as it runs), only GCC/Clang let you use #pragma pack(1) to make structs smaller than their contained types (e.g. struct { u32 blah : 8 } being 1 byte instead of 4), so currently, VS UIDs are smaller on unix than Windows. Do we want to do anything about this? I changed postMtxInfo to use u8s to avoid this, but texMtxInfo contains enums that are defined as : u32.

@phire

phire commented Aug 7, 2026

Copy link
Copy Markdown
Member

Conflicts with #14789 and #14791 (and #14792), sorry I should have tagged you in those.

BTW, at least according to compiler explorer (and to be verified by CI as it runs), only GCC/Clang let you use #pragma pack(1)

Yeah, I encountered that in both my PRs too, I actually made it worse before noticing by using even more enums.

Do we want to do anything about this? I changed postMtxInfo to use u8s to avoid this, but texMtxInfo contains enums that are defined as : u32.

We absolutely want to do something.

After thinking about this for several days (and several attempted fixes) I think the best solution is drop the relevant enums down to u8/u16.

t's not part of the documented API, but I'm pretty sure we can just pass u32 as a fourth parameter to BitField and it will work (it compiles, I'm just not 100% sure about correctness yet)

@phire

phire commented Aug 7, 2026

Copy link
Copy Markdown
Member

t's not part of the documented API, but I'm pretty sure we can just pass u32 as a fourth parameter to BitField and it will work (it compiles, I'm just not 100% sure about correctness yet)

It's not part of the documented API, but searching for BitField<.*,.*,.*,.*> reveals we already use it in 130 places.

@TellowKrinkle

Copy link
Copy Markdown
Contributor Author

It's not part of the documented API, but I'm pretty sure we can just pass u32 as a fourth parameter to BitField and it will work (it compiles, I'm just not 100% sure about correctness yet)

I tried, and there's currently a static_assert that complains. We could delete it though.

@phire

phire commented Aug 7, 2026

Copy link
Copy Markdown
Member

No, you have to do it the other way around. See my PRs

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants