Conversation
kainino0x
requested changes
Sep 16, 2026
Collaborator
There was a problem hiding this comment.
this code should not be so complicated that it needs tests
Comment on lines
+46
to
+66
| export function selectRoute( | ||
| requestedRoute: RequestedRoute, | ||
| languageFeatures: ReadonlySet<string> | ||
| ): RouteSelection { | ||
| const packedLanguageFeatureSupported = languageFeatures.has( | ||
| packedDotLanguageFeature | ||
| ); | ||
| const wantsPacked = requestedRoute !== 'scalar'; | ||
| const effectiveRoute = | ||
| wantsPacked && packedLanguageFeatureSupported ? 'packed' : 'scalar'; | ||
|
|
||
| return { | ||
| requestedRoute, | ||
| effectiveRoute, | ||
| packedLanguageFeatureSupported, | ||
| fallbackReason: | ||
| requestedRoute === 'packed' && !packedLanguageFeatureSupported | ||
| ? `WGSL language feature '${packedDotLanguageFeature}' is unavailable` | ||
| : null, | ||
| }; | ||
| } |
Collaborator
There was a problem hiding this comment.
this seems excessively complicated, also I don't think we should have fallback in a sample, that makes it confusing about what implementation you're looking at
Comment on lines
+83
to
+94
| if (actual.length !== expected.length) { | ||
| throw new Error( | ||
| `partial output: expected ${expected.length} results, received ${actual.length}` | ||
| ); | ||
| } | ||
| for (let index = 0; index < expected.length; ++index) { | ||
| if (actual[index] !== expected[index]) { | ||
| throw new Error( | ||
| `result ${index} mismatch: expected ${expected[index]}, received ${actual[index]}` | ||
| ); | ||
| } | ||
| } |
Collaborator
There was a problem hiding this comment.
this is a sample not a test, don't check results as it makes the total amount of code too much for the sample to be easily readable by a learner
Collaborator
There was a problem hiding this comment.
please use dat.gui like other samples instead of implementing custom UI
This file contains hidden or 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
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.
Adds a small
dot4I8Packedcompute example toward #350.The sample packs four signed 8-bit components into each
u32, computes four example dot products, and reads the results back from the GPU. A dat.gui selector displays the input vectors and result for each example.It requires
packed_4x8_integer_dot_productand displays a requirement message when that WGSL language feature is unavailable. There is one packed compute pipeline, with no scalar fallback or in-sample result validation.Testing
--enable-unsafe-webgpu, on an Apple Metal adapter: all four examples returned the expected results, and the dat.gui selector was exercised.No new dependencies or external assets.