wgpu 1.2.0 → 1.2.1

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.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +40 -0
  3. data/README.md +18 -2
  4. data/docs/README.md +2 -2
  5. data/docs/api_coverage.md +23 -15
  6. data/docs/async.md +10 -0
  7. data/docs/command_encoding.md +25 -0
  8. data/docs/getting_started_compute.md +1 -0
  9. data/docs/pipeline_descriptors.md +7 -2
  10. data/docs/releasing.md +11 -1
  11. data/docs/resource_lifetime.md +16 -2
  12. data/docs/texture_readback.md +27 -0
  13. data/docs/troubleshooting.md +5 -0
  14. data/docs/upgrading_wgpu_native.md +16 -5
  15. data/lib/wgpu/async_task.rb +19 -0
  16. data/lib/wgpu/commands/command_buffer.rb +14 -1
  17. data/lib/wgpu/commands/command_encoder.rb +58 -1
  18. data/lib/wgpu/commands/compute_pass.rb +43 -0
  19. data/lib/wgpu/commands/render_bundle.rb +9 -1
  20. data/lib/wgpu/commands/render_bundle_encoder.rb +55 -1
  21. data/lib/wgpu/commands/render_pass.rb +102 -0
  22. data/lib/wgpu/core/adapter.rb +91 -12
  23. data/lib/wgpu/core/async_waiter.rb +15 -0
  24. data/lib/wgpu/core/canvas_context.rb +32 -0
  25. data/lib/wgpu/core/device.rb +296 -46
  26. data/lib/wgpu/core/instance.rb +20 -0
  27. data/lib/wgpu/core/queue.rb +139 -24
  28. data/lib/wgpu/core/surface.rb +49 -1
  29. data/lib/wgpu/data_types.rb +16 -0
  30. data/lib/wgpu/descriptor_helpers.rb +65 -0
  31. data/lib/wgpu/error.rb +15 -0
  32. data/lib/wgpu/native/abi_verifier.rb +37 -3
  33. data/lib/wgpu/native/callbacks.rb +6 -0
  34. data/lib/wgpu/native/capabilities.rb +16 -2
  35. data/lib/wgpu/native/distribution.rb +63 -0
  36. data/lib/wgpu/native/enum_helper.rb +17 -0
  37. data/lib/wgpu/native/enums.rb +8 -0
  38. data/lib/wgpu/native/fixtures/webgpu-v27.0.4.0-enums.h +848 -0
  39. data/lib/wgpu/native/functions.rb +11 -0
  40. data/lib/wgpu/native/installer.rb +48 -17
  41. data/lib/wgpu/native/loader.rb +22 -0
  42. data/lib/wgpu/native/structs.rb +18 -1
  43. data/lib/wgpu/native_resource.rb +174 -3
  44. data/lib/wgpu/pipeline/bind_group.rb +9 -0
  45. data/lib/wgpu/pipeline/bind_group_layout.rb +17 -4
  46. data/lib/wgpu/pipeline/compute_pipeline.rb +20 -32
  47. data/lib/wgpu/pipeline/pipeline_layout.rb +8 -0
  48. data/lib/wgpu/pipeline/render_pipeline.rb +27 -42
  49. data/lib/wgpu/pipeline/shader_module.rb +54 -29
  50. data/lib/wgpu/resources/buffer.rb +258 -31
  51. data/lib/wgpu/resources/query_set.rb +12 -0
  52. data/lib/wgpu/resources/sampler.rb +7 -0
  53. data/lib/wgpu/resources/texture.rb +45 -6
  54. data/lib/wgpu/resources/texture_view.rb +24 -4
  55. data/lib/wgpu/texture_format.rb +14 -0
  56. data/lib/wgpu/version.rb +1 -1
  57. data/lib/wgpu/window.rb +26 -0
  58. data/sig/wgpu.rbs +84 -5
  59. metadata +3 -1
@@ -4,6 +4,12 @@ module WGPU
4
4
  class Texture
5
5
  attr_reader :handle, :surface_status
6
6
 
7
+ # Creates a GPU texture.
8
+ # @param device [Device] owning device
9
+ # @param size [Hash, Array] texture extent
10
+ # @param format [Symbol, Integer] texel format
11
+ # @param usage [Symbol, Array<Symbol>, Integer] usage flags
12
+ # @raise [ResourceError] if native validation or creation fails
7
13
  def initialize(device, label: nil, size:, format:, usage:, dimension: :d2, mip_level_count: 1, sample_count: 1, view_formats: [])
8
14
  @device = device
9
15
 
@@ -30,15 +36,23 @@ module WGPU
30
36
  end
31
37
  end
32
38
 
33
- def self.from_handle(handle, surface_status: nil)
34
- texture = allocate
35
- texture.instance_variable_set(:@handle, handle)
36
- texture.instance_variable_set(:@device, nil)
39
+ # Wraps a native texture handle, such as a surface-acquired texture.
40
+ #
41
+ # @param handle [FFI::Pointer] native texture handle
42
+ # @param surface_status [Symbol, nil] acquisition status associated with the texture
43
+ # @param device [Device, nil] device whose callbacks the texture may use
44
+ # @return [Texture] adopted wrapper
45
+ def self.from_handle(handle, surface_status: nil, device: nil)
46
+ texture = adopt_native_handle(handle)
47
+ texture.instance_variable_set(:@device, device)
37
48
  texture.instance_variable_set(:@surface_status, surface_status)
49
+ texture.send(:attach_device_callback_lifetime, device)
38
50
  texture
39
51
  end
40
52
 
41
- def create_view(label: nil, format: nil, dimension: nil, base_mip_level: 0, mip_level_count: nil, base_array_layer: 0, array_layer_count: nil, aspect: :all)
53
+ # Creates a view into this texture.
54
+ # @return [TextureView]
55
+ def create_view(label: nil, format: nil, dimension: nil, base_mip_level: 0, mip_level_count: nil, base_array_layer: 0, array_layer_count: nil, aspect: :all, usage: nil)
42
56
  TextureView.new(self,
43
57
  label: label,
44
58
  format: format,
@@ -47,14 +61,19 @@ module WGPU
47
61
  mip_level_count: mip_level_count,
48
62
  base_array_layer: base_array_layer,
49
63
  array_layer_count: array_layer_count,
50
- aspect: aspect
64
+ aspect: aspect,
65
+ usage: usage
51
66
  )
52
67
  end
53
68
 
69
+ # Returns the texture width in texels.
70
+ # @return [Integer]
54
71
  def width
55
72
  Native.wgpuTextureGetWidth(@handle)
56
73
  end
57
74
 
75
+ # Returns the texture extent.
76
+ # @return [Hash{Symbol => Integer}]
58
77
  def size
59
78
  {
60
79
  width: width,
@@ -63,38 +82,58 @@ module WGPU
63
82
  }
64
83
  end
65
84
 
85
+ # Returns the texture height in texels.
86
+ # @return [Integer]
66
87
  def height
67
88
  Native.wgpuTextureGetHeight(@handle)
68
89
  end
69
90
 
91
+ # Returns the texture depth or array layer count.
92
+ # @return [Integer]
70
93
  def depth_or_array_layers
71
94
  Native.wgpuTextureGetDepthOrArrayLayers(@handle)
72
95
  end
73
96
 
97
+ # Returns the number of mip levels.
98
+ # @return [Integer]
74
99
  def mip_level_count
75
100
  Native.wgpuTextureGetMipLevelCount(@handle)
76
101
  end
77
102
 
103
+ # Returns the multisample count.
104
+ # @return [Integer]
78
105
  def sample_count
79
106
  Native.wgpuTextureGetSampleCount(@handle)
80
107
  end
81
108
 
109
+ # Returns the texture dimension.
110
+ # @return [Symbol, Integer]
82
111
  def dimension
83
112
  Native.wgpuTextureGetDimension(@handle)
84
113
  end
85
114
 
115
+ # Returns the texture format.
116
+ # @return [Symbol, Integer]
86
117
  def format
87
118
  Native.wgpuTextureGetFormat(@handle)
88
119
  end
89
120
 
121
+ # Returns the texture usage flags.
122
+ # @return [Integer]
90
123
  def usage
91
124
  Native.wgpuTextureGetUsage(@handle)
92
125
  end
93
126
 
127
+ # Destroys the texture's storage.
128
+ # @return [void]
94
129
  def destroy
95
130
  Native.wgpuTextureDestroy(@handle)
96
131
  end
97
132
 
133
+ # Releases the native texture handle.
134
+ #
135
+ # Calling this method more than once has no effect.
136
+ # @return [void]
98
137
  def release
99
138
  return if @handle.null?
100
139
  Native.wgpuTextureRelease(@handle)
@@ -4,7 +4,10 @@ module WGPU
4
4
  class TextureView
5
5
  attr_reader :handle, :texture
6
6
 
7
- def initialize(texture, label: nil, format: nil, dimension: nil, base_mip_level: 0, mip_level_count: nil, base_array_layer: 0, array_layer_count: nil, aspect: :all)
7
+ # Creates a view selecting texture format, dimension, subresources, and aspect.
8
+ # @param texture [Texture] parent texture
9
+ # @raise [ResourceError] if native creation fails
10
+ def initialize(texture, label: nil, format: nil, dimension: nil, base_mip_level: 0, mip_level_count: nil, base_array_layer: 0, array_layer_count: nil, aspect: :all, usage: nil)
8
11
  @texture = texture
9
12
 
10
13
  desc = Native::TextureViewDescriptor.new
@@ -32,22 +35,39 @@ module WGPU
32
35
  desc[:base_array_layer] = base_array_layer
33
36
  desc[:array_layer_count] = array_layer_count || 0xFFFFFFFF
34
37
  desc[:aspect] = Native::EnumHelper.coerce(Native::TextureAspect, aspect, name: "texture aspect")
38
+ desc[:usage] = Native::EnumHelper.coerce_flags(
39
+ Native::TextureUsage,
40
+ usage || :none,
41
+ name: "texture view usage"
42
+ )
35
43
 
36
44
  @handle = Native.wgpuTextureCreateView(texture.handle, desc)
37
45
  raise ResourceError, "Failed to create texture view" if @handle.null?
38
46
  end
39
47
 
40
- def self.from_handle(handle)
41
- view = allocate
42
- view.instance_variable_set(:@handle, handle)
48
+ # Wraps a native texture view handle owned by the caller.
49
+ #
50
+ # @param handle [FFI::Pointer] native texture view handle
51
+ # @param device [Device, nil] device whose callbacks the view may use
52
+ # @return [TextureView] adopted wrapper without a parent texture
53
+ def self.from_handle(handle, device: nil)
54
+ view = adopt_native_handle(handle)
43
55
  view.instance_variable_set(:@texture, nil)
56
+ view.send(:attach_device_callback_lifetime, device)
44
57
  view
45
58
  end
46
59
 
60
+ # Returns the parent texture dimensions when known.
61
+ #
62
+ # @return [Hash, nil] texture extent, or +nil+ for an adopted standalone view
47
63
  def size
48
64
  @texture&.size
49
65
  end
50
66
 
67
+ # Releases the native texture view handle.
68
+ #
69
+ # Calling this method more than once has no effect.
70
+ # @return [void]
51
71
  def release
52
72
  return if @handle.null?
53
73
  Native.wgpuTextureViewRelease(@handle)
@@ -6,24 +6,38 @@ module WGPU
6
6
 
7
7
  module_function
8
8
 
9
+ # Returns the byte size of one texel block.
10
+ # @return [Integer]
9
11
  def block_size(format, aspect: :all)
10
12
  block_info(format, aspect:).last
11
13
  end
12
14
 
15
+ # Returns a format's texel block width and height.
16
+ # @return [Array(Integer, Integer)]
13
17
  def block_dimensions(format)
14
18
  block_info(format).first(2)
15
19
  end
16
20
 
21
+ # Returns the tightly packed bytes required for one texel row.
22
+ # @return [Integer]
17
23
  def bytes_per_row(width, format, aspect: :all)
18
24
  block_width, _, bytes = block_info(format, aspect:)
19
25
  ((Integer(width) + block_width - 1) / block_width) * bytes
20
26
  end
21
27
 
28
+ # Returns row bytes rounded up to the requested copy alignment.
29
+ # @return [Integer]
22
30
  def aligned_bytes_per_row(width, format, aspect: :all, alignment: COPY_ALIGNMENT)
23
31
  row_bytes = bytes_per_row(width, format, aspect:)
24
32
  ((row_bytes + alignment - 1) / alignment) * alignment
25
33
  end
26
34
 
35
+ # Returns the copy footprint of one texel block.
36
+ #
37
+ # @param format [Symbol, Integer] texture format
38
+ # @param aspect [Symbol] texture aspect for depth/stencil formats
39
+ # @return [Array(Integer, Integer, Integer)] block width, height, and byte size
40
+ # @raise [ArgumentError] if the format has no portable copy footprint
27
41
  def block_info(format, aspect: :all)
28
42
  name = normalize_format(format)
29
43
  special = depth_stencil_block_info(name, aspect)
data/lib/wgpu/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WGPU
4
- VERSION = "1.2.0"
4
+ VERSION = "1.2.1"
5
5
  end
data/lib/wgpu/window.rb CHANGED
@@ -22,6 +22,11 @@ module WGPU
22
22
  SDL_PROP_WINDOW_WAYLAND_DISPLAY_POINTER = "SDL.window.wayland.display"
23
23
  SDL_PROP_WINDOW_WAYLAND_SURFACE_POINTER = "SDL.window.wayland.surface"
24
24
 
25
+ # Creates an SDL window suitable for WebGPU presentation.
26
+ # @param title [String] window title
27
+ # @param width [Integer] initial logical width
28
+ # @param height [Integer] initial logical height
29
+ # @param resizable [Boolean] whether the user may resize the window
25
30
  def initialize(title:, width: 800, height: 600, resizable: true)
26
31
  @width = width
27
32
  @height = height
@@ -35,6 +40,11 @@ module WGPU
35
40
  @window = SDL3::Window.new(title, width, height, flags)
36
41
  end
37
42
 
43
+ # Creates a presentation surface for this native window.
44
+ #
45
+ # @param instance [Instance] WebGPU instance that owns the surface
46
+ # @return [Surface] platform-specific presentation surface
47
+ # @raise [WindowError] if the platform or native window handle is unsupported
38
48
  def create_surface(instance)
39
49
  case platform
40
50
  when :macos
@@ -50,6 +60,9 @@ module WGPU
50
60
  end
51
61
  end
52
62
 
63
+ # Collects currently pending SDL events.
64
+ #
65
+ # @return [Array] events in delivery order
53
66
  def poll_events
54
67
  events = []
55
68
  SDL3::Event.each do |event|
@@ -58,10 +71,17 @@ module WGPU
58
71
  events
59
72
  end
60
73
 
74
+ # Reports whether a quit event is present.
75
+ # @param events [Array] SDL events to inspect
76
+ # @return [Boolean]
61
77
  def should_close?(events)
62
78
  events.any?(&:quit?)
63
79
  end
64
80
 
81
+ # Reports whether a key-down event matches the requested key.
82
+ # @param events [Array] SDL events to inspect
83
+ # @param key [Symbol, Integer] common key name or SDL scancode
84
+ # @return [Boolean]
65
85
  def key_pressed?(events, key)
66
86
  scancode = case key
67
87
  when :escape then SDL3::Raw::SDL_SCANCODE_ESCAPE
@@ -78,12 +98,18 @@ module WGPU
78
98
  end
79
99
  end
80
100
 
101
+ # Returns the drawable size in physical pixels.
102
+ #
103
+ # @return [Array(Integer, Integer)] width and height
81
104
  def drawable_size
82
105
  @window.size_in_pixels
83
106
  rescue
84
107
  [@width, @height]
85
108
  end
86
109
 
110
+ # Destroys platform-specific resources and the SDL window.
111
+ #
112
+ # @return [void]
87
113
  def close
88
114
  if @metal_view && !@metal_view.null?
89
115
  SDL3::Raw.SDL_Metal_DestroyView(@metal_view)
data/sig/wgpu.rbs CHANGED
@@ -5,10 +5,15 @@ module WGPU
5
5
  type flags = enum_value | Array[Symbol]
6
6
  type data = String | Array[Numeric] | untyped
7
7
  type extent_3d = Hash[Symbol, Integer] | Array[Integer]
8
+ type texture_copy = Hash[Symbol, untyped]
9
+ type texture_data_layout = Hash[Symbol, Integer]
10
+ type configuration = Hash[Symbol, untyped]
8
11
 
9
12
  def self.log_level: () -> Symbol
10
13
  def self.log_level=: (enum_value) -> enum_value
11
14
  def self.on_log: () { (Symbol, String) -> void } -> singleton(WGPU)
15
+ def self.debug_leaks: () -> bool
16
+ def self.debug_leaks=: (bool) -> bool
12
17
 
13
18
  class Error < StandardError
14
19
  end
@@ -70,6 +75,9 @@ module WGPU
70
75
  attr_reader type: Symbol
71
76
  attr_reader message: String
72
77
 
78
+ # Creates a typed GPU error with its native category and diagnostic message.
79
+ def initialize: (Symbol type, String message) -> void
80
+ | (type: Symbol, message: String) -> void
73
81
  def self.from_hash: (Hash[Symbol, untyped]? error) -> GPUError?
74
82
  def exception_class: () -> singleton(Error)
75
83
  def raise!: () -> bot
@@ -92,6 +100,7 @@ module WGPU
92
100
  attr_reader label: String?
93
101
  def released?: () -> bool
94
102
  def use: [A] () { (self) -> A } -> A
103
+ # Releases the native handle and unregisters its leak-tracking entry.
95
104
  def release: () -> void
96
105
  end
97
106
 
@@ -124,14 +133,17 @@ module WGPU
124
133
  def self.block_dimensions: (enum_value) -> [Integer, Integer]
125
134
  def self.bytes_per_row: (Integer, enum_value, ?aspect: Symbol) -> Integer
126
135
  def self.aligned_bytes_per_row: (Integer, enum_value, ?aspect: Symbol, ?alignment: Integer) -> Integer
136
+ def self.block_info: (enum_value, ?aspect: Symbol) -> [Integer, Integer, Integer]
127
137
  end
128
138
 
129
139
  class Instance
130
140
  include NativeResource
131
141
  attr_reader handle: untyped
132
142
  def initialize: () -> void
133
- def request_adapter: (**untyped) -> Adapter
134
- def request_adapter_async: (**untyped) -> AsyncTask[Adapter]
143
+ def request_adapter: (?power_preference: enum_value, ?backend: enum_value?, ?feature_level: enum_value, ?force_fallback_adapter: bool, ?compatible_surface: Surface?, ?timeout: Numeric?) -> Adapter
144
+ | (**untyped) -> Adapter
145
+ def request_adapter_async: (?power_preference: enum_value, ?backend: enum_value?, ?feature_level: enum_value, ?force_fallback_adapter: bool, ?compatible_surface: Surface?, ?timeout: Numeric?) -> AsyncTask[Adapter]
146
+ | (**untyped) -> AsyncTask[Adapter]
135
147
  def enumerate_adapters: (?backends: flags?) -> Array[Adapter]
136
148
  def enumerate_adapters_async: (?backends: flags?) -> AsyncTask[Array[Adapter]]
137
149
  def get_canvas_context: (Hash[Symbol, untyped]) -> CanvasContext
@@ -143,8 +155,12 @@ module WGPU
143
155
  attr_reader handle: untyped
144
156
  attr_reader instance: Instance?
145
157
  def self.from_handle: (untyped, ?instance: Instance?) -> Adapter
146
- def request_device: (**untyped) -> Device
147
- def request_device_async: (**untyped) -> AsyncTask[Device]
158
+ def self.request: (Instance, ?power_preference: enum_value, ?backend: enum_value?, ?feature_level: enum_value, ?force_fallback_adapter: bool, ?compatible_surface: Surface?, ?timeout: Numeric?) -> Adapter
159
+ | (Instance, **untyped) -> Adapter
160
+ def request_device: (?label: String?, ?required_features: Array[enum_value], ?required_limits: Hash[Symbol, Integer]?, ?timeout: Numeric?) -> Device
161
+ | (**untyped) -> Device
162
+ def request_device_async: (?label: String?, ?required_features: Array[enum_value], ?required_limits: Hash[Symbol, Integer]?, ?timeout: Numeric?) -> AsyncTask[Device]
163
+ | (**untyped) -> AsyncTask[Device]
148
164
  def info: () -> Hash[Symbol, untyped]
149
165
  def name: () -> String
150
166
  def vendor: () -> String
@@ -161,6 +177,8 @@ module WGPU
161
177
  attr_reader handle: untyped
162
178
  attr_reader queue: Queue
163
179
  attr_reader adapter: Adapter?
180
+ def self.request: (Adapter, ?label: String?, ?required_features: Array[enum_value], ?required_limits: Hash[Symbol, Integer]?, ?timeout: Numeric?) -> Device
181
+ | (Adapter, **untyped) -> Device
164
182
  def adapter_info: () -> Hash[Symbol, untyped]?
165
183
  def create_buffer: (?label: String?, size: Integer, usage: flags, ?mapped_at_creation: bool) -> Buffer
166
184
  def create_buffer_with_data: (?label: String?, data: data, usage: flags, ?type: Symbol) -> Buffer
@@ -183,6 +201,7 @@ module WGPU
183
201
  def poll: (?wait: bool) -> Integer
184
202
  def push_error_scope: (?enum_value) -> void
185
203
  def pop_error_scope: (?timeout: Numeric?) -> Hash[Symbol, untyped]
204
+ def pop_error_scope_async: (?timeout: Numeric?) -> AsyncTask[Hash[Symbol, untyped]]
186
205
  def pop_error_scope_typed: (?timeout: Numeric?) -> GPUError?
187
206
  def with_error_scope: [A] (?enum_value) { () -> A } -> A
188
207
  def on_uncaptured_error: () { (GPUError) -> void } -> self
@@ -197,7 +216,8 @@ module WGPU
197
216
  def write_buffer: (Buffer, Integer, data, ?data_offset: Integer, ?size: Integer?, ?type: Symbol) -> void
198
217
  def write_texture: (**untyped) -> void
199
218
  def read_buffer: (Buffer, ?offset: Integer, ?size: Integer?, ?device: Device?, ?staging: Buffer?) -> String
200
- def read_texture: (**untyped) -> String
219
+ def read_texture: (source: texture_copy, data_layout: texture_data_layout, size: extent_3d, ?device: Device?, ?staging: Buffer?) -> String
220
+ | (**untyped) -> String
201
221
  def on_submitted_work_done: (?device: Device?, ?timeout: Numeric?) -> Symbol
202
222
  def on_submitted_work_done_async: (?device: Device?, ?timeout: Numeric?) -> AsyncTask[Symbol]
203
223
  end
@@ -216,6 +236,12 @@ module WGPU
216
236
  def read_mapped_data: (?offset: Integer, ?size: Integer?) -> String
217
237
  def read_mapped: (?offset: Integer, ?size: Integer?, ?type: Symbol?) -> (String | Array[Numeric])
218
238
  def write_mapped: (data, ?offset: Integer, ?type: Symbol) -> void
239
+ def read_mapped_floats: (?offset: Integer, ?count: Integer?) -> Array[Float]
240
+ def read_mapped_uint32s: (?offset: Integer, ?count: Integer?) -> Array[Integer]
241
+ def read_mapped_int32s: (?offset: Integer, ?count: Integer?) -> Array[Integer]
242
+ def read_mapped_float64s: (?offset: Integer, ?count: Integer?) -> Array[Float]
243
+ def read_mapped_uint16s: (?offset: Integer, ?count: Integer?) -> Array[Integer]
244
+ def read_mapped_uint8s: (?offset: Integer, ?count: Integer?) -> Array[Integer]
219
245
  def read_mapped_values: (?type: Symbol, ?offset: Integer, ?count: Integer?) -> Array[Numeric]
220
246
  def map_state: () -> Symbol
221
247
  def destroy: () -> void
@@ -228,6 +254,14 @@ module WGPU
228
254
  def write_floats: (Array[Numeric]) -> void
229
255
  def read_uint32s: (?Integer?) -> Array[Integer]
230
256
  def write_uint32s: (Array[Integer]) -> void
257
+ def read_int32s: (?Integer?) -> Array[Integer]
258
+ def write_int32s: (Array[Integer]) -> void
259
+ def read_float64s: (?Integer?) -> Array[Float]
260
+ def write_float64s: (Array[Numeric]) -> void
261
+ def read_uint16s: (?Integer?) -> Array[Integer]
262
+ def write_uint16s: (Array[Integer]) -> void
263
+ def read_uint8s: (?Integer?) -> Array[Integer]
264
+ def write_uint8s: (Array[Integer]) -> void
231
265
  def read_bytes: () -> String
232
266
  def write_bytes: (String) -> void
233
267
  end
@@ -236,6 +270,7 @@ module WGPU
236
270
  include NativeResource
237
271
  attr_reader handle: untyped
238
272
  attr_reader surface_status: Symbol?
273
+ def self.from_handle: (untyped, ?surface_status: Symbol?, ?device: Device?) -> Texture
239
274
  def create_view: (**untyped) -> TextureView
240
275
  def width: () -> Integer
241
276
  def height: () -> Integer
@@ -252,6 +287,9 @@ module WGPU
252
287
  class TextureView
253
288
  include NativeResource
254
289
  attr_reader handle: untyped
290
+ attr_reader texture: Texture?
291
+ def self.from_handle: (untyped, ?device: Device?) -> TextureView
292
+ def size: () -> Hash[Symbol, Integer]?
255
293
  end
256
294
 
257
295
  class Sampler
@@ -277,6 +315,7 @@ module WGPU
277
315
  class BindGroupLayout
278
316
  include NativeResource
279
317
  attr_reader handle: untyped
318
+ def self.from_handle: (untyped, ?device: Device?) -> BindGroupLayout
280
319
  end
281
320
 
282
321
  class BindGroup
@@ -315,6 +354,9 @@ module WGPU
315
354
  def resolve_query_set: (**untyped) -> void
316
355
  def clear_buffer: (Buffer, ?offset: Integer, ?size: Integer?) -> void
317
356
  def write_timestamp: (QuerySet, Integer) -> void
357
+ def push_debug_group: (String) -> void
358
+ def pop_debug_group: () -> void
359
+ def insert_debug_marker: (String) -> void
318
360
  def finish: (?label: String?) -> CommandBuffer
319
361
  end
320
362
 
@@ -331,6 +373,9 @@ module WGPU
331
373
  def set_bind_group: (Integer, BindGroup, ?dynamic_offsets: Array[Integer]) -> void
332
374
  def dispatch_workgroups: (Integer, ?Integer, ?Integer) -> void
333
375
  def dispatch_workgroups_indirect: (Buffer, ?offset: Integer) -> void
376
+ def push_debug_group: (String) -> void
377
+ def pop_debug_group: () -> void
378
+ def insert_debug_marker: (String) -> void
334
379
  def end_pass: () -> void
335
380
  def end: () -> void
336
381
  def ended?: () -> bool
@@ -345,6 +390,18 @@ module WGPU
345
390
  def set_index_buffer: (Buffer, enum_value, ?offset: Integer, ?size: Integer?) -> void
346
391
  def draw: (Integer, ?instance_count: Integer, ?first_vertex: Integer, ?first_instance: Integer) -> void
347
392
  def draw_indexed: (Integer, **untyped) -> void
393
+ def set_viewport: (Numeric, Numeric, Numeric, Numeric, ?min_depth: Numeric, ?max_depth: Numeric) -> void
394
+ def set_scissor_rect: (Integer, Integer, Integer, Integer) -> void
395
+ def set_blend_constant: (?r: Numeric, ?g: Numeric, ?b: Numeric, ?a: Numeric) -> void
396
+ def set_stencil_reference: (Integer) -> void
397
+ def draw_indirect: (Buffer, ?offset: Integer) -> void
398
+ def draw_indexed_indirect: (Buffer, ?offset: Integer) -> void
399
+ def execute_bundles: (Array[RenderBundle]) -> void
400
+ def begin_occlusion_query: (Integer) -> void
401
+ def end_occlusion_query: () -> void
402
+ def push_debug_group: (String) -> void
403
+ def pop_debug_group: () -> void
404
+ def insert_debug_marker: (String) -> void
348
405
  def end_pass: () -> void
349
406
  def end: () -> void
350
407
  def ended?: () -> bool
@@ -353,6 +410,17 @@ module WGPU
353
410
  class RenderBundleEncoder
354
411
  include NativeResource
355
412
  attr_reader handle: untyped
413
+ def set_pipeline: (RenderPipeline) -> void
414
+ def set_bind_group: (Integer, BindGroup, ?dynamic_offsets: Array[Integer]?) -> void
415
+ def set_vertex_buffer: (Integer, Buffer, ?offset: Integer, ?size: Integer?) -> void
416
+ def set_index_buffer: (Buffer, ?format: enum_value, ?offset: Integer, ?size: Integer?) -> void
417
+ def draw: (Integer, ?instance_count: Integer, ?first_vertex: Integer, ?first_instance: Integer) -> void
418
+ def draw_indexed: (Integer, ?instance_count: Integer, ?first_index: Integer, ?base_vertex: Integer, ?first_instance: Integer) -> void
419
+ def draw_indirect: (Buffer, ?offset: Integer) -> void
420
+ def draw_indexed_indirect: (Buffer, ?offset: Integer) -> void
421
+ def push_debug_group: (String) -> void
422
+ def pop_debug_group: () -> void
423
+ def insert_debug_marker: (String) -> void
356
424
  def finish: (?label: String?) -> RenderBundle
357
425
  end
358
426
 
@@ -364,15 +432,26 @@ module WGPU
364
432
  class Surface
365
433
  include NativeResource
366
434
  attr_reader handle: untyped
435
+ def self.from_metal_layer: (Instance, untyped) -> Surface
436
+ def self.from_windows_hwnd: (Instance, untyped, untyped) -> Surface
437
+ def self.from_xlib_window: (Instance, untyped, Integer) -> Surface
438
+ def self.from_wayland_surface: (Instance, untyped, untyped) -> Surface
367
439
  def configure: (**untyped) -> void
368
440
  def unconfigure: () -> void
369
441
  def current_texture: () -> Texture
442
+ def get_current_texture: () -> Texture
370
443
  def present: () -> void
444
+ def get_configuration: () -> configuration?
445
+ def get_preferred_format: (Adapter) -> Symbol
371
446
  def capabilities: (Adapter) -> Hash[Symbol, untyped]
372
447
  end
373
448
 
374
449
  class CanvasContext
375
450
  include NativeResource
451
+ attr_reader physical_size: [Integer, Integer]
452
+ def set_physical_size: (Integer, Integer) -> [Integer, Integer]
453
+ def get_preferred_format: (Adapter) -> Symbol
454
+ def get_configuration: () -> configuration?
376
455
  def configure: (**untyped) -> void
377
456
  def unconfigure: () -> void
378
457
  def get_current_texture: () -> Texture
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wgpu
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yudai Takada
@@ -94,6 +94,7 @@ files:
94
94
  - lib/wgpu/native/distribution.rb
95
95
  - lib/wgpu/native/enum_helper.rb
96
96
  - lib/wgpu/native/enums.rb
97
+ - lib/wgpu/native/fixtures/webgpu-v27.0.4.0-enums.h
97
98
  - lib/wgpu/native/functions.rb
98
99
  - lib/wgpu/native/installer.rb
99
100
  - lib/wgpu/native/loader.rb
@@ -122,6 +123,7 @@ metadata:
122
123
  homepage_uri: https://github.com/ydah/wgpu-ruby
123
124
  source_code_uri: https://github.com/ydah/wgpu-ruby/tree/main
124
125
  changelog_uri: https://github.com/ydah/wgpu-ruby/blob/main/CHANGELOG.md
126
+ documentation_uri: https://www.rubydoc.info/gems/wgpu
125
127
  rdoc_options: []
126
128
  require_paths:
127
129
  - lib