{"_id":"@bun-win32/directml","_rev":"4-e0bf1b8b83cbe41edfe8fb112211ec39","name":"@bun-win32/directml","dist-tags":{"latest":"2.0.1"},"versions":{"1.0.0":{"name":"@bun-win32/directml","version":"1.0.0","keywords":["bun","ffi","win32","windows","directml","bindings","typescript","dll"],"author":"Stev Peifer <stev@bell.net>","license":"MIT","_id":"@bun-win32/directml@1.0.0","maintainers":[{"name":"obscuritysrl","email":"stev@bell.net"}],"homepage":"https://github.com/ObscuritySRL/bun-win32#readme","bugs":{"url":"https://github.com/ObscuritySRL/bun-win32/issues"},"dist":{"shasum":"aca401013b8c4bd40bb71c783311e9a0b4e2c1b1","tarball":"https://registry.npmjs.org/@bun-win32/directml/-/directml-1.0.0.tgz","fileCount":6,"integrity":"sha512-MEEgISuTFwkajs12h/IOleX00ml9xRnh/GKh8nOdiNswJAqY0XLGS6kNQcuBzF5MwRLoLXQ2jUoRhAwtOFG8AA==","signatures":[{"sig":"MEQCIEA0CR2kWhliVmauSivRSGEQBvPeGEJsVhZWjKkH5j6XAiAd4tkBh+pV/1AbPrpVtSWlF4wIhKxky6V9rxOV5P4Z0Q==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":10111},"main":"./index.ts","type":"module","module":"index.ts","shasum":"aca401013b8c4bd40bb71c783311e9a0b4e2c1b1","engines":{"bun":">=1.1.0"},"exports":{".":"./index.ts"},"private":false,"scripts":{"example:directml-device-report":"bun ./example/directml-device-report.ts","example:directml-capability-observatory":"bun ./example/directml-capability-observatory.ts"},"_npmUser":{"name":"obscuritysrl","email":"stev@bell.net"},"_integrity":"sha512-MEEgISuTFwkajs12h/IOleX00ml9xRnh/GKh8nOdiNswJAqY0XLGS6kNQcuBzF5MwRLoLXQ2jUoRhAwtOFG8AA==","repository":{"url":"git://github.com/ObscuritySRL/bun-win32.git","type":"git","directory":"packages/directml"},"_npmVersion":"10.8.3","description":"Zero-dependency, zero-overhead Win32 DIRECTML bindings for Bun (FFI) on Windows.","directories":{},"sideEffects":false,"_nodeVersion":"24.3.0","dependencies":{"@bun-win32/core":"1.1.2"},"_hasShrinkwrap":false,"devDependencies":{"@types/bun":"latest","@bun-win32/d3d12":"1.0.0"},"peerDependencies":{"typescript":"^5"},"_npmOperationalInternal":{"tmp":"tmp/directml_1.0.0_1780539749380_0.06562635678174633","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@bun-win32/directml","version":"1.0.1","keywords":["bun","ffi","win32","windows","directml","bindings","typescript","dll"],"author":"Stev Peifer <stev.p@outlook.com>","license":"MIT","_id":"@bun-win32/directml@1.0.1","maintainers":[{"name":"obscuritysrl","email":"stev@bell.net"}],"homepage":"https://github.com/ObscuritySRL/bun-win32#readme","bugs":{"url":"https://github.com/ObscuritySRL/bun-win32/issues"},"dist":{"shasum":"12bac0f0d98d114ff5c4246b73283bd31edbe816","tarball":"https://registry.npmjs.org/@bun-win32/directml/-/directml-1.0.1.tgz","fileCount":6,"integrity":"sha512-fsT5u/LJJ6s9Wk7H6fVqR4OtCPGX+tPySzRTfiso0hG4aHtVMtyDL9iD2bfxZ50pZCjmyDZ8PKTi+9hCbPdTRQ==","signatures":[{"sig":"MEQCIAu1tSjCHUj1n6uuC6kSN/PkIaYXlOFq9eGxZe6jMPEdAiBEsEJ7HyOHgt3WYCcjJOx4PWqfslZJmy4Cq0LgZD02Tg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":10116},"main":"./index.ts","type":"module","module":"index.ts","shasum":"12bac0f0d98d114ff5c4246b73283bd31edbe816","engines":{"bun":">=1.1.0"},"exports":{".":"./index.ts"},"private":false,"scripts":{"example:directml-device-report":"bun ./example/directml-device-report.ts","example:directml-capability-observatory":"bun ./example/directml-capability-observatory.ts"},"_npmUser":{"name":"obscuritysrl","email":"stev@bell.net"},"_integrity":"sha512-fsT5u/LJJ6s9Wk7H6fVqR4OtCPGX+tPySzRTfiso0hG4aHtVMtyDL9iD2bfxZ50pZCjmyDZ8PKTi+9hCbPdTRQ==","repository":{"url":"git://github.com/ObscuritySRL/bun-win32.git","type":"git","directory":"packages/directml"},"_npmVersion":"10.8.3","description":"Zero-dependency, zero-overhead Win32 DIRECTML bindings for Bun (FFI) on Windows.","directories":{},"sideEffects":false,"_nodeVersion":"24.3.0","dependencies":{"@bun-win32/core":"1.1.4"},"_hasShrinkwrap":false,"devDependencies":{"@types/bun":"latest","@bun-win32/d3d12":"1.0.1"},"peerDependencies":{"typescript":"^5"},"_npmOperationalInternal":{"tmp":"tmp/directml_1.0.1_1781130817747_0.7564474982891303","host":"s3://npm-registry-packages-npm-production"}},"2.0.0":{"name":"@bun-win32/directml","version":"2.0.0","keywords":["bun","ffi","win32","windows","directml","bindings","typescript","dll"],"author":"Stev Peifer <stev.p@outlook.com>","license":"MIT","_id":"@bun-win32/directml@2.0.0","maintainers":[{"name":"obscuritysrl","email":"stev.p@outlook.com"}],"homepage":"https://github.com/ObscuritySRL/bun-win32#readme","bugs":{"url":"https://github.com/ObscuritySRL/bun-win32/issues"},"dist":{"shasum":"405892e8d31fbb141efcf095870ca9b461a52418","tarball":"https://registry.npmjs.org/@bun-win32/directml/-/directml-2.0.0.tgz","fileCount":6,"integrity":"sha512-JJQLd7YX6XxHu9j3Ozze1AvZ69S0jClKJGx98jrCbssj+GpgNKojtBRqA887FoGsZKmBMzr+iGo5rYTdVWsUww==","signatures":[{"sig":"MEQCIB5M7poinFIgYVnJvr20S0bIZDTiuqBCcc+b9TQaXTDvAiAuLRV2lsWIL8OVj6kLKHmxCSKjSGWAIdZ9Wf+KRT6lxA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":11392},"main":"./index.ts","type":"module","module":"index.ts","shasum":"405892e8d31fbb141efcf095870ca9b461a52418","engines":{"bun":">=1.1.0"},"exports":{".":"./index.ts"},"private":false,"scripts":{"example:directml-device-report":"bun ./example/directml-device-report.ts","example:directml-capability-observatory":"bun ./example/directml-capability-observatory.ts"},"_npmUser":{"name":"obscuritysrl","email":"stev.p@outlook.com"},"_integrity":"sha512-JJQLd7YX6XxHu9j3Ozze1AvZ69S0jClKJGx98jrCbssj+GpgNKojtBRqA887FoGsZKmBMzr+iGo5rYTdVWsUww==","repository":{"url":"git://github.com/ObscuritySRL/bun-win32.git","type":"git","directory":"packages/directml"},"_npmVersion":"10.8.3","description":"Zero-dependency, zero-overhead Win32 DIRECTML bindings for Bun (FFI) on Windows.","directories":{},"sideEffects":false,"_nodeVersion":"26.3.0","dependencies":{"@bun-win32/core":"2.0.0"},"_hasShrinkwrap":false,"devDependencies":{"@types/bun":"latest","@bun-win32/d3d12":"2.0.0"},"peerDependencies":{"typescript":"^5"},"_npmOperationalInternal":{"tmp":"tmp/directml_2.0.0_1782435295999_0.48102856315680254","host":"s3://npm-registry-packages-npm-production"}},"2.0.1":{"author":"Stev Peifer <stev.p@outlook.com>","bugs":{"url":"https://github.com/ObscuritySRL/bun-win32/issues"},"dependencies":{"@bun-win32/core":"2.0.1"},"description":"Zero-dependency, zero-overhead Win32 DIRECTML bindings for Bun (FFI) on Windows.","devDependencies":{"@bun-win32/d3d12":"2.0.1","@types/bun":"latest"},"exports":{".":"./index.ts"},"license":"MIT","module":"index.ts","name":"@bun-win32/directml","peerDependencies":{"typescript":"^5"},"private":false,"homepage":"https://github.com/ObscuritySRL/bun-win32#readme","repository":{"type":"git","url":"git://github.com/ObscuritySRL/bun-win32.git","directory":"packages/directml"},"type":"module","version":"2.0.1","main":"./index.ts","keywords":["bun","ffi","win32","windows","directml","bindings","typescript","dll"],"sideEffects":false,"engines":{"bun":">=1.1.0"},"scripts":{"example:directml-capability-observatory":"bun ./example/directml-capability-observatory.ts","example:directml-device-report":"bun ./example/directml-device-report.ts"},"_id":"@bun-win32/directml@2.0.1","_integrity":"sha512-yF/VefhfoD1EQ3TOwYzezCgWz0nj+H6JSGwW8Y847bc09rsoZCi3A0ZEByJnuAF0e8/lhmsn8d1e0TWK0FoZWw==","_nodeVersion":"26.3.0","_npmVersion":"10.8.3","shasum":"15653ea396f15d3dedc18cac05ab790fcb5e8af7","dist":{"integrity":"sha512-yF/VefhfoD1EQ3TOwYzezCgWz0nj+H6JSGwW8Y847bc09rsoZCi3A0ZEByJnuAF0e8/lhmsn8d1e0TWK0FoZWw==","shasum":"15653ea396f15d3dedc18cac05ab790fcb5e8af7","tarball":"https://registry.npmjs.org/@bun-win32/directml/-/directml-2.0.1.tgz","fileCount":6,"unpackedSize":11392,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCICWkp1oW1GcSCH/JAQ4clM4Ki87r3RuhXBvgjWDM2P2ZAiEA2bfe3dcVVMo/ChE9cg5EcXXk4lIe4uqF/BJN5+puMw0="}]},"_npmUser":{"name":"obscuritysrl","email":"stev.p@outlook.com"},"directories":{},"maintainers":[{"name":"obscuritysrl","email":"stev.p@outlook.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/directml_2.0.1_1782437755970_0.22094249502988905"},"_hasShrinkwrap":false}},"time":{"created":"2026-06-04T02:22:29.258Z","modified":"2026-06-26T01:35:56.241Z","1.0.0":"2026-06-04T02:22:29.512Z","1.0.1":"2026-06-10T22:33:37.893Z","2.0.0":"2026-06-26T00:54:56.131Z","2.0.1":"2026-06-26T01:35:56.110Z"},"bugs":{"url":"https://github.com/ObscuritySRL/bun-win32/issues"},"author":"Stev Peifer <stev.p@outlook.com>","license":"MIT","homepage":"https://github.com/ObscuritySRL/bun-win32#readme","keywords":["bun","ffi","win32","windows","directml","bindings","typescript","dll"],"repository":{"type":"git","url":"git://github.com/ObscuritySRL/bun-win32.git","directory":"packages/directml"},"description":"Zero-dependency, zero-overhead Win32 DIRECTML bindings for Bun (FFI) on Windows.","maintainers":[{"name":"obscuritysrl","email":"stev.p@outlook.com"}],"readme":"# @bun-win32/directml\n\nZero-dependency, zero-overhead Win32 DirectML bindings for [Bun](https://bun.sh) on Windows.\n\n## Overview\n\n`@bun-win32/directml` exposes the `DirectML.dll` exports using [Bun](https://bun.sh)'s FFI. It provides a single class, `DirectML`, which lazily binds native symbols on first use. You can optionally preload a subset or all symbols up-front via `Preload()`.\n\nThe bindings are strongly typed for a smooth DX in TypeScript.\n\n## Features\n\n- [Bun](https://bun.sh)-first ergonomics on Windows 10/11.\n- Direct FFI to `DirectML.dll` (vendor-neutral, Direct3D 12-backed machine-learning device creation).\n- In-source docs in `structs/DirectML.ts` with links to Microsoft Docs.\n- Lazy binding on first call; optional eager preload (`DirectML.Preload()`).\n- No wrapper overhead; calls map 1:1 to native APIs.\n- Strongly-typed Win32 aliases (see `types/DirectML.ts`).\n\n## Requirements\n\n- [Bun](https://bun.sh) runtime\n- Windows 10 or later\n- A Direct3D 12-capable adapter (DirectML is created over an `ID3D12Device`)\n\n## Installation\n\n```sh\nbun add @bun-win32/directml\n```\n\n## Quick Start\n\n```ts\nimport DirectML, { DML_CREATE_DEVICE_FLAGS, DML_FEATURE_LEVEL } from '@bun-win32/directml';\n\n// DirectML is created over an existing ID3D12Device. The d3d12 binding can\n// produce one; pass its raw pointer value (a bigint) as d3d12Device.\n//\n// IID_IDMLDevice {6dbd6437-96fd-423f-a98c-ae5e7c2a573f}\nconst iidDmlDevice = Buffer.alloc(16);\niidDmlDevice.writeUInt32LE(0x6dbd6437, 0);\niidDmlDevice.writeUInt16LE(0x96fd, 4);\niidDmlDevice.writeUInt16LE(0x423f, 6);\nBuffer.from([0xa9, 0x8c, 0xae, 0x5e, 0x7c, 0x2a, 0x57, 0x3f]).copy(iidDmlDevice, 8);\n\n// d3d12Device is the bigint pointer to a live ID3D12Device.\nconst ppDmlDevice = Buffer.alloc(8);\nconst hr = DirectML.DMLCreateDevice1(\n  d3d12Device,\n  DML_CREATE_DEVICE_FLAGS.DML_CREATE_DEVICE_FLAG_NONE,\n  DML_FEATURE_LEVEL.DML_FEATURE_LEVEL_1_0,\n  iidDmlDevice.ptr,\n  ppDmlDevice.ptr,\n);\nif (hr === 0) {\n  const dmlDeviceAddress = ppDmlDevice.readBigUInt64LE(0);\n  console.log(`IDMLDevice @ 0x${dmlDeviceAddress.toString(16)}`);\n  // Drive IDMLDevice via its COM vtable, then Release when done.\n}\n```\n\n> [!NOTE]\n> AI agents: see `AI.md` for the package binding contract and source-navigation guidance. It explains how to use the package without scanning the entire implementation.\n\n## Examples\n\nRun the included examples:\n\n```sh\n# Thorough flat-FFI diagnostic: real D3D12 -> DirectML device creation via both\n# entry points, CheckFeatureSupport, GetDeviceRemovedReason, and a verified\n# GetParentDevice round-trip back to the ID3D12Device\nbun run example:directml-device-report\n\n# Creative: an animated capability \"observatory\" that fires a real\n# DMLCreateDevice1 at every documented feature level and decodes the device's\n# true max feature level live over the IDMLDevice COM vtable\nbun run example:directml-capability-observatory\n```\n\n## Notes\n\n- Either rely on lazy binding or call `DirectML.Preload()`.\n- Windows only. Bun runtime required.\n- DirectML requires an `ID3D12Device`; the examples use the sibling `@bun-win32/d3d12` binding to create one.\n- **SAL types & naming:** nullability is in the **type** — `Optional<T>` (formally optional, SAL `_*opt_`) and `Nullable<T>` (plain `[in]`/`[out]` the docs say can be NULL), the null sentinel derived from `T` (`null` for pointers `LP*`/`P*`, `0n` for handles/by-value addresses); direction is in the **parameter name** — `_out` (`_Out_`), `_in_out` (`_Inout_`), `_In_` bare. See `AI.md` and the repo `AGENTS.md`.\n","readmeFilename":"README.md"}