8000 Fix `ColorWriteMask` property type of `BlendState` in ShaderLab by Sway007 · Pull Request #2651 · galacean/engine · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix ColorWriteMask property type of BlendState in ShaderLab #2651

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Sway007
Copy link
Member
@Sway007 Sway007 commented May 7, 2025

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

Fix the doc error and runtime implementation of ColorWriteMask.

BlendState state {
  Enabled: bool;
  ColorBlendOperation: BlendOperation.XXX;
  AlphaBlendOperation: BlendOperation.XXX;
  SourceColorBlendFactor: BlendFactor.XXX;
  SourceAlphaBlendFactor: BlendFactor.XXX;
  DestinationColorBlendFactor: BlendFactor.XXX;
  DestinationAlphaBlendFactor: BlendFactor.XXX;
  // should be ColorWriteMask.XXX;
  ColorWriteMask: float;
  BlendColor: vec4;
  AlphaToCoverage: bool;
}

TODO

  • support bitwise opeators
...
ColorWriteMask: ColorWriteMask.Red | ColorWriteMask.Green | ColorWriteMask.Blue
...

@Sway007 Sway007 requested review from GuoLei1990 and zhuxudong May 7, 2025 09:45
@Sway007 Sway007 self-assigned this May 7, 2025
@Sway007 Sway007 added bug Something isn't working shader Shader related functions high priority High priority issue labels May 7, 2025
Copy link
coderabbitai bot commented May 7, 2025

Walkthrough

The changes introduce the ColorWriteMask enum into the shader lab codebase, updating documentation, parser internals, and tests to use this strongly typed enum instead of numeric literals or generic types. The enum is also added to relevant keyword mappings and parser type references for improved clarity and consistency.

Changes

Files/Groups Change Summary
docs/zh/graphics/material/shaderLab/global.mdx Updated BlendState.ColorWriteMask type annotation from float to ColorWriteMask.XXX in documentation.
packages/shader-lab/src/common/Keywords.ts Added GS_ColorWriteMask to the EKeyword enum.
packages/shader-lab/src/contentParser/KeywordMap.ts Mapped "ColorWriteMask" string to EKeyword.GS_ColorWriteMask in KeywordMap.
packages/shader-lab/src/contentParser/ShaderContentParser.ts Added ColorWriteMask to the static _engineType object in ShaderContentParser.
tests/src/shader-lab/ShaderLab.test.ts Replaced a numeric literal with ColorWriteMask.None in a render state test case.

Sequence Diagram(s)

sequenceDiagram
    participant Test as Test Case
    participant Parser as ShaderContentParser
    participant Engine as Engine Types

    Test->>Parser: Provide shader content with ColorWriteMask
    Parser->>Engine: Resolve ColorWriteMask from _engineType
    Engine-->>Parser: Return ColorWriteMask enum
    Parser-->>Test: Use ColorWriteMask enum in parsed data
Loading

Suggested labels

documentation

Poem

In fields of color, masks align,
No more numbers, enums shine!
The parser learns a brand new trick,
With ColorWriteMask, choices click.
Tests and docs all join the fun—
Type-safe shaders for everyone!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the documentation Improvements or additions to documentation label May 7, 2025
Copy link
@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
docs/zh/graphics/material/shaderLab/global.mdx (1)

35-35: Update BlendState documentation to use ColorWriteMask enum
Changing the type annotation from float to ColorWriteMask.XXX aligns the docs with the runtime API.

Consider adding an API link (e.g., [ColorWriteMask](/apis/galacean/#ColorWriteMask)) for consistency with other enum references.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5c73208 and ccfcff5.

⛔ Files ignored due to path filters (1)
  • tests/src/shader-lab/shaders/demo.shader is excluded by !**/*.shader
📒 Files selected for processing (5)
  • docs/zh/graphics/material/shaderLab/global.mdx (1 hunks)
  • packages/shader-lab/src/common/Keywords.ts (1 hunks)
  • packages/shader-lab/src/contentParser/KeywordMap.ts (1 hunks)
  • packages/shader-lab/src/contentParser/ShaderContentParser.ts (2 hunks)
  • tests/src/shader-lab/ShaderLab.test.ts (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: e2e (22.x)
  • GitHub Check: codecov
  • GitHub Check: build (22.x, windows-latest)
🔇 Additional comments (6)
packages/shader-lab/src/contentParser/KeywordMap.ts (1)

27-27: Add mapping for ColorWriteMask keyword
Mapping "ColorWriteMask" to EKeyword.GS_ColorWriteMask accurately introduces the new enum to the parser's keyword map.

packages/shader-lab/src/common/Keywords.ts (1)

100-100: Introduce GS_ColorWriteMask enum member
Adding GS_ColorWriteMask in the EKeyword enum enables recognition of the ColorWriteMask keyword in parser and keyword mapping. Ensure its position aligns with the existing ordering of galacean-internal keywords.

packages/shader-lab/src/contentParser/ShaderContentParser.ts (2)

17-17: Import ColorWriteMask from engine package
Including ColorWriteMask in the import is necessary for the parser to reference the enum values at runtime.


63-63: Include ColorWriteMask in _engineType mapping
Adding ColorWriteMask to the static _engineType ensures ShaderContentParser can resolve ColorWriteMask.XXX references correctly.

tests/src/shader-lab/ShaderLab.test.ts (2)

3-3: Import ColorWriteMask into test suite
Bringing in ColorWriteMask from @galacean/engine-core is required to reference the enum in assertions.


191-191: Assert ColorWriteMask.None instead of numeric literal
Using the enum value improves readability and ensures test resilience against changes in underlying numeric values.

Copy link
codecov bot commented May 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 68.90%. Comparing base (5c73208) to head (ccfcff5).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2651      +/-   ##
==========================================
- Coverage   68.90%   68.90%   -0.01%     
==========================================
  Files         961      961              
  Lines      100604   100615      +11     
  Branches     8715     8714       -1     
==========================================
+ Hits        69322    69328       +6     
- Misses      31022    31027       +5     
  Partials      260      260              
Flag Coverage Δ
unittests 68.90% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Sway007 Sway007 marked this pull request as draft May 15, 2025 02:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation high priority High priority issue shader Shader related functions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0