Skip to content

feat: Introduce Index buffers and improve buffer UX #1340

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

Open
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

reczkok
Copy link
Contributor

@reczkok reczkok commented Jun 5, 2025

Also adds a very simple square example that uses the experimental APIs and demonstrates the index buffer :)
image

  • unit tests
  • include decorated types in the recursive HasNestedType check

closes #863

Copy link

github-actions bot commented Jun 5, 2025

pkg.pr.new

packages

pnpm i https://pkg.pr.new/software-mansion/TypeGPU/typegpu@1340
pnpm i https://pkg.pr.new/software-mansion/TypeGPU/typegpu@bb018782a4feb498bbceb2163902792c16a41850

benchmark
view benchmark

commit
view commit

@reczkok reczkok force-pushed the feat/index-buffers branch from c9c3e0a to ce93b12 Compare June 5, 2025 16:26
reczkok added 5 commits June 12, 2025 12:04
Also update resolveData to throw for u16 type in WGSL. Remove unused test buffer in cubemap-reflection example.
- Add a simple square example with color controls
- Implement .withIndexBuffer and .drawIndexed for render pipelines
- Allow u16 arrays as index buffers; improve type safety for buffer schemas
- Update alignment and size maps to include u16
- Refactor HasNestedType utility and enforce buffer schema constraints
@reczkok reczkok force-pushed the feat/index-buffers branch from ce93b12 to 741e69d Compare June 12, 2025 10:11
@reczkok reczkok requested a review from Copilot June 12, 2025 10:56
Copilot

This comment was marked as resolved.

@reczkok reczkok marked this pull request as ready for review June 18, 2025 12:02
Copy link
Collaborator

@iwoplaza iwoplaza left a comment

Choose a reason for hiding this comment

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

Awesome addition! 🚀

Comment on lines +541 to +543
const pass = this.setupRenderPass();
const { branch } = this[$internal].core.options;
const internals = this[$internal];
Copy link
Collaborator

Choose a reason for hiding this comment

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

Small suggestion

Suggested change
const pass = this.setupRenderPass();
const { branch } = this[$internal].core.options;
const internals = this[$internal];
const internals = this[$internal];
const pass = this.setupRenderPass();
const { branch } = internals.core.options;

color: readonly [number, number, number],
position: keyof typeof colors,
): void {
colors[position] = d.vec4f(color[0], color[1], color[2], 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
colors[position] = d.vec4f(color[0], color[1], color[2], 1);
colors[position] = d.vec4f(...color, 1);

Copy link
Contributor

@aleksanderkatan aleksanderkatan left a comment

Choose a reason for hiding this comment

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

Another step closer to full coverage!

@@ -357,6 +362,17 @@ export interface RenderPass {
): undefined;
}

type ValidateSchema<TData extends AnyData> = HasNestedType<
Copy link
Contributor

Choose a reason for hiding this comment

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

What was our consensus on returning errors in types? Are we going to keep doing this or is this a special case?

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.

feat: Introduce index buffers
4 participants