Skip to content

fix(typegpu): flat interpolate integer varyings#2566

Open
Will-thom wants to merge 1 commit into
software-mansion:mainfrom
Will-thom:will/typegpu-2147-flat-integer-varyings
Open

fix(typegpu): flat interpolate integer varyings#2566
Will-thom wants to merge 1 commit into
software-mansion:mainfrom
Will-thom:will/typegpu-2147-flat-integer-varyings

Conversation

@Will-thom
Copy link
Copy Markdown
Contributor

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.

Copilot AI review requested due to automatic review settings May 26, 2026 19:18
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 IoSchemaOptions plumbing through createIoSchema, withLocations, separateBuiltins, and AutoStruct to 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)); }"
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.

impr: Auto @interpolate(flat) when integer field encountered in varyings struct

2 participants