fix(typegpu): flat interpolate integer varyings#2566
Open
Will-thom wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR updates TypeGPU’s WGSL IO schema generation so integer varyings are automatically decorated with @interpolate(flat), and updates/adds tests to validate the new output.
Changes:
- Add
IoSchemaOptionsplumbing throughcreateIoSchema,withLocations,separateBuiltins, andAutoStructto control IO schema generation behavior. - Automatically apply
@interpolate(flat)to integer varyings when generating vertex outputs and fragment inputs. - Update snapshots and add a dedicated test covering integer varying interpolation.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/typegpu/tests/renderPipeline.test.ts | Updates snapshots to expect @interpolate(flat) on integer varyings. |
| packages/typegpu/tests/entryFnHeaderGen.test.ts | Adds a test asserting integer varyings are emitted with flat interpolation. |
| packages/typegpu/src/data/autoStruct.ts | Passes new IO schema options through AutoStruct to schema creation. |
| packages/typegpu/src/core/function/tgpuVertexFn.ts | Enables auto-flat interpolation for integer vertex outputs via io schema options. |
| packages/typegpu/src/core/function/tgpuFragmentFn.ts | Enables auto-flat interpolation for integer fragment inputs via io schema options. |
| packages/typegpu/src/core/function/ioSchema.ts | Implements autoInterpolateIntegerVaryings and threads options through schema generation. |
| packages/typegpu/src/core/function/autoIO.ts | Enables auto-flat interpolation for generated vertex/fragment IO structs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return [key, memberWithInterpolation]; | ||
| } | ||
|
|
||
| if (locations[key]) { |
| const dataSchema = | ||
| Object.keys(dataFields).length > 0 | ||
| ? INTERNAL_createStruct(withLocations(dataFields, locations), /* isAbstruct */ false) | ||
| ? INTERNAL_createStruct(withLocations(dataFields, locations, options), /* isAbstruct */ false) |
Comment on lines
+160
to
161
| withLocations(layout as Record<string, BaseData>, locations, options), | ||
| /* isAbstruct */ false, |
| @location(0) @interpolate(flat) flag: u32, | ||
| } | ||
|
|
||
| @fragment fn fragment(in: fragment_Input) -> @location(0) vec4f { return vec4f(f32(in.flag)); }" |
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.
Fixes #2147.\n\nAutomatically applies @interpolate(flat) to integer varyings generated for vertex outputs and fragment inputs, while keeping vertex inputs and fragment outputs unchanged. Existing explicit interpolation attributes are preserved.\n\nValidation:\n- corepack pnpm vitest run --project=!browser packages/typegpu/tests/entryFnHeaderGen.test.ts packages/typegpu/tests/renderPipeline.test.ts\n- corepack pnpm --dir packages/typegpu exec tsc --p ./tsconfig.test.json --noEmit\n- corepack pnpm oxlint -c oxlint.config.ts packages/typegpu/src/core/function/ioSchema.ts packages/typegpu/src/core/function/autoIO.ts packages/typegpu/src/core/function/tgpuVertexFn.ts packages/typegpu/src/core/function/tgpuFragmentFn.ts packages/typegpu/src/data/autoStruct.ts packages/typegpu/tests/entryFnHeaderGen.test.ts packages/typegpu/tests/renderPipeline.test.ts\n- corepack pnpm oxfmt --check packages/typegpu/src/core/function/ioSchema.ts packages/typegpu/src/core/function/autoIO.ts packages/typegpu/src/core/function/tgpuVertexFn.ts packages/typegpu/src/core/function/tgpuFragmentFn.ts packages/typegpu/src/data/autoStruct.ts packages/typegpu/tests/entryFnHeaderGen.test.ts packages/typegpu/tests/renderPipeline.test.ts\n\nNote: local validation was run with Node v22.21.1, which prints the project engine warning for Node >=24.0.0, but the focused tests and typecheck passed.