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

Add component count data to TextureFormat::describe #2020

Merged
merged 1 commit into from
Oct 5, 2021

Conversation

cwfitzgerald
Copy link
Member

Connections

None

Description

This is a useful bit of information to know about a texture format. In order to make decisions about what channels are valid, we need to know the component count, but we don't actually care about the format.

Testing

👀

@cwfitzgerald cwfitzgerald requested a review from kvark October 5, 2021 04:35
@kvark
Copy link
Member

kvark commented Oct 5, 2021

Can you tell more? What part of userspace actually need to know which channels are valid?
The shader can sampler or load any channels, regardless of the format.

@cwfitzgerald
Copy link
Member Author

cwfitzgerald commented Oct 5, 2021

"Valid" was a bad choice of words on my end. More "contains useful data".

The use case that spawned this PR was the following two situations:

  • When loading a ktx2 normal map, I get the format, then need to decide if to treat it as a bicomponent (r + g with derived b), or tricomponent (r + g + b). This comes from the amount of components inside the format.
  • When loading a ktx2 metallic roughness map in the context of gtlf, I get the format, then need to decide if treat it as (metallic in g, roughness in b) or as (metallic in r, roughness in g). This also comes from the component count.

These are some very specific situations, but component count is a useful cross-format property to know. I could build this up myself, but this is low cost to implement inside wgpu, and gives out this information if other people need it.

Copy link
Member

@kvark kvark left a comment

Choose a reason for hiding this comment

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

Makes sense!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants