wgpu 1.2.0 → 1.2.2
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +66 -0
- data/README.md +18 -2
- data/docs/README.md +2 -2
- data/docs/api_coverage.md +23 -15
- data/docs/async.md +13 -1
- data/docs/command_encoding.md +25 -0
- data/docs/errors.md +13 -0
- data/docs/getting_started_compute.md +1 -0
- data/docs/getting_started_rendering.md +5 -0
- data/docs/pipeline_descriptors.md +7 -2
- data/docs/releasing.md +11 -1
- data/docs/resource_lifetime.md +25 -2
- data/docs/texture_readback.md +27 -0
- data/docs/troubleshooting.md +5 -0
- data/docs/upgrading_wgpu_native.md +16 -5
- data/lib/wgpu/async_task.rb +19 -0
- data/lib/wgpu/commands/command_buffer.rb +14 -1
- data/lib/wgpu/commands/command_encoder.rb +82 -27
- data/lib/wgpu/commands/compute_pass.rb +49 -6
- data/lib/wgpu/commands/render_bundle.rb +9 -1
- data/lib/wgpu/commands/render_bundle_encoder.rb +63 -9
- data/lib/wgpu/commands/render_pass.rb +116 -14
- data/lib/wgpu/core/adapter.rb +95 -13
- data/lib/wgpu/core/async_waiter.rb +30 -4
- data/lib/wgpu/core/canvas_context.rb +37 -2
- data/lib/wgpu/core/device.rb +377 -70
- data/lib/wgpu/core/instance.rb +20 -0
- data/lib/wgpu/core/queue.rb +143 -43
- data/lib/wgpu/core/surface.rb +55 -7
- data/lib/wgpu/data_types.rb +16 -0
- data/lib/wgpu/descriptor_helpers.rb +87 -0
- data/lib/wgpu/error.rb +15 -0
- data/lib/wgpu/native/abi_verifier.rb +37 -3
- data/lib/wgpu/native/callbacks.rb +6 -0
- data/lib/wgpu/native/capabilities.rb +16 -2
- data/lib/wgpu/native/distribution.rb +63 -0
- data/lib/wgpu/native/enum_helper.rb +17 -0
- data/lib/wgpu/native/enums.rb +8 -0
- data/lib/wgpu/native/fixtures/webgpu-v27.0.4.0-enums.h +848 -0
- data/lib/wgpu/native/functions.rb +14 -0
- data/lib/wgpu/native/installer.rb +55 -18
- data/lib/wgpu/native/loader.rb +22 -0
- data/lib/wgpu/native/structs.rb +18 -1
- data/lib/wgpu/native_resource.rb +190 -3
- data/lib/wgpu/pipeline/bind_group.rb +16 -7
- data/lib/wgpu/pipeline/bind_group_layout.rb +20 -7
- data/lib/wgpu/pipeline/compute_pipeline.rb +25 -37
- data/lib/wgpu/pipeline/pipeline_layout.rb +12 -4
- data/lib/wgpu/pipeline/render_pipeline.rb +33 -48
- data/lib/wgpu/pipeline/shader_module.rb +57 -32
- data/lib/wgpu/resources/buffer.rb +330 -59
- data/lib/wgpu/resources/query_set.rb +13 -1
- data/lib/wgpu/resources/sampler.rb +10 -3
- data/lib/wgpu/resources/texture.rb +49 -12
- data/lib/wgpu/resources/texture_view.rb +25 -5
- data/lib/wgpu/texture_format.rb +14 -0
- data/lib/wgpu/version.rb +1 -1
- data/lib/wgpu/window.rb +26 -0
- data/sig/wgpu.rbs +85 -5
- metadata +12 -4
|
@@ -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
|
|
|
@@ -19,9 +25,9 @@ module WGPU
|
|
|
19
25
|
)
|
|
20
26
|
@descriptor_keepalive = keepalive
|
|
21
27
|
|
|
22
|
-
device.
|
|
23
|
-
|
|
24
|
-
|
|
28
|
+
error = device.send(:capture_error_scope) do
|
|
29
|
+
@handle = Native.wgpuDeviceCreateTexture(NativeResource.checked_handle(device, expected_class: Device), desc)
|
|
30
|
+
end
|
|
25
31
|
@descriptor_keepalive = nil
|
|
26
32
|
|
|
27
33
|
if @handle.null? || (error[:type] && error[:type] != :no_error)
|
|
@@ -30,15 +36,23 @@ module WGPU
|
|
|
30
36
|
end
|
|
31
37
|
end
|
|
32
38
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
|
|
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)
|
|
@@ -117,9 +156,7 @@ module WGPU
|
|
|
117
156
|
DescriptorHelpers.set_label(desc, label, keepalive:)
|
|
118
157
|
desc[:usage] = normalize_usage(usage)
|
|
119
158
|
desc[:dimension] = Native::EnumHelper.coerce(Native::TextureDimension, dimension, name: "texture dimension")
|
|
120
|
-
desc[:size]
|
|
121
|
-
desc[:size][:height] = size[:height] || size[1] || 1
|
|
122
|
-
desc[:size][:depth_or_array_layers] = size[:depth_or_array_layers] || size[2] || 1
|
|
159
|
+
desc[:size] = DescriptorHelpers.extent_3d(size)
|
|
123
160
|
desc[:format] = Native::EnumHelper.coerce(Native::TextureFormat, format, name: "texture format")
|
|
124
161
|
desc[:mip_level_count] = mip_level_count
|
|
125
162
|
desc[:sample_count] = sample_count
|
|
@@ -4,7 +4,10 @@ module WGPU
|
|
|
4
4
|
class TextureView
|
|
5
5
|
attr_reader :handle, :texture
|
|
6
6
|
|
|
7
|
-
|
|
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
|
-
@handle = Native.wgpuTextureCreateView(texture
|
|
44
|
+
@handle = Native.wgpuTextureCreateView(NativeResource.checked_handle(texture, expected_class: Texture), desc)
|
|
37
45
|
raise ResourceError, "Failed to create texture view" if @handle.null?
|
|
38
46
|
end
|
|
39
47
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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)
|
data/lib/wgpu/texture_format.rb
CHANGED
|
@@ -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
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: (
|
|
134
|
-
|
|
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
|
|
147
|
-
|
|
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: (
|
|
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,18 +236,33 @@ 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
|
|
222
248
|
end
|
|
223
249
|
|
|
224
250
|
class BufferMappedRange
|
|
251
|
+
def initialize: (untyped pointer, Integer size, buffer: Buffer, generation: Integer) -> void
|
|
225
252
|
def read: (?type: Symbol, ?count: Integer?) -> Array[Numeric]
|
|
226
253
|
def write: (data, ?type: Symbol) -> void
|
|
227
254
|
def read_floats: (?Integer?) -> Array[Float]
|
|
228
255
|
def write_floats: (Array[Numeric]) -> void
|
|
229
256
|
def read_uint32s: (?Integer?) -> Array[Integer]
|
|
230
257
|
def write_uint32s: (Array[Integer]) -> void
|
|
258
|
+
def read_int32s: (?Integer?) -> Array[Integer]
|
|
259
|
+
def write_int32s: (Array[Integer]) -> void
|
|
260
|
+
def read_float64s: (?Integer?) -> Array[Float]
|
|
261
|
+
def write_float64s: (Array[Numeric]) -> void
|
|
262
|
+
def read_uint16s: (?Integer?) -> Array[Integer]
|
|
263
|
+
def write_uint16s: (Array[Integer]) -> void
|
|
264
|
+
def read_uint8s: (?Integer?) -> Array[Integer]
|
|
265
|
+
def write_uint8s: (Array[Integer]) -> void
|
|
231
266
|
def read_bytes: () -> String
|
|
232
267
|
def write_bytes: (String) -> void
|
|
233
268
|
end
|
|
@@ -236,6 +271,7 @@ module WGPU
|
|
|
236
271
|
include NativeResource
|
|
237
272
|
attr_reader handle: untyped
|
|
238
273
|
attr_reader surface_status: Symbol?
|
|
274
|
+
def self.from_handle: (untyped, ?surface_status: Symbol?, ?device: Device?) -> Texture
|
|
239
275
|
def create_view: (**untyped) -> TextureView
|
|
240
276
|
def width: () -> Integer
|
|
241
277
|
def height: () -> Integer
|
|
@@ -252,6 +288,9 @@ module WGPU
|
|
|
252
288
|
class TextureView
|
|
253
289
|
include NativeResource
|
|
254
290
|
attr_reader handle: untyped
|
|
291
|
+
attr_reader texture: Texture?
|
|
292
|
+
def self.from_handle: (untyped, ?device: Device?) -> TextureView
|
|
293
|
+
def size: () -> Hash[Symbol, Integer]?
|
|
255
294
|
end
|
|
256
295
|
|
|
257
296
|
class Sampler
|
|
@@ -277,6 +316,7 @@ module WGPU
|
|
|
277
316
|
class BindGroupLayout
|
|
278
317
|
include NativeResource
|
|
279
318
|
attr_reader handle: untyped
|
|
319
|
+
def self.from_handle: (untyped, ?device: Device?) -> BindGroupLayout
|
|
280
320
|
end
|
|
281
321
|
|
|
282
322
|
class BindGroup
|
|
@@ -315,6 +355,9 @@ module WGPU
|
|
|
315
355
|
def resolve_query_set: (**untyped) -> void
|
|
316
356
|
def clear_buffer: (Buffer, ?offset: Integer, ?size: Integer?) -> void
|
|
317
357
|
def write_timestamp: (QuerySet, Integer) -> void
|
|
358
|
+
def push_debug_group: (String) -> void
|
|
359
|
+
def pop_debug_group: () -> void
|
|
360
|
+
def insert_debug_marker: (String) -> void
|
|
318
361
|
def finish: (?label: String?) -> CommandBuffer
|
|
319
362
|
end
|
|
320
363
|
|
|
@@ -331,6 +374,9 @@ module WGPU
|
|
|
331
374
|
def set_bind_group: (Integer, BindGroup, ?dynamic_offsets: Array[Integer]) -> void
|
|
332
375
|
def dispatch_workgroups: (Integer, ?Integer, ?Integer) -> void
|
|
333
376
|
def dispatch_workgroups_indirect: (Buffer, ?offset: Integer) -> void
|
|
377
|
+
def push_debug_group: (String) -> void
|
|
378
|
+
def pop_debug_group: () -> void
|
|
379
|
+
def insert_debug_marker: (String) -> void
|
|
334
380
|
def end_pass: () -> void
|
|
335
381
|
def end: () -> void
|
|
336
382
|
def ended?: () -> bool
|
|
@@ -345,6 +391,18 @@ module WGPU
|
|
|
345
391
|
def set_index_buffer: (Buffer, enum_value, ?offset: Integer, ?size: Integer?) -> void
|
|
346
392
|
def draw: (Integer, ?instance_count: Integer, ?first_vertex: Integer, ?first_instance: Integer) -> void
|
|
347
393
|
def draw_indexed: (Integer, **untyped) -> void
|
|
394
|
+
def set_viewport: (Numeric, Numeric, Numeric, Numeric, ?min_depth: Numeric, ?max_depth: Numeric) -> void
|
|
395
|
+
def set_scissor_rect: (Integer, Integer, Integer, Integer) -> void
|
|
396
|
+
def set_blend_constant: (?r: Numeric, ?g: Numeric, ?b: Numeric, ?a: Numeric) -> void
|
|
397
|
+
def set_stencil_reference: (Integer) -> void
|
|
398
|
+
def draw_indirect: (Buffer, ?offset: Integer) -> void
|
|
399
|
+
def draw_indexed_indirect: (Buffer, ?offset: Integer) -> void
|
|
400
|
+
def execute_bundles: (Array[RenderBundle]) -> void
|
|
401
|
+
def begin_occlusion_query: (Integer) -> void
|
|
402
|
+
def end_occlusion_query: () -> void
|
|
403
|
+
def push_debug_group: (String) -> void
|
|
404
|
+
def pop_debug_group: () -> void
|
|
405
|
+
def insert_debug_marker: (String) -> void
|
|
348
406
|
def end_pass: () -> void
|
|
349
407
|
def end: () -> void
|
|
350
408
|
def ended?: () -> bool
|
|
@@ -353,6 +411,17 @@ module WGPU
|
|
|
353
411
|
class RenderBundleEncoder
|
|
354
412
|
include NativeResource
|
|
355
413
|
attr_reader handle: untyped
|
|
414
|
+
def set_pipeline: (RenderPipeline) -> void
|
|
415
|
+
def set_bind_group: (Integer, BindGroup, ?dynamic_offsets: Array[Integer]?) -> void
|
|
416
|
+
def set_vertex_buffer: (Integer, Buffer, ?offset: Integer, ?size: Integer?) -> void
|
|
417
|
+
def set_index_buffer: (Buffer, ?format: enum_value, ?offset: Integer, ?size: Integer?) -> void
|
|
418
|
+
def draw: (Integer, ?instance_count: Integer, ?first_vertex: Integer, ?first_instance: Integer) -> void
|
|
419
|
+
def draw_indexed: (Integer, ?instance_count: Integer, ?first_index: Integer, ?base_vertex: Integer, ?first_instance: Integer) -> void
|
|
420
|
+
def draw_indirect: (Buffer, ?offset: Integer) -> void
|
|
421
|
+
def draw_indexed_indirect: (Buffer, ?offset: Integer) -> void
|
|
422
|
+
def push_debug_group: (String) -> void
|
|
423
|
+
def pop_debug_group: () -> void
|
|
424
|
+
def insert_debug_marker: (String) -> void
|
|
356
425
|
def finish: (?label: String?) -> RenderBundle
|
|
357
426
|
end
|
|
358
427
|
|
|
@@ -364,15 +433,26 @@ module WGPU
|
|
|
364
433
|
class Surface
|
|
365
434
|
include NativeResource
|
|
366
435
|
attr_reader handle: untyped
|
|
436
|
+
def self.from_metal_layer: (Instance, untyped) -> Surface
|
|
437
|
+
def self.from_windows_hwnd: (Instance, untyped, untyped) -> Surface
|
|
438
|
+
def self.from_xlib_window: (Instance, untyped, Integer) -> Surface
|
|
439
|
+
def self.from_wayland_surface: (Instance, untyped, untyped) -> Surface
|
|
367
440
|
def configure: (**untyped) -> void
|
|
368
441
|
def unconfigure: () -> void
|
|
369
442
|
def current_texture: () -> Texture
|
|
443
|
+
def get_current_texture: () -> Texture
|
|
370
444
|
def present: () -> void
|
|
445
|
+
def get_configuration: () -> configuration?
|
|
446
|
+
def get_preferred_format: (Adapter) -> Symbol
|
|
371
447
|
def capabilities: (Adapter) -> Hash[Symbol, untyped]
|
|
372
448
|
end
|
|
373
449
|
|
|
374
450
|
class CanvasContext
|
|
375
451
|
include NativeResource
|
|
452
|
+
attr_reader physical_size: [Integer, Integer]
|
|
453
|
+
def set_physical_size: (Integer, Integer) -> [Integer, Integer]
|
|
454
|
+
def get_preferred_format: (Adapter) -> Symbol
|
|
455
|
+
def get_configuration: () -> configuration?
|
|
376
456
|
def configure: (**untyped) -> void
|
|
377
457
|
def unconfigure: () -> void
|
|
378
458
|
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.
|
|
4
|
+
version: 1.2.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Yudai Takada
|
|
@@ -27,16 +27,22 @@ dependencies:
|
|
|
27
27
|
name: rubyzip
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
29
29
|
requirements:
|
|
30
|
-
- - "
|
|
30
|
+
- - ">="
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
32
|
version: '2.3'
|
|
33
|
+
- - "<"
|
|
34
|
+
- !ruby/object:Gem::Version
|
|
35
|
+
version: '4.0'
|
|
33
36
|
type: :runtime
|
|
34
37
|
prerelease: false
|
|
35
38
|
version_requirements: !ruby/object:Gem::Requirement
|
|
36
39
|
requirements:
|
|
37
|
-
- - "
|
|
40
|
+
- - ">="
|
|
38
41
|
- !ruby/object:Gem::Version
|
|
39
42
|
version: '2.3'
|
|
43
|
+
- - "<"
|
|
44
|
+
- !ruby/object:Gem::Version
|
|
45
|
+
version: '4.0'
|
|
40
46
|
description: Ruby bindings for the WebGPU API, providing GPU compute and graphics
|
|
41
47
|
capabilities through the wgpu-native library.
|
|
42
48
|
email:
|
|
@@ -94,6 +100,7 @@ files:
|
|
|
94
100
|
- lib/wgpu/native/distribution.rb
|
|
95
101
|
- lib/wgpu/native/enum_helper.rb
|
|
96
102
|
- lib/wgpu/native/enums.rb
|
|
103
|
+
- lib/wgpu/native/fixtures/webgpu-v27.0.4.0-enums.h
|
|
97
104
|
- lib/wgpu/native/functions.rb
|
|
98
105
|
- lib/wgpu/native/installer.rb
|
|
99
106
|
- lib/wgpu/native/loader.rb
|
|
@@ -122,6 +129,7 @@ metadata:
|
|
|
122
129
|
homepage_uri: https://github.com/ydah/wgpu-ruby
|
|
123
130
|
source_code_uri: https://github.com/ydah/wgpu-ruby/tree/main
|
|
124
131
|
changelog_uri: https://github.com/ydah/wgpu-ruby/blob/main/CHANGELOG.md
|
|
132
|
+
documentation_uri: https://www.rubydoc.info/gems/wgpu
|
|
125
133
|
rdoc_options: []
|
|
126
134
|
require_paths:
|
|
127
135
|
- lib
|
|
@@ -136,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
136
144
|
- !ruby/object:Gem::Version
|
|
137
145
|
version: '0'
|
|
138
146
|
requirements: []
|
|
139
|
-
rubygems_version: 4.0.
|
|
147
|
+
rubygems_version: 4.0.19
|
|
140
148
|
specification_version: 4
|
|
141
149
|
summary: Ruby bindings for WebGPU via wgpu-native
|
|
142
150
|
test_files: []
|