mirror of
https://github.com/fumiama/gozel.git
synced 2026-06-10 19:30:25 +08:00
feat(example): impl. vadd
This commit is contained in:
31
ze/module.go
Normal file
31
ze/module.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package ze
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
|
||||
"github.com/fumiama/gozel"
|
||||
)
|
||||
|
||||
// ModuleHandle is a handle to a Level Zero module.
|
||||
type ModuleHandle gozel.ZeModuleHandle
|
||||
|
||||
// ModuleCreate creates a module from SPIR-V binary data on the given device.
|
||||
func (h ContextHandle) ModuleCreate(hDevice gozel.ZeDeviceHandle, data []byte) (
|
||||
ModuleHandle, error,
|
||||
) {
|
||||
var m gozel.ZeModuleHandle
|
||||
_, err := gozel.ZeModuleCreate(gozel.ZeContextHandle(h), hDevice, &gozel.ZeModuleDesc{
|
||||
Stype: gozel.ZE_STRUCTURE_TYPE_MODULE_DESC,
|
||||
Format: gozel.ZE_MODULE_FORMAT_IL_SPIRV,
|
||||
Inputsize: uintptr(len(data)),
|
||||
Pinputmodule: &data[0],
|
||||
}, &m, nil)
|
||||
runtime.KeepAlive(data)
|
||||
return ModuleHandle(m), err
|
||||
}
|
||||
|
||||
// Destroy destroys the module and releases its resources.
|
||||
func (h ModuleHandle) Destroy() error {
|
||||
_, err := gozel.ZeModuleDestroy(gozel.ZeModuleHandle(h))
|
||||
return err
|
||||
}
|
||||
Reference in New Issue
Block a user