-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[BREAKING] Implementation of BlendState #5083
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kungfooman
reviewed
Feb 21, 2023
mvaligursky
changed the title
[Breaking] Implementation of BlendState
[BREAKING] Implementation of BlendState
Feb 21, 2023
slimbuck
reviewed
Feb 22, 2023
Co-authored-by: Donovan Hutchence <slimbuck7@gmail.com>
GSterbrant
reviewed
Feb 22, 2023
GSterbrant
approved these changes
Feb 23, 2023
slimbuck
approved these changes
Feb 23, 2023
willeastcott
approved these changes
Feb 23, 2023
Open
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related to #2254
Overview
A new BlendState class is implemented, which encapsulates a blending state of rendering pipeline. It handles alpha blending and enabling of per-channel writes. Internally, a bit packing is used to store blend state in a single number (per render target, to allow multiple render targets in the future). This makes blend state setup more costly, but per frame rendering is faster as just a single number needs to be compared to see if blend state needs to be changed. Additionally, it makes it fast to generate a key which is used for render pipeline look up on WebGPU.
Breaking changes
although all public functionality has been deprecated and preserved, if some private blending related functionality has been used, it's possible the code needs to be updated to use public functionality.
To align WebGL and WebGPU:
is now
New public API (still breaking change, as old APIs are deprecated)
BlendState.constructor(blend = false, colorOp = BLENDEQUATION_ADD, colorSrcFactor = BLENDMODE_ONE, colorDstFactor = BLENDMODE_ZERO,
alphaOp, alphaSrcFactor, alphaDstFactor,
redWrite = true, greenWrite = true, blueWrite = true, alphaWrite = true)
BlendState.blend - toggle blending
BlendState.equals - compares two blend states
BlendState.DEFAULT - a static access to a blend state with no blending and writing to all channels
GraphicsDevice.setBlendState(blendState)
this replaces these properties:
this replaces these properties:
Other changes
Testing
JSDocs for the new class