-
Notifications
You must be signed in to change notification settings - Fork 55
Add "texture-component-swizzle" feature
#560
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
Conversation
kainino0x
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM but let's wait for any bikeshedding to happen in the WG first.
|
I believe we're good now. |
|
Thanks. I guess we should still talk about what we want the C API for this to look like since it's not a direct mapping from JS. I'd really like it to be more ergonomic; I'm not sure if there's a good string-based solution but I still don't like the soup of channel identifiers. (I so wish that C 4-character literals like Or we could just not worry about the ergonomics and leave it as is. Actually, there could be a macro based helper if we wanted to keep this structure and also make it ergonomic. But kinda unnecessary. typedef enum CS { CS_R, CS_G, CS_B, CS_A, CS_0, CS_1 } CS;
typedef struct TCS { CS r, g, b, a; } TCS;
typedef struct TCSD { TCS swizzle; } TCSD;
#define MAKE_TCS(cr, cg, cb, ca) (TCS){ \
.r = CS_##cr, .g = CS_##cg, .b = CS_##cb, .a = CS_##ca }
int main() {
TCSD desc = { .swizzle = MAKE_TCS(B, 0, 1, R) };
} |
|
@cwfitzgerald do you have opinions about this? |
|
Not any particular strong feelings, the macro would work for me. We also need docs |
|
I would not worry about the ergonomics. The following code looks good to me. wgpu::TextureViewDescriptor viewDesc{};
wgpu::TextureComponentSwizzleDescriptor swizzleDesc{};
swizzleDesc.swizzle.r = wgpu::ComponentSwizzle::R;
swizzleDesc.swizzle.g = wgpu::ComponentSwizzle::Zero;
swizzleDesc.swizzle.b = wgpu::ComponentSwizzle::Zero;
swizzleDesc.swizzle.a = wgpu::ComponentSwizzle::One;
viewDesc.nextInChain = &swizzleDesc; |
|
I agree with @beaufortfrancois , it's fine and too niche to need a fancy ergonomic version. If people want they can make their own macro to do |
|
SGTM let's keep as is then. For docs IMO we just need a very brief explanation of how this maps with the JS API since there's a non-trivial mapping. For the rest people can refer to JS. |
94c9364 to
175ea31
Compare
|
I've added some doc |
175ea31 to
0b434aa
Compare
|
Gentle ping
…On Wed, Oct 15, 2025, 21:58 Kai Ninomiya ***@***.***> wrote:
*kainino0x* left a comment (webgpu-native/webgpu-headers#560)
<#560 (comment)>
SGTM let's keep as is then.
For docs IMO we just need a very brief explanation of how this maps with
the JS API since there's a non-trivial mapping. For the rest people can
refer to JS.
—
Reply to this email directly, view it on GitHub
<#560 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAE243UXAQZVRMV6QD6HOQ33X2YRHAVCNFSM6AAAAACIXQH4M2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTIMBYGI2TINBYGE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
kainino0x
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I completely missed your revision somehow!
I do want to avoid duplicating docs into this header but this is fine for now, we can resolve that at a later point when we figure out how to link the docs better.
This PR adds the
"texture-component-swizzle feature"in parallel of gpuweb/gpuweb#5361