{"id":44803758,"url":"https://github.com/ydah/wgpu-ruby","last_synced_at":"2026-02-16T14:22:09.489Z","repository":{"id":338723850,"uuid":"1125709809","full_name":"ydah/wgpu-ruby","owner":"ydah","description":"Ruby bindings for WebGPU via wgpu-native.","archived":false,"fork":false,"pushed_at":"2026-02-16T03:03:18.000Z","size":82,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-16T09:58:33.401Z","etag":null,"topics":["bindings","ruby","vulkan","webgpu","wgpu"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ydah.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-31T07:54:15.000Z","updated_at":"2026-02-16T03:03:21.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/ydah/wgpu-ruby","commit_stats":null,"previous_names":["ydah/wgpu-ruby"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/ydah/wgpu-ruby","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ydah%2Fwgpu-ruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ydah%2Fwgpu-ruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ydah%2Fwgpu-ruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ydah%2Fwgpu-ruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ydah","download_url":"https://codeload.github.com/ydah/wgpu-ruby/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ydah%2Fwgpu-ruby/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29508734,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-16T09:05:14.864Z","status":"ssl_error","status_checked_at":"2026-02-16T08:55:59.364Z","response_time":115,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["bindings","ruby","vulkan","webgpu","wgpu"],"created_at":"2026-02-16T14:22:08.816Z","updated_at":"2026-02-16T14:22:09.479Z","avatar_url":"https://github.com/ydah.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WGPU Ruby\n\nRuby bindings for [WebGPU](https://www.w3.org/TR/webgpu/) via [wgpu-native](https://github.com/gfx-rs/wgpu-native).\n\n## Features\n\n- Complete WebGPU API bindings using Ruby-FFI\n- GPU compute shaders (GPGPU)\n- Cross-platform support (macOS, Linux, Windows)\n- Automatic wgpu-native library download on gem install\n\n## Requirements\n\n- Ruby 3.2+\n- Supported platforms:\n  - macOS (x86_64, arm64)\n  - Linux (x86_64, aarch64)\n  - Windows (x86_64)\n\n## Installation\n\nAdd to your Gemfile:\n\n```ruby\ngem 'wgpu'\n```\n\nThen run:\n\n```bash\nbundle install\n```\n\nOr install directly:\n\n```bash\ngem install wgpu\n```\n\nThe wgpu-native library is automatically downloaded from GitHub Releases during installation.\n\n### Custom wgpu-native Build\n\nTo use a custom build of wgpu-native:\n\n```bash\nexport WGPU_LIB_PATH=/path/to/libwgpu_native.so\n```\n\n## Usage\n\n### Basic Setup\n\n```ruby\nrequire 'wgpu'\n\ninstance = WGPU::Instance.new\nadapter = instance.request_adapter(power_preference: :high_performance)\ndevice = adapter.request_device\nqueue = device.queue\n\nputs \"Using: #{adapter.info[:device]} (#{adapter.info[:backend_type]})\"\n```\n\n### Compute Shader Example\n\n```ruby\nrequire 'wgpu'\n\nshader_code = \u003c\u003c~WGSL\n  @group(0) @binding(0) var\u003cstorage, read_write\u003e data: array\u003cf32\u003e;\n\n  @compute @workgroup_size(64)\n  fn main(@builtin(global_invocation_id) id: vec3\u003cu32\u003e) {\n    data[id.x] = data[id.x] * 2.0;\n  }\nWGSL\n\ninstance = WGPU::Instance.new\nadapter = instance.request_adapter\ndevice = adapter.request_device\nqueue = device.queue\n\n# Create buffer with initial data\ninput_data = (0...256).map(\u0026:to_f)\nbuffer = device.create_buffer(\n  size: input_data.size * 4,\n  usage: [:storage, :copy_src, :copy_dst],\n  mapped_at_creation: true\n)\nbuffer.mapped_range.write_floats(input_data)\nbuffer.unmap\n\n# Create shader and pipeline\nshader = device.create_shader_module(code: shader_code)\n\nbind_group_layout = device.create_bind_group_layout(\n  entries: [{ binding: 0, visibility: :compute, buffer: { type: :storage } }]\n)\n\nbind_group = device.create_bind_group(\n  layout: bind_group_layout,\n  entries: [{ binding: 0, buffer: buffer, offset: 0, size: buffer.size }]\n)\n\npipeline_layout = device.create_pipeline_layout(bind_group_layouts: [bind_group_layout])\npipeline = device.create_compute_pipeline(\n  layout: pipeline_layout,\n  compute: { module: shader, entry_point: \"main\" }\n)\n\n# Execute compute pass\nencoder = device.create_command_encoder\npass = encoder.begin_compute_pass\npass.set_pipeline(pipeline)\npass.set_bind_group(0, bind_group)\npass.dispatch_workgroups(input_data.size / 64)\npass.end_pass\nqueue.submit([encoder.finish])\n\n# Read results\nresult = queue.read_buffer(buffer, device: device)\noutput_data = result.unpack(\"f*\")\n\nputs output_data[0, 10].inspect\n# =\u003e [0.0, 2.0, 4.0, 6.0, 8.0, 10.0, 12.0, 14.0, 16.0, 18.0]\n```\n\n## Examples\n\nSee the `examples/` directory for more complete examples:\n\nCompute examples:\n- `01_adapter_info.rb` - Query GPU adapter information\n- `02_compute_basic.rb` - Basic compute shader\n- `03_buffer_operations.rb` - Buffer read/write operations\n- `04_matrix_multiply.rb` - GPU matrix multiplication\n- `05_image_blur.rb` - Image processing with box filter\n- `06_parallel_reduction.rb` - Parallel sum reduction\n\nRendering examples (SDL3):\n- `07_triangle.rb` - Basic triangle rendering\n- `08_colored_quad.rb` - Indexed colored quad rendering\n- `09_clear_color.rb` - Animated clear color\n- `10_textured_quad.rb` - Textured quad rendering\n- `11_rotating_cube.rb` - Rotating 3D cube with depth buffer\n\nRun an example:\n\n```bash\nbundle exec ruby examples/02_compute_basic.rb\n```\n\nRendering examples require SDL3 on your system:\n\n```bash\n# macOS\nbrew install sdl3\n```\n\n## API Overview\n\n### Core Objects\n\n| Class | Description |\n|-------|-------------|\n| `WGPU::Instance` | Entry point for WebGPU |\n| `WGPU::Adapter` | Represents a GPU adapter |\n| `WGPU::Device` | Logical device for GPU operations |\n| `WGPU::Queue` | Command submission queue |\n\n### Resources\n\n| Class | Description |\n|-------|-------------|\n| `WGPU::Buffer` | GPU buffer for data storage |\n| `WGPU::Texture` | GPU texture |\n| `WGPU::TextureView` | View into a texture |\n| `WGPU::Sampler` | Texture sampling configuration |\n\n### Pipeline\n\n| Class | Description |\n|-------|-------------|\n| `WGPU::ShaderModule` | Compiled WGSL shader |\n| `WGPU::ComputePipeline` | Compute shader pipeline |\n| `WGPU::RenderPipeline` | Render pipeline |\n| `WGPU::BindGroup` | Resource bindings for shaders |\n| `WGPU::BindGroupLayout` | Layout definition for bind groups |\n| `WGPU::PipelineLayout` | Pipeline layout definition |\n\n### Commands\n\n| Class | Description |\n|-------|-------------|\n| `WGPU::CommandEncoder` | Records GPU commands |\n| `WGPU::CommandBuffer` | Encoded commands ready to submit |\n| `WGPU::ComputePass` | Compute pass encoder |\n| `WGPU::RenderPass` | Render pass encoder |\n\n## Development\n\n```bash\ngit clone https://github.com/ydah/wgpu-ruby.git\ncd wgpu-ruby\nbundle install\nbundle exec rake spec\n```\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/ydah/wgpu-ruby.\n\n## License\n\nLicensed under either of\n\n- [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0)\n- [MIT License](http://opensource.org/licenses/MIT)\n\nat your option.\n\n## References\n\n- [WebGPU Specification](https://www.w3.org/TR/webgpu/)\n- [WGSL Specification](https://www.w3.org/TR/WGSL/)\n- [wgpu-native](https://github.com/gfx-rs/wgpu-native)\n- [wgpu (Rust)](https://github.com/gfx-rs/wgpu)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fydah%2Fwgpu-ruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fydah%2Fwgpu-ruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fydah%2Fwgpu-ruby/lists"}