Skip to content

Noah/webgpu scatterbrain pt1#246

Draft
froyo-np wants to merge 10 commits intomainfrom
noah/webgpu-scatterbrain-pt1
Draft

Noah/webgpu scatterbrain pt1#246
froyo-np wants to merge 10 commits intomainfrom
noah/webgpu-scatterbrain-pt1

Conversation

@froyo-np
Copy link
Copy Markdown
Collaborator

WIP Steps

This section is optional if the PR is fully ready for review

  • Create the PR as a "draft" PR
  • Add [WIP] to the title
  • Use the template below to ask for specific feedback
  • @name: Could you look at ___? I'm trying to do... (etc.)

What

Replace this with 1-2 line Description of what feature, bugfix, chore does the PR contain the code for.

How

Replace this txt describing what kind of technical overlaying code changes were introduced here.

Screenshots

This section is optional if there are no visible changes

  • If possible add screenshots of the visible additions in the UI.
  • If there are changes in the UI, add Before and After Screenshots for quick overview.
  • If there was a Figma design, add a link to that here as well.
  • Hint : Drag and Drop any images you want to add to the PR. Also you can create a gif of an interactive version and add that!

PR Checklist

  • Is your PR title following our conventional commit naming recommendations?
  • Have you filled in the PR Description Template?
  • Is your branch up to date with the latest in main?
  • Do the CI checks pass successfully?
  • Have you smoke tested the example applications?
  • Did you check that the changes meet accessibility standards?
  • Have you tested the application on these browsers?
    • Chrome (Fully supported)
    • Firefox (Major bug fixes supported)
    • Safari (Major bug fixes supported)


type Content<V extends Cacheable> = Record<string, V>

export function buildScatterbrainCacheClient<V extends Cacheable>(
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

this file got moved - its mostly the same as the old webGL cache client! it did get a tiny tweak to make it agnostic to webGL / webGPU - you can use the same function (this one) to create either a webGL or webGPU cache-client, and they can even share the same cache, if you wanted

@@ -0,0 +1,32 @@
<!DOCTYPE html>
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

this is the demo I used to debug my webGPU implementation - we should remove it, but for now starlight seems to have trouble with our webGPU utils (a 3rd party helper)

} & QuantitativeFilterRanges


export function generate(config: Config): string {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

the guts of the shader that we generate to render a scatterplot in a particular configuration

const toGpuBuffer = (buffer: ArrayBuffer, type: WebGLSafeBasicType) => {
if (type === 'uint16') {
// seems like uint16 is cursed - vertex buffers have to have a stride of at least 4...
const B = device.createBuffer({ size: buffer.byteLength * 2, usage: GPUBufferUsage.COPY_DST | GPUBufferUsage.VERTEX });
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

here is the hack I use to deal with uint16 data - we expand it here when we cache it - its not slow, and we still get to keep our 16bit ints over the wire, but on the GPU we have to expand them to 32bit

Copy link
Copy Markdown
Collaborator Author

@froyo-np froyo-np Apr 27, 2026

Choose a reason for hiding this comment

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

note that uint16 data is supported in webGPU, but any buffer that is bound as a vertex attribute must declare an arrayStride of at least 4 (bytes). this means if that its easy to use u16 data in an interleaved buffer, but impossible to use via separate buffers as we do for scatterbrain style columnar vertex data

const bg1 = updateCategorical(categories);
const bg2 = updateGradient(viridis); // todo - dont do this every frame...

// so... the gad damn bindings - if you dont use a binding, it needs to be omitted from
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

this comment was made in anger, as I beat my head against a wall trying to get the shader to validate. remove!

};


export async function whatever() {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

the bootstrap function for my demo - remote eventually

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.

1 participant