Skip to content

Noah/webgpu scatterbrain pt1#246

Open
froyo-np wants to merge 29 commits into
mainfrom
noah/webgpu-scatterbrain-pt1
Open

Noah/webgpu scatterbrain pt1#246
froyo-np wants to merge 29 commits into
mainfrom
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

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.

@Jarbuckle interested in your thoughts on this part!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Alrighty, I shall take a look! 🙂

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

@froyo-np froyo-np marked this pull request as ready for review May 1, 2026 16:11
@froyo-np froyo-np requested a review from a team as a code owner May 1, 2026 16:11
@froyo-np froyo-np requested review from TheMooseman and suyli7 May 1, 2026 16:11
@froyo-np froyo-np requested review from Jarbuckle and removed request for suyli7 May 4, 2026 17:35
// ugh, it also requires bindgroup layouts in non-auto mode - such a slog
// ok - seems like the most normal-person thing to do here would be to split out the per-qt-node and the per-frame uniforms into 2 groups
// then create the per-qt-node data when we load it, and stow it in the cache... that would be ok, although it does require
// a bindGroupLayout (non-automode) separate from the creation of the pipeline... thats gonna be a good idea anyway if anyone ever changes any settings for these...
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The decision here is very sound, we should just clean up this comment


function columnsForItem<T extends object>(
config: Config,
col2shader: Record<string, string>,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I would still name it columnNameToShaderName here

dataset: ScatterbrainDataset | SlideviewScatterbrainDataset,
) {
const columns: Record<string, ColumnRequest> = {};
const s2c = Object.keys(col2shader).reduce(
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

shaderNameToColumnName

}
const bg = device.createBindGroup({
label: 'single bg',
entries,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

does createBindGroup succeed here if settings.categoricalFilters and quantitativeRangeFilters are empty?

I'm having some trouble running the demo

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.

3 participants