Class: WGPU::ComputePass
- Inherits:
-
Object
- Object
- WGPU::ComputePass
- Includes:
- NativeResource
- Defined in:
- lib/wgpu/commands/compute_pass.rb,
sig/wgpu.rbs
Constant Summary
Constants included from NativeResource
NativeResource::GUARDED_METHOD_EXEMPTIONS
Instance Attribute Summary collapse
-
#handle ⇒ Object
readonly
Returns the value of attribute handle.
Attributes included from NativeResource
Instance Method Summary collapse
-
#dispatch_workgroups(x, y = 1, z = 1) ⇒ void
Dispatches a three-dimensional compute workgroup grid.
-
#dispatch_workgroups_indirect(buffer, offset: 0) ⇒ void
Dispatches workgroups using arguments read from a buffer.
-
#end ⇒ void
Ends the pass.
-
#end_pass ⇒ void
Ends the pass if it has not already ended.
-
#ended? ⇒ Boolean
Reports whether the pass has ended.
-
#initialize(encoder, label: nil, timestamp_writes: nil) ⇒ ComputePass
constructor
Begins a compute pass owned by the command encoder.
-
#insert_debug_marker(label) ⇒ void
Inserts a labeled point in GPU debugging tools.
-
#pop_debug_group ⇒ void
Ends the most recently pushed debug group.
-
#push_debug_group(label) ⇒ void
Starts a labeled group in GPU debugging tools.
-
#release ⇒ void
Releases the native compute pass encoder handle.
-
#set_bind_group(index, bind_group, dynamic_offsets: []) ⇒ void
Binds a resource group for subsequent dispatches.
-
#set_pipeline(pipeline) ⇒ void
Selects the compute pipeline used by subsequent dispatches.
Methods included from NativeResource
included, #inspect, #released?, #use
Constructor Details
#initialize(encoder, label: nil, timestamp_writes: nil) ⇒ ComputePass
Begins a compute pass owned by the command encoder.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/wgpu/commands/compute_pass.rb', line 12 def initialize(encoder, label: nil, timestamp_writes: nil) @encoder = encoder @ended = false desc = Native::ComputePassDescriptor.new desc[:next_in_chain] = nil if label label_ptr = FFI::MemoryPointer.from_string(label) desc[:label][:data] = label_ptr desc[:label][:length] = label.bytesize else desc[:label][:data] = nil desc[:label][:length] = 0 end @timestamp_writes = nil if @timestamp_writes = Native::ComputePassTimestampWrites.new @timestamp_writes[:query_set] = .fetch(:query_set).handle @timestamp_writes[:beginning_of_pass_write_index] = [:beginning_of_pass_write_index] || 0xFFFFFFFF @timestamp_writes[:end_of_pass_write_index] = [:end_of_pass_write_index] || 0xFFFFFFFF desc[:timestamp_writes] = @timestamp_writes.to_ptr else desc[:timestamp_writes] = nil end @handle = Native.wgpuCommandEncoderBeginComputePass(encoder.handle, desc) raise CommandError, "Failed to begin compute pass" if @handle.null? end |
Instance Attribute Details
#handle ⇒ Object (readonly)
Returns the value of attribute handle.
5 6 7 |
# File 'lib/wgpu/commands/compute_pass.rb', line 5 def handle @handle end |
Instance Method Details
#dispatch_workgroups(x, y = 1, z = 1) ⇒ void
This method returns an undefined value.
Dispatches a three-dimensional compute workgroup grid.
67 68 69 |
# File 'lib/wgpu/commands/compute_pass.rb', line 67 def dispatch_workgroups(x, y = 1, z = 1) Native.wgpuComputePassEncoderDispatchWorkgroups(@handle, x, y, z) end |
#dispatch_workgroups_indirect(buffer, offset: 0) ⇒ void
This method returns an undefined value.
Dispatches workgroups using arguments read from a buffer.
75 76 77 |
# File 'lib/wgpu/commands/compute_pass.rb', line 75 def dispatch_workgroups_indirect(buffer, offset: 0) Native.wgpuComputePassEncoderDispatchWorkgroupsIndirect(@handle, buffer.handle, offset) end |
#end ⇒ void
This method returns an undefined value.
Ends the pass.
122 123 124 |
# File 'lib/wgpu/commands/compute_pass.rb', line 122 def end end_pass end |
#end_pass ⇒ void
This method returns an undefined value.
Ends the pass if it has not already ended.
112 113 114 115 116 117 118 |
# File 'lib/wgpu/commands/compute_pass.rb', line 112 def end_pass return if @ended Native.wgpuComputePassEncoderEnd(@handle) @ended = true @encoder.send(:pass_ended, self) end |
#ended? ⇒ Boolean
Reports whether the pass has ended.
128 129 130 |
# File 'lib/wgpu/commands/compute_pass.rb', line 128 def ended? @ended end |
#insert_debug_marker(label) ⇒ void
This method returns an undefined value.
Inserts a labeled point in GPU debugging tools.
102 103 104 105 106 107 108 |
# File 'lib/wgpu/commands/compute_pass.rb', line 102 def insert_debug_marker(label) label_view = Native::StringView.new label_ptr = FFI::MemoryPointer.from_string(label) label_view[:data] = label_ptr label_view[:length] = label.bytesize Native.wgpuComputePassEncoderInsertDebugMarker(@handle, label_view) end |
#pop_debug_group ⇒ void
This method returns an undefined value.
Ends the most recently pushed debug group.
94 95 96 |
# File 'lib/wgpu/commands/compute_pass.rb', line 94 def pop_debug_group Native.wgpuComputePassEncoderPopDebugGroup(@handle) end |
#push_debug_group(label) ⇒ void
This method returns an undefined value.
Starts a labeled group in GPU debugging tools.
83 84 85 86 87 88 89 |
# File 'lib/wgpu/commands/compute_pass.rb', line 83 def push_debug_group(label) label_view = Native::StringView.new label_ptr = FFI::MemoryPointer.from_string(label) label_view[:data] = label_ptr label_view[:length] = label.bytesize Native.wgpuComputePassEncoderPushDebugGroup(@handle, label_view) end |
#release ⇒ void
This method returns an undefined value.
Releases the native compute pass encoder handle.
Calling this method more than once has no effect.
136 137 138 139 140 |
# File 'lib/wgpu/commands/compute_pass.rb', line 136 def release return if @handle.null? Native.wgpuComputePassEncoderRelease(@handle) @handle = FFI::Pointer::NULL end |
#set_bind_group(index, bind_group, dynamic_offsets: []) ⇒ void
This method returns an undefined value.
Binds a resource group for subsequent dispatches.
52 53 54 55 56 57 58 59 60 |
# File 'lib/wgpu/commands/compute_pass.rb', line 52 def set_bind_group(index, bind_group, dynamic_offsets: []) if dynamic_offsets.empty? Native.wgpuComputePassEncoderSetBindGroup(@handle, index, bind_group.handle, 0, nil) else offsets_ptr = FFI::MemoryPointer.new(:uint32, dynamic_offsets.size) offsets_ptr.write_array_of_uint32(dynamic_offsets) Native.wgpuComputePassEncoderSetBindGroup(@handle, index, bind_group.handle, dynamic_offsets.size, offsets_ptr) end end |
#set_pipeline(pipeline) ⇒ void
This method returns an undefined value.
Selects the compute pipeline used by subsequent dispatches.
43 44 45 |
# File 'lib/wgpu/commands/compute_pass.rb', line 43 def set_pipeline(pipeline) Native.wgpuComputePassEncoderSetPipeline(@handle, pipeline.handle) end |