native

package module
v0.0.0-...-6c92dd7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 18, 2026 License: MIT Imports: 4 Imported by: 0

README

GoGPU's internal HAL init and selection system

This is a fork of GoGPU's internal HAL init and selection system.

This fork is made purely out of convenience and it is no different than the code found in the original repo.(except for the fact that i integrate the enums in gpu/types for convenience)

Documentation

Overview

Package native provides HAL backend registration for the pure Go (gogpu/wgpu) path. This is the default backend, always available without external dependencies.

Supports: Windows (Vulkan, DX12), Linux (Vulkan), macOS (Metal)

Importing this package triggers HAL backend registration via init() side effects. The renderer calls BackendInfo(api) to get the display name and variant mask, then uses wgpu.CreateInstance() which discovers the registered backends.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BackendInfo

func BackendInfo(api GraphicsAPI) (name string, mask gputypes.Backends)

BackendInfo returns the backend display name and mask for the given graphics API.

Types

type BackendType

type BackendType uint8
const (
	// BackendAuto automatically selects the best available backend.
	// Pure Go is default, Rust is opt-in with -tags rust.
	BackendAuto BackendType = iota

	// BackendNative uses pure Go WebGPU implementation (gogpu/wgpu).
	// Zero dependencies, just `go build`. Default backend.
	BackendNative

	// BackendRust uses wgpu-gpu (Rust) via go-webgpu/webgpu.
	// Maximum performance, requires wgpu-native shared library.
	BackendRust

	// BackendGo is an alias for BackendNative.
	// Provided for user convenience ("I want the Go backend").
	BackendGo = BackendNative
)

func (BackendType) String

func (b BackendType) String() string

String returns the backend name.

type GraphicsAPI

type GraphicsAPI uint8

GraphicsAPI specifies which graphics API to use for rendering. This is orthogonal to BackendType (Rust/Native implementation choice).

const (
	// GraphicsAPIAuto automatically selects the best graphics API for the platform.
	// Windows: Vulkan (default), macOS: Metal, Linux: Vulkan.
	GraphicsAPIAuto GraphicsAPI = iota

	// GraphicsAPIVulkan forces Vulkan. Available on Windows and Linux.
	GraphicsAPIVulkan

	// GraphicsAPIDX12 forces DirectX 12. Available on Windows only.
	GraphicsAPIDX12

	// GraphicsAPIMetal forces Metal. Available on macOS only.
	GraphicsAPIMetal

	// GraphicsAPIGLES forces OpenGL ES. Available on Windows and Linux.
	GraphicsAPIGLES

	// GraphicsAPISoftware forces the CPU-based software rasterizer.
	// Always available — no build tags or GPU hardware required.
	// Useful for headless rendering, CI/CD, and systems without GPU.
	GraphicsAPISoftware
)

func (GraphicsAPI) String

func (g GraphicsAPI) String() string

String returns the graphics API name.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL