Files
overlord/Overlord-Client/cmd/agent/capture/nvenc_smoke_windows.go
T

45 lines
1.0 KiB
Go
Raw Normal View History

2026-07-11 14:55:26 -05:00
//go:build windows && !no_nvenc
2026-06-06 16:08:28 -05:00
package capture
import (
"fmt"
"syscall"
"unsafe"
)
type NVENCSmokeResult struct {
Available bool `json:"available"`
DLL string `json:"dll"`
APIMajor int `json:"api_major"`
APIMinor int `json:"api_minor"`
RawAPI uint32 `json:"raw_api"`
Error string `json:"error,omitempty"`
}
func RunNVENCSmoke() NVENCSmokeResult {
result := NVENCSmokeResult{DLL: "nvEncodeAPI64.dll"}
dll := syscall.NewLazyDLL(result.DLL)
proc := dll.NewProc("NvEncodeAPIGetMaxSupportedVersion")
if err := dll.Load(); err != nil {
result.Error = err.Error()
return result
}
if err := proc.Find(); err != nil {
result.Error = err.Error()
return result
}
var raw uint32
status, _, _ := proc.Call(uintptr(unsafe.Pointer(&raw)))
if status != 0 {
result.Error = fmt.Sprintf("NvEncodeAPIGetMaxSupportedVersion failed status=%d", status)
return result
}
result.Available = true
result.RawAPI = raw
result.APIMajor = int(raw >> 4)
result.APIMinor = int(raw & 0xf)
return result
}