{"id":20461376,"url":"https://github.com/antvis/g-webgl-compute","last_synced_at":"2025-08-21T07:33:07.188Z","repository":{"id":38431835,"uuid":"243957699","full_name":"antvis/g-webgl-compute","owner":"antvis","description":"A GPGPU implementation based on WebGL.","archived":false,"fork":false,"pushed_at":"2023-09-28T05:44:25.000Z","size":33691,"stargazers_count":145,"open_issues_count":37,"forks_count":15,"subscribers_count":10,"default_branch":"master","last_synced_at":"2024-10-29T21:05:30.406Z","etag":null,"topics":["gpgpu","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/antvis.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2020-02-29T11:38:18.000Z","updated_at":"2024-09-29T18:53:33.000Z","dependencies_parsed_at":"2023-09-29T04:02:44.858Z","dependency_job_id":null,"html_url":"https://github.com/antvis/g-webgl-compute","commit_stats":null,"previous_names":["antvis/g-webgl-compute","antvis/gwebgpuengine"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antvis%2Fg-webgl-compute","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antvis%2Fg-webgl-compute/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antvis%2Fg-webgl-compute/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antvis%2Fg-webgl-compute/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/antvis","download_url":"https://codeload.github.com/antvis/g-webgl-compute/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230501172,"owners_count":18236061,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gpgpu","typescript"],"created_at":"2024-11-15T12:25:07.264Z","updated_at":"2024-12-19T21:09:26.797Z","avatar_url":"https://github.com/antvis.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @antv/g-webgl-compute\n\n[![travis ci](https://travis-ci.com/antvis/GWebGPUEngine.svg?branch=master)](https://travis-ci.com/antvis/GWebGPUEngine) [![](https://flat.badgen.net/npm/v/@antv/g-webgpu?icon=npm)](https://www.npmjs.com/package/@antv/g-webgpu) ![最近提交](https://badgen.net/github/last-commit/antvis/GWebGPUEngine)\n\nA GPGPU implematation based on WebGL. [中文](./README.zh-CN.md)\n\n## GPGPU\n\nYou can try to solve some compute-intensive tasks like layout \u0026 particle effects with GPGPU technique.\nUse any rendering techniques(d3, g, Three.js or ours' rendering API if you like) when calculation is completed.\n\n```typescript\nimport { World } from '@antv/g-webgl-compute';\n\nconst world = new World({\n  engineOptions: {\n    supportCompute: true,\n  },\n});\n\nconst compute = world.createComputePipeline({\n  shader: `\n    //...\n  `,\n  dispatch: [1, 1, 1],\n  onCompleted: (result) =\u003e {\n    console.log(result); // [2, 4, 6, 8, 10, 12, 14, 16]\n    world.destroy();\n  },\n});\n\n// bind 2 params to Compute Shader\nworld.setBinding(compute, 'vectorA', [1, 2, 3, 4, 5, 6, 7, 8]);\nworld.setBinding(compute, 'vectorB', [1, 2, 3, 4, 5, 6, 7, 8]);\n```\n\nOur Compute Shader using Typescript syntax：\n\n```typescript\nimport { globalInvocationID } from 'g-webgpu';\n\n@numthreads(8, 1, 1)\nclass Add2Vectors {\n  @in @out\n  vectorA: float[];\n\n  @in\n  vectorB: float[];\n\n  sum(a: float, b: float): float {\n    return a + b;\n  }\n\n  @main\n  compute() {\n    // 获取当前线程处理的数据\n    const a = this.vectorA[globalInvocationID.x];\n    const b = this.vectorB[globalInvocationID.x];\n\n    // 输出当前线程处理完毕的数据，即两个向量相加后的结果\n    this.vectorA[globalInvocationID.x] = this.sum(a, b);\n  }\n}\n```\n\n## Resources\n\n- [WebGPU Design](https://github.com/gpuweb/gpuweb/tree/master/design)\n- [WebGPU Samples](https://github.com/austinEng/webgpu-samples)\n- [Raw WebGPU](https://alain.xyz/blog/raw-webgpu)\n- [WebGPU implementation in Rust](https://github.com/gfx-rs/wgpu)\n- [awesome-webgpu](https://github.com/mikbry/awesome-webgpu)\n- [Matrix Compute Online Demo](https://observablehq.com/@yhyddr/gpu-matrix-compute)\n- [From WebGL to WebGPU](https://www.youtube.com/watch?v=A2FxeEl4nWw)\n- [tensorflow.js WebGPU backend](https://github.com/tensorflow/tfjs/tree/master/tfjs-backend-webgpu)\n- [get-started-with-gpu-compute-on-the-web](https://developers.google.com/web/updates/2019/08/get-started-with-gpu-compute-on-the-web#shader_programming)\n\n## Contributing\n\nBootstrap with Yarn Workspace.\n\n```bash\nyarn install\n```\n\nWatch all the packages:\n\n```bash\nyarn watch\n```\n\n```bash\nyarn start\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantvis%2Fg-webgl-compute","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fantvis%2Fg-webgl-compute","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantvis%2Fg-webgl-compute/lists"}