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

WebGPU ShaderStage missing Flags attribute #2238

Closed
joskuijpers opened this issue Jul 1, 2024 · 3 comments
Closed

WebGPU ShaderStage missing Flags attribute #2238

joskuijpers opened this issue Jul 1, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@joskuijpers
Copy link
Contributor

Summary

ShaderStage is used to indicate visibility of bind groups. It is allowed to have more than 1 of these items, and their values are 2^n.

Steps to reproduce

Write:

ShaderStage.Vertex | ShaderStage.Fragment

gives warning:

Bitwise operation on enum is not marked by [Flags] attribute

Comments

I know [Flags] needs to be added, I just do not know how in the process to automate that.

@Perksey
Copy link
Member

Perksey commented Jul 1, 2024

Hmmm. Looking at that enum it won't be automatically marked because of Force32, so I guess in automating this we'd have to add recognition for such patterns.

Maybe:

  1. Do the current checks.
  2. If unsuccessful, remove MaxValue values from the list of enums to check.
  3. If still unsuccessful, check whether:
    • each enum has only one bit set, or
    • each enum only has bits set that were declared before it when ordered, as long as
    • the enum is not sequential (a false positive check for the previous check)

Or alternatively mark everything as Flags, but that seems like a bad idea.

@Perksey
Copy link
Member

Perksey commented Jul 1, 2024

cc @tannergooding do you have opinions on marking things with Flags?

@joskuijpers
Copy link
Contributor Author

The problem is IsSequential returning true for the [0,1,2,4,int.MaxValue] set.
So keeping an IsSequential check won't work.

Idea:

  • Current algorithm succeeds,
  • or:
    • All items that are not int.MaxValue have PopCount==1
    • There are more than 2 items that have value > 0 (to prevent [1,2] [0,1], [0,1,2] from becoming flags)

Perksey added a commit that referenced this issue Oct 31, 2024
@Perksey Perksey closed this as completed in f9535d2 Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

No branches or pull requests

2 participants