Class: WGPU::Native::AbiVerifier
- Inherits:
-
Object
- Object
- WGPU::Native::AbiVerifier
- Defined in:
- lib/wgpu/native/abi_verifier.rb
Constant Summary collapse
- FORCE32_KEY =
"force32"- EXTENSION_ENTRIES =
{ "SType" => %w[invalid shadersourceglsl], "FeatureName" => %w[ pushconstants textureadapterspecificformatfeatures multidrawindirectcount vertexwritablestorage texturebindingarray sampledtextureandstoragebufferarraynonuniformindexing pipelinestatisticsquery storageresourcebindingarray partiallyboundbindingarray textureformat16bitnorm texturecompressionastchdr mappableprimarybuffers bufferbindingarray uniformbufferandstoragetexturearraynonuniformindexing polygonmodeline polygonmodepoint conservativerasterization spirvshaderpassthrough vertexattribute64bit textureformatnv12 rayquery shaderf64 shaderi16 shaderprimitiveindex shaderearlydepthtest subgroup subgroupvertex subgroupbarrier timestampqueryinsideencoders timestampqueryinsidepasses shaderint64 ] }.freeze
Class Method Summary collapse
-
.default_header_path ⇒ String
Locates the pinned header used for ABI verification.
-
.fixture_header_path ⇒ String
Returns the repository's pinned enum fixture path.
Instance Method Summary collapse
-
#enum_differences ⇒ Array<String>
Compares Ruby enum values with the pinned native header.
-
#initialize(header_path: nil, native: Native) ⇒ AbiVerifier
constructor
Creates a verifier for a header and native binding.
-
#verify! ⇒ true
Verifies the runtime version and Ruby enum ABI against the header.
Constructor Details
#initialize(header_path: nil, native: Native) ⇒ AbiVerifier
Creates a verifier for a header and native binding.
28 29 30 31 |
# File 'lib/wgpu/native/abi_verifier.rb', line 28 def initialize(header_path: nil, native: Native) @header_path = header_path || self.class.default_header_path @native = native end |
Class Method Details
.default_header_path ⇒ String
Locates the pinned header used for ABI verification.
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/wgpu/native/abi_verifier.rb', line 61 def self.default_header_path override = ENV["WGPU_HEADER_PATH"] return File.(override) if override && !override.empty? fixture = fixture_header_path return fixture if File.file?(fixture) candidates = Distribution.cache_directories.map do |cache_dir| File.join(cache_dir, "include", "webgpu", "webgpu.h") end path = candidates.find { |candidate| File.file?(candidate) } return path if path raise WGPU::Error, <<~MSG.chomp Pinned #{Distribution::VERSION} webgpu.h was not found. Restore the repository ABI fixture, run `bundle exec rake wgpu:install`, or set WGPU_HEADER_PATH. Searched: #{([fixture] + candidates).join(", ")} MSG end |
.fixture_header_path ⇒ String
Returns the repository's pinned enum fixture path.
85 86 87 |
# File 'lib/wgpu/native/abi_verifier.rb', line 85 def self.fixture_header_path File.("fixtures/webgpu-#{Distribution::VERSION}-enums.h", __dir__) end |
Instance Method Details
#enum_differences ⇒ Array<String>
Compares Ruby enum values with the pinned native header.
48 49 50 51 52 53 54 55 56 |
# File 'lib/wgpu/native/abi_verifier.rb', line 48 def enum_differences header_enums = parse_header ruby_enums.filter_map do |name, mapping| header_mapping = header_enums[name] next unless header_mapping compare_enum(name, ruby_mapping(mapping), header_mapping) end end |
#verify! ⇒ true
Verifies the runtime version and Ruby enum ABI against the header.
36 37 38 39 40 41 42 43 |
# File 'lib/wgpu/native/abi_verifier.rb', line 36 def verify! differences = enum_differences version_difference = native_version_difference differences.unshift(version_difference) if version_difference return true if differences.empty? raise WGPU::Error, "wgpu-native ABI differences:\n#{differences.join("\n")}" end |