Class: WGPU::QuerySet
- Inherits:
-
Object
- Object
- WGPU::QuerySet
- Includes:
- NativeResource
- Defined in:
- lib/wgpu/resources/query_set.rb,
sig/wgpu.rbs
Constant Summary
Constants included from NativeResource
NativeResource::GUARDED_METHOD_EXEMPTIONS
Instance Attribute Summary collapse
-
#count ⇒ Integer
readonly
Returns the value of attribute count.
-
#handle ⇒ Object
readonly
Returns the value of attribute handle.
-
#type ⇒ Symbol
readonly
Returns the value of attribute type.
Attributes included from NativeResource
Instance Method Summary collapse
-
#destroy ⇒ void
Destroys the query storage once.
-
#initialize(device, label: nil, type:, count:) ⇒ QuerySet
constructor
Creates a set of GPU queries.
-
#release ⇒ void
Releases the native query set handle.
Methods included from NativeResource
included, #inspect, #released?, #use
Constructor Details
#initialize(device, label: nil, type:, count:) ⇒ QuerySet
Creates a set of GPU queries.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/wgpu/resources/query_set.rb', line 12 def initialize(device, label: nil, type:, count:) @device = device @count = Integer(count) type_value = Native::EnumHelper.coerce(Native::QueryType, type, name: "query type") @type = Native::QueryType[type_value] @destroyed = false desc = Native::QuerySetDescriptor.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 desc[:type] = type_value desc[:count] = @count @handle = Native.wgpuDeviceCreateQuerySet(device.handle, desc) raise ResourceError, "Failed to create query set" if @handle.null? end |
Instance Attribute Details
#count ⇒ Integer (readonly)
Returns the value of attribute count.
5 6 7 |
# File 'lib/wgpu/resources/query_set.rb', line 5 def count @count end |
#handle ⇒ Object (readonly)
Returns the value of attribute handle.
5 6 7 |
# File 'lib/wgpu/resources/query_set.rb', line 5 def handle @handle end |
#type ⇒ Symbol (readonly)
Returns the value of attribute type.
5 6 7 |
# File 'lib/wgpu/resources/query_set.rb', line 5 def type @type end |
Instance Method Details
#destroy ⇒ void
This method returns an undefined value.
Destroys the query storage once.
38 39 40 41 42 43 |
# File 'lib/wgpu/resources/query_set.rb', line 38 def destroy return if @destroyed Native.wgpuQuerySetDestroy(@handle) @destroyed = true end |
#release ⇒ void
This method returns an undefined value.
Releases the native query set handle.
A query set destroyed through #destroy is only marked released because the pinned native implementation cannot safely release it afterward.
50 51 52 53 54 55 56 57 |
# File 'lib/wgpu/resources/query_set.rb', line 50 def release return if @handle.null? # Pinned wgpu-native v27 removes a destroyed query set from its storage; # calling Release afterward aborts inside Rust instead of being harmless. Native.wgpuQuerySetRelease(@handle) unless @destroyed @handle = FFI::Pointer::NULL end |