render/device.go
Functions
func Adapter
func (NullDeviceHandle) Adapter() gpucontext.Adapter { return nil }
func AdapterInfo
AdapterInfo returns unknown adapter info.
func (NullDeviceHandle) AdapterInfo() gpucontext.AdapterInfo {
return gpucontext.AdapterInfo{Type: gpucontext.AdapterTypeUnknown}
}
func DefaultTextureDescriptor
DefaultTextureDescriptor returns a TextureDescriptor with sensible defaults.
Only Width, Height, and Format need to be set.
func DefaultTextureDescriptor(width, height uint32, format gputypes.TextureFormat) TextureDescriptor {
return TextureDescriptor{
Width: width,
Height: height,
Depth: 1,
MipLevelCount: 1,
SampleCount: 1,
Format: format,
Usage: TextureUsageTextureBinding | TextureUsageRenderAttachment,
}
}
func Device
Device returns nil for the null device.
func (NullDeviceHandle) Device() gpucontext.Device { return nil }
func Queue
Queue returns nil for the null device.
func (NullDeviceHandle) Queue() gpucontext.Queue { return nil }
func SurfaceFormat
SurfaceFormat returns undefined format for the null device.
func (NullDeviceHandle) SurfaceFormat() gputypes.TextureFormat {
return gputypes.TextureFormatUndefined
}
Structs
type TextureDescriptor struct
TextureDescriptor describes parameters for creating a texture.
This mirrors the WebGPU GPUTextureDescriptor specification.
type TextureDescriptor struct {
// Label is an optional debug label for the texture.
Label string
// Width is the texture width in pixels.
Width uint32
// Height is the texture height in pixels.
Height uint32
// Depth is the texture depth for 3D textures, or array layer count.
// Use 1 for regular 2D textures.
Depth uint32
// MipLevelCount is the number of mipmap levels.
// Use 1 for no mipmaps.
MipLevelCount uint32
// SampleCount is the number of samples for multisampling.
// Use 1 for no multisampling.
SampleCount uint32
// Format is the texture pixel format.
Format gputypes.TextureFormat
// Usage specifies how the texture will be used.
Usage TextureUsage
}
type DeviceCapabilities struct
DeviceCapabilities describes the capabilities of a GPU device.
Used to determine available features and limits for rendering decisions.
type DeviceCapabilities struct {
// MaxTextureSize is the maximum texture dimension supported.
MaxTextureSize uint32
// MaxBindGroups is the maximum number of bind groups.
MaxBindGroups uint32
// SupportsCompute indicates if compute shaders are supported.
SupportsCompute bool
// SupportsStorageTextures indicates if storage textures are supported.
SupportsStorageTextures bool
// VendorName is the GPU vendor name.
VendorName string
// DeviceName is the GPU device name.
DeviceName string
}
type NullDeviceHandle struct
NullDeviceHandle is a DeviceHandle that provides nil implementations.
Used for CPU-only rendering where no GPU is available.
type NullDeviceHandle struct{}
Interfaces
type Texture interface
Texture represents a GPU texture resource.
This interface wraps the underlying WebGPU texture.
type Texture interface {
// Width returns the texture width in pixels.
Width() uint32
// Height returns the texture height in pixels.
Height() uint32
// Format returns the texture pixel format.
Format() gputypes.TextureFormat
// CreateView creates a view for this texture.
CreateView() TextureView
// Destroy releases GPU resources associated with this texture.
Destroy()
}
type TextureView interface
TextureView represents a view into a texture.
Views are used to bind textures to shader stages.
type TextureView interface {
// Destroy releases resources associated with this view.
Destroy()
}
Adapter returns nil for the null device.