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

Change BitfieldExtract to use a pointer to the bitfield member #9633

Merged

Conversation

Pokechu22
Copy link
Contributor

@Pokechu22 Pokechu22 commented Apr 11, 2021

This PR changes BitfieldExtract to use a pointer to a member to deduce information about the BitField instead of creating a temporary variable and passing its bitfield instance. The pointer-to-member is also a template argument instead of a regular argument. For example, BitfieldExtract("colorreg", LitChannel().matsource) is now BitfieldExtract<&LitChannel::matsource>("colorreg"), and BitfieldExtract("ss.cc", TevStageCombiner().colorC.bias) is now BitfieldExtract<&TevStageCombiner::ColorCombiner::bias>("ss.cc").

As an additional change to make this work, I made BitField::StartBit and BitField::NumBits static. The other code that already used StartBit is not affected by this change (for instance int(TwoTevStageOrders().enable1.StartBit() - TwoTevStageOrders().enable0.StartBit())).

Note that this does not make any difference with performance (compiler explorer); the only change is the syntax.

This didn't take too long to do, and it's subjective whether or not this is really an improvement. If people don't like it, then I'm fine with it not being merged.

@Pokechu22 Pokechu22 force-pushed the BitfieldExtract-pointer-to-member branch from 69eddfe to fe51f44 Compare April 11, 2021 02:50
@Pokechu22 Pokechu22 force-pushed the BitfieldExtract-pointer-to-member branch 2 times, most recently from 29e14fc to 937ff0a Compare May 7, 2021 20:53
Source/Core/Common/TypeUtils.h Outdated Show resolved Hide resolved
Source/Core/VideoCommon/UberShaderCommon.h Outdated Show resolved Hide resolved
@Pokechu22 Pokechu22 force-pushed the BitfieldExtract-pointer-to-member branch from 937ff0a to df805a0 Compare May 7, 2021 22:08
@Pokechu22 Pokechu22 force-pushed the BitfieldExtract-pointer-to-member branch from df805a0 to 0f7c9ef Compare May 7, 2021 22:11
@leoetlino leoetlino merged commit a6f6211 into dolphin-emu:master May 7, 2021
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants