wgpu 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,413 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WGPU
4
+ module Native
5
+ attach_function :wgpuCreateInstance,
6
+ [InstanceDescriptor.by_ref], :pointer
7
+
8
+ attach_function :wgpuInstanceRelease,
9
+ [:pointer], :void
10
+
11
+ attach_function :wgpuInstanceRequestAdapter,
12
+ [:pointer, RequestAdapterOptions.by_ref, RequestAdapterCallbackInfo.by_value], :pointer
13
+
14
+ attach_function :wgpuInstanceEnumerateAdapters,
15
+ [:pointer, :pointer, :pointer], :size_t
16
+
17
+ attach_function :wgpuInstanceProcessEvents,
18
+ [:pointer], :void
19
+
20
+ attach_function :wgpuAdapterRelease,
21
+ [:pointer], :void
22
+
23
+ attach_function :wgpuAdapterGetInfo,
24
+ [:pointer, AdapterInfo.by_ref], :void
25
+
26
+ attach_function :wgpuAdapterRequestDevice,
27
+ [:pointer, DeviceDescriptor.by_ref, RequestDeviceCallbackInfo.by_value], :pointer
28
+
29
+ attach_function :wgpuAdapterGetFeatures,
30
+ [:pointer, :pointer], :void
31
+
32
+ attach_function :wgpuAdapterGetLimits,
33
+ [:pointer, :pointer], :uint32
34
+
35
+ attach_function :wgpuDeviceRelease,
36
+ [:pointer], :void
37
+
38
+ attach_function :wgpuDeviceGetQueue,
39
+ [:pointer], :pointer
40
+
41
+ attach_function :wgpuDeviceCreateBuffer,
42
+ [:pointer, BufferDescriptor.by_ref], :pointer
43
+
44
+ attach_function :wgpuDeviceCreateTexture,
45
+ [:pointer, TextureDescriptor.by_ref], :pointer
46
+
47
+ attach_function :wgpuDeviceCreateSampler,
48
+ [:pointer, :pointer], :pointer
49
+
50
+ attach_function :wgpuDeviceCreateShaderModule,
51
+ [:pointer, ShaderModuleDescriptor.by_ref], :pointer
52
+
53
+ attach_function :wgpuDeviceCreateBindGroupLayout,
54
+ [:pointer, BindGroupLayoutDescriptor.by_ref], :pointer
55
+
56
+ attach_function :wgpuDeviceCreateBindGroup,
57
+ [:pointer, BindGroupDescriptor.by_ref], :pointer
58
+
59
+ attach_function :wgpuDeviceCreatePipelineLayout,
60
+ [:pointer, PipelineLayoutDescriptor.by_ref], :pointer
61
+
62
+ attach_function :wgpuDeviceCreateRenderPipeline,
63
+ [:pointer, :pointer], :pointer
64
+
65
+ attach_function :wgpuDeviceCreateComputePipeline,
66
+ [:pointer, ComputePipelineDescriptor.by_ref], :pointer
67
+
68
+ attach_function :wgpuDeviceCreateCommandEncoder,
69
+ [:pointer, CommandEncoderDescriptor.by_ref], :pointer
70
+
71
+ attach_function :wgpuDevicePoll,
72
+ [:pointer, :uint32, :pointer], :uint32
73
+
74
+ attach_function :wgpuQueueRelease,
75
+ [:pointer], :void
76
+
77
+ attach_function :wgpuQueueSubmit,
78
+ [:pointer, :size_t, :pointer], :void
79
+
80
+ attach_function :wgpuQueueOnSubmittedWorkDone,
81
+ [:pointer, QueueWorkDoneCallbackInfo.by_value], :pointer
82
+
83
+ attach_function :wgpuQueueWriteBuffer,
84
+ [:pointer, :pointer, :uint64, :pointer, :size_t], :void
85
+
86
+ attach_function :wgpuQueueWriteTexture,
87
+ [:pointer, :pointer, :pointer, :size_t, :pointer, :pointer], :void
88
+
89
+ attach_function :wgpuBufferRelease,
90
+ [:pointer], :void
91
+
92
+ attach_function :wgpuBufferDestroy,
93
+ [:pointer], :void
94
+
95
+ attach_function :wgpuBufferMapAsync,
96
+ [:pointer, :uint64, :size_t, :size_t, BufferMapCallbackInfo.by_value], :pointer
97
+
98
+ attach_function :wgpuBufferUnmap,
99
+ [:pointer], :void
100
+
101
+ attach_function :wgpuBufferGetMappedRange,
102
+ [:pointer, :size_t, :size_t], :pointer
103
+
104
+ attach_function :wgpuBufferGetConstMappedRange,
105
+ [:pointer, :size_t, :size_t], :pointer
106
+
107
+ attach_function :wgpuBufferGetSize,
108
+ [:pointer], :uint64
109
+
110
+ attach_function :wgpuBufferGetUsage,
111
+ [:pointer], :uint64
112
+
113
+ attach_function :wgpuBufferGetMapState,
114
+ [:pointer], BufferMapState
115
+
116
+ attach_function :wgpuShaderModuleRelease,
117
+ [:pointer], :void
118
+
119
+ attach_function :wgpuShaderModuleGetCompilationInfo,
120
+ [:pointer, CompilationInfoCallbackInfo.by_value], :pointer
121
+
122
+ attach_function :wgpuCommandEncoderRelease,
123
+ [:pointer], :void
124
+
125
+ attach_function :wgpuCommandEncoderBeginRenderPass,
126
+ [:pointer, RenderPassDescriptor.by_ref], :pointer
127
+
128
+ attach_function :wgpuCommandEncoderBeginComputePass,
129
+ [:pointer, ComputePassDescriptor.by_ref], :pointer
130
+
131
+ attach_function :wgpuCommandEncoderCopyBufferToBuffer,
132
+ [:pointer, :pointer, :uint64, :pointer, :uint64, :uint64], :void
133
+
134
+ attach_function :wgpuCommandEncoderCopyBufferToTexture,
135
+ [:pointer, :pointer, :pointer, :pointer], :void
136
+
137
+ attach_function :wgpuCommandEncoderCopyTextureToBuffer,
138
+ [:pointer, :pointer, :pointer, :pointer], :void
139
+
140
+ attach_function :wgpuCommandEncoderCopyTextureToTexture,
141
+ [:pointer, :pointer, :pointer, :pointer], :void
142
+
143
+ attach_function :wgpuCommandEncoderFinish,
144
+ [:pointer, :pointer], :pointer
145
+
146
+ attach_function :wgpuCommandEncoderClearBuffer,
147
+ [:pointer, :pointer, :uint64, :uint64], :void
148
+
149
+ attach_function :wgpuCommandEncoderWriteTimestamp,
150
+ [:pointer, :pointer, :uint32], :void
151
+
152
+ attach_function :wgpuCommandEncoderPushDebugGroup,
153
+ [:pointer, StringView.by_value], :void
154
+
155
+ attach_function :wgpuCommandEncoderPopDebugGroup,
156
+ [:pointer], :void
157
+
158
+ attach_function :wgpuCommandEncoderInsertDebugMarker,
159
+ [:pointer, StringView.by_value], :void
160
+
161
+ attach_function :wgpuCommandBufferRelease,
162
+ [:pointer], :void
163
+
164
+ attach_function :wgpuRenderPassEncoderRelease,
165
+ [:pointer], :void
166
+
167
+ attach_function :wgpuRenderPassEncoderEnd,
168
+ [:pointer], :void
169
+
170
+ attach_function :wgpuRenderPassEncoderSetPipeline,
171
+ [:pointer, :pointer], :void
172
+
173
+ attach_function :wgpuRenderPassEncoderSetBindGroup,
174
+ [:pointer, :uint32, :pointer, :size_t, :pointer], :void
175
+
176
+ attach_function :wgpuRenderPassEncoderSetVertexBuffer,
177
+ [:pointer, :uint32, :pointer, :uint64, :uint64], :void
178
+
179
+ attach_function :wgpuRenderPassEncoderSetIndexBuffer,
180
+ [:pointer, :pointer, IndexFormat, :uint64, :uint64], :void
181
+
182
+ attach_function :wgpuRenderPassEncoderDraw,
183
+ [:pointer, :uint32, :uint32, :uint32, :uint32], :void
184
+
185
+ attach_function :wgpuRenderPassEncoderDrawIndexed,
186
+ [:pointer, :uint32, :uint32, :uint32, :int32, :uint32], :void
187
+
188
+ attach_function :wgpuRenderPassEncoderSetViewport,
189
+ [:pointer, :float, :float, :float, :float, :float, :float], :void
190
+
191
+ attach_function :wgpuRenderPassEncoderSetScissorRect,
192
+ [:pointer, :uint32, :uint32, :uint32, :uint32], :void
193
+
194
+ attach_function :wgpuRenderPassEncoderSetBlendConstant,
195
+ [:pointer, :pointer], :void
196
+
197
+ attach_function :wgpuRenderPassEncoderSetStencilReference,
198
+ [:pointer, :uint32], :void
199
+
200
+ attach_function :wgpuRenderPassEncoderDrawIndirect,
201
+ [:pointer, :pointer, :uint64], :void
202
+
203
+ attach_function :wgpuRenderPassEncoderDrawIndexedIndirect,
204
+ [:pointer, :pointer, :uint64], :void
205
+
206
+ attach_function :wgpuRenderPassEncoderExecuteBundles,
207
+ [:pointer, :size_t, :pointer], :void
208
+
209
+ attach_function :wgpuRenderPassEncoderBeginOcclusionQuery,
210
+ [:pointer, :uint32], :void
211
+
212
+ attach_function :wgpuRenderPassEncoderEndOcclusionQuery,
213
+ [:pointer], :void
214
+
215
+ attach_function :wgpuRenderPassEncoderPushDebugGroup,
216
+ [:pointer, StringView.by_value], :void
217
+
218
+ attach_function :wgpuRenderPassEncoderPopDebugGroup,
219
+ [:pointer], :void
220
+
221
+ attach_function :wgpuRenderPassEncoderInsertDebugMarker,
222
+ [:pointer, StringView.by_value], :void
223
+
224
+ attach_function :wgpuComputePassEncoderRelease,
225
+ [:pointer], :void
226
+
227
+ attach_function :wgpuComputePassEncoderEnd,
228
+ [:pointer], :void
229
+
230
+ attach_function :wgpuComputePassEncoderSetPipeline,
231
+ [:pointer, :pointer], :void
232
+
233
+ attach_function :wgpuComputePassEncoderSetBindGroup,
234
+ [:pointer, :uint32, :pointer, :size_t, :pointer], :void
235
+
236
+ attach_function :wgpuComputePassEncoderDispatchWorkgroups,
237
+ [:pointer, :uint32, :uint32, :uint32], :void
238
+
239
+ attach_function :wgpuComputePassEncoderDispatchWorkgroupsIndirect,
240
+ [:pointer, :pointer, :uint64], :void
241
+
242
+ attach_function :wgpuComputePassEncoderPushDebugGroup,
243
+ [:pointer, StringView.by_value], :void
244
+
245
+ attach_function :wgpuComputePassEncoderPopDebugGroup,
246
+ [:pointer], :void
247
+
248
+ attach_function :wgpuComputePassEncoderInsertDebugMarker,
249
+ [:pointer, StringView.by_value], :void
250
+
251
+ attach_function :wgpuBindGroupRelease,
252
+ [:pointer], :void
253
+
254
+ attach_function :wgpuBindGroupLayoutRelease,
255
+ [:pointer], :void
256
+
257
+ attach_function :wgpuPipelineLayoutRelease,
258
+ [:pointer], :void
259
+
260
+ attach_function :wgpuComputePipelineRelease,
261
+ [:pointer], :void
262
+
263
+ attach_function :wgpuRenderPipelineRelease,
264
+ [:pointer], :void
265
+
266
+ attach_function :wgpuTextureRelease,
267
+ [:pointer], :void
268
+
269
+ attach_function :wgpuTextureDestroy,
270
+ [:pointer], :void
271
+
272
+ attach_function :wgpuTextureCreateView,
273
+ [:pointer, :pointer], :pointer
274
+
275
+ attach_function :wgpuTextureViewRelease,
276
+ [:pointer], :void
277
+
278
+ attach_function :wgpuAdapterInfoFreeMembers,
279
+ [AdapterInfo.by_value], :void
280
+
281
+ attach_function :wgpuSamplerRelease,
282
+ [:pointer], :void
283
+
284
+ attach_function :wgpuInstanceCreateSurface,
285
+ [:pointer, SurfaceDescriptor.by_ref], :pointer
286
+
287
+ attach_function :wgpuSurfaceRelease,
288
+ [:pointer], :void
289
+
290
+ attach_function :wgpuSurfaceConfigure,
291
+ [:pointer, SurfaceConfiguration.by_ref], :void
292
+
293
+ attach_function :wgpuSurfaceUnconfigure,
294
+ [:pointer], :void
295
+
296
+ attach_function :wgpuSurfaceGetCurrentTexture,
297
+ [:pointer, SurfaceTexture.by_ref], :void
298
+
299
+ attach_function :wgpuSurfacePresent,
300
+ [:pointer], :void
301
+
302
+ attach_function :wgpuSurfaceGetCapabilities,
303
+ [:pointer, :pointer, SurfaceCapabilities.by_ref], :void
304
+
305
+ attach_function :wgpuTextureGetWidth,
306
+ [:pointer], :uint32
307
+
308
+ attach_function :wgpuTextureGetHeight,
309
+ [:pointer], :uint32
310
+
311
+ attach_function :wgpuTextureGetDepthOrArrayLayers,
312
+ [:pointer], :uint32
313
+
314
+ attach_function :wgpuTextureGetMipLevelCount,
315
+ [:pointer], :uint32
316
+
317
+ attach_function :wgpuTextureGetSampleCount,
318
+ [:pointer], :uint32
319
+
320
+ attach_function :wgpuTextureGetDimension,
321
+ [:pointer], TextureDimension
322
+
323
+ attach_function :wgpuTextureGetFormat,
324
+ [:pointer], TextureFormat
325
+
326
+ attach_function :wgpuTextureGetUsage,
327
+ [:pointer], :uint64
328
+
329
+ attach_function :wgpuDeviceCreateQuerySet,
330
+ [:pointer, QuerySetDescriptor.by_ref], :pointer
331
+
332
+ attach_function :wgpuQuerySetDestroy,
333
+ [:pointer], :void
334
+
335
+ attach_function :wgpuQuerySetRelease,
336
+ [:pointer], :void
337
+
338
+ attach_function :wgpuQuerySetGetCount,
339
+ [:pointer], :uint32
340
+
341
+ attach_function :wgpuQuerySetGetType,
342
+ [:pointer], QueryType
343
+
344
+ attach_function :wgpuCommandEncoderResolveQuerySet,
345
+ [:pointer, :pointer, :uint32, :uint32, :pointer, :uint64], :void
346
+
347
+ attach_function :wgpuAdapterGetFeatures,
348
+ [:pointer, SupportedFeatures.by_ref], :void
349
+
350
+ attach_function :wgpuDeviceGetFeatures,
351
+ [:pointer, SupportedFeatures.by_ref], :void
352
+
353
+ attach_function :wgpuDeviceGetLimits,
354
+ [:pointer, SupportedLimits.by_ref], :uint32
355
+
356
+ attach_function :wgpuDevicePushErrorScope,
357
+ [:pointer, ErrorFilter], :void
358
+
359
+ attach_function :wgpuDevicePopErrorScope,
360
+ [:pointer, PopErrorScopeCallbackInfo.by_value], :pointer
361
+
362
+ attach_function :wgpuComputePipelineGetBindGroupLayout,
363
+ [:pointer, :uint32], :pointer
364
+
365
+ attach_function :wgpuRenderPipelineGetBindGroupLayout,
366
+ [:pointer, :uint32], :pointer
367
+
368
+ attach_function :wgpuDeviceCreateRenderBundleEncoder,
369
+ [:pointer, RenderBundleEncoderDescriptor.by_ref], :pointer
370
+
371
+ attach_function :wgpuRenderBundleEncoderFinish,
372
+ [:pointer, :pointer], :pointer
373
+
374
+ attach_function :wgpuRenderBundleEncoderRelease,
375
+ [:pointer], :void
376
+
377
+ attach_function :wgpuRenderBundleRelease,
378
+ [:pointer], :void
379
+
380
+ attach_function :wgpuRenderBundleEncoderSetPipeline,
381
+ [:pointer, :pointer], :void
382
+
383
+ attach_function :wgpuRenderBundleEncoderSetBindGroup,
384
+ [:pointer, :uint32, :pointer, :size_t, :pointer], :void
385
+
386
+ attach_function :wgpuRenderBundleEncoderSetVertexBuffer,
387
+ [:pointer, :uint32, :pointer, :uint64, :uint64], :void
388
+
389
+ attach_function :wgpuRenderBundleEncoderSetIndexBuffer,
390
+ [:pointer, :pointer, IndexFormat, :uint64, :uint64], :void
391
+
392
+ attach_function :wgpuRenderBundleEncoderDraw,
393
+ [:pointer, :uint32, :uint32, :uint32, :uint32], :void
394
+
395
+ attach_function :wgpuRenderBundleEncoderDrawIndexed,
396
+ [:pointer, :uint32, :uint32, :uint32, :int32, :uint32], :void
397
+
398
+ attach_function :wgpuRenderBundleEncoderDrawIndirect,
399
+ [:pointer, :pointer, :uint64], :void
400
+
401
+ attach_function :wgpuRenderBundleEncoderDrawIndexedIndirect,
402
+ [:pointer, :pointer, :uint64], :void
403
+
404
+ attach_function :wgpuRenderBundleEncoderPushDebugGroup,
405
+ [:pointer, StringView.by_value], :void
406
+
407
+ attach_function :wgpuRenderBundleEncoderPopDebugGroup,
408
+ [:pointer], :void
409
+
410
+ attach_function :wgpuRenderBundleEncoderInsertDebugMarker,
411
+ [:pointer, StringView.by_value], :void
412
+ end
413
+ end
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "ffi"
4
+ require "rbconfig"
5
+
6
+ module WGPU
7
+ module Native
8
+ extend FFI::Library
9
+
10
+ WGPU_VERSION = "v27.0.4.0"
11
+
12
+ class << self
13
+ def library_path
14
+ if ENV["WGPU_LIB_PATH"]
15
+ path = ENV["WGPU_LIB_PATH"]
16
+ raise LoadError, "WGPU_LIB_PATH points to non-existent file: #{path}" unless File.exist?(path)
17
+ return path
18
+ end
19
+
20
+ cached_path = File.join(cache_dir, "lib", library_name)
21
+ return cached_path if File.exist?(cached_path)
22
+
23
+ raise LoadError, <<~MSG
24
+ wgpu-native library not found.
25
+ Expected at: #{cached_path}
26
+
27
+ Try reinstalling the gem:
28
+ gem install wgpu
29
+
30
+ Or set WGPU_LIB_PATH environment variable to your custom wgpu-native build.
31
+ MSG
32
+ end
33
+
34
+ def cache_dir
35
+ File.join(Dir.home, ".cache", "wgpu-ruby", WGPU_VERSION)
36
+ end
37
+
38
+ def library_name
39
+ case host_os
40
+ when /linux/ then "libwgpu_native.so"
41
+ when /darwin/ then "libwgpu_native.dylib"
42
+ when /mingw|mswin/ then "wgpu_native.dll"
43
+ else raise LoadError, "Unsupported OS: #{host_os}"
44
+ end
45
+ end
46
+
47
+ private
48
+
49
+ def host_os
50
+ RbConfig::CONFIG["host_os"]
51
+ end
52
+ end
53
+
54
+ ffi_lib library_path
55
+ end
56
+ end
57
+
58
+ require_relative "enums"
59
+ require_relative "structs"
60
+ require_relative "callbacks"
61
+ require_relative "functions"